@xemahq/contracts 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "algorithm": "sha256/len-framed-v1",
3
- "hash": "215a5086538b6716d986c0902e636d5df1c7db96d68ed3200185b4637ed0b4ff",
4
- "fileCount": 515
3
+ "hash": "6dd1fc61af526dcbe627bbde3197d58bdbde23fffabebffb75e00a266bcda1c7",
4
+ "fileCount": 516
5
5
  }
@@ -2,6 +2,7 @@ export * from './lib/space';
2
2
  export * from './lib/space-classification';
3
3
  export * from './lib/space-kind-rank';
4
4
  export * from './lib/scoped-resolution';
5
+ export * from './lib/scoped-setting';
5
6
  export * from './lib/space-promotion';
6
7
  export * from './lib/space-ref-parser';
7
8
  export * from './lib/space-traversal';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/space/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/space/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC"}
@@ -18,6 +18,7 @@ __exportStar(require("./lib/space"), exports);
18
18
  __exportStar(require("./lib/space-classification"), exports);
19
19
  __exportStar(require("./lib/space-kind-rank"), exports);
20
20
  __exportStar(require("./lib/scoped-resolution"), exports);
21
+ __exportStar(require("./lib/scoped-setting"), exports);
21
22
  __exportStar(require("./lib/space-promotion"), exports);
22
23
  __exportStar(require("./lib/space-ref-parser"), exports);
23
24
  __exportStar(require("./lib/space-traversal"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/space/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,6DAA2C;AAC3C,wDAAsC;AACtC,0DAAwC;AACxC,wDAAsC;AACtC,yDAAuC;AACvC,wDAAsC;AACtC,wDAAsC;AACtC,+DAA6C;AAC7C,+DAA6C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/space/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,6DAA2C;AAC3C,wDAAsC;AACtC,0DAAwC;AACxC,uDAAqC;AACrC,wDAAsC;AACtC,yDAAuC;AACvC,wDAAsC;AACtC,wDAAsC;AACtC,+DAA6C;AAC7C,+DAA6C"}
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ import { type ScopedResolution } from './scoped-resolution';
3
+ import { SpaceKind } from './space';
4
+ export declare const SCOPED_SETTING_KEY_PATTERN: RegExp;
5
+ export declare const ScopedSettingKeySchema: z.ZodString;
6
+ export declare enum ScopedSettingOwnership {
7
+ OrgOnly = "org-only",
8
+ ProjectOverridable = "project-overridable",
9
+ ProjectOnly = "project-only",
10
+ Other = "other"
11
+ }
12
+ export interface ScopedSettingDefinition<TValue = unknown> {
13
+ readonly key: string;
14
+ readonly schema: z.ZodType<TValue>;
15
+ readonly declarableAt: readonly SpaceKind[];
16
+ }
17
+ export declare const ScopedSettingDefinitionSchema: z.ZodObject<{
18
+ key: z.ZodString;
19
+ declarableAt: z.ZodArray<z.ZodEnum<typeof SpaceKind>>;
20
+ }, z.core.$strict>;
21
+ export declare function mayDeclareAt(definition: Pick<ScopedSettingDefinition, 'declarableAt'>, tier: SpaceKind): boolean;
22
+ export declare function scopedSettingOwnership(definition: Pick<ScopedSettingDefinition, 'declarableAt'>): ScopedSettingOwnership;
23
+ export interface ScopedSettingDeclaration<TValue = unknown> {
24
+ readonly ownerSpaceKind: SpaceKind;
25
+ readonly value: TValue;
26
+ }
27
+ export declare function resolveScopedSetting<TValue>(definition: Pick<ScopedSettingDefinition<TValue>, 'declarableAt'>, declarations: readonly ScopedSettingDeclaration<TValue>[]): ScopedResolution<TValue> | undefined;
28
+ //# sourceMappingURL=scoped-setting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scoped-setting.d.ts","sourceRoot":"","sources":["../../../src/space/lib/scoped-setting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAA0B,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,SAAS,EAAmB,MAAM,SAAS,CAAC;AA8DrD,eAAO,MAAM,0BAA0B,QACK,CAAC;AAE7C,eAAO,MAAM,sBAAsB,aAKhC,CAAC;AAGJ,oBAAY,sBAAsB;IAChC,OAAO,aAAa;IACpB,kBAAkB,wBAAwB;IAC1C,WAAW,iBAAiB;IAE5B,KAAK,UAAU;CAChB;AAED,MAAM,WAAW,uBAAuB,CAAC,MAAM,GAAG,OAAO;IACvD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAKnC,QAAQ,CAAC,YAAY,EAAE,SAAS,SAAS,EAAE,CAAC;CAC7C;AAED,eAAO,MAAM,6BAA6B;;;kBAW/B,CAAC;AASZ,wBAAgB,YAAY,CAC1B,UAAU,EAAE,IAAI,CAAC,uBAAuB,EAAE,cAAc,CAAC,EACzD,IAAI,EAAE,SAAS,GACd,OAAO,CAET;AASD,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,IAAI,CAAC,uBAAuB,EAAE,cAAc,CAAC,GACxD,sBAAsB,CAUxB;AAGD,MAAM,WAAW,wBAAwB,CAAC,MAAM,GAAG,OAAO;IACxD,QAAQ,CAAC,cAAc,EAAE,SAAS,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAWD,wBAAgB,oBAAoB,CAAC,MAAM,EACzC,UAAU,EAAE,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC,EACjE,YAAY,EAAE,SAAS,wBAAwB,CAAC,MAAM,CAAC,EAAE,GACxD,gBAAgB,CAAC,MAAM,CAAC,GAAG,SAAS,CAuBtC"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScopedSettingDefinitionSchema = exports.ScopedSettingOwnership = exports.ScopedSettingKeySchema = exports.SCOPED_SETTING_KEY_PATTERN = void 0;
4
+ exports.mayDeclareAt = mayDeclareAt;
5
+ exports.scopedSettingOwnership = scopedSettingOwnership;
6
+ exports.resolveScopedSetting = resolveScopedSetting;
7
+ const zod_1 = require("zod");
8
+ const scoped_resolution_1 = require("./scoped-resolution");
9
+ const space_1 = require("./space");
10
+ const space_kind_rank_1 = require("./space-kind-rank");
11
+ exports.SCOPED_SETTING_KEY_PATTERN = /^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)+$/u;
12
+ exports.ScopedSettingKeySchema = zod_1.z
13
+ .string()
14
+ .regex(exports.SCOPED_SETTING_KEY_PATTERN, 'A setting key is dotted lower-kebab, e.g. "xema.llm.default-strategy".');
15
+ var ScopedSettingOwnership;
16
+ (function (ScopedSettingOwnership) {
17
+ ScopedSettingOwnership["OrgOnly"] = "org-only";
18
+ ScopedSettingOwnership["ProjectOverridable"] = "project-overridable";
19
+ ScopedSettingOwnership["ProjectOnly"] = "project-only";
20
+ ScopedSettingOwnership["Other"] = "other";
21
+ })(ScopedSettingOwnership || (exports.ScopedSettingOwnership = ScopedSettingOwnership = {}));
22
+ exports.ScopedSettingDefinitionSchema = zod_1.z
23
+ .object({
24
+ key: exports.ScopedSettingKeySchema,
25
+ declarableAt: zod_1.z
26
+ .array(space_1.SpaceKindSchema)
27
+ .min(1, 'A scoped setting must be declarable somewhere.')
28
+ .refine((kinds) => new Set(kinds).size === kinds.length, 'A tier may appear at most once in `declarableAt`.'),
29
+ })
30
+ .strict();
31
+ function mayDeclareAt(definition, tier) {
32
+ return definition.declarableAt.includes(tier);
33
+ }
34
+ function scopedSettingOwnership(definition) {
35
+ const tiers = new Set(definition.declarableAt);
36
+ const org = tiers.has(space_1.SpaceKind.Org);
37
+ const project = tiers.has(space_1.SpaceKind.Project);
38
+ if (tiers.size === 1 && org)
39
+ return ScopedSettingOwnership.OrgOnly;
40
+ if (tiers.size === 1 && project)
41
+ return ScopedSettingOwnership.ProjectOnly;
42
+ if (tiers.size === 2 && org && project) {
43
+ return ScopedSettingOwnership.ProjectOverridable;
44
+ }
45
+ return ScopedSettingOwnership.Other;
46
+ }
47
+ function resolveScopedSetting(definition, declarations) {
48
+ for (const declaration of declarations) {
49
+ if (!mayDeclareAt(definition, declaration.ownerSpaceKind)) {
50
+ throw new Error(`A value was declared at "${declaration.ownerSpaceKind}", which this ` +
51
+ `setting does not admit (declarable at: ${definition.declarableAt.join(', ')}).`);
52
+ }
53
+ (0, space_kind_rank_1.spaceKindRank)(declaration.ownerSpaceKind);
54
+ }
55
+ return (0, scoped_resolution_1.resolveScopedCandidate)(declarations.map((declaration) => ({
56
+ ownerSpaceKind: declaration.ownerSpaceKind,
57
+ value: declaration.value,
58
+ })), () => 0);
59
+ }
60
+ //# sourceMappingURL=scoped-setting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scoped-setting.js","sourceRoot":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C,IAAI,KAAK,CAAC,IAAI,GAAG;QAAE,OAAO,sBAAsB,CAAC,OAAO,CAAC;IACnE,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,OAAO;QAAE,OAAO,sBAAsB,CAAC,WAAW,CAAC;IAC3E,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;QACvC,OAAO,sBAAsB,CAAC,kBAAkB,CAAC;IACnD,CAAC;IACD,OAAO,sBAAsB,CAAC,KAAK,CAAC;AACtC,CAAC;AAiBD,SAAgB,oBAAoB,CAClC,UAAiE,EACjE,YAAyD;IAEzD,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,WAAW,CAAC,cAAc,CAAC,EAAE,CAAC;YAC1D,MAAM,IAAI,KAAK,CACb,4BAA4B,WAAW,CAAC,cAAc,gBAAgB;gBACpE,0CAA0C,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CACnF,CAAC;QACJ,CAAC;QAGD,IAAA,+BAAa,EAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,IAAA,0CAAsB,EAC3B,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QACjC,cAAc,EAAE,WAAW,CAAC,cAAc;QAC1C,KAAK,EAAE,WAAW,CAAC,KAAK;KACzB,CAAC,CAAC,EAKH,GAAG,EAAE,CAAC,CAAC,CACR,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xemahq/contracts",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Consolidated Xema OS kernel wire contracts — pure types + zod schemas for the kernel protocol surfaces. One package, one npm scope, wildcard per-surface subpath exports. No framework/runtime deps.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Neuralchowder Inc. <developer@xema.dev> (https://xema.dev)",