@inf-monkeys-tech/monkeys 1.1.14 → 1.1.16

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 +67 -0
  13. package/lib/esm/contracts/index.mjs.map +1 -1
  14. package/lib/esm/index.mjs +69 -0
  15. package/lib/esm/index.mjs.map +1 -1
  16. package/lib/esm/runtime/index.mjs +68 -0
  17. package/lib/esm/runtime/index.mjs.map +1 -1
  18. package/lib/esm/schemas/index.mjs +66 -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/schemas/index.d.ts +20 -0
  26. package/lib/schemas/index.d.ts.map +1 -1
  27. package/lib/theme-tokens/core.d.ts.map +1 -1
  28. package/lib/theme-tokens/core.js +29 -0
  29. package/lib/theme-tokens/core.js.map +1 -1
  30. package/package.json +1 -1
@@ -11229,6 +11229,34 @@ var PageNodeSchema = z15.lazy(
11229
11229
  children: z15.array(PageNodeSchema).optional()
11230
11230
  }).strict()
11231
11231
  );
11232
+ var PageSharedStateBindingSchema = z15.object({
11233
+ bindingId: ContractIdentifierSchema,
11234
+ provider: z15.object({ id: ContractIdentifierSchema, version: z15.number().int().positive() }).strict(),
11235
+ states: z15.record(ContractIdentifierSchema, ContractIdentifierSchema).refine((value) => Object.keys(value).length > 0 && Object.keys(value).length <= 32, "Map 1\u201332 state slots."),
11236
+ queries: z15.record(ContractIdentifierSchema, ContractIdentifierSchema).refine((value) => Object.keys(value).length <= 16, "Map at most 16 query slots."),
11237
+ writeInteractions: z15.array(ContractIdentifierSchema).max(32)
11238
+ }).strict();
11239
+ var validateSharedStateBindings = (bindings, states, queryIds, interactions, context) => {
11240
+ const ids = /* @__PURE__ */ new Set();
11241
+ const owned = /* @__PURE__ */ new Set();
11242
+ for (const [index, binding] of (bindings ?? []).entries()) {
11243
+ const issue = (message) => context.addIssue({ code: "custom", path: ["sharedStateBindings", index], message });
11244
+ if (ids.has(binding.bindingId)) issue("Shared state binding ids must be unique.");
11245
+ ids.add(binding.bindingId);
11246
+ const mapped = Object.values(binding.states);
11247
+ for (const id of mapped) {
11248
+ if (owned.has(id)) issue("Shared state mappings must have one owner and distinct slots.");
11249
+ owned.add(id);
11250
+ if (!states.some((state) => state.stateId === id && !state.scopeNodeId)) issue(`Shared state ${id} must reference a declared root state.`);
11251
+ }
11252
+ for (const id of Object.values(binding.queries)) if (!queryIds.has(id)) issue(`Unknown shared state query ${id}.`);
11253
+ if (new Set(binding.writeInteractions).size !== binding.writeInteractions.length) issue("Shared state write interactions must be unique.");
11254
+ for (const id of binding.writeInteractions) {
11255
+ const interaction = interactions.find((entry) => entry.bindingId === id);
11256
+ if (!interaction || !mapped.includes(interaction.targetStateId)) issue(`Shared state write ${id} must target a mapped state.`);
11257
+ }
11258
+ }
11259
+ };
11232
11260
  var PageSchema = z15.object({
11233
11261
  contract: z15.literal("Page"),
11234
11262
  schemaVersion: z15.literal(DECLARATIVE_CONTROL_SCHEMA_VERSION),
@@ -11243,6 +11271,7 @@ var PageSchema = z15.object({
11243
11271
  shell: ContractIdentifierSchema.optional(),
11244
11272
  body: PageNodeSchema,
11245
11273
  state: z15.array(PageStateSchema).optional(),
11274
+ sharedStateBindings: z15.array(PageSharedStateBindingSchema).max(16).optional(),
11246
11275
  entryTransitions: z15.array(PageEntrySchema).optional(),
11247
11276
  access: AccessPolicySchema,
11248
11277
  managementAccess: ManagementAccessSchema,
@@ -11255,6 +11284,7 @@ var PageSchema = z15.object({
11255
11284
  const dataIds = /* @__PURE__ */ new Set();
11256
11285
  const actionIds = /* @__PURE__ */ new Set();
11257
11286
  const interactionIds = /* @__PURE__ */ new Set();
11287
+ const sharedInteractions = [];
11258
11288
  const visit = (node, path) => {
11259
11289
  if (ids.has(node.id))
11260
11290
  context.addIssue({
@@ -11277,11 +11307,13 @@ var PageSchema = z15.object({
11277
11307
  });
11278
11308
  target.add(value.bindingId);
11279
11309
  }
11310
+ sharedInteractions.push(...node.on ?? []);
11280
11311
  (node.children ?? []).forEach(
11281
11312
  (child, index) => visit(child, [...path, "children", index])
11282
11313
  );
11283
11314
  };
11284
11315
  visit(page.body, ["body"]);
11316
+ validateSharedStateBindings(page.sharedStateBindings, page.state ?? [], dataIds, sharedInteractions, context);
11285
11317
  const stateIds = (page.state ?? []).map((entry) => entry.stateId);
11286
11318
  if (new Set(stateIds).size !== stateIds.length)
11287
11319
  context.addIssue({
@@ -11311,6 +11343,7 @@ var ResolvedPageSchema = z15.object({
11311
11343
  renderTree: RenderTreeSchema,
11312
11344
  capabilityInstances: z15.array(CapabilityInstanceSchema).min(1),
11313
11345
  stateDefinitions: z15.array(PageStateDefinitionSchema).optional(),
11346
+ sharedStateBindings: z15.array(PageSharedStateBindingSchema).max(16).optional(),
11314
11347
  entryTransitions: z15.array(PageEntryTransitionSchema).optional(),
11315
11348
  interactionBindings: z15.array(InteractionBindingSchema).optional(),
11316
11349
  ontologyBindings: z15.array(PersistedOntologyBindingSchema),
@@ -11353,6 +11386,7 @@ var ResolvedPageSchema = z15.object({
11353
11386
  });
11354
11387
  }
11355
11388
  });
11389
+ validateSharedStateBindings(value.sharedStateBindings, value.stateDefinitions ?? [], new Set([...value.queryBindings ?? [], ...value.ontologyBindings].map((binding) => binding.bindingId)), value.interactionBindings ?? [], context);
11356
11390
  const stateDefinitions = value.stateDefinitions ?? [];
11357
11391
  const entryTransitions = value.entryTransitions ?? [];
11358
11392
  const interactionBindings = value.interactionBindings ?? [];
@@ -13109,6 +13143,7 @@ var CompatiblePageRuntimeBundleSchema = z15.object({
13109
13143
  deniedCapabilityInstanceIds: z15.array(ContractIdentifierSchema).default([]),
13110
13144
  capabilityAccessEvaluated: z15.literal(true).optional(),
13111
13145
  stateDefinitions: z15.array(PageStateDefinitionSchema).default([]),
13146
+ sharedStateBindings: z15.array(PageSharedStateBindingSchema).max(16).optional(),
13112
13147
  entryTransitions: z15.array(ResolvedPageEntryTransitionSchema).default([]),
13113
13148
  interactionBindings: z15.array(InteractionBindingSchema).default([]),
13114
13149
  ontologyBindings: z15.array(PersistedOntologyBindingSchema),
@@ -13125,6 +13160,7 @@ var CompatiblePageRuntimeBundleSchema = z15.object({
13125
13160
  "restricted"
13126
13161
  ])
13127
13162
  }).strict().superRefine((value, context) => {
13163
+ validateSharedStateBindings(value.sharedStateBindings, value.stateDefinitions, new Set([...value.queryBindings, ...value.ontologyBindings].map((binding) => binding.bindingId)), value.interactionBindings, context);
13128
13164
  const instanceIds = new Set(
13129
13165
  value.capabilityInstances.map((instance) => instance.instanceId)
13130
13166
  );
@@ -18122,6 +18158,7 @@ function resolveThemeTokens(input) {
18122
18158
  return result;
18123
18159
  };
18124
18160
  for (const path of collected.keys()) resolveToken(path);
18161
+ assertBentoTokens(resolved);
18125
18162
  const resolvedDocument = {};
18126
18163
  for (const token of resolved.values()) {
18127
18164
  const segments = token.path.split(".");
@@ -18201,6 +18238,35 @@ var MONKEYS_REQUIRED_THEME_TOKEN_PATHS = Object.freeze({
18201
18238
  "semantic.spacing.global.comfortable": "dimension",
18202
18239
  "semantic.font.body": "fontFamily"
18203
18240
  });
18241
+ function assertBentoTokens(tokens) {
18242
+ const fields = {
18243
+ background: "color",
18244
+ borderColor: "color",
18245
+ borderWidth: "dimension",
18246
+ borderStyle: "strokeStyle",
18247
+ radius: "dimension",
18248
+ shadow: "shadow",
18249
+ padding: "dimension",
18250
+ gap: "dimension"
18251
+ };
18252
+ for (const [path, token] of tokens) {
18253
+ if (!path.startsWith("semantic.bento.")) continue;
18254
+ const match = /^semantic\.bento\.(?:default|levels\.level([1-9]\d*))\.([a-zA-Z]+)(?:\.([a-z]+))?$/.exec(path);
18255
+ const field = match?.[2];
18256
+ const axis = match?.[3];
18257
+ const expected = field && fields[field];
18258
+ const modes = field === "padding" || field === "gap" ? ["compact", "default", "comfortable"] : ["light", "dark"];
18259
+ if (!match || !expected || token.type !== expected || axis && !modes.includes(axis) || match[1] && !Number.isSafeInteger(Number(match[1]))) {
18260
+ throw new ThemeTokenValidationError("Invalid Bento semantic token.", [{ path, message: "Expected a supported Bento field, type, level and mode." }]);
18261
+ }
18262
+ if (field === "borderStyle" && typeof token.value !== "string") {
18263
+ throw new ThemeTokenValidationError("Invalid Bento border style.", [{ path, message: "Bento borders require a CSS stroke keyword." }]);
18264
+ }
18265
+ if (token.type === "dimension" && token.value.value < 0) {
18266
+ throw new ThemeTokenValidationError("Invalid Bento dimension.", [{ path, message: "Bento dimensions must be non-negative." }]);
18267
+ }
18268
+ }
18269
+ }
18204
18270
 
18205
18271
  // src/contracts/theme.ts
18206
18272
  var ThemeTokenTypeSchema = z20.enum(THEME_TOKEN_TYPES);