@kosdev-code/kos-api-levels 0.1.0-dev.5797

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.
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Emits a one-time console warning in non-production environments when a
3
+ * deprecated API is used.
4
+ *
5
+ * @param apiName - The name of the deprecated API (e.g. `@kosSubscribe`)
6
+ * @param serviceId - The service the API belongs to (e.g. `core.subscribe`)
7
+ * @param deprecatedAtLevel - The API level at which this API was deprecated
8
+ * @param replacement - The recommended replacement (e.g. `@kosTopicHandler`)
9
+ * @param removeAtLevel - The API level at which this API will be removed
10
+ */
11
+ export declare function warnDeprecated(apiName: string, serviceId: string, deprecatedAtLevel: number, replacement: string, removeAtLevel: number): void;
12
+ //# sourceMappingURL=deprecation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deprecation.d.ts","sourceRoot":"","sources":["../../../../packages/sdk/kos-api-levels/src/deprecation.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,MAAM,EACzB,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,GACpB,IAAI,CAUN"}
package/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=new Set;function d(e,t,n,i,l){typeof process<"u"&&process.env.NODE_ENV==="production"||c.has(e)||(c.add(e),console.warn(`[KOS] "${e}" is deprecated since ${t} level ${n}. Use "${i}" instead. Will be removed at level ${l}.`))}const u={};function p(e){Object.assign(u,e)}function a(){return u}function r(e){return a()[e]??0}function g(e,t){return r(e)>=t}function v(e,t){const n=r(e);if(n<t){const i=n===0?"not registered":String(n);throw new Error(`[KOS] API level requirement not met for "${e}": required ${t}, actual ${i}`)}}function f(){return a()}function L(e){const t={};let n=!0;for(const[i,l]of Object.entries(e)){if(l===void 0)continue;const o=r(i),s=o>=l;t[i]={required:l,actual:o,ok:s},s||(n=!1)}return{satisfied:n,details:t}}function k(e){const t=r("ddk.compat"),n=r("ddk.compat.min-plugin");if(e.pluginRequiresDdkLevel>t){const i=t===0?"not registered":String(t);return{ok:!1,reason:"too-new-plugin",message:`[KOS] Plugin requires DDK level ${e.pluginRequiresDdkLevel}, but host provides level ${i}.`}}return n>0&&e.pluginLevel<n?{ok:!1,reason:"too-old-plugin",message:`[KOS] Plugin level ${e.pluginLevel} is below the host's minimum accepted plugin level ${n}.`}:{ok:!0,reason:"ok"}}exports.checkApiLevels=L;exports.checkCompatibility=k;exports.getAllApiLevels=f;exports.getApiLevel=r;exports.hasApiLevel=g;exports.registerApiLevels=p;exports.requireApiLevel=v;exports.warnDeprecated=d;
2
+ //# sourceMappingURL=index.cjs.map
package/index.cjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../../../packages/sdk/kos-api-levels/src/deprecation.ts","../../../../packages/sdk/kos-api-levels/src/registry.ts","../../../../packages/sdk/kos-api-levels/src/runtime.ts"],"sourcesContent":["const _warned = new Set<string>();\n\n/**\n * Emits a one-time console warning in non-production environments when a\n * deprecated API is used.\n *\n * @param apiName - The name of the deprecated API (e.g. `@kosSubscribe`)\n * @param serviceId - The service the API belongs to (e.g. `core.subscribe`)\n * @param deprecatedAtLevel - The API level at which this API was deprecated\n * @param replacement - The recommended replacement (e.g. `@kosTopicHandler`)\n * @param removeAtLevel - The API level at which this API will be removed\n */\nexport function warnDeprecated(\n apiName: string,\n serviceId: string,\n deprecatedAtLevel: number,\n replacement: string,\n removeAtLevel: number\n): void {\n if (typeof process !== 'undefined' && process.env['NODE_ENV'] === 'production') {\n return;\n }\n if (_warned.has(apiName)) return;\n _warned.add(apiName);\n console.warn(\n `[KOS] \"${apiName}\" is deprecated since ${serviceId} level ${deprecatedAtLevel}. ` +\n `Use \"${replacement}\" instead. Will be removed at level ${removeAtLevel}.`\n );\n}\n","import type { ApiLevelMap } from './types';\n\nconst _registry: ApiLevelMap = {};\n\n/**\n * Registers API levels for an SDK package. Each SDK package calls this on\n * import to populate the in-memory registry. Works in browser and Node.js.\n *\n * Phase 1: called manually from each package's index.ts.\n * Phase 2: generated automatically by the JSDoc scanner at build time.\n */\nexport function registerApiLevels(levels: ApiLevelMap): void {\n Object.assign(_registry, levels);\n}\n\nexport function getRegistry(): Readonly<ApiLevelMap> {\n return _registry;\n}\n","import type { ServiceId, ApiLevelMap, CheckResult, PluginCompatRequirements, CompatResult } from './types';\nimport { getRegistry } from './registry';\n\n/**\n * Returns the current API level for a service.\n * Returns 0 if the service has not been registered.\n */\nexport function getApiLevel(service: ServiceId): number {\n return getRegistry()[service] ?? 0;\n}\n\n/**\n * Returns true if the registered level for a service meets the minimum requirement.\n */\nexport function hasApiLevel(service: ServiceId, minLevel: number): boolean {\n return getApiLevel(service) >= minLevel;\n}\n\n/**\n * Throws if the registered level for a service does not meet the minimum requirement.\n */\nexport function requireApiLevel(service: ServiceId, minLevel: number): void {\n const actual = getApiLevel(service);\n if (actual < minLevel) {\n const actualLabel = actual === 0 ? 'not registered' : String(actual);\n throw new Error(\n `[KOS] API level requirement not met for \"${service}\": required ${minLevel}, actual ${actualLabel}`\n );\n }\n}\n\n/**\n * Returns all registered API levels. Useful for diagnostics and logging.\n */\nexport function getAllApiLevels(): Readonly<ApiLevelMap> {\n return getRegistry();\n}\n\n/**\n * Checks multiple service requirements in a single call.\n */\nexport function checkApiLevels(requirements: Partial<ApiLevelMap>): CheckResult {\n const details: CheckResult['details'] = {};\n let satisfied = true;\n\n for (const [service, required] of Object.entries(requirements)) {\n if (required === undefined) continue;\n const actual = getApiLevel(service);\n const ok = actual >= required;\n details[service] = { required, actual, ok };\n if (!ok) satisfied = false;\n }\n\n return { satisfied, details };\n}\n\n/**\n * Checks whether a DDK plugin is compatible with the current DDK host.\n *\n * The DDK host registers two services at startup:\n * - `ddk.compat` — the current DDK API level (what it provides)\n * - `ddk.compat.min-plugin` — the oldest plugin level this host still accepts\n *\n * A plugin passes its own requirements:\n * - `pluginRequiresDdkLevel` — minimum DDK level the plugin needs\n * - `pluginLevel` — the API level of the plugin itself\n *\n * Both directions are checked:\n * - Plugin too new for host: `pluginRequiresDdkLevel > ddk.compat`\n * - Plugin too old for host: `pluginLevel < ddk.compat.min-plugin`\n */\nexport function checkCompatibility(requirements: PluginCompatRequirements): CompatResult {\n const ddkLevel = getApiLevel('ddk.compat');\n const minPluginLevel = getApiLevel('ddk.compat.min-plugin');\n\n if (requirements.pluginRequiresDdkLevel > ddkLevel) {\n const ddkLabel = ddkLevel === 0 ? 'not registered' : String(ddkLevel);\n return {\n ok: false,\n reason: 'too-new-plugin',\n message:\n `[KOS] Plugin requires DDK level ${requirements.pluginRequiresDdkLevel}, ` +\n `but host provides level ${ddkLabel}.`,\n };\n }\n\n if (minPluginLevel > 0 && requirements.pluginLevel < minPluginLevel) {\n return {\n ok: false,\n reason: 'too-old-plugin',\n message:\n `[KOS] Plugin level ${requirements.pluginLevel} is below the host's minimum ` +\n `accepted plugin level ${minPluginLevel}.`,\n };\n }\n\n return { ok: true, reason: 'ok' };\n}\n"],"names":["_warned","warnDeprecated","apiName","serviceId","deprecatedAtLevel","replacement","removeAtLevel","_registry","registerApiLevels","levels","getRegistry","getApiLevel","service","hasApiLevel","minLevel","requireApiLevel","actual","actualLabel","getAllApiLevels","checkApiLevels","requirements","details","satisfied","required","ok","checkCompatibility","ddkLevel","minPluginLevel","ddkLabel"],"mappings":"gFAAA,MAAMA,MAAc,IAYb,SAASC,EACdC,EACAC,EACAC,EACAC,EACAC,EACM,CACF,OAAO,QAAY,KAAe,QAAQ,IAAI,WAAgB,cAG9DN,EAAQ,IAAIE,CAAO,IACvBF,EAAQ,IAAIE,CAAO,EACnB,QAAQ,KACN,UAAUA,CAAO,yBAAyBC,CAAS,UAAUC,CAAiB,UACpEC,CAAW,uCAAuCC,CAAa,GAAA,EAE7E,CC1BA,MAAMC,EAAyB,CAAA,EASxB,SAASC,EAAkBC,EAA2B,CAC3D,OAAO,OAAOF,EAAWE,CAAM,CACjC,CAEO,SAASC,GAAqC,CACnD,OAAOH,CACT,CCVO,SAASI,EAAYC,EAA4B,CACtD,OAAOF,EAAA,EAAcE,CAAO,GAAK,CACnC,CAKO,SAASC,EAAYD,EAAoBE,EAA2B,CACzE,OAAOH,EAAYC,CAAO,GAAKE,CACjC,CAKO,SAASC,EAAgBH,EAAoBE,EAAwB,CAC1E,MAAME,EAASL,EAAYC,CAAO,EAClC,GAAII,EAASF,EAAU,CACrB,MAAMG,EAAcD,IAAW,EAAI,iBAAmB,OAAOA,CAAM,EACnE,MAAM,IAAI,MACR,4CAA4CJ,CAAO,eAAeE,CAAQ,YAAYG,CAAW,EAAA,CAErG,CACF,CAKO,SAASC,GAAyC,CACvD,OAAOR,EAAA,CACT,CAKO,SAASS,EAAeC,EAAiD,CAC9E,MAAMC,EAAkC,CAAA,EACxC,IAAIC,EAAY,GAEhB,SAAW,CAACV,EAASW,CAAQ,IAAK,OAAO,QAAQH,CAAY,EAAG,CAC9D,GAAIG,IAAa,OAAW,SAC5B,MAAMP,EAASL,EAAYC,CAAO,EAC5BY,EAAKR,GAAUO,EACrBF,EAAQT,CAAO,EAAI,CAAE,SAAAW,EAAU,OAAAP,EAAQ,GAAAQ,CAAA,EAClCA,IAAIF,EAAY,GACvB,CAEA,MAAO,CAAE,UAAAA,EAAW,QAAAD,CAAA,CACtB,CAiBO,SAASI,EAAmBL,EAAsD,CACvF,MAAMM,EAAWf,EAAY,YAAY,EACnCgB,EAAiBhB,EAAY,uBAAuB,EAE1D,GAAIS,EAAa,uBAAyBM,EAAU,CAClD,MAAME,EAAWF,IAAa,EAAI,iBAAmB,OAAOA,CAAQ,EACpE,MAAO,CACL,GAAI,GACJ,OAAQ,iBACR,QACE,mCAAmCN,EAAa,sBAAsB,6BAC3CQ,CAAQ,GAAA,CAEzC,CAEA,OAAID,EAAiB,GAAKP,EAAa,YAAcO,EAC5C,CACL,GAAI,GACJ,OAAQ,iBACR,QACE,sBAAsBP,EAAa,WAAW,sDACrBO,CAAc,GAAA,EAItC,CAAE,GAAI,GAAM,OAAQ,IAAA,CAC7B"}
package/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export { warnDeprecated } from './deprecation';
2
+ export { registerApiLevels } from './registry';
3
+ export { checkApiLevels, checkCompatibility, getAllApiLevels, getApiLevel, hasApiLevel, requireApiLevel, } from './runtime';
4
+ export type { ApiLevelMap, CheckResult, CompatResult, CompatReason, PluginCompatRequirements, ServiceId, } from './types';
5
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/sdk/kos-api-levels/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,WAAW,EACX,eAAe,GAChB,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,wBAAwB,EACxB,SAAS,GACV,MAAM,SAAS,CAAC"}
package/index.js ADDED
@@ -0,0 +1,69 @@
1
+ const u = /* @__PURE__ */ new Set();
2
+ function d(e, n, t, i, r) {
3
+ typeof process < "u" && process.env.NODE_ENV === "production" || u.has(e) || (u.add(e), console.warn(
4
+ `[KOS] "${e}" is deprecated since ${n} level ${t}. Use "${i}" instead. Will be removed at level ${r}.`
5
+ ));
6
+ }
7
+ const c = {};
8
+ function f(e) {
9
+ Object.assign(c, e);
10
+ }
11
+ function a() {
12
+ return c;
13
+ }
14
+ function o(e) {
15
+ return a()[e] ?? 0;
16
+ }
17
+ function g(e, n) {
18
+ return o(e) >= n;
19
+ }
20
+ function p(e, n) {
21
+ const t = o(e);
22
+ if (t < n) {
23
+ const i = t === 0 ? "not registered" : String(t);
24
+ throw new Error(
25
+ `[KOS] API level requirement not met for "${e}": required ${n}, actual ${i}`
26
+ );
27
+ }
28
+ }
29
+ function v() {
30
+ return a();
31
+ }
32
+ function k(e) {
33
+ const n = {};
34
+ let t = !0;
35
+ for (const [i, r] of Object.entries(e)) {
36
+ if (r === void 0)
37
+ continue;
38
+ const l = o(i), s = l >= r;
39
+ n[i] = { required: r, actual: l, ok: s }, s || (t = !1);
40
+ }
41
+ return { satisfied: t, details: n };
42
+ }
43
+ function L(e) {
44
+ const n = o("ddk.compat"), t = o("ddk.compat.min-plugin");
45
+ if (e.pluginRequiresDdkLevel > n) {
46
+ const i = n === 0 ? "not registered" : String(n);
47
+ return {
48
+ ok: !1,
49
+ reason: "too-new-plugin",
50
+ message: `[KOS] Plugin requires DDK level ${e.pluginRequiresDdkLevel}, but host provides level ${i}.`
51
+ };
52
+ }
53
+ return t > 0 && e.pluginLevel < t ? {
54
+ ok: !1,
55
+ reason: "too-old-plugin",
56
+ message: `[KOS] Plugin level ${e.pluginLevel} is below the host's minimum accepted plugin level ${t}.`
57
+ } : { ok: !0, reason: "ok" };
58
+ }
59
+ export {
60
+ k as checkApiLevels,
61
+ L as checkCompatibility,
62
+ v as getAllApiLevels,
63
+ o as getApiLevel,
64
+ g as hasApiLevel,
65
+ f as registerApiLevels,
66
+ p as requireApiLevel,
67
+ d as warnDeprecated
68
+ };
69
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../packages/sdk/kos-api-levels/src/deprecation.ts","../../../../packages/sdk/kos-api-levels/src/registry.ts","../../../../packages/sdk/kos-api-levels/src/runtime.ts"],"sourcesContent":["const _warned = new Set<string>();\n\n/**\n * Emits a one-time console warning in non-production environments when a\n * deprecated API is used.\n *\n * @param apiName - The name of the deprecated API (e.g. `@kosSubscribe`)\n * @param serviceId - The service the API belongs to (e.g. `core.subscribe`)\n * @param deprecatedAtLevel - The API level at which this API was deprecated\n * @param replacement - The recommended replacement (e.g. `@kosTopicHandler`)\n * @param removeAtLevel - The API level at which this API will be removed\n */\nexport function warnDeprecated(\n apiName: string,\n serviceId: string,\n deprecatedAtLevel: number,\n replacement: string,\n removeAtLevel: number\n): void {\n if (typeof process !== 'undefined' && process.env['NODE_ENV'] === 'production') {\n return;\n }\n if (_warned.has(apiName)) return;\n _warned.add(apiName);\n console.warn(\n `[KOS] \"${apiName}\" is deprecated since ${serviceId} level ${deprecatedAtLevel}. ` +\n `Use \"${replacement}\" instead. Will be removed at level ${removeAtLevel}.`\n );\n}\n","import type { ApiLevelMap } from './types';\n\nconst _registry: ApiLevelMap = {};\n\n/**\n * Registers API levels for an SDK package. Each SDK package calls this on\n * import to populate the in-memory registry. Works in browser and Node.js.\n *\n * Phase 1: called manually from each package's index.ts.\n * Phase 2: generated automatically by the JSDoc scanner at build time.\n */\nexport function registerApiLevels(levels: ApiLevelMap): void {\n Object.assign(_registry, levels);\n}\n\nexport function getRegistry(): Readonly<ApiLevelMap> {\n return _registry;\n}\n","import type { ServiceId, ApiLevelMap, CheckResult, PluginCompatRequirements, CompatResult } from './types';\nimport { getRegistry } from './registry';\n\n/**\n * Returns the current API level for a service.\n * Returns 0 if the service has not been registered.\n */\nexport function getApiLevel(service: ServiceId): number {\n return getRegistry()[service] ?? 0;\n}\n\n/**\n * Returns true if the registered level for a service meets the minimum requirement.\n */\nexport function hasApiLevel(service: ServiceId, minLevel: number): boolean {\n return getApiLevel(service) >= minLevel;\n}\n\n/**\n * Throws if the registered level for a service does not meet the minimum requirement.\n */\nexport function requireApiLevel(service: ServiceId, minLevel: number): void {\n const actual = getApiLevel(service);\n if (actual < minLevel) {\n const actualLabel = actual === 0 ? 'not registered' : String(actual);\n throw new Error(\n `[KOS] API level requirement not met for \"${service}\": required ${minLevel}, actual ${actualLabel}`\n );\n }\n}\n\n/**\n * Returns all registered API levels. Useful for diagnostics and logging.\n */\nexport function getAllApiLevels(): Readonly<ApiLevelMap> {\n return getRegistry();\n}\n\n/**\n * Checks multiple service requirements in a single call.\n */\nexport function checkApiLevels(requirements: Partial<ApiLevelMap>): CheckResult {\n const details: CheckResult['details'] = {};\n let satisfied = true;\n\n for (const [service, required] of Object.entries(requirements)) {\n if (required === undefined) continue;\n const actual = getApiLevel(service);\n const ok = actual >= required;\n details[service] = { required, actual, ok };\n if (!ok) satisfied = false;\n }\n\n return { satisfied, details };\n}\n\n/**\n * Checks whether a DDK plugin is compatible with the current DDK host.\n *\n * The DDK host registers two services at startup:\n * - `ddk.compat` — the current DDK API level (what it provides)\n * - `ddk.compat.min-plugin` — the oldest plugin level this host still accepts\n *\n * A plugin passes its own requirements:\n * - `pluginRequiresDdkLevel` — minimum DDK level the plugin needs\n * - `pluginLevel` — the API level of the plugin itself\n *\n * Both directions are checked:\n * - Plugin too new for host: `pluginRequiresDdkLevel > ddk.compat`\n * - Plugin too old for host: `pluginLevel < ddk.compat.min-plugin`\n */\nexport function checkCompatibility(requirements: PluginCompatRequirements): CompatResult {\n const ddkLevel = getApiLevel('ddk.compat');\n const minPluginLevel = getApiLevel('ddk.compat.min-plugin');\n\n if (requirements.pluginRequiresDdkLevel > ddkLevel) {\n const ddkLabel = ddkLevel === 0 ? 'not registered' : String(ddkLevel);\n return {\n ok: false,\n reason: 'too-new-plugin',\n message:\n `[KOS] Plugin requires DDK level ${requirements.pluginRequiresDdkLevel}, ` +\n `but host provides level ${ddkLabel}.`,\n };\n }\n\n if (minPluginLevel > 0 && requirements.pluginLevel < minPluginLevel) {\n return {\n ok: false,\n reason: 'too-old-plugin',\n message:\n `[KOS] Plugin level ${requirements.pluginLevel} is below the host's minimum ` +\n `accepted plugin level ${minPluginLevel}.`,\n };\n }\n\n return { ok: true, reason: 'ok' };\n}\n"],"names":["_warned","warnDeprecated","apiName","serviceId","deprecatedAtLevel","replacement","removeAtLevel","_registry","registerApiLevels","levels","getRegistry","getApiLevel","service","hasApiLevel","minLevel","requireApiLevel","actual","actualLabel","getAllApiLevels","checkApiLevels","requirements","details","satisfied","required","ok","checkCompatibility","ddkLevel","minPluginLevel","ddkLabel"],"mappings":"AAAA,MAAMA,wBAAc,IAAA;AAYb,SAASC,EACdC,GACAC,GACAC,GACAC,GACAC,GACM;AACN,EAAI,OAAO,UAAY,OAAe,QAAQ,IAAI,aAAgB,gBAG9DN,EAAQ,IAAIE,CAAO,MACvBF,EAAQ,IAAIE,CAAO,GACnB,QAAQ;AAAA,IACN,UAAUA,CAAO,yBAAyBC,CAAS,UAAUC,CAAiB,UACpEC,CAAW,uCAAuCC,CAAa;AAAA,EAAA;AAE7E;AC1BA,MAAMC,IAAyB,CAAA;AASxB,SAASC,EAAkBC,GAA2B;AAC3D,SAAO,OAAOF,GAAWE,CAAM;AACjC;AAEO,SAASC,IAAqC;AACnD,SAAOH;AACT;ACVO,SAASI,EAAYC,GAA4B;AACtD,SAAOF,EAAA,EAAcE,CAAO,KAAK;AACnC;AAKO,SAASC,EAAYD,GAAoBE,GAA2B;AACzE,SAAOH,EAAYC,CAAO,KAAKE;AACjC;AAKO,SAASC,EAAgBH,GAAoBE,GAAwB;AAC1E,QAAME,IAASL,EAAYC,CAAO;AAClC,MAAII,IAASF,GAAU;AACrB,UAAMG,IAAcD,MAAW,IAAI,mBAAmB,OAAOA,CAAM;AACnE,UAAM,IAAI;AAAA,MACR,4CAA4CJ,CAAO,eAAeE,CAAQ,YAAYG,CAAW;AAAA,IAAA;AAAA,EAErG;AACF;AAKO,SAASC,IAAyC;AACvD,SAAOR,EAAA;AACT;AAKO,SAASS,EAAeC,GAAiD;AAC9E,QAAMC,IAAkC,CAAA;AACxC,MAAIC,IAAY;AAEhB,aAAW,CAACV,GAASW,CAAQ,KAAK,OAAO,QAAQH,CAAY,GAAG;AAC9D,QAAIG,MAAa;AAAW;AAC5B,UAAMP,IAASL,EAAYC,CAAO,GAC5BY,IAAKR,KAAUO;AACrB,IAAAF,EAAQT,CAAO,IAAI,EAAE,UAAAW,GAAU,QAAAP,GAAQ,IAAAQ,EAAA,GAClCA,MAAIF,IAAY;AAAA,EACvB;AAEA,SAAO,EAAE,WAAAA,GAAW,SAAAD,EAAA;AACtB;AAiBO,SAASI,EAAmBL,GAAsD;AACvF,QAAMM,IAAWf,EAAY,YAAY,GACnCgB,IAAiBhB,EAAY,uBAAuB;AAE1D,MAAIS,EAAa,yBAAyBM,GAAU;AAClD,UAAME,IAAWF,MAAa,IAAI,mBAAmB,OAAOA,CAAQ;AACpE,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,QAAQ;AAAA,MACR,SACE,mCAAmCN,EAAa,sBAAsB,6BAC3CQ,CAAQ;AAAA,IAAA;AAAA,EAEzC;AAEA,SAAID,IAAiB,KAAKP,EAAa,cAAcO,IAC5C;AAAA,IACL,IAAI;AAAA,IACJ,QAAQ;AAAA,IACR,SACE,sBAAsBP,EAAa,WAAW,sDACrBO,CAAc;AAAA,EAAA,IAItC,EAAE,IAAI,IAAM,QAAQ,KAAA;AAC7B;"}
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@kosdev-code/kos-api-levels",
3
+ "version": "0.1.0-dev.5797",
4
+ "type": "module",
5
+ "main": "./index.cjs",
6
+ "module": "./index.js",
7
+ "publishConfig": {
8
+ "registry": "https://registry.npmjs.org/"
9
+ },
10
+ "exports": {
11
+ ".": {
12
+ "import": {
13
+ "types": "./index.d.ts",
14
+ "default": "./index.js"
15
+ },
16
+ "require": {
17
+ "types": "./index.d.cts",
18
+ "default": "./index.cjs"
19
+ }
20
+ },
21
+ "./package.json": "./package.json"
22
+ },
23
+ "kos": {
24
+ "build": {
25
+ "gitHash": "bf103bc72ca8e841f32e61351ce311eb8be4a681"
26
+ }
27
+ }
28
+ }
package/registry.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { ApiLevelMap } from './types';
2
+
3
+ /**
4
+ * Registers API levels for an SDK package. Each SDK package calls this on
5
+ * import to populate the in-memory registry. Works in browser and Node.js.
6
+ *
7
+ * Phase 1: called manually from each package's index.ts.
8
+ * Phase 2: generated automatically by the JSDoc scanner at build time.
9
+ */
10
+ export declare function registerApiLevels(levels: ApiLevelMap): void;
11
+ export declare function getRegistry(): Readonly<ApiLevelMap>;
12
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../packages/sdk/kos-api-levels/src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAI3C;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAE3D;AAED,wBAAgB,WAAW,IAAI,QAAQ,CAAC,WAAW,CAAC,CAEnD"}
package/runtime.d.ts ADDED
@@ -0,0 +1,40 @@
1
+ import { ServiceId, ApiLevelMap, CheckResult, PluginCompatRequirements, CompatResult } from './types';
2
+
3
+ /**
4
+ * Returns the current API level for a service.
5
+ * Returns 0 if the service has not been registered.
6
+ */
7
+ export declare function getApiLevel(service: ServiceId): number;
8
+ /**
9
+ * Returns true if the registered level for a service meets the minimum requirement.
10
+ */
11
+ export declare function hasApiLevel(service: ServiceId, minLevel: number): boolean;
12
+ /**
13
+ * Throws if the registered level for a service does not meet the minimum requirement.
14
+ */
15
+ export declare function requireApiLevel(service: ServiceId, minLevel: number): void;
16
+ /**
17
+ * Returns all registered API levels. Useful for diagnostics and logging.
18
+ */
19
+ export declare function getAllApiLevels(): Readonly<ApiLevelMap>;
20
+ /**
21
+ * Checks multiple service requirements in a single call.
22
+ */
23
+ export declare function checkApiLevels(requirements: Partial<ApiLevelMap>): CheckResult;
24
+ /**
25
+ * Checks whether a DDK plugin is compatible with the current DDK host.
26
+ *
27
+ * The DDK host registers two services at startup:
28
+ * - `ddk.compat` — the current DDK API level (what it provides)
29
+ * - `ddk.compat.min-plugin` — the oldest plugin level this host still accepts
30
+ *
31
+ * A plugin passes its own requirements:
32
+ * - `pluginRequiresDdkLevel` — minimum DDK level the plugin needs
33
+ * - `pluginLevel` — the API level of the plugin itself
34
+ *
35
+ * Both directions are checked:
36
+ * - Plugin too new for host: `pluginRequiresDdkLevel > ddk.compat`
37
+ * - Plugin too old for host: `pluginLevel < ddk.compat.min-plugin`
38
+ */
39
+ export declare function checkCompatibility(requirements: PluginCompatRequirements): CompatResult;
40
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../packages/sdk/kos-api-levels/src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG3G;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,SAAS,GAAG,MAAM,CAEtD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEzE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAQ1E;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,QAAQ,CAAC,WAAW,CAAC,CAEvD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,WAAW,CAa9E;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,wBAAwB,GAAG,YAAY,CA0BvF"}
package/types.d.ts ADDED
@@ -0,0 +1,65 @@
1
+ /**
2
+ * An API level identifier string.
3
+ *
4
+ * For SDK packages this is the npm package name:
5
+ * `kos-ui-sdk`, `kos-dispense-sdk`
6
+ *
7
+ * For DDK compatibility this is a well-known service ID:
8
+ * `ddk.compat`, `ddk.compat.min-plugin`
9
+ *
10
+ * Per-service IDs (`core.topic-handler`, `dispense.nozzle`, etc.) exist in
11
+ * the scanner catalog (`generated/catalog.json`) for changelog and documentation
12
+ * purposes but are NOT registered at runtime.
13
+ */
14
+ export type ServiceId = string;
15
+ /**
16
+ * Map of service IDs to their current API level integers.
17
+ */
18
+ export type ApiLevelMap = Record<ServiceId, number>;
19
+ /**
20
+ * Result of a batch API level check.
21
+ */
22
+ export interface CheckResult {
23
+ /** True if all requirements are satisfied. */
24
+ satisfied: boolean;
25
+ /** Per-service breakdown of required vs actual levels. */
26
+ details: Record<string, {
27
+ required: number;
28
+ actual: number;
29
+ ok: boolean;
30
+ }>;
31
+ }
32
+ /**
33
+ * Requirements declared by a plugin when entering a DDK host.
34
+ * The plugin states the DDK API level it was written against and its own plugin-level.
35
+ */
36
+ export interface PluginCompatRequirements {
37
+ /**
38
+ * The DDK API level this plugin requires from the host.
39
+ * The host must satisfy: `ddk.compat >= pluginRequiresDdkLevel`.
40
+ */
41
+ pluginRequiresDdkLevel: number;
42
+ /**
43
+ * The API level of this plugin itself.
44
+ * The host must satisfy: `ddk.compat.min-plugin <= pluginLevel`.
45
+ */
46
+ pluginLevel: number;
47
+ }
48
+ /**
49
+ * Result of a DDK plugin/host compatibility check.
50
+ *
51
+ * - `ok` — plugin and host are compatible
52
+ * - `too-old-plugin` — this plugin is too old for the current DDK host
53
+ * (host's minimum accepted plugin level is higher than the plugin's level)
54
+ * - `too-new-plugin` — this plugin requires a newer DDK than the host provides
55
+ */
56
+ export type CompatReason = "ok" | "too-old-plugin" | "too-new-plugin";
57
+ export interface CompatResult {
58
+ ok: boolean;
59
+ reason: CompatReason;
60
+ /**
61
+ * Human-readable description of the incompatibility, if any.
62
+ */
63
+ message?: string;
64
+ }
65
+ //# sourceMappingURL=types.d.ts.map
package/types.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../packages/sdk/kos-api-levels/src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,8CAA8C;IAC9C,SAAS,EAAE,OAAO,CAAC;IACnB,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CAC5E;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAEtE,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,YAAY,CAAC;IACrB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}