@inf-monkeys-tech/monkeys 1.1.8 → 1.1.10

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.
@@ -20089,6 +20089,103 @@ var RecordEditorSubmissionSnapshotSchema = z26.object({
20089
20089
  value: JsonObjectSchema
20090
20090
  }).strict();
20091
20091
 
20092
+ // src/contracts/declarative-document-import.ts
20093
+ import { z as z27 } from "zod";
20094
+ var sameScope = (left, right) => ["tenantRef", "dataSpaceRef", "teamRef"].every(
20095
+ (key) => left[key]?.kind === right[key]?.kind && left[key]?.id === right[key]?.id && left[key]?.ownerRepo === right[key]?.ownerRepo
20096
+ );
20097
+ var DeclarativeImportDocumentSchema = z27.union([
20098
+ PageSchema,
20099
+ NavigationSchema
20100
+ ]);
20101
+ var requestShape = {
20102
+ document: DeclarativeImportDocumentSchema,
20103
+ surface: ProductSurfaceSchema,
20104
+ environmentId: ContractIdentifierSchema.optional()
20105
+ };
20106
+ function supportsSurface(value) {
20107
+ return value.document.contract === "Page" ? value.document.surface === value.surface : value.document.supportedSurfaces.includes(value.surface);
20108
+ }
20109
+ var DeclarativeDocumentImportRequestSchema = z27.object(requestShape).strict().refine(supportsSurface, {
20110
+ path: ["surface"],
20111
+ message: "The document does not support the selected surface."
20112
+ });
20113
+ var DeclarativeDocumentImportIntentSchema = z27.object({
20114
+ ...requestShape,
20115
+ expectedVersion: z27.number().int().nonnegative(),
20116
+ expectedPlanHash: Sha256Schema,
20117
+ idempotencyKey: z27.string().trim().min(1).max(256)
20118
+ }).strict().refine(supportsSurface, {
20119
+ path: ["surface"],
20120
+ message: "The document does not support the selected surface."
20121
+ });
20122
+ var DeclarativeDocumentImportPlanSchema = z27.object({
20123
+ contract: z27.literal("DeclarativeDocumentImportPlan"),
20124
+ schemaVersion: z27.literal(1),
20125
+ resourceKind: z27.enum(["page", "navigation"]),
20126
+ resourceId: ContractIdentifierSchema,
20127
+ surface: ProductSurfaceSchema,
20128
+ sourceContentHash: Sha256Schema,
20129
+ environmentRevisionRef: RevisionRefSchema,
20130
+ document: DeclarativeImportDocumentSchema,
20131
+ tenantScope: TenantScopeSchema.nullable(),
20132
+ requiresInitialization: z27.boolean(),
20133
+ expectedVersion: z27.number().int().nonnegative(),
20134
+ currentContentHash: Sha256Schema.nullable(),
20135
+ changed: z27.boolean(),
20136
+ diagnostics: z27.array(
20137
+ z27.object({
20138
+ code: z27.string().min(1),
20139
+ path: z27.string(),
20140
+ message: z27.string(),
20141
+ blocking: z27.boolean()
20142
+ }).strict()
20143
+ ),
20144
+ dependencyContentHash: Sha256Schema,
20145
+ planHash: Sha256Schema
20146
+ }).strict().superRefine((value, context) => {
20147
+ const kind = value.document.contract === "Page" ? "page" : "navigation";
20148
+ const id = value.document.contract === "Page" ? value.document.pageId : value.document.navigationId;
20149
+ if (kind !== value.resourceKind || id !== value.resourceId || !supportsSurface(value))
20150
+ context.addIssue({
20151
+ code: "custom",
20152
+ path: ["document"],
20153
+ message: "The plan must identify its document and supported surface."
20154
+ });
20155
+ if (value.requiresInitialization !== (value.tenantScope === null))
20156
+ context.addIssue({
20157
+ code: "custom",
20158
+ path: ["requiresInitialization"],
20159
+ message: "Only an uninitialized target may omit tenantScope."
20160
+ });
20161
+ if (value.environmentRevisionRef.kind !== "environment")
20162
+ context.addIssue({
20163
+ code: "custom",
20164
+ path: ["environmentRevisionRef"],
20165
+ message: "The import plan must pin an environment revision."
20166
+ });
20167
+ if (value.tenantScope && !sameScope(value.tenantScope, value.document.tenantScope))
20168
+ context.addIssue({
20169
+ code: "custom",
20170
+ path: ["tenantScope"],
20171
+ message: "The plan and bound document must belong to the same scope."
20172
+ });
20173
+ });
20174
+ var DeclarativeDocumentImportResultSchema = z27.object({
20175
+ action: z27.literal("import"),
20176
+ changed: z27.boolean(),
20177
+ plan: DeclarativeDocumentImportPlanSchema,
20178
+ revisionRef: RevisionRefSchema
20179
+ }).strict().superRefine((value, context) => {
20180
+ if (value.changed !== value.plan.changed || value.revisionRef.kind !== value.plan.resourceKind || value.revisionRef.id !== value.plan.resourceId || value.revisionRef.revision !== value.plan.expectedVersion + Number(value.changed) || !value.revisionRef.tenantScope || !sameScope(value.revisionRef.tenantScope, value.plan.document.tenantScope)) {
20181
+ context.addIssue({
20182
+ code: "custom",
20183
+ path: ["revisionRef"],
20184
+ message: "The import result must identify the exact saved or unchanged draft revision."
20185
+ });
20186
+ }
20187
+ });
20188
+
20092
20189
  // src/schemas/index.ts
20093
20190
  var canonicalContractSchemas = {
20094
20191
  "aggregate-commit-request": AggregateCommitRequestSchema,
@@ -20312,6 +20409,11 @@ export {
20312
20409
  DeclarativeAuthoringResourcePageQuerySchema,
20313
20410
  DeclarativeAuthoringResourcePageSchema,
20314
20411
  DeclarativeControlOntologyDefinitionSchema,
20412
+ DeclarativeDocumentImportIntentSchema,
20413
+ DeclarativeDocumentImportPlanSchema,
20414
+ DeclarativeDocumentImportRequestSchema,
20415
+ DeclarativeDocumentImportResultSchema,
20416
+ DeclarativeImportDocumentSchema,
20315
20417
  DeclarativeLifecycleSchema,
20316
20418
  DeclarativeRouteClaimSchema,
20317
20419
  DeclarativeRouteOwnerIndexSchema,