@almadar/core 10.129.0 → 11.0.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/behavior-package.d.ts +49 -11
- package/dist/behavior-package.js +1 -1
- package/dist/{orbital-CkFdDS9f.d.ts → builders-BdgbY7Th.d.ts} +5828 -6917
- package/dist/builders.d.ts +6 -6
- package/dist/builders.js +7 -6
- package/dist/{bus-CcbB__oo.d.ts → bus-C0hFDNFR.d.ts} +262 -354
- package/dist/chunk-347APWFM.js +286 -0
- package/dist/chunk-347APWFM.js.map +1 -0
- package/dist/chunk-5WQ3U7NJ.js +2363 -0
- package/dist/chunk-5WQ3U7NJ.js.map +1 -0
- package/dist/chunk-5YTPYMPZ.js +99 -0
- package/dist/chunk-5YTPYMPZ.js.map +1 -0
- package/dist/chunk-66Q5VX2F.js +3810 -0
- package/dist/chunk-66Q5VX2F.js.map +1 -0
- package/dist/chunk-7GHJU5WI.js +39 -0
- package/dist/chunk-7GHJU5WI.js.map +1 -0
- package/dist/chunk-B4MNHGBP.js +8 -0
- package/dist/chunk-B4MNHGBP.js.map +1 -0
- package/dist/chunk-E4T2MQAV.js +24 -0
- package/dist/chunk-E4T2MQAV.js.map +1 -0
- package/dist/chunk-ENOCKYGA.js +412 -0
- package/dist/chunk-ENOCKYGA.js.map +1 -0
- package/dist/chunk-FGT5OS2Y.js +918 -0
- package/dist/chunk-FGT5OS2Y.js.map +1 -0
- package/dist/chunk-GF7KCLNR.js +3284 -0
- package/dist/chunk-GF7KCLNR.js.map +1 -0
- package/dist/chunk-PNGFWLHD.js +1567 -0
- package/dist/chunk-PNGFWLHD.js.map +1 -0
- package/dist/{chunk-X4SC7FGF.js → chunk-RGACZEYC.js} +99 -96
- package/dist/chunk-RGACZEYC.js.map +1 -0
- package/dist/{chunk-RYPVOI6H.js → chunk-SNZYN7UA.js} +2541 -433
- package/dist/{chunk-RYPVOI6H.js.map → chunk-SNZYN7UA.js.map} +1 -1
- package/dist/{chunk-KDMV222Q.js → chunk-TDNQT3M3.js} +304 -373
- package/dist/chunk-TDNQT3M3.js.map +1 -0
- package/dist/chunk-VG7BRFUD.js +152 -0
- package/dist/chunk-VG7BRFUD.js.map +1 -0
- package/dist/chunk-Z7BI7DE7.js +1293 -0
- package/dist/chunk-Z7BI7DE7.js.map +1 -0
- package/dist/{domain-Dz3jP-UM.d.ts → domain-Cpmja5ak.d.ts} +55 -55
- package/dist/{effect-CiEVLsZz.d.ts → effect-DZaXwSAz.d.ts} +283 -453
- package/dist/{effect-result-Bebwu9yT.d.ts → effect-result-1HpXgeBc.d.ts} +656 -851
- package/dist/{expression-D0Fs0riG.d.ts → expression-DirYKz-f.d.ts} +5 -13
- package/dist/factory/index.d.ts +7 -144
- package/dist/factory/index.js +8 -8
- package/dist/factory-runtime/index.d.ts +7 -6
- package/dist/factory-runtime/index.js +527 -8
- package/dist/factory-runtime/index.js.map +1 -1
- package/dist/fixtures.d.ts +9 -11
- package/dist/fixtures.js +12 -8
- package/dist/fixtures.js.map +1 -1
- package/dist/i18n/index.d.ts +15 -19
- package/dist/i18n/index.js +2 -1
- package/dist/{index-BC-Jycqj.d.ts → index-D7SxwNdv.d.ts} +34 -734
- package/dist/index.d.ts +92 -247
- package/dist/index.js +322 -986
- package/dist/index.js.map +1 -1
- package/dist/kernel-wire.d.ts +3 -3
- package/dist/kernel-wire.js +3 -79
- package/dist/kernel-wire.js.map +1 -1
- package/dist/language/constructs.json +22 -2
- package/dist/language/program-types.json +203 -22
- package/dist/language/protocols.json +46 -0
- package/dist/language/ui-vocabulary.json +1697 -0
- package/dist/language/validation-codes.json +1222 -1212
- package/dist/language/vocabulary.json +44 -8
- package/dist/language-data.d.ts +7 -4
- package/dist/language-data.js +20 -14
- package/dist/language-data.js.map +1 -1
- package/dist/patterns/component-mapping.json +11 -1
- package/dist/patterns/definitions.d.ts +2 -2
- package/dist/patterns/definitions.js +1 -1
- package/dist/patterns/event-contracts.json +1 -15
- package/dist/patterns/game-font-families.json +13 -0
- package/dist/patterns/index.d.ts +24 -120
- package/dist/patterns/index.js +3 -3
- package/dist/patterns/pattern-tile-geometry.json +1065 -0
- package/dist/patterns/patterns-registry.json +2539 -431
- package/dist/patterns/registry.json +2539 -431
- package/dist/trait-sRjIivFq.d.ts +3519 -0
- package/dist/types/index.d.ts +9 -10
- package/dist/types/index.js +11 -5
- package/dist/{types-DGwrltUF.d.ts → types-C6_yPMpn.d.ts} +3 -3
- package/fixtures/events-wire/client-effects-by-trait/response.json +0 -18
- package/fixtures/events-wire/client-effects-provenance/response.json +0 -18
- package/fixtures/events-wire/effect-results-every-kind/response.json +2 -27
- package/fixtures/events-wire/navigate-1/response.json +8 -5
- package/fixtures/events-wire/navigate-2/response.json +11 -8
- package/fixtures/events-wire/navigate-3/response.json +14 -11
- package/fixtures/events-wire/navigate-back/response.json +7 -4
- package/fixtures/events-wire/render-ui-3/response.json +12 -9
- package/fixtures/events-wire/render-ui-clear/response.json +0 -7
- package/fixtures/events-wire/sse-stream/response.json +0 -20
- package/fixtures/events-wire/sse-stream/stream.json +0 -20
- package/fixtures/events-wire/stateless-traits/response.json +14 -5
- package/fixtures/kernel-wire/golden/basic-entity.json +1687 -0
- package/fixtures/kernel-wire/golden/entity-rerender.json +743 -0
- package/fixtures/kernel-wire/golden/rollback.json +793 -0
- package/fixtures/kernel-wire/golden/tick-counter.json +1538 -0
- package/fixtures/kernel-wire/golden/two-orbital-chore.json +847 -0
- package/fixtures/kernel-wire/golden/two-orbital-task.json +457 -0
- package/fixtures/kernel-wire/played-step.json +136 -0
- package/fixtures/kernel-wire/scripts/basic-entity.json +28 -0
- package/fixtures/kernel-wire/scripts/entity-rerender.json +13 -0
- package/fixtures/kernel-wire/scripts/rollback.json +53 -0
- package/fixtures/kernel-wire/scripts/tick-counter.json +26 -0
- package/fixtures/kernel-wire/scripts/two-orbital-chore.json +9 -0
- package/fixtures/kernel-wire/scripts/two-orbital-task.json +9 -0
- package/package.json +28 -19
- package/dist/builders-DmZE5By0.d.ts +0 -2663
- package/dist/chunk-45I2O4SJ.js +0 -4646
- package/dist/chunk-45I2O4SJ.js.map +0 -1
- package/dist/chunk-6LR43Z5E.js +0 -3061
- package/dist/chunk-6LR43Z5E.js.map +0 -1
- package/dist/chunk-GIUA3NUJ.js +0 -809
- package/dist/chunk-GIUA3NUJ.js.map +0 -1
- package/dist/chunk-GTY53NS5.js +0 -1908
- package/dist/chunk-GTY53NS5.js.map +0 -1
- package/dist/chunk-JOHDVS6J.js +0 -1614
- package/dist/chunk-JOHDVS6J.js.map +0 -1
- package/dist/chunk-KDMV222Q.js.map +0 -1
- package/dist/chunk-QRHJUS3D.js +0 -23
- package/dist/chunk-QRHJUS3D.js.map +0 -1
- package/dist/chunk-QUOTJULD.js +0 -4009
- package/dist/chunk-QUOTJULD.js.map +0 -1
- package/dist/chunk-V5VNGRVU.js +0 -66
- package/dist/chunk-V5VNGRVU.js.map +0 -1
- package/dist/chunk-X4SC7FGF.js.map +0 -1
- package/dist/entityAccess-BPSz1i2n.d.ts +0 -80
- package/dist/mock/index.d.ts +0 -153
- package/dist/mock/index.js +0 -190
- package/dist/mock/index.js.map +0 -1
- package/dist/schema-T5RT5s6H.d.ts +0 -282
- package/dist/state-machine/index.d.ts +0 -359
- package/dist/state-machine/index.js +0 -3
- package/dist/state-machine/index.js.map +0 -1
package/dist/chunk-V5VNGRVU.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
// src/access/entityAccess.ts
|
|
2
|
-
function orbitalInlineEntities(orbital) {
|
|
3
|
-
const out = [];
|
|
4
|
-
const refs = [orbital.entity, ...orbital.auxiliaryEntities ?? []];
|
|
5
|
-
for (const ref of refs) {
|
|
6
|
-
if (typeof ref === "object" && ref !== null && "fields" in ref) {
|
|
7
|
-
out.push(ref);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
return out;
|
|
11
|
-
}
|
|
12
|
-
function entityOwnerOrbital(schema, entityType) {
|
|
13
|
-
return schema.orbitals.find((orbital) => orbitalInlineEntities(orbital).some((entity) => entity.name === entityType));
|
|
14
|
-
}
|
|
15
|
-
function inlineEntities(schema) {
|
|
16
|
-
return (schema.orbitals ?? []).flatMap(orbitalInlineEntities);
|
|
17
|
-
}
|
|
18
|
-
function isDeclared(p) {
|
|
19
|
-
return p.read !== void 0 || p.create !== void 0 || p.update !== void 0 || p.delete !== void 0;
|
|
20
|
-
}
|
|
21
|
-
function entityAccessTable(schema) {
|
|
22
|
-
const table = /* @__PURE__ */ new Map();
|
|
23
|
-
const collectionOf = /* @__PURE__ */ new Map();
|
|
24
|
-
for (const def of inlineEntities(schema)) {
|
|
25
|
-
table.set(def.name, {
|
|
26
|
-
read: def.read_policy,
|
|
27
|
-
create: def.create_policy,
|
|
28
|
-
update: def.update_policy,
|
|
29
|
-
delete: def.delete_policy
|
|
30
|
-
});
|
|
31
|
-
if (def.collection) collectionOf.set(def.name, def.collection);
|
|
32
|
-
}
|
|
33
|
-
const byCollection = /* @__PURE__ */ new Map();
|
|
34
|
-
for (const [name, policies] of table) {
|
|
35
|
-
const collection = collectionOf.get(name);
|
|
36
|
-
if (collection && isDeclared(policies) && !byCollection.has(collection)) {
|
|
37
|
-
byCollection.set(collection, policies);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
for (const [name, policies] of table) {
|
|
41
|
-
if (isDeclared(policies)) continue;
|
|
42
|
-
const collection = collectionOf.get(name);
|
|
43
|
-
const inherited = collection ? byCollection.get(collection) : void 0;
|
|
44
|
-
if (inherited) table.set(name, { ...inherited });
|
|
45
|
-
}
|
|
46
|
-
return table;
|
|
47
|
-
}
|
|
48
|
-
function entityAccessPolicies(schema, entityName) {
|
|
49
|
-
return entityAccessTable(schema).get(entityName);
|
|
50
|
-
}
|
|
51
|
-
function entityAccessPoliciesByStoreKey(schema) {
|
|
52
|
-
const collectionOf = /* @__PURE__ */ new Map();
|
|
53
|
-
for (const def of inlineEntities(schema)) {
|
|
54
|
-
if (def.collection) collectionOf.set(def.name, def.collection);
|
|
55
|
-
}
|
|
56
|
-
const byKey = /* @__PURE__ */ new Map();
|
|
57
|
-
for (const [name, policies] of entityAccessTable(schema)) {
|
|
58
|
-
const key = collectionOf.get(name) ?? name.toLowerCase();
|
|
59
|
-
if (!byKey.has(key) && isDeclared(policies)) byKey.set(key, policies);
|
|
60
|
-
}
|
|
61
|
-
return byKey;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export { entityAccessPolicies, entityAccessPoliciesByStoreKey, entityAccessTable, entityOwnerOrbital, orbitalInlineEntities };
|
|
65
|
-
//# sourceMappingURL=chunk-V5VNGRVU.js.map
|
|
66
|
-
//# sourceMappingURL=chunk-V5VNGRVU.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/access/entityAccess.ts"],"names":[],"mappings":";AA4BO,SAAS,sBAAsB,OAAA,EAA6C;AACjF,EAAA,MAAM,MAAuB,EAAC;AAC9B,EAAA,MAAM,IAAA,GAAoB,CAAC,OAAA,CAAQ,MAAA,EAAQ,GAAI,OAAA,CAAQ,iBAAA,IAAqB,EAAG,CAAA;AAC/E,EAAA,KAAA,MAAW,OAAO,IAAA,EAAM;AACtB,IAAA,IAAI,OAAO,GAAA,KAAQ,QAAA,IAAY,GAAA,KAAQ,IAAA,IAAQ,YAAY,GAAA,EAAK;AAC9D,MAAA,GAAA,CAAI,KAAK,GAAoB,CAAA;AAAA,IAC/B;AAAA,EACF;AACA,EAAA,OAAO,GAAA;AACT;AAGO,SAAS,kBAAA,CAAmB,QAAuB,UAAA,EAAmD;AAC3G,EAAA,OAAO,MAAA,CAAO,QAAA,CAAS,IAAA,CAAK,CAAC,YAAY,qBAAA,CAAsB,OAAO,CAAA,CAAE,IAAA,CAAK,CAAC,MAAA,KAAW,MAAA,CAAO,IAAA,KAAS,UAAU,CAAC,CAAA;AACtH;AAIA,SAAS,eAAe,MAAA,EAAwC;AAC9D,EAAA,OAAA,CAAQ,MAAA,CAAO,QAAA,IAAY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AC1B,IAAA,MAAM,UAAA,GAAa,YAAA,CAAa,GAAA,CAAI,IAAI,CAAA;AACxC,IAAA,MAAM,SAAA,GAAY,UAAA,GAAa,YAAA,CAAa,GAAA,CAAI,UAAU,CAAA,GAAI,MAAA;AAC9D,IAAA,IAAI,WAAW,KAAA,CAAM,GAAA,CAAI,MAAM,EAAE,GAAG,WAAW,CAAA;AAAA,EACjD;AAEA,EAAA,OAAO,KAAA;AACT;AAGO,SAAS,oBAAA,CACd,QACA,UAAA,EACkC;AAClC,EAAA,OAAO,iBAAA,CAAkB,MAAM,CAAA,CAAE,GAAA,CAAI,UAAU,CAAA;AACjD;AAaO,SAAS,+BACd,MAAA,EACmC;AACnC,EAAA,MAAM,YAAA,uBAAmB,GAAA,EAAoB;AAC7C,EAAA,KAAA,MAAW,GAAA,IAAO,cAAA,CAAe,MAAM,CAAA,EAAG;AACxC,IAAA,IAAI,IAAI,UAAA,EAAY,YAAA,CAAa,IAAI,GAAA,CAAI,IAAA,EAAM,IAAI,UAAU,CAAA;AAAA,EAC/D;AACA,EAAA,MAAM,KAAA,uBAAY,GAAA,EAAkC;AACpD,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,QAAQ,CAAA,IAAK,iBAAA,CAAkB,MAAM,CAAA,EAAG;AACxD,IAAA,MAAM,MAAM,YAAA,CAAa,GAAA,CAAI,IAAI,CAAA,IAAK,KAAK,WAAA,EAAY;AACvD,IAAA,IAAI,CAAC,KAAA,CAAM,GAAA,CAAI,GAAG,CAAA,IAAK,UAAA,CAAW,QAAQ,CAAA,EAAG,KAAA,CAAM,GAAA,CAAI,GAAA,EAAK,QAAQ,CAAA;AAAA,EACtE;AACA,EAAA,OAAO,KAAA;AACT","file":"chunk-V5VNGRVU.js","sourcesContent":["/**\n * Entity access policies — the declared `@read`/`@create`/`@update`/`@delete`\n * directives, keyed by entity name.\n *\n * The JS mirror of `orbital-core/src/runtime/entity_access.rs`'s\n * `EntityAccessPolicies`/`EntityAccessTable`. Both paths must agree: a\n * directive is a per-row predicate (`@entity` = the candidate row, or for\n * `@create` the incoming data; `@user` = the viewer), enforced once for\n * every trait that touches the entity — the un-bypassable twin of a\n * call-site `filter:`, which sibling traits can skip simply by not\n * declaring one.\n *\n * @packageDocumentation\n */\n\nimport type { OrbitalEntity } from '../types/entity.js';\nimport type { EntityRef, OrbitalDefinition } from '../types/orbital.js';\nimport type { OrbitalSchema } from '../types/schema.js';\nimport type { SExpr } from '../types/expression.js';\n\n/**\n * One orbital's own inline entity definitions: its primary entity plus any\n * auxiliaries an import brought along (`auxiliaryEntities` — a linkedEntity\n * naming an imported atom's own entity resolves here, not among any\n * orbital's primary entity alone). Skips unresolved `string`/`EntityCall`\n * refs — those are pre-inline-phase forms that never reach this by the time\n * a schema is served.\n */\nexport function orbitalInlineEntities(orbital: OrbitalDefinition): OrbitalEntity[] {\n const out: OrbitalEntity[] = [];\n const refs: EntityRef[] = [orbital.entity, ...(orbital.auxiliaryEntities ?? [])];\n for (const ref of refs) {\n if (typeof ref === 'object' && ref !== null && 'fields' in ref) {\n out.push(ref as OrbitalEntity);\n }\n }\n return out;\n}\n\n/** The orbital of `schema` that declares the entity `entityType` inline, when one does. */\nexport function entityOwnerOrbital(schema: OrbitalSchema, entityType: string): OrbitalDefinition | undefined {\n return schema.orbitals.find((orbital) => orbitalInlineEntities(orbital).some((entity) => entity.name === entityType));\n}\n\n/** Inline entity definitions of every orbital in a schema: each orbital's\n * primary entity plus any auxiliaries. */\nfunction inlineEntities(schema: OrbitalSchema): OrbitalEntity[] {\n return (schema.orbitals ?? []).flatMap(orbitalInlineEntities);\n}\n\n/** An entity's four declared directives. Any may be absent — an absent\n * directive means \"no restriction\" for that operation, exactly like an\n * absent fetch `filter:`. */\nexport interface EntityAccessPolicies {\n read?: SExpr;\n create?: SExpr;\n update?: SExpr;\n delete?: SExpr;\n}\n\n/** Whether the author declared any of the four directives on this entity. */\nfunction isDeclared(p: EntityAccessPolicies): boolean {\n return (\n p.read !== undefined ||\n p.create !== undefined ||\n p.update !== undefined ||\n p.delete !== undefined\n );\n}\n\n/**\n * Every entity's access policies, keyed by entity name.\n *\n * A policy governs the **collection**, not the declaration. A `persistent:`\n * collection is one table, and two entity declarations over one table cannot\n * honestly carry different visibility rules. Keying by entity name alone let an\n * organism declare `@read` on its own entity and still ship an ALLOW-ALL list\n * wherever a page rendered through a std-atom trait that fetched the ATOM's\n * entity on the same collection — measured on `std-customer-success`, where\n * `/health-scores` returned 6 rows for every persona while the organism's own\n * `/cs-accounts` correctly returned 3 vs 6. 36 of 54 app organisms share a\n * collection this way (`R-SHADOW-ENTITY-SHARES-COLLECTION-DIRECTIVES-DONT-APPLY`).\n *\n * So an entity that declares nothing adopts the policy declared on its\n * collection. This can only ever ADD a restriction: an entity with its own\n * directives keeps exactly those, and an entity whose collection carries no\n * declared policy is untouched. Conflicting declarations on one collection are\n * rejected at validate time by `ORB_S_COLLECTION_POLICY_CONFLICT`.\n *\n * Mirrors `resolve_collection_inheritance` in\n * `orbital-rust/crates/orbital-core/src/runtime/entity_access.rs`.\n */\nexport function entityAccessTable(schema: OrbitalSchema): Map<string, EntityAccessPolicies> {\n const table = new Map<string, EntityAccessPolicies>();\n const collectionOf = new Map<string, string>();\n\n for (const def of inlineEntities(schema)) {\n table.set(def.name, {\n read: def.read_policy,\n create: def.create_policy,\n update: def.update_policy,\n delete: def.delete_policy,\n });\n if (def.collection) collectionOf.set(def.name, def.collection);\n }\n\n const byCollection = new Map<string, EntityAccessPolicies>();\n for (const [name, policies] of table) {\n const collection = collectionOf.get(name);\n if (collection && isDeclared(policies) && !byCollection.has(collection)) {\n byCollection.set(collection, policies);\n }\n }\n\n for (const [name, policies] of table) {\n if (isDeclared(policies)) continue;\n const collection = collectionOf.get(name);\n const inherited = collection ? byCollection.get(collection) : undefined;\n if (inherited) table.set(name, { ...inherited });\n }\n\n return table;\n}\n\n/** One entity's access policies, or `undefined` when it declares none. */\nexport function entityAccessPolicies(\n schema: OrbitalSchema,\n entityName: string,\n): EntityAccessPolicies | undefined {\n return entityAccessTable(schema).get(entityName);\n}\n\n/**\n * Access policies keyed the way the mock store keys its tables: the declared\n * `persistent:` collection, else the lowercased entity name. The mock\n * adapter's owner-restamp consults this map to decide whether a persona the\n * dev host switches to could have CREATED a row before re-pointing its owner\n * column — a reader persona must not inherit authorship of a draft just\n * because the demo store follows the viewer (the `@create` directive is the\n * single authority on who authors; no role heuristics here). First declared\n * policy per collection wins, the same collection-inheritance rule as\n * `entityAccessTable`.\n */\nexport function entityAccessPoliciesByStoreKey(\n schema: OrbitalSchema,\n): Map<string, EntityAccessPolicies> {\n const collectionOf = new Map<string, string>();\n for (const def of inlineEntities(schema)) {\n if (def.collection) collectionOf.set(def.name, def.collection);\n }\n const byKey = new Map<string, EntityAccessPolicies>();\n for (const [name, policies] of entityAccessTable(schema)) {\n const key = collectionOf.get(name) ?? name.toLowerCase();\n if (!byKey.has(key) && isDeclared(policies)) byKey.set(key, policies);\n }\n return byKey;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/behavior-package.ts"],"names":["readdirSync","join","relative"],"mappings":";;;;;;;;;AAuBA,IAAM,EAAE,YAAW,GAAI,UAAA;AACvB,IAAM,EAAE,YAAA,EAAc,UAAA,EAAY,SAAA,EAAW,WAAA,EAAAA,YAAAA,EAAa,YAAA,EAAc,YAAA,EAAc,UAAA,EAAY,MAAA,EAAQ,QAAA,EAAU,aAAA,EAAc,GAAI,MAAA;AACtI,IAAM,EAAE,eAAc,GAAI,UAAA;AAC1B,IAAM,EAAE,SAAQ,GAAI,MAAA;AACpB,IAAM,EAAE,SAAS,UAAA,EAAY,IAAA,EAAAC,OAAM,QAAA,EAAAC,SAAAA,EAAU,OAAA,EAAS,GAAA,EAAI,GAAI,QAAA;AAEvD,IAAM,6BAAA,GAAgC,EAC1C,MAAA,CAAO;AAAA,EACR,MAAA,EAAQ,CAAA,CAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA;AAAA;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M,CAAA;AAC1J,IAAA,IAAI,GAAA,CAAI,MAAA,KAAW,CAAA,EAAG,MAAM,IAAI,oBAAA,CAAqB,CAAA,EAAG,GAAA,CAAI,IAAI,CAAA,iBAAA,EAAoB,GAAG,CAAA,WAAA,EAAc,GAAA,CAAI,MAAM,CAAA,CAAE,CAAA;AAAA,EACnH;AACA,EAAA,OAAO,EAAE,GAAG,GAAA,CAAI,GAAA,EAAK,UAAU,SAAA,EAAU;AAC3C","file":"chunk-X4SC7FGF.js","sourcesContent":["/**\n * The `orb` block a behavior package declares in its `package.json`\n * (`docs/Almadar_Behavior_Packages.md` §3) and the one resolver for the files it\n * declares. Readers resolve sidecars through these declared paths, never through\n * a hardcoded package layout. TS mirror of `orbital_core::behavior_packages`.\n *\n * Node-only (reads `package.json` with `node:fs`): exported from the\n * `@almadar/core/behavior-package` subpath only, never the main entry, so browser\n * bundles never pull in `node:fs` (the `@almadar/core/fixtures` precedent).\n *\n * @packageDocumentation\n */\n// Namespace imports: a browser bundle that reaches this Node-only module through a\n// dynamic import (the runtime's external loader) can still link it against the\n// bundler's empty builtin stubs — named imports would fail to bind.\nimport * as nodeCrypto from 'node:crypto';\nimport * as nodeChildProcess from 'node:child_process';\nimport * as nodeFs from 'node:fs';\nimport * as nodeModule from 'node:module';\nimport * as nodeOs from 'node:os';\nimport * as nodePath from 'node:path';\nimport { z } from 'zod';\n\nconst { createHash } = nodeCrypto;\nconst { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } = nodeFs;\nconst { createRequire } = nodeModule;\nconst { homedir } = nodeOs;\nconst { dirname, isAbsolute, join, relative, resolve, sep } = nodePath;\n\nexport const BehaviorPackageOrbBlockSchema = z\n .object({\n prefix: z.string().min(1),\n /** A materialized tree of lowered `.orb` programs (a published package). */\n registry: z.string().min(1).optional(),\n /** The `.lolo` sources, lowered on read when no `registry` is declared (a workspace package). */\n source: z.string().min(1).optional(),\n vectors: z.string().min(1).optional(),\n compiler: z.string().min(1),\n })\n .refine((orb) => orb.registry !== undefined || orb.source !== undefined, {\n message: 'declares neither `registry` (materialized) nor `source` (live)',\n });\n\nexport type BehaviorPackageOrbBlock = z.infer<typeof BehaviorPackageOrbBlockSchema>;\n\nconst PackageManifestSchema = z.object({\n name: z.string().default(''),\n version: z.string().default(''),\n orb: BehaviorPackageOrbBlockSchema.optional(),\n});\n\n/** `sidecars.lock.json` — package-relative paths whose content lives in the sidecar store (§13). */\nexport const SidecarLockSchema = z.object({\n version: z.literal(1),\n files: z.record(\n z.string(),\n z.object({\n sha256: z.string().regex(/^[0-9a-f]{64}$/),\n bytes: z.number().int().nonnegative(),\n url: z.string().url(),\n }),\n ),\n});\n\nexport type SidecarLock = z.infer<typeof SidecarLockSchema>;\nexport type SidecarLockEntry = SidecarLock['files'][string];\n\nexport type DeclaredFileKey = 'vectors';\n\nexport interface BehaviorPackage {\n name: string;\n version: string;\n root: string;\n orb: BehaviorPackageOrbBlock;\n /** The package's `sidecars.lock.json`, or `null` when it ships none. */\n lock: SidecarLock | null;\n}\n\n/** Fetches a lock entry's url and returns its (decoded) bytes. Injected in tests. */\nexport type SidecarFetch = (url: string) => Promise<Uint8Array>;\n\nexport interface SidecarOptions {\n /** Default: `ALMADAR_SIDECAR_CACHE`, else `~/.almadar/sidecars`. */\n cacheDir?: string;\n fetch?: SidecarFetch;\n}\n\nexport class BehaviorPackageError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'BehaviorPackageError';\n }\n}\n\n/** Read the behavior package rooted at `root`; refuses a `package.json` with no `orb` block. */\nexport function readBehaviorPackage(root: string): BehaviorPackage {\n const manifest = join(root, 'package.json');\n const result = PackageManifestSchema.safeParse(JSON.parse(readFileSync(manifest, 'utf8')));\n if (!result.success) {\n throw new BehaviorPackageError(`${manifest}: malformed \\`orb\\` block — ${result.error.message}`);\n }\n const { name, version, orb } = result.data;\n if (!orb) {\n throw new BehaviorPackageError(`${manifest} declares no \\`orb\\` block — not a behavior package`);\n }\n return { name, version, root, orb, lock: readSidecarLock(root) };\n}\n\n/** Runtime sidecars: shipped, resolved on demand. */\nexport const SIDECAR_LOCK_FILE = 'sidecars.lock.json';\n/** Build inputs: committed, not shipped; restored into the package before a build. */\nexport const BUILD_INPUTS_LOCK_FILE = 'build-inputs.lock.json';\n\n/** Read a package lock file (`SIDECAR_LOCK_FILE` or `BUILD_INPUTS_LOCK_FILE`); `null` when the package has none. */\nexport function readLockFile(root: string, lockFile: string = SIDECAR_LOCK_FILE): SidecarLock | null {\n const lockPath = join(root, lockFile);\n if (!existsSync(lockPath)) return null;\n const result = SidecarLockSchema.safeParse(JSON.parse(readFileSync(lockPath, 'utf8')));\n if (!result.success) {\n throw new BehaviorPackageError(`${lockPath}: malformed ${lockFile} — ${result.error.message}`);\n }\n return result.data;\n}\n\nfunction readSidecarLock(root: string): SidecarLock | null {\n return readLockFile(root, SIDECAR_LOCK_FILE);\n}\n\nexport function sidecarCacheDir(): string {\n return process.env['ALMADAR_SIDECAR_CACHE'] || join(homedir(), '.almadar', 'sidecars');\n}\n\nconst defaultFetch: SidecarFetch = async (url) => {\n const response = await fetch(url);\n if (!response.ok) throw new Error(`HTTP ${response.status}`);\n return new Uint8Array(await response.arrayBuffer());\n};\n\nfunction urlHost(url: string): string {\n return new URL(url).host;\n}\n\nfunction hashMismatch(pkg: Pick<BehaviorPackage, 'name' | 'version'>, relPath: string, entry: SidecarLockEntry, detail: string): BehaviorPackageError {\n return new BehaviorPackageError(\n `ORB_SIDECAR_HASH_MISMATCH: ${pkg.name}@${pkg.version} ${relPath} — expected sha256 ${entry.sha256} (${entry.bytes} bytes), ${detail}`,\n );\n}\n\nfunction packageFile(pkg: BehaviorPackage, relPath: string, label: string): string {\n const absolute = resolve(pkg.root, relPath);\n const rel = relative(pkg.root, absolute);\n if (rel.startsWith('..') || isAbsolute(rel)) {\n throw new BehaviorPackageError(`${pkg.name}: ${label} = \"${relPath}\" points outside the package`);\n }\n if (!existsSync(absolute)) {\n throw new BehaviorPackageError(`${pkg.name}@${pkg.version}: ${label} declares \"${relPath}\", which is not in the package`);\n }\n return absolute;\n}\n\n/**\n * Sync resolution of a declared path (§13 rule): a lock-declared path resolves to its cache\n * file and fails with ORB_SIDECAR_NOT_CACHED when absent; any other path is read from the package.\n */\nexport function resolveDeclaredPath(pkg: BehaviorPackage, relPath: string, options: SidecarOptions = {}, label = 'declared path'): string {\n const entry = pkg.lock?.files[relPath];\n if (!entry) return packageFile(pkg, relPath, label);\n const cached = join(options.cacheDir ?? sidecarCacheDir(), entry.sha256);\n if (!existsSync(cached)) {\n throw new BehaviorPackageError(\n `ORB_SIDECAR_NOT_CACHED: ${pkg.name}@${pkg.version} ${relPath} (sha256 ${entry.sha256}) is not in the sidecar cache — resolve it with ensureDeclaredPath or \\`npx @almadar/db sidecars pull\\``,\n );\n }\n if (statSync(cached).size !== entry.bytes) throw hashMismatch(pkg, relPath, entry, `cached file has ${statSync(cached).size} bytes`);\n return cached;\n}\n\n/** Ensures one lock entry is in the cache (downloading and verifying it on a miss) and returns the cache file. */\nexport async function ensureLockEntry(\n pkg: Pick<BehaviorPackage, 'name' | 'version'>,\n relPath: string,\n entry: SidecarLockEntry,\n options: SidecarOptions = {},\n): Promise<string> {\n const cacheDir = options.cacheDir ?? sidecarCacheDir();\n const cached = join(cacheDir, entry.sha256);\n if (existsSync(cached)) {\n if (statSync(cached).size !== entry.bytes) throw hashMismatch(pkg, relPath, entry, `cached file has ${statSync(cached).size} bytes`);\n return cached;\n }\n let bytes: Uint8Array;\n try {\n bytes = await (options.fetch ?? defaultFetch)(entry.url);\n } catch (error) {\n throw new BehaviorPackageError(\n `ORB_SIDECAR_FETCH_FAILED: ${pkg.name}@${pkg.version} ${relPath} (sha256 ${entry.sha256}) from ${urlHost(entry.url)} — ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n const actual = createHash('sha256').update(bytes).digest('hex');\n if (actual !== entry.sha256 || bytes.byteLength !== entry.bytes) {\n throw hashMismatch(pkg, relPath, entry, `downloaded ${bytes.byteLength} bytes with sha256 ${actual}`);\n }\n mkdirSync(cacheDir, { recursive: true });\n const temp = `${cached}.${process.pid}.tmp`;\n writeFileSync(temp, bytes);\n renameSync(temp, cached);\n return cached;\n}\n\n/** Async resolution of a declared path: a lock-declared path is downloaded and verified into the cache on a miss. */\nexport async function ensureDeclaredPath(pkg: BehaviorPackage, relPath: string, options: SidecarOptions = {}): Promise<string> {\n const entry = pkg.lock?.files[relPath];\n if (!entry) return packageFile(pkg, relPath, 'declared path');\n return ensureLockEntry(pkg, relPath, entry, options);\n}\n\n/** The user store (`~/.orb`): the last rung of discovery, after every ancestor `node_modules`. */\nexport function userStoreDir(): string {\n return join(homedir(), '.orb');\n}\n\n/** The `orb` fields only a behavior package declares (`@almadar/core`'s language block is not one). */\nconst BEHAVIOR_BLOCK_FIELDS = ['prefix', 'registry', 'source'];\n\nfunction packageDirs(nodeModules: string): string[] {\n if (!existsSync(nodeModules)) return [];\n const out: Array<[string, string]> = [];\n for (const entry of readdirSync(nodeModules)) {\n const path = join(nodeModules, entry);\n if (entry.startsWith('@')) {\n if (!existsSync(path) || !statSync(path).isDirectory()) continue;\n for (const sub of readdirSync(path)) out.push([`${entry}/${sub}`, join(path, sub)]);\n } else {\n out.push([entry, path]);\n }\n }\n return out.sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0)).map(([, path]) => path);\n}\n\nfunction isBehaviorManifest(manifestPath: string): boolean {\n const manifest = JSON.parse(readFileSync(manifestPath, 'utf8')) as { orb?: Record<string, object> | null };\n const orb = manifest.orb;\n return orb !== undefined && orb !== null && typeof orb === 'object' && BEHAVIOR_BLOCK_FIELDS.some((field) => field in orb);\n}\n\n/**\n * Every installed package directory, the node-style rule `orb` uses\n * (`orbital-core` `behavior_packages`): each ancestor `node_modules` of\n * `startDir`, nearest first, then the user store's; scoped and unscoped; only\n * directories holding a `package.json`. Real paths; a package name may repeat\n * across rungs (callers keep the nearest).\n */\nexport function installedPackageDirs(startDir: string, userStore: string = userStoreDir()): string[] {\n const rungs: string[] = [];\n for (let dir = resolve(startDir); ; dir = dirname(dir)) {\n rungs.push(join(dir, 'node_modules'));\n if (dirname(dir) === dir) break;\n }\n rungs.push(join(userStore, 'node_modules'));\n const out: string[] = [];\n for (const nodeModules of rungs) {\n for (const dir of packageDirs(nodeModules)) {\n if (!existsSync(join(dir, 'package.json')) || !statSync(dir).isDirectory()) continue;\n out.push(realpathSync(dir));\n }\n }\n return out;\n}\n\n/**\n * Every installed behavior package, the same rule as `orb`\n * (`orbital-core` `behavior_packages::discover`): every package\n * ({@link installedPackageDirs}) whose `package.json` carries a behavior `orb`\n * block; nearest wins per name; two packages claiming one prefix is an error.\n */\nexport function discoverBehaviorPackages(startDir: string, userStore: string = userStoreDir()): BehaviorPackage[] {\n const found: BehaviorPackage[] = [];\n const seen = new Set<string>();\n for (const dir of installedPackageDirs(startDir, userStore)) {\n if (!isBehaviorManifest(join(dir, 'package.json'))) continue;\n const pkg = readBehaviorPackage(dir);\n if (seen.has(pkg.name)) continue;\n seen.add(pkg.name);\n found.push(pkg);\n }\n const byPrefix = new Map<string, BehaviorPackage>();\n for (const pkg of found) {\n const other = byPrefix.get(pkg.orb.prefix);\n if (other && other.name !== pkg.name) {\n throw new BehaviorPackageError(`prefix \\`${pkg.orb.prefix}\\` is claimed by ${other.name} (${other.root}) and ${pkg.name} (${pkg.root})`);\n }\n byPrefix.set(pkg.orb.prefix, pkg);\n }\n return found;\n}\n\n/** Resolve an installed behavior package by name, node-style, from `fromDir`. */\nexport function findInstalledBehaviorPackage(name: string, fromDir: string): BehaviorPackage {\n const req = createRequire(join(resolve(fromDir), 'noop.js'));\n return readBehaviorPackage(dirname(req.resolve(`${name}/package.json`)));\n}\n\n/** The absolute path of a file (or the registry directory) the package declares. Fails when it is missing. */\nexport function resolveDeclaredFile(pkg: BehaviorPackage, key: DeclaredFileKey, options: SidecarOptions = {}): string {\n const declared = pkg.orb[key];\n if (declared === undefined) {\n throw new BehaviorPackageError(`${pkg.name}@${pkg.version}: orb.${key} is not declared`);\n }\n return resolveDeclaredPath(pkg, declared, options, `orb.${key}`);\n}\n\n/** The `bin` entry of an installed `@almadar/orb` manifest: a string, or a map whose first entry is the CLI. */\nconst OrbPackageManifest = z.object({ bin: z.union([z.string(), z.record(z.string(), z.string())]).optional() });\n\n/**\n * The `orb` binary, the one rule every TS host uses (G-CROSS-261; the editor's language server too, G-EXTENSIONS-004),\n * from exactly two explicit sources: `ORB_BIN` (a set path must exist: it is refused by name, never skipped), else the\n * binary the `@almadar/orb` installed for `from` declares. Nothing on PATH, in `~/bin` or elsewhere is consulted.\n */\nexport function resolveOrbBinary(from: string = process.cwd()): string {\n const configured = process.env['ORB_BIN'];\n if (configured) {\n if (!existsSync(configured)) throw new BehaviorPackageError(`ORB_BIN is set to ${configured}, which does not exist`);\n return configured;\n }\n const installed = installedOrbBin(from);\n if (installed !== undefined) return installed;\n throw new BehaviorPackageError('no `orb` binary: set ORB_BIN or install @almadar/orb');\n}\n\n/** The CLI the nearest `node_modules/@almadar/orb` walking up from `from` declares in its manifest `bin`. */\nfunction installedOrbBin(from: string): string | undefined {\n for (let dir = resolve(from); ; dir = dirname(dir)) {\n const manifestPath = join(dir, 'node_modules', '@almadar', 'orb', 'package.json');\n if (existsSync(manifestPath)) {\n const parsed = OrbPackageManifest.safeParse(JSON.parse(readFileSync(manifestPath, 'utf8')));\n const bin = !parsed.success || parsed.data.bin === undefined ? undefined : typeof parsed.data.bin === 'string' ? parsed.data.bin : Object.values(parsed.data.bin)[0];\n const path = bin === undefined ? undefined : resolve(dirname(manifestPath), bin);\n return path !== undefined && existsSync(path) ? path : undefined;\n }\n if (dirname(dir) === dir) return undefined;\n }\n}\n\n/** Default: `ALMADAR_DERIVED_CACHE`, else `~/.almadar/derived`. */\nexport function derivedCacheDir(): string {\n return process.env['ALMADAR_DERIVED_CACHE'] || join(homedir(), '.almadar', 'derived');\n}\n\nexport interface RegistryDirOptions {\n orbBin?: string;\n cacheDir?: string;\n /** How many files one `orb lower` run takes. */\n batch?: number;\n}\n\nconst fileHashes = new Map<string, string>();\n\n/** sha256 of a file's bytes, memoized by path, size and mtime. */\nfunction fileHash(path: string): string {\n const stat = statSync(path);\n const memo = `${path}\\0${stat.size}\\0${stat.mtimeMs}`;\n const known = fileHashes.get(memo);\n if (known) return known;\n const hash = createHash('sha256').update(readFileSync(path)).digest('hex');\n fileHashes.set(memo, hash);\n return hash;\n}\n\n/**\n * What a lowering depends on besides the source: the `orb` binary's bytes (a\n * rebuilt binary keeps its version string) and the language data files the\n * `@almadar/core` that `orb` resolves from `pkgRoot` declares (`orbLanguage`,\n * same walk as `orb`: ancestor `node_modules`, then the user store).\n */\nfunction lowererKey(orbBin: string, pkgRoot: string): string {\n const hash = createHash('sha256').update(fileHash(orbBin));\n const rungs: string[] = [];\n for (let dir = resolve(pkgRoot); ; dir = dirname(dir)) {\n rungs.push(join(dir, 'node_modules'));\n if (dirname(dir) === dir) break;\n }\n rungs.push(join(userStoreDir(), 'node_modules'));\n const coreRoot = rungs.map((nm) => join(nm, '@almadar', 'core')).find((dir) => existsSync(join(dir, 'package.json')));\n if (!coreRoot) return hash.update('\\0no-core').digest('hex');\n const manifest = JSON.parse(readFileSync(join(coreRoot, 'package.json'), 'utf8')) as { orbLanguage?: Record<string, string> };\n for (const [field, rel] of Object.entries(manifest.orbLanguage ?? {}).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))) {\n const path = join(coreRoot, rel);\n if (field === 'compiler' || !existsSync(path) || !statSync(path).isFile()) continue;\n hash.update(`\\0${field}\\0${fileHash(path)}`);\n }\n return hash.digest('hex');\n}\n\nfunction filesWithExtension(dir: string, extension: string): string[] {\n if (!existsSync(dir)) return [];\n const out: string[] = [];\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n const path = join(dir, entry.name);\n if (entry.isDirectory()) out.push(...filesWithExtension(path, extension));\n else if (entry.name.endsWith(extension)) out.push(path);\n }\n return out.sort();\n}\n\n/** A source file's path in the mirror: a `.lolo` becomes its lowered `.orb`; a message catalog keeps its path. */\nfunction mirrorPath(rel: string): string {\n return rel.replace(/\\.lolo$/, '.orb');\n}\n\ninterface SourceStamp {\n sha256: string;\n mtimeMs: number;\n size: number;\n}\n\ninterface LoweredLine {\n path: string;\n orb?: object;\n error?: string;\n}\n\n/** Where a live package's mirror lives: keyed by its root and what lowers it ({@link lowererKey}). */\nfunction mirrorDir(pkg: BehaviorPackage, orbBin: string, cacheDir: string | undefined): string {\n const key = createHash('sha256').update(`${resolve(pkg.root)}\\0${lowererKey(orbBin, pkg.root)}`).digest('hex').slice(0, 32);\n return join(cacheDir ?? derivedCacheDir(), 'registry', key);\n}\n\n/**\n * Delete every live-package mirror under the derived cache except those of\n * `keep` (as the current `orb` keys them) — a new `orb` binary, new language data or a moved\n * checkout leaves the old ones behind. Returns the removed directories.\n * Explicit only: other checkouts share the cache, so nothing prunes on its own.\n */\nexport function pruneRegistryMirrors(keep: readonly BehaviorPackage[], options: RegistryDirOptions = {}): string[] {\n const orbBin = options.orbBin ?? resolveOrbBinary();\n const kept = new Set(keep.filter((pkg) => pkg.orb.registry === undefined).map((pkg) => mirrorDir(pkg, orbBin, options.cacheDir)));\n const root = join(options.cacheDir ?? derivedCacheDir(), 'registry');\n if (!existsSync(root)) return [];\n const removed: string[] = [];\n for (const entry of readdirSync(root, { withFileTypes: true })) {\n const dir = join(root, entry.name);\n if (!entry.isDirectory() || kept.has(dir)) continue;\n rmSync(dir, { recursive: true, force: true });\n removed.push(dir);\n }\n return removed.sort();\n}\n\n/**\n * The directory of lowered `.orb` programs for `pkg`. A declared `orb.registry`\n * (a published package) is that directory. A live package (`orb.source`, no\n * `registry`) gets a content-addressed mirror under `derivedCacheDir()`, keyed by\n * the package root, the `orb` binary and the installed language data: each `.lolo` whose content hash changed\n * since the last call is re-lowered with `orb lower`, a removed one is pruned, and\n * an unchanged one is never touched; each behavior's `locales/<locale>/<name>.json`\n * catalog is copied beside its program. Same tree layout as a materialized registry,\n * so every reader of `.orb` files works unchanged. A lowering error fails the call,\n * naming the file.\n */\n/**\n * The files a package authors its behaviors in, without lowering anything: a\n * live package's `.lolo` source tree, or a published package's declared registry\n * of `.orb` programs. For tools that read behavior text (a class scanner, a\n * file watcher); a reader of lowered programs uses {@link behaviorRegistryDir}.\n */\nexport function behaviorSourceTree(pkg: BehaviorPackage): { dir: string; extension: '.lolo' | '.orb' } {\n if (pkg.orb.registry !== undefined) {\n return { dir: resolveDeclaredPath(pkg, pkg.orb.registry, {}, 'orb.registry'), extension: '.orb' };\n }\n if (pkg.orb.source === undefined) throw new BehaviorPackageError(`${pkg.name}: declares neither \\`orb.registry\\` nor \\`orb.source\\``);\n return { dir: packageFile(pkg, pkg.orb.source, 'orb.source'), extension: '.lolo' };\n}\n\nexport function behaviorRegistryDir(pkg: BehaviorPackage, options: RegistryDirOptions = {}): string {\n if (pkg.orb.registry !== undefined) return resolveDeclaredPath(pkg, pkg.orb.registry, {}, 'orb.registry');\n const sourceRel = pkg.orb.source;\n if (sourceRel === undefined) throw new BehaviorPackageError(`${pkg.name}: declares neither \\`orb.registry\\` nor \\`orb.source\\``);\n const source = packageFile(pkg, sourceRel, 'orb.source');\n const orbBin = options.orbBin ?? resolveOrbBinary();\n const out = mirrorDir(pkg, orbBin, options.cacheDir);\n const hashesPath = join(out, '.hashes.json');\n const previous: Record<string, SourceStamp> = existsSync(hashesPath) ? (JSON.parse(readFileSync(hashesPath, 'utf8')) as Record<string, SourceStamp>) : {};\n const current: Record<string, SourceStamp> = {};\n const stale: string[] = [];\n const staleCatalogs: string[] = [];\n const catalogs = filesWithExtension(source, '.json').filter((file) => relative(source, file).split(sep).includes('locales'));\n for (const file of [...filesWithExtension(source, '.lolo'), ...catalogs]) {\n const rel = relative(source, file);\n const { mtimeMs, size } = statSync(file);\n const before = previous[rel];\n // Hash only a file whose stat moved: an unchanged tree costs one stat per file.\n const sha256 =\n before && before.mtimeMs === mtimeMs && before.size === size ? before.sha256 : createHash('sha256').update(readFileSync(file)).digest('hex');\n current[rel] = { sha256, mtimeMs, size };\n if (before?.sha256 === sha256 && existsSync(join(out, mirrorPath(rel)))) continue;\n if (rel.endsWith('.lolo')) stale.push(file);\n else staleCatalogs.push(file);\n }\n const batch = options.batch ?? 200;\n for (let i = 0; i < stale.length; i += batch) {\n const files = stale.slice(i, i + batch);\n const run = nodeChildProcess.spawnSync(orbBin, ['lower', ...files], { cwd: pkg.root, encoding: 'utf8', maxBuffer: 1024 * 1024 * 1024 });\n if (run.status !== 0) throw new BehaviorPackageError(`${pkg.name}: \\`orb lower\\` failed: ${run.stderr}`);\n for (const line of run.stdout.split('\\n').filter((l) => l.trim() !== '')) {\n const lowered = JSON.parse(line) as LoweredLine;\n if (lowered.error !== undefined || lowered.orb === undefined) {\n throw new BehaviorPackageError(`${pkg.name}: ${lowered.path} does not lower: ${lowered.error ?? 'no program'}`);\n }\n const target = join(out, mirrorPath(relative(source, lowered.path)));\n mkdirSync(dirname(target), { recursive: true });\n const temp = `${target}.${process.pid}.tmp`;\n writeFileSync(temp, JSON.stringify(lowered.orb));\n renameSync(temp, target);\n }\n }\n for (const file of staleCatalogs) {\n const target = join(out, relative(source, file));\n mkdirSync(dirname(target), { recursive: true });\n copyFileSync(file, target);\n }\n for (const rel of Object.keys(previous)) {\n if (!(rel in current)) rmSync(join(out, mirrorPath(rel)), { force: true });\n }\n mkdirSync(out, { recursive: true });\n const stamps = JSON.stringify(current);\n if (stale.length > 0 || staleCatalogs.length > 0 || stamps !== JSON.stringify(previous)) writeFileSync(hashesPath, stamps);\n return out;\n}\n\n/**\n * Every behavior program in the package's registry, by behavior name: each `.orb` under the\n * registry tree, named by its basename (the rule `orb` indexes by). Two programs with one name\n * are refused.\n */\nexport function behaviorProgramFiles(pkg: BehaviorPackage, options: RegistryDirOptions = {}): Map<string, string> {\n const root = behaviorRegistryDir(pkg, options);\n const files = new Map<string, string>();\n const walk = (dir: string): void => {\n for (const entry of nodeFs.readdirSync(dir, { withFileTypes: true })) {\n const full = nodePath.join(dir, entry.name);\n if (entry.isDirectory()) walk(full);\n else if (entry.isFile() && entry.name.endsWith('.orb')) {\n const name = entry.name.slice(0, -'.orb'.length);\n const seen = files.get(name);\n if (seen !== undefined) {\n throw new BehaviorPackageError(`${pkg.name}: two programs named \"${name}\": ${nodePath.relative(root, seen)} and ${nodePath.relative(root, full)}`);\n }\n files.set(name, full);\n }\n }\n };\n walk(root);\n return files;\n}\n\nexport interface MaterializeOptions extends RegistryDirOptions {\n /** Package-relative directory the programs are written into. Default `behaviors/registry`. */\n target?: string;\n}\n\nfunction treeFiles(dir: string): string[] {\n if (!existsSync(dir)) return [];\n const out: string[] = [];\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n if (entry.name.startsWith('.')) continue;\n const path = join(dir, entry.name);\n if (entry.isDirectory()) out.push(...treeFiles(path));\n else out.push(path);\n }\n return out.sort();\n}\n\n/**\n * Publish-time materialization of a live package (`orb.source`, no\n * `orb.registry`): copies its lowered programs and their catalogs from\n * {@link behaviorRegistryDir} into `target` inside the package, re-emits each\n * program that declares `locales` through `orb emit orb --output` so its merged\n * `<stem>.<locale>.json` catalogs ship beside it, and returns the `orb` block the\n * published manifest declares (`registry` set, `source` kept). Files already in\n * `target` that are not programs are\n * left alone.\n */\nexport function materializeRegistry(pkg: BehaviorPackage, options: MaterializeOptions = {}): BehaviorPackageOrbBlock {\n if (pkg.orb.registry !== undefined) {\n throw new BehaviorPackageError(`${pkg.name}: already declares \\`orb.registry\\` (${pkg.orb.registry}) — only a live package is materialized`);\n }\n const sourceRel = pkg.orb.source;\n if (sourceRel === undefined) throw new BehaviorPackageError(`${pkg.name}: declares no \\`orb.source\\``);\n const orbBin = options.orbBin ?? resolveOrbBinary();\n const mirror = behaviorRegistryDir(pkg, { ...options, orbBin });\n const targetRel = options.target ?? 'behaviors/registry';\n const target = join(pkg.root, targetRel);\n const source = packageFile(pkg, sourceRel, 'orb.source');\n for (const file of treeFiles(mirror)) {\n const rel = relative(mirror, file);\n const dest = join(target, rel);\n mkdirSync(dirname(dest), { recursive: true });\n copyFileSync(file, dest);\n if (!rel.endsWith('.orb')) continue;\n const program = JSON.parse(readFileSync(file, 'utf8')) as { locales?: string[] };\n if (program.locales === undefined || program.locales.length === 0) continue;\n const lolo = join(source, rel.replace(/\\.orb$/, '.lolo'));\n const run = nodeChildProcess.spawnSync(orbBin, ['emit', 'orb', lolo, '--output', dest], { cwd: pkg.root, encoding: 'utf8', maxBuffer: 1024 * 1024 * 1024 });\n if (run.status !== 0) throw new BehaviorPackageError(`${pkg.name}: \\`orb emit orb ${rel}\\` failed: ${run.stderr}`);\n }\n return { ...pkg.orb, registry: targetRel };\n}\n"]}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { O as OrbitalEntity } from './effect-CiEVLsZz.js';
|
|
2
|
-
import { O as OrbitalDefinition } from './orbital-CkFdDS9f.js';
|
|
3
|
-
import { O as OrbitalSchema } from './schema-T5RT5s6H.js';
|
|
4
|
-
import { S as SExpr } from './expression-D0Fs0riG.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Entity access policies — the declared `@read`/`@create`/`@update`/`@delete`
|
|
8
|
-
* directives, keyed by entity name.
|
|
9
|
-
*
|
|
10
|
-
* The JS mirror of `orbital-core/src/runtime/entity_access.rs`'s
|
|
11
|
-
* `EntityAccessPolicies`/`EntityAccessTable`. Both paths must agree: a
|
|
12
|
-
* directive is a per-row predicate (`@entity` = the candidate row, or for
|
|
13
|
-
* `@create` the incoming data; `@user` = the viewer), enforced once for
|
|
14
|
-
* every trait that touches the entity — the un-bypassable twin of a
|
|
15
|
-
* call-site `filter:`, which sibling traits can skip simply by not
|
|
16
|
-
* declaring one.
|
|
17
|
-
*
|
|
18
|
-
* @packageDocumentation
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* One orbital's own inline entity definitions: its primary entity plus any
|
|
23
|
-
* auxiliaries an import brought along (`auxiliaryEntities` — a linkedEntity
|
|
24
|
-
* naming an imported atom's own entity resolves here, not among any
|
|
25
|
-
* orbital's primary entity alone). Skips unresolved `string`/`EntityCall`
|
|
26
|
-
* refs — those are pre-inline-phase forms that never reach this by the time
|
|
27
|
-
* a schema is served.
|
|
28
|
-
*/
|
|
29
|
-
declare function orbitalInlineEntities(orbital: OrbitalDefinition): OrbitalEntity[];
|
|
30
|
-
/** The orbital of `schema` that declares the entity `entityType` inline, when one does. */
|
|
31
|
-
declare function entityOwnerOrbital(schema: OrbitalSchema, entityType: string): OrbitalDefinition | undefined;
|
|
32
|
-
/** An entity's four declared directives. Any may be absent — an absent
|
|
33
|
-
* directive means "no restriction" for that operation, exactly like an
|
|
34
|
-
* absent fetch `filter:`. */
|
|
35
|
-
interface EntityAccessPolicies {
|
|
36
|
-
read?: SExpr;
|
|
37
|
-
create?: SExpr;
|
|
38
|
-
update?: SExpr;
|
|
39
|
-
delete?: SExpr;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Every entity's access policies, keyed by entity name.
|
|
43
|
-
*
|
|
44
|
-
* A policy governs the **collection**, not the declaration. A `persistent:`
|
|
45
|
-
* collection is one table, and two entity declarations over one table cannot
|
|
46
|
-
* honestly carry different visibility rules. Keying by entity name alone let an
|
|
47
|
-
* organism declare `@read` on its own entity and still ship an ALLOW-ALL list
|
|
48
|
-
* wherever a page rendered through a std-atom trait that fetched the ATOM's
|
|
49
|
-
* entity on the same collection — measured on `std-customer-success`, where
|
|
50
|
-
* `/health-scores` returned 6 rows for every persona while the organism's own
|
|
51
|
-
* `/cs-accounts` correctly returned 3 vs 6. 36 of 54 app organisms share a
|
|
52
|
-
* collection this way (`R-SHADOW-ENTITY-SHARES-COLLECTION-DIRECTIVES-DONT-APPLY`).
|
|
53
|
-
*
|
|
54
|
-
* So an entity that declares nothing adopts the policy declared on its
|
|
55
|
-
* collection. This can only ever ADD a restriction: an entity with its own
|
|
56
|
-
* directives keeps exactly those, and an entity whose collection carries no
|
|
57
|
-
* declared policy is untouched. Conflicting declarations on one collection are
|
|
58
|
-
* rejected at validate time by `ORB_S_COLLECTION_POLICY_CONFLICT`.
|
|
59
|
-
*
|
|
60
|
-
* Mirrors `resolve_collection_inheritance` in
|
|
61
|
-
* `orbital-rust/crates/orbital-core/src/runtime/entity_access.rs`.
|
|
62
|
-
*/
|
|
63
|
-
declare function entityAccessTable(schema: OrbitalSchema): Map<string, EntityAccessPolicies>;
|
|
64
|
-
/** One entity's access policies, or `undefined` when it declares none. */
|
|
65
|
-
declare function entityAccessPolicies(schema: OrbitalSchema, entityName: string): EntityAccessPolicies | undefined;
|
|
66
|
-
/**
|
|
67
|
-
* Access policies keyed the way the mock store keys its tables: the declared
|
|
68
|
-
* `persistent:` collection, else the lowercased entity name. The mock
|
|
69
|
-
* adapter's owner-restamp consults this map to decide whether a persona the
|
|
70
|
-
* dev host switches to could have CREATED a row before re-pointing its owner
|
|
71
|
-
* column — a reader persona must not inherit authorship of a draft just
|
|
72
|
-
* because the demo store follows the viewer (the `@create` directive is the
|
|
73
|
-
* single authority on who authors; no role heuristics here). First declared
|
|
74
|
-
* policy per collection wins, the same collection-inheritance rule as
|
|
75
|
-
* `entityAccessTable`.
|
|
76
|
-
*/
|
|
77
|
-
declare function entityAccessPoliciesByStoreKey(schema: OrbitalSchema): Map<string, EntityAccessPolicies>;
|
|
78
|
-
|
|
79
|
-
export { entityAccessPoliciesByStoreKey as a, entityAccessTable as b, entityOwnerOrbital as c, entityAccessPolicies as e, orbitalInlineEntities as o };
|
|
80
|
-
export type { EntityAccessPolicies as E };
|
package/dist/mock/index.d.ts
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { OrbitalEntity } from '../index.js';
|
|
2
|
-
import { OrbitalDefinition } from '../index.js';
|
|
3
|
-
import { OrbitalSchema } from '../index.js';
|
|
4
|
-
import { SExpr } from '../index.js';
|
|
5
|
-
export { E as EntityAccessPolicies, e as entityAccessPolicies, a as entityAccessPoliciesByStoreKey, b as entityAccessTable } from '../entityAccess-BPSz1i2n.js';
|
|
6
|
-
import 'zod';
|
|
7
|
-
import '../domain-Dz3jP-UM.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Owner columns derived from a program's `[identity]` entity.
|
|
11
|
-
*
|
|
12
|
-
* The JS mirror of `orbital-core/src/runtime/seed.rs`
|
|
13
|
-
* (`identity_entity_name` / `owner_fields_from_schema`). Both paths must agree:
|
|
14
|
-
* a column is an owner column because the source *declared* it as a relation to
|
|
15
|
-
* the `[identity]` entity (`patientId : Person`), never because its name looks
|
|
16
|
-
* like one — a name-matching guess would silently scope the wrong column.
|
|
17
|
-
*
|
|
18
|
-
* @packageDocumentation
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* The `[identity]` entities that decide what `@user` resolves to, primaries
|
|
23
|
-
* first then auxiliaries.
|
|
24
|
-
*
|
|
25
|
-
* A behavior declares its own roster so it runs standalone. Composing it never
|
|
26
|
-
* imports that orbital, but a trait bound to one of its siblings drags the
|
|
27
|
-
* roster in as an auxiliary copy, tag and all — so a PRIMARY roster shadows
|
|
28
|
-
* every imported copy: the composing app decides who `@user` is. With no
|
|
29
|
-
* primary roster the copies still count, which is what lets a thin app that
|
|
30
|
-
* wraps one behavior inherit that behavior's roster.
|
|
31
|
-
*
|
|
32
|
-
* Compiled-path twin: `identity_entities` in
|
|
33
|
-
* `orbital-compiler/src/phases/validation/identity/user_identity.rs` (L94-102).
|
|
34
|
-
*/
|
|
35
|
-
declare function identityEntitiesOf(orbitals: readonly OrbitalDefinition[]): OrbitalEntity[];
|
|
36
|
-
/**
|
|
37
|
-
* The name of the schema's `[identity]` entity, if it declares one.
|
|
38
|
-
*
|
|
39
|
-
* Compiled-path twin: `identity_entities` in
|
|
40
|
-
* `orbital-compiler/src/phases/validation/identity/user_identity.rs`.
|
|
41
|
-
*/
|
|
42
|
-
declare function identityEntityName(schema: OrbitalSchema): string | undefined;
|
|
43
|
-
/**
|
|
44
|
-
* Every `[identity]`-tagged name, shadowed copies included.
|
|
45
|
-
*
|
|
46
|
-
* Owner-column derivation asks whether a relation targets *a* roster, not *the*
|
|
47
|
-
* one: `Timesheet.employeeId : Employee` is an owner column whether or not
|
|
48
|
-
* `Employee` won the `@user` binding. Dropping the shadowed names here would
|
|
49
|
-
* leave an imported behavior's rows unscoped at runtime while the compiled path
|
|
50
|
-
* treats the very same column as an owner column.
|
|
51
|
-
*
|
|
52
|
-
* Compiled-path twin: `identity_entity_names` in
|
|
53
|
-
* `orbital-compiler/src/phases/validation/identity/user_identity.rs`.
|
|
54
|
-
*/
|
|
55
|
-
declare function identityEntityNames(schema: OrbitalSchema): string[];
|
|
56
|
-
/**
|
|
57
|
-
* The declared vocabulary for an identity field, following `items` for the
|
|
58
|
-
* array/map form. `roles : ["a" | "b"]` keeps the union on the ELEMENT, so a
|
|
59
|
-
* multi-valued role field is read through `items` — one level, not recursive.
|
|
60
|
-
*
|
|
61
|
-
* Compiled-path twin: `vocabulary` in
|
|
62
|
-
* `orbital-compiler/src/phases/validation/identity/user_identity.rs` (L125-134).
|
|
63
|
-
*/
|
|
64
|
-
declare function roleVocabularyOf(entity: OrbitalEntity, field?: string): readonly string[] | undefined;
|
|
65
|
-
/**
|
|
66
|
-
* Every column `expr` compares to `@user.id` via direct equality — the
|
|
67
|
-
* general form of "self-identity": `@entity.<field> == @user.id` (either
|
|
68
|
-
* operand order, either spelling — see `fieldRefName`) names `field` as an
|
|
69
|
-
* owner column, whether `field` is the row's OWN `id` (distinct from a
|
|
70
|
-
* relation column like `@entity.managerId == @user.id`) or any other
|
|
71
|
-
* declared field (the shape `ORB_S_OWNER_FIELD_NOT_IDENTITY_TYPED` flags as
|
|
72
|
-
* an authoring error when it is neither — codegen still needs to seed it).
|
|
73
|
-
* Recurses through `and`/`or`/`not`/any other combinator —
|
|
74
|
-
* `std-time-tracking`'s `Employee [identity]` declares
|
|
75
|
-
* `@read (or (= @user.role "approver") (= (object/get @entity id) @user.id))`,
|
|
76
|
-
* and the self-access arm counts even though it isn't the whole policy.
|
|
77
|
-
* Rust twin: `owner_columns_from_policy` in `orbital-core/src/runtime/seed.rs`.
|
|
78
|
-
*/
|
|
79
|
-
declare function ownerColumnsFromPolicy(expr: SExpr, out?: string[]): string[];
|
|
80
|
-
/**
|
|
81
|
-
* Owner columns as `Entity.field` pairs — every NON-INTRINSIC relation field
|
|
82
|
-
* pointing at an `[identity]`-tagged entity, shadowed imported rosters
|
|
83
|
-
* included, PLUS `Entity.id` for an `[identity]` entity whose own declared
|
|
84
|
-
* access policy compares its row directly to the viewer (self-identity), PLUS
|
|
85
|
-
* any other column an entity's own declared `@read`/`@update`/`@delete`
|
|
86
|
-
* compares to `@user.id` (see `ownerColumnsFromPolicy`). Empty when the
|
|
87
|
-
* program declares no identity, which keeps every unmigrated app behaving
|
|
88
|
-
* exactly as before.
|
|
89
|
-
*
|
|
90
|
-
* An `intrinsic: true` relation field is excluded even when it targets the
|
|
91
|
-
* identity entity: intrinsic marks framework plumbing the owning trait
|
|
92
|
-
* computes itself (`EntityField.intrinsic` doc, `types/field.ts`), never
|
|
93
|
-
* domain ownership — a generic atom's self-relation (`ModalRecord.seedRow :
|
|
94
|
-
* ModalRecord`, record-detail/modal edit-seed plumbing) gets its relation
|
|
95
|
-
* target rewritten onto whatever entity the trait binds, so a self-identity
|
|
96
|
-
* entity like `std-time-tracking`'s `Employee [identity]` ends up with an
|
|
97
|
-
* `Employee.seedRow : Employee` self-relation that is structurally
|
|
98
|
-
* indistinguishable from a real owner column by type/target alone. Stamping
|
|
99
|
-
* it with the viewer id (as an owner column would be) creates a row that
|
|
100
|
-
* references itself, which trips the entity's own `onDelete: restrict`.
|
|
101
|
-
*/
|
|
102
|
-
declare function ownerFieldsFromSchema(schema: OrbitalSchema): string[];
|
|
103
|
-
/**
|
|
104
|
-
* Every literal an expression compares against `@user.<field>` (any field),
|
|
105
|
-
* keyed by field name — the collecting counterpart of `orbital-compiler`'s
|
|
106
|
-
* `validation::user_identity::check_comparison` (B4-R4; the two must stay
|
|
107
|
-
* shape-identical, each cites the other): an equality node (`EQUALITY_OPS`)
|
|
108
|
-
* or an `array/includes` node, walked transparently through `and`/`or`/`not`
|
|
109
|
-
* and any other combinator (the Rust check runs on EVERY array node
|
|
110
|
-
* regardless of what wraps it, so this does too).
|
|
111
|
-
*
|
|
112
|
-
* `array/includes` is directional, but the sigil can sit on EITHER side:
|
|
113
|
-
* `(array/includes @user.roles "ghost")` checks a literal against a
|
|
114
|
-
* multi-valued field's own vocabulary (field is the haystack, position 0);
|
|
115
|
-
* the Stage-B orbital-import role rewrite (Rust `inline/rewrite.rs`
|
|
116
|
-
* `rewrite_role_literals`, which `check_comparison` mirrors) instead
|
|
117
|
-
* produces `(array/includes ["owner","project_manager"] @user.role)` — a
|
|
118
|
-
* literal ARRAY haystack with the sigil as the needle, position 1 (found
|
|
119
|
-
* live: Project Friday's imported `Timesheet.@delete` after `roles {
|
|
120
|
-
* approver: [owner, project_manager] }`). So the sigil is located BY
|
|
121
|
-
* CONTENT, never position: check position 0 first, fall back to position 1.
|
|
122
|
-
* The OTHER side is then flattened to a literal list — a scalar (equality,
|
|
123
|
-
* or an `array/includes` whose haystack is the sigil's own multi-valued
|
|
124
|
-
* field) or, for the role-rewrite shape, every string element of a literal
|
|
125
|
-
* array.
|
|
126
|
-
*
|
|
127
|
-
* A collected literal is a CANDIDATE a viewer might satisfy the expression
|
|
128
|
-
* with, never a proof: a policy that ANDs the field check with an unrelated
|
|
129
|
-
* condition can still reject a viewer carrying it. Callers that need
|
|
130
|
-
* certainty re-check with the real evaluator (`checkMutationAccess` /
|
|
131
|
-
* `evaluate`), the way any other synthesized dispatch is confirmed.
|
|
132
|
-
*/
|
|
133
|
-
declare function collectUserFieldLiterals(expr: SExpr, out?: Map<string, Set<string>>): Map<string, Set<string>>;
|
|
134
|
-
/**
|
|
135
|
-
* A `@user.<field>` value that satisfies `policy`, chosen from the identity
|
|
136
|
-
* entity's own declared vocabulary — never a guess: only a literal BOTH
|
|
137
|
-
* (a) compared against `field` in an equality/`array/includes` node
|
|
138
|
-
* somewhere in `policy` (see {@link collectUserFieldLiterals}) AND (b) a
|
|
139
|
-
* declared member of `identity`'s `field` vocabulary (see
|
|
140
|
-
* {@link roleVocabularyOf}) is a candidate. The pick is deterministic — the
|
|
141
|
-
* first vocabulary value, in declaration order, that is also a candidate —
|
|
142
|
-
* so two callers asking about the same policy always agree.
|
|
143
|
-
*
|
|
144
|
-
* `undefined` when `policy` is absent/`null` (no restriction — nothing to
|
|
145
|
-
* satisfy), `field` carries no declared vocabulary on `identity`, or no
|
|
146
|
-
* declared value appears anywhere in the policy. The last case is a genuine
|
|
147
|
-
* finding for the CALLER to report, not a probe defect to paper over: the
|
|
148
|
-
* policy structurally cannot be satisfied by any roster member, so forcing a
|
|
149
|
-
* viewer past it would misreport an unreachable transition as reachable.
|
|
150
|
-
*/
|
|
151
|
-
declare function roleSatisfyingPolicy(policy: SExpr | undefined, identity: OrbitalEntity, field?: string): string | undefined;
|
|
152
|
-
|
|
153
|
-
export { collectUserFieldLiterals, identityEntitiesOf, identityEntityName, identityEntityNames, ownerColumnsFromPolicy, ownerFieldsFromSchema, roleSatisfyingPolicy, roleVocabularyOf };
|
package/dist/mock/index.js
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { entityAccessPolicies, orbitalInlineEntities } from '../chunk-V5VNGRVU.js';
|
|
2
|
-
export { entityAccessPolicies, entityAccessPoliciesByStoreKey, entityAccessTable } from '../chunk-V5VNGRVU.js';
|
|
3
|
-
|
|
4
|
-
// src/mock/identityOwners.ts
|
|
5
|
-
function inlineEntities(schema) {
|
|
6
|
-
return (schema.orbitals ?? []).flatMap(orbitalInlineEntities);
|
|
7
|
-
}
|
|
8
|
-
function identityEntitiesTaggedOf(orbitals) {
|
|
9
|
-
const out = [];
|
|
10
|
-
for (const orbital of orbitals) {
|
|
11
|
-
const ref = orbital.entity;
|
|
12
|
-
if (typeof ref === "object" && ref !== null && "fields" in ref && ref.identity === true) {
|
|
13
|
-
out.push({ def: ref, primary: true });
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
for (const orbital of orbitals) {
|
|
17
|
-
for (const ref of orbital.auxiliaryEntities ?? []) {
|
|
18
|
-
if (typeof ref === "object" && ref !== null && "fields" in ref && ref.identity === true) {
|
|
19
|
-
out.push({ def: ref, primary: false });
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return out;
|
|
24
|
-
}
|
|
25
|
-
function identityEntitiesOf(orbitals) {
|
|
26
|
-
const tagged = identityEntitiesTaggedOf(orbitals);
|
|
27
|
-
const hasPrimary = tagged.some((e) => e.primary);
|
|
28
|
-
return tagged.filter((e) => e.primary || !hasPrimary).map((e) => e.def);
|
|
29
|
-
}
|
|
30
|
-
function identityEntityName(schema) {
|
|
31
|
-
return identityEntitiesOf(schema.orbitals ?? [])[0]?.name;
|
|
32
|
-
}
|
|
33
|
-
function identityEntityNames(schema) {
|
|
34
|
-
const out = [];
|
|
35
|
-
for (const { def } of identityEntitiesTaggedOf(schema.orbitals ?? [])) {
|
|
36
|
-
if (!out.includes(def.name)) out.push(def.name);
|
|
37
|
-
}
|
|
38
|
-
return out;
|
|
39
|
-
}
|
|
40
|
-
function roleVocabularyOf(entity, field = "role") {
|
|
41
|
-
const def = entity.fields.find((f) => f.name === field);
|
|
42
|
-
if (!def) return void 0;
|
|
43
|
-
return fieldVocabulary(def);
|
|
44
|
-
}
|
|
45
|
-
function fieldVocabulary(field) {
|
|
46
|
-
if ("values" in field && field.values && field.values.length > 0) {
|
|
47
|
-
return field.values;
|
|
48
|
-
}
|
|
49
|
-
if ("items" in field && field.items && "values" in field.items && field.items.values && field.items.values.length > 0) {
|
|
50
|
-
return field.items.values;
|
|
51
|
-
}
|
|
52
|
-
return void 0;
|
|
53
|
-
}
|
|
54
|
-
function fieldRefName(x, binding) {
|
|
55
|
-
if (typeof x === "string" && x.startsWith(`${binding}.`)) return x.slice(binding.length + 1);
|
|
56
|
-
if (Array.isArray(x) && x.length === 3 && x[0] === "object/get" && x[1] === binding && typeof x[2] === "string") {
|
|
57
|
-
return x[2];
|
|
58
|
-
}
|
|
59
|
-
return void 0;
|
|
60
|
-
}
|
|
61
|
-
function isFieldRef(x, binding, field) {
|
|
62
|
-
return fieldRefName(x, binding) === field;
|
|
63
|
-
}
|
|
64
|
-
var OWNER_EQ_OPS = ["=", "=="];
|
|
65
|
-
function ownerColumnsFromPolicy(expr, out = []) {
|
|
66
|
-
if (Array.isArray(expr)) {
|
|
67
|
-
if (expr.length === 3) {
|
|
68
|
-
const [op, a, b] = expr;
|
|
69
|
-
if (typeof op === "string" && OWNER_EQ_OPS.includes(op)) {
|
|
70
|
-
const field = isFieldRef(b, "@user", "id") ? fieldRefName(a, "@entity") : isFieldRef(a, "@user", "id") ? fieldRefName(b, "@entity") : void 0;
|
|
71
|
-
if (field !== void 0 && !out.includes(field)) out.push(field);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
for (const item of expr) ownerColumnsFromPolicy(item, out);
|
|
75
|
-
}
|
|
76
|
-
return out;
|
|
77
|
-
}
|
|
78
|
-
function policiesSelfIdentify(policies) {
|
|
79
|
-
if (policies === void 0) return false;
|
|
80
|
-
return [policies.read, policies.create, policies.update, policies.delete].some(
|
|
81
|
-
(expr) => expr !== void 0 && ownerColumnsFromPolicy(expr).includes("id")
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
function ownerFieldsFromSchema(schema) {
|
|
85
|
-
const identities = identityEntityNames(schema);
|
|
86
|
-
if (identities.length === 0) return [];
|
|
87
|
-
const out = [];
|
|
88
|
-
const defs = inlineEntities(schema);
|
|
89
|
-
const declaredByCollection = /* @__PURE__ */ new Map();
|
|
90
|
-
for (const def of defs) {
|
|
91
|
-
for (const field of def.fields ?? []) {
|
|
92
|
-
if (field.name && field.type === "relation" && !field.intrinsic && identities.includes(field.relation.entity)) {
|
|
93
|
-
out.push(`${def.name}.${field.name}`);
|
|
94
|
-
if (def.collection) {
|
|
95
|
-
const cols = declaredByCollection.get(def.collection) ?? [];
|
|
96
|
-
if (!cols.includes(field.name)) cols.push(field.name);
|
|
97
|
-
declaredByCollection.set(def.collection, cols);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
for (const name of identities) {
|
|
103
|
-
if (policiesSelfIdentify(entityAccessPolicies(schema, name))) {
|
|
104
|
-
const key = `${name}.id`;
|
|
105
|
-
if (!out.includes(key)) out.push(key);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
for (const def of defs) {
|
|
109
|
-
const policies = entityAccessPolicies(schema, def.name);
|
|
110
|
-
if (policies === void 0) continue;
|
|
111
|
-
for (const policy of [policies.read, policies.update, policies.delete]) {
|
|
112
|
-
if (policy === void 0) continue;
|
|
113
|
-
for (const field of ownerColumnsFromPolicy(policy)) {
|
|
114
|
-
const key = `${def.name}.${field}`;
|
|
115
|
-
if (!out.includes(key)) out.push(key);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
for (const def of defs) {
|
|
120
|
-
const cols = def.collection ? declaredByCollection.get(def.collection) : void 0;
|
|
121
|
-
if (!cols) continue;
|
|
122
|
-
for (const col of cols) {
|
|
123
|
-
const key = `${def.name}.${col}`;
|
|
124
|
-
if (out.includes(key)) continue;
|
|
125
|
-
if ((def.fields ?? []).some((f) => f.name === col)) out.push(key);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return out;
|
|
129
|
-
}
|
|
130
|
-
var EQUALITY_OPS = ["=", "==", "!=", "!==", "eq", "neq"];
|
|
131
|
-
function isUserFieldSigil(x) {
|
|
132
|
-
return typeof x === "string" && fieldRefName(x, "@user") !== void 0;
|
|
133
|
-
}
|
|
134
|
-
function literalHaystackMembers(items) {
|
|
135
|
-
const isListCall = items[0] === "list";
|
|
136
|
-
const members = isListCall ? items.slice(1) : items;
|
|
137
|
-
return members.every((v) => typeof v === "string") ? [...members] : void 0;
|
|
138
|
-
}
|
|
139
|
-
function collectUserFieldLiterals(expr, out = /* @__PURE__ */ new Map()) {
|
|
140
|
-
if (Array.isArray(expr)) {
|
|
141
|
-
const [op, ...args] = expr;
|
|
142
|
-
if (typeof op === "string" && args.length >= 2 && (EQUALITY_OPS.includes(op) || op === "array/includes")) {
|
|
143
|
-
const isIncludes = op === "array/includes";
|
|
144
|
-
let sigilSide;
|
|
145
|
-
let literalSide;
|
|
146
|
-
if (isIncludes) {
|
|
147
|
-
if (isUserFieldSigil(args[0])) {
|
|
148
|
-
sigilSide = args.slice(0, 1);
|
|
149
|
-
literalSide = args.slice(1, 2);
|
|
150
|
-
} else {
|
|
151
|
-
sigilSide = args.slice(1, 2);
|
|
152
|
-
literalSide = args.slice(0, 1);
|
|
153
|
-
}
|
|
154
|
-
} else {
|
|
155
|
-
sigilSide = args;
|
|
156
|
-
literalSide = args;
|
|
157
|
-
}
|
|
158
|
-
const field = sigilSide.map((arg) => fieldRefName(arg, "@user")).find((f) => f !== void 0);
|
|
159
|
-
if (field !== void 0) {
|
|
160
|
-
const literalArrayHaystack = literalSide[0];
|
|
161
|
-
const literals = isIncludes && Array.isArray(literalArrayHaystack) ? literalHaystackMembers(literalArrayHaystack) ?? [] : literalSide;
|
|
162
|
-
for (const literal of literals) {
|
|
163
|
-
if (typeof literal === "string" && !literal.startsWith("@")) {
|
|
164
|
-
const set = out.get(field) ?? /* @__PURE__ */ new Set();
|
|
165
|
-
set.add(literal);
|
|
166
|
-
out.set(field, set);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
for (const item of expr) collectUserFieldLiterals(item, out);
|
|
172
|
-
return out;
|
|
173
|
-
}
|
|
174
|
-
if (expr !== null && typeof expr === "object") {
|
|
175
|
-
for (const value of Object.values(expr)) collectUserFieldLiterals(value, out);
|
|
176
|
-
}
|
|
177
|
-
return out;
|
|
178
|
-
}
|
|
179
|
-
function roleSatisfyingPolicy(policy, identity, field = "role") {
|
|
180
|
-
if (policy === void 0 || policy === null) return void 0;
|
|
181
|
-
const vocab = roleVocabularyOf(identity, field);
|
|
182
|
-
if (vocab === void 0) return void 0;
|
|
183
|
-
const accepted = collectUserFieldLiterals(policy).get(field);
|
|
184
|
-
if (accepted === void 0) return void 0;
|
|
185
|
-
return vocab.find((value) => accepted.has(value));
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export { collectUserFieldLiterals, identityEntitiesOf, identityEntityName, identityEntityNames, ownerColumnsFromPolicy, ownerFieldsFromSchema, roleSatisfyingPolicy, roleVocabularyOf };
|
|
189
|
-
//# sourceMappingURL=index.js.map
|
|
190
|
-
//# sourceMappingURL=index.js.map
|