@venizia/ignis-helpers 0.4.8-12 → 0.4.8-14
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/esm/common/redact.js.map +1 -1
- package/dist/esm/common/types/class.d.ts +14 -12
- package/dist/esm/common/types/class.js.map +1 -1
- package/dist/esm/common/types/const-value.d.ts +3 -3
- package/dist/esm/common/types/const-value.js.map +1 -1
- package/dist/esm/common/types/field-mapping.d.ts +6 -6
- package/dist/esm/common/types/field-mapping.js.map +1 -1
- package/dist/esm/common/types/injection.d.ts +1 -1
- package/dist/esm/common/types/injection.js.map +1 -1
- package/dist/esm/common/types/utility.d.ts +0 -4
- package/dist/esm/common/types/utility.js.map +1 -1
- package/dist/esm/modules/env/app-env.d.ts +17 -8
- package/dist/esm/modules/env/app-env.js +18 -15
- package/dist/esm/modules/env/app-env.js.map +1 -1
- package/dist/esm/modules/env/common/types.d.ts +22 -6
- package/dist/esm/modules/env/common/types.js.map +1 -1
- package/dist/esm/modules/logger/base/abstract.d.ts +6 -7
- package/dist/esm/modules/logger/base/abstract.js.map +1 -1
- package/dist/esm/modules/logger/base/base.d.ts +7 -8
- package/dist/esm/modules/logger/base/base.js.map +1 -1
- package/dist/esm/modules/logger/base/console.d.ts +6 -7
- package/dist/esm/modules/logger/base/console.js.map +1 -1
- package/dist/esm/modules/logger/common/types.d.ts +7 -7
- package/dist/esm/modules/logger/common/types.js.map +1 -1
- package/dist/esm/modules/logger/factory.js.map +1 -1
- package/dist/esm/modules/logger/hf/flusher.js.map +1 -1
- package/dist/esm/modules/logger/hf/logger.d.ts +6 -7
- package/dist/esm/modules/logger/hf/logger.js.map +1 -1
- package/dist/esm/modules/logger/pino/backing.js.map +1 -1
- package/dist/esm/modules/logger/pino/destination.d.ts +1 -1
- package/dist/esm/modules/logger/pino/destination.js.map +1 -1
- package/dist/esm/modules/logger/pino/logger.d.ts +1 -2
- package/dist/esm/modules/logger/pino/logger.js.map +1 -1
- package/dist/esm/modules/logger/winston/formats.js +2 -2
- package/dist/esm/modules/logger/winston/formats.js.map +1 -1
- package/dist/esm/modules/logger/winston/logger.d.ts +1 -2
- package/dist/esm/modules/logger/winston/logger.js.map +1 -1
- package/dist/esm/modules/logger/winston/transports/dgram.transport.d.ts +1 -1
- package/dist/esm/modules/logger/winston/transports/dgram.transport.js +1 -1
- package/dist/esm/modules/logger/winston/transports/dgram.transport.js.map +1 -1
- package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.d.ts +6 -6
- package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.js.map +1 -1
- package/dist/esm/modules/network/http-request/fetcher/base-fetcher.d.ts +2 -3
- package/dist/esm/modules/network/http-request/fetcher/base-fetcher.js.map +1 -1
- package/dist/esm/modules/network/http-request/fetcher/common/types.d.ts +1 -1
- package/dist/esm/modules/network/http-request/fetcher/common/types.js.map +1 -1
- package/dist/esm/modules/network/http-request/fetcher/node-fetcher.d.ts +1 -2
- package/dist/esm/modules/network/http-request/fetcher/node-fetcher.js +5 -6
- package/dist/esm/modules/network/http-request/fetcher/node-fetcher.js.map +1 -1
- package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.d.ts +4 -4
- package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.js +1 -1
- package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.js.map +1 -1
- package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.d.ts +3 -3
- package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js.map +1 -1
- package/dist/esm/modules/network/utilities/query-string.d.ts +2 -2
- package/dist/esm/modules/network/utilities/query-string.js.map +1 -1
- package/dist/esm/modules/network/utilities/url-safety/ingest.js.map +1 -1
- package/dist/esm/modules/queue/kafka/base.d.ts +1 -1
- package/dist/esm/modules/queue/kafka/base.js +13 -2
- package/dist/esm/modules/queue/kafka/base.js.map +1 -1
- package/dist/esm/modules/redis/cluster/cluster.helper.d.ts +1 -1
- package/dist/esm/modules/redis/cluster/cluster.helper.js +10 -3
- package/dist/esm/modules/redis/cluster/cluster.helper.js.map +1 -1
- package/dist/esm/modules/redis/cluster/index.d.ts +1 -0
- package/dist/esm/modules/redis/cluster/index.js +1 -0
- package/dist/esm/modules/redis/cluster/index.js.map +1 -1
- package/dist/esm/modules/redis/cluster/types.d.ts +20 -0
- package/dist/esm/modules/redis/cluster/types.js +2 -0
- package/dist/esm/modules/redis/cluster/types.js.map +1 -0
- package/dist/esm/modules/redis/common/constants.d.ts +2 -8
- package/dist/esm/modules/redis/common/constants.js +2 -5
- package/dist/esm/modules/redis/common/constants.js.map +1 -1
- package/dist/esm/modules/redis/common/types.d.ts +9 -62
- package/dist/esm/modules/redis/common/types.js.map +1 -1
- package/dist/esm/modules/redis/factory.d.ts +3 -4
- package/dist/esm/modules/redis/factory.js.map +1 -1
- package/dist/esm/modules/redis/sentinel/constants.d.ts +14 -0
- package/dist/esm/modules/redis/sentinel/constants.js +11 -0
- package/dist/esm/modules/redis/sentinel/constants.js.map +1 -0
- package/dist/esm/modules/redis/sentinel/index.d.ts +2 -0
- package/dist/esm/modules/redis/sentinel/index.js +2 -0
- package/dist/esm/modules/redis/sentinel/index.js.map +1 -1
- package/dist/esm/modules/redis/sentinel/sentinel.helper.d.ts +1 -1
- package/dist/esm/modules/redis/sentinel/sentinel.helper.js +18 -9
- package/dist/esm/modules/redis/sentinel/sentinel.helper.js.map +1 -1
- package/dist/esm/modules/redis/sentinel/types.d.ts +26 -0
- package/dist/esm/modules/redis/sentinel/types.js +2 -0
- package/dist/esm/modules/redis/sentinel/types.js.map +1 -0
- package/dist/esm/modules/redis/single/index.d.ts +1 -0
- package/dist/esm/modules/redis/single/index.js +1 -0
- package/dist/esm/modules/redis/single/index.js.map +1 -1
- package/dist/esm/modules/redis/single/single.helper.d.ts +1 -1
- package/dist/esm/modules/redis/single/single.helper.js +1 -1
- package/dist/esm/modules/redis/single/single.helper.js.map +1 -1
- package/dist/esm/modules/redis/single/types.d.ts +15 -0
- package/dist/esm/modules/redis/single/types.js +2 -0
- package/dist/esm/modules/redis/single/types.js.map +1 -0
- package/dist/esm/modules/secrets/base/abstract.helper.js +6 -1
- package/dist/esm/modules/secrets/base/abstract.helper.js.map +1 -1
- package/dist/esm/modules/secrets/common/types/registration.d.ts +25 -6
- package/dist/esm/modules/secrets/common/types/registration.js.map +1 -1
- package/dist/esm/modules/secrets/dotenv/dotenv.helper.js +1 -1
- package/dist/esm/modules/secrets/dotenv/dotenv.helper.js.map +1 -1
- package/dist/esm/modules/secrets/factory.js +7 -6
- package/dist/esm/modules/secrets/factory.js.map +1 -1
- package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.d.ts +12 -10
- package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.js +50 -25
- package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.js.map +1 -1
- package/dist/esm/modules/socket/socket-io/client/browser-helper.js.map +1 -1
- package/dist/esm/modules/socket/socket-io/common/types/client.d.ts +2 -2
- package/dist/esm/modules/socket/socket-io/common/types/client.js.map +1 -1
- package/dist/esm/modules/socket/socket-io/common/types/server.d.ts +3 -1
- package/dist/esm/modules/socket/socket-io/common/types/server.js.map +1 -1
- package/dist/esm/modules/socket/socket-io/server/helper.d.ts +2 -2
- package/dist/esm/modules/socket/socket-io/server/helper.js.map +1 -1
- package/dist/esm/modules/storage/in-memory/helper.d.ts +2 -3
- package/dist/esm/modules/storage/in-memory/helper.js.map +1 -1
- package/dist/esm/modules/worker-thread/common/types.d.ts +2 -2
- package/dist/esm/modules/worker-thread/common/types.js.map +1 -1
- package/dist/esm/modules/worker-thread/thread/abstract.d.ts +2 -2
- package/dist/esm/modules/worker-thread/thread/abstract.js.map +1 -1
- package/dist/esm/modules/worker-thread/worker-pool.d.ts +1 -1
- package/dist/esm/modules/worker-thread/worker-pool.js.map +1 -1
- package/dist/esm/utilities/module.utility.d.ts +8 -5
- package/dist/esm/utilities/module.utility.js +5 -1
- package/dist/esm/utilities/module.utility.js.map +1 -1
- package/dist/esm/utilities/parse.utility.d.ts +34 -6
- package/dist/esm/utilities/parse.utility.js +82 -15
- package/dist/esm/utilities/parse.utility.js.map +1 -1
- package/dist/esm/utilities/performance.utility.d.ts +3 -3
- package/dist/esm/utilities/performance.utility.js.map +1 -1
- package/dist/esm/utilities/promise.utility.d.ts +1 -1
- package/dist/esm/utilities/promise.utility.js.map +1 -1
- package/dist/esm/utilities/request.utility.d.ts +9 -11
- package/dist/esm/utilities/request.utility.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redact.js","sourceRoot":"","sources":["../../../src/common/redact.ts"],"names":[],"mappings":"AAEA,gHAAgH;AAChH,MAAM,kBAAkB,GAAG,IAAI,MAAM,CACnC;IACE,qDAAqD;IACrD,6EAA6E;IAC7E,qFAAqF;IACrF,oEAAoE;IAEpE,iKAAiK;IACjK,qCAAqC;IAErC,8MAA8M;IAC9M,yBAAyB;IAEzB,8RAA8R;IAC9R,2BAA2B;IAE3B,4JAA4J;IAC5J,qDAAqD;IAErD,uMAAuM;IACvM,uCAAuC;IAEvC,yIAAyI;IACzI,+BAA+B;IAE/B,2MAA2M;IAC3M,gFAAgF;IAChF,6DAA6D;IAE7D,kHAAkH;IAClH,qHAAqH;IACrH,uHAAuH;IACvH,kCAAkC;IAClC,sNAAsN;IACtN,sIAAsI;IACtI,qHAAqH;IACrH,8DAA8D;IAC9D,4DAA4D;IAC5D,gEAAgE;IAChE,yFAAyF;CAC1F,CAAC,IAAI,CAAC,EAAE,CAAC,EACV,GAAG,CACJ,CAAC;AAEF,uEAAuE;AACvE,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAC;AAErC;;;;GAIG;AACH,MAAM,oBAAoB,GAAG,wCAAwC,CAAC;AAEtE,4GAA4G;AAC5G,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAEvD,6GAA6G;AAC7G,MAAM,mBAAmB,GAAG,6CAA6C,CAAC;AAE1E,qIAAqI;AACrI,MAA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,CAAC,IAAwC;QACvD,OAAO,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;IAC/E,CAAC;IAED,omBAAomB;IACpmB,MAAM,CAAC,UAAU,CAAC,IAAyD;QACzE,OAAO,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE;YAC9B,IAAI,EAAE,IAAI,OAAO,EAAU;YAC3B,QAAQ,EAAE,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC;YACxC,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,QAAQ;YAC7B,iGAAiG;YACjG,qDAAqD;YACrD,eAAe,EAAE,sBAAsB,EAAE;SAC1C,CAAC,CAAC;IACL,CAAC;IAED,qUAAqU;IACrU,MAAM,CAAC,oBAAoB,CAAC,IAAsC;QAChE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAE5B,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,GAAG,CAAC;QACb,CAAC;QAED,IAAI,MAAW,CAAC;QAEhB,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,GAAG,CAAC;QACb,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACrB,OAAO,GAAG,CAAC;QACb,CAAC;QAED,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAE3B,OAAO,kBAAkB,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["import { type AnyObject } from './types';\n\n/** Keys whose VALUES must never reach a log line - matched case-insensitively on the key name, at any depth. */\nconst SECRET_KEY_PATTERN = new RegExp(\n [\n // Options-object spellings (camelCase / snake_case).\n '^(pass|password|passphrase|secret|token|apiKey|api_key|accessKey|access_key',\n '|secretKey|secret_key|privateKey|private_key|key|cert|ca|pfx|credential|credentials',\n '|authorization|auth|jwtSecret|applicationSecret|connectionString)$',\n\n // Vault wire spellings (snake_case): node-vault's AppRole login/response bodies carry these exact keys, and none are matched by the anchored options list above.\n '|^(client_token|secret_id|role_id)$',\n\n // Any `*_token` (snake_case) or `*Token` (camelCase) key; a preceding character is required so the bare word `token` (already covered above) is not the whole match, and so ordinary words are not swallowed.\n '|_token$|[a-z0-9]token$',\n\n // The `*Secret` counterpart the `*Token` rule always lacked. `clientSecret` / `client_secret` is the RFC 6749 parameter name and a live field on the search connector's model options, and `webhookSecret` is the standard spelling everywhere; none of them matched the anchored list above.\n '|_secret$|[a-z0-9]secret$',\n\n // Connection descriptors: `connectionString` was anchored above but its snake_case twin was not, and `dsn` is the third common spelling for the same thing.\n '|^(connection_string|dsn|database_url|databaseUrl)$',\n\n // Any `*_credential` / `*Credential` key, singular or plural - `dbCredential`, `api_credentials`. The bare words are anchored above; this catches the prefixed forms, the way the `*Secret` rule does.\n '|_credentials?$|[a-z0-9]credentials?$',\n\n // Any `*_password` / `*Password` key - `dbPassword`, `admin_password`. The bare word is anchored above; this catches the prefixed forms.\n '|_password$|[a-z0-9]password$',\n\n // HTTP HEADER spellings: header names are kebab-case and often `x-`-prefixed, none of which the camelCase list above matches; `vault` is included so `X-Vault-Token` (node-vault's auth header) is caught.\n '|^(x-)?(api|auth|access|secret|session|csrf|xsrf|vault)-(key|token|secret|id)$',\n '|^(cookie|set-cookie|proxy-authorization|www-authenticate)$',\n\n // Named secrets that no suffix rule reaches. An explicit list, never a blanket `*Key` or `code`: those would mask\n // `primaryKey`, `cacheKey` and every status `code`. Cloud and signing keys, session and one-time values, signatures,\n // card and national-id numbers, and the kebab spellings of tokens and secrets (the suffix rules above need a letter or\n // an underscore before the word).\n '|^(secret_?access_?key|aws_?secret_?access_?key|signing_?key|encryption_?key|master_?key|hmac_?key|account_?key|storage_?key|license_?key|reset_?key|reset_?code|verification_?code|authorization_?code|auth_?code)$',\n '|^(jwt|session_?id|sid|signature|sig|passwd|pwd|passcode|pass_phrase|secret_?answer|otp|totp|cvv|cvc|card_?number|ssn|national_?id)$',\n '|^(redis_?url|mongo_?uri|mongo_?url|webhook_?url|private_?key_?pem|password_?hash|mfa_?code|otp_?code|x_?api_?key)$',\n '|^(api_?keys|refresh_?tokens|access_?tokens|secrets|tokens)$',\n '|^(x-amz-signature|x-amz-security-token|x-amz-credential)$',\n '|^(id|refresh|access|bearer|auth|api|session|csrf|xsrf)-token$',\n '|^(client|api|app|webhook)-secret$|^(private|signing|secret|api|access|encryption)-key$',\n ].join(''),\n 'i',\n);\n\n/** The placeholder that replaces a secret value in redacted output. */\nexport const REDACTED = '[REDACTED]';\n\n/**\n * `://user:password@host`: the password of a url's userinfo, wherever the url sits inside a string. Anchored on `://`\n * (not on the scheme, whose letters a pattern would rescan from every start) and every run is bounded, so the cost is\n * linear in the string. The password runs to the LAST `@` before a space or slash, so one that holds an `@` is whole.\n */\nconst URL_USERINFO_PATTERN = /(:\\/\\/[^\\s/:@]{0,256}):[^\\s/]{1,256}@/g;\n\n/** `://token@host`: a userinfo with no password is the credential itself (`https://<token>@github.com`). */\nconst URL_USER_ONLY_PATTERN = /:\\/\\/[^\\s/:@]{1,256}@/g;\n\n/** `Bearer abc...` and `Basic abc...` credentials, as an `Authorization` header or a message quotes them. */\nconst AUTH_SCHEME_PATTERN = /\\b(Bearer|Basic)\\s+[A-Za-z0-9._~+/=-]{8,}/gi;\n\n/** A credential-like `name=value` after a query, fragment, list or space: `?access_token=...`, `#id_token=...`, `, password=...`. */\nconst QUERY_CREDENTIAL_PATTERN =\n /([?&;,#\\s])(access_token|refresh_token|id_token|token|api_key|apikey|x-api-key|key|auth|password|passwd|pwd|secret|client_secret|signature|sig|x-amz-signature|x-amz-security-token|jwt|session_id|sessionid|code)=([^&\\s#,)]*)/gi;\n\n/** A string with the credentials it carries masked: a connection url's password, a bearer token, a credential query parameter. */\nconst scrubString = (value: string): string => {\n if (!value.includes('@') && !value.includes('=') && !/bearer|basic/i.test(value)) {\n return value;\n }\n\n return value\n .replace(URL_USERINFO_PATTERN, `$1:${'[REDACTED]'}@`)\n .replace(URL_USER_ONLY_PATTERN, `://${'[REDACTED]'}@`)\n .replace(AUTH_SCHEME_PATTERN, `$1 ${'[REDACTED]'}`)\n .replace(QUERY_CREDENTIAL_PATTERN, `$1$2=${'[REDACTED]'}`);\n};\n\n/** Kill-switch for local debugging: only the literal `false` disables redaction (fail-closed); read per call so it can be flipped at runtime. Never disable in production. `force` is the caller opting out of the switch: it always masks. */\nconst isRedactionEnabled = (force?: boolean): boolean =>\n force === true || globalThis.process?.env?.APP_ENV_LOGGER_DO_REDACT !== 'false';\n\n/** Longest string a log line carries whole. `APP_ENV_LOGGER_MAX_STRING_LENGTH=0` turns capping off. */\nconst DEFAULT_MAX_STRING_LENGTH = 2048;\n\nconst resolveMaxStringLength = (): number => {\n const configured = Number(globalThis.process?.env?.APP_ENV_LOGGER_MAX_STRING_LENGTH);\n\n return Number.isFinite(configured) && configured >= 0 ? configured : DEFAULT_MAX_STRING_LENGTH;\n};\n\n/**\n * Keys whose value is long BY NATURE and useless truncated. A stack trace is the whole reason you\n * are reading the line.\n */\nconst UNCAPPED_KEYS = new Set(['stack', 'stacktrace', 'stack_trace']);\n\n/**\n * Caps a long string, keeping the ORIGINAL LENGTH in the marker - that number is what tells you the\n * payload was a 300 KB image rather than a truncated sentence.\n *\n * A base64 body is the case this exists for: one `data:image/png;base64,...` field turns a request\n * log into hundreds of kilobytes, and nothing about it is readable.\n */\nconst capString = (opts: { value: string; key?: string; limit: number }): string => {\n const { value, key, limit } = opts;\n\n if (limit === 0 || value.length <= limit || (key && UNCAPPED_KEYS.has(key.toLowerCase()))) {\n return value;\n }\n\n return `${value.slice(0, limit)}... [truncated, ${value.length} chars total]`;\n};\n\ntype TSanitizeContext = {\n seen: WeakSet<object>;\n doRedact: boolean;\n /** Levels still allowed BELOW the current one; `Infinity` walks the whole graph. */\n depth: number;\n /** Longest string kept whole; 0 keeps every string. */\n maxStringLength: number;\n /** The key this value was found under, so a stack trace can be exempted from capping. */\n key?: string;\n};\n\nconst deepSanitize = (value: unknown, context: TSanitizeContext): unknown => {\n const { seen, doRedact, depth } = context;\n\n if (typeof value === 'string') {\n const text = doRedact ? scrubString(value) : value;\n\n return capString({ value: text, key: context.key, limit: context.maxStringLength });\n }\n\n // A function is not data, and an own `toJSON` on an object would run after this walk, inside `JSON.stringify`, and\n // hand back keys the walk never saw. Naming it keeps the redacted copy free of code.\n if (typeof value === 'function') {\n return '[Function]';\n }\n\n if (value === null || typeof value !== 'object') {\n return value;\n }\n\n // A Date holds its value in an internal slot, so the generic branch below - which reads Object.keys() - would flatten it to `{}`. Checked BEFORE `seen`: a Date cannot carry a cycle, and entering the set would make a second reference to the same instance read as `[Circular]`.\n if (value instanceof Date) {\n return value;\n }\n\n if (seen.has(value)) {\n return '[Circular]';\n }\n\n if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer) {\n return `[Binary ${(value as ArrayBufferView).byteLength ?? 0} bytes]`;\n }\n\n if (depth <= 0) {\n return Array.isArray(value) ? '[Array]' : '[Object]';\n }\n\n seen.add(value);\n const nested: TSanitizeContext = {\n seen,\n doRedact,\n depth: depth - 1,\n maxStringLength: context.maxStringLength,\n };\n\n // Error keeps name/message/stack NON-enumerable, so Object.keys() skips them and naive redaction would drop the message - reproject into a plain object carrying those fields plus its redacted enumerable own-props.\n if (value instanceof Error) {\n const source = value;\n const result: AnyObject = {\n name: value.name,\n message: doRedact ? scrubString(value.message) : value.message,\n stack: doRedact && value.stack ? scrubString(value.stack) : value.stack,\n };\n\n for (const [key, entry] of Object.entries(source)) {\n result[key] =\n doRedact && SECRET_KEY_PATTERN.test(key)\n ? REDACTED\n : deepSanitize(entry, { ...nested, key });\n }\n\n return result;\n }\n\n if (Array.isArray(value)) {\n return value.map((entry) => deepSanitize(entry, nested));\n }\n\n const source = value;\n const result: AnyObject = {};\n\n for (const [key, entry] of Object.entries(source)) {\n if (doRedact && SECRET_KEY_PATTERN.test(key)) {\n result[key] = REDACTED;\n continue;\n }\n\n result[key] = deepSanitize(entry, { ...nested, key });\n }\n\n return result;\n};\n\n/** Makes a log argument safe to print: masks secret-looking keys, breaks cycles, caps long strings and strips URL credentials. `APP_ENV_LOGGER_DO_REDACT=false` turns off the key masking only. */\nexport class RedactUtility {\n /**\n * Redacts every secret-looking KEY (not value shape - buffers/typed arrays are summarized, not\n * serialized). `APP_ENV_LOGGER_DO_REDACT=false` makes this the identity function.\n *\n * `depth` bounds the walk, exactly as {@link RedactUtility.toJsonSafe} already does. It defaults to\n * `Infinity` for callers that really do want the whole graph, but the logger passes its own bound:\n * rendering only inspects a handful of levels, so walking to `Infinity` did work whose result was\n * thrown away - 12x on a deep graph, and a `RangeError` on a very deep chain.\n *\n * `force: true` masks secret-looking KEYS even when `APP_ENV_LOGGER_DO_REDACT=false`. The result is still the\n * log-shaped copy: long strings are capped, a second reference to one object reads `[Circular]`, binary is\n * summarized, and a key is masked by name only (a card number under `number` is not). It is not a faithful\n * redacted document. The logger never sets it.\n */\n static redactSecrets(opts: {\n value: unknown;\n seen?: WeakSet<object>;\n depth?: number;\n force?: boolean;\n }): unknown {\n const { value, seen, depth = Infinity, force } = opts;\n\n if (!isRedactionEnabled(force)) {\n return value;\n }\n\n return deepSanitize(value, {\n seen: seen ?? new WeakSet<object>(),\n doRedact: true,\n depth,\n maxStringLength: resolveMaxStringLength(),\n });\n }\n\n /** Masks the credentials a plain string carries (a url's password, a bearer token, credential query parameters). For a log line's string argument; objects go through {@link RedactUtility.redactSecrets}. `force: true` scrubs even when `APP_ENV_LOGGER_DO_REDACT=false`. */\n static scrubText(opts: { value: string; force?: boolean }): string {\n return isRedactionEnabled(opts.force) ? scrubString(opts.value) : opts.value;\n }\n\n /** Projects a value into something `JSON.stringify` can render: it answers `[Circular]` for the WHOLE payload when one cycle sits anywhere inside it, so cycles must be broken per-branch first. `depth` bounds the walk the way `util.inspect` does - a log argument may hold a live connector or request context, whose graph is effectively unbounded. The projection itself is unconditional: `APP_ENV_LOGGER_DO_REDACT=false` turns off the key masking, never the structural pass. `force: true` keeps the key masking on whatever the switch says; the projection stays lossy, as in {@link RedactUtility.redactSecrets}. */\n static toJsonSafe(opts: { value: unknown; depth?: number; force?: boolean }): unknown {\n return deepSanitize(opts.value, {\n seen: new WeakSet<object>(),\n doRedact: isRedactionEnabled(opts.force),\n depth: opts.depth ?? Infinity,\n // Capping is STRUCTURAL, like the projection itself: turning redaction off is about key masking,\n // never about letting a 300 KB base64 field through.\n maxStringLength: resolveMaxStringLength(),\n });\n }\n\n /** Strips credentials from a connection URL's authority section (`user:hunter2@host` -> `user:[REDACTED]@host`) - {@link RedactUtility.redactSecrets} matches on KEY names and can't see them there. A value that fails to parse as a URL is returned unchanged. `force: true` strips even when `APP_ENV_LOGGER_DO_REDACT=false`. */\n static redactUrlCredentials(opts: { url: string; force?: boolean }): string {\n const { url, force } = opts;\n\n if (!isRedactionEnabled(force)) {\n return url;\n }\n\n let parsed: URL;\n\n try {\n parsed = new URL(url);\n } catch {\n return url;\n }\n\n if (!parsed.password) {\n return url;\n }\n\n parsed.password = REDACTED;\n\n return decodeURIComponent(parsed.toString());\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"redact.js","sourceRoot":"","sources":["../../../src/common/redact.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,MAAM,kBAAkB,GAAG,IAAI,MAAM,CACnC;IACE,qDAAqD;IACrD,6EAA6E;IAC7E,qFAAqF;IACrF,oEAAoE;IAEpE,iKAAiK;IACjK,qCAAqC;IAErC,8MAA8M;IAC9M,yBAAyB;IAEzB,8RAA8R;IAC9R,2BAA2B;IAE3B,4JAA4J;IAC5J,qDAAqD;IAErD,uMAAuM;IACvM,uCAAuC;IAEvC,yIAAyI;IACzI,+BAA+B;IAE/B,2MAA2M;IAC3M,gFAAgF;IAChF,6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C;QAEhB,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,GAAG,CAAC;QACb,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACrB,OAAO,GAAG,CAAC;QACb,CAAC;QAED,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAE3B,OAAO,kBAAkB,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["/** Keys whose VALUES must never reach a log line - matched case-insensitively on the key name, at any depth. */\nconst SECRET_KEY_PATTERN = new RegExp(\n [\n // Options-object spellings (camelCase / snake_case).\n '^(pass|password|passphrase|secret|token|apiKey|api_key|accessKey|access_key',\n '|secretKey|secret_key|privateKey|private_key|key|cert|ca|pfx|credential|credentials',\n '|authorization|auth|jwtSecret|applicationSecret|connectionString)$',\n\n // Vault wire spellings (snake_case): node-vault's AppRole login/response bodies carry these exact keys, and none are matched by the anchored options list above.\n '|^(client_token|secret_id|role_id)$',\n\n // Any `*_token` (snake_case) or `*Token` (camelCase) key; a preceding character is required so the bare word `token` (already covered above) is not the whole match, and so ordinary words are not swallowed.\n '|_token$|[a-z0-9]token$',\n\n // The `*Secret` counterpart the `*Token` rule always lacked. `clientSecret` / `client_secret` is the RFC 6749 parameter name and a live field on the search connector's model options, and `webhookSecret` is the standard spelling everywhere; none of them matched the anchored list above.\n '|_secret$|[a-z0-9]secret$',\n\n // Connection descriptors: `connectionString` was anchored above but its snake_case twin was not, and `dsn` is the third common spelling for the same thing.\n '|^(connection_string|dsn|database_url|databaseUrl)$',\n\n // Any `*_credential` / `*Credential` key, singular or plural - `dbCredential`, `api_credentials`. The bare words are anchored above; this catches the prefixed forms, the way the `*Secret` rule does.\n '|_credentials?$|[a-z0-9]credentials?$',\n\n // Any `*_password` / `*Password` key - `dbPassword`, `admin_password`. The bare word is anchored above; this catches the prefixed forms.\n '|_password$|[a-z0-9]password$',\n\n // HTTP HEADER spellings: header names are kebab-case and often `x-`-prefixed, none of which the camelCase list above matches; `vault` is included so `X-Vault-Token` (node-vault's auth header) is caught.\n '|^(x-)?(api|auth|access|secret|session|csrf|xsrf|vault)-(key|token|secret|id)$',\n '|^(cookie|set-cookie|proxy-authorization|www-authenticate)$',\n\n // Named secrets that no suffix rule reaches. An explicit list, never a blanket `*Key` or `code`: those would mask\n // `primaryKey`, `cacheKey` and every status `code`. Cloud and signing keys, session and one-time values, signatures,\n // card and national-id numbers, and the kebab spellings of tokens and secrets (the suffix rules above need a letter or\n // an underscore before the word).\n '|^(secret_?access_?key|aws_?secret_?access_?key|signing_?key|encryption_?key|master_?key|hmac_?key|account_?key|storage_?key|license_?key|reset_?key|reset_?code|verification_?code|authorization_?code|auth_?code)$',\n '|^(jwt|session_?id|sid|signature|sig|passwd|pwd|passcode|pass_phrase|secret_?answer|otp|totp|cvv|cvc|card_?number|ssn|national_?id)$',\n '|^(redis_?url|mongo_?uri|mongo_?url|webhook_?url|private_?key_?pem|password_?hash|mfa_?code|otp_?code|x_?api_?key)$',\n '|^(api_?keys|refresh_?tokens|access_?tokens|secrets|tokens)$',\n '|^(x-amz-signature|x-amz-security-token|x-amz-credential)$',\n '|^(id|refresh|access|bearer|auth|api|session|csrf|xsrf)-token$',\n '|^(client|api|app|webhook)-secret$|^(private|signing|secret|api|access|encryption)-key$',\n ].join(''),\n 'i',\n);\n\n/** The placeholder that replaces a secret value in redacted output. */\nexport const REDACTED = '[REDACTED]';\n\n/**\n * `://user:password@host`: the password of a url's userinfo, wherever the url sits inside a string. Anchored on `://`\n * (not on the scheme, whose letters a pattern would rescan from every start) and every run is bounded, so the cost is\n * linear in the string. The password runs to the LAST `@` before a space or slash, so one that holds an `@` is whole.\n */\nconst URL_USERINFO_PATTERN = /(:\\/\\/[^\\s/:@]{0,256}):[^\\s/]{1,256}@/g;\n\n/** `://token@host`: a userinfo with no password is the credential itself (`https://<token>@github.com`). */\nconst URL_USER_ONLY_PATTERN = /:\\/\\/[^\\s/:@]{1,256}@/g;\n\n/** `Bearer abc...` and `Basic abc...` credentials, as an `Authorization` header or a message quotes them. */\nconst AUTH_SCHEME_PATTERN = /\\b(Bearer|Basic)\\s+[A-Za-z0-9._~+/=-]{8,}/gi;\n\n/** A credential-like `name=value` after a query, fragment, list or space: `?access_token=...`, `#id_token=...`, `, password=...`. */\nconst QUERY_CREDENTIAL_PATTERN =\n /([?&;,#\\s])(access_token|refresh_token|id_token|token|api_key|apikey|x-api-key|key|auth|password|passwd|pwd|secret|client_secret|signature|sig|x-amz-signature|x-amz-security-token|jwt|session_id|sessionid|code)=([^&\\s#,)]*)/gi;\n\n/** A string with the credentials it carries masked: a connection url's password, a bearer token, a credential query parameter. */\nconst scrubString = (value: string): string => {\n if (!value.includes('@') && !value.includes('=') && !/bearer|basic/i.test(value)) {\n return value;\n }\n\n return value\n .replace(URL_USERINFO_PATTERN, `$1:${'[REDACTED]'}@`)\n .replace(URL_USER_ONLY_PATTERN, `://${'[REDACTED]'}@`)\n .replace(AUTH_SCHEME_PATTERN, `$1 ${'[REDACTED]'}`)\n .replace(QUERY_CREDENTIAL_PATTERN, `$1$2=${'[REDACTED]'}`);\n};\n\n/** Kill-switch for local debugging: only the literal `false` disables redaction (fail-closed); read per call so it can be flipped at runtime. Never disable in production. `force` is the caller opting out of the switch: it always masks. */\nconst isRedactionEnabled = (force?: boolean): boolean =>\n force === true || globalThis.process?.env?.APP_ENV_LOGGER_DO_REDACT !== 'false';\n\n/** Longest string a log line carries whole. `APP_ENV_LOGGER_MAX_STRING_LENGTH=0` turns capping off. */\nconst DEFAULT_MAX_STRING_LENGTH = 2048;\n\nconst resolveMaxStringLength = (): number => {\n const configured = Number(globalThis.process?.env?.APP_ENV_LOGGER_MAX_STRING_LENGTH);\n\n return Number.isFinite(configured) && configured >= 0 ? configured : DEFAULT_MAX_STRING_LENGTH;\n};\n\n/**\n * Keys whose value is long BY NATURE and useless truncated. A stack trace is the whole reason you\n * are reading the line.\n */\nconst UNCAPPED_KEYS = new Set(['stack', 'stacktrace', 'stack_trace']);\n\n/**\n * Caps a long string, keeping the ORIGINAL LENGTH in the marker - that number is what tells you the\n * payload was a 300 KB image rather than a truncated sentence.\n *\n * A base64 body is the case this exists for: one `data:image/png;base64,...` field turns a request\n * log into hundreds of kilobytes, and nothing about it is readable.\n */\nconst capString = (opts: { value: string; key?: string; limit: number }): string => {\n const { value, key, limit } = opts;\n\n if (limit === 0 || value.length <= limit || (key && UNCAPPED_KEYS.has(key.toLowerCase()))) {\n return value;\n }\n\n return `${value.slice(0, limit)}... [truncated, ${value.length} chars total]`;\n};\n\ntype TSanitizeContext = {\n seen: WeakSet<object>;\n doRedact: boolean;\n /** Levels still allowed BELOW the current one; `Infinity` walks the whole graph. */\n depth: number;\n /** Longest string kept whole; 0 keeps every string. */\n maxStringLength: number;\n /** The key this value was found under, so a stack trace can be exempted from capping. */\n key?: string;\n};\n\nconst deepSanitize = (value: unknown, context: TSanitizeContext): unknown => {\n const { seen, doRedact, depth } = context;\n\n if (typeof value === 'string') {\n const text = doRedact ? scrubString(value) : value;\n\n return capString({ value: text, key: context.key, limit: context.maxStringLength });\n }\n\n // A function is not data, and an own `toJSON` on an object would run after this walk, inside `JSON.stringify`, and\n // hand back keys the walk never saw. Naming it keeps the redacted copy free of code.\n if (typeof value === 'function') {\n return '[Function]';\n }\n\n if (value === null || typeof value !== 'object') {\n return value;\n }\n\n // A Date holds its value in an internal slot, so the generic branch below - which reads Object.keys() - would flatten it to `{}`. Checked BEFORE `seen`: a Date cannot carry a cycle, and entering the set would make a second reference to the same instance read as `[Circular]`.\n if (value instanceof Date) {\n return value;\n }\n\n if (seen.has(value)) {\n return '[Circular]';\n }\n\n if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer) {\n return `[Binary ${(value as ArrayBufferView).byteLength ?? 0} bytes]`;\n }\n\n if (depth <= 0) {\n return Array.isArray(value) ? '[Array]' : '[Object]';\n }\n\n seen.add(value);\n const nested: TSanitizeContext = {\n seen,\n doRedact,\n depth: depth - 1,\n maxStringLength: context.maxStringLength,\n };\n\n // Error keeps name/message/stack NON-enumerable, so Object.keys() skips them and naive redaction would drop the message - reproject into a plain object carrying those fields plus its redacted enumerable own-props.\n if (value instanceof Error) {\n const source = value;\n const result: Record<string, unknown> = {\n name: value.name,\n message: doRedact ? scrubString(value.message) : value.message,\n stack: doRedact && value.stack ? scrubString(value.stack) : value.stack,\n };\n\n for (const [key, entry] of Object.entries(source)) {\n result[key] =\n doRedact && SECRET_KEY_PATTERN.test(key)\n ? REDACTED\n : deepSanitize(entry, { ...nested, key });\n }\n\n return result;\n }\n\n if (Array.isArray(value)) {\n return value.map((entry) => deepSanitize(entry, nested));\n }\n\n const source = value;\n const result: Record<string, unknown> = {};\n\n for (const [key, entry] of Object.entries(source)) {\n if (doRedact && SECRET_KEY_PATTERN.test(key)) {\n result[key] = REDACTED;\n continue;\n }\n\n result[key] = deepSanitize(entry, { ...nested, key });\n }\n\n return result;\n};\n\n/** Makes a log argument safe to print: masks secret-looking keys, breaks cycles, caps long strings and strips URL credentials. `APP_ENV_LOGGER_DO_REDACT=false` turns off the key masking only. */\nexport class RedactUtility {\n /**\n * Redacts every secret-looking KEY (not value shape - buffers/typed arrays are summarized, not\n * serialized). `APP_ENV_LOGGER_DO_REDACT=false` makes this the identity function.\n *\n * `depth` bounds the walk, exactly as {@link RedactUtility.toJsonSafe} already does. It defaults to\n * `Infinity` for callers that really do want the whole graph, but the logger passes its own bound:\n * rendering only inspects a handful of levels, so walking to `Infinity` did work whose result was\n * thrown away - 12x on a deep graph, and a `RangeError` on a very deep chain.\n *\n * `force: true` masks secret-looking KEYS even when `APP_ENV_LOGGER_DO_REDACT=false`. The result is still the\n * log-shaped copy: long strings are capped, a second reference to one object reads `[Circular]`, binary is\n * summarized, and a key is masked by name only (a card number under `number` is not). It is not a faithful\n * redacted document. The logger never sets it.\n */\n static redactSecrets(opts: {\n value: unknown;\n seen?: WeakSet<object>;\n depth?: number;\n force?: boolean;\n }): unknown {\n const { value, seen, depth = Infinity, force } = opts;\n\n if (!isRedactionEnabled(force)) {\n return value;\n }\n\n return deepSanitize(value, {\n seen: seen ?? new WeakSet<object>(),\n doRedact: true,\n depth,\n maxStringLength: resolveMaxStringLength(),\n });\n }\n\n /** Masks the credentials a plain string carries (a url's password, a bearer token, credential query parameters). For a log line's string argument; objects go through {@link RedactUtility.redactSecrets}. `force: true` scrubs even when `APP_ENV_LOGGER_DO_REDACT=false`. */\n static scrubText(opts: { value: string; force?: boolean }): string {\n return isRedactionEnabled(opts.force) ? scrubString(opts.value) : opts.value;\n }\n\n /** Projects a value into something `JSON.stringify` can render: it answers `[Circular]` for the WHOLE payload when one cycle sits anywhere inside it, so cycles must be broken per-branch first. `depth` bounds the walk the way `util.inspect` does - a log argument may hold a live connector or request context, whose graph is effectively unbounded. The projection itself is unconditional: `APP_ENV_LOGGER_DO_REDACT=false` turns off the key masking, never the structural pass. `force: true` keeps the key masking on whatever the switch says; the projection stays lossy, as in {@link RedactUtility.redactSecrets}. */\n static toJsonSafe(opts: { value: unknown; depth?: number; force?: boolean }): unknown {\n return deepSanitize(opts.value, {\n seen: new WeakSet<object>(),\n doRedact: isRedactionEnabled(opts.force),\n depth: opts.depth ?? Infinity,\n // Capping is STRUCTURAL, like the projection itself: turning redaction off is about key masking,\n // never about letting a 300 KB base64 field through.\n maxStringLength: resolveMaxStringLength(),\n });\n }\n\n /** Strips credentials from a connection URL's authority section (`user:hunter2@host` -> `user:[REDACTED]@host`) - {@link RedactUtility.redactSecrets} matches on KEY names and can't see them there. A value that fails to parse as a URL is returned unchanged. `force: true` strips even when `APP_ENV_LOGGER_DO_REDACT=false`. */\n static redactUrlCredentials(opts: { url: string; force?: boolean }): string {\n const { url, force } = opts;\n\n if (!isRedactionEnabled(force)) {\n return url;\n }\n\n let parsed: URL;\n\n try {\n parsed = new URL(url);\n } catch {\n return url;\n }\n\n if (!parsed.password) {\n return url;\n }\n\n parsed.password = REDACTED;\n\n return decodeURIComponent(parsed.toString());\n }\n}\n"]}
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
/** A concrete class constructor producing `T`. */
|
|
2
|
-
export type TConstructor<T> = new (...args:
|
|
2
|
+
export type TConstructor<T> = new (...args: never[]) => T;
|
|
3
3
|
/** An abstract class constructor producing `T`; it cannot be called with `new` directly. */
|
|
4
|
-
export type TAbstractConstructor<T> = abstract new (...args:
|
|
5
|
-
/** A concrete class producing `T
|
|
6
|
-
export type TClass<T> = TConstructor<T
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
export type TAbstractConstructor<T> = abstract new (...args: never[]) => T;
|
|
5
|
+
/** A concrete class producing `T`. Read its static members through a type that declares them, such as `typeof MyClass`. */
|
|
6
|
+
export type TClass<T> = TConstructor<T>;
|
|
7
|
+
/** An abstract class producing `T`. */
|
|
8
|
+
export type TAbstractClass<T> = TAbstractConstructor<T>;
|
|
9
|
+
/**
|
|
10
|
+
* The constructor shape a mixin base takes. TypeScript requires `new (...args: any[]) => T` here (error TS2545: a mixin class must have a constructor with a single rest parameter of type `any[]`), so this is the one `any` the language mandates.
|
|
11
|
+
*/
|
|
12
|
+
export type TMixinConstructor<T> = new (...args: any[]) => T;
|
|
13
|
+
/** The abstract form of {@link TMixinConstructor}. */
|
|
14
|
+
export type TAbstractMixinConstructor<T> = abstract new (...args: any[]) => T;
|
|
13
15
|
/** The constructor type a mixin accepts as its base: it must produce at least the members of `T`. */
|
|
14
|
-
export type TMixinTarget<T> =
|
|
16
|
+
export type TMixinTarget<T> = TMixinConstructor<{
|
|
15
17
|
[P in keyof T]: T[P];
|
|
16
18
|
}>;
|
|
17
19
|
/** `TMixinTarget` for an abstract base class. */
|
|
18
|
-
export type TAbstractMixinTarget<T> =
|
|
20
|
+
export type TAbstractMixinTarget<T> = TAbstractMixinConstructor<{
|
|
19
21
|
[P in keyof T]: T[P];
|
|
20
22
|
}>;
|
|
21
23
|
//# sourceMappingURL=class.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class.js","sourceRoot":"","sources":["../../../../src/common/types/class.ts"],"names":[],"mappings":"","sourcesContent":["/** A concrete class constructor producing `T`. */\nexport type TConstructor<T> = new (...args:
|
|
1
|
+
{"version":3,"file":"class.js","sourceRoot":"","sources":["../../../../src/common/types/class.ts"],"names":[],"mappings":"","sourcesContent":["/** A concrete class constructor producing `T`. */\nexport type TConstructor<T> = new (...args: never[]) => T;\n/** An abstract class constructor producing `T`; it cannot be called with `new` directly. */\nexport type TAbstractConstructor<T> = abstract new (...args: never[]) => T;\n/** A concrete class producing `T`. Read its static members through a type that declares them, such as `typeof MyClass`. */\nexport type TClass<T> = TConstructor<T>;\n/** An abstract class producing `T`. */\nexport type TAbstractClass<T> = TAbstractConstructor<T>;\n\n/**\n * The constructor shape a mixin base takes. TypeScript requires `new (...args: any[]) => T` here (error TS2545: a mixin class must have a constructor with a single rest parameter of type `any[]`), so this is the one `any` the language mandates.\n */\nexport type TMixinConstructor<T> = new (...args: any[]) => T;\n/** The abstract form of {@link TMixinConstructor}. */\nexport type TAbstractMixinConstructor<T> = abstract new (...args: any[]) => T;\n\n/** The constructor type a mixin accepts as its base: it must produce at least the members of `T`. */\nexport type TMixinTarget<T> = TMixinConstructor<{ [P in keyof T]: T[P] }>;\n/** `TMixinTarget` for an abstract base class. */\nexport type TAbstractMixinTarget<T> = TAbstractMixinConstructor<{ [P in keyof T]: T[P] }>;\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { TClass } from './class.js';
|
|
2
2
|
import type { ValueOf } from './utility.js';
|
|
3
3
|
/** The string values held by the `static readonly` members of const class `T`, as a plain union. */
|
|
4
|
-
export type TStringConstValue<T extends TClass<
|
|
4
|
+
export type TStringConstValue<T extends TClass<unknown>> = Extract<ValueOf<T>, string> & {};
|
|
5
5
|
/** The number values held by the `static readonly` members of const class `T`, as a plain union. */
|
|
6
|
-
export type TNumberConstValue<T extends TClass<
|
|
6
|
+
export type TNumberConstValue<T extends TClass<unknown>> = Extract<ValueOf<T>, number> & {};
|
|
7
7
|
/** The string and number values held by the `static readonly` members of const class `T`, as a plain union. */
|
|
8
|
-
export type TConstValue<T extends TClass<
|
|
8
|
+
export type TConstValue<T extends TClass<unknown>> = Extract<ValueOf<T>, string | number> & {};
|
|
9
9
|
//# sourceMappingURL=const-value.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const-value.js","sourceRoot":"","sources":["../../../../src/common/types/const-value.ts"],"names":[],"mappings":"","sourcesContent":["import type { TClass } from './class';\nimport type { ValueOf } from './utility';\n\n/*\n * `& {}` keeps the same literal set but makes it a regular union. Without it the members of a\n * `static readonly` const class stay widening literals, and a value of these types widens to\n * `string` / `number` in an object literal, a `let`, or a generic inference.\n */\n/** The string values held by the `static readonly` members of const class `T`, as a plain union. */\nexport type TStringConstValue<T extends TClass<
|
|
1
|
+
{"version":3,"file":"const-value.js","sourceRoot":"","sources":["../../../../src/common/types/const-value.ts"],"names":[],"mappings":"","sourcesContent":["import type { TClass } from './class';\nimport type { ValueOf } from './utility';\n\n/*\n * `& {}` keeps the same literal set but makes it a regular union. Without it the members of a\n * `static readonly` const class stay widening literals, and a value of these types widens to\n * `string` / `number` in an object literal, a `let`, or a generic inference.\n */\n/** The string values held by the `static readonly` members of const class `T`, as a plain union. */\nexport type TStringConstValue<T extends TClass<unknown>> = Extract<ValueOf<T>, string> & {};\n/** The number values held by the `static readonly` members of const class `T`, as a plain union. */\nexport type TNumberConstValue<T extends TClass<unknown>> = Extract<ValueOf<T>, number> & {};\n/** The string and number values held by the `static readonly` members of const class `T`, as a plain union. */\nexport type TConstValue<T extends TClass<unknown>> = Extract<ValueOf<T>, string | number> & {};\n"]}
|
|
@@ -23,28 +23,28 @@ export type TFieldMappingNames<T extends Array<IFieldMapping>> = Extract<T[numbe
|
|
|
23
23
|
export type TObjectFromFieldMappings<T extends readonly {
|
|
24
24
|
name: string;
|
|
25
25
|
type: string;
|
|
26
|
-
[extra: string | symbol]:
|
|
26
|
+
[extra: string | symbol]: unknown;
|
|
27
27
|
}[]> = {
|
|
28
28
|
[K in T[number]['name']]: T extends {
|
|
29
29
|
name: K;
|
|
30
30
|
type: 'string';
|
|
31
|
-
[extra: string | symbol]:
|
|
31
|
+
[extra: string | symbol]: unknown;
|
|
32
32
|
} ? string : T extends {
|
|
33
33
|
name: K;
|
|
34
34
|
type: 'number';
|
|
35
|
-
[extra: string | symbol]:
|
|
35
|
+
[extra: string | symbol]: unknown;
|
|
36
36
|
} ? number : T extends {
|
|
37
37
|
name: K;
|
|
38
38
|
type: 'boolean';
|
|
39
|
-
[extra: string | symbol]:
|
|
39
|
+
[extra: string | symbol]: unknown;
|
|
40
40
|
} ? boolean : T extends {
|
|
41
41
|
name: K;
|
|
42
42
|
type: 'strings';
|
|
43
|
-
[extra: string | symbol]:
|
|
43
|
+
[extra: string | symbol]: unknown;
|
|
44
44
|
} ? string[] : T extends {
|
|
45
45
|
name: K;
|
|
46
46
|
type: 'numbers';
|
|
47
|
-
[extra: string | symbol]:
|
|
47
|
+
[extra: string | symbol]: unknown;
|
|
48
48
|
} ? number[] : never;
|
|
49
49
|
};
|
|
50
50
|
//# sourceMappingURL=field-mapping.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-mapping.js","sourceRoot":"","sources":["../../../../src/common/types/field-mapping.ts"],"names":[],"mappings":"AAEA,6CAA6C;AAC7C,MAAM,OAAO,qBAAqB;aAChB,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,YAAO,GAAG,SAAS,CAAC;aACpB,YAAO,GAAG,SAAS,CAAC;aACpB,YAAO,GAAG,SAAS,CAAC","sourcesContent":["import type { TConstValue } from './const-value';\n\n/** The value kinds a field mapping reads. */\nexport class FieldMappingDataTypes {\n static readonly STRING = 'string';\n static readonly NUMBER = 'number';\n static readonly STRINGS = 'strings';\n static readonly NUMBERS = 'numbers';\n static readonly BOOLEAN = 'boolean';\n}\n\n/** Valid field mapping data type values. */\nexport type TFieldMappingDataType = TConstValue<typeof FieldMappingDataTypes>;\n\n/** Describes one field to read: its `name`, its value `type`, and an optional `default`. */\nexport interface IFieldMapping {\n name: string;\n type: TFieldMappingDataType;\n default?: string | number | Array<string> | Array<number> | boolean;\n}\n\n/** The union of `name` values in a list of field mappings. */\nexport type TFieldMappingNames<T extends Array<IFieldMapping>> = Extract<\n T[number],\n { type: Exclude<T[number]['type'], undefined> }\n>['name'];\n\n/** The object a list of field mappings yields: one key per `name`, typed from its `type` (`string`, `number`, `boolean`, `strings` or `numbers`). Needs the list typed as a literal (`as const`) to narrow. */\nexport type TObjectFromFieldMappings<\n T extends readonly {\n name: string;\n type: string;\n [extra: string | symbol]:
|
|
1
|
+
{"version":3,"file":"field-mapping.js","sourceRoot":"","sources":["../../../../src/common/types/field-mapping.ts"],"names":[],"mappings":"AAEA,6CAA6C;AAC7C,MAAM,OAAO,qBAAqB;aAChB,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,YAAO,GAAG,SAAS,CAAC;aACpB,YAAO,GAAG,SAAS,CAAC;aACpB,YAAO,GAAG,SAAS,CAAC","sourcesContent":["import type { TConstValue } from './const-value';\n\n/** The value kinds a field mapping reads. */\nexport class FieldMappingDataTypes {\n static readonly STRING = 'string';\n static readonly NUMBER = 'number';\n static readonly STRINGS = 'strings';\n static readonly NUMBERS = 'numbers';\n static readonly BOOLEAN = 'boolean';\n}\n\n/** Valid field mapping data type values. */\nexport type TFieldMappingDataType = TConstValue<typeof FieldMappingDataTypes>;\n\n/** Describes one field to read: its `name`, its value `type`, and an optional `default`. */\nexport interface IFieldMapping {\n name: string;\n type: TFieldMappingDataType;\n default?: string | number | Array<string> | Array<number> | boolean;\n}\n\n/** The union of `name` values in a list of field mappings. */\nexport type TFieldMappingNames<T extends Array<IFieldMapping>> = Extract<\n T[number],\n { type: Exclude<T[number]['type'], undefined> }\n>['name'];\n\n/** The object a list of field mappings yields: one key per `name`, typed from its `type` (`string`, `number`, `boolean`, `strings` or `numbers`). Needs the list typed as a literal (`as const`) to narrow. */\nexport type TObjectFromFieldMappings<\n T extends readonly {\n name: string;\n type: string;\n [extra: string | symbol]: unknown;\n }[],\n> = {\n [K in T[number]['name']]: T extends {\n name: K;\n type: 'string';\n [extra: string | symbol]: unknown;\n }\n ? string\n : T extends { name: K; type: 'number'; [extra: string | symbol]: unknown }\n ? number\n : T extends { name: K; type: 'boolean'; [extra: string | symbol]: unknown }\n ? boolean\n : T extends { name: K; type: 'strings'; [extra: string | symbol]: unknown }\n ? string[]\n : T extends {\n name: K;\n type: 'numbers';\n [extra: string | symbol]: unknown;\n }\n ? number[]\n : never;\n};\n"]}
|
|
@@ -4,7 +4,7 @@ export type TInjectionGetter = <T>(opts: {
|
|
|
4
4
|
key: string | symbol;
|
|
5
5
|
}) => T;
|
|
6
6
|
/** Something set up by a `configure` call, which may be asynchronous. */
|
|
7
|
-
export interface IConfigurable<Options extends object =
|
|
7
|
+
export interface IConfigurable<Options extends object = object, Result = unknown> {
|
|
8
8
|
configure(opts?: Options): ValueOrPromise<Result>;
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=injection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injection.js","sourceRoot":"","sources":["../../../../src/common/types/injection.ts"],"names":[],"mappings":"","sourcesContent":["import type { ValueOrPromise } from './utility';\n\n/** Reads one value by binding `key` from the container; the caller supplies `T`. */\nexport type TInjectionGetter = <T>(opts: { key: string | symbol }) => T;\n\n/** Something set up by a `configure` call, which may be asynchronous. */\nexport interface IConfigurable<Options extends object =
|
|
1
|
+
{"version":3,"file":"injection.js","sourceRoot":"","sources":["../../../../src/common/types/injection.ts"],"names":[],"mappings":"","sourcesContent":["import type { ValueOrPromise } from './utility';\n\n/** Reads one value by binding `key` from the container; the caller supplies `T`. */\nexport type TInjectionGetter = <T>(opts: { key: string | symbol }) => T;\n\n/** Something set up by a `configure` call, which may be asynchronous. */\nexport interface IConfigurable<Options extends object = object, Result = unknown> {\n configure(opts?: Options): ValueOrPromise<Result>;\n}\n"]}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
/** `T`, `undefined` or `null`. */
|
|
2
2
|
export type TNullable<T> = T | undefined | null;
|
|
3
|
-
/** Escape hatch for a value of unknown shape; prefer a real type. */
|
|
4
|
-
export type AnyType = any;
|
|
5
|
-
/** An object with any string, number or symbol keys. */
|
|
6
|
-
export type AnyObject = Record<string | symbol | number, any>;
|
|
7
3
|
/** An options object of shape `T`; empty by default. */
|
|
8
4
|
export type TOptions<T extends object = {}> = T;
|
|
9
5
|
/** `T` or a promise of `T`; `await` it to get `T` either way. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utility.js","sourceRoot":"","sources":["../../../../src/common/types/utility.ts"],"names":[],"mappings":"","sourcesContent":["/** `T`, `undefined` or `null`. */\nexport type TNullable<T> = T | undefined | null;\n\n/**
|
|
1
|
+
{"version":3,"file":"utility.js","sourceRoot":"","sources":["../../../../src/common/types/utility.ts"],"names":[],"mappings":"","sourcesContent":["/** `T`, `undefined` or `null`. */\nexport type TNullable<T> = T | undefined | null;\n\n/** An options object of shape `T`; empty by default. */\nexport type TOptions<T extends object = {}> = T;\n\n/** `T` or a promise of `T`; `await` it to get `T` either way. */\nexport type ValueOrPromise<T> = T | Promise<T>;\n/** The union of the property value types of `T`. */\nexport type ValueOf<T> = T[keyof T];\n\n/** `T` with the keys `K` made optional. */\nexport type ValueOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n/** `T` with every key optional except `K`. */\nexport type ValueOptionalExcept<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>>;\n\n/** Flattens an intersection of types into one object type, for readable hovers. */\nexport type TPrettify<T> = { [K in keyof T]: T[K] } & {};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseHelper } from '../base.js';
|
|
2
2
|
import { EnvironmentNames } from './names.js';
|
|
3
|
-
import { type IApplicationEnvironment } from './common/index.js';
|
|
3
|
+
import { type IApplicationEnvironment, type IApplicationEnvironmentDefaultedTransformOptions, type IApplicationEnvironmentTransformOptions } from './common/index.js';
|
|
4
4
|
/** Adds the `NODE_ENV` reads to {@link EnvironmentNames}. Every name and set is inherited, so `Environment.PRODUCTION`, `Environment.COMMON_ENVS` and `Environment.DEVELOPMENT_ENVS` keep resolving here; only these two members need a `process`. */
|
|
5
5
|
export declare class Environment extends EnvironmentNames {
|
|
6
6
|
/** `NODE_ENV` exactly as the host has it, `undefined` when unset. Destructured on purpose: `bun build` rewrites `process.env.NODE_ENV` to a literal at build time, a destructured read stays a runtime read. */
|
|
@@ -16,7 +16,7 @@ export declare class ApplicationEnvironment extends BaseHelper implements IAppli
|
|
|
16
16
|
private arguments;
|
|
17
17
|
constructor(opts: {
|
|
18
18
|
prefix: string;
|
|
19
|
-
envs: Record<string, string |
|
|
19
|
+
envs: Record<string, string | undefined>;
|
|
20
20
|
});
|
|
21
21
|
/**
|
|
22
22
|
* Reads one name. A line that is present but empty - `KEY=`, or padded to `KEY= ` by a hand
|
|
@@ -29,13 +29,22 @@ export declare class ApplicationEnvironment extends BaseHelper implements IAppli
|
|
|
29
29
|
* receives `''` unchanged, so no existing read changes shape. `'0'` and `'false'` are values and
|
|
30
30
|
* are never normalised.
|
|
31
31
|
*/
|
|
32
|
-
get
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}):
|
|
36
|
-
|
|
32
|
+
get(key: string): string | undefined;
|
|
33
|
+
get(key: string, opts: {
|
|
34
|
+
defaultValue: string;
|
|
35
|
+
}): string;
|
|
36
|
+
get<R>(key: string, opts: IApplicationEnvironmentDefaultedTransformOptions<R>): R;
|
|
37
|
+
get<R>(key: string, opts: IApplicationEnvironmentTransformOptions<R>): R;
|
|
38
|
+
/**
|
|
39
|
+
* A variable the app cannot run without: it is set and not blank (the rule `get` applies to a `defaultValue`), or this throws an error naming the key. The check runs before `transform`, so `transform` receives a `string`; a `transform` that answers null or undefined throws too. A required value has no `defaultValue`.
|
|
40
|
+
*/
|
|
41
|
+
getRequired(key: string): string;
|
|
42
|
+
getRequired<R>(key: string, opts: {
|
|
43
|
+
transform: (raw: string) => R | null | undefined;
|
|
44
|
+
}): R;
|
|
45
|
+
set(key: string, value: string | undefined): void;
|
|
37
46
|
merge(opts: {
|
|
38
|
-
envs: Record<string, string>;
|
|
47
|
+
envs: Record<string, string | undefined>;
|
|
39
48
|
}): void;
|
|
40
49
|
isDevelopment(): boolean;
|
|
41
50
|
keys(): string[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ParseUtility } from '../../utilities/parse.utility.js';
|
|
2
2
|
import { BaseHelper } from '../base.js';
|
|
3
|
+
import { getError } from '../error/index.js';
|
|
3
4
|
import { EnvironmentNames } from './names.js';
|
|
4
5
|
/** Adds the `NODE_ENV` reads to {@link EnvironmentNames}. Every name and set is inherited, so `Environment.PRODUCTION`, `Environment.COMMON_ENVS` and `Environment.DEVELOPMENT_ENVS` keep resolving here; only these two members need a `process`. */
|
|
5
6
|
export class Environment extends EnvironmentNames {
|
|
@@ -28,26 +29,28 @@ export class ApplicationEnvironment extends BaseHelper {
|
|
|
28
29
|
this.arguments[key] = opts.envs[key];
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Reads one name. A line that is present but empty - `KEY=`, or padded to `KEY= ` by a hand
|
|
33
|
-
* edit - is a pipeline that forgot to export the value, not a value: it is normalised to
|
|
34
|
-
* `undefined` so `defaultValue` applies, and `transform` is handed that `undefined` rather than
|
|
35
|
-
* the empty string.
|
|
36
|
-
*
|
|
37
|
-
* The normalisation runs ONLY when the caller supplied a `defaultValue`, because that call site
|
|
38
|
-
* has already declared what it wants when the name carries nothing. A caller without one still
|
|
39
|
-
* receives `''` unchanged, so no existing read changes shape. `'0'` and `'false'` are values and
|
|
40
|
-
* are never normalised.
|
|
41
|
-
*/
|
|
42
32
|
get(key, opts) {
|
|
43
33
|
const raw = this.arguments[key];
|
|
44
|
-
const isBlank = raw
|
|
34
|
+
const isBlank = raw == null || (typeof raw === 'string' && !raw.trim());
|
|
45
35
|
const rs = opts?.defaultValue !== undefined && isBlank ? undefined : raw;
|
|
46
36
|
if (!opts?.transform) {
|
|
47
|
-
return
|
|
37
|
+
return rs ?? opts?.defaultValue;
|
|
48
38
|
}
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
return opts.transform(rs) ?? opts.defaultValue;
|
|
40
|
+
}
|
|
41
|
+
getRequired(key, opts) {
|
|
42
|
+
const value = this.get(key);
|
|
43
|
+
if (typeof value !== 'string' || !value.trim()) {
|
|
44
|
+
throw getError({ message: `[getRequired] ${key} is not set` });
|
|
45
|
+
}
|
|
46
|
+
if (!opts) {
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
const transformed = opts.transform(value);
|
|
50
|
+
if (transformed === null || transformed === undefined) {
|
|
51
|
+
throw getError({ message: `[getRequired] ${key} is not valid` });
|
|
52
|
+
}
|
|
53
|
+
return transformed;
|
|
51
54
|
}
|
|
52
55
|
set(key, value) {
|
|
53
56
|
this.arguments[key] = value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-env.js","sourceRoot":"","sources":["../../../../src/modules/env/app-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"app-env.js","sourceRoot":"","sources":["../../../../src/modules/env/app-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC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AAC,CAAC;QAE9C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC;YACvC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAC9B,CAAC;IACH,CAAC;IAED,aAAa;QACX,OAAO,WAAW,CAAC,OAAO,KAAK,aAAa,CAAC;IAC/C,CAAC;IAED,IAAI;QACF,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;CACF;AAED,iNAAiN;AACjN,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;AAElE,MAAM,6BAA6B,GAAG,GAA2B,EAAE;IACjE,MAAM,MAAM,GAAuC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAE1F,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,sBAAsB,CAAC;QACzC,MAAM,EACJ,YAAY,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,CAAC,IAAI,SAAS;QAC3F,IAAI,EAAE,OAAO,CAAC,GAAG;KAClB,CAAC,CAAC;IACH,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;IAEhD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,2MAA2M;AAC3M,MAAM,CAAC,MAAM,sBAAsB,GAAG,6BAA6B,EAAE,CAAC;AAEtE,yCAAyC;AACzC,MAAM,CAAC,MAAM,OAAO,GAAG,sBAAsB,CAAC","sourcesContent":["import { ParseUtility } from '@/utilities/parse.utility';\nimport { BaseHelper } from '@/modules/base';\nimport { getError } from '@/modules/error';\nimport { EnvironmentNames } from './names';\nimport {\n type IApplicationEnvironment,\n type IApplicationEnvironmentDefaultedTransformOptions,\n type IApplicationEnvironmentTransformOptions,\n} from './common';\n\n/** Adds the `NODE_ENV` reads to {@link EnvironmentNames}. Every name and set is inherited, so `Environment.PRODUCTION`, `Environment.COMMON_ENVS` and `Environment.DEVELOPMENT_ENVS` keep resolving here; only these two members need a `process`. */\nexport class Environment extends EnvironmentNames {\n /** `NODE_ENV` exactly as the host has it, `undefined` when unset. Destructured on purpose: `bun build` rewrites `process.env.NODE_ENV` to a literal at build time, a destructured read stays a runtime read. */\n static get ambient(): string | undefined {\n const { NODE_ENV } = process.env;\n\n return NODE_ENV;\n }\n\n static get current(): string {\n return Environment.ambient ?? Environment.DEVELOPMENT;\n }\n\n static is(opts: { name: string }) {\n return this.current === opts.name;\n }\n}\n\n/** Key-value store of the environment entries whose key starts with `prefix`; other keys are dropped at construction. `get` applies a default and an optional transform. Use the shared `applicationEnvironment` instance rather than constructing one. */\nexport class ApplicationEnvironment extends BaseHelper implements IApplicationEnvironment {\n private prefix: string;\n private arguments: Record<string, string | undefined> = Object.create(null);\n\n constructor(opts: { prefix: string; envs: Record<string, string | undefined> }) {\n super({ scope: ApplicationEnvironment.name });\n\n this.prefix = opts.prefix;\n\n for (const key in opts.envs) {\n if (!key.startsWith(this.prefix)) {\n continue;\n }\n\n this.arguments[key] = opts.envs[key];\n }\n }\n\n /**\n * Reads one name. A line that is present but empty - `KEY=`, or padded to `KEY= ` by a hand\n * edit - is a pipeline that forgot to export the value, not a value: it is normalised to\n * `undefined` so `defaultValue` applies, and `transform` is handed that `undefined` rather than\n * the empty string.\n *\n * The normalisation runs ONLY when the caller supplied a `defaultValue`, because that call site\n * has already declared what it wants when the name carries nothing. A caller without one still\n * receives `''` unchanged, so no existing read changes shape. `'0'` and `'false'` are values and\n * are never normalised.\n */\n get(key: string): string | undefined;\n get(key: string, opts: { defaultValue: string }): string;\n get<R>(key: string, opts: IApplicationEnvironmentDefaultedTransformOptions<R>): R;\n // oxlint-disable-next-line typescript/unified-signatures -- one union parameter infers `R` from the transform alone (`number | undefined`); two overloads let the `defaultValue` fix `R`\n get<R>(key: string, opts: IApplicationEnvironmentTransformOptions<R>): R;\n get<R>(\n key: string,\n opts?: {\n defaultValue?: string | R;\n transform?: (raw: string | undefined) => R | null | undefined;\n },\n ): string | R | undefined {\n const raw = this.arguments[key];\n\n const isBlank = raw == null || (typeof raw === 'string' && !raw.trim());\n const rs = opts?.defaultValue !== undefined && isBlank ? undefined : raw;\n\n if (!opts?.transform) {\n return rs ?? opts?.defaultValue;\n }\n\n return opts.transform(rs) ?? opts.defaultValue;\n }\n\n /**\n * A variable the app cannot run without: it is set and not blank (the rule `get` applies to a `defaultValue`), or this throws an error naming the key. The check runs before `transform`, so `transform` receives a `string`; a `transform` that answers null or undefined throws too. A required value has no `defaultValue`.\n */\n getRequired(key: string): string;\n getRequired<R>(key: string, opts: { transform: (raw: string) => R | null | undefined }): R;\n getRequired<R>(\n key: string,\n opts?: { transform: (raw: string) => R | null | undefined },\n ): string | R {\n const value = this.get(key);\n\n if (typeof value !== 'string' || !value.trim()) {\n throw getError({ message: `[getRequired] ${key} is not set` });\n }\n\n if (!opts) {\n return value;\n }\n\n const transformed = opts.transform(value);\n\n if (transformed === null || transformed === undefined) {\n throw getError({ message: `[getRequired] ${key} is not valid` });\n }\n\n return transformed;\n }\n\n set(key: string, value: string | undefined): void {\n this.arguments[key] = value;\n }\n\n merge(opts: { envs: Record<string, string | undefined> }) {\n const envsEntries = Object.entries(opts.envs);\n\n for (const [key, value] of envsEntries) {\n this.arguments[key] = value;\n }\n }\n\n isDevelopment() {\n return Environment.ambient === 'development';\n }\n\n keys() {\n return Object.keys(this.arguments);\n }\n}\n\n/** A process can carry two copies of this module - an application's ESM import beside a CommonJS require. The instance lives in this globalThis slot so a `set()` through one copy is read through the other. */\nconst INSTANCE_SLOT = Symbol.for('ignis:application-environment');\n\nconst resolveApplicationEnvironment = (): ApplicationEnvironment => {\n const shared: ApplicationEnvironment | undefined = Reflect.get(globalThis, INSTANCE_SLOT);\n\n if (shared) {\n return shared;\n }\n\n const created = new ApplicationEnvironment({\n prefix:\n ParseUtility.blankToUndefined({ input: process.env.APPLICATION_ENV_PREFIX }) ?? 'APP_ENV',\n envs: process.env,\n });\n Reflect.set(globalThis, INSTANCE_SLOT, created);\n\n return created;\n};\n\n/** The process-wide environment store, built from `process.env` with the prefix in `APPLICATION_ENV_PREFIX` (`APP_ENV` when unset). One instance is shared by every copy of this module in the process. */\nexport const applicationEnvironment = resolveApplicationEnvironment();\n\n/** Alias of `applicationEnvironment`. */\nexport const AppEnvs = applicationEnvironment;\n"]}
|
|
@@ -1,9 +1,25 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Options of `get` that run a `transform` over the raw value; `defaultValue` applies when the value is absent or the transform answers null or undefined. */
|
|
2
|
+
export interface IApplicationEnvironmentTransformOptions<R> {
|
|
3
|
+
transform: (raw: string | undefined) => R;
|
|
4
|
+
defaultValue?: R;
|
|
5
|
+
}
|
|
6
|
+
/** A `transform` that may answer null or undefined, with the `defaultValue` that then applies: the read answers `R`. */
|
|
7
|
+
export interface IApplicationEnvironmentDefaultedTransformOptions<R> {
|
|
8
|
+
transform: (raw: string | undefined) => R | null | undefined;
|
|
9
|
+
defaultValue: R;
|
|
10
|
+
}
|
|
11
|
+
/** Read and write contract of the application environment store. Every value is a string: `get` answers the raw string (or `undefined`), the `defaultValue` of a string read, or what a `transform` makes of the raw string. */
|
|
2
12
|
export interface IApplicationEnvironment {
|
|
3
|
-
get
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}):
|
|
7
|
-
|
|
13
|
+
get(key: string): string | undefined;
|
|
14
|
+
get(key: string, opts: {
|
|
15
|
+
defaultValue: string;
|
|
16
|
+
}): string;
|
|
17
|
+
get<R>(key: string, opts: IApplicationEnvironmentDefaultedTransformOptions<R>): R;
|
|
18
|
+
get<R>(key: string, opts: IApplicationEnvironmentTransformOptions<R>): R;
|
|
19
|
+
getRequired(key: string): string;
|
|
20
|
+
getRequired<R>(key: string, opts: {
|
|
21
|
+
transform: (raw: string) => R | null | undefined;
|
|
22
|
+
}): R;
|
|
23
|
+
set(key: string, value: string | undefined): void;
|
|
8
24
|
}
|
|
9
25
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/env/common/types.ts"],"names":[],"mappings":"","sourcesContent":["/** Read and write contract of the application environment store
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/env/common/types.ts"],"names":[],"mappings":"","sourcesContent":["/** Options of `get` that run a `transform` over the raw value; `defaultValue` applies when the value is absent or the transform answers null or undefined. */\nexport interface IApplicationEnvironmentTransformOptions<R> {\n transform: (raw: string | undefined) => R;\n defaultValue?: R;\n}\n\n/** A `transform` that may answer null or undefined, with the `defaultValue` that then applies: the read answers `R`. */\nexport interface IApplicationEnvironmentDefaultedTransformOptions<R> {\n transform: (raw: string | undefined) => R | null | undefined;\n defaultValue: R;\n}\n\n/** Read and write contract of the application environment store. Every value is a string: `get` answers the raw string (or `undefined`), the `defaultValue` of a string read, or what a `transform` makes of the raw string. */\nexport interface IApplicationEnvironment {\n get(key: string): string | undefined;\n get(key: string, opts: { defaultValue: string }): string;\n get<R>(key: string, opts: IApplicationEnvironmentDefaultedTransformOptions<R>): R;\n // oxlint-disable-next-line typescript/unified-signatures -- one union parameter infers `R` from the transform alone (`number | undefined`); two overloads let the `defaultValue` fix `R`\n get<R>(key: string, opts: IApplicationEnvironmentTransformOptions<R>): R;\n getRequired(key: string): string;\n getRequired<R>(key: string, opts: { transform: (raw: string) => R | null | undefined }): R;\n set(key: string, value: string | undefined): void;\n}\n"]}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { type AnyType } from '../../../common/types/index.js';
|
|
2
1
|
/** The leaf, not the `../common` barrel: that barrel reaches `constants.ts`, which reads `process.env` at module load. Both bindings here are types so a bundler erases the edge, but the source graph still carries it. */
|
|
3
2
|
import { type ILogger, type TLogLevel } from '../common/types.js';
|
|
4
3
|
/** The ILogger contract as a class - for instanceof and implementations sharing no plumbing. */
|
|
5
4
|
export declare abstract class AbstractLogger implements ILogger {
|
|
6
|
-
abstract debug(message: string, ...args:
|
|
7
|
-
abstract info(message: string, ...args:
|
|
8
|
-
abstract warn(message: string, ...args:
|
|
9
|
-
abstract error(message: string, ...args:
|
|
10
|
-
abstract emerg(message: string, ...args:
|
|
11
|
-
abstract log(level: TLogLevel, message: string, ...args:
|
|
5
|
+
abstract debug(message: string, ...args: unknown[]): void;
|
|
6
|
+
abstract info(message: string, ...args: unknown[]): void;
|
|
7
|
+
abstract warn(message: string, ...args: unknown[]): void;
|
|
8
|
+
abstract error(message: string, ...args: unknown[]): void;
|
|
9
|
+
abstract emerg(message: string, ...args: unknown[]): void;
|
|
10
|
+
abstract log(level: TLogLevel, message: string, ...args: unknown[]): void;
|
|
12
11
|
abstract for(methodName: string): ILogger;
|
|
13
12
|
}
|
|
14
13
|
//# sourceMappingURL=abstract.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../../../src/modules/logger/base/abstract.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../../../src/modules/logger/base/abstract.ts"],"names":[],"mappings":"AAGA,gGAAgG;AAChG,MAAM,OAAgB,cAAc;CAQnC","sourcesContent":["/** The leaf, not the `../common` barrel: that barrel reaches `constants.ts`, which reads `process.env` at module load. Both bindings here are types so a bundler erases the edge, but the source graph still carries it. */\nimport { type ILogger, type TLogLevel } from '../common/types';\n\n/** The ILogger contract as a class - for instanceof and implementations sharing no plumbing. */\nexport abstract class AbstractLogger implements ILogger {\n abstract debug(message: string, ...args: unknown[]): void;\n abstract info(message: string, ...args: unknown[]): void;\n abstract warn(message: string, ...args: unknown[]): void;\n abstract error(message: string, ...args: unknown[]): void;\n abstract emerg(message: string, ...args: unknown[]): void;\n abstract log(level: TLogLevel, message: string, ...args: unknown[]): void;\n abstract for(methodName: string): ILogger;\n}\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type AnyType } from '../../../common/types/index.js';
|
|
2
1
|
import { type ILogger, type TLogLevel } from '../common/index.js';
|
|
3
2
|
import { AbstractLogger } from './abstract.js';
|
|
4
3
|
/** Provider-independent plumbing: scope, prefix, DEBUG gate, for(). Every level method funnels into ONE abstract write() sink; child() lets each provider keep its own caching policy. */
|
|
@@ -11,17 +10,17 @@ export declare abstract class BaseLogger extends AbstractLogger {
|
|
|
11
10
|
protected abstract write(opts: {
|
|
12
11
|
level: TLogLevel;
|
|
13
12
|
message: string;
|
|
14
|
-
args:
|
|
13
|
+
args: unknown[];
|
|
15
14
|
}): void;
|
|
16
15
|
protected abstract child(opts: {
|
|
17
16
|
scope: string;
|
|
18
17
|
}): ILogger;
|
|
19
|
-
debug(message: string, ...args:
|
|
20
|
-
info(message: string, ...args:
|
|
21
|
-
warn(message: string, ...args:
|
|
22
|
-
error(message: string, ...args:
|
|
23
|
-
emerg(message: string, ...args:
|
|
24
|
-
log(level: TLogLevel, message: string, ...args:
|
|
18
|
+
debug(message: string, ...args: unknown[]): void;
|
|
19
|
+
info(message: string, ...args: unknown[]): void;
|
|
20
|
+
warn(message: string, ...args: unknown[]): void;
|
|
21
|
+
error(message: string, ...args: unknown[]): void;
|
|
22
|
+
emerg(message: string, ...args: unknown[]): void;
|
|
23
|
+
log(level: TLogLevel, message: string, ...args: unknown[]): void;
|
|
25
24
|
for(methodName: string): ILogger;
|
|
26
25
|
}
|
|
27
26
|
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../src/modules/logger/base/base.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../src/modules/logger/base/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,SAAS,EAA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AE,IAAI,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,GAAG,CAAC,KAAgB,EAAE,OAAe,EAAE,GAAG,IAAe;QACvD,IAAI,KAAK,KAAK,SAAS,CAAC,KAAK,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC;YAC3D,OAAO;QACT,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC;IAED,GAAG,CAAC,UAAkB;QACpB,qHAAqH;QACrH,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC;IACjG,CAAC;CACF","sourcesContent":["import { type ILogger, LogLevels, LoggerDebugGate, type TLogLevel } from '../common';\nimport { AbstractLogger } from './abstract';\n\n/** Provider-independent plumbing: scope, prefix, DEBUG gate, for(). Every level method funnels into ONE abstract write() sink; child() lets each provider keep its own caching policy. */\nexport abstract class BaseLogger extends AbstractLogger {\n protected readonly _scope: string;\n protected readonly _formattedPrefix: string;\n\n constructor(opts: { scope: string }) {\n super();\n this._scope = opts.scope;\n this._formattedPrefix = opts.scope !== '' ? `[${opts.scope}] ` : '';\n }\n\n protected abstract write(opts: { level: TLogLevel; message: string; args: unknown[] }): void;\n\n protected abstract child(opts: { scope: string }): ILogger;\n\n debug(message: string, ...args: unknown[]) {\n if (!LoggerDebugGate.isOpen()) {\n return;\n }\n\n this.write({ level: LogLevels.DEBUG, message, args });\n }\n\n info(message: string, ...args: unknown[]) {\n this.write({ level: LogLevels.INFO, message, args });\n }\n\n warn(message: string, ...args: unknown[]) {\n this.write({ level: LogLevels.WARN, message, args });\n }\n\n error(message: string, ...args: unknown[]) {\n this.write({ level: LogLevels.ERROR, message, args });\n }\n\n emerg(message: string, ...args: unknown[]) {\n this.write({ level: LogLevels.EMERG, message, args });\n }\n\n log(level: TLogLevel, message: string, ...args: unknown[]) {\n if (level === LogLevels.DEBUG && !LoggerDebugGate.isOpen()) {\n return;\n }\n\n this.write({ level, message, args });\n }\n\n for(methodName: string): ILogger {\n // An empty parent scope must not produce a leading dash - the child simply takes the method name as its whole scope.\n return this.child({ scope: this._scope !== '' ? `${this._scope}-${methodName}` : methodName });\n }\n}\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type AnyType } from '../../../common/types/index.js';
|
|
2
1
|
import { type ILogger, type TLogLevel } from '../common/types.js';
|
|
3
2
|
import { AbstractLogger } from './abstract.js';
|
|
4
3
|
/**
|
|
@@ -15,12 +14,12 @@ export declare class ConsoleLogger extends AbstractLogger {
|
|
|
15
14
|
private constructor();
|
|
16
15
|
static get(scope: string): ConsoleLogger;
|
|
17
16
|
private emit;
|
|
18
|
-
debug(message: string, ...args:
|
|
19
|
-
info(message: string, ...args:
|
|
20
|
-
warn(message: string, ...args:
|
|
21
|
-
error(message: string, ...args:
|
|
22
|
-
emerg(message: string, ...args:
|
|
23
|
-
log(level: TLogLevel, message: string, ...args:
|
|
17
|
+
debug(message: string, ...args: unknown[]): void;
|
|
18
|
+
info(message: string, ...args: unknown[]): void;
|
|
19
|
+
warn(message: string, ...args: unknown[]): void;
|
|
20
|
+
error(message: string, ...args: unknown[]): void;
|
|
21
|
+
emerg(message: string, ...args: unknown[]): void;
|
|
22
|
+
log(level: TLogLevel, message: string, ...args: unknown[]): void;
|
|
24
23
|
for(methodName: string): ILogger;
|
|
25
24
|
}
|
|
26
25
|
//# sourceMappingURL=console.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.js","sourceRoot":"","sources":["../../../../../src/modules/logger/base/console.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"console.js","sourceRoot":"","sources":["../../../../../src/modules/logger/base/console.ts"],"names":[],"mappings":"AAAA,OAA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["import { LoggerDebugGate } from '../common/debug-gate';\nimport { type ILogger, LogLevels, type TLogLevel } from '../common/types';\nimport { AbstractLogger } from './abstract';\n\n/**\n * The default logger provider: it writes to the console, and it is the only provider a browser bundle reaches. It\n * satisfies `ILoggerProvider` (`ConsoleLogger.get(scope)`), so it is registered like Winston and Pino.\n *\n * Extends AbstractLogger rather than BaseLogger because BaseLogger's module graph reads `process.env` at load.\n * `debug` follows the rule of the other providers (`LoggerDebugGate`): off unless `DEBUG` is truthy and the\n * environment is allowed, and off in a browser, which has no `process`; `LoggerFactory.use({ level })` overrides it.\n */\nexport class ConsoleLogger extends AbstractLogger {\n private readonly prefix: string;\n\n private constructor(private readonly scope: string) {\n super();\n this.prefix = scope !== '' ? `[${scope}] ` : '';\n }\n\n static get(scope: string): ConsoleLogger {\n return new ConsoleLogger(scope);\n }\n\n private emit(opts: {\n sink: (message: string, ...args: unknown[]) => void;\n message: string;\n args: unknown[];\n }) {\n opts.sink(`${this.prefix}${opts.message}`, ...opts.args);\n }\n\n debug(message: string, ...args: unknown[]) {\n if (!LoggerDebugGate.isOpen()) {\n return;\n }\n\n this.emit({ sink: console.debug, message, args });\n }\n\n info(message: string, ...args: unknown[]) {\n this.emit({ sink: console.log, message, args });\n }\n\n warn(message: string, ...args: unknown[]) {\n this.emit({ sink: console.warn, message, args });\n }\n\n error(message: string, ...args: unknown[]) {\n this.emit({ sink: console.error, message, args });\n }\n\n emerg(message: string, ...args: unknown[]) {\n this.emit({ sink: console.error, message, args });\n }\n\n log(level: TLogLevel, message: string, ...args: unknown[]) {\n switch (level) {\n case LogLevels.DEBUG: {\n this.debug(message, ...args);\n\n return;\n }\n case LogLevels.WARN: {\n this.warn(message, ...args);\n\n return;\n }\n case LogLevels.ERROR:\n case LogLevels.EMERG: {\n this.error(message, ...args);\n\n return;\n }\n default: {\n this.info(message, ...args);\n }\n }\n }\n\n for(methodName: string): ILogger {\n const childScope = this.scope !== '' ? `${this.scope}-${methodName}` : methodName;\n\n return ConsoleLogger.get(childScope);\n }\n}\n"]}
|