@inf-monkeys-tech/monkeys 1.1.15 → 1.1.17

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.
Files changed (30) hide show
  1. package/README.md +6 -0
  2. package/lib/contracts/declarative-control-http.d.ts +340 -0
  3. package/lib/contracts/declarative-control-http.d.ts.map +1 -1
  4. package/lib/contracts/declarative-control.d.ts +42 -0
  5. package/lib/contracts/declarative-control.d.ts.map +1 -1
  6. package/lib/contracts/declarative-control.js +46 -2
  7. package/lib/contracts/declarative-control.js.map +1 -1
  8. package/lib/contracts/declarative-document-import.d.ts +50 -0
  9. package/lib/contracts/declarative-document-import.d.ts.map +1 -1
  10. package/lib/contracts/declarative-publication-job.d.ts +80 -0
  11. package/lib/contracts/declarative-publication-job.d.ts.map +1 -1
  12. package/lib/esm/contracts/index.mjs +37 -0
  13. package/lib/esm/contracts/index.mjs.map +1 -1
  14. package/lib/esm/index.mjs +42 -0
  15. package/lib/esm/index.mjs.map +1 -1
  16. package/lib/esm/runtime/index.mjs +41 -0
  17. package/lib/esm/runtime/index.mjs.map +1 -1
  18. package/lib/esm/schemas/index.mjs +36 -0
  19. package/lib/esm/schemas/index.mjs.map +1 -1
  20. package/lib/json-schema/page-runtime-bundle.schema.json +77 -0
  21. package/lib/json-schema/page.schema.json +77 -0
  22. package/lib/runtime/declarative-control-compiler.d.ts.map +1 -1
  23. package/lib/runtime/declarative-control-compiler.js +2 -0
  24. package/lib/runtime/declarative-control-compiler.js.map +1 -1
  25. package/lib/runtime/declarative-runtime-contract.d.ts.map +1 -1
  26. package/lib/runtime/declarative-runtime-contract.js +6 -2
  27. package/lib/runtime/declarative-runtime-contract.js.map +1 -1
  28. package/lib/schemas/index.d.ts +20 -0
  29. package/lib/schemas/index.d.ts.map +1 -1
  30. package/package.json +1 -1
@@ -12928,6 +12928,34 @@ var PageNodeSchema = z13.lazy(
12928
12928
  children: z13.array(PageNodeSchema).optional()
12929
12929
  }).strict()
12930
12930
  );
12931
+ var PageSharedStateBindingSchema = z13.object({
12932
+ bindingId: ContractIdentifierSchema,
12933
+ provider: z13.object({ id: ContractIdentifierSchema, version: z13.number().int().positive() }).strict(),
12934
+ states: z13.record(ContractIdentifierSchema, ContractIdentifierSchema).refine((value) => Object.keys(value).length > 0 && Object.keys(value).length <= 32, "Map 1\u201332 state slots."),
12935
+ queries: z13.record(ContractIdentifierSchema, ContractIdentifierSchema).refine((value) => Object.keys(value).length <= 16, "Map at most 16 query slots."),
12936
+ writeInteractions: z13.array(ContractIdentifierSchema).max(32)
12937
+ }).strict();
12938
+ var validateSharedStateBindings = (bindings, states, queryIds, interactions, context) => {
12939
+ const ids = /* @__PURE__ */ new Set();
12940
+ const owned = /* @__PURE__ */ new Set();
12941
+ for (const [index, binding] of (bindings ?? []).entries()) {
12942
+ const issue = (message) => context.addIssue({ code: "custom", path: ["sharedStateBindings", index], message });
12943
+ if (ids.has(binding.bindingId)) issue("Shared state binding ids must be unique.");
12944
+ ids.add(binding.bindingId);
12945
+ const mapped = Object.values(binding.states);
12946
+ for (const id of mapped) {
12947
+ if (owned.has(id)) issue("Shared state mappings must have one owner and distinct slots.");
12948
+ owned.add(id);
12949
+ if (!states.some((state) => state.stateId === id && !state.scopeNodeId)) issue(`Shared state ${id} must reference a declared root state.`);
12950
+ }
12951
+ for (const id of Object.values(binding.queries)) if (!queryIds.has(id)) issue(`Unknown shared state query ${id}.`);
12952
+ if (new Set(binding.writeInteractions).size !== binding.writeInteractions.length) issue("Shared state write interactions must be unique.");
12953
+ for (const id of binding.writeInteractions) {
12954
+ const interaction = interactions.find((entry) => entry.bindingId === id);
12955
+ if (!interaction || !mapped.includes(interaction.targetStateId)) issue(`Shared state write ${id} must target a mapped state.`);
12956
+ }
12957
+ }
12958
+ };
12931
12959
  var PageSchema = z13.object({
12932
12960
  contract: z13.literal("Page"),
12933
12961
  schemaVersion: z13.literal(DECLARATIVE_CONTROL_SCHEMA_VERSION),
@@ -12942,6 +12970,7 @@ var PageSchema = z13.object({
12942
12970
  shell: ContractIdentifierSchema.optional(),
12943
12971
  body: PageNodeSchema,
12944
12972
  state: z13.array(PageStateSchema).optional(),
12973
+ sharedStateBindings: z13.array(PageSharedStateBindingSchema).max(16).optional(),
12945
12974
  entryTransitions: z13.array(PageEntrySchema).optional(),
12946
12975
  access: AccessPolicySchema,
12947
12976
  managementAccess: ManagementAccessSchema,
@@ -12954,6 +12983,7 @@ var PageSchema = z13.object({
12954
12983
  const dataIds = /* @__PURE__ */ new Set();
12955
12984
  const actionIds = /* @__PURE__ */ new Set();
12956
12985
  const interactionIds = /* @__PURE__ */ new Set();
12986
+ const sharedInteractions = [];
12957
12987
  const visit = (node, path) => {
12958
12988
  if (ids.has(node.id))
12959
12989
  context.addIssue({
@@ -12976,11 +13006,13 @@ var PageSchema = z13.object({
12976
13006
  });
12977
13007
  target.add(value.bindingId);
12978
13008
  }
13009
+ sharedInteractions.push(...node.on ?? []);
12979
13010
  (node.children ?? []).forEach(
12980
13011
  (child, index) => visit(child, [...path, "children", index])
12981
13012
  );
12982
13013
  };
12983
13014
  visit(page.body, ["body"]);
13015
+ validateSharedStateBindings(page.sharedStateBindings, page.state ?? [], dataIds, sharedInteractions, context);
12984
13016
  const stateIds = (page.state ?? []).map((entry) => entry.stateId);
12985
13017
  if (new Set(stateIds).size !== stateIds.length)
12986
13018
  context.addIssue({
@@ -13010,6 +13042,7 @@ var ResolvedPageSchema = z13.object({
13010
13042
  renderTree: RenderTreeSchema,
13011
13043
  capabilityInstances: z13.array(CapabilityInstanceSchema).min(1),
13012
13044
  stateDefinitions: z13.array(PageStateDefinitionSchema).optional(),
13045
+ sharedStateBindings: z13.array(PageSharedStateBindingSchema).max(16).optional(),
13013
13046
  entryTransitions: z13.array(PageEntryTransitionSchema).optional(),
13014
13047
  interactionBindings: z13.array(InteractionBindingSchema).optional(),
13015
13048
  ontologyBindings: z13.array(PersistedOntologyBindingSchema),
@@ -13052,6 +13085,7 @@ var ResolvedPageSchema = z13.object({
13052
13085
  });
13053
13086
  }
13054
13087
  });
13088
+ validateSharedStateBindings(value.sharedStateBindings, value.stateDefinitions ?? [], new Set([...value.queryBindings ?? [], ...value.ontologyBindings].map((binding) => binding.bindingId)), value.interactionBindings ?? [], context);
13055
13089
  const stateDefinitions = value.stateDefinitions ?? [];
13056
13090
  const entryTransitions = value.entryTransitions ?? [];
13057
13091
  const interactionBindings = value.interactionBindings ?? [];
@@ -14808,6 +14842,7 @@ var CompatiblePageRuntimeBundleSchema = z13.object({
14808
14842
  deniedCapabilityInstanceIds: z13.array(ContractIdentifierSchema).default([]),
14809
14843
  capabilityAccessEvaluated: z13.literal(true).optional(),
14810
14844
  stateDefinitions: z13.array(PageStateDefinitionSchema).default([]),
14845
+ sharedStateBindings: z13.array(PageSharedStateBindingSchema).max(16).optional(),
14811
14846
  entryTransitions: z13.array(ResolvedPageEntryTransitionSchema).default([]),
14812
14847
  interactionBindings: z13.array(InteractionBindingSchema).default([]),
14813
14848
  ontologyBindings: z13.array(PersistedOntologyBindingSchema),
@@ -14824,6 +14859,7 @@ var CompatiblePageRuntimeBundleSchema = z13.object({
14824
14859
  "restricted"
14825
14860
  ])
14826
14861
  }).strict().superRefine((value, context) => {
14862
+ validateSharedStateBindings(value.sharedStateBindings, value.stateDefinitions, new Set([...value.queryBindings, ...value.ontologyBindings].map((binding) => binding.bindingId)), value.interactionBindings, context);
14827
14863
  const instanceIds = new Set(
14828
14864
  value.capabilityInstances.map((instance) => instance.instanceId)
14829
14865
  );
@@ -18963,6 +18999,7 @@ var resolvePage = (input) => {
18963
18999
  },
18964
19000
  capabilityInstances,
18965
19001
  ...stateDefinitions.length ? { stateDefinitions } : {},
19002
+ ...page.sharedStateBindings ? { sharedStateBindings: page.sharedStateBindings } : {},
18966
19003
  ...page.entryTransitions ? {
18967
19004
  entryTransitions: page.entryTransitions.map(
18968
19005
  ({ target, ...transition }, index) => {
@@ -19650,6 +19687,7 @@ var compilePageRuntimeBundleInternal = (input, legacy) => {
19650
19687
  capabilityInstances: page.capabilityInstances,
19651
19688
  deniedCapabilityInstanceIds: [],
19652
19689
  stateDefinitions: page.stateDefinitions,
19690
+ ...page.sharedStateBindings ? { sharedStateBindings: page.sharedStateBindings } : {},
19653
19691
  entryTransitions,
19654
19692
  interactionBindings: page.interactionBindings,
19655
19693
  ontologyBindings: page.ontologyBindings,
@@ -24672,6 +24710,7 @@ var acceptsPreviousSchema = (previous, next) => {
24672
24710
  required: oldRequired,
24673
24711
  additionalProperties: oldAdditional,
24674
24712
  enum: oldEnum,
24713
+ items: oldItems,
24675
24714
  ...oldFixed
24676
24715
  } = before;
24677
24716
  const {
@@ -24679,9 +24718,11 @@ var acceptsPreviousSchema = (previous, next) => {
24679
24718
  required: newRequired,
24680
24719
  additionalProperties: newAdditional,
24681
24720
  enum: newEnum,
24721
+ items: newItems,
24682
24722
  ...newFixed
24683
24723
  } = after;
24684
24724
  if (canonicalContentHash(oldFixed) !== canonicalContentHash(newFixed)) return false;
24725
+ if (!acceptsPreviousSchema(oldItems ?? true, newItems ?? true)) return false;
24685
24726
  if (newEnum && (!oldEnum || oldEnum.some((value) => !newEnum.some((candidate) => canonicalContentHash(candidate) === canonicalContentHash(value))))) return false;
24686
24727
  if ((newRequired ?? []).some((key) => !(oldRequired ?? []).includes(key))) return false;
24687
24728
  const oldExtra = oldAdditional ?? true;