-first commit

This commit is contained in:
2025-11-11 12:36:06 +07:00
commit b99c214434
5683 changed files with 713336 additions and 0 deletions

50
node_modules/ioredis/built/utils/Commander.d.ts generated vendored Normal file
View File

@@ -0,0 +1,50 @@
import Command from "../Command";
import { WriteableStream } from "../types";
import RedisCommander, { ClientContext } from "./RedisCommander";
export interface CommanderOptions {
keyPrefix?: string;
showFriendlyErrorStack?: boolean;
}
declare class Commander<Context extends ClientContext = {
type: "default";
}> {
options: CommanderOptions;
/**
* @ignore
*/
scriptsSet: {};
/**
* @ignore
*/
addedBuiltinSet: Set<string>;
/**
* Return supported builtin commands
*/
getBuiltinCommands(): string[];
/**
* Create a builtin command
*/
createBuiltinCommand(commandName: string): {
string: any;
buffer: any;
};
/**
* Create add builtin command
*/
addBuiltinCommand(commandName: string): void;
/**
* Define a custom command using lua script
*/
defineCommand(name: string, definition: {
lua: string;
numberOfKeys?: number;
readOnly?: boolean;
}): void;
/**
* @ignore
*/
sendCommand(command: Command, stream?: WriteableStream, node?: unknown): unknown;
}
interface Commander<Context> extends RedisCommander<Context> {
}
export default Commander;

117
node_modules/ioredis/built/utils/Commander.js generated vendored Normal file
View File

@@ -0,0 +1,117 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const commands_1 = require("@ioredis/commands");
const autoPipelining_1 = require("../autoPipelining");
const Command_1 = require("../Command");
const Script_1 = require("../Script");
// eslint-disable-next-line @typescript-eslint/no-unused-vars
class Commander {
constructor() {
this.options = {};
/**
* @ignore
*/
this.scriptsSet = {};
/**
* @ignore
*/
this.addedBuiltinSet = new Set();
}
/**
* Return supported builtin commands
*/
getBuiltinCommands() {
return commands.slice(0);
}
/**
* Create a builtin command
*/
createBuiltinCommand(commandName) {
return {
string: generateFunction(null, commandName, "utf8"),
buffer: generateFunction(null, commandName, null),
};
}
/**
* Create add builtin command
*/
addBuiltinCommand(commandName) {
this.addedBuiltinSet.add(commandName);
this[commandName] = generateFunction(commandName, commandName, "utf8");
this[commandName + "Buffer"] = generateFunction(commandName + "Buffer", commandName, null);
}
/**
* Define a custom command using lua script
*/
defineCommand(name, definition) {
const script = new Script_1.default(definition.lua, definition.numberOfKeys, this.options.keyPrefix, definition.readOnly);
this.scriptsSet[name] = script;
this[name] = generateScriptingFunction(name, name, script, "utf8");
this[name + "Buffer"] = generateScriptingFunction(name + "Buffer", name, script, null);
}
/**
* @ignore
*/
sendCommand(command, stream, node) {
throw new Error('"sendCommand" is not implemented');
}
}
const commands = commands_1.list.filter((command) => command !== "monitor");
commands.push("sentinel");
commands.forEach(function (commandName) {
Commander.prototype[commandName] = generateFunction(commandName, commandName, "utf8");
Commander.prototype[commandName + "Buffer"] = generateFunction(commandName + "Buffer", commandName, null);
});
Commander.prototype.call = generateFunction("call", "utf8");
Commander.prototype.callBuffer = generateFunction("callBuffer", null);
// @ts-expect-error
Commander.prototype.send_command = Commander.prototype.call;
function generateFunction(functionName, _commandName, _encoding) {
if (typeof _encoding === "undefined") {
_encoding = _commandName;
_commandName = null;
}
return function (...args) {
const commandName = (_commandName || args.shift());
let callback = args[args.length - 1];
if (typeof callback === "function") {
args.pop();
}
else {
callback = undefined;
}
const options = {
errorStack: this.options.showFriendlyErrorStack ? new Error() : undefined,
keyPrefix: this.options.keyPrefix,
replyEncoding: _encoding,
};
// No auto pipeline, use regular command sending
if (!(0, autoPipelining_1.shouldUseAutoPipelining)(this, functionName, commandName)) {
return this.sendCommand(
// @ts-expect-error
new Command_1.default(commandName, args, options, callback));
}
// Create a new pipeline and make sure it's scheduled
return (0, autoPipelining_1.executeWithAutoPipelining)(this, functionName, commandName,
// @ts-expect-error
args, callback);
};
}
function generateScriptingFunction(functionName, commandName, script, encoding) {
return function (...args) {
const callback = typeof args[args.length - 1] === "function" ? args.pop() : undefined;
const options = {
replyEncoding: encoding,
};
if (this.options.showFriendlyErrorStack) {
options.errorStack = new Error();
}
// No auto pipeline, use regular command sending
if (!(0, autoPipelining_1.shouldUseAutoPipelining)(this, functionName, commandName)) {
return script.execute(this, args, options, callback);
}
// Create a new pipeline and make sure it's scheduled
return (0, autoPipelining_1.executeWithAutoPipelining)(this, functionName, commandName, args, callback);
};
}
exports.default = Commander;

8796
node_modules/ioredis/built/utils/RedisCommander.d.ts generated vendored Normal file

File diff suppressed because it is too large Load Diff

7
node_modules/ioredis/built/utils/RedisCommander.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
"use strict";
/**
* This file is generated by @ioredis/interface-generator.
* Don't edit it manually. Instead, run `npm run generate` to update
* this file.
*/
Object.defineProperty(exports, "__esModule", { value: true });

3
node_modules/ioredis/built/utils/applyMixin.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
declare type Constructor = new (...args: any[]) => void;
declare function applyMixin(derivedConstructor: Constructor, mixinConstructor: Constructor): void;
export default applyMixin;

8
node_modules/ioredis/built/utils/applyMixin.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function applyMixin(derivedConstructor, mixinConstructor) {
Object.getOwnPropertyNames(mixinConstructor.prototype).forEach((name) => {
Object.defineProperty(derivedConstructor.prototype, name, Object.getOwnPropertyDescriptor(mixinConstructor.prototype, name));
});
}
exports.default = applyMixin;

16
node_modules/ioredis/built/utils/debug.d.ts generated vendored Normal file
View File

@@ -0,0 +1,16 @@
declare const MAX_ARGUMENT_LENGTH = 200;
/**
* helper function that tried to get a string value for
* arbitrary "debug" arg
*/
declare function getStringValue(v: any): string | void;
/**
* helper function that redacts a string representation of a "debug" arg
*/
declare function genRedactedString(str: string, maxLen: number): string;
/**
* a wrapper for the `debug` module, used to generate
* "debug functions" that trim the values in their output
*/
export default function genDebugFunction(namespace: string): (...args: any[]) => void;
export { MAX_ARGUMENT_LENGTH, getStringValue, genRedactedString };

95
node_modules/ioredis/built/utils/debug.js generated vendored Normal file
View File

@@ -0,0 +1,95 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.genRedactedString = exports.getStringValue = exports.MAX_ARGUMENT_LENGTH = void 0;
const debug_1 = require("debug");
const MAX_ARGUMENT_LENGTH = 200;
exports.MAX_ARGUMENT_LENGTH = MAX_ARGUMENT_LENGTH;
const NAMESPACE_PREFIX = "ioredis";
/**
* helper function that tried to get a string value for
* arbitrary "debug" arg
*/
function getStringValue(v) {
if (v === null) {
return;
}
switch (typeof v) {
case "boolean":
return;
case "number":
return;
case "object":
if (Buffer.isBuffer(v)) {
return v.toString("hex");
}
if (Array.isArray(v)) {
return v.join(",");
}
try {
return JSON.stringify(v);
}
catch (e) {
return;
}
case "string":
return v;
}
}
exports.getStringValue = getStringValue;
/**
* helper function that redacts a string representation of a "debug" arg
*/
function genRedactedString(str, maxLen) {
const { length } = str;
return length <= maxLen
? str
: str.slice(0, maxLen) + ' ... <REDACTED full-length="' + length + '">';
}
exports.genRedactedString = genRedactedString;
/**
* a wrapper for the `debug` module, used to generate
* "debug functions" that trim the values in their output
*/
function genDebugFunction(namespace) {
const fn = (0, debug_1.default)(`${NAMESPACE_PREFIX}:${namespace}`);
function wrappedDebug(...args) {
if (!fn.enabled) {
return; // no-op
}
// we skip the first arg because that is the message
for (let i = 1; i < args.length; i++) {
const str = getStringValue(args[i]);
if (typeof str === "string" && str.length > MAX_ARGUMENT_LENGTH) {
args[i] = genRedactedString(str, MAX_ARGUMENT_LENGTH);
}
}
return fn.apply(null, args);
}
Object.defineProperties(wrappedDebug, {
namespace: {
get() {
return fn.namespace;
},
},
enabled: {
get() {
return fn.enabled;
},
},
destroy: {
get() {
return fn.destroy;
},
},
log: {
get() {
return fn.log;
},
set(l) {
fn.log = l;
},
},
});
return wrappedDebug;
}
exports.default = genDebugFunction;

124
node_modules/ioredis/built/utils/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,124 @@
/// <reference types="node" />
import { defaults, noop } from "./lodash";
import { Callback } from "../types";
import Debug from "./debug";
/**
* Convert a buffer to string, supports buffer array
*
* @example
* ```js
* const input = [Buffer.from('foo'), [Buffer.from('bar')]]
* const res = convertBufferToString(input, 'utf8')
* expect(res).to.eql(['foo', ['bar']])
* ```
*/
export declare function convertBufferToString(value: any, encoding?: BufferEncoding): any;
/**
* Convert a list of results to node-style
*
* @example
* ```js
* const input = ['a', 'b', new Error('c'), 'd']
* const output = exports.wrapMultiResult(input)
* expect(output).to.eql([[null, 'a'], [null, 'b'], [new Error('c')], [null, 'd'])
* ```
*/
export declare function wrapMultiResult(arr: unknown[] | null): unknown[][] | null;
/**
* Detect if the argument is a int
* @example
* ```js
* > isInt('123')
* true
* > isInt('123.3')
* false
* > isInt('1x')
* false
* > isInt(123)
* true
* > isInt(true)
* false
* ```
*/
export declare function isInt(value: any): value is string;
/**
* Pack an array to an Object
*
* @example
* ```js
* > packObject(['a', 'b', 'c', 'd'])
* { a: 'b', c: 'd' }
* ```
*/
export declare function packObject(array: any[]): Record<string, any>;
/**
* Return a callback with timeout
*/
export declare function timeout<T>(callback: Callback<T>, timeout: number): Callback<T>;
/**
* Convert an object to an array
* @example
* ```js
* > convertObjectToArray({ a: '1' })
* ['a', '1']
* ```
*/
export declare function convertObjectToArray<T>(obj: Record<string, T>): (string | T)[];
/**
* Convert a map to an array
* @example
* ```js
* > convertMapToArray(new Map([[1, '2']]))
* [1, '2']
* ```
*/
export declare function convertMapToArray<K, V>(map: Map<K, V>): (K | V)[];
/**
* Convert a non-string arg to a string
*/
export declare function toArg(arg: any): string;
/**
* Optimize error stack
*
* @param error actually error
* @param friendlyStack the stack that more meaningful
* @param filterPath only show stacks with the specified path
*/
export declare function optimizeErrorStack(error: Error, friendlyStack: string, filterPath: string): Error;
/**
* Parse the redis protocol url
*/
export declare function parseURL(url: string): Record<string, unknown>;
interface TLSOptions {
port: number;
host: string;
[key: string]: any;
}
/**
* Resolve TLS profile shortcut in connection options
*/
export declare function resolveTLSProfile(options: TLSOptions): TLSOptions;
/**
* Get a random element from `array`
*/
export declare function sample<T>(array: T[], from?: number): T;
/**
* Shuffle the array using the Fisher-Yates Shuffle.
* This method will mutate the original array.
*/
export declare function shuffle<T>(array: T[]): T[];
/**
* Error message for connection being disconnected
*/
export declare const CONNECTION_CLOSED_ERROR_MSG = "Connection is closed.";
export declare function zipMap<K, V>(keys: K[], values: V[]): Map<K, V>;
/**
* Retrieves cached package metadata from package.json.
*
* @internal
* @returns {Promise<{version: string} | null>} Package metadata or null if unavailable
*/
export declare function getPackageMeta(): Promise<{
version: string;
}>;
export { Debug, defaults, noop };

332
node_modules/ioredis/built/utils/index.js generated vendored Normal file
View File

@@ -0,0 +1,332 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.noop = exports.defaults = exports.Debug = exports.getPackageMeta = exports.zipMap = exports.CONNECTION_CLOSED_ERROR_MSG = exports.shuffle = exports.sample = exports.resolveTLSProfile = exports.parseURL = exports.optimizeErrorStack = exports.toArg = exports.convertMapToArray = exports.convertObjectToArray = exports.timeout = exports.packObject = exports.isInt = exports.wrapMultiResult = exports.convertBufferToString = void 0;
const fs_1 = require("fs");
const path_1 = require("path");
const url_1 = require("url");
const lodash_1 = require("./lodash");
Object.defineProperty(exports, "defaults", { enumerable: true, get: function () { return lodash_1.defaults; } });
Object.defineProperty(exports, "noop", { enumerable: true, get: function () { return lodash_1.noop; } });
const debug_1 = require("./debug");
exports.Debug = debug_1.default;
const TLSProfiles_1 = require("../constants/TLSProfiles");
/**
* Convert a buffer to string, supports buffer array
*
* @example
* ```js
* const input = [Buffer.from('foo'), [Buffer.from('bar')]]
* const res = convertBufferToString(input, 'utf8')
* expect(res).to.eql(['foo', ['bar']])
* ```
*/
function convertBufferToString(value, encoding) {
if (value instanceof Buffer) {
return value.toString(encoding);
}
if (Array.isArray(value)) {
const length = value.length;
const res = Array(length);
for (let i = 0; i < length; ++i) {
res[i] =
value[i] instanceof Buffer && encoding === "utf8"
? value[i].toString()
: convertBufferToString(value[i], encoding);
}
return res;
}
return value;
}
exports.convertBufferToString = convertBufferToString;
/**
* Convert a list of results to node-style
*
* @example
* ```js
* const input = ['a', 'b', new Error('c'), 'd']
* const output = exports.wrapMultiResult(input)
* expect(output).to.eql([[null, 'a'], [null, 'b'], [new Error('c')], [null, 'd'])
* ```
*/
function wrapMultiResult(arr) {
// When using WATCH/EXEC transactions, the EXEC will return
// a null instead of an array
if (!arr) {
return null;
}
const result = [];
const length = arr.length;
for (let i = 0; i < length; ++i) {
const item = arr[i];
if (item instanceof Error) {
result.push([item]);
}
else {
result.push([null, item]);
}
}
return result;
}
exports.wrapMultiResult = wrapMultiResult;
/**
* Detect if the argument is a int
* @example
* ```js
* > isInt('123')
* true
* > isInt('123.3')
* false
* > isInt('1x')
* false
* > isInt(123)
* true
* > isInt(true)
* false
* ```
*/
function isInt(value) {
const x = parseFloat(value);
return !isNaN(value) && (x | 0) === x;
}
exports.isInt = isInt;
/**
* Pack an array to an Object
*
* @example
* ```js
* > packObject(['a', 'b', 'c', 'd'])
* { a: 'b', c: 'd' }
* ```
*/
function packObject(array) {
const result = {};
const length = array.length;
for (let i = 1; i < length; i += 2) {
result[array[i - 1]] = array[i];
}
return result;
}
exports.packObject = packObject;
/**
* Return a callback with timeout
*/
function timeout(callback, timeout) {
let timer = null;
const run = function () {
if (timer) {
clearTimeout(timer);
timer = null;
callback.apply(this, arguments);
}
};
timer = setTimeout(run, timeout, new Error("timeout"));
return run;
}
exports.timeout = timeout;
/**
* Convert an object to an array
* @example
* ```js
* > convertObjectToArray({ a: '1' })
* ['a', '1']
* ```
*/
function convertObjectToArray(obj) {
const result = [];
const keys = Object.keys(obj); // Object.entries requires node 7+
for (let i = 0, l = keys.length; i < l; i++) {
result.push(keys[i], obj[keys[i]]);
}
return result;
}
exports.convertObjectToArray = convertObjectToArray;
/**
* Convert a map to an array
* @example
* ```js
* > convertMapToArray(new Map([[1, '2']]))
* [1, '2']
* ```
*/
function convertMapToArray(map) {
const result = [];
let pos = 0;
map.forEach(function (value, key) {
result[pos] = key;
result[pos + 1] = value;
pos += 2;
});
return result;
}
exports.convertMapToArray = convertMapToArray;
/**
* Convert a non-string arg to a string
*/
function toArg(arg) {
if (arg === null || typeof arg === "undefined") {
return "";
}
return String(arg);
}
exports.toArg = toArg;
/**
* Optimize error stack
*
* @param error actually error
* @param friendlyStack the stack that more meaningful
* @param filterPath only show stacks with the specified path
*/
function optimizeErrorStack(error, friendlyStack, filterPath) {
const stacks = friendlyStack.split("\n");
let lines = "";
let i;
for (i = 1; i < stacks.length; ++i) {
if (stacks[i].indexOf(filterPath) === -1) {
break;
}
}
for (let j = i; j < stacks.length; ++j) {
lines += "\n" + stacks[j];
}
if (error.stack) {
const pos = error.stack.indexOf("\n");
error.stack = error.stack.slice(0, pos) + lines;
}
return error;
}
exports.optimizeErrorStack = optimizeErrorStack;
/**
* Parse the redis protocol url
*/
function parseURL(url) {
if (isInt(url)) {
return { port: url };
}
let parsed = (0, url_1.parse)(url, true, true);
if (!parsed.slashes && url[0] !== "/") {
url = "//" + url;
parsed = (0, url_1.parse)(url, true, true);
}
const options = parsed.query || {};
const result = {};
if (parsed.auth) {
const index = parsed.auth.indexOf(":");
result.username = index === -1 ? parsed.auth : parsed.auth.slice(0, index);
result.password = index === -1 ? "" : parsed.auth.slice(index + 1);
}
if (parsed.pathname) {
if (parsed.protocol === "redis:" || parsed.protocol === "rediss:") {
if (parsed.pathname.length > 1) {
result.db = parsed.pathname.slice(1);
}
}
else {
result.path = parsed.pathname;
}
}
if (parsed.host) {
result.host = parsed.hostname;
}
if (parsed.port) {
result.port = parsed.port;
}
if (typeof options.family === "string") {
const intFamily = Number.parseInt(options.family, 10);
if (!Number.isNaN(intFamily)) {
result.family = intFamily;
}
}
(0, lodash_1.defaults)(result, options);
return result;
}
exports.parseURL = parseURL;
/**
* Resolve TLS profile shortcut in connection options
*/
function resolveTLSProfile(options) {
let tls = options === null || options === void 0 ? void 0 : options.tls;
if (typeof tls === "string")
tls = { profile: tls };
const profile = TLSProfiles_1.default[tls === null || tls === void 0 ? void 0 : tls.profile];
if (profile) {
tls = Object.assign({}, profile, tls);
delete tls.profile;
options = Object.assign({}, options, { tls });
}
return options;
}
exports.resolveTLSProfile = resolveTLSProfile;
/**
* Get a random element from `array`
*/
function sample(array, from = 0) {
const length = array.length;
if (from >= length) {
return null;
}
return array[from + Math.floor(Math.random() * (length - from))];
}
exports.sample = sample;
/**
* Shuffle the array using the Fisher-Yates Shuffle.
* This method will mutate the original array.
*/
function shuffle(array) {
let counter = array.length;
// While there are elements in the array
while (counter > 0) {
// Pick a random index
const index = Math.floor(Math.random() * counter);
// Decrease counter by 1
counter--;
// And swap the last element with it
[array[counter], array[index]] = [array[index], array[counter]];
}
return array;
}
exports.shuffle = shuffle;
/**
* Error message for connection being disconnected
*/
exports.CONNECTION_CLOSED_ERROR_MSG = "Connection is closed.";
function zipMap(keys, values) {
const map = new Map();
keys.forEach((key, index) => {
map.set(key, values[index]);
});
return map;
}
exports.zipMap = zipMap;
/**
* Memoized package metadata to avoid repeated file system reads.
*
* @internal
*/
let cachedPackageMeta = null;
/**
* Retrieves cached package metadata from package.json.
*
* @internal
* @returns {Promise<{version: string} | null>} Package metadata or null if unavailable
*/
async function getPackageMeta() {
if (cachedPackageMeta) {
return cachedPackageMeta;
}
try {
const filePath = (0, path_1.resolve)(__dirname, "..", "..", "package.json");
const data = await fs_1.promises.readFile(filePath, "utf8");
const parsed = JSON.parse(data);
cachedPackageMeta = {
version: parsed.version,
};
return cachedPackageMeta;
}
catch (err) {
cachedPackageMeta = {
version: "error-fetching-version",
};
return cachedPackageMeta;
}
}
exports.getPackageMeta = getPackageMeta;

4
node_modules/ioredis/built/utils/lodash.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import defaults = require("lodash.defaults");
import isArguments = require("lodash.isarguments");
export declare function noop(): void;
export { defaults, isArguments };

9
node_modules/ioredis/built/utils/lodash.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isArguments = exports.defaults = exports.noop = void 0;
const defaults = require("lodash.defaults");
exports.defaults = defaults;
const isArguments = require("lodash.isarguments");
exports.isArguments = isArguments;
function noop() { }
exports.noop = noop;