@nmakarov/cli-toolkit 0.18.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/params.cjs CHANGED
@@ -364,7 +364,7 @@ var Params = class _Params {
364
364
  throw new ParamError(`default value "${defValObj.value}" type mismatch`);
365
365
  }
366
366
  type = type.default(defValObj.value);
367
- } else if (str.match(/required/)) {
367
+ } else if (str.match(/\s*required\s*/)) {
368
368
  type = type.required();
369
369
  } else {
370
370
  type = type.optional();
@@ -440,6 +440,8 @@ var Params = class _Params {
440
440
  /**
441
441
  * Get all parameters from definitions (main script).
442
442
  * Same as getAllForModule("script", defs). Processes left-to-right for cross-parameter references.
443
+ * Libraries should use {@link getAllForModule} with an explicit module name (or {@link runWithModule}
444
+ * around {@link get}) so --showUsedParams groups usage correctly.
443
445
  */
444
446
  getAll(defs) {
445
447
  return this.getAllForModule("script", defs);
@@ -476,6 +478,19 @@ var Params = class _Params {
476
478
  this._currentModule = prev;
477
479
  }
478
480
  }
481
+ /**
482
+ * Run a callback with {@link _currentModule} set so single {@link get} calls are tracked
483
+ * under the same module (for --showUsedParams / getFiguredByModule).
484
+ */
485
+ runWithModule(moduleName, fn) {
486
+ const prev = this._currentModule;
487
+ this._currentModule = moduleName;
488
+ try {
489
+ return fn();
490
+ } finally {
491
+ this._currentModule = prev;
492
+ }
493
+ }
479
494
  /**
480
495
  * Infer module name from call stack: first caller outside params/index gives path like .../src/<moduleName>/...
481
496
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/params.ts","../src/params/index.ts","../src/errors.ts","../src/params/custom-types.ts"],"sourcesContent":["// Re-export everything from the params module directory\nexport * from \"./params/index.js\";\n\n","import Joi from \"joi\";\nimport { ParamError } from \"../errors\";\nimport { joiEdateType, joiStringArrayType } from \"./custom-types\";\n\n/**\n * Parameter definition types\n */\nexport type ParamDefinition = \n | string \n | Joi.Schema \n | { \n type?: string | Joi.Schema; \n values?: any[]; \n [key: string]: any; \n };\n\nexport type ParamGetter = (key: string, definition?: any) => any;\nexport type ParamSetter = (key: string, value: any) => boolean;\n\n/**\n * Args instance interface\n */\nexport interface ArgsInstance {\n get(key: string): any;\n}\n\n/**\n * Params constructor options\n */\nexport interface ParamsOptions {\n [key: string]: any;\n}\n\n/** Origin of a parameter value: CLI args, env var, config file, options/overrides, or definition default */\nexport type ParamSource = \"cli\" | \"env\" | \"config\" | \"options\" | \"default\";\n\n/**\n * Tracked parameter information for --stopAfter=init and --showUsedParams\n */\ninterface TrackedParam {\n key: string;\n definition: ParamDefinition;\n value: any;\n source: ParamSource;\n module: string;\n}\n\n/**\n * Params class for parameter validation and type checking\n * Built on top of Args library with Joi validation\n */\nexport class Params {\n private context: any; // Partial context during initialization\n private params: Record<string, any> = {};\n private paramSources: Record<string, ParamSource> = {};\n private definitions: Record<string, any> = {};\n private args: ArgsInstance;\n private paramSetters: ParamSetter[] = [];\n private paramGetters: ParamGetter[] = [];\n private trackedParams: TrackedParam[] = [];\n private _currentModule: string = \"script\";\n /** Resolved early in constructor so cleanup does not read params lazily */\n private _showUsedParams: boolean = false;\n\n constructor(context: any, options: ParamsOptions = {}) {\n // Context might be partial during initialization\n this.context = context;\n this.args = context.args;\n\n // Apply initial configuration\n if (Object.keys(options).length > 0) {\n this.configure(options);\n }\n\n // Resolve showUsedParams early (fail fast, consistent with \"params figured in init\")\n this._showUsedParams = this.get(\"showUsedParams\", \"boolean default false\");\n\n if (context && typeof context.registerCleanup === \"function\") {\n context.registerCleanup((ctx: any) => {\n if (!ctx.params.getShowUsedParams()) return;\n const byModule = ctx.params.getFiguredByModule();\n const modules = Object.keys(byModule).sort();\n if (modules.length === 0) return;\n const logger = ctx.logger;\n logger.debug(\"[Params]: list of used params:\");\n type Entry = { value: any; source: ParamSource };\n if (typeof logger.highlight !== \"function\") {\n for (const mod of modules) {\n logger.debug(` [${mod}]`);\n for (const [key, entry] of Object.entries(byModule[mod]) as [string, Entry][]) {\n logger.debug(` ${key}: ${JSON.stringify(entry.value)} (${entry.source})`);\n }\n }\n return;\n }\n for (const mod of modules) {\n logger.debug(` [${mod}]`);\n for (const [key, entry] of Object.entries(byModule[mod]) as [string, Entry][]) {\n const valueStr = JSON.stringify(entry.value);\n const display = entry.source === \"default\" ? valueStr : logger.highlight(valueStr);\n logger.debug(` ${key}: ${display} (${entry.source})`);\n }\n }\n });\n }\n }\n\n /** Whether --showUsedParams was requested (resolved in constructor). */\n getShowUsedParams(): boolean {\n return this._showUsedParams;\n }\n\n /**\n * Configure parameters\n * Only parameters present in options are updated\n */\n configure(options: ParamsOptions): void {\n for (const [k, v] of Object.entries(options)) {\n // TODO: opt values might be an object with definitions in it, so perhaps `this.set` should be used\n this.params[k] = v;\n }\n }\n\n /**\n * Initialize Params from context and CLI parameters\n * Note: Params is special - it's initialized early with partial context\n */\n static init(context: any, options?: ParamsOptions): Params {\n return new Params(context, options || {});\n }\n\n /**\n * Track a parameter request for --stopAfter=init and --showUsedParams\n */\n private trackParam(key: string, definition: ParamDefinition, value: any, source: ParamSource, moduleName?: string): void {\n this.trackedParams.push({\n key,\n definition,\n value,\n source,\n module: moduleName ?? this._currentModule,\n });\n }\n\n /**\n * Get all tracked parameters (for --stopAfter=init)\n */\n getTrackedParams(): TrackedParam[] {\n return [...this.trackedParams];\n }\n\n /**\n * Get all figured parameters as a record (flat, last occurrence per key)\n * Returns all parameters that were collected during initialization,\n * whether from CLI args, options, or defaults\n */\n getAllFigured(): Record<string, { value: any; source: ParamSource }> {\n const result: Record<string, { value: any; source: ParamSource }> = {};\n for (const param of this.trackedParams) {\n result[param.key] = {\n value: param.value,\n source: param.source,\n };\n }\n return result;\n }\n\n /**\n * Get figured parameters grouped by module name.\n * Same param can appear in multiple modules (e.g. source, resource).\n */\n getFiguredByModule(): Record<string, Record<string, { value: any; source: ParamSource }>> {\n const byModule: Record<string, Record<string, { value: any; source: ParamSource }>> = {};\n for (const param of this.trackedParams) {\n const mod = param.module;\n if (!byModule[mod]) byModule[mod] = {};\n byModule[mod][param.key] = { value: param.value, source: param.source };\n }\n return byModule;\n }\n\n /**\n * Clear tracked parameters\n */\n clearTrackedParams(): void {\n this.trackedParams = [];\n }\n\n /**\n * Assign a parameter definition\n */\n assignDefinition(key: string, definition?: ParamDefinition): any {\n if (this.definitions[key] && !definition) {\n return this.definitions[key];\n }\n\n let type: Joi.Schema;\n if (!definition) {\n type = Joi.string();\n } else if (Joi.isSchema(definition)) {\n type = definition;\n } else if (Joi.isSchema(definition.type)) {\n type = definition.type;\n } else if (typeof definition === \"string\") {\n type = this.toJoi(definition);\n } else if (typeof definition.type === \"string\") {\n type = this.toJoi(definition.type);\n } else if (!definition.type) {\n type = Joi.string();\n } else {\n type = Joi.string();\n }\n\n if (!this.definitions[key]) {\n this.definitions[key] = {};\n }\n this.definitions[key].type = type;\n\n if (definition && definition.values) {\n if (Array.isArray(definition.values)) {\n this.definitions[key].values = definition.values;\n }\n }\n return this.definitions[key];\n }\n\n /**\n * Convert string definition to Joi schema\n */\n toJoi(str: string): Joi.Schema {\n let type: Joi.Schema;\n \n if (str.match(/^string|^text/i)) {\n type = Joi.string();\n } else if (str.match(/^number|^integer|^int/i)) {\n type = Joi.number();\n } else if (str.match(/^boolean|^bool/i)) {\n type = Joi.boolean();\n } else if (str.match(/^date/i)) {\n type = Joi.custom(joiEdateType);\n } else if (str.match(/^duration/i)) {\n type = Joi.string().isoDuration();\n } else if (str.match(/^array/i)) {\n let elementTypes = \"string\";\n const tmp = str.match(/\\((.*)\\)/);\n if (tmp && tmp[1].match(/string/i)) {\n elementTypes = \"string\";\n } else if (tmp && tmp[1].match(/number|integer|int/i)) {\n elementTypes = \"number\";\n } else if (tmp && tmp[1].match(/boolean|bool/i)) {\n elementTypes = \"boolean\";\n }\n type = Joi.custom(joiStringArrayType(elementTypes));\n } else {\n type = Joi.string();\n }\n\n // Handle default values\n const regexForDefault = /\\bdefault\\s+([^\\s]+)/;\n const matchForDefault = str.match(regexForDefault);\n if (matchForDefault) {\n const defValObj = type.validate(matchForDefault[1]);\n if (defValObj.error) {\n throw new ParamError(`default value \"${defValObj.value}\" type mismatch`);\n }\n // Joi's default() automatically allows undefined and applies the default\n type = type.default(defValObj.value);\n } else if (str.match(/required/)) {\n type = type.required();\n } else {\n // If not required and no default, make it optional\n type = type.optional();\n }\n\n return type;\n }\n\n /**\n * Validate a value against a definition\n */\n validate(key: string, val: any, def: any): any {\n // Convert null to undefined so Joi defaults can be applied\n // Joi's .default() only works with undefined, not null\n const normalizedVal = val === null ? undefined : val;\n \n // Pass current params as context to support cross-parameter references (e.g., @startTime+2h)\n // Use abortEarly: false to get all errors, and allowUnknown: false for strict validation\n const { value, error } = def.type.validate(normalizedVal, { \n context: { params: this.params },\n abortEarly: false,\n allowUnknown: false,\n });\n if (error) {\n const errs = error.details.map((el: any) => el.message).join(\", \");\n throw new ParamError(`\"${key}\" validation error: ${errs}`);\n }\n return value;\n }\n\n /**\n * Get a parameter value with validation\n */\n get(key: string, definition?: ParamDefinition): any {\n const def = this.assignDefinition(key, definition);\n let valFromGetters: any = undefined;\n \n if (def.volatile || true) {\n valFromGetters = this.runAllRegisteredGetters(key);\n }\n \n // Always call args.get() to mark the key as used, even if it doesn't exist\n const valFromArgs = this.args.get(key);\n const valFromParams = this.params[key];\n\n let source: ParamSource = \"default\";\n let value: any;\n\n if (valFromGetters !== undefined && valFromGetters !== null) {\n value = this.validate(key, valFromGetters, def);\n source = \"options\";\n } else if (valFromArgs !== undefined && valFromArgs !== null) {\n value = this.validate(key, valFromArgs, def);\n const argsSource = (this.args as { getSource?(k: string): string }).getSource?.(key);\n if (argsSource === \"overrides\") source = \"options\";\n else if (argsSource === \"cli\" || argsSource === \"env\" || argsSource === \"config\") source = argsSource;\n else if (argsSource === \"default\") source = \"default\";\n else source = \"cli\";\n } else if (valFromParams !== undefined && valFromParams !== null) {\n value = this.validate(key, valFromParams, def);\n source = this.paramSources[key] ?? \"options\";\n } else {\n value = this.validate(key, undefined, def);\n source = \"default\";\n }\n\n this.paramSources[key] = source;\n // Track parameter for --stopAfter=init and --showUsedParams\n this.trackParam(key, definition || \"string\", value, source);\n\n if (value !== undefined && def.values && !def.values.includes(value)) {\n throw new ParamError(`key ${key} should be one of ${def.values}`);\n }\n return value;\n }\n\n /**\n * Set a parameter value with validation\n */\n set(key: string, val: any, definition?: ParamDefinition): void {\n // TODO: check if there's a test for this:\n if (val && val.type && val.value) {\n definition = val;\n val = val.value;\n }\n const def = this.assignDefinition(key, definition);\n\n if (!this.runAllRegisteredSetters(key, val)) {\n this.params[key] = val;\n }\n }\n\n /**\n * Get all parameters from definitions (main script).\n * Same as getAllForModule(\"script\", defs). Processes left-to-right for cross-parameter references.\n */\n getAll(defs: Record<string, ParamDefinition>): Record<string, any> {\n return this.getAllForModule(\"script\", defs);\n }\n\n /**\n * Get all parameters from definitions for a given module name.\n * Figured params are grouped by module when using --showUsedParams.\n * Processes parameters left-to-right to support cross-parameter references.\n * If moduleName is omitted, it is inferred from the caller's file path (directory name under src/).\n */\n getAllForModule(moduleNameOrDefs: string | Record<string, ParamDefinition>, defs?: Record<string, ParamDefinition>): Record<string, any> {\n let moduleName: string;\n let definitions: Record<string, ParamDefinition>;\n if (defs !== undefined) {\n moduleName = moduleNameOrDefs as string;\n definitions = defs;\n } else {\n definitions = moduleNameOrDefs as Record<string, ParamDefinition>;\n moduleName = this._inferModuleNameFromStack();\n }\n const prev = this._currentModule;\n this._currentModule = moduleName;\n try {\n const res: Record<string, any> = {};\n for (const [k, def] of Object.entries(definitions)) {\n const value = this.get(k, def);\n res[k] = value;\n if (value !== undefined) {\n this.params[k] = value;\n }\n }\n return res;\n } finally {\n this._currentModule = prev;\n }\n }\n\n /**\n * Infer module name from call stack: first caller outside params/index gives path like .../src/<moduleName>/...\n */\n private _inferModuleNameFromStack(): string {\n const stack = new Error().stack;\n if (!stack) return \"script\";\n const lines = stack.split(\"\\n\");\n const paramsIndexPath = \"params\" + (typeof process !== \"undefined\" && process.platform === \"win32\" ? \"\\\\\" : \"/\") + \"index.\";\n for (const line of lines) {\n const parenMatch = line.match(/\\(([^)]+)\\)/);\n if (!parenMatch) continue;\n const parts = parenMatch[1].split(\":\");\n if (parts.length < 3) continue;\n const path = parts.slice(0, -2).join(\":\").replace(/^file:\\/\\//, \"\");\n if (!path || path.includes(paramsIndexPath)) continue;\n const srcMatch = path.match(/[/\\\\]src[/\\\\]([^/\\\\]+)(?:[/\\\\]|$)/);\n if (srcMatch) return srcMatch[1];\n }\n return \"script\";\n }\n\n /**\n * Run all registered getters for a key\n */\n runAllRegisteredGetters(key: string): any {\n let val: any = undefined;\n for (const getter of this.paramGetters) {\n val = getter(key, this.definitions[key]);\n if (val !== undefined && val !== null) {\n break;\n }\n }\n return val;\n }\n\n /**\n * Run all registered setters for a key\n */\n runAllRegisteredSetters(key: string, value: any): boolean {\n let setterUsed: boolean = false;\n for (const setter of this.paramSetters) {\n setterUsed = setter(key, value);\n if (setterUsed) {\n break;\n }\n }\n return setterUsed;\n }\n\n /**\n * Register a parameter getter\n */\n registerParamGetter(fn: ParamGetter): void {\n this.paramGetters.push(fn);\n }\n\n /**\n * Register a parameter setter\n */\n registerParamSetter(fn: ParamSetter): void {\n this.paramSetters.push(fn);\n }\n}\n\n// Export custom types for external use\nexport { joiEdateType, joiStringArrayType };\n\n","/**\n * Error classes for the CLI toolkit\n */\n\nexport class FrameworkError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"FrameworkError\";\n }\n}\n\nexport class ParamError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"ParamError\";\n }\n}\n\nexport class InitError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"InitError\";\n }\n}\n\nexport class CriticalRequestError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"CriticalRequestError\";\n }\n}\n\nexport class ControlFlowError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ControlFlowError\";\n }\n}\n\nexport class HttpClientError extends FrameworkError {\n constructor(message: string, public readonly cause?: Error) {\n super(message);\n this.name = \"HttpClientError\";\n }\n}\n\nexport class FileDatabaseError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"FileDatabaseError\";\n }\n}\n\n","import Joi from \"joi\";\nimport { ParamError } from \"../errors.js\";\n\n/**\n * Custom Joi type for enhanced date parsing with relative time support\n * Supports:\n * - ISO8601 strings: \"2025-01-01T01:01:01Z\"\n * - Relative time: \"-2h\", \"+1d\", \"now\"\n * - Cross-parameter references: \"@startTime+2h\", \"@endDate-30m\"\n * \n * Internal representation: UTC ISO8601 string (YYYY-MM-DDTHH:mm:ssZ)\n * \n * @param value - Date value to parse\n * @param helpers - Joi helpers (includes context with other params)\n * @returns ISO8601 string in UTC timezone\n */\nexport const joiEdateType = (value: any, helpers: Joi.CustomHelpers): string => {\n // If value is already a string in ISO format, validate and return\n if (typeof value === \"string\" && /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?Z$/.test(value)) {\n const testDate = new Date(value);\n if (!isNaN(testDate.getTime())) {\n return value;\n }\n }\n\n // If value is a Date object, convert to ISO string\n if (value instanceof Date) {\n return value.toISOString();\n }\n\n // If value is not a string, try to convert it\n if (typeof value !== \"string\") {\n value = String(value);\n }\n\n // Handle special keyword \"now\"\n if (value.toLowerCase() === \"now\") {\n return new Date().toISOString();\n }\n\n // Check for cross-parameter reference with relative time: @paramName+2h, @paramName-30m\n const referenceRegex = /^@(\\w+)([+-]\\d+[smhdwy])$/i;\n const referenceMatch = value.match(referenceRegex);\n \n if (referenceMatch) {\n const [, paramName, relativeExpr] = referenceMatch;\n \n // Get the referenced parameter from context (if available via helpers.state.ancestors)\n // For now, we'll use helpers.prefs.context which Joi provides\n const context = (helpers as any).prefs?.context;\n \n if (!context || !context.params) {\n throw new ParamError(`Cannot resolve cross-parameter reference @${paramName}: context not available. Ensure parameters are processed with proper context.`);\n }\n\n const referencedValue = context.params[paramName];\n \n if (referencedValue === undefined || referencedValue === null) {\n throw new ParamError(`Cannot resolve @${paramName}: parameter \"${paramName}\" is not defined or has no value. Parameters are evaluated left-to-right.`);\n }\n\n // Referenced value should be an ISO string or Date\n let referenceDate: Date;\n if (referencedValue instanceof Date) {\n referenceDate = referencedValue;\n } else if (typeof referencedValue === \"string\") {\n referenceDate = new Date(referencedValue);\n if (isNaN(referenceDate.getTime())) {\n throw new ParamError(`Referenced parameter @${paramName} has invalid date value: ${referencedValue}`);\n }\n } else {\n throw new ParamError(`Referenced parameter @${paramName} is not a valid date type (found: ${typeof referencedValue})`);\n }\n\n // Parse the relative expression and apply to reference date\n const relativeMatch = relativeExpr.match(/^([+-])(\\d+)([smhdwy])$/i);\n if (!relativeMatch) {\n throw new ParamError(`Invalid relative time expression in @${paramName}${relativeExpr}`);\n }\n\n const [, sign, amount, unit] = relativeMatch;\n const offset = calculateTimeOffset(parseInt(amount, 10), unit, sign);\n const resultDate = new Date(referenceDate.getTime() + offset);\n \n return resultDate.toISOString();\n }\n\n // Check for relative time expressions like \"-2h\", \"+1d\", \"-30m\", etc.\n const relativeTimeRegex = /^([+-])(\\d+)([smhdwy])$/i;\n const relativeMatch = value.match(relativeTimeRegex);\n \n if (relativeMatch) {\n const [, sign, amount, unit] = relativeMatch;\n const numAmount = parseInt(amount, 10);\n \n if (isNaN(numAmount)) {\n throw new ParamError(`Invalid relative time amount: ${amount}`);\n }\n\n const offset = calculateTimeOffset(numAmount, unit, sign);\n const resultDate = new Date(Date.now() + offset);\n \n return resultDate.toISOString();\n }\n\n // Try to parse as a regular date string\n const parsedDate = new Date(value);\n \n // Check if the parsed date is valid\n if (isNaN(parsedDate.getTime())) {\n throw new ParamError(`Invalid date format: ${value}. Expected a valid date string, \"now\", relative time expression (e.g., \"-2h\", \"+1d\"), or cross-parameter reference (e.g., \"@startTime+2h\")`);\n }\n\n return parsedDate.toISOString();\n};\n\n/**\n * Calculate time offset in milliseconds\n */\nfunction calculateTimeOffset(amount: number, unit: string, sign: string): number {\n let multiplier = 1;\n \n // Convert to milliseconds based on unit\n switch (unit.toLowerCase()) {\n case \"s\": // seconds\n multiplier = 1000;\n break;\n case \"m\": // minutes\n multiplier = 60 * 1000;\n break;\n case \"h\": // hours\n multiplier = 60 * 60 * 1000;\n break;\n case \"d\": // days\n multiplier = 24 * 60 * 60 * 1000;\n break;\n case \"w\": // weeks\n multiplier = 7 * 24 * 60 * 60 * 1000;\n break;\n case \"y\": // years (approximate)\n multiplier = 365 * 24 * 60 * 60 * 1000;\n break;\n default:\n throw new ParamError(`Invalid time unit: ${unit}. Supported units: s, m, h, d, w, y`);\n }\n\n return sign === \"+\" ? amount * multiplier : -amount * multiplier;\n}\n\n/**\n * Custom Joi type for string array parsing\n * Converts comma-separated strings to typed arrays\n */\nexport const joiStringArrayType = (type: string) => (value: any, helpers: Joi.CustomHelpers): any[] => {\n if (value === undefined || typeof value === \"function\") {\n return [];\n }\n \n const arr = value.split(/,\\s*/).map((el: string) => {\n if (type === \"number\") {\n const v = parseInt(el, 10);\n if (isNaN(v)) {\n throw new ParamError(`array element \"${el}\" should be numeric`);\n }\n return v;\n } else if (type === \"boolean\") {\n const v = el.match(/true|t|yes|1/i) ? true :\n el.match(/false|f|no|0/i) ? false : null;\n if (v === null) {\n throw new ParamError(`array element \"${el}\" should be boolean`);\n }\n return v;\n } else if (type === \"string\") {\n return el;\n } else {\n throw new ParamError(`unknown type \"${type}\" for array elements`);\n }\n });\n \n return arr;\n};\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAgB;;;ACIT,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACtC,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,aAAN,cAAyB,eAAe;AAAA,EAC3C,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;;;ACAO,IAAM,eAAe,CAAC,OA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,YAAM,QAAQ,WAAW,CAAC,EAAE,MAAM,GAAG;AACrC,UAAI,MAAM,SAAS,EAAG;AACtB,YAAM,OAAO,MAAM,MAAM,GAAG,EAAE,EAAE,KAAK,GAAG,EAAE,QAAQ,cAAc,EAAE;AAClE,UAAI,CAAC,QAAQ,KAAK,SAAS,eAAe,EAAG;AAC7C,YAAM,WAAW,KAAK,MAAM,mCAAmC;AAC/D,UAAI,SAAU,QAAO,SAAS,CAAC;AAAA,IACnC;AACA,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAKA,wBAAwB,KAAkB;AACtC,QAAI,MAAW;AACf,eAAW,UAAU,KAAK,cAAc;AACpC,YAAM,OAAO,KAAK,KAAK,YAAY,GAAG,CAAC;AACvC,UAAI,QAAQ,UAAa,QAAQ,MAAM;AACnC;AAAA,MACJ;AAAA,IACJ;AACA,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAKA,wBAAwB,KAAa,OAAqB;AACtD,QAAI,aAAsB;AAC1B,eAAW,UAAU,KAAK,cAAc;AACpC,mBAAa,OAAO,KAAK,KAAK;AAC9B,UAAI,YAAY;AACZ;AAAA,MACJ;AAAA,IACJ;AACA,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAKA,oBAAoB,IAAuB;AACvC,SAAK,aAAa,KAAK,EAAE;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA,EAKA,oBAAoB,IAAuB;AACvC,SAAK,aAAa,KAAK,EAAE;AAAA,EAC7B;AACJ;","names":["relativeMatch","Joi"]}
1
+ {"version":3,"sources":["../src/params.ts","../src/params/index.ts","../src/errors.ts","../src/params/custom-types.ts"],"sourcesContent":["// Re-export everything from the params module directory\nexport * from \"./params/index.js\";\n\n","import Joi from \"joi\";\nimport { ParamError } from \"../errors\";\nimport { joiEdateType, joiStringArrayType } from \"./custom-types\";\n\n/**\n * Parameter definition types\n */\nexport type ParamDefinition = \n | string \n | Joi.Schema \n | { \n type?: string | Joi.Schema; \n values?: any[]; \n [key: string]: any; \n };\n\nexport type ParamGetter = (key: string, definition?: any) => any;\nexport type ParamSetter = (key: string, value: any) => boolean;\n\n/**\n * Args instance interface\n */\nexport interface ArgsInstance {\n get(key: string): any;\n}\n\n/**\n * Params constructor options\n */\nexport interface ParamsOptions {\n [key: string]: any;\n}\n\n/** Origin of a parameter value: CLI args, env var, config file, options/overrides, or definition default */\nexport type ParamSource = \"cli\" | \"env\" | \"config\" | \"options\" | \"default\";\n\n/**\n * Tracked parameter information for --stopAfter=init and --showUsedParams\n */\ninterface TrackedParam {\n key: string;\n definition: ParamDefinition;\n value: any;\n source: ParamSource;\n module: string;\n}\n\n/**\n * Params class for parameter validation and type checking\n * Built on top of Args library with Joi validation\n */\nexport class Params {\n private context: any; // Partial context during initialization\n private params: Record<string, any> = {};\n private paramSources: Record<string, ParamSource> = {};\n private definitions: Record<string, any> = {};\n private args: ArgsInstance;\n private paramSetters: ParamSetter[] = [];\n private paramGetters: ParamGetter[] = [];\n private trackedParams: TrackedParam[] = [];\n private _currentModule: string = \"script\";\n /** Resolved early in constructor so cleanup does not read params lazily */\n private _showUsedParams: boolean = false;\n\n constructor(context: any, options: ParamsOptions = {}) {\n // Context might be partial during initialization\n this.context = context;\n this.args = context.args;\n\n // Apply initial configuration\n if (Object.keys(options).length > 0) {\n this.configure(options);\n }\n\n // Resolve showUsedParams early (fail fast, consistent with \"params figured in init\")\n this._showUsedParams = this.get(\"showUsedParams\", \"boolean default false\");\n\n if (context && typeof context.registerCleanup === \"function\") {\n context.registerCleanup((ctx: any) => {\n if (!ctx.params.getShowUsedParams()) return;\n const byModule = ctx.params.getFiguredByModule();\n const modules = Object.keys(byModule).sort();\n if (modules.length === 0) return;\n const logger = ctx.logger;\n logger.debug(\"[Params]: list of used params:\");\n type Entry = { value: any; source: ParamSource };\n if (typeof logger.highlight !== \"function\") {\n for (const mod of modules) {\n logger.debug(` [${mod}]`);\n for (const [key, entry] of Object.entries(byModule[mod]) as [string, Entry][]) {\n logger.debug(` ${key}: ${JSON.stringify(entry.value)} (${entry.source})`);\n }\n }\n return;\n }\n for (const mod of modules) {\n logger.debug(` [${mod}]`);\n for (const [key, entry] of Object.entries(byModule[mod]) as [string, Entry][]) {\n const valueStr = JSON.stringify(entry.value);\n const display = entry.source === \"default\" ? valueStr : logger.highlight(valueStr);\n logger.debug(` ${key}: ${display} (${entry.source})`);\n }\n }\n });\n }\n }\n\n /** Whether --showUsedParams was requested (resolved in constructor). */\n getShowUsedParams(): boolean {\n return this._showUsedParams;\n }\n\n /**\n * Configure parameters\n * Only parameters present in options are updated\n */\n configure(options: ParamsOptions): void {\n for (const [k, v] of Object.entries(options)) {\n // TODO: opt values might be an object with definitions in it, so perhaps `this.set` should be used\n this.params[k] = v;\n }\n }\n\n /**\n * Initialize Params from context and CLI parameters\n * Note: Params is special - it's initialized early with partial context\n */\n static init(context: any, options?: ParamsOptions): Params {\n return new Params(context, options || {});\n }\n\n /**\n * Track a parameter request for --stopAfter=init and --showUsedParams\n */\n private trackParam(key: string, definition: ParamDefinition, value: any, source: ParamSource, moduleName?: string): void {\n this.trackedParams.push({\n key,\n definition,\n value,\n source,\n module: moduleName ?? this._currentModule,\n });\n }\n\n /**\n * Get all tracked parameters (for --stopAfter=init)\n */\n getTrackedParams(): TrackedParam[] {\n return [...this.trackedParams];\n }\n\n /**\n * Get all figured parameters as a record (flat, last occurrence per key)\n * Returns all parameters that were collected during initialization,\n * whether from CLI args, options, or defaults\n */\n getAllFigured(): Record<string, { value: any; source: ParamSource }> {\n const result: Record<string, { value: any; source: ParamSource }> = {};\n for (const param of this.trackedParams) {\n result[param.key] = {\n value: param.value,\n source: param.source,\n };\n }\n return result;\n }\n\n /**\n * Get figured parameters grouped by module name.\n * Same param can appear in multiple modules (e.g. source, resource).\n */\n getFiguredByModule(): Record<string, Record<string, { value: any; source: ParamSource }>> {\n const byModule: Record<string, Record<string, { value: any; source: ParamSource }>> = {};\n for (const param of this.trackedParams) {\n const mod = param.module;\n if (!byModule[mod]) byModule[mod] = {};\n byModule[mod][param.key] = { value: param.value, source: param.source };\n }\n return byModule;\n }\n\n /**\n * Clear tracked parameters\n */\n clearTrackedParams(): void {\n this.trackedParams = [];\n }\n\n /**\n * Assign a parameter definition\n */\n assignDefinition(key: string, definition?: ParamDefinition): any {\n if (this.definitions[key] && !definition) {\n return this.definitions[key];\n }\n\n let type: Joi.Schema;\n if (!definition) {\n type = Joi.string();\n } else if (Joi.isSchema(definition)) {\n type = definition;\n } else if (Joi.isSchema(definition.type)) {\n type = definition.type;\n } else if (typeof definition === \"string\") {\n type = this.toJoi(definition);\n } else if (typeof definition.type === \"string\") {\n type = this.toJoi(definition.type);\n } else if (!definition.type) {\n type = Joi.string();\n } else {\n type = Joi.string();\n }\n\n if (!this.definitions[key]) {\n this.definitions[key] = {};\n }\n this.definitions[key].type = type;\n\n if (definition && definition.values) {\n if (Array.isArray(definition.values)) {\n this.definitions[key].values = definition.values;\n }\n }\n return this.definitions[key];\n }\n\n /**\n * Convert string definition to Joi schema\n */\n toJoi(str: string): Joi.Schema {\n let type: Joi.Schema;\n \n if (str.match(/^string|^text/i)) {\n type = Joi.string();\n } else if (str.match(/^number|^integer|^int/i)) {\n type = Joi.number();\n } else if (str.match(/^boolean|^bool/i)) {\n type = Joi.boolean();\n } else if (str.match(/^date/i)) {\n type = Joi.custom(joiEdateType);\n } else if (str.match(/^duration/i)) {\n type = Joi.string().isoDuration();\n } else if (str.match(/^array/i)) {\n let elementTypes = \"string\";\n const tmp = str.match(/\\((.*)\\)/);\n if (tmp && tmp[1].match(/string/i)) {\n elementTypes = \"string\";\n } else if (tmp && tmp[1].match(/number|integer|int/i)) {\n elementTypes = \"number\";\n } else if (tmp && tmp[1].match(/boolean|bool/i)) {\n elementTypes = \"boolean\";\n }\n type = Joi.custom(joiStringArrayType(elementTypes));\n } else {\n type = Joi.string();\n }\n\n // Handle default values\n const regexForDefault = /\\bdefault\\s+([^\\s]+)/;\n const matchForDefault = str.match(regexForDefault);\n if (matchForDefault) {\n const defValObj = type.validate(matchForDefault[1]);\n if (defValObj.error) {\n throw new ParamError(`default value \"${defValObj.value}\" type mismatch`);\n }\n // Joi's default() automatically allows undefined and applies the default\n type = type.default(defValObj.value);\n } else if (str.match(/\\s*required\\s*/)) {\n type = type.required();\n } else {\n // If not required and no default, make it optional\n type = type.optional();\n }\n\n return type;\n }\n\n /**\n * Validate a value against a definition\n */\n validate(key: string, val: any, def: any): any {\n // Convert null to undefined so Joi defaults can be applied\n // Joi's .default() only works with undefined, not null\n const normalizedVal = val === null ? undefined : val;\n \n // Pass current params as context to support cross-parameter references (e.g., @startTime+2h)\n // Use abortEarly: false to get all errors, and allowUnknown: false for strict validation\n const { value, error } = def.type.validate(normalizedVal, { \n context: { params: this.params },\n abortEarly: false,\n allowUnknown: false,\n });\n if (error) {\n const errs = error.details.map((el: any) => el.message).join(\", \");\n throw new ParamError(`\"${key}\" validation error: ${errs}`);\n }\n return value;\n }\n\n /**\n * Get a parameter value with validation\n */\n get(key: string, definition?: ParamDefinition): any {\n const def = this.assignDefinition(key, definition);\n let valFromGetters: any = undefined;\n \n if (def.volatile || true) {\n valFromGetters = this.runAllRegisteredGetters(key);\n }\n \n // Always call args.get() to mark the key as used, even if it doesn't exist\n const valFromArgs = this.args.get(key);\n const valFromParams = this.params[key];\n\n let source: ParamSource = \"default\";\n let value: any;\n\n if (valFromGetters !== undefined && valFromGetters !== null) {\n value = this.validate(key, valFromGetters, def);\n source = \"options\";\n } else if (valFromArgs !== undefined && valFromArgs !== null) {\n value = this.validate(key, valFromArgs, def);\n const argsSource = (this.args as { getSource?(k: string): string }).getSource?.(key);\n if (argsSource === \"overrides\") source = \"options\";\n else if (argsSource === \"cli\" || argsSource === \"env\" || argsSource === \"config\") source = argsSource;\n else if (argsSource === \"default\") source = \"default\";\n else source = \"cli\";\n } else if (valFromParams !== undefined && valFromParams !== null) {\n value = this.validate(key, valFromParams, def);\n source = this.paramSources[key] ?? \"options\";\n } else {\n value = this.validate(key, undefined, def);\n source = \"default\";\n }\n\n this.paramSources[key] = source;\n // Track parameter for --stopAfter=init and --showUsedParams\n this.trackParam(key, definition || \"string\", value, source);\n\n if (value !== undefined && def.values && !def.values.includes(value)) {\n throw new ParamError(`key ${key} should be one of ${def.values}`);\n }\n return value;\n }\n\n /**\n * Set a parameter value with validation\n */\n set(key: string, val: any, definition?: ParamDefinition): void {\n // TODO: check if there's a test for this:\n if (val && val.type && val.value) {\n definition = val;\n val = val.value;\n }\n const def = this.assignDefinition(key, definition);\n\n if (!this.runAllRegisteredSetters(key, val)) {\n this.params[key] = val;\n }\n }\n\n /**\n * Get all parameters from definitions (main script).\n * Same as getAllForModule(\"script\", defs). Processes left-to-right for cross-parameter references.\n * Libraries should use {@link getAllForModule} with an explicit module name (or {@link runWithModule}\n * around {@link get}) so --showUsedParams groups usage correctly.\n */\n getAll(defs: Record<string, ParamDefinition>): Record<string, any> {\n return this.getAllForModule(\"script\", defs);\n }\n\n /**\n * Get all parameters from definitions for a given module name.\n * Figured params are grouped by module when using --showUsedParams.\n * Processes parameters left-to-right to support cross-parameter references.\n * If moduleName is omitted, it is inferred from the caller's file path (directory name under src/).\n */\n getAllForModule(moduleNameOrDefs: string | Record<string, ParamDefinition>, defs?: Record<string, ParamDefinition>): Record<string, any> {\n let moduleName: string;\n let definitions: Record<string, ParamDefinition>;\n if (defs !== undefined) {\n moduleName = moduleNameOrDefs as string;\n definitions = defs;\n } else {\n definitions = moduleNameOrDefs as Record<string, ParamDefinition>;\n moduleName = this._inferModuleNameFromStack();\n }\n const prev = this._currentModule;\n this._currentModule = moduleName;\n try {\n const res: Record<string, any> = {};\n for (const [k, def] of Object.entries(definitions)) {\n const value = this.get(k, def);\n res[k] = value;\n if (value !== undefined) {\n this.params[k] = value;\n }\n }\n return res;\n } finally {\n this._currentModule = prev;\n }\n }\n\n /**\n * Run a callback with {@link _currentModule} set so single {@link get} calls are tracked\n * under the same module (for --showUsedParams / getFiguredByModule).\n */\n runWithModule<T>(moduleName: string, fn: () => T): T {\n const prev = this._currentModule;\n this._currentModule = moduleName;\n try {\n return fn();\n } finally {\n this._currentModule = prev;\n }\n }\n\n /**\n * Infer module name from call stack: first caller outside params/index gives path like .../src/<moduleName>/...\n */\n private _inferModuleNameFromStack(): string {\n const stack = new Error().stack;\n if (!stack) return \"script\";\n const lines = stack.split(\"\\n\");\n const paramsIndexPath = \"params\" + (typeof process !== \"undefined\" && process.platform === \"win32\" ? \"\\\\\" : \"/\") + \"index.\";\n for (const line of lines) {\n const parenMatch = line.match(/\\(([^)]+)\\)/);\n if (!parenMatch) continue;\n const parts = parenMatch[1].split(\":\");\n if (parts.length < 3) continue;\n const path = parts.slice(0, -2).join(\":\").replace(/^file:\\/\\//, \"\");\n if (!path || path.includes(paramsIndexPath)) continue;\n const srcMatch = path.match(/[/\\\\]src[/\\\\]([^/\\\\]+)(?:[/\\\\]|$)/);\n if (srcMatch) return srcMatch[1];\n }\n return \"script\";\n }\n\n /**\n * Run all registered getters for a key\n */\n runAllRegisteredGetters(key: string): any {\n let val: any = undefined;\n for (const getter of this.paramGetters) {\n val = getter(key, this.definitions[key]);\n if (val !== undefined && val !== null) {\n break;\n }\n }\n return val;\n }\n\n /**\n * Run all registered setters for a key\n */\n runAllRegisteredSetters(key: string, value: any): boolean {\n let setterUsed: boolean = false;\n for (const setter of this.paramSetters) {\n setterUsed = setter(key, value);\n if (setterUsed) {\n break;\n }\n }\n return setterUsed;\n }\n\n /**\n * Register a parameter getter\n */\n registerParamGetter(fn: ParamGetter): void {\n this.paramGetters.push(fn);\n }\n\n /**\n * Register a parameter setter\n */\n registerParamSetter(fn: ParamSetter): void {\n this.paramSetters.push(fn);\n }\n}\n\n// Export custom types for external use\nexport { joiEdateType, joiStringArrayType };\n\n","/**\n * Error classes for the CLI toolkit\n */\n\nexport class FrameworkError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"FrameworkError\";\n }\n}\n\nexport class ParamError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"ParamError\";\n }\n}\n\nexport class InitError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"InitError\";\n }\n}\n\nexport class CriticalRequestError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"CriticalRequestError\";\n }\n}\n\nexport class ControlFlowError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ControlFlowError\";\n }\n}\n\nexport class HttpClientError extends FrameworkError {\n constructor(message: string, public readonly cause?: Error) {\n super(message);\n this.name = \"HttpClientError\";\n }\n}\n\nexport class FileDatabaseError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"FileDatabaseError\";\n }\n}\n\n","import Joi from \"joi\";\nimport { ParamError } from \"../errors.js\";\n\n/**\n * Custom Joi type for enhanced date parsing with relative time support\n * Supports:\n * - ISO8601 strings: \"2025-01-01T01:01:01Z\"\n * - Relative time: \"-2h\", \"+1d\", \"now\"\n * - Cross-parameter references: \"@startTime+2h\", \"@endDate-30m\"\n * \n * Internal representation: UTC ISO8601 string (YYYY-MM-DDTHH:mm:ssZ)\n * \n * @param value - Date value to parse\n * @param helpers - Joi helpers (includes context with other params)\n * @returns ISO8601 string in UTC timezone\n */\nexport const joiEdateType = (value: any, helpers: Joi.CustomHelpers): string => {\n // If value is already a string in ISO format, validate and return\n if (typeof value === \"string\" && /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?Z$/.test(value)) {\n const testDate = new Date(value);\n if (!isNaN(testDate.getTime())) {\n return value;\n }\n }\n\n // If value is a Date object, convert to ISO string\n if (value instanceof Date) {\n return value.toISOString();\n }\n\n // If value is not a string, try to convert it\n if (typeof value !== \"string\") {\n value = String(value);\n }\n\n // Handle special keyword \"now\"\n if (value.toLowerCase() === \"now\") {\n return new Date().toISOString();\n }\n\n // Check for cross-parameter reference with relative time: @paramName+2h, @paramName-30m\n const referenceRegex = /^@(\\w+)([+-]\\d+[smhdwy])$/i;\n const referenceMatch = value.match(referenceRegex);\n \n if (referenceMatch) {\n const [, paramName, relativeExpr] = referenceMatch;\n \n // Get the referenced parameter from context (if available via helpers.state.ancestors)\n // For now, we'll use helpers.prefs.context which Joi provides\n const context = (helpers as any).prefs?.context;\n \n if (!context || !context.params) {\n throw new ParamError(`Cannot resolve cross-parameter reference @${paramName}: context not available. Ensure parameters are processed with proper context.`);\n }\n\n const referencedValue = context.params[paramName];\n \n if (referencedValue === undefined || referencedValue === null) {\n throw new ParamError(`Cannot resolve @${paramName}: parameter \"${paramName}\" is not defined or has no value. Parameters are evaluated left-to-right.`);\n }\n\n // Referenced value should be an ISO string or Date\n let referenceDate: Date;\n if (referencedValue instanceof Date) {\n referenceDate = referencedValue;\n } else if (typeof referencedValue === \"string\") {\n referenceDate = new Date(referencedValue);\n if (isNaN(referenceDate.getTime())) {\n throw new ParamError(`Referenced parameter @${paramName} has invalid date value: ${referencedValue}`);\n }\n } else {\n throw new ParamError(`Referenced parameter @${paramName} is not a valid date type (found: ${typeof referencedValue})`);\n }\n\n // Parse the relative expression and apply to reference date\n const relativeMatch = relativeExpr.match(/^([+-])(\\d+)([smhdwy])$/i);\n if (!relativeMatch) {\n throw new ParamError(`Invalid relative time expression in @${paramName}${relativeExpr}`);\n }\n\n const [, sign, amount, unit] = relativeMatch;\n const offset = calculateTimeOffset(parseInt(amount, 10), unit, sign);\n const resultDate = new Date(referenceDate.getTime() + offset);\n \n return resultDate.toISOString();\n }\n\n // Check for relative time expressions like \"-2h\", \"+1d\", \"-30m\", etc.\n const relativeTimeRegex = /^([+-])(\\d+)([smhdwy])$/i;\n const relativeMatch = value.match(relativeTimeRegex);\n \n if (relativeMatch) {\n const [, sign, amount, unit] = relativeMatch;\n const numAmount = parseInt(amount, 10);\n \n if (isNaN(numAmount)) {\n throw new ParamError(`Invalid relative time amount: ${amount}`);\n }\n\n const offset = calculateTimeOffset(numAmount, unit, sign);\n const resultDate = new Date(Date.now() + offset);\n \n return resultDate.toISOString();\n }\n\n // Try to parse as a regular date string\n const parsedDate = new Date(value);\n \n // Check if the parsed date is valid\n if (isNaN(parsedDate.getTime())) {\n throw new ParamError(`Invalid date format: ${value}. Expected a valid date string, \"now\", relative time expression (e.g., \"-2h\", \"+1d\"), or cross-parameter reference (e.g., \"@startTime+2h\")`);\n }\n\n return parsedDate.toISOString();\n};\n\n/**\n * Calculate time offset in milliseconds\n */\nfunction calculateTimeOffset(amount: number, unit: string, sign: string): number {\n let multiplier = 1;\n \n // Convert to milliseconds based on unit\n switch (unit.toLowerCase()) {\n case \"s\": // seconds\n multiplier = 1000;\n break;\n case \"m\": // minutes\n multiplier = 60 * 1000;\n break;\n case \"h\": // hours\n multiplier = 60 * 60 * 1000;\n break;\n case \"d\": // days\n multiplier = 24 * 60 * 60 * 1000;\n break;\n case \"w\": // weeks\n multiplier = 7 * 24 * 60 * 60 * 1000;\n break;\n case \"y\": // years (approximate)\n multiplier = 365 * 24 * 60 * 60 * 1000;\n break;\n default:\n throw new ParamError(`Invalid time unit: ${unit}. Supported units: s, m, h, d, w, y`);\n }\n\n return sign === \"+\" ? amount * multiplier : -amount * multiplier;\n}\n\n/**\n * Custom Joi type for string array parsing\n * Converts comma-separated strings to typed arrays\n */\nexport const joiStringArrayType = (type: string) => (value: any, helpers: Joi.CustomHelpers): any[] => {\n if (value === undefined || typeof value === \"function\") {\n return [];\n }\n \n const arr = value.split(/,\\s*/).map((el: string) => {\n if (type === \"number\") {\n const v = parseInt(el, 10);\n if (isNaN(v)) {\n throw new ParamError(`array element \"${el}\" should be numeric`);\n }\n return v;\n } else if (type === \"boolean\") {\n const v = el.match(/true|t|yes|1/i) ? true :\n el.match(/false|f|no|0/i) ? false : null;\n if (v === null) {\n throw new ParamError(`array element \"${el}\" should be boolean`);\n }\n return v;\n } else if (type === \"string\") {\n return el;\n } else {\n throw new ParamError(`unknown type \"${type}\" for array elements`);\n }\n });\n \n return arr;\n};\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;A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AAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAKA,oBAAoB,IAAuB;AACvC,SAAK,aAAa,KAAK,EAAE;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA,EAKA,oBAAoB,IAAuB;AACvC,SAAK,aAAa,KAAK,EAAE;AAAA,EAC7B;AACJ;","names":["relativeMatch","Joi"]}
package/dist/params.js CHANGED
@@ -326,7 +326,7 @@ var Params = class _Params {
326
326
  throw new ParamError(`default value "${defValObj.value}" type mismatch`);
327
327
  }
328
328
  type = type.default(defValObj.value);
329
- } else if (str.match(/required/)) {
329
+ } else if (str.match(/\s*required\s*/)) {
330
330
  type = type.required();
331
331
  } else {
332
332
  type = type.optional();
@@ -402,6 +402,8 @@ var Params = class _Params {
402
402
  /**
403
403
  * Get all parameters from definitions (main script).
404
404
  * Same as getAllForModule("script", defs). Processes left-to-right for cross-parameter references.
405
+ * Libraries should use {@link getAllForModule} with an explicit module name (or {@link runWithModule}
406
+ * around {@link get}) so --showUsedParams groups usage correctly.
405
407
  */
406
408
  getAll(defs) {
407
409
  return this.getAllForModule("script", defs);
@@ -438,6 +440,19 @@ var Params = class _Params {
438
440
  this._currentModule = prev;
439
441
  }
440
442
  }
443
+ /**
444
+ * Run a callback with {@link _currentModule} set so single {@link get} calls are tracked
445
+ * under the same module (for --showUsedParams / getFiguredByModule).
446
+ */
447
+ runWithModule(moduleName, fn) {
448
+ const prev = this._currentModule;
449
+ this._currentModule = moduleName;
450
+ try {
451
+ return fn();
452
+ } finally {
453
+ this._currentModule = prev;
454
+ }
455
+ }
441
456
  /**
442
457
  * Infer module name from call stack: first caller outside params/index gives path like .../src/<moduleName>/...
443
458
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/params/index.ts","../src/errors.ts","../src/params/custom-types.ts"],"sourcesContent":["import Joi from \"joi\";\nimport { ParamError } from \"../errors\";\nimport { joiEdateType, joiStringArrayType } from \"./custom-types\";\n\n/**\n * Parameter definition types\n */\nexport type ParamDefinition = \n | string \n | Joi.Schema \n | { \n type?: string | Joi.Schema; \n values?: any[]; \n [key: string]: any; \n };\n\nexport type ParamGetter = (key: string, definition?: any) => any;\nexport type ParamSetter = (key: string, value: any) => boolean;\n\n/**\n * Args instance interface\n */\nexport interface ArgsInstance {\n get(key: string): any;\n}\n\n/**\n * Params constructor options\n */\nexport interface ParamsOptions {\n [key: string]: any;\n}\n\n/** Origin of a parameter value: CLI args, env var, config file, options/overrides, or definition default */\nexport type ParamSource = \"cli\" | \"env\" | \"config\" | \"options\" | \"default\";\n\n/**\n * Tracked parameter information for --stopAfter=init and --showUsedParams\n */\ninterface TrackedParam {\n key: string;\n definition: ParamDefinition;\n value: any;\n source: ParamSource;\n module: string;\n}\n\n/**\n * Params class for parameter validation and type checking\n * Built on top of Args library with Joi validation\n */\nexport class Params {\n private context: any; // Partial context during initialization\n private params: Record<string, any> = {};\n private paramSources: Record<string, ParamSource> = {};\n private definitions: Record<string, any> = {};\n private args: ArgsInstance;\n private paramSetters: ParamSetter[] = [];\n private paramGetters: ParamGetter[] = [];\n private trackedParams: TrackedParam[] = [];\n private _currentModule: string = \"script\";\n /** Resolved early in constructor so cleanup does not read params lazily */\n private _showUsedParams: boolean = false;\n\n constructor(context: any, options: ParamsOptions = {}) {\n // Context might be partial during initialization\n this.context = context;\n this.args = context.args;\n\n // Apply initial configuration\n if (Object.keys(options).length > 0) {\n this.configure(options);\n }\n\n // Resolve showUsedParams early (fail fast, consistent with \"params figured in init\")\n this._showUsedParams = this.get(\"showUsedParams\", \"boolean default false\");\n\n if (context && typeof context.registerCleanup === \"function\") {\n context.registerCleanup((ctx: any) => {\n if (!ctx.params.getShowUsedParams()) return;\n const byModule = ctx.params.getFiguredByModule();\n const modules = Object.keys(byModule).sort();\n if (modules.length === 0) return;\n const logger = ctx.logger;\n logger.debug(\"[Params]: list of used params:\");\n type Entry = { value: any; source: ParamSource };\n if (typeof logger.highlight !== \"function\") {\n for (const mod of modules) {\n logger.debug(` [${mod}]`);\n for (const [key, entry] of Object.entries(byModule[mod]) as [string, Entry][]) {\n logger.debug(` ${key}: ${JSON.stringify(entry.value)} (${entry.source})`);\n }\n }\n return;\n }\n for (const mod of modules) {\n logger.debug(` [${mod}]`);\n for (const [key, entry] of Object.entries(byModule[mod]) as [string, Entry][]) {\n const valueStr = JSON.stringify(entry.value);\n const display = entry.source === \"default\" ? valueStr : logger.highlight(valueStr);\n logger.debug(` ${key}: ${display} (${entry.source})`);\n }\n }\n });\n }\n }\n\n /** Whether --showUsedParams was requested (resolved in constructor). */\n getShowUsedParams(): boolean {\n return this._showUsedParams;\n }\n\n /**\n * Configure parameters\n * Only parameters present in options are updated\n */\n configure(options: ParamsOptions): void {\n for (const [k, v] of Object.entries(options)) {\n // TODO: opt values might be an object with definitions in it, so perhaps `this.set` should be used\n this.params[k] = v;\n }\n }\n\n /**\n * Initialize Params from context and CLI parameters\n * Note: Params is special - it's initialized early with partial context\n */\n static init(context: any, options?: ParamsOptions): Params {\n return new Params(context, options || {});\n }\n\n /**\n * Track a parameter request for --stopAfter=init and --showUsedParams\n */\n private trackParam(key: string, definition: ParamDefinition, value: any, source: ParamSource, moduleName?: string): void {\n this.trackedParams.push({\n key,\n definition,\n value,\n source,\n module: moduleName ?? this._currentModule,\n });\n }\n\n /**\n * Get all tracked parameters (for --stopAfter=init)\n */\n getTrackedParams(): TrackedParam[] {\n return [...this.trackedParams];\n }\n\n /**\n * Get all figured parameters as a record (flat, last occurrence per key)\n * Returns all parameters that were collected during initialization,\n * whether from CLI args, options, or defaults\n */\n getAllFigured(): Record<string, { value: any; source: ParamSource }> {\n const result: Record<string, { value: any; source: ParamSource }> = {};\n for (const param of this.trackedParams) {\n result[param.key] = {\n value: param.value,\n source: param.source,\n };\n }\n return result;\n }\n\n /**\n * Get figured parameters grouped by module name.\n * Same param can appear in multiple modules (e.g. source, resource).\n */\n getFiguredByModule(): Record<string, Record<string, { value: any; source: ParamSource }>> {\n const byModule: Record<string, Record<string, { value: any; source: ParamSource }>> = {};\n for (const param of this.trackedParams) {\n const mod = param.module;\n if (!byModule[mod]) byModule[mod] = {};\n byModule[mod][param.key] = { value: param.value, source: param.source };\n }\n return byModule;\n }\n\n /**\n * Clear tracked parameters\n */\n clearTrackedParams(): void {\n this.trackedParams = [];\n }\n\n /**\n * Assign a parameter definition\n */\n assignDefinition(key: string, definition?: ParamDefinition): any {\n if (this.definitions[key] && !definition) {\n return this.definitions[key];\n }\n\n let type: Joi.Schema;\n if (!definition) {\n type = Joi.string();\n } else if (Joi.isSchema(definition)) {\n type = definition;\n } else if (Joi.isSchema(definition.type)) {\n type = definition.type;\n } else if (typeof definition === \"string\") {\n type = this.toJoi(definition);\n } else if (typeof definition.type === \"string\") {\n type = this.toJoi(definition.type);\n } else if (!definition.type) {\n type = Joi.string();\n } else {\n type = Joi.string();\n }\n\n if (!this.definitions[key]) {\n this.definitions[key] = {};\n }\n this.definitions[key].type = type;\n\n if (definition && definition.values) {\n if (Array.isArray(definition.values)) {\n this.definitions[key].values = definition.values;\n }\n }\n return this.definitions[key];\n }\n\n /**\n * Convert string definition to Joi schema\n */\n toJoi(str: string): Joi.Schema {\n let type: Joi.Schema;\n \n if (str.match(/^string|^text/i)) {\n type = Joi.string();\n } else if (str.match(/^number|^integer|^int/i)) {\n type = Joi.number();\n } else if (str.match(/^boolean|^bool/i)) {\n type = Joi.boolean();\n } else if (str.match(/^date/i)) {\n type = Joi.custom(joiEdateType);\n } else if (str.match(/^duration/i)) {\n type = Joi.string().isoDuration();\n } else if (str.match(/^array/i)) {\n let elementTypes = \"string\";\n const tmp = str.match(/\\((.*)\\)/);\n if (tmp && tmp[1].match(/string/i)) {\n elementTypes = \"string\";\n } else if (tmp && tmp[1].match(/number|integer|int/i)) {\n elementTypes = \"number\";\n } else if (tmp && tmp[1].match(/boolean|bool/i)) {\n elementTypes = \"boolean\";\n }\n type = Joi.custom(joiStringArrayType(elementTypes));\n } else {\n type = Joi.string();\n }\n\n // Handle default values\n const regexForDefault = /\\bdefault\\s+([^\\s]+)/;\n const matchForDefault = str.match(regexForDefault);\n if (matchForDefault) {\n const defValObj = type.validate(matchForDefault[1]);\n if (defValObj.error) {\n throw new ParamError(`default value \"${defValObj.value}\" type mismatch`);\n }\n // Joi's default() automatically allows undefined and applies the default\n type = type.default(defValObj.value);\n } else if (str.match(/required/)) {\n type = type.required();\n } else {\n // If not required and no default, make it optional\n type = type.optional();\n }\n\n return type;\n }\n\n /**\n * Validate a value against a definition\n */\n validate(key: string, val: any, def: any): any {\n // Convert null to undefined so Joi defaults can be applied\n // Joi's .default() only works with undefined, not null\n const normalizedVal = val === null ? undefined : val;\n \n // Pass current params as context to support cross-parameter references (e.g., @startTime+2h)\n // Use abortEarly: false to get all errors, and allowUnknown: false for strict validation\n const { value, error } = def.type.validate(normalizedVal, { \n context: { params: this.params },\n abortEarly: false,\n allowUnknown: false,\n });\n if (error) {\n const errs = error.details.map((el: any) => el.message).join(\", \");\n throw new ParamError(`\"${key}\" validation error: ${errs}`);\n }\n return value;\n }\n\n /**\n * Get a parameter value with validation\n */\n get(key: string, definition?: ParamDefinition): any {\n const def = this.assignDefinition(key, definition);\n let valFromGetters: any = undefined;\n \n if (def.volatile || true) {\n valFromGetters = this.runAllRegisteredGetters(key);\n }\n \n // Always call args.get() to mark the key as used, even if it doesn't exist\n const valFromArgs = this.args.get(key);\n const valFromParams = this.params[key];\n\n let source: ParamSource = \"default\";\n let value: any;\n\n if (valFromGetters !== undefined && valFromGetters !== null) {\n value = this.validate(key, valFromGetters, def);\n source = \"options\";\n } else if (valFromArgs !== undefined && valFromArgs !== null) {\n value = this.validate(key, valFromArgs, def);\n const argsSource = (this.args as { getSource?(k: string): string }).getSource?.(key);\n if (argsSource === \"overrides\") source = \"options\";\n else if (argsSource === \"cli\" || argsSource === \"env\" || argsSource === \"config\") source = argsSource;\n else if (argsSource === \"default\") source = \"default\";\n else source = \"cli\";\n } else if (valFromParams !== undefined && valFromParams !== null) {\n value = this.validate(key, valFromParams, def);\n source = this.paramSources[key] ?? \"options\";\n } else {\n value = this.validate(key, undefined, def);\n source = \"default\";\n }\n\n this.paramSources[key] = source;\n // Track parameter for --stopAfter=init and --showUsedParams\n this.trackParam(key, definition || \"string\", value, source);\n\n if (value !== undefined && def.values && !def.values.includes(value)) {\n throw new ParamError(`key ${key} should be one of ${def.values}`);\n }\n return value;\n }\n\n /**\n * Set a parameter value with validation\n */\n set(key: string, val: any, definition?: ParamDefinition): void {\n // TODO: check if there's a test for this:\n if (val && val.type && val.value) {\n definition = val;\n val = val.value;\n }\n const def = this.assignDefinition(key, definition);\n\n if (!this.runAllRegisteredSetters(key, val)) {\n this.params[key] = val;\n }\n }\n\n /**\n * Get all parameters from definitions (main script).\n * Same as getAllForModule(\"script\", defs). Processes left-to-right for cross-parameter references.\n */\n getAll(defs: Record<string, ParamDefinition>): Record<string, any> {\n return this.getAllForModule(\"script\", defs);\n }\n\n /**\n * Get all parameters from definitions for a given module name.\n * Figured params are grouped by module when using --showUsedParams.\n * Processes parameters left-to-right to support cross-parameter references.\n * If moduleName is omitted, it is inferred from the caller's file path (directory name under src/).\n */\n getAllForModule(moduleNameOrDefs: string | Record<string, ParamDefinition>, defs?: Record<string, ParamDefinition>): Record<string, any> {\n let moduleName: string;\n let definitions: Record<string, ParamDefinition>;\n if (defs !== undefined) {\n moduleName = moduleNameOrDefs as string;\n definitions = defs;\n } else {\n definitions = moduleNameOrDefs as Record<string, ParamDefinition>;\n moduleName = this._inferModuleNameFromStack();\n }\n const prev = this._currentModule;\n this._currentModule = moduleName;\n try {\n const res: Record<string, any> = {};\n for (const [k, def] of Object.entries(definitions)) {\n const value = this.get(k, def);\n res[k] = value;\n if (value !== undefined) {\n this.params[k] = value;\n }\n }\n return res;\n } finally {\n this._currentModule = prev;\n }\n }\n\n /**\n * Infer module name from call stack: first caller outside params/index gives path like .../src/<moduleName>/...\n */\n private _inferModuleNameFromStack(): string {\n const stack = new Error().stack;\n if (!stack) return \"script\";\n const lines = stack.split(\"\\n\");\n const paramsIndexPath = \"params\" + (typeof process !== \"undefined\" && process.platform === \"win32\" ? \"\\\\\" : \"/\") + \"index.\";\n for (const line of lines) {\n const parenMatch = line.match(/\\(([^)]+)\\)/);\n if (!parenMatch) continue;\n const parts = parenMatch[1].split(\":\");\n if (parts.length < 3) continue;\n const path = parts.slice(0, -2).join(\":\").replace(/^file:\\/\\//, \"\");\n if (!path || path.includes(paramsIndexPath)) continue;\n const srcMatch = path.match(/[/\\\\]src[/\\\\]([^/\\\\]+)(?:[/\\\\]|$)/);\n if (srcMatch) return srcMatch[1];\n }\n return \"script\";\n }\n\n /**\n * Run all registered getters for a key\n */\n runAllRegisteredGetters(key: string): any {\n let val: any = undefined;\n for (const getter of this.paramGetters) {\n val = getter(key, this.definitions[key]);\n if (val !== undefined && val !== null) {\n break;\n }\n }\n return val;\n }\n\n /**\n * Run all registered setters for a key\n */\n runAllRegisteredSetters(key: string, value: any): boolean {\n let setterUsed: boolean = false;\n for (const setter of this.paramSetters) {\n setterUsed = setter(key, value);\n if (setterUsed) {\n break;\n }\n }\n return setterUsed;\n }\n\n /**\n * Register a parameter getter\n */\n registerParamGetter(fn: ParamGetter): void {\n this.paramGetters.push(fn);\n }\n\n /**\n * Register a parameter setter\n */\n registerParamSetter(fn: ParamSetter): void {\n this.paramSetters.push(fn);\n }\n}\n\n// Export custom types for external use\nexport { joiEdateType, joiStringArrayType };\n\n","/**\n * Error classes for the CLI toolkit\n */\n\nexport class FrameworkError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"FrameworkError\";\n }\n}\n\nexport class ParamError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"ParamError\";\n }\n}\n\nexport class InitError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"InitError\";\n }\n}\n\nexport class CriticalRequestError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"CriticalRequestError\";\n }\n}\n\nexport class ControlFlowError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ControlFlowError\";\n }\n}\n\nexport class HttpClientError extends FrameworkError {\n constructor(message: string, public readonly cause?: Error) {\n super(message);\n this.name = \"HttpClientError\";\n }\n}\n\nexport class FileDatabaseError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"FileDatabaseError\";\n }\n}\n\n","import Joi from \"joi\";\nimport { ParamError } from \"../errors.js\";\n\n/**\n * Custom Joi type for enhanced date parsing with relative time support\n * Supports:\n * - ISO8601 strings: \"2025-01-01T01:01:01Z\"\n * - Relative time: \"-2h\", \"+1d\", \"now\"\n * - Cross-parameter references: \"@startTime+2h\", \"@endDate-30m\"\n * \n * Internal representation: UTC ISO8601 string (YYYY-MM-DDTHH:mm:ssZ)\n * \n * @param value - Date value to parse\n * @param helpers - Joi helpers (includes context with other params)\n * @returns ISO8601 string in UTC timezone\n */\nexport const joiEdateType = (value: any, helpers: Joi.CustomHelpers): string => {\n // If value is already a string in ISO format, validate and return\n if (typeof value === \"string\" && /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?Z$/.test(value)) {\n const testDate = new Date(value);\n if (!isNaN(testDate.getTime())) {\n return value;\n }\n }\n\n // If value is a Date object, convert to ISO string\n if (value instanceof Date) {\n return value.toISOString();\n }\n\n // If value is not a string, try to convert it\n if (typeof value !== \"string\") {\n value = String(value);\n }\n\n // Handle special keyword \"now\"\n if (value.toLowerCase() === \"now\") {\n return new Date().toISOString();\n }\n\n // Check for cross-parameter reference with relative time: @paramName+2h, @paramName-30m\n const referenceRegex = /^@(\\w+)([+-]\\d+[smhdwy])$/i;\n const referenceMatch = value.match(referenceRegex);\n \n if (referenceMatch) {\n const [, paramName, relativeExpr] = referenceMatch;\n \n // Get the referenced parameter from context (if available via helpers.state.ancestors)\n // For now, we'll use helpers.prefs.context which Joi provides\n const context = (helpers as any).prefs?.context;\n \n if (!context || !context.params) {\n throw new ParamError(`Cannot resolve cross-parameter reference @${paramName}: context not available. Ensure parameters are processed with proper context.`);\n }\n\n const referencedValue = context.params[paramName];\n \n if (referencedValue === undefined || referencedValue === null) {\n throw new ParamError(`Cannot resolve @${paramName}: parameter \"${paramName}\" is not defined or has no value. Parameters are evaluated left-to-right.`);\n }\n\n // Referenced value should be an ISO string or Date\n let referenceDate: Date;\n if (referencedValue instanceof Date) {\n referenceDate = referencedValue;\n } else if (typeof referencedValue === \"string\") {\n referenceDate = new Date(referencedValue);\n if (isNaN(referenceDate.getTime())) {\n throw new ParamError(`Referenced parameter @${paramName} has invalid date value: ${referencedValue}`);\n }\n } else {\n throw new ParamError(`Referenced parameter @${paramName} is not a valid date type (found: ${typeof referencedValue})`);\n }\n\n // Parse the relative expression and apply to reference date\n const relativeMatch = relativeExpr.match(/^([+-])(\\d+)([smhdwy])$/i);\n if (!relativeMatch) {\n throw new ParamError(`Invalid relative time expression in @${paramName}${relativeExpr}`);\n }\n\n const [, sign, amount, unit] = relativeMatch;\n const offset = calculateTimeOffset(parseInt(amount, 10), unit, sign);\n const resultDate = new Date(referenceDate.getTime() + offset);\n \n return resultDate.toISOString();\n }\n\n // Check for relative time expressions like \"-2h\", \"+1d\", \"-30m\", etc.\n const relativeTimeRegex = /^([+-])(\\d+)([smhdwy])$/i;\n const relativeMatch = value.match(relativeTimeRegex);\n \n if (relativeMatch) {\n const [, sign, amount, unit] = relativeMatch;\n const numAmount = parseInt(amount, 10);\n \n if (isNaN(numAmount)) {\n throw new ParamError(`Invalid relative time amount: ${amount}`);\n }\n\n const offset = calculateTimeOffset(numAmount, unit, sign);\n const resultDate = new Date(Date.now() + offset);\n \n return resultDate.toISOString();\n }\n\n // Try to parse as a regular date string\n const parsedDate = new Date(value);\n \n // Check if the parsed date is valid\n if (isNaN(parsedDate.getTime())) {\n throw new ParamError(`Invalid date format: ${value}. Expected a valid date string, \"now\", relative time expression (e.g., \"-2h\", \"+1d\"), or cross-parameter reference (e.g., \"@startTime+2h\")`);\n }\n\n return parsedDate.toISOString();\n};\n\n/**\n * Calculate time offset in milliseconds\n */\nfunction calculateTimeOffset(amount: number, unit: string, sign: string): number {\n let multiplier = 1;\n \n // Convert to milliseconds based on unit\n switch (unit.toLowerCase()) {\n case \"s\": // seconds\n multiplier = 1000;\n break;\n case \"m\": // minutes\n multiplier = 60 * 1000;\n break;\n case \"h\": // hours\n multiplier = 60 * 60 * 1000;\n break;\n case \"d\": // days\n multiplier = 24 * 60 * 60 * 1000;\n break;\n case \"w\": // weeks\n multiplier = 7 * 24 * 60 * 60 * 1000;\n break;\n case \"y\": // years (approximate)\n multiplier = 365 * 24 * 60 * 60 * 1000;\n break;\n default:\n throw new ParamError(`Invalid time unit: ${unit}. Supported units: s, m, h, d, w, y`);\n }\n\n return sign === \"+\" ? amount * multiplier : -amount * multiplier;\n}\n\n/**\n * Custom Joi type for string array parsing\n * Converts comma-separated strings to typed arrays\n */\nexport const joiStringArrayType = (type: string) => (value: any, helpers: Joi.CustomHelpers): any[] => {\n if (value === undefined || typeof value === \"function\") {\n return [];\n }\n \n const arr = value.split(/,\\s*/).map((el: string) => {\n if (type === \"number\") {\n const v = parseInt(el, 10);\n if (isNaN(v)) {\n throw new ParamError(`array element \"${el}\" should be numeric`);\n }\n return v;\n } else if (type === \"boolean\") {\n const v = el.match(/true|t|yes|1/i) ? true :\n el.match(/false|f|no|0/i) ? false : null;\n if (v === null) {\n throw new ParamError(`array element \"${el}\" should be boolean`);\n }\n return v;\n } else if (type === \"string\") {\n return el;\n } else {\n throw new ParamError(`unknown type \"${type}\" for array elements`);\n }\n });\n \n return arr;\n};\n\n"],"mappings":";AAAA,OAAO,SAAS;;;ACIT,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACtC,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,aAAN,cAAyB,eAAe;AAAA,EAC3C,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;;;ACAO,IAAM,eAAe,CAAC,OAAY,YAAuC;AAE5E,MAAI,O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AAE,EAAE,KAAK,GAAG,EAAE,QAAQ,cAAc,EAAE;AAClE,UAAI,CAAC,QAAQ,KAAK,SAAS,eAAe,EAAG;AAC7C,YAAM,WAAW,KAAK,MAAM,mCAAmC;AAC/D,UAAI,SAAU,QAAO,SAAS,CAAC;AAAA,IACnC;AACA,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAKA,wBAAwB,KAAkB;AACtC,QAAI,MAAW;AACf,eAAW,UAAU,KAAK,cAAc;AACpC,YAAM,OAAO,KAAK,KAAK,YAAY,GAAG,CAAC;AACvC,UAAI,QAAQ,UAAa,QAAQ,MAAM;AACnC;AAAA,MACJ;AAAA,IACJ;AACA,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAKA,wBAAwB,KAAa,OAAqB;AACtD,QAAI,aAAsB;AAC1B,eAAW,UAAU,KAAK,cAAc;AACpC,mBAAa,OAAO,KAAK,KAAK;AAC9B,UAAI,YAAY;AACZ;AAAA,MACJ;AAAA,IACJ;AACA,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAKA,oBAAoB,IAAuB;AACvC,SAAK,aAAa,KAAK,EAAE;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA,EAKA,oBAAoB,IAAuB;AACvC,SAAK,aAAa,KAAK,EAAE;AAAA,EAC7B;AACJ;","names":["relativeMatch"]}
1
+ {"version":3,"sources":["../src/params/index.ts","../src/errors.ts","../src/params/custom-types.ts"],"sourcesContent":["import Joi from \"joi\";\nimport { ParamError } from \"../errors\";\nimport { joiEdateType, joiStringArrayType } from \"./custom-types\";\n\n/**\n * Parameter definition types\n */\nexport type ParamDefinition = \n | string \n | Joi.Schema \n | { \n type?: string | Joi.Schema; \n values?: any[]; \n [key: string]: any; \n };\n\nexport type ParamGetter = (key: string, definition?: any) => any;\nexport type ParamSetter = (key: string, value: any) => boolean;\n\n/**\n * Args instance interface\n */\nexport interface ArgsInstance {\n get(key: string): any;\n}\n\n/**\n * Params constructor options\n */\nexport interface ParamsOptions {\n [key: string]: any;\n}\n\n/** Origin of a parameter value: CLI args, env var, config file, options/overrides, or definition default */\nexport type ParamSource = \"cli\" | \"env\" | \"config\" | \"options\" | \"default\";\n\n/**\n * Tracked parameter information for --stopAfter=init and --showUsedParams\n */\ninterface TrackedParam {\n key: string;\n definition: ParamDefinition;\n value: any;\n source: ParamSource;\n module: string;\n}\n\n/**\n * Params class for parameter validation and type checking\n * Built on top of Args library with Joi validation\n */\nexport class Params {\n private context: any; // Partial context during initialization\n private params: Record<string, any> = {};\n private paramSources: Record<string, ParamSource> = {};\n private definitions: Record<string, any> = {};\n private args: ArgsInstance;\n private paramSetters: ParamSetter[] = [];\n private paramGetters: ParamGetter[] = [];\n private trackedParams: TrackedParam[] = [];\n private _currentModule: string = \"script\";\n /** Resolved early in constructor so cleanup does not read params lazily */\n private _showUsedParams: boolean = false;\n\n constructor(context: any, options: ParamsOptions = {}) {\n // Context might be partial during initialization\n this.context = context;\n this.args = context.args;\n\n // Apply initial configuration\n if (Object.keys(options).length > 0) {\n this.configure(options);\n }\n\n // Resolve showUsedParams early (fail fast, consistent with \"params figured in init\")\n this._showUsedParams = this.get(\"showUsedParams\", \"boolean default false\");\n\n if (context && typeof context.registerCleanup === \"function\") {\n context.registerCleanup((ctx: any) => {\n if (!ctx.params.getShowUsedParams()) return;\n const byModule = ctx.params.getFiguredByModule();\n const modules = Object.keys(byModule).sort();\n if (modules.length === 0) return;\n const logger = ctx.logger;\n logger.debug(\"[Params]: list of used params:\");\n type Entry = { value: any; source: ParamSource };\n if (typeof logger.highlight !== \"function\") {\n for (const mod of modules) {\n logger.debug(` [${mod}]`);\n for (const [key, entry] of Object.entries(byModule[mod]) as [string, Entry][]) {\n logger.debug(` ${key}: ${JSON.stringify(entry.value)} (${entry.source})`);\n }\n }\n return;\n }\n for (const mod of modules) {\n logger.debug(` [${mod}]`);\n for (const [key, entry] of Object.entries(byModule[mod]) as [string, Entry][]) {\n const valueStr = JSON.stringify(entry.value);\n const display = entry.source === \"default\" ? valueStr : logger.highlight(valueStr);\n logger.debug(` ${key}: ${display} (${entry.source})`);\n }\n }\n });\n }\n }\n\n /** Whether --showUsedParams was requested (resolved in constructor). */\n getShowUsedParams(): boolean {\n return this._showUsedParams;\n }\n\n /**\n * Configure parameters\n * Only parameters present in options are updated\n */\n configure(options: ParamsOptions): void {\n for (const [k, v] of Object.entries(options)) {\n // TODO: opt values might be an object with definitions in it, so perhaps `this.set` should be used\n this.params[k] = v;\n }\n }\n\n /**\n * Initialize Params from context and CLI parameters\n * Note: Params is special - it's initialized early with partial context\n */\n static init(context: any, options?: ParamsOptions): Params {\n return new Params(context, options || {});\n }\n\n /**\n * Track a parameter request for --stopAfter=init and --showUsedParams\n */\n private trackParam(key: string, definition: ParamDefinition, value: any, source: ParamSource, moduleName?: string): void {\n this.trackedParams.push({\n key,\n definition,\n value,\n source,\n module: moduleName ?? this._currentModule,\n });\n }\n\n /**\n * Get all tracked parameters (for --stopAfter=init)\n */\n getTrackedParams(): TrackedParam[] {\n return [...this.trackedParams];\n }\n\n /**\n * Get all figured parameters as a record (flat, last occurrence per key)\n * Returns all parameters that were collected during initialization,\n * whether from CLI args, options, or defaults\n */\n getAllFigured(): Record<string, { value: any; source: ParamSource }> {\n const result: Record<string, { value: any; source: ParamSource }> = {};\n for (const param of this.trackedParams) {\n result[param.key] = {\n value: param.value,\n source: param.source,\n };\n }\n return result;\n }\n\n /**\n * Get figured parameters grouped by module name.\n * Same param can appear in multiple modules (e.g. source, resource).\n */\n getFiguredByModule(): Record<string, Record<string, { value: any; source: ParamSource }>> {\n const byModule: Record<string, Record<string, { value: any; source: ParamSource }>> = {};\n for (const param of this.trackedParams) {\n const mod = param.module;\n if (!byModule[mod]) byModule[mod] = {};\n byModule[mod][param.key] = { value: param.value, source: param.source };\n }\n return byModule;\n }\n\n /**\n * Clear tracked parameters\n */\n clearTrackedParams(): void {\n this.trackedParams = [];\n }\n\n /**\n * Assign a parameter definition\n */\n assignDefinition(key: string, definition?: ParamDefinition): any {\n if (this.definitions[key] && !definition) {\n return this.definitions[key];\n }\n\n let type: Joi.Schema;\n if (!definition) {\n type = Joi.string();\n } else if (Joi.isSchema(definition)) {\n type = definition;\n } else if (Joi.isSchema(definition.type)) {\n type = definition.type;\n } else if (typeof definition === \"string\") {\n type = this.toJoi(definition);\n } else if (typeof definition.type === \"string\") {\n type = this.toJoi(definition.type);\n } else if (!definition.type) {\n type = Joi.string();\n } else {\n type = Joi.string();\n }\n\n if (!this.definitions[key]) {\n this.definitions[key] = {};\n }\n this.definitions[key].type = type;\n\n if (definition && definition.values) {\n if (Array.isArray(definition.values)) {\n this.definitions[key].values = definition.values;\n }\n }\n return this.definitions[key];\n }\n\n /**\n * Convert string definition to Joi schema\n */\n toJoi(str: string): Joi.Schema {\n let type: Joi.Schema;\n \n if (str.match(/^string|^text/i)) {\n type = Joi.string();\n } else if (str.match(/^number|^integer|^int/i)) {\n type = Joi.number();\n } else if (str.match(/^boolean|^bool/i)) {\n type = Joi.boolean();\n } else if (str.match(/^date/i)) {\n type = Joi.custom(joiEdateType);\n } else if (str.match(/^duration/i)) {\n type = Joi.string().isoDuration();\n } else if (str.match(/^array/i)) {\n let elementTypes = \"string\";\n const tmp = str.match(/\\((.*)\\)/);\n if (tmp && tmp[1].match(/string/i)) {\n elementTypes = \"string\";\n } else if (tmp && tmp[1].match(/number|integer|int/i)) {\n elementTypes = \"number\";\n } else if (tmp && tmp[1].match(/boolean|bool/i)) {\n elementTypes = \"boolean\";\n }\n type = Joi.custom(joiStringArrayType(elementTypes));\n } else {\n type = Joi.string();\n }\n\n // Handle default values\n const regexForDefault = /\\bdefault\\s+([^\\s]+)/;\n const matchForDefault = str.match(regexForDefault);\n if (matchForDefault) {\n const defValObj = type.validate(matchForDefault[1]);\n if (defValObj.error) {\n throw new ParamError(`default value \"${defValObj.value}\" type mismatch`);\n }\n // Joi's default() automatically allows undefined and applies the default\n type = type.default(defValObj.value);\n } else if (str.match(/\\s*required\\s*/)) {\n type = type.required();\n } else {\n // If not required and no default, make it optional\n type = type.optional();\n }\n\n return type;\n }\n\n /**\n * Validate a value against a definition\n */\n validate(key: string, val: any, def: any): any {\n // Convert null to undefined so Joi defaults can be applied\n // Joi's .default() only works with undefined, not null\n const normalizedVal = val === null ? undefined : val;\n \n // Pass current params as context to support cross-parameter references (e.g., @startTime+2h)\n // Use abortEarly: false to get all errors, and allowUnknown: false for strict validation\n const { value, error } = def.type.validate(normalizedVal, { \n context: { params: this.params },\n abortEarly: false,\n allowUnknown: false,\n });\n if (error) {\n const errs = error.details.map((el: any) => el.message).join(\", \");\n throw new ParamError(`\"${key}\" validation error: ${errs}`);\n }\n return value;\n }\n\n /**\n * Get a parameter value with validation\n */\n get(key: string, definition?: ParamDefinition): any {\n const def = this.assignDefinition(key, definition);\n let valFromGetters: any = undefined;\n \n if (def.volatile || true) {\n valFromGetters = this.runAllRegisteredGetters(key);\n }\n \n // Always call args.get() to mark the key as used, even if it doesn't exist\n const valFromArgs = this.args.get(key);\n const valFromParams = this.params[key];\n\n let source: ParamSource = \"default\";\n let value: any;\n\n if (valFromGetters !== undefined && valFromGetters !== null) {\n value = this.validate(key, valFromGetters, def);\n source = \"options\";\n } else if (valFromArgs !== undefined && valFromArgs !== null) {\n value = this.validate(key, valFromArgs, def);\n const argsSource = (this.args as { getSource?(k: string): string }).getSource?.(key);\n if (argsSource === \"overrides\") source = \"options\";\n else if (argsSource === \"cli\" || argsSource === \"env\" || argsSource === \"config\") source = argsSource;\n else if (argsSource === \"default\") source = \"default\";\n else source = \"cli\";\n } else if (valFromParams !== undefined && valFromParams !== null) {\n value = this.validate(key, valFromParams, def);\n source = this.paramSources[key] ?? \"options\";\n } else {\n value = this.validate(key, undefined, def);\n source = \"default\";\n }\n\n this.paramSources[key] = source;\n // Track parameter for --stopAfter=init and --showUsedParams\n this.trackParam(key, definition || \"string\", value, source);\n\n if (value !== undefined && def.values && !def.values.includes(value)) {\n throw new ParamError(`key ${key} should be one of ${def.values}`);\n }\n return value;\n }\n\n /**\n * Set a parameter value with validation\n */\n set(key: string, val: any, definition?: ParamDefinition): void {\n // TODO: check if there's a test for this:\n if (val && val.type && val.value) {\n definition = val;\n val = val.value;\n }\n const def = this.assignDefinition(key, definition);\n\n if (!this.runAllRegisteredSetters(key, val)) {\n this.params[key] = val;\n }\n }\n\n /**\n * Get all parameters from definitions (main script).\n * Same as getAllForModule(\"script\", defs). Processes left-to-right for cross-parameter references.\n * Libraries should use {@link getAllForModule} with an explicit module name (or {@link runWithModule}\n * around {@link get}) so --showUsedParams groups usage correctly.\n */\n getAll(defs: Record<string, ParamDefinition>): Record<string, any> {\n return this.getAllForModule(\"script\", defs);\n }\n\n /**\n * Get all parameters from definitions for a given module name.\n * Figured params are grouped by module when using --showUsedParams.\n * Processes parameters left-to-right to support cross-parameter references.\n * If moduleName is omitted, it is inferred from the caller's file path (directory name under src/).\n */\n getAllForModule(moduleNameOrDefs: string | Record<string, ParamDefinition>, defs?: Record<string, ParamDefinition>): Record<string, any> {\n let moduleName: string;\n let definitions: Record<string, ParamDefinition>;\n if (defs !== undefined) {\n moduleName = moduleNameOrDefs as string;\n definitions = defs;\n } else {\n definitions = moduleNameOrDefs as Record<string, ParamDefinition>;\n moduleName = this._inferModuleNameFromStack();\n }\n const prev = this._currentModule;\n this._currentModule = moduleName;\n try {\n const res: Record<string, any> = {};\n for (const [k, def] of Object.entries(definitions)) {\n const value = this.get(k, def);\n res[k] = value;\n if (value !== undefined) {\n this.params[k] = value;\n }\n }\n return res;\n } finally {\n this._currentModule = prev;\n }\n }\n\n /**\n * Run a callback with {@link _currentModule} set so single {@link get} calls are tracked\n * under the same module (for --showUsedParams / getFiguredByModule).\n */\n runWithModule<T>(moduleName: string, fn: () => T): T {\n const prev = this._currentModule;\n this._currentModule = moduleName;\n try {\n return fn();\n } finally {\n this._currentModule = prev;\n }\n }\n\n /**\n * Infer module name from call stack: first caller outside params/index gives path like .../src/<moduleName>/...\n */\n private _inferModuleNameFromStack(): string {\n const stack = new Error().stack;\n if (!stack) return \"script\";\n const lines = stack.split(\"\\n\");\n const paramsIndexPath = \"params\" + (typeof process !== \"undefined\" && process.platform === \"win32\" ? \"\\\\\" : \"/\") + \"index.\";\n for (const line of lines) {\n const parenMatch = line.match(/\\(([^)]+)\\)/);\n if (!parenMatch) continue;\n const parts = parenMatch[1].split(\":\");\n if (parts.length < 3) continue;\n const path = parts.slice(0, -2).join(\":\").replace(/^file:\\/\\//, \"\");\n if (!path || path.includes(paramsIndexPath)) continue;\n const srcMatch = path.match(/[/\\\\]src[/\\\\]([^/\\\\]+)(?:[/\\\\]|$)/);\n if (srcMatch) return srcMatch[1];\n }\n return \"script\";\n }\n\n /**\n * Run all registered getters for a key\n */\n runAllRegisteredGetters(key: string): any {\n let val: any = undefined;\n for (const getter of this.paramGetters) {\n val = getter(key, this.definitions[key]);\n if (val !== undefined && val !== null) {\n break;\n }\n }\n return val;\n }\n\n /**\n * Run all registered setters for a key\n */\n runAllRegisteredSetters(key: string, value: any): boolean {\n let setterUsed: boolean = false;\n for (const setter of this.paramSetters) {\n setterUsed = setter(key, value);\n if (setterUsed) {\n break;\n }\n }\n return setterUsed;\n }\n\n /**\n * Register a parameter getter\n */\n registerParamGetter(fn: ParamGetter): void {\n this.paramGetters.push(fn);\n }\n\n /**\n * Register a parameter setter\n */\n registerParamSetter(fn: ParamSetter): void {\n this.paramSetters.push(fn);\n }\n}\n\n// Export custom types for external use\nexport { joiEdateType, joiStringArrayType };\n\n","/**\n * Error classes for the CLI toolkit\n */\n\nexport class FrameworkError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"FrameworkError\";\n }\n}\n\nexport class ParamError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"ParamError\";\n }\n}\n\nexport class InitError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"InitError\";\n }\n}\n\nexport class CriticalRequestError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"CriticalRequestError\";\n }\n}\n\nexport class ControlFlowError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ControlFlowError\";\n }\n}\n\nexport class HttpClientError extends FrameworkError {\n constructor(message: string, public readonly cause?: Error) {\n super(message);\n this.name = \"HttpClientError\";\n }\n}\n\nexport class FileDatabaseError extends FrameworkError {\n constructor(message: string) {\n super(message);\n this.name = \"FileDatabaseError\";\n }\n}\n\n","import Joi from \"joi\";\nimport { ParamError } from \"../errors.js\";\n\n/**\n * Custom Joi type for enhanced date parsing with relative time support\n * Supports:\n * - ISO8601 strings: \"2025-01-01T01:01:01Z\"\n * - Relative time: \"-2h\", \"+1d\", \"now\"\n * - Cross-parameter references: \"@startTime+2h\", \"@endDate-30m\"\n * \n * Internal representation: UTC ISO8601 string (YYYY-MM-DDTHH:mm:ssZ)\n * \n * @param value - Date value to parse\n * @param helpers - Joi helpers (includes context with other params)\n * @returns ISO8601 string in UTC timezone\n */\nexport const joiEdateType = (value: any, helpers: Joi.CustomHelpers): string => {\n // If value is already a string in ISO format, validate and return\n if (typeof value === \"string\" && /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?Z$/.test(value)) {\n const testDate = new Date(value);\n if (!isNaN(testDate.getTime())) {\n return value;\n }\n }\n\n // If value is a Date object, convert to ISO string\n if (value instanceof Date) {\n return value.toISOString();\n }\n\n // If value is not a string, try to convert it\n if (typeof value !== \"string\") {\n value = String(value);\n }\n\n // Handle special keyword \"now\"\n if (value.toLowerCase() === \"now\") {\n return new Date().toISOString();\n }\n\n // Check for cross-parameter reference with relative time: @paramName+2h, @paramName-30m\n const referenceRegex = /^@(\\w+)([+-]\\d+[smhdwy])$/i;\n const referenceMatch = value.match(referenceRegex);\n \n if (referenceMatch) {\n const [, paramName, relativeExpr] = referenceMatch;\n \n // Get the referenced parameter from context (if available via helpers.state.ancestors)\n // For now, we'll use helpers.prefs.context which Joi provides\n const context = (helpers as any).prefs?.context;\n \n if (!context || !context.params) {\n throw new ParamError(`Cannot resolve cross-parameter reference @${paramName}: context not available. Ensure parameters are processed with proper context.`);\n }\n\n const referencedValue = context.params[paramName];\n \n if (referencedValue === undefined || referencedValue === null) {\n throw new ParamError(`Cannot resolve @${paramName}: parameter \"${paramName}\" is not defined or has no value. Parameters are evaluated left-to-right.`);\n }\n\n // Referenced value should be an ISO string or Date\n let referenceDate: Date;\n if (referencedValue instanceof Date) {\n referenceDate = referencedValue;\n } else if (typeof referencedValue === \"string\") {\n referenceDate = new Date(referencedValue);\n if (isNaN(referenceDate.getTime())) {\n throw new ParamError(`Referenced parameter @${paramName} has invalid date value: ${referencedValue}`);\n }\n } else {\n throw new ParamError(`Referenced parameter @${paramName} is not a valid date type (found: ${typeof referencedValue})`);\n }\n\n // Parse the relative expression and apply to reference date\n const relativeMatch = relativeExpr.match(/^([+-])(\\d+)([smhdwy])$/i);\n if (!relativeMatch) {\n throw new ParamError(`Invalid relative time expression in @${paramName}${relativeExpr}`);\n }\n\n const [, sign, amount, unit] = relativeMatch;\n const offset = calculateTimeOffset(parseInt(amount, 10), unit, sign);\n const resultDate = new Date(referenceDate.getTime() + offset);\n \n return resultDate.toISOString();\n }\n\n // Check for relative time expressions like \"-2h\", \"+1d\", \"-30m\", etc.\n const relativeTimeRegex = /^([+-])(\\d+)([smhdwy])$/i;\n const relativeMatch = value.match(relativeTimeRegex);\n \n if (relativeMatch) {\n const [, sign, amount, unit] = relativeMatch;\n const numAmount = parseInt(amount, 10);\n \n if (isNaN(numAmount)) {\n throw new ParamError(`Invalid relative time amount: ${amount}`);\n }\n\n const offset = calculateTimeOffset(numAmount, unit, sign);\n const resultDate = new Date(Date.now() + offset);\n \n return resultDate.toISOString();\n }\n\n // Try to parse as a regular date string\n const parsedDate = new Date(value);\n \n // Check if the parsed date is valid\n if (isNaN(parsedDate.getTime())) {\n throw new ParamError(`Invalid date format: ${value}. Expected a valid date string, \"now\", relative time expression (e.g., \"-2h\", \"+1d\"), or cross-parameter reference (e.g., \"@startTime+2h\")`);\n }\n\n return parsedDate.toISOString();\n};\n\n/**\n * Calculate time offset in milliseconds\n */\nfunction calculateTimeOffset(amount: number, unit: string, sign: string): number {\n let multiplier = 1;\n \n // Convert to milliseconds based on unit\n switch (unit.toLowerCase()) {\n case \"s\": // seconds\n multiplier = 1000;\n break;\n case \"m\": // minutes\n multiplier = 60 * 1000;\n break;\n case \"h\": // hours\n multiplier = 60 * 60 * 1000;\n break;\n case \"d\": // days\n multiplier = 24 * 60 * 60 * 1000;\n break;\n case \"w\": // weeks\n multiplier = 7 * 24 * 60 * 60 * 1000;\n break;\n case \"y\": // years (approximate)\n multiplier = 365 * 24 * 60 * 60 * 1000;\n break;\n default:\n throw new ParamError(`Invalid time unit: ${unit}. Supported units: s, m, h, d, w, y`);\n }\n\n return sign === \"+\" ? amount * multiplier : -amount * multiplier;\n}\n\n/**\n * Custom Joi type for string array parsing\n * Converts comma-separated strings to typed arrays\n */\nexport const joiStringArrayType = (type: string) => (value: any, helpers: Joi.CustomHelpers): any[] => {\n if (value === undefined || typeof value === \"function\") {\n return [];\n }\n \n const arr = value.split(/,\\s*/).map((el: string) => {\n if (type === \"number\") {\n const v = parseInt(el, 10);\n if (isNaN(v)) {\n throw new ParamError(`array element \"${el}\" should be numeric`);\n }\n return v;\n } else if (type === \"boolean\") {\n const v = el.match(/true|t|yes|1/i) ? true :\n el.match(/false|f|no|0/i) ? false : null;\n if (v === null) {\n throw new ParamError(`array element \"${el}\" should be boolean`);\n }\n return v;\n } else if (type === \"string\") {\n return el;\n } else {\n throw new ParamError(`unknown type \"${type}\" for array elements`);\n }\n });\n \n return arr;\n};\n\n"],"mappings":";AAAA,OAAO,SAAS;;;ACIT,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACtC,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,IAAM,aAAN,cAAyB,eAAe;AAAA,EAC3C,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAA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