@objectstack/types 7.1.0 → 7.2.1
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/index.d.mts +29 -1
- package/dist/index.d.ts +29 -1
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read an env var, preferring the canonical `OS_*` name and falling
|
|
3
|
+
* back to one or more legacy aliases.
|
|
4
|
+
*
|
|
5
|
+
* When only a legacy alias is set, emits a one-shot deprecation warning.
|
|
6
|
+
* The warning is process-wide deduplicated: identical (preferred, legacy)
|
|
7
|
+
* pairs will only warn once even if read from multiple call sites.
|
|
8
|
+
*
|
|
9
|
+
* Legacy aliases are checked in order; the first one with a defined
|
|
10
|
+
* value wins (and triggers the warning for that specific alias).
|
|
11
|
+
*
|
|
12
|
+
* Safe to call from environments where `process` is unavailable (returns
|
|
13
|
+
* `undefined`); the warning is suppressed when running outside Node-like
|
|
14
|
+
* runtimes that lack `console.warn`.
|
|
15
|
+
*
|
|
16
|
+
* @param preferred Canonical OS_*-prefixed env var name.
|
|
17
|
+
* @param legacy Older name (or array of older names) to fall back on.
|
|
18
|
+
* @returns The resolved value, or `undefined` if neither is set.
|
|
19
|
+
*/
|
|
20
|
+
declare function readEnvWithDeprecation(preferred: string, legacy: string | readonly string[]): string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Internal: clear the dedupe set. Test-only; exposed so suite-wide
|
|
23
|
+
* deprecation warnings don't bleed between tests.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
declare function _resetEnvDeprecationWarnings(): void;
|
|
28
|
+
|
|
1
29
|
interface IKernel {
|
|
2
30
|
ql?: any;
|
|
3
31
|
start(): Promise<void>;
|
|
@@ -12,4 +40,4 @@ interface RuntimePlugin {
|
|
|
12
40
|
onStart?: (ctx: RuntimeContext) => void | Promise<void>;
|
|
13
41
|
}
|
|
14
42
|
|
|
15
|
-
export type
|
|
43
|
+
export { type IKernel, type RuntimeContext, type RuntimePlugin, _resetEnvDeprecationWarnings, readEnvWithDeprecation };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read an env var, preferring the canonical `OS_*` name and falling
|
|
3
|
+
* back to one or more legacy aliases.
|
|
4
|
+
*
|
|
5
|
+
* When only a legacy alias is set, emits a one-shot deprecation warning.
|
|
6
|
+
* The warning is process-wide deduplicated: identical (preferred, legacy)
|
|
7
|
+
* pairs will only warn once even if read from multiple call sites.
|
|
8
|
+
*
|
|
9
|
+
* Legacy aliases are checked in order; the first one with a defined
|
|
10
|
+
* value wins (and triggers the warning for that specific alias).
|
|
11
|
+
*
|
|
12
|
+
* Safe to call from environments where `process` is unavailable (returns
|
|
13
|
+
* `undefined`); the warning is suppressed when running outside Node-like
|
|
14
|
+
* runtimes that lack `console.warn`.
|
|
15
|
+
*
|
|
16
|
+
* @param preferred Canonical OS_*-prefixed env var name.
|
|
17
|
+
* @param legacy Older name (or array of older names) to fall back on.
|
|
18
|
+
* @returns The resolved value, or `undefined` if neither is set.
|
|
19
|
+
*/
|
|
20
|
+
declare function readEnvWithDeprecation(preferred: string, legacy: string | readonly string[]): string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Internal: clear the dedupe set. Test-only; exposed so suite-wide
|
|
23
|
+
* deprecation warnings don't bleed between tests.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
declare function _resetEnvDeprecationWarnings(): void;
|
|
28
|
+
|
|
1
29
|
interface IKernel {
|
|
2
30
|
ql?: any;
|
|
3
31
|
start(): Promise<void>;
|
|
@@ -12,4 +40,4 @@ interface RuntimePlugin {
|
|
|
12
40
|
onStart?: (ctx: RuntimeContext) => void | Promise<void>;
|
|
13
41
|
}
|
|
14
42
|
|
|
15
|
-
export type
|
|
43
|
+
export { type IKernel, type RuntimeContext, type RuntimePlugin, _resetEnvDeprecationWarnings, readEnvWithDeprecation };
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
6
10
|
var __copyProps = (to, from, except, desc) => {
|
|
7
11
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
12
|
for (let key of __getOwnPropNames(from))
|
|
@@ -15,5 +19,45 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
15
19
|
|
|
16
20
|
// src/index.ts
|
|
17
21
|
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
_resetEnvDeprecationWarnings: () => _resetEnvDeprecationWarnings,
|
|
24
|
+
readEnvWithDeprecation: () => readEnvWithDeprecation
|
|
25
|
+
});
|
|
18
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
|
|
28
|
+
// src/env.ts
|
|
29
|
+
var _warnedKeys = /* @__PURE__ */ new Set();
|
|
30
|
+
function readEnvWithDeprecation(preferred, legacy) {
|
|
31
|
+
const env = globalThis.process?.env;
|
|
32
|
+
if (!env) return void 0;
|
|
33
|
+
const preferredValue = env[preferred];
|
|
34
|
+
if (preferredValue !== void 0) return preferredValue;
|
|
35
|
+
const legacyList = typeof legacy === "string" ? [legacy] : legacy;
|
|
36
|
+
for (const legacyName of legacyList) {
|
|
37
|
+
const legacyValue = env[legacyName];
|
|
38
|
+
if (legacyValue !== void 0) {
|
|
39
|
+
const dedupeKey = `${preferred}|${legacyName}`;
|
|
40
|
+
if (!_warnedKeys.has(dedupeKey)) {
|
|
41
|
+
_warnedKeys.add(dedupeKey);
|
|
42
|
+
const consoleRef = globalThis.console;
|
|
43
|
+
try {
|
|
44
|
+
consoleRef?.warn?.(
|
|
45
|
+
`[ObjectStack] Env var \`${legacyName}\` is deprecated; rename it to \`${preferred}\`. The legacy name still works for now but will be removed in a future major release.`
|
|
46
|
+
);
|
|
47
|
+
} catch {
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return legacyValue;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return void 0;
|
|
54
|
+
}
|
|
55
|
+
function _resetEnvDeprecationWarnings() {
|
|
56
|
+
_warnedKeys.clear();
|
|
57
|
+
}
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
_resetEnvDeprecationWarnings,
|
|
61
|
+
readEnvWithDeprecation
|
|
62
|
+
});
|
|
19
63
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\n// Placeholder for Kernel interface to avoid circular dependency\n// The actual Kernel implementation will satisfy this interface.\nexport interface IKernel {\n // We can add specific methods here that plugins are allowed to call\n // forcing a stricter contract than exposing the whole class.\n ql?: any; // ObjectQL instance (optional to support initialization phase)\n start(): Promise<void>;\n // ... expose other needed public methods\n [key: string]: any; \n}\n\nexport interface RuntimeContext {\n engine: IKernel;\n}\n\nexport interface RuntimePlugin {\n name: string;\n install?: (ctx: RuntimeContext) => void | Promise<void>;\n onStart?: (ctx: RuntimeContext) => void | Promise<void>;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/env.ts"],"sourcesContent":["// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nexport * from './env.js';\n\n// Placeholder for Kernel interface to avoid circular dependency\n// The actual Kernel implementation will satisfy this interface.\nexport interface IKernel {\n // We can add specific methods here that plugins are allowed to call\n // forcing a stricter contract than exposing the whole class.\n ql?: any; // ObjectQL instance (optional to support initialization phase)\n start(): Promise<void>;\n // ... expose other needed public methods\n [key: string]: any; \n}\n\nexport interface RuntimeContext {\n engine: IKernel;\n}\n\nexport interface RuntimePlugin {\n name: string;\n install?: (ctx: RuntimeContext) => void | Promise<void>;\n onStart?: (ctx: RuntimeContext) => void | Promise<void>;\n}\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\n/**\n * Environment-variable helpers shared across `@objectstack/*` packages.\n *\n * The framework standardises on `OS_*` prefixed env vars (see AGENTS.md\n * \"Environment Variables\" section). Some historical names predate this\n * convention — `AUTH_SECRET`, `ROOT_DOMAIN`, `OBJECTSTACK_*`, …\n *\n * To migrate without breaking user `.env` files mid-release, call\n * {@link readEnvWithDeprecation} at every legacy read site:\n *\n * const v = readEnvWithDeprecation('OS_AUTH_SECRET', 'AUTH_SECRET');\n *\n * If only the legacy name is set, the value is still returned but a\n * one-shot `console.warn` fires (per-process per-variable) telling\n * operators to rename it.\n */\n\nconst _warnedKeys = new Set<string>();\n\n/**\n * Read an env var, preferring the canonical `OS_*` name and falling\n * back to one or more legacy aliases.\n *\n * When only a legacy alias is set, emits a one-shot deprecation warning.\n * The warning is process-wide deduplicated: identical (preferred, legacy)\n * pairs will only warn once even if read from multiple call sites.\n *\n * Legacy aliases are checked in order; the first one with a defined\n * value wins (and triggers the warning for that specific alias).\n *\n * Safe to call from environments where `process` is unavailable (returns\n * `undefined`); the warning is suppressed when running outside Node-like\n * runtimes that lack `console.warn`.\n *\n * @param preferred Canonical OS_*-prefixed env var name.\n * @param legacy Older name (or array of older names) to fall back on.\n * @returns The resolved value, or `undefined` if neither is set.\n */\nexport function readEnvWithDeprecation(\n preferred: string,\n legacy: string | readonly string[],\n): string | undefined {\n const env = (globalThis as { process?: { env?: Record<string, string | undefined> } })\n .process?.env;\n if (!env) return undefined;\n\n const preferredValue = env[preferred];\n if (preferredValue !== undefined) return preferredValue;\n\n const legacyList = typeof legacy === 'string' ? [legacy] : legacy;\n for (const legacyName of legacyList) {\n const legacyValue = env[legacyName];\n if (legacyValue !== undefined) {\n const dedupeKey = `${preferred}|${legacyName}`;\n if (!_warnedKeys.has(dedupeKey)) {\n _warnedKeys.add(dedupeKey);\n const consoleRef = (globalThis as { console?: { warn?: (msg: string) => void } }).console;\n try {\n consoleRef?.warn?.(\n `[ObjectStack] Env var \\`${legacyName}\\` is deprecated; rename it to \\`${preferred}\\`. ` +\n `The legacy name still works for now but will be removed in a future major release.`,\n );\n } catch {\n /* `console.warn` unavailable (exotic runtime) — ignore */\n }\n }\n return legacyValue;\n }\n }\n\n return undefined;\n}\n\n/**\n * Internal: clear the dedupe set. Test-only; exposed so suite-wide\n * deprecation warnings don't bleed between tests.\n *\n * @internal\n */\nexport function _resetEnvDeprecationWarnings(): void {\n _warnedKeys.clear();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACmBA,IAAM,cAAc,oBAAI,IAAY;AAqB7B,SAAS,uBACd,WACA,QACoB;AACpB,QAAM,MAAO,WACV,SAAS;AACZ,MAAI,CAAC,IAAK,QAAO;AAEjB,QAAM,iBAAiB,IAAI,SAAS;AACpC,MAAI,mBAAmB,OAAW,QAAO;AAEzC,QAAM,aAAa,OAAO,WAAW,WAAW,CAAC,MAAM,IAAI;AAC3D,aAAW,cAAc,YAAY;AACnC,UAAM,cAAc,IAAI,UAAU;AAClC,QAAI,gBAAgB,QAAW;AAC7B,YAAM,YAAY,GAAG,SAAS,IAAI,UAAU;AAC5C,UAAI,CAAC,YAAY,IAAI,SAAS,GAAG;AAC/B,oBAAY,IAAI,SAAS;AACzB,cAAM,aAAc,WAA8D;AAClF,YAAI;AACF,sBAAY;AAAA,YACV,2BAA2B,UAAU,oCAAoC,SAAS;AAAA,UAEpF;AAAA,QACF,QAAQ;AAAA,QAER;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;AAQO,SAAS,+BAAqC;AACnD,cAAY,MAAM;AACpB;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,35 @@
|
|
|
1
|
+
// src/env.ts
|
|
2
|
+
var _warnedKeys = /* @__PURE__ */ new Set();
|
|
3
|
+
function readEnvWithDeprecation(preferred, legacy) {
|
|
4
|
+
const env = globalThis.process?.env;
|
|
5
|
+
if (!env) return void 0;
|
|
6
|
+
const preferredValue = env[preferred];
|
|
7
|
+
if (preferredValue !== void 0) return preferredValue;
|
|
8
|
+
const legacyList = typeof legacy === "string" ? [legacy] : legacy;
|
|
9
|
+
for (const legacyName of legacyList) {
|
|
10
|
+
const legacyValue = env[legacyName];
|
|
11
|
+
if (legacyValue !== void 0) {
|
|
12
|
+
const dedupeKey = `${preferred}|${legacyName}`;
|
|
13
|
+
if (!_warnedKeys.has(dedupeKey)) {
|
|
14
|
+
_warnedKeys.add(dedupeKey);
|
|
15
|
+
const consoleRef = globalThis.console;
|
|
16
|
+
try {
|
|
17
|
+
consoleRef?.warn?.(
|
|
18
|
+
`[ObjectStack] Env var \`${legacyName}\` is deprecated; rename it to \`${preferred}\`. The legacy name still works for now but will be removed in a future major release.`
|
|
19
|
+
);
|
|
20
|
+
} catch {
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return legacyValue;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return void 0;
|
|
27
|
+
}
|
|
28
|
+
function _resetEnvDeprecationWarnings() {
|
|
29
|
+
_warnedKeys.clear();
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
_resetEnvDeprecationWarnings,
|
|
33
|
+
readEnvWithDeprecation
|
|
34
|
+
};
|
|
1
35
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/env.ts"],"sourcesContent":["// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\n/**\n * Environment-variable helpers shared across `@objectstack/*` packages.\n *\n * The framework standardises on `OS_*` prefixed env vars (see AGENTS.md\n * \"Environment Variables\" section). Some historical names predate this\n * convention — `AUTH_SECRET`, `ROOT_DOMAIN`, `OBJECTSTACK_*`, …\n *\n * To migrate without breaking user `.env` files mid-release, call\n * {@link readEnvWithDeprecation} at every legacy read site:\n *\n * const v = readEnvWithDeprecation('OS_AUTH_SECRET', 'AUTH_SECRET');\n *\n * If only the legacy name is set, the value is still returned but a\n * one-shot `console.warn` fires (per-process per-variable) telling\n * operators to rename it.\n */\n\nconst _warnedKeys = new Set<string>();\n\n/**\n * Read an env var, preferring the canonical `OS_*` name and falling\n * back to one or more legacy aliases.\n *\n * When only a legacy alias is set, emits a one-shot deprecation warning.\n * The warning is process-wide deduplicated: identical (preferred, legacy)\n * pairs will only warn once even if read from multiple call sites.\n *\n * Legacy aliases are checked in order; the first one with a defined\n * value wins (and triggers the warning for that specific alias).\n *\n * Safe to call from environments where `process` is unavailable (returns\n * `undefined`); the warning is suppressed when running outside Node-like\n * runtimes that lack `console.warn`.\n *\n * @param preferred Canonical OS_*-prefixed env var name.\n * @param legacy Older name (or array of older names) to fall back on.\n * @returns The resolved value, or `undefined` if neither is set.\n */\nexport function readEnvWithDeprecation(\n preferred: string,\n legacy: string | readonly string[],\n): string | undefined {\n const env = (globalThis as { process?: { env?: Record<string, string | undefined> } })\n .process?.env;\n if (!env) return undefined;\n\n const preferredValue = env[preferred];\n if (preferredValue !== undefined) return preferredValue;\n\n const legacyList = typeof legacy === 'string' ? [legacy] : legacy;\n for (const legacyName of legacyList) {\n const legacyValue = env[legacyName];\n if (legacyValue !== undefined) {\n const dedupeKey = `${preferred}|${legacyName}`;\n if (!_warnedKeys.has(dedupeKey)) {\n _warnedKeys.add(dedupeKey);\n const consoleRef = (globalThis as { console?: { warn?: (msg: string) => void } }).console;\n try {\n consoleRef?.warn?.(\n `[ObjectStack] Env var \\`${legacyName}\\` is deprecated; rename it to \\`${preferred}\\`. ` +\n `The legacy name still works for now but will be removed in a future major release.`,\n );\n } catch {\n /* `console.warn` unavailable (exotic runtime) — ignore */\n }\n }\n return legacyValue;\n }\n }\n\n return undefined;\n}\n\n/**\n * Internal: clear the dedupe set. Test-only; exposed so suite-wide\n * deprecation warnings don't bleed between tests.\n *\n * @internal\n */\nexport function _resetEnvDeprecationWarnings(): void {\n _warnedKeys.clear();\n}\n"],"mappings":";AAmBA,IAAM,cAAc,oBAAI,IAAY;AAqB7B,SAAS,uBACd,WACA,QACoB;AACpB,QAAM,MAAO,WACV,SAAS;AACZ,MAAI,CAAC,IAAK,QAAO;AAEjB,QAAM,iBAAiB,IAAI,SAAS;AACpC,MAAI,mBAAmB,OAAW,QAAO;AAEzC,QAAM,aAAa,OAAO,WAAW,WAAW,CAAC,MAAM,IAAI;AAC3D,aAAW,cAAc,YAAY;AACnC,UAAM,cAAc,IAAI,UAAU;AAClC,QAAI,gBAAgB,QAAW;AAC7B,YAAM,YAAY,GAAG,SAAS,IAAI,UAAU;AAC5C,UAAI,CAAC,YAAY,IAAI,SAAS,GAAG;AAC/B,oBAAY,IAAI,SAAS;AACzB,cAAM,aAAc,WAA8D;AAClF,YAAI;AACF,sBAAY;AAAA,YACV,2BAA2B,UAAU,oCAAoC,SAAS;AAAA,UAEpF;AAAA,QACF,QAAQ;AAAA,QAER;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;AAQO,SAAS,+BAAqC;AACnD,cAAY,MAAM;AACpB;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@objectstack/types",
|
|
3
|
-
"version": "7.1
|
|
3
|
+
"version": "7.2.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Shared interfaces describing the ObjectStack Runtime environment",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@objectstack/spec": "7.1
|
|
16
|
+
"@objectstack/spec": "7.2.1"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"typescript": "^6.0.3"
|