@slicemachine/manager 0.24.15-beta.6 → 0.24.15-beta.7

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.
@@ -80,12 +80,109 @@ class CustomTypesManager extends BaseManager.BaseManager {
80
80
  errors: errors2
81
81
  };
82
82
  }
83
+ /**
84
+ * Update the Content Relationship API IDs for all existing custom types and
85
+ * slices. The change is determined by properties inside the `updateMeta`
86
+ * property.
87
+ */
88
+ async updateContentRelationships(args) {
89
+ assertPluginsInitialized.assertPluginsInitialized(this.sliceMachinePluginRunner);
90
+ const { model } = args;
91
+ let { newPath, previousPath } = args;
92
+ if (previousPath.join(".") !== newPath.join(".")) {
93
+ previousPath = [model.id, ...previousPath];
94
+ newPath = [model.id, ...newPath];
95
+ const crUpdates = [];
96
+ const customTypes = await this.readAllCustomTypes();
97
+ updateCustomTypeContentRelationships({
98
+ models: customTypes.models,
99
+ onUpdate: ({ previousModel, model: updatedModel }) => {
100
+ var _a;
101
+ assertPluginsInitialized.assertPluginsInitialized(this.sliceMachinePluginRunner);
102
+ crUpdates.push({
103
+ updatePromise: (_a = this.sliceMachinePluginRunner) == null ? void 0 : _a.callHook("custom-type:update", { model: updatedModel }),
104
+ rollback: () => {
105
+ var _a2;
106
+ (_a2 = this.sliceMachinePluginRunner) == null ? void 0 : _a2.callHook("custom-type:update", {
107
+ model: previousModel
108
+ });
109
+ }
110
+ });
111
+ },
112
+ previousPath,
113
+ newPath
114
+ });
115
+ const { libraries } = await this.slices.readAllSliceLibraries();
116
+ for (const library of libraries) {
117
+ const slices = await this.slices.readAllSlicesForLibrary({
118
+ libraryID: library.libraryID
119
+ });
120
+ updateSharedSliceContentRelationships({
121
+ models: slices.models,
122
+ onUpdate: ({ previousModel, model: updatedModel }) => {
123
+ var _a;
124
+ assertPluginsInitialized.assertPluginsInitialized(this.sliceMachinePluginRunner);
125
+ crUpdates.push({
126
+ updatePromise: (_a = this.sliceMachinePluginRunner) == null ? void 0 : _a.callHook("slice:update", { libraryID: library.libraryID, model: updatedModel }),
127
+ rollback: () => {
128
+ var _a2;
129
+ (_a2 = this.sliceMachinePluginRunner) == null ? void 0 : _a2.callHook("slice:update", {
130
+ libraryID: library.libraryID,
131
+ model: previousModel
132
+ });
133
+ }
134
+ });
135
+ },
136
+ previousPath,
137
+ newPath
138
+ });
139
+ }
140
+ const crUpdatesResult = await Promise.all(crUpdates.map((update) => update.updatePromise));
141
+ if (crUpdatesResult.some((result) => result.errors.length > 0)) {
142
+ return {
143
+ errors: crUpdatesResult.flatMap((result) => result.errors),
144
+ rollback: async () => {
145
+ await Promise.all(crUpdates.map((update) => update.rollback()));
146
+ }
147
+ };
148
+ }
149
+ }
150
+ return { errors: [] };
151
+ }
83
152
  async updateCustomType(args) {
153
+ var _a, _b;
84
154
  assertPluginsInitialized.assertPluginsInitialized(this.sliceMachinePluginRunner);
85
- const hookResult = await this.sliceMachinePluginRunner.callHook("custom-type:update", args);
86
- return {
87
- errors: hookResult.errors
88
- };
155
+ const { model } = args;
156
+ const { fieldIdChanged } = args.updateMeta ?? {};
157
+ let previousCustomType;
158
+ if (fieldIdChanged) {
159
+ const customTypeRead = await this.readCustomType({ id: model.id });
160
+ if (customTypeRead.errors.length > 0) {
161
+ return { errors: customTypeRead.errors };
162
+ }
163
+ if (!customTypeRead.model) {
164
+ throw new Error(`readCustomType succeeded reading custom type ${model.id} but model is undefined.`);
165
+ }
166
+ previousCustomType = customTypeRead.model;
167
+ }
168
+ const customTypeUpdateResult = await this.sliceMachinePluginRunner.callHook("custom-type:update", { model });
169
+ if (customTypeUpdateResult.errors.length > 0) {
170
+ return { errors: customTypeUpdateResult.errors };
171
+ }
172
+ if (previousCustomType && fieldIdChanged) {
173
+ const crUpdateResult = await this.updateContentRelationships({
174
+ ...fieldIdChanged,
175
+ model: previousCustomType
176
+ });
177
+ if (crUpdateResult.errors.length > 0) {
178
+ await ((_a = this.sliceMachinePluginRunner) == null ? void 0 : _a.callHook("custom-type:update", {
179
+ model: previousCustomType
180
+ }));
181
+ await ((_b = crUpdateResult.rollback) == null ? void 0 : _b.call(crUpdateResult));
182
+ return { errors: crUpdateResult.errors };
183
+ }
184
+ }
185
+ return { errors: [] };
89
186
  }
90
187
  async renameCustomType(args) {
91
188
  assertPluginsInitialized.assertPluginsInitialized(this.sliceMachinePluginRunner);
@@ -231,5 +328,117 @@ const InferSliceResponse = index.default.object({
231
328
  }),
232
329
  langSmithUrl: index.default.string().url().optional()
233
330
  });
331
+ function updateCRCustomType(args) {
332
+ const [previousCustomTypeId, previousFieldId] = args.previousPath;
333
+ const [newCustomTypeId, newFieldId] = args.newPath;
334
+ if (!previousCustomTypeId || !newCustomTypeId) {
335
+ throw new Error("Could not find a customtype id in previousPath and/or newPath, which should not be possible.");
336
+ }
337
+ if (!previousFieldId || !newFieldId) {
338
+ throw new Error("Could not find a field id in previousPath and/or newPath, which should not be possible.");
339
+ }
340
+ const customType = shallowCloneIfObject(args.customType);
341
+ if (typeof customType === "string" || !customType.fields) {
342
+ return customType;
343
+ }
344
+ const matchedCustomTypeId = customType.id === previousCustomTypeId;
345
+ const newFields = customType.fields.map((fieldArg) => {
346
+ const customTypeField = shallowCloneIfObject(fieldArg);
347
+ if (typeof customTypeField === "string") {
348
+ if (matchedCustomTypeId && customTypeField === previousFieldId && customTypeField !== newFieldId) {
349
+ return newFieldId;
350
+ }
351
+ return customTypeField;
352
+ }
353
+ if (matchedCustomTypeId && customTypeField.id === previousFieldId && customTypeField.id !== newFieldId) {
354
+ customTypeField.id = newFieldId;
355
+ }
356
+ return {
357
+ ...customTypeField,
358
+ customtypes: customTypeField.customtypes.map((customTypeArg) => {
359
+ const nestedCustomType = shallowCloneIfObject(customTypeArg);
360
+ if (typeof nestedCustomType === "string" || !nestedCustomType.fields || // Since we are on the last level, if we don't start matching right
361
+ // at the custom type id, we can return exit early because it's not
362
+ // a match.
363
+ nestedCustomType.id !== previousCustomTypeId) {
364
+ return nestedCustomType;
365
+ }
366
+ return {
367
+ ...nestedCustomType,
368
+ fields: nestedCustomType.fields.map((fieldArg2) => {
369
+ const nestedCustomTypeField = shallowCloneIfObject(fieldArg2);
370
+ if (nestedCustomTypeField === previousFieldId && nestedCustomTypeField !== newFieldId) {
371
+ return newFieldId;
372
+ }
373
+ return nestedCustomTypeField;
374
+ })
375
+ };
376
+ })
377
+ };
378
+ });
379
+ return { ...customType, fields: newFields };
380
+ }
381
+ function updateFieldContentRelationships(args) {
382
+ var _a, _b;
383
+ const { field, ...updateMeta } = args;
384
+ if (field.type !== "Link" || ((_a = field.config) == null ? void 0 : _a.select) !== "document" || !((_b = field.config) == null ? void 0 : _b.customtypes)) {
385
+ return field;
386
+ }
387
+ const newCustomTypes = field.config.customtypes.map((customType) => {
388
+ return updateCRCustomType({ customType, ...updateMeta });
389
+ });
390
+ return {
391
+ ...field,
392
+ config: { ...field.config, customtypes: newCustomTypes }
393
+ };
394
+ }
395
+ function updateCustomTypeContentRelationships(args) {
396
+ const { models, previousPath, newPath, onUpdate } = args;
397
+ for (const { model: customType } of models) {
398
+ const updatedCustomType = customtypes.traverseCustomType({
399
+ customType,
400
+ onField: ({ field }) => {
401
+ return updateFieldContentRelationships({
402
+ field,
403
+ previousPath,
404
+ newPath
405
+ });
406
+ }
407
+ });
408
+ if (!isEqualModel(customType, updatedCustomType)) {
409
+ onUpdate({ model: updatedCustomType, previousModel: customType });
410
+ }
411
+ }
412
+ }
413
+ function updateSharedSliceContentRelationships(args) {
414
+ const { models, previousPath, newPath, onUpdate } = args;
415
+ for (const { model: slice } of models) {
416
+ const updateSlice = customtypes.traverseSharedSlice({
417
+ path: ["."],
418
+ slice,
419
+ onField: ({ field }) => {
420
+ return updateFieldContentRelationships({
421
+ field,
422
+ previousPath,
423
+ newPath
424
+ });
425
+ }
426
+ });
427
+ if (!isEqualModel(slice, updateSlice)) {
428
+ onUpdate({ model: updateSlice, previousModel: slice });
429
+ }
430
+ }
431
+ }
432
+ function isEqualModel(modelA, modelB) {
433
+ return JSON.stringify(modelA) === JSON.stringify(modelB);
434
+ }
435
+ function shallowCloneIfObject(value) {
436
+ if (typeof value === "object") {
437
+ return { ...value };
438
+ }
439
+ return value;
440
+ }
234
441
  exports.CustomTypesManager = CustomTypesManager;
442
+ exports.updateCustomTypeContentRelationships = updateCustomTypeContentRelationships;
443
+ exports.updateSharedSliceContentRelationships = updateSharedSliceContentRelationships;
235
444
  //# sourceMappingURL=CustomTypesManager.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CustomTypesManager.cjs","sources":["../../../../src/managers/customTypes/CustomTypesManager.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport {\n\tCustomType,\n\tSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport {\n\tCallHookReturnType,\n\tCustomTypeCreateHook,\n\tCustomTypeCreateHookData,\n\tCustomTypeReadHookData,\n\tCustomTypeRenameHook,\n\tCustomTypeRenameHookData,\n\tCustomTypeUpdateHook,\n\tCustomTypeUpdateHookData,\n\tHookError,\n} from \"@slicemachine/plugin-kit\";\nimport { z } from \"zod\";\n\nimport { DecodeError } from \"../../lib/DecodeError\";\nimport { assertPluginsInitialized } from \"../../lib/assertPluginsInitialized\";\nimport { decodeHookResult } from \"../../lib/decodeHookResult\";\nimport fetch from \"../../lib/fetch\";\n\nimport { OnlyHookErrors } from \"../../types\";\nimport { API_ENDPOINTS } from \"../../constants/API_ENDPOINTS\";\nimport { SLICE_MACHINE_USER_AGENT } from \"../../constants/SLICE_MACHINE_USER_AGENT\";\nimport { UnauthorizedError } from \"../../errors\";\n\nimport { BaseManager } from \"../BaseManager\";\nimport { CustomTypeFormat } from \"./types\";\n\ntype SliceMachineManagerReadCustomTypeLibraryReturnType = {\n\tids: string[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypesManagerReadAllCustomTypesArgs = {\n\tformat: CustomTypeFormat;\n};\n\ntype SliceMachineManagerReadAllCustomTypeReturnType = {\n\tmodels: { model: CustomType }[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadCustomTypeReturnType = {\n\tmodel: CustomType | undefined;\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerPushCustomTypeArgs = {\n\tid: string;\n\tuserAgent?: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType = {\n\t// TODO\n\tmocksConfig?: Record<string, unknown>;\n\terrors: HookError[];\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n\t// TODO\n\tmocksConfig: Record<string, unknown>;\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType = {\n\terrors: HookError[];\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeArgs = {\n\tid: string;\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\nexport class CustomTypesManager extends BaseManager {\n\tasync readCustomTypeLibrary(): Promise<SliceMachineManagerReadCustomTypeLibraryReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type-library:read\",\n\t\t\tundefined,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tids: t.array(t.string),\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tids: data[0]?.ids || [],\n\t\t\terrors,\n\t\t};\n\t}\n\n\tasync readAllCustomTypes(\n\t\targs?: CustomTypesManagerReadAllCustomTypesArgs,\n\t): Promise<SliceMachineManagerReadAllCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst res: SliceMachineManagerReadAllCustomTypeReturnType = {\n\t\t\tmodels: [],\n\t\t\terrors: [],\n\t\t};\n\n\t\tconst { ids, errors } = await this.readCustomTypeLibrary();\n\t\tres.errors = [...res.errors, ...errors];\n\n\t\tif (ids) {\n\t\t\tfor (const id of ids) {\n\t\t\t\tconst { model, errors } = await this.readCustomType({ id });\n\t\t\t\tres.errors = [...res.errors, ...errors];\n\n\t\t\t\tif (model && (!args || args.format === model.format)) {\n\t\t\t\t\tres.models.push({ model });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync createCustomType(\n\t\targs: CustomTypeCreateHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeCreateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:create\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync readCustomType(\n\t\targs: CustomTypeReadHookData,\n\t): Promise<SliceMachineManagerReadCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:read\",\n\t\t\targs,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tmodel: CustomType,\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tmodel: data[0]?.model,\n\t\t\terrors,\n\t\t};\n\t}\n\n\tasync updateCustomType(\n\t\targs: CustomTypeUpdateHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeUpdateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:update\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync renameCustomType(\n\t\targs: CustomTypeRenameHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeRenameHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:rename\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync deleteCustomType(\n\t\targs: CustomTypesMachineManagerDeleteCustomTypeArgs,\n\t): Promise<CustomTypesMachineManagerDeleteCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { model, errors: readCustomTypeErrors } = await this.readCustomType({\n\t\t\tid: args.id,\n\t\t});\n\n\t\tif (model) {\n\t\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\t\"custom-type:delete\",\n\t\t\t\t{ model },\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\terrors: readCustomTypeErrors,\n\t\t\t};\n\t\t}\n\t}\n\n\tasync pushCustomType(\n\t\targs: SliceMachineManagerPushCustomTypeArgs,\n\t): Promise<void> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\t// TODO: Handle errors\n\t\tconst { model } = await this.readCustomType({ id: args.id });\n\n\t\tif (model) {\n\t\t\t// TODO: Create a single shared client.\n\t\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\t\trepositoryName,\n\t\t\t\ttoken: authenticationToken,\n\t\t\t\tfetch,\n\t\t\t\tfetchOptions: {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"User-Agent\": args.userAgent || SLICE_MACHINE_USER_AGENT,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\n\t\t\ttry {\n\t\t\t\t// Check if Custom Type already exists on the repository.\n\t\t\t\tawait client.getCustomTypeByID(args.id);\n\n\t\t\t\t// If it exists on the repository, update it.\n\t\t\t\tawait client.updateCustomType(model);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof prismicCustomTypesClient.NotFoundError) {\n\t\t\t\t\t// If it doesn't exist on the repository, insert it.\n\t\t\t\t\tawait client.insertCustomType(model);\n\t\t\t\t} else if (error instanceof prismicCustomTypesClient.ForbiddenError) {\n\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\"You do not have access to push types to this Prismic repository.\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync readCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerReadCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:read\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tassetID: \"mocks.config.json\",\n\t\t\t},\n\t\t);\n\t\tconst data = hookResult.data[0]?.data;\n\n\t\t// TODO: Validate the returned data.\n\n\t\tif (data) {\n\t\t\treturn {\n\t\t\t\tmocksConfig: JSON.parse(data.toString()),\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tmocksConfig: undefined,\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync updateCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerUpdateCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:update\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tasset: {\n\t\t\t\t\tid: \"mocks.config.json\",\n\t\t\t\t\tdata: Buffer.from(JSON.stringify(args.mocksConfig, null, \"\\t\")),\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync fetchRemoteCustomTypes(): Promise<CustomType[]> {\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\trepositoryName,\n\t\t\ttoken: authenticationToken,\n\t\t\tfetch,\n\t\t\tfetchOptions: {\n\t\t\t\theaders: {\n\t\t\t\t\t\"User-Agent\": SLICE_MACHINE_USER_AGENT,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\treturn await client.getAllCustomTypes();\n\t}\n\n\tasync inferSlice({\n\t\timageUrl,\n\t}: {\n\t\timageUrl: string;\n\t}): Promise<InferSliceResponse> {\n\t\tconst authToken = await this.user.getAuthenticationToken();\n\t\tconst headers = {\n\t\t\tAuthorization: `Bearer ${authToken}`,\n\t\t};\n\n\t\tconst repository = await this.project.getResolvedRepositoryName();\n\t\tconst searchParams = new URLSearchParams({\n\t\t\trepository,\n\t\t});\n\n\t\tconst url = new URL(\"./slices/infer\", API_ENDPOINTS.CustomTypeService);\n\t\turl.search = searchParams.toString();\n\n\t\tconst response = await fetch(url.toString(), {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: headers,\n\t\t\tbody: JSON.stringify({ imageUrl }),\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(`Failed to infer slice: ${response.statusText}`);\n\t\t}\n\n\t\tconst json = await response.json();\n\n\t\treturn InferSliceResponse.parse(json);\n\t}\n}\n\ntype InferSliceResponse = z.infer<typeof InferSliceResponse>;\n\nconst InferSliceResponse = z.object({\n\tslice: z.custom().transform((value, ctx) => {\n\t\tconst result = SharedSlice.decode(value);\n\t\tif (result._tag === \"Right\") {\n\t\t\treturn result.right;\n\t\t}\n\t\tctx.addIssue({\n\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\tmessage: `Invalid shared slice: ${JSON.stringify(value, null, 2)}`,\n\t\t});\n\n\t\treturn z.NEVER;\n\t}),\n\tlangSmithUrl: z.string().url().optional(),\n});\n"],"names":["BaseManager","assertPluginsInitialized","errors","decodeHookResult","t","CustomType","prismicCustomTypesClient","API_ENDPOINTS","fetch","SLICE_MACHINE_USER_AGENT","UnauthorizedError","z","SharedSlice"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFM,MAAO,2BAA2BA,YAAAA,YAAW;AAAA,EAClD,MAAM,wBAAqB;;AAC1BC,sDAAyB,KAAK,wBAAwB;AAEtD,UAAM,aAAa,MAAM,KAAK,yBAAyB,SACtD,4BACA,MAAS;AAEV,UAAM,EAAE,MAAM,QAAAC,QAAA,IAAWC,iBAAAA,iBACxBC,aAAE,KAAK;AAAA,MACN,KAAKA,aAAE,MAAMA,aAAE,MAAM;AAAA,IAAA,CACrB,GACD,UAAU;AAGJ,WAAA;AAAA,MACN,OAAK,UAAK,CAAC,MAAN,mBAAS,QAAO,CAAE;AAAA,MACvB,QAAAF;AAAA,IAAA;AAAA,EAEF;AAAA,EAEA,MAAM,mBACL,MAA+C;AAE/CD,sDAAyB,KAAK,wBAAwB;AAEtD,UAAM,MAAsD;AAAA,MAC3D,QAAQ,CAAE;AAAA,MACV,QAAQ,CAAE;AAAA,IAAA;AAGX,UAAM,EAAE,KAAK,QAAAC,QAAA,IAAW,MAAM,KAAK,sBA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sB;AACxD,UAAM,UAAU;AAAA,MACf,eAAe,UAAU;AAAA,IAAA;AAG1B,UAAM,aAAa,MAAM,KAAK,QAAQ,0BAAyB;AACzD,UAAA,eAAe,IAAI,gBAAgB;AAAA,MACxC;AAAA,IAAA,CACA;AAED,UAAM,MAAM,IAAI,IAAI,kBAAkBF,4BAAc,iBAAiB;AACjE,QAAA,SAAS,aAAa;AAE1B,UAAM,WAAW,MAAMC,MAAAA,QAAM,IAAI,YAAY;AAAA,MAC5C,QAAQ;AAAA,MACR;AAAA,MACA,MAAM,KAAK,UAAU,EAAE,UAAU;AAAA,IAAA,CACjC;AAEG,QAAA,CAAC,SAAS,IAAI;AACjB,YAAM,IAAI,MAAM,0BAA0B,SAAS,YAAY;AAAA,IAChE;AAEM,UAAA,OAAO,MAAM,SAAS;AAErB,WAAA,mBAAmB,MAAM,IAAI;AAAA,EACrC;AACA;AAID,MAAM,qBAAqBG,cAAE,OAAO;AAAA,EACnC,OAAOA,MAAE,QAAA,OAAA,EAAS,UAAU,CAAC,OAAO,QAAO;AACpC,UAAA,SAASC,YAAAA,YAAY,OAAO,KAAK;AACnC,QAAA,OAAO,SAAS,SAAS;AAC5B,aAAO,OAAO;AAAA,IACf;AACA,QAAI,SAAS;AAAA,MACZ,MAAMD,MAAAA,QAAE,aAAa;AAAA,MACrB,SAAS,yBAAyB,KAAK,UAAU,OAAO,MAAM,CAAC;AAAA,IAAA,CAC/D;AAED,WAAOA,MAAAA,QAAE;AAAA,EAAA,CACT;AAAA,EACD,cAAcA,MAAAA,QAAE,OAAS,EAAA,IAAA,EAAM,SAAU;AACzC,CAAA;;"}
1
+ {"version":3,"file":"CustomTypesManager.cjs","sources":["../../../../src/managers/customTypes/CustomTypesManager.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport {\n\tCustomType,\n\tGroup,\n\tNestableWidget,\n\tNestedGroup,\n\tSharedSlice,\n\tUID,\n\ttraverseCustomType,\n\ttraverseSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport {\n\tCallHookReturnType,\n\tCustomTypeCreateHook,\n\tCustomTypeCreateHookData,\n\tCustomTypeReadHookData,\n\tCustomTypeRenameHook,\n\tCustomTypeRenameHookData,\n\tCustomTypeUpdateHook,\n\tCustomTypeUpdateHookData,\n\tHookError,\n} from \"@slicemachine/plugin-kit\";\nimport { z } from \"zod\";\n\nimport { DecodeError } from \"../../lib/DecodeError\";\nimport { assertPluginsInitialized } from \"../../lib/assertPluginsInitialized\";\nimport { decodeHookResult } from \"../../lib/decodeHookResult\";\nimport fetch from \"../../lib/fetch\";\n\nimport { OnlyHookErrors } from \"../../types\";\nimport { API_ENDPOINTS } from \"../../constants/API_ENDPOINTS\";\nimport { SLICE_MACHINE_USER_AGENT } from \"../../constants/SLICE_MACHINE_USER_AGENT\";\nimport { UnauthorizedError } from \"../../errors\";\n\nimport { BaseManager } from \"../BaseManager\";\nimport { CustomTypeFormat } from \"./types\";\n\ntype SliceMachineManagerReadCustomTypeLibraryReturnType = {\n\tids: string[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypesManagerReadAllCustomTypesArgs = {\n\tformat: CustomTypeFormat;\n};\n\ntype SliceMachineManagerReadAllCustomTypeReturnType = {\n\tmodels: { model: CustomType }[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadCustomTypeReturnType = {\n\tmodel: CustomType | undefined;\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerPushCustomTypeArgs = {\n\tid: string;\n\tuserAgent?: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType = {\n\t// TODO\n\tmocksConfig?: Record<string, unknown>;\n\terrors: HookError[];\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n\t// TODO\n\tmocksConfig: Record<string, unknown>;\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType = {\n\terrors: HookError[];\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeArgs = {\n\tid: string;\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypesMachineManagerUpdateCustomTypeReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypeFieldIdChangedMeta = {\n\tpreviousPath: string[];\n\tnewPath: string[];\n};\n\ntype CrCustomType =\n\t| string\n\t| { id: string; fields?: readonly CrCustomTypeNestedCr[] };\ntype CrCustomTypeNestedCr =\n\t| string\n\t| { id: string; customtypes: readonly CrCustomTypeFieldLeaf[] };\ntype CrCustomTypeFieldLeaf =\n\t| string\n\t| { id: string; fields?: readonly string[] };\n\nexport class CustomTypesManager extends BaseManager {\n\tasync readCustomTypeLibrary(): Promise<SliceMachineManagerReadCustomTypeLibraryReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type-library:read\",\n\t\t\tundefined,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tids: t.array(t.string),\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tids: data[0]?.ids || [],\n\t\t\terrors,\n\t\t};\n\t}\n\n\tasync readAllCustomTypes(\n\t\targs?: CustomTypesManagerReadAllCustomTypesArgs,\n\t): Promise<SliceMachineManagerReadAllCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst res: SliceMachineManagerReadAllCustomTypeReturnType = {\n\t\t\tmodels: [],\n\t\t\terrors: [],\n\t\t};\n\n\t\tconst { ids, errors } = await this.readCustomTypeLibrary();\n\t\tres.errors = [...res.errors, ...errors];\n\n\t\tif (ids) {\n\t\t\tfor (const id of ids) {\n\t\t\t\tconst { model, errors } = await this.readCustomType({ id });\n\t\t\t\tres.errors = [...res.errors, ...errors];\n\n\t\t\t\tif (model && (!args || args.format === model.format)) {\n\t\t\t\t\tres.models.push({ model });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync createCustomType(\n\t\targs: CustomTypeCreateHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeCreateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:create\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync readCustomType(\n\t\targs: CustomTypeReadHookData,\n\t): Promise<SliceMachineManagerReadCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:read\",\n\t\t\targs,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tmodel: CustomType,\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tmodel: data[0]?.model,\n\t\t\terrors,\n\t\t};\n\t}\n\n\t/**\n\t * Update the Content Relationship API IDs for all existing custom types and\n\t * slices. The change is determined by properties inside the `updateMeta`\n\t * property.\n\t */\n\tprivate async updateContentRelationships(\n\t\targs: { model: CustomType } & CustomTypeFieldIdChangedMeta,\n\t): Promise<\n\t\tOnlyHookErrors<CallHookReturnType<CustomTypeUpdateHook>> & {\n\t\t\trollback?: () => Promise<void>;\n\t\t}\n\t> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { model } = args;\n\t\tlet { newPath, previousPath } = args;\n\n\t\tif (previousPath.join(\".\") !== newPath.join(\".\")) {\n\t\t\tpreviousPath = [model.id, ...previousPath];\n\t\t\tnewPath = [model.id, ...newPath];\n\n\t\t\tconst crUpdates: {\n\t\t\t\tupdatePromise: Promise<{ errors: HookError[] }>;\n\t\t\t\trollback: () => void;\n\t\t\t}[] = [];\n\n\t\t\t// Find existing content relationships that link to the renamed field id in\n\t\t\t// any custom type and update them to use the new one.\n\t\t\tconst customTypes = await this.readAllCustomTypes();\n\n\t\t\tupdateCustomTypeContentRelationships({\n\t\t\t\tmodels: customTypes.models,\n\t\t\t\tonUpdate: ({ previousModel, model: updatedModel }) => {\n\t\t\t\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\t\t\t\tcrUpdates.push({\n\t\t\t\t\t\tupdatePromise: this.sliceMachinePluginRunner?.callHook(\n\t\t\t\t\t\t\t\"custom-type:update\",\n\t\t\t\t\t\t\t{ model: updatedModel },\n\t\t\t\t\t\t),\n\t\t\t\t\t\trollback: () => {\n\t\t\t\t\t\t\tthis.sliceMachinePluginRunner?.callHook(\"custom-type:update\", {\n\t\t\t\t\t\t\t\tmodel: previousModel,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tpreviousPath,\n\t\t\t\tnewPath,\n\t\t\t});\n\n\t\t\t// Find existing slice with content relationships that link to the renamed\n\t\t\t// field id in all libraries and update them to use the new one.\n\t\t\tconst { libraries } = await this.slices.readAllSliceLibraries();\n\n\t\t\tfor (const library of libraries) {\n\t\t\t\tconst slices = await this.slices.readAllSlicesForLibrary({\n\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t});\n\n\t\t\t\tupdateSharedSliceContentRelationships({\n\t\t\t\t\tmodels: slices.models,\n\t\t\t\t\tonUpdate: ({ previousModel, model: updatedModel }) => {\n\t\t\t\t\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\t\t\t\t\tcrUpdates.push({\n\t\t\t\t\t\t\tupdatePromise: this.sliceMachinePluginRunner?.callHook(\n\t\t\t\t\t\t\t\t\"slice:update\",\n\t\t\t\t\t\t\t\t{ libraryID: library.libraryID, model: updatedModel },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\trollback: () => {\n\t\t\t\t\t\t\t\tthis.sliceMachinePluginRunner?.callHook(\"slice:update\", {\n\t\t\t\t\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t\t\t\t\t\tmodel: previousModel,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Process all the Content Relationship updates at once.\n\t\t\tconst crUpdatesResult = await Promise.all(\n\t\t\t\tcrUpdates.map((update) => update.updatePromise),\n\t\t\t);\n\n\t\t\tif (crUpdatesResult.some((result) => result.errors.length > 0)) {\n\t\t\t\treturn {\n\t\t\t\t\terrors: crUpdatesResult.flatMap((result) => result.errors),\n\t\t\t\t\trollback: async () => {\n\t\t\t\t\t\tawait Promise.all(crUpdates.map((update) => update.rollback()));\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn { errors: [] };\n\t}\n\n\tasync updateCustomType(\n\t\targs: CustomTypeUpdateHookData,\n\t): Promise<CustomTypesMachineManagerUpdateCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\t\tconst { model } = args;\n\t\tconst { fieldIdChanged } = args.updateMeta ?? {};\n\n\t\tlet previousCustomType: CustomType | undefined;\n\n\t\tif (fieldIdChanged) {\n\t\t\tconst customTypeRead = await this.readCustomType({ id: model.id });\n\n\t\t\tif (customTypeRead.errors.length > 0) {\n\t\t\t\treturn { errors: customTypeRead.errors };\n\t\t\t}\n\t\t\tif (!customTypeRead.model) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`readCustomType succeeded reading custom type ${model.id} but model is undefined.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpreviousCustomType = customTypeRead.model;\n\t\t}\n\n\t\tconst customTypeUpdateResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:update\",\n\t\t\t{ model },\n\t\t);\n\n\t\tif (customTypeUpdateResult.errors.length > 0) {\n\t\t\treturn { errors: customTypeUpdateResult.errors };\n\t\t}\n\n\t\tif (previousCustomType && fieldIdChanged) {\n\t\t\tconst crUpdateResult = await this.updateContentRelationships({\n\t\t\t\t...fieldIdChanged,\n\t\t\t\tmodel: previousCustomType,\n\t\t\t});\n\n\t\t\tif (crUpdateResult.errors.length > 0) {\n\t\t\t\t// put the previous custom type back\n\t\t\t\tawait this.sliceMachinePluginRunner?.callHook(\"custom-type:update\", {\n\t\t\t\t\tmodel: previousCustomType,\n\t\t\t\t});\n\t\t\t\t// revert the content relationships updates\n\t\t\t\tawait crUpdateResult.rollback?.();\n\n\t\t\t\treturn { errors: crUpdateResult.errors };\n\t\t\t}\n\t\t}\n\n\t\treturn { errors: [] };\n\t}\n\n\tasync renameCustomType(\n\t\targs: CustomTypeRenameHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeRenameHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:rename\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync deleteCustomType(\n\t\targs: CustomTypesMachineManagerDeleteCustomTypeArgs,\n\t): Promise<CustomTypesMachineManagerDeleteCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { model, errors: readCustomTypeErrors } = await this.readCustomType({\n\t\t\tid: args.id,\n\t\t});\n\n\t\tif (model) {\n\t\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\t\"custom-type:delete\",\n\t\t\t\t{ model },\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\terrors: readCustomTypeErrors,\n\t\t\t};\n\t\t}\n\t}\n\n\tasync pushCustomType(\n\t\targs: SliceMachineManagerPushCustomTypeArgs,\n\t): Promise<void> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\t// TODO: Handle errors\n\t\tconst { model } = await this.readCustomType({ id: args.id });\n\n\t\tif (model) {\n\t\t\t// TODO: Create a single shared client.\n\t\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\t\trepositoryName,\n\t\t\t\ttoken: authenticationToken,\n\t\t\t\tfetch,\n\t\t\t\tfetchOptions: {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"User-Agent\": args.userAgent || SLICE_MACHINE_USER_AGENT,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\n\t\t\ttry {\n\t\t\t\t// Check if Custom Type already exists on the repository.\n\t\t\t\tawait client.getCustomTypeByID(args.id);\n\n\t\t\t\t// If it exists on the repository, update it.\n\t\t\t\tawait client.updateCustomType(model);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof prismicCustomTypesClient.NotFoundError) {\n\t\t\t\t\t// If it doesn't exist on the repository, insert it.\n\t\t\t\t\tawait client.insertCustomType(model);\n\t\t\t\t} else if (error instanceof prismicCustomTypesClient.ForbiddenError) {\n\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\"You do not have access to push types to this Prismic repository.\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync readCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerReadCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:read\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tassetID: \"mocks.config.json\",\n\t\t\t},\n\t\t);\n\t\tconst data = hookResult.data[0]?.data;\n\n\t\t// TODO: Validate the returned data.\n\n\t\tif (data) {\n\t\t\treturn {\n\t\t\t\tmocksConfig: JSON.parse(data.toString()),\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tmocksConfig: undefined,\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync updateCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerUpdateCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:update\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tasset: {\n\t\t\t\t\tid: \"mocks.config.json\",\n\t\t\t\t\tdata: Buffer.from(JSON.stringify(args.mocksConfig, null, \"\\t\")),\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync fetchRemoteCustomTypes(): Promise<CustomType[]> {\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\trepositoryName,\n\t\t\ttoken: authenticationToken,\n\t\t\tfetch,\n\t\t\tfetchOptions: {\n\t\t\t\theaders: {\n\t\t\t\t\t\"User-Agent\": SLICE_MACHINE_USER_AGENT,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\treturn await client.getAllCustomTypes();\n\t}\n\n\tasync inferSlice({\n\t\timageUrl,\n\t}: {\n\t\timageUrl: string;\n\t}): Promise<InferSliceResponse> {\n\t\tconst authToken = await this.user.getAuthenticationToken();\n\t\tconst headers = {\n\t\t\tAuthorization: `Bearer ${authToken}`,\n\t\t};\n\n\t\tconst repository = await this.project.getResolvedRepositoryName();\n\t\tconst searchParams = new URLSearchParams({\n\t\t\trepository,\n\t\t});\n\n\t\tconst url = new URL(\"./slices/infer\", API_ENDPOINTS.CustomTypeService);\n\t\turl.search = searchParams.toString();\n\n\t\tconst response = await fetch(url.toString(), {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: headers,\n\t\t\tbody: JSON.stringify({ imageUrl }),\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(`Failed to infer slice: ${response.statusText}`);\n\t\t}\n\n\t\tconst json = await response.json();\n\n\t\treturn InferSliceResponse.parse(json);\n\t}\n}\n\ntype InferSliceResponse = z.infer<typeof InferSliceResponse>;\n\nconst InferSliceResponse = z.object({\n\tslice: z.custom().transform((value, ctx) => {\n\t\tconst result = SharedSlice.decode(value);\n\t\tif (result._tag === \"Right\") {\n\t\t\treturn result.right;\n\t\t}\n\t\tctx.addIssue({\n\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\tmessage: `Invalid shared slice: ${JSON.stringify(value, null, 2)}`,\n\t\t});\n\n\t\treturn z.NEVER;\n\t}),\n\tlangSmithUrl: z.string().url().optional(),\n});\n\nfunction updateCRCustomType(\n\targs: { customType: CrCustomType } & CustomTypeFieldIdChangedMeta,\n): CrCustomType {\n\tconst [previousCustomTypeId, previousFieldId] = args.previousPath;\n\tconst [newCustomTypeId, newFieldId] = args.newPath;\n\n\tif (!previousCustomTypeId || !newCustomTypeId) {\n\t\tthrow new Error(\n\t\t\t\"Could not find a customtype id in previousPath and/or newPath, which should not be possible.\",\n\t\t);\n\t}\n\n\tif (!previousFieldId || !newFieldId) {\n\t\tthrow new Error(\n\t\t\t\"Could not find a field id in previousPath and/or newPath, which should not be possible.\",\n\t\t);\n\t}\n\n\tconst customType = shallowCloneIfObject(args.customType);\n\n\tif (typeof customType === \"string\" || !customType.fields) {\n\t\treturn customType;\n\t}\n\n\tconst matchedCustomTypeId = customType.id === previousCustomTypeId;\n\n\tconst newFields = customType.fields.map((fieldArg) => {\n\t\tconst customTypeField = shallowCloneIfObject(fieldArg);\n\n\t\tif (typeof customTypeField === \"string\") {\n\t\t\tif (\n\t\t\t\tmatchedCustomTypeId &&\n\t\t\t\tcustomTypeField === previousFieldId &&\n\t\t\t\tcustomTypeField !== newFieldId\n\t\t\t) {\n\t\t\t\t// We have reached a field id that matches the id that was renamed,\n\t\t\t\t// so we update it new one. The field is a string, so return the new\n\t\t\t\t// id.\n\t\t\t\treturn newFieldId;\n\t\t\t}\n\n\t\t\treturn customTypeField;\n\t\t}\n\n\t\tif (\n\t\t\tmatchedCustomTypeId &&\n\t\t\tcustomTypeField.id === previousFieldId &&\n\t\t\tcustomTypeField.id !== newFieldId\n\t\t) {\n\t\t\t// We have reached a field id that matches the id that was renamed,\n\t\t\t// so we update it new one.\n\t\t\t// Since field is not a string, we don't exit, as we might have\n\t\t\t// something to update further down in customtypes.\n\t\t\tcustomTypeField.id = newFieldId;\n\t\t}\n\n\t\treturn {\n\t\t\t...customTypeField,\n\t\t\tcustomtypes: customTypeField.customtypes.map((customTypeArg) => {\n\t\t\t\tconst nestedCustomType = shallowCloneIfObject(customTypeArg);\n\n\t\t\t\tif (\n\t\t\t\t\ttypeof nestedCustomType === \"string\" ||\n\t\t\t\t\t!nestedCustomType.fields ||\n\t\t\t\t\t// Since we are on the last level, if we don't start matching right\n\t\t\t\t\t// at the custom type id, we can return exit early because it's not\n\t\t\t\t\t// a match.\n\t\t\t\t\tnestedCustomType.id !== previousCustomTypeId\n\t\t\t\t) {\n\t\t\t\t\treturn nestedCustomType;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...nestedCustomType,\n\t\t\t\t\tfields: nestedCustomType.fields.map((fieldArg) => {\n\t\t\t\t\t\tconst nestedCustomTypeField = shallowCloneIfObject(fieldArg);\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnestedCustomTypeField === previousFieldId &&\n\t\t\t\t\t\t\tnestedCustomTypeField !== newFieldId\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// Matches the previous id, so we update it and return because\n\t\t\t\t\t\t\t// it's the last level.\n\t\t\t\t\t\t\treturn newFieldId;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn nestedCustomTypeField;\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t}),\n\t\t};\n\t});\n\n\treturn { ...customType, fields: newFields };\n}\n\n/**\n * Update the Content Relationship API IDs of a single field. The change is\n * determined by the `previousPath` and `newPath` properties.\n */\nfunction updateFieldContentRelationships<\n\tT extends UID | NestableWidget | Group | NestedGroup,\n>(args: { field: T } & CustomTypeFieldIdChangedMeta): T {\n\tconst { field, ...updateMeta } = args;\n\tif (\n\t\tfield.type !== \"Link\" ||\n\t\tfield.config?.select !== \"document\" ||\n\t\t!field.config?.customtypes\n\t) {\n\t\t// not a content relationship field\n\t\treturn field;\n\t}\n\n\tconst newCustomTypes = field.config.customtypes.map((customType) => {\n\t\treturn updateCRCustomType({ customType, ...updateMeta });\n\t});\n\n\treturn {\n\t\t...field,\n\t\tconfig: { ...field.config, customtypes: newCustomTypes },\n\t};\n}\n\nexport function updateCustomTypeContentRelationships(\n\targs: {\n\t\tmodels: { model: CustomType }[];\n\t\tonUpdate: (model: { previousModel: CustomType; model: CustomType }) => void;\n\t} & CustomTypeFieldIdChangedMeta,\n): void {\n\tconst { models, previousPath, newPath, onUpdate } = args;\n\n\tfor (const { model: customType } of models) {\n\t\tconst updatedCustomType = traverseCustomType({\n\t\t\tcustomType,\n\t\t\tonField: ({ field }) => {\n\t\t\t\treturn updateFieldContentRelationships({\n\t\t\t\t\tfield,\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t});\n\t\t\t},\n\t\t});\n\n\t\tif (!isEqualModel(customType, updatedCustomType)) {\n\t\t\tonUpdate({ model: updatedCustomType, previousModel: customType });\n\t\t}\n\t}\n}\n\nexport function updateSharedSliceContentRelationships(\n\targs: {\n\t\tmodels: { model: SharedSlice }[];\n\t\tonUpdate: (model: {\n\t\t\tpreviousModel: SharedSlice;\n\t\t\tmodel: SharedSlice;\n\t\t}) => void;\n\t} & CustomTypeFieldIdChangedMeta,\n): void {\n\tconst { models, previousPath, newPath, onUpdate } = args;\n\n\tfor (const { model: slice } of models) {\n\t\tconst updateSlice = traverseSharedSlice({\n\t\t\tpath: [\".\"],\n\t\t\tslice,\n\t\t\tonField: ({ field }) => {\n\t\t\t\treturn updateFieldContentRelationships({\n\t\t\t\t\tfield,\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t});\n\t\t\t},\n\t\t});\n\n\t\tif (!isEqualModel(slice, updateSlice)) {\n\t\t\tonUpdate({ model: updateSlice, previousModel: slice });\n\t\t}\n\t}\n}\n\nfunction isEqualModel<T extends CustomType | SharedSlice>(\n\tmodelA: T,\n\tmodelB: T,\n): boolean {\n\treturn JSON.stringify(modelA) === JSON.stringify(modelB);\n}\n\nfunction shallowCloneIfObject<T>(value: T): T {\n\tif (typeof value === \"object\") {\n\t\treturn { ...value };\n\t}\n\n\treturn value;\n}\n"],"names":["BaseManager","assertPluginsInitialized","errors","decodeHookResult","t","CustomType","_a","prismicCustomTypesClient","API_ENDPOINTS","fetch","SLICE_MACHINE_USER_AGENT","UnauthorizedError","z","SharedSlice","fieldArg","traverseCustomType","traverseSharedSlice"],"mappings":";;;;;;;;;;;;;;;;;;;;;;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A,CACA;AAED,QAAI,CAAC,aAAa,YAAY,iBAAiB,GAAG;AACjD,eAAS,EAAE,OAAO,mBAAmB,eAAe,WAAY,CAAA;AAAA,IACjE;AAAA,EACD;AACD;AAEM,SAAU,sCACf,MAMgC;AAEhC,QAAM,EAAE,QAAQ,cAAc,SAAS,aAAa;AAEpD,aAAW,EAAE,OAAO,MAAO,KAAI,QAAQ;AACtC,UAAM,cAAcC,YAAAA,oBAAoB;AAAA,MACvC,MAAM,CAAC,GAAG;AAAA,MACV;AAAA,MACA,SAAS,CAAC,EAAE,YAAW;AACtB,eAAO,gCAAgC;AAAA,UACtC;AAAA,UACA;AAAA,UACA;AAAA,QAAA,CACA;AAAA,MACF;AAAA,IAAA,CACA;AAED,QAAI,CAAC,aAAa,OAAO,WAAW,GAAG;AACtC,eAAS,EAAE,OAAO,aAAa,eAAe,MAAO,CAAA;AAAA,IACtD;AAAA,EACD;AACD;AAEA,SAAS,aACR,QACA,QAAS;AAET,SAAO,KAAK,UAAU,MAAM,MAAM,KAAK,UAAU,MAAM;AACxD;AAEA,SAAS,qBAAwB,OAAQ;AACpC,MAAA,OAAO,UAAU,UAAU;AACvB,WAAA,EAAE,GAAG;EACb;AAEO,SAAA;AACR;;;;"}
@@ -1,5 +1,5 @@
1
- import { CustomType } from "@prismicio/types-internal/lib/customtypes";
2
- import { CallHookReturnType, CustomTypeCreateHook, CustomTypeCreateHookData, CustomTypeReadHookData, CustomTypeRenameHook, CustomTypeRenameHookData, CustomTypeUpdateHook, CustomTypeUpdateHookData, HookError } from "@slicemachine/plugin-kit";
1
+ import { CustomType, SharedSlice } from "@prismicio/types-internal/lib/customtypes";
2
+ import { CallHookReturnType, CustomTypeCreateHook, CustomTypeCreateHookData, CustomTypeReadHookData, CustomTypeRenameHook, CustomTypeRenameHookData, CustomTypeUpdateHookData, HookError } from "@slicemachine/plugin-kit";
3
3
  import { z } from "zod";
4
4
  import { DecodeError } from "../../lib/DecodeError";
5
5
  import { OnlyHookErrors } from "../../types";
@@ -46,12 +46,25 @@ type CustomTypesMachineManagerDeleteCustomTypeArgs = {
46
46
  type CustomTypesMachineManagerDeleteCustomTypeReturnType = {
47
47
  errors: (DecodeError | HookError)[];
48
48
  };
49
+ type CustomTypesMachineManagerUpdateCustomTypeReturnType = {
50
+ errors: (DecodeError | HookError)[];
51
+ };
52
+ type CustomTypeFieldIdChangedMeta = {
53
+ previousPath: string[];
54
+ newPath: string[];
55
+ };
49
56
  export declare class CustomTypesManager extends BaseManager {
50
57
  readCustomTypeLibrary(): Promise<SliceMachineManagerReadCustomTypeLibraryReturnType>;
51
58
  readAllCustomTypes(args?: CustomTypesManagerReadAllCustomTypesArgs): Promise<SliceMachineManagerReadAllCustomTypeReturnType>;
52
59
  createCustomType(args: CustomTypeCreateHookData): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeCreateHook>>>;
53
60
  readCustomType(args: CustomTypeReadHookData): Promise<SliceMachineManagerReadCustomTypeReturnType>;
54
- updateCustomType(args: CustomTypeUpdateHookData): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeUpdateHook>>>;
61
+ /**
62
+ * Update the Content Relationship API IDs for all existing custom types and
63
+ * slices. The change is determined by properties inside the `updateMeta`
64
+ * property.
65
+ */
66
+ private updateContentRelationships;
67
+ updateCustomType(args: CustomTypeUpdateHookData): Promise<CustomTypesMachineManagerUpdateCustomTypeReturnType>;
55
68
  renameCustomType(args: CustomTypeRenameHookData): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeRenameHook>>>;
56
69
  deleteCustomType(args: CustomTypesMachineManagerDeleteCustomTypeArgs): Promise<CustomTypesMachineManagerDeleteCustomTypeReturnType>;
57
70
  pushCustomType(args: SliceMachineManagerPushCustomTypeArgs): Promise<void>;
@@ -208,7 +221,18 @@ declare const InferSliceResponse: z.ZodObject<{
208
221
  useAsTitle?: boolean | undefined;
209
222
  placeholder?: string | undefined;
210
223
  select?: "media" | "document" | "web" | null | undefined;
211
- customtypes?: readonly string[] | undefined;
224
+ customtypes?: readonly (string | ({
225
+ id: string;
226
+ } & {
227
+ fields?: readonly (string | {
228
+ id: string;
229
+ customtypes: readonly (string | ({
230
+ id: string;
231
+ } & {
232
+ fields?: readonly string[] | undefined;
233
+ }))[];
234
+ })[] | undefined;
235
+ }))[] | undefined;
212
236
  masks?: readonly string[] | undefined;
213
237
  tags?: readonly string[] | undefined;
214
238
  allowTargetBlank?: boolean | undefined;
@@ -383,7 +407,18 @@ declare const InferSliceResponse: z.ZodObject<{
383
407
  useAsTitle?: boolean | undefined;
384
408
  placeholder?: string | undefined;
385
409
  select?: "media" | "document" | "web" | null | undefined;
386
- customtypes?: readonly string[] | undefined;
410
+ customtypes?: readonly (string | ({
411
+ id: string;
412
+ } & {
413
+ fields?: readonly (string | {
414
+ id: string;
415
+ customtypes: readonly (string | ({
416
+ id: string;
417
+ } & {
418
+ fields?: readonly string[] | undefined;
419
+ }))[];
420
+ })[] | undefined;
421
+ }))[] | undefined;
387
422
  masks?: readonly string[] | undefined;
388
423
  tags?: readonly string[] | undefined;
389
424
  allowTargetBlank?: boolean | undefined;
@@ -558,7 +593,18 @@ declare const InferSliceResponse: z.ZodObject<{
558
593
  useAsTitle?: boolean | undefined;
559
594
  placeholder?: string | undefined;
560
595
  select?: "media" | "document" | "web" | null | undefined;
561
- customtypes?: readonly string[] | undefined;
596
+ customtypes?: readonly (string | ({
597
+ id: string;
598
+ } & {
599
+ fields?: readonly (string | {
600
+ id: string;
601
+ customtypes: readonly (string | ({
602
+ id: string;
603
+ } & {
604
+ fields?: readonly string[] | undefined;
605
+ }))[];
606
+ })[] | undefined;
607
+ }))[] | undefined;
562
608
  masks?: readonly string[] | undefined;
563
609
  tags?: readonly string[] | undefined;
564
610
  allowTargetBlank?: boolean | undefined;
@@ -732,7 +778,18 @@ declare const InferSliceResponse: z.ZodObject<{
732
778
  useAsTitle?: boolean | undefined;
733
779
  placeholder?: string | undefined;
734
780
  select?: "media" | "document" | "web" | null | undefined;
735
- customtypes?: readonly string[] | undefined;
781
+ customtypes?: readonly (string | ({
782
+ id: string;
783
+ } & {
784
+ fields?: readonly (string | {
785
+ id: string;
786
+ customtypes: readonly (string | ({
787
+ id: string;
788
+ } & {
789
+ fields?: readonly string[] | undefined;
790
+ }))[];
791
+ })[] | undefined;
792
+ }))[] | undefined;
736
793
  masks?: readonly string[] | undefined;
737
794
  tags?: readonly string[] | undefined;
738
795
  allowTargetBlank?: boolean | undefined;
@@ -922,7 +979,18 @@ declare const InferSliceResponse: z.ZodObject<{
922
979
  useAsTitle?: boolean | undefined;
923
980
  placeholder?: string | undefined;
924
981
  select?: "media" | "document" | "web" | null | undefined;
925
- customtypes?: readonly string[] | undefined;
982
+ customtypes?: readonly (string | ({
983
+ id: string;
984
+ } & {
985
+ fields?: readonly (string | {
986
+ id: string;
987
+ customtypes: readonly (string | ({
988
+ id: string;
989
+ } & {
990
+ fields?: readonly string[] | undefined;
991
+ }))[];
992
+ })[] | undefined;
993
+ }))[] | undefined;
926
994
  masks?: readonly string[] | undefined;
927
995
  tags?: readonly string[] | undefined;
928
996
  allowTargetBlank?: boolean | undefined;
@@ -1097,7 +1165,18 @@ declare const InferSliceResponse: z.ZodObject<{
1097
1165
  useAsTitle?: boolean | undefined;
1098
1166
  placeholder?: string | undefined;
1099
1167
  select?: "media" | "document" | "web" | null | undefined;
1100
- customtypes?: readonly string[] | undefined;
1168
+ customtypes?: readonly (string | ({
1169
+ id: string;
1170
+ } & {
1171
+ fields?: readonly (string | {
1172
+ id: string;
1173
+ customtypes: readonly (string | ({
1174
+ id: string;
1175
+ } & {
1176
+ fields?: readonly string[] | undefined;
1177
+ }))[];
1178
+ })[] | undefined;
1179
+ }))[] | undefined;
1101
1180
  masks?: readonly string[] | undefined;
1102
1181
  tags?: readonly string[] | undefined;
1103
1182
  allowTargetBlank?: boolean | undefined;
@@ -1272,7 +1351,18 @@ declare const InferSliceResponse: z.ZodObject<{
1272
1351
  useAsTitle?: boolean | undefined;
1273
1352
  placeholder?: string | undefined;
1274
1353
  select?: "media" | "document" | "web" | null | undefined;
1275
- customtypes?: readonly string[] | undefined;
1354
+ customtypes?: readonly (string | ({
1355
+ id: string;
1356
+ } & {
1357
+ fields?: readonly (string | {
1358
+ id: string;
1359
+ customtypes: readonly (string | ({
1360
+ id: string;
1361
+ } & {
1362
+ fields?: readonly string[] | undefined;
1363
+ }))[];
1364
+ })[] | undefined;
1365
+ }))[] | undefined;
1276
1366
  masks?: readonly string[] | undefined;
1277
1367
  tags?: readonly string[] | undefined;
1278
1368
  allowTargetBlank?: boolean | undefined;
@@ -1446,7 +1536,18 @@ declare const InferSliceResponse: z.ZodObject<{
1446
1536
  useAsTitle?: boolean | undefined;
1447
1537
  placeholder?: string | undefined;
1448
1538
  select?: "media" | "document" | "web" | null | undefined;
1449
- customtypes?: readonly string[] | undefined;
1539
+ customtypes?: readonly (string | ({
1540
+ id: string;
1541
+ } & {
1542
+ fields?: readonly (string | {
1543
+ id: string;
1544
+ customtypes: readonly (string | ({
1545
+ id: string;
1546
+ } & {
1547
+ fields?: readonly string[] | undefined;
1548
+ }))[];
1549
+ })[] | undefined;
1550
+ }))[] | undefined;
1450
1551
  masks?: readonly string[] | undefined;
1451
1552
  tags?: readonly string[] | undefined;
1452
1553
  allowTargetBlank?: boolean | undefined;
@@ -1495,4 +1596,22 @@ declare const InferSliceResponse: z.ZodObject<{
1495
1596
  slice?: unknown;
1496
1597
  langSmithUrl?: string | undefined;
1497
1598
  }>;
1599
+ export declare function updateCustomTypeContentRelationships(args: {
1600
+ models: {
1601
+ model: CustomType;
1602
+ }[];
1603
+ onUpdate: (model: {
1604
+ previousModel: CustomType;
1605
+ model: CustomType;
1606
+ }) => void;
1607
+ } & CustomTypeFieldIdChangedMeta): void;
1608
+ export declare function updateSharedSliceContentRelationships(args: {
1609
+ models: {
1610
+ model: SharedSlice;
1611
+ }[];
1612
+ onUpdate: (model: {
1613
+ previousModel: SharedSlice;
1614
+ model: SharedSlice;
1615
+ }) => void;
1616
+ } & CustomTypeFieldIdChangedMeta): void;
1498
1617
  export {};