@inf-monkeys-tech/monkeys 1.1.71 → 1.1.73

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 (86) hide show
  1. package/lib/contracts/bento-block.d.ts +14 -0
  2. package/lib/contracts/bento-block.d.ts.map +1 -1
  3. package/lib/contracts/bento-block.js +16 -0
  4. package/lib/contracts/bento-block.js.map +1 -1
  5. package/lib/contracts/declarative-control-http.d.ts +54 -0
  6. package/lib/contracts/declarative-control-http.d.ts.map +1 -1
  7. package/lib/contracts/declarative-control-http.js +9 -0
  8. package/lib/contracts/declarative-control-http.js.map +1 -1
  9. package/lib/contracts/declarative-document-import.d.ts +51 -0
  10. package/lib/contracts/declarative-document-import.d.ts.map +1 -1
  11. package/lib/contracts/declarative-document-import.js +6 -0
  12. package/lib/contracts/declarative-document-import.js.map +1 -1
  13. package/lib/contracts/declarative-page-delivery.d.ts +145 -0
  14. package/lib/contracts/declarative-page-delivery.d.ts.map +1 -0
  15. package/lib/contracts/declarative-page-delivery.js +164 -0
  16. package/lib/contracts/declarative-page-delivery.js.map +1 -0
  17. package/lib/contracts/declarative-publication-health.d.ts +1061 -0
  18. package/lib/contracts/declarative-publication-health.d.ts.map +1 -0
  19. package/lib/contracts/declarative-publication-health.js +148 -0
  20. package/lib/contracts/declarative-publication-health.js.map +1 -0
  21. package/lib/contracts/declarative-publication-job.d.ts +51 -0
  22. package/lib/contracts/declarative-publication-job.d.ts.map +1 -1
  23. package/lib/contracts/declarative-publication-verification.d.ts +6 -0
  24. package/lib/contracts/declarative-publication-verification.d.ts.map +1 -1
  25. package/lib/contracts/declarative-publication-verification.js +5 -0
  26. package/lib/contracts/declarative-publication-verification.js.map +1 -1
  27. package/lib/contracts/index.d.ts +2 -0
  28. package/lib/contracts/index.d.ts.map +1 -1
  29. package/lib/contracts/index.js +2 -0
  30. package/lib/contracts/index.js.map +1 -1
  31. package/lib/contracts/render.d.ts +4 -0
  32. package/lib/contracts/render.d.ts.map +1 -1
  33. package/lib/contracts/render.js +4 -0
  34. package/lib/contracts/render.js.map +1 -1
  35. package/lib/esm/{chunk-75IO3EKE.mjs → chunk-ES3EYSBV.mjs} +16 -2
  36. package/lib/esm/chunk-ES3EYSBV.mjs.map +1 -0
  37. package/lib/esm/{chunk-TKVCHO6V.mjs → chunk-FNYVI3AY.mjs} +2032 -1740
  38. package/lib/esm/chunk-FNYVI3AY.mjs.map +1 -0
  39. package/lib/esm/{chunk-DWQNEXK3.mjs → chunk-UVLLWRYL.mjs} +2 -2
  40. package/lib/esm/{chunk-JEAEX7QG.mjs → chunk-WIGX4I2M.mjs} +499 -273
  41. package/lib/esm/chunk-WIGX4I2M.mjs.map +1 -0
  42. package/lib/esm/contracts/index.mjs +34 -2
  43. package/lib/esm/index.mjs +42 -6
  44. package/lib/esm/index.mjs.map +1 -1
  45. package/lib/esm/runtime/index.mjs +9 -5
  46. package/lib/esm/schemas/index.mjs +2 -2
  47. package/lib/json-schema/bento-node.schema.json +37 -0
  48. package/lib/json-schema/declarative-page-overlay.schema.json +184 -0
  49. package/lib/json-schema/declarative-page-package.schema.json +73 -0
  50. package/lib/json-schema/declarative-page-rendering.schema.json +239 -0
  51. package/lib/json-schema/declarative-publication-last-known-good-result.schema.json +675 -0
  52. package/lib/json-schema/declarative-publication-last-known-good.schema.json +651 -0
  53. package/lib/json-schema/declarative-publication-record-result.schema.json +1138 -0
  54. package/lib/json-schema/declarative-publication-recovery-result.schema.json +1775 -0
  55. package/lib/json-schema/declarative-publication-verification.schema.json +11 -0
  56. package/lib/json-schema/index.json +7 -0
  57. package/lib/json-schema/overlay-node.schema.json +18 -0
  58. package/lib/json-schema/page-runtime-bundle.schema.json +18 -0
  59. package/lib/json-schema/page.schema.json +18 -0
  60. package/lib/json-schema/render-node.schema.json +18 -0
  61. package/lib/json-schema/render-tree.schema.json +18 -0
  62. package/lib/json-schema/view-ontology-record.schema.json +37 -0
  63. package/lib/runtime/artifact-session.d.ts +0 -8
  64. package/lib/runtime/artifact-session.d.ts.map +1 -1
  65. package/lib/runtime/artifact-session.js +10 -114
  66. package/lib/runtime/artifact-session.js.map +1 -1
  67. package/lib/runtime/bento-render-tree.d.ts.map +1 -1
  68. package/lib/runtime/bento-render-tree.js +2 -1
  69. package/lib/runtime/bento-render-tree.js.map +1 -1
  70. package/lib/runtime/declarative-page-delivery.d.ts +41 -0
  71. package/lib/runtime/declarative-page-delivery.d.ts.map +1 -0
  72. package/lib/runtime/declarative-page-delivery.js +270 -0
  73. package/lib/runtime/declarative-page-delivery.js.map +1 -0
  74. package/lib/runtime/index.d.ts +1 -0
  75. package/lib/runtime/index.d.ts.map +1 -1
  76. package/lib/runtime/index.js +1 -0
  77. package/lib/runtime/index.js.map +1 -1
  78. package/lib/schemas/index.d.ts +227 -0
  79. package/lib/schemas/index.d.ts.map +1 -1
  80. package/lib/schemas/index.js +9 -0
  81. package/lib/schemas/index.js.map +1 -1
  82. package/package.json +2 -2
  83. package/lib/esm/chunk-75IO3EKE.mjs.map +0 -1
  84. package/lib/esm/chunk-JEAEX7QG.mjs.map +0 -1
  85. package/lib/esm/chunk-TKVCHO6V.mjs.map +0 -1
  86. /package/lib/esm/{chunk-DWQNEXK3.mjs.map → chunk-UVLLWRYL.mjs.map} +0 -0
@@ -4,15 +4,15 @@ import {
4
4
  PAGE_STREAM_MAX_FRAME_BYTES,
5
5
  PageStreamDescriptorSchema,
6
6
  PageStreamEventSchema
7
- } from "./chunk-DWQNEXK3.mjs";
7
+ } from "./chunk-UVLLWRYL.mjs";
8
8
  import {
9
9
  AccessPolicySchema,
10
+ ActionProgramArtifactSchema,
10
11
  ActionProgramDefinitionSchema,
11
12
  AgentSessionEventSchema,
12
13
  AgentSessionViewModelSchema,
13
14
  ApplicationHandoffSchema,
14
15
  ArtifactProfileSchema,
15
- ArtifactViewSchema,
16
16
  BENTO_GRID_COLUMNS,
17
17
  CapabilityManifestSchema,
18
18
  CapabilityRegistryDocumentSchema,
@@ -24,6 +24,10 @@ import {
24
24
  ComponentAssemblySchema,
25
25
  ConductorWorkflowDefinitionSchema,
26
26
  ContractIdentifierSchema,
27
+ DECLARATIVE_PAGE_BINDING_TOKEN_SOURCE,
28
+ DeclarativePageOverlaySchema,
29
+ DeclarativePagePackageSchema,
30
+ DeclarativePageRenderingSchema,
27
31
  DeclarativeProductResourceRegistrationSchema,
28
32
  DeclarativeRouteOwnerIndexSchema,
29
33
  DeclarativeRuntimeResolveResultSchema,
@@ -72,6 +76,7 @@ import {
72
76
  PermissionAlternativePolicySchema,
73
77
  ProductAccessDeclarationSchema,
74
78
  ProductDeclarationSchema,
79
+ ProductDeclarativeAuthoringCatalogSchema,
75
80
  ProductDeclarativeCapabilityRegistrationSchema,
76
81
  ProductSurfaceSchema,
77
82
  RecordEditorDraftOperationSchema,
@@ -120,7 +125,7 @@ import {
120
125
  require_validation,
121
126
  require_validation_error,
122
127
  resolveThemeTokens
123
- } from "./chunk-TKVCHO6V.mjs";
128
+ } from "./chunk-FNYVI3AY.mjs";
124
129
  import {
125
130
  __commonJS,
126
131
  __toESM
@@ -1078,109 +1083,195 @@ var compileCapabilityRegistry = (sources) => {
1078
1083
  });
1079
1084
  };
1080
1085
 
1081
- // src/runtime/artifact-session.ts
1082
- function buildArtifactCollabRoomId(key) {
1083
- const tenant = key.tenantId ? `${key.tenantId}:` : "";
1084
- return `artifact:${tenant}${key.teamId}:${key.ontologyId}:${key.artifactKind}:${key.recordId}`;
1086
+ // src/runtime/bento-render-tree.ts
1087
+ function mapContainerLayout(node) {
1088
+ const gap = typeof node.gap === "number" ? node.gap : void 0;
1089
+ if (node.layout === "grid") {
1090
+ return {
1091
+ mode: "grid",
1092
+ columns: node.columns ?? BENTO_GRID_COLUMNS,
1093
+ ...typeof node.rowHeight === "number" ? { rowHeight: node.rowHeight } : {},
1094
+ ...gap !== void 0 ? { gap } : {}
1095
+ };
1096
+ }
1097
+ if (node.layout === "split") {
1098
+ return {
1099
+ mode: "split",
1100
+ direction: node.direction === "vertical" ? "column" : "row",
1101
+ ...gap !== void 0 ? { gap } : {}
1102
+ };
1103
+ }
1104
+ if (node.layout === "tabs") {
1105
+ return {
1106
+ mode: "tabs",
1107
+ ...gap !== void 0 ? { gap } : {}
1108
+ };
1109
+ }
1110
+ if (node.layout === "floating") {
1111
+ return {
1112
+ mode: "floating",
1113
+ ...node.floating ? { floating: node.floating } : {},
1114
+ ...gap !== void 0 ? { gap } : {}
1115
+ };
1116
+ }
1117
+ return {
1118
+ mode: "flex",
1119
+ direction: node.direction === "horizontal" ? "row" : "column",
1120
+ ...gap !== void 0 ? { gap } : {}
1121
+ };
1085
1122
  }
1086
- function compileBentoTreeToRenderTree(viewInput, options = {}) {
1087
- const view = ArtifactViewSchema.parse(viewInput);
1123
+ function buildPlacementStyle(node) {
1124
+ const style = {};
1125
+ const grid = node.placement?.grid;
1126
+ if (grid) {
1127
+ style.gridColumn = `${grid.x + 1} / span ${grid.w}`;
1128
+ style.gridRow = `${grid.y + 1} / span ${grid.h}`;
1129
+ }
1130
+ const split = node.placement?.split;
1131
+ if (split?.size !== void 0) {
1132
+ style.flex = typeof split.size === "number" ? `0 0 ${split.size}%` : `0 0 ${split.size}`;
1133
+ }
1134
+ if (split?.minSize !== void 0) {
1135
+ style.minWidth = typeof split.minSize === "number" ? `${split.minSize}px` : split.minSize;
1136
+ }
1137
+ if (split?.maxSize !== void 0) {
1138
+ style.maxWidth = typeof split.maxSize === "number" ? `${split.maxSize}px` : split.maxSize;
1139
+ }
1140
+ return Object.keys(style).length > 0 ? style : void 0;
1141
+ }
1142
+ function mapLeafDataBinding(node, data) {
1143
+ const source = node.block.dataSource;
1144
+ if (!source || source.kind === "static") return void 0;
1145
+ if (source.kind === "statement") {
1146
+ const inlineStatement = data?.statements?.[source.statementId];
1147
+ return inlineStatement ?? { kind: "statement", statementId: source.statementId };
1148
+ }
1149
+ if (source.kind === "ontology-view" || source.kind === "ontology-relation" || source.kind === "ontology-action" || source.kind === "artifact.body" || source.kind === "record.fields" || source.kind === "navigation" || source.kind === "workflow" || source.kind === "command") {
1150
+ return source;
1151
+ }
1152
+ return void 0;
1153
+ }
1154
+ function compileBentoNodeToRenderTree(root, options) {
1088
1155
  const product = options.product ?? "studio";
1089
- const ownerRepo = options.ownerRepo ?? "monkeys-studio";
1090
- const rootPrefix = `bento.${view.viewId}`;
1091
- const pageRef = { kind: "page", id: rootPrefix, ownerRepo };
1092
- const defaultSurface = { frameOwner: "host", density: "default" };
1093
- const defaultScroll = { owner: "surface", axis: "y", virtualizationBoundary: false };
1094
- const defaultLifecycle = {
1095
- mountPolicy: "when-active",
1096
- queryPolicy: "when-active",
1097
- retainOnDeactivate: true,
1098
- deepLink: true,
1099
- focusReturn: false
1100
- };
1156
+ const ownerRepo = options.ownerRepo ?? "monkeys-sdk";
1157
+ const pageId = options.pageId ?? options.treeId;
1101
1158
  const nodes = [];
1102
- const lowerNode = (node, parentNodeId) => {
1103
- const nodeId = parentNodeId ? `${rootPrefix}.${node.id}` : `${rootPrefix}.root`;
1104
- if (node.kind === "leaf") {
1105
- const dsKind = node.block.dataSource?.kind;
1106
- nodes.push({
1107
- contract: "RenderNode",
1108
- nodeId,
1109
- kind: dsKind === "artifact.body" ? "professional-provider" : dsKind === "record.fields" ? "record" : "view",
1110
- version: 1,
1111
- ownerRepo,
1112
- ...parentNodeId ? { parentNodeId } : {},
1113
- children: [],
1114
- slot: node.id,
1115
- pageRef,
1116
- capabilityRef: {
1117
- kind: "capability",
1118
- id: `monkeys.block.${node.block.customType ?? node.block.type}`,
1119
- version: 1,
1120
- ownerRepo
1121
- },
1122
- surface: defaultSurface,
1123
- scroll: dsKind === "artifact.body" ? { owner: "provider", axis: "none", virtualizationBoundary: false } : defaultScroll,
1124
- activation: { activationId: `${nodeId}.activate`, mode: "inline" },
1125
- lifecycle: defaultLifecycle,
1126
- layout: { mode: "flex", direction: "column" },
1127
- responsive: [],
1128
- state: "idle",
1129
- renderModel: {
1130
- bentoId: node.id,
1131
- chrome: node.chrome ?? "panel",
1132
- ...node.placement ? { placement: node.placement } : {},
1133
- block: node.block
1134
- }
1135
- });
1136
- return nodeId;
1137
- }
1138
- const childIds = node.children.map((child) => lowerNode(child, nodeId));
1139
- const isHorizontal = node.layout === "split" && (node.direction ?? "horizontal") === "horizontal";
1140
- nodes.unshift({
1159
+ const visit = (node, parentNodeId, inheritedData) => {
1160
+ const effectiveData = node.kind === "container" && node.data ? node.data : inheritedData;
1161
+ const chrome = node.chrome ?? (node.kind === "leaf" ? "panel" : "none");
1162
+ const style = buildPlacementStyle(node);
1163
+ const common = {
1141
1164
  contract: "RenderNode",
1142
- nodeId,
1143
- kind: "view",
1165
+ nodeId: node.id,
1144
1166
  version: 1,
1145
1167
  ownerRepo,
1146
1168
  ...parentNodeId ? { parentNodeId } : {},
1147
- children: childIds,
1148
- pageRef,
1169
+ pageRef: { kind: "page", id: pageId },
1149
1170
  capabilityRef: {
1150
1171
  kind: "capability",
1151
- id: `monkeys.bento.${node.layout}`,
1172
+ id: node.kind === "leaf" ? `monkeys.bento.block.${node.block.customType ?? node.block.type}` : `monkeys.bento.container.${node.layout}`,
1152
1173
  version: 1,
1153
1174
  ownerRepo
1154
1175
  },
1155
- surface: defaultSurface,
1156
- scroll: { owner: "page", axis: "none", virtualizationBoundary: false },
1157
- activation: { activationId: `${nodeId}.activate`, mode: "inline" },
1158
- lifecycle: defaultLifecycle,
1159
- layout: isHorizontal ? { mode: "flex", direction: "row" } : { mode: "flex", direction: "column" },
1176
+ surface: {
1177
+ frameOwner: chrome === "none" ? "none" : "host",
1178
+ density: "default",
1179
+ ...chrome !== "none" ? { bento: { chrome } } : {}
1180
+ },
1181
+ scroll: {
1182
+ owner: "surface",
1183
+ axis: "none",
1184
+ virtualizationBoundary: false
1185
+ },
1186
+ activation: {
1187
+ activationId: node.id,
1188
+ mode: "inline"
1189
+ },
1190
+ lifecycle: {
1191
+ mountPolicy: "always",
1192
+ queryPolicy: "always",
1193
+ retainOnDeactivate: true,
1194
+ deepLink: false,
1195
+ focusReturn: false
1196
+ },
1197
+ ...node.placement ? { placement: node.placement } : {},
1198
+ ...node.dynamicLayout ? { dynamicLayout: node.dynamicLayout } : {},
1199
+ ...style ? { style } : {},
1160
1200
  responsive: [],
1161
- state: "idle",
1201
+ state: "idle"
1202
+ };
1203
+ if (node.kind === "container") {
1204
+ nodes.push({
1205
+ ...common,
1206
+ kind: parentNodeId ? "view" : "page",
1207
+ children: node.children.map((child) => child.id),
1208
+ layout: mapContainerLayout(node),
1209
+ ...node.wiring ? { wiring: node.wiring } : {},
1210
+ renderModel: {
1211
+ bentoKind: "container",
1212
+ layout: node.layout,
1213
+ ...node.direction ? { direction: node.direction } : {},
1214
+ ...node.floating ? { floating: node.floating } : {},
1215
+ ...node.title ? { title: node.title } : {},
1216
+ ...node.description ? { description: node.description } : {},
1217
+ ...node.wiring ? { wiring: node.wiring } : {}
1218
+ }
1219
+ });
1220
+ for (const child of node.children) {
1221
+ visit(child, node.id, effectiveData);
1222
+ }
1223
+ return;
1224
+ }
1225
+ const dataBinding = mapLeafDataBinding(node, effectiveData);
1226
+ const moduleId = node.block.customType ?? node.block.type;
1227
+ nodes.push({
1228
+ ...common,
1229
+ kind: "view",
1230
+ children: [],
1231
+ layout: { mode: "block" },
1232
+ ...dataBinding ? { dataBinding } : {},
1233
+ module: {
1234
+ id: moduleId,
1235
+ granularity: "atomic",
1236
+ ...node.block.title ? { title: node.block.title } : {},
1237
+ ...node.block.config ? { props: node.block.config } : {}
1238
+ },
1162
1239
  renderModel: {
1163
- bentoId: node.id,
1164
- layout: node.layout,
1165
- ...node.direction ? { direction: node.direction } : {},
1166
- ...node.columns ? { columns: node.columns } : {},
1167
- ...node.chrome ? { chrome: node.chrome } : {},
1168
- ...node.placement ? { placement: node.placement } : {},
1169
- ...node.data ? { data: node.data } : {},
1170
- ...node.wiring ? { wiring: node.wiring } : {}
1240
+ bentoKind: "leaf",
1241
+ blockType: node.block.type,
1242
+ ...node.block.customType ? { customType: node.block.customType } : {},
1243
+ ...node.block.title ? { title: node.block.title } : {},
1244
+ ...node.block.dataSource ? { dataSource: node.block.dataSource } : {},
1245
+ ...node.block.actionStatementIds ? { actionStatementIds: node.block.actionStatementIds } : {},
1246
+ ...node.block.config ? { config: node.block.config } : {}
1171
1247
  }
1172
1248
  });
1173
- return nodeId;
1174
1249
  };
1175
- const rootNodeId = lowerNode(view.root);
1250
+ visit(root, void 0, options.data);
1176
1251
  return RenderTreeSchema.parse({
1177
1252
  contract: "RenderTree",
1178
- treeId: `tree.${view.viewId}`,
1253
+ treeId: options.treeId,
1179
1254
  product,
1180
- rootNodeId,
1255
+ rootNodeId: root.id,
1256
+ ...options.data ? { data: options.data } : {},
1181
1257
  nodes
1182
1258
  });
1183
1259
  }
1260
+ function compileViewRecordToRenderTree(record2, options) {
1261
+ return compileBentoNodeToRenderTree(record2.root, {
1262
+ treeId: record2.viewId,
1263
+ pageId: record2.viewId,
1264
+ product: options?.product ?? "studio",
1265
+ ownerRepo: options?.ownerRepo ?? "monkeys-sdk",
1266
+ data: record2.data
1267
+ });
1268
+ }
1269
+
1270
+ // src/runtime/artifact-session.ts
1271
+ function buildArtifactCollabRoomId(key) {
1272
+ const tenant = key.tenantId ? `${key.tenantId}:` : "";
1273
+ return `artifact:${tenant}${key.teamId}:${key.ontologyId}:${key.artifactKind}:${key.recordId}`;
1274
+ }
1184
1275
  function createArtifactRegistry(initialProfiles = []) {
1185
1276
  const profiles = /* @__PURE__ */ new Map();
1186
1277
  const registerProfile = (profileInput, options = {}) => {
@@ -1211,7 +1302,12 @@ function createArtifactRegistry(initialProfiles = []) {
1211
1302
  resolveView,
1212
1303
  compileView: (artifactKind, viewId, options) => {
1213
1304
  const view = resolveView(artifactKind, viewId);
1214
- return view ? compileBentoTreeToRenderTree(view, options) : void 0;
1305
+ return view ? compileBentoNodeToRenderTree(view.root, {
1306
+ treeId: view.viewId,
1307
+ pageId: view.viewId,
1308
+ product: options?.product ?? "studio",
1309
+ ownerRepo: options?.ownerRepo ?? "monkeys-studio"
1310
+ }) : void 0;
1215
1311
  }
1216
1312
  });
1217
1313
  }
@@ -4823,6 +4919,318 @@ function normalizeDeclarativeReferences(document, resolve) {
4823
4919
  return { document: visit(document), counts };
4824
4920
  }
4825
4921
 
4922
+ // src/runtime/declarative-page-delivery.ts
4923
+ var byText = (left, right) => left < right ? -1 : left > right ? 1 : 0;
4924
+ var DeclarativePageDeliveryError = class extends Error {
4925
+ constructor(code, message, details = []) {
4926
+ super(message);
4927
+ this.code = code;
4928
+ this.details = details;
4929
+ this.name = "DeclarativePageDeliveryError";
4930
+ }
4931
+ };
4932
+ var CATALOG_COLLECTIONS = [
4933
+ "createTemplates",
4934
+ "routeSpaces",
4935
+ "resourceRegistrations",
4936
+ "defaultPolicies",
4937
+ "domainQueryDefinitions",
4938
+ "domainCommandDefinitions",
4939
+ "schemaDefinitions",
4940
+ "capabilityRegistrations"
4941
+ ];
4942
+ var DETAIL_LIMIT = 20;
4943
+ var isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
4944
+ var bindingText = (binding) => binding.kind === "value" ? binding.value : binding.id;
4945
+ function collectDeclarativePageBindingKeys(document) {
4946
+ const keys = /* @__PURE__ */ new Set();
4947
+ const visit = (value) => {
4948
+ if (typeof value === "string") {
4949
+ for (const match of value.matchAll(
4950
+ new RegExp(DECLARATIVE_PAGE_BINDING_TOKEN_SOURCE, "g")
4951
+ )) {
4952
+ keys.add(match[1]);
4953
+ }
4954
+ } else if (Array.isArray(value)) {
4955
+ value.forEach(visit);
4956
+ } else if (isRecord(value)) {
4957
+ Object.values(value).forEach(visit);
4958
+ }
4959
+ };
4960
+ visit(document);
4961
+ return [...keys];
4962
+ }
4963
+ var substitute = (document, bindings, used, unbound) => {
4964
+ if (typeof document === "string") {
4965
+ return document.replace(
4966
+ new RegExp(DECLARATIVE_PAGE_BINDING_TOKEN_SOURCE, "g"),
4967
+ (token, key) => {
4968
+ const binding = bindings[key];
4969
+ if (!binding) {
4970
+ unbound.add(key);
4971
+ return token;
4972
+ }
4973
+ used.add(key);
4974
+ return bindingText(binding);
4975
+ }
4976
+ );
4977
+ }
4978
+ if (Array.isArray(document)) {
4979
+ return document.map((entry) => substitute(entry, bindings, used, unbound));
4980
+ }
4981
+ if (isRecord(document)) {
4982
+ return Object.fromEntries(
4983
+ Object.entries(document).map(([key, value]) => [
4984
+ key,
4985
+ substitute(value, bindings, used, unbound)
4986
+ ])
4987
+ );
4988
+ }
4989
+ return document;
4990
+ };
4991
+ var issueLines = (issues) => issues.slice(0, DETAIL_LIMIT).map((issue) => `${issue.path.map(String).join(".") || "(root)"}: ${issue.message}`);
4992
+ var parsePackages = (sources) => {
4993
+ const packages = /* @__PURE__ */ new Map();
4994
+ sources.forEach((source, index) => {
4995
+ const parsed = DeclarativePagePackageSchema.safeParse(source.manifest);
4996
+ if (!parsed.success) {
4997
+ throw new DeclarativePageDeliveryError(
4998
+ "DELIVERY_PACKAGE_INVALID",
4999
+ `Package manifest ${index} is not a DeclarativePagePackage.`,
5000
+ issueLines(parsed.error.issues)
5001
+ );
5002
+ }
5003
+ if (packages.has(parsed.data.domain)) {
5004
+ throw new DeclarativePageDeliveryError(
5005
+ "DELIVERY_PACKAGE_DUPLICATE",
5006
+ `Package ${parsed.data.domain} is declared more than once.`
5007
+ );
5008
+ }
5009
+ packages.set(parsed.data.domain, { manifest: parsed.data, source });
5010
+ });
5011
+ return packages;
5012
+ };
5013
+ var pageIdOf = (document, owner) => {
5014
+ if (!isRecord(document) || typeof document.pageId !== "string" || !document.pageId) {
5015
+ throw new DeclarativePageDeliveryError(
5016
+ "DELIVERY_DOCUMENT_INVALID",
5017
+ `Package ${owner} contains a Page without a pageId.`
5018
+ );
5019
+ }
5020
+ return document.pageId;
5021
+ };
5022
+ var programIdOf = (document, owner) => {
5023
+ const definition = isRecord(document) ? document.definition : void 0;
5024
+ if (!isRecord(definition) || typeof definition.programId !== "string" || !definition.programId) {
5025
+ throw new DeclarativePageDeliveryError(
5026
+ "DELIVERY_DOCUMENT_INVALID",
5027
+ `Package ${owner} contains an ActionProgram artifact without a programId.`
5028
+ );
5029
+ }
5030
+ return definition.programId;
5031
+ };
5032
+ function renderDeclarativePagePackages(input) {
5033
+ const parsedOverlay = DeclarativePageOverlaySchema.safeParse(input.overlay);
5034
+ if (!parsedOverlay.success) {
5035
+ throw new DeclarativePageDeliveryError(
5036
+ "DELIVERY_OVERLAY_INVALID",
5037
+ "The overlay is not a DeclarativePageOverlay.",
5038
+ issueLines(parsedOverlay.error.issues)
5039
+ );
5040
+ }
5041
+ const overlay = parsedOverlay.data;
5042
+ const packages = parsePackages(input.packages);
5043
+ const selected = new Map(overlay.packages.map((entry) => [entry.package, entry]));
5044
+ const closure = /* @__PURE__ */ new Set();
5045
+ const pending = [...selected.keys()];
5046
+ while (pending.length > 0) {
5047
+ const name = pending.pop();
5048
+ if (closure.has(name)) continue;
5049
+ const entry = packages.get(name);
5050
+ if (!entry) {
5051
+ throw new DeclarativePageDeliveryError(
5052
+ "DELIVERY_PACKAGE_UNKNOWN",
5053
+ `Package ${name} is selected or required but was not provided.`
5054
+ );
5055
+ }
5056
+ closure.add(name);
5057
+ pending.push(...entry.manifest.dependsOn);
5058
+ }
5059
+ const closureNames = [...closure].sort();
5060
+ const applicationIds = new Set(
5061
+ closureNames.map((name) => packages.get(name).manifest.applicationId)
5062
+ );
5063
+ if (applicationIds.size !== 1) {
5064
+ throw new DeclarativePageDeliveryError(
5065
+ "DELIVERY_APPLICATION_MISMATCH",
5066
+ "Selected packages and their dependencies must belong to one application.",
5067
+ closureNames.map((name) => `${name}: ${packages.get(name).manifest.applicationId}`)
5068
+ );
5069
+ }
5070
+ const applicationId = [...applicationIds][0];
5071
+ const foreign = closureNames.filter((name) => {
5072
+ const customer = packages.get(name).manifest.customer;
5073
+ return customer !== void 0 && customer !== overlay.customer;
5074
+ });
5075
+ if (foreign.length > 0) {
5076
+ throw new DeclarativePageDeliveryError(
5077
+ "DELIVERY_CUSTOMER_MISMATCH",
5078
+ `Overlay ${overlay.customer}/${overlay.environment} cannot use another customer's packages.`,
5079
+ foreign
5080
+ );
5081
+ }
5082
+ const unbound = /* @__PURE__ */ new Map();
5083
+ const render = (document, label) => {
5084
+ const documentUsed = /* @__PURE__ */ new Set();
5085
+ const documentUnbound = /* @__PURE__ */ new Set();
5086
+ const value = substitute(document, overlay.bindings, documentUsed, documentUnbound);
5087
+ if (documentUnbound.size > 0) unbound.set(label, documentUnbound);
5088
+ return { value, keys: [...documentUsed].sort() };
5089
+ };
5090
+ const pages = {};
5091
+ const pageEntries = [];
5092
+ for (const name of [...selected.keys()].sort()) {
5093
+ const { source } = packages.get(name);
5094
+ const available = /* @__PURE__ */ new Map();
5095
+ for (const document of source.pages ?? []) {
5096
+ const pageId = pageIdOf(document, name);
5097
+ if (available.has(pageId)) {
5098
+ throw new DeclarativePageDeliveryError(
5099
+ "DELIVERY_PAGE_DUPLICATE",
5100
+ `Package ${name} declares Page ${pageId} more than once.`
5101
+ );
5102
+ }
5103
+ available.set(pageId, document);
5104
+ }
5105
+ const wanted = selected.get(name).pages ?? [...available.keys()];
5106
+ const missing = wanted.filter((pageId) => !available.has(pageId));
5107
+ if (missing.length > 0) {
5108
+ throw new DeclarativePageDeliveryError(
5109
+ "DELIVERY_PAGE_UNKNOWN",
5110
+ `Overlay selects Pages that package ${name} does not contain.`,
5111
+ missing
5112
+ );
5113
+ }
5114
+ for (const pageId of [...wanted].sort()) {
5115
+ if (pages[pageId]) {
5116
+ throw new DeclarativePageDeliveryError(
5117
+ "DELIVERY_PAGE_DUPLICATE",
5118
+ `Page ${pageId} is owned by more than one selected package.`
5119
+ );
5120
+ }
5121
+ const rendered = render(available.get(pageId), `page ${pageId}`);
5122
+ const checked = PageSchema.safeParse(rendered.value);
5123
+ if (!checked.success && !unbound.has(`page ${pageId}`)) {
5124
+ throw new DeclarativePageDeliveryError(
5125
+ "DELIVERY_DOCUMENT_INVALID",
5126
+ `Rendered Page ${pageId} is not a valid Page.`,
5127
+ issueLines(checked.error.issues)
5128
+ );
5129
+ }
5130
+ pages[pageId] = rendered.value;
5131
+ const bindings = [];
5132
+ for (const key of rendered.keys) {
5133
+ const binding = overlay.bindings[key];
5134
+ if (binding.kind !== "value") bindings.push({ key, binding });
5135
+ }
5136
+ pageEntries.push({
5137
+ pageId,
5138
+ package: name,
5139
+ contentHash: canonicalContentHash(rendered.value),
5140
+ bindings
5141
+ });
5142
+ }
5143
+ }
5144
+ const programs = {};
5145
+ const programEntries = [];
5146
+ const merged = Object.fromEntries(
5147
+ CATALOG_COLLECTIONS.map((collection) => [collection, []])
5148
+ );
5149
+ for (const name of closureNames) {
5150
+ const { source } = packages.get(name);
5151
+ for (const document of source.programs ?? []) {
5152
+ const programId = programIdOf(document, name);
5153
+ if (programs[programId]) {
5154
+ throw new DeclarativePageDeliveryError(
5155
+ "DELIVERY_PROGRAM_DUPLICATE",
5156
+ `ActionProgram ${programId} is owned by more than one package.`
5157
+ );
5158
+ }
5159
+ const rendered2 = render(document, `program ${programId}`);
5160
+ const checked = ActionProgramArtifactSchema.safeParse(rendered2.value);
5161
+ if (!checked.success && !unbound.has(`program ${programId}`)) {
5162
+ throw new DeclarativePageDeliveryError(
5163
+ "DELIVERY_DOCUMENT_INVALID",
5164
+ `Rendered ActionProgram ${programId} is not a valid artifact.`,
5165
+ issueLines(checked.error.issues)
5166
+ );
5167
+ }
5168
+ programs[programId] = rendered2.value;
5169
+ programEntries.push({
5170
+ programId,
5171
+ package: name,
5172
+ contentHash: canonicalContentHash(rendered2.value)
5173
+ });
5174
+ }
5175
+ if (source.catalog === void 0) continue;
5176
+ const rendered = render(source.catalog, `catalog ${name}`).value;
5177
+ if (!isRecord(rendered) || rendered.applicationId !== applicationId) {
5178
+ throw new DeclarativePageDeliveryError(
5179
+ "DELIVERY_CATALOG_INVALID",
5180
+ `The catalog of package ${name} does not belong to application ${applicationId}.`
5181
+ );
5182
+ }
5183
+ for (const collection of CATALOG_COLLECTIONS) {
5184
+ const entries = rendered[collection];
5185
+ if (entries === void 0) continue;
5186
+ if (!Array.isArray(entries)) {
5187
+ throw new DeclarativePageDeliveryError(
5188
+ "DELIVERY_CATALOG_INVALID",
5189
+ `The catalog of package ${name} has a non-array ${collection}.`
5190
+ );
5191
+ }
5192
+ merged[collection].push(...entries);
5193
+ }
5194
+ }
5195
+ if (unbound.size > 0) {
5196
+ throw new DeclarativePageDeliveryError(
5197
+ "DELIVERY_BINDING_UNBOUND",
5198
+ `Overlay ${overlay.customer}/${overlay.environment} leaves binding keys unbound.`,
5199
+ [...unbound.entries()].slice(0, DETAIL_LIMIT).map(([label, keys]) => `${label}: ${[...keys].sort().join(", ")}`)
5200
+ );
5201
+ }
5202
+ const catalogCandidate = {
5203
+ contract: "ProductDeclarativeAuthoringCatalog",
5204
+ schemaVersion: 1,
5205
+ applicationId,
5206
+ ...merged
5207
+ };
5208
+ const catalog = ProductDeclarativeAuthoringCatalogSchema.safeParse(catalogCandidate);
5209
+ if (!catalog.success) {
5210
+ throw new DeclarativePageDeliveryError(
5211
+ "DELIVERY_CATALOG_INVALID",
5212
+ "The merged package catalogs are not a valid ProductDeclarativeAuthoringCatalog.",
5213
+ issueLines(catalog.error.issues)
5214
+ );
5215
+ }
5216
+ const unsigned = {
5217
+ contract: "DeclarativePageRendering",
5218
+ schemaVersion: 1,
5219
+ customer: overlay.customer,
5220
+ environment: overlay.environment,
5221
+ applicationId,
5222
+ packages: closureNames,
5223
+ pages: pageEntries.sort((left, right) => byText(left.pageId, right.pageId)),
5224
+ programs: programEntries.sort((left, right) => byText(left.programId, right.programId)),
5225
+ catalogContentHash: canonicalContentHash(catalogCandidate)
5226
+ };
5227
+ const rendering = DeclarativePageRenderingSchema.parse({
5228
+ ...unsigned,
5229
+ contentHash: canonicalContentHash(unsigned)
5230
+ });
5231
+ return { rendering, pages, programs, catalog: catalogCandidate };
5232
+ }
5233
+
4826
5234
  // src/runtime/menu-compiler.ts
4827
5235
  var MenuCompilationError = class extends Error {
4828
5236
  constructor(code, path, message) {
@@ -7981,198 +8389,15 @@ function attenuateViewCapabilities(parentCapabilities, requestedCapabilities) {
7981
8389
  );
7982
8390
  }
7983
8391
 
7984
- // src/runtime/bento-render-tree.ts
7985
- function mapContainerLayout(node) {
7986
- const gap = typeof node.gap === "number" ? node.gap : void 0;
7987
- if (node.layout === "grid") {
7988
- return {
7989
- mode: "grid",
7990
- columns: node.columns ?? BENTO_GRID_COLUMNS,
7991
- ...typeof node.rowHeight === "number" ? { rowHeight: node.rowHeight } : {},
7992
- ...gap !== void 0 ? { gap } : {}
7993
- };
7994
- }
7995
- if (node.layout === "split") {
7996
- return {
7997
- mode: "split",
7998
- direction: node.direction === "vertical" ? "column" : "row",
7999
- ...gap !== void 0 ? { gap } : {}
8000
- };
8001
- }
8002
- if (node.layout === "tabs") {
8003
- return {
8004
- mode: "tabs",
8005
- ...gap !== void 0 ? { gap } : {}
8006
- };
8007
- }
8008
- if (node.layout === "floating") {
8009
- return {
8010
- mode: "floating",
8011
- ...node.floating ? { floating: node.floating } : {},
8012
- ...gap !== void 0 ? { gap } : {}
8013
- };
8014
- }
8015
- return {
8016
- mode: "flex",
8017
- direction: node.direction === "horizontal" ? "row" : "column",
8018
- ...gap !== void 0 ? { gap } : {}
8019
- };
8020
- }
8021
- function buildPlacementStyle(node) {
8022
- const style = {};
8023
- const grid = node.placement?.grid;
8024
- if (grid) {
8025
- style.gridColumn = `${grid.x + 1} / span ${grid.w}`;
8026
- style.gridRow = `${grid.y + 1} / span ${grid.h}`;
8027
- }
8028
- const split = node.placement?.split;
8029
- if (split?.size !== void 0) {
8030
- style.flex = typeof split.size === "number" ? `0 0 ${split.size}%` : `0 0 ${split.size}`;
8031
- }
8032
- if (split?.minSize !== void 0) {
8033
- style.minWidth = typeof split.minSize === "number" ? `${split.minSize}px` : split.minSize;
8034
- }
8035
- if (split?.maxSize !== void 0) {
8036
- style.maxWidth = typeof split.maxSize === "number" ? `${split.maxSize}px` : split.maxSize;
8037
- }
8038
- return Object.keys(style).length > 0 ? style : void 0;
8039
- }
8040
- function mapLeafDataBinding(node, data) {
8041
- const source = node.block.dataSource;
8042
- if (!source || source.kind === "static") return void 0;
8043
- if (source.kind === "statement") {
8044
- const inlineStatement = data?.statements?.[source.statementId];
8045
- return inlineStatement ?? { kind: "statement", statementId: source.statementId };
8046
- }
8047
- if (source.kind === "ontology-relation" || source.kind === "ontology-action" || source.kind === "artifact.body" || source.kind === "record.fields" || source.kind === "navigation" || source.kind === "workflow" || source.kind === "command") {
8048
- return source;
8049
- }
8050
- return void 0;
8051
- }
8052
- function compileBentoNodeToRenderTree(root, options) {
8053
- const product = options.product ?? "studio";
8054
- const ownerRepo = options.ownerRepo ?? "monkeys-sdk";
8055
- const pageId = options.pageId ?? options.treeId;
8056
- const nodes = [];
8057
- const visit = (node, parentNodeId, inheritedData) => {
8058
- const effectiveData = node.kind === "container" && node.data ? node.data : inheritedData;
8059
- const chrome = node.chrome ?? (node.kind === "leaf" ? "panel" : "none");
8060
- const style = buildPlacementStyle(node);
8061
- const common = {
8062
- contract: "RenderNode",
8063
- nodeId: node.id,
8064
- version: 1,
8065
- ownerRepo,
8066
- ...parentNodeId ? { parentNodeId } : {},
8067
- pageRef: { kind: "page", id: pageId },
8068
- capabilityRef: {
8069
- kind: "capability",
8070
- id: node.kind === "leaf" ? `monkeys.bento.block.${node.block.customType ?? node.block.type}` : `monkeys.bento.container.${node.layout}`,
8071
- version: 1,
8072
- ownerRepo
8073
- },
8074
- surface: {
8075
- frameOwner: chrome === "none" ? "none" : "host",
8076
- density: "default",
8077
- ...chrome !== "none" ? { bento: { chrome } } : {}
8078
- },
8079
- scroll: {
8080
- owner: "surface",
8081
- axis: "none",
8082
- virtualizationBoundary: false
8083
- },
8084
- activation: {
8085
- activationId: node.id,
8086
- mode: "inline"
8087
- },
8088
- lifecycle: {
8089
- mountPolicy: "always",
8090
- queryPolicy: "always",
8091
- retainOnDeactivate: true,
8092
- deepLink: false,
8093
- focusReturn: false
8094
- },
8095
- ...node.placement ? { placement: node.placement } : {},
8096
- ...node.dynamicLayout ? { dynamicLayout: node.dynamicLayout } : {},
8097
- ...style ? { style } : {},
8098
- responsive: [],
8099
- state: "idle"
8100
- };
8101
- if (node.kind === "container") {
8102
- nodes.push({
8103
- ...common,
8104
- kind: parentNodeId ? "view" : "page",
8105
- children: node.children.map((child) => child.id),
8106
- layout: mapContainerLayout(node),
8107
- ...node.wiring ? { wiring: node.wiring } : {},
8108
- renderModel: {
8109
- bentoKind: "container",
8110
- layout: node.layout,
8111
- ...node.direction ? { direction: node.direction } : {},
8112
- ...node.floating ? { floating: node.floating } : {},
8113
- ...node.title ? { title: node.title } : {},
8114
- ...node.description ? { description: node.description } : {},
8115
- ...node.wiring ? { wiring: node.wiring } : {}
8116
- }
8117
- });
8118
- for (const child of node.children) {
8119
- visit(child, node.id, effectiveData);
8120
- }
8121
- return;
8122
- }
8123
- const dataBinding = mapLeafDataBinding(node, effectiveData);
8124
- const moduleId = node.block.customType ?? node.block.type;
8125
- nodes.push({
8126
- ...common,
8127
- kind: "view",
8128
- children: [],
8129
- layout: { mode: "block" },
8130
- ...dataBinding ? { dataBinding } : {},
8131
- module: {
8132
- id: moduleId,
8133
- granularity: "atomic",
8134
- ...node.block.title ? { title: node.block.title } : {},
8135
- ...node.block.config ? { props: node.block.config } : {}
8136
- },
8137
- renderModel: {
8138
- bentoKind: "leaf",
8139
- blockType: node.block.type,
8140
- ...node.block.customType ? { customType: node.block.customType } : {},
8141
- ...node.block.title ? { title: node.block.title } : {},
8142
- ...node.block.dataSource ? { dataSource: node.block.dataSource } : {},
8143
- ...node.block.actionStatementIds ? { actionStatementIds: node.block.actionStatementIds } : {},
8144
- ...node.block.config ? { config: node.block.config } : {}
8145
- }
8146
- });
8147
- };
8148
- visit(root, void 0, options.data);
8149
- return RenderTreeSchema.parse({
8150
- contract: "RenderTree",
8151
- treeId: options.treeId,
8152
- product,
8153
- rootNodeId: root.id,
8154
- ...options.data ? { data: options.data } : {},
8155
- nodes
8156
- });
8157
- }
8158
- function compileViewRecordToRenderTree(record2, options) {
8159
- return compileBentoNodeToRenderTree(record2.root, {
8160
- treeId: record2.viewId,
8161
- pageId: record2.viewId,
8162
- product: options?.product ?? "studio",
8163
- ownerRepo: options?.ownerRepo ?? "monkeys-sdk",
8164
- data: record2.data
8165
- });
8166
- }
8167
-
8168
8392
  export {
8169
8393
  extractOpenApiCapabilityManifests,
8170
8394
  createCapabilityRegistrySource,
8171
8395
  createOpenApiCapabilityRegistrySource,
8172
8396
  createWorkflowCapabilityManifest,
8173
8397
  compileCapabilityRegistry,
8398
+ compileBentoNodeToRenderTree,
8399
+ compileViewRecordToRenderTree,
8174
8400
  buildArtifactCollabRoomId,
8175
- compileBentoTreeToRenderTree,
8176
8401
  createArtifactRegistry,
8177
8402
  createAgentSessionEventProjection,
8178
8403
  projectAgentSessionEvents,
@@ -8226,6 +8451,9 @@ export {
8226
8451
  assertProgramRegistration,
8227
8452
  projectCurrentNavigationPages,
8228
8453
  normalizeDeclarativeReferences,
8454
+ DeclarativePageDeliveryError,
8455
+ collectDeclarativePageBindingKeys,
8456
+ renderDeclarativePagePackages,
8229
8457
  MenuCompilationError,
8230
8458
  resolveMenuActivationId,
8231
8459
  readMenuActivationFromSearch,
@@ -8314,8 +8542,6 @@ export {
8314
8542
  createSingleBlockViewRecord,
8315
8543
  createSelectionShareViewRecord,
8316
8544
  createWorkflowViewRecord,
8317
- attenuateViewCapabilities,
8318
- compileBentoNodeToRenderTree,
8319
- compileViewRecordToRenderTree
8545
+ attenuateViewCapabilities
8320
8546
  };
8321
- //# sourceMappingURL=chunk-JEAEX7QG.mjs.map
8547
+ //# sourceMappingURL=chunk-WIGX4I2M.mjs.map