@slicemachine/manager 0.24.14-alpha.jp-update-cr-links-unit.3 → 0.24.14-alpha.jp-update-cr-links-remove-recursion.1
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.
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/client.cjs +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/client.js +1 -1
- package/dist/_node_modules/cross-spawn/index.cjs +1 -1
- package/dist/_node_modules/cross-spawn/index.js +1 -1
- package/dist/_virtual/index2.cjs +4 -3
- package/dist/_virtual/index2.cjs.map +1 -1
- package/dist/_virtual/index2.js +4 -2
- package/dist/_virtual/index2.js.map +1 -1
- package/dist/_virtual/index3.cjs +3 -4
- package/dist/_virtual/index3.cjs.map +1 -1
- package/dist/_virtual/index3.js +2 -4
- package/dist/_virtual/index3.js.map +1 -1
- package/dist/managers/customTypes/CustomTypesManager.cjs +113 -128
- package/dist/managers/customTypes/CustomTypesManager.cjs.map +1 -1
- package/dist/managers/customTypes/CustomTypesManager.d.ts +12 -14
- package/dist/managers/customTypes/CustomTypesManager.js +115 -130
- package/dist/managers/customTypes/CustomTypesManager.js.map +1 -1
- package/package.json +2 -2
- package/src/managers/customTypes/CustomTypesManager.ts +162 -196
@@ -1,6 +1,6 @@
|
|
1
1
|
import * as t from "io-ts";
|
2
2
|
import * as prismicCustomTypesClient from "@prismicio/custom-types-client";
|
3
|
-
import { CustomType,
|
3
|
+
import { CustomType, traverseCustomType, traverseSharedSlice, SharedSlice } from "@prismicio/types-internal/lib/customtypes";
|
4
4
|
import z from './../../_node_modules/zod/lib/index.js';
|
5
5
|
import { assertPluginsInitialized } from "../../lib/assertPluginsInitialized.js";
|
6
6
|
import { decodeHookResult } from "../../lib/decodeHookResult.js";
|
@@ -60,6 +60,86 @@ class CustomTypesManager extends BaseManager {
|
|
60
60
|
errors
|
61
61
|
};
|
62
62
|
}
|
63
|
+
updateCRCustomType(args) {
|
64
|
+
const { previousPath, newPath } = args;
|
65
|
+
const customType = shallowClone(args.customType);
|
66
|
+
const [previousId] = previousPath;
|
67
|
+
const [newId] = newPath;
|
68
|
+
if (!previousId || !newId || typeof customType === "string") {
|
69
|
+
return customType;
|
70
|
+
}
|
71
|
+
if (customType.fields) {
|
72
|
+
const newFields = customType.fields.map((fieldArg) => {
|
73
|
+
const field = shallowClone(fieldArg);
|
74
|
+
const previousId2 = previousPath[1];
|
75
|
+
const newId2 = newPath[1];
|
76
|
+
if (!previousId2 || !newId2) {
|
77
|
+
return field;
|
78
|
+
}
|
79
|
+
if (typeof field === "string") {
|
80
|
+
if (field === previousId2 && field !== newId2) {
|
81
|
+
return newId2;
|
82
|
+
}
|
83
|
+
return field;
|
84
|
+
}
|
85
|
+
if (field.id === previousId2 && field.id !== newId2) {
|
86
|
+
field.id = newId2;
|
87
|
+
}
|
88
|
+
return {
|
89
|
+
...field,
|
90
|
+
customtypes: field.customtypes.map((customTypeArg) => {
|
91
|
+
const customType2 = shallowClone(customTypeArg);
|
92
|
+
const previousId3 = previousPath[2];
|
93
|
+
const newId3 = newPath[2];
|
94
|
+
if (!previousId3 || !newId3) {
|
95
|
+
return customType2;
|
96
|
+
}
|
97
|
+
if (typeof customType2 === "string") {
|
98
|
+
if (customType2 === previousId3 && customType2 !== newId3) {
|
99
|
+
return newId3;
|
100
|
+
}
|
101
|
+
return customType2;
|
102
|
+
}
|
103
|
+
if (customType2.id === previousId3 && customType2.id !== newId3) {
|
104
|
+
return { ...customType2, id: newId3 };
|
105
|
+
}
|
106
|
+
return customType2;
|
107
|
+
})
|
108
|
+
};
|
109
|
+
});
|
110
|
+
return { ...customType, fields: newFields };
|
111
|
+
}
|
112
|
+
return customType;
|
113
|
+
}
|
114
|
+
/**
|
115
|
+
* Map over the custom types of a Content Relationship Link and update the API
|
116
|
+
* IDs that were changed during the custom type update.
|
117
|
+
*/
|
118
|
+
updateCRCustomTypes(args) {
|
119
|
+
const { customTypes, ...updateMeta } = args;
|
120
|
+
return customTypes.map((customType) => {
|
121
|
+
return this.updateCRCustomType({ customType, ...updateMeta });
|
122
|
+
});
|
123
|
+
}
|
124
|
+
/**
|
125
|
+
* Update the Content Relationship API IDs of a single field. The change is
|
126
|
+
* determined by the `previousPath` and `newPath` properties.
|
127
|
+
*/
|
128
|
+
updateFieldContentRelationships(args) {
|
129
|
+
var _a, _b;
|
130
|
+
const { field, ...updateMeta } = args;
|
131
|
+
if (field.type !== "Link" || ((_a = field.config) == null ? void 0 : _a.select) !== "document" || !((_b = field.config) == null ? void 0 : _b.customtypes)) {
|
132
|
+
return field;
|
133
|
+
}
|
134
|
+
const newCustomTypes = this.updateCRCustomTypes({
|
135
|
+
...updateMeta,
|
136
|
+
customTypes: field.config.customtypes
|
137
|
+
});
|
138
|
+
return {
|
139
|
+
...field,
|
140
|
+
config: { ...field.config, customtypes: newCustomTypes }
|
141
|
+
};
|
142
|
+
}
|
63
143
|
/**
|
64
144
|
* Update the Content Relationship API IDs for all existing custom types and
|
65
145
|
* slices. The change is determined by properties inside the `updateMeta`
|
@@ -75,34 +155,43 @@ class CustomTypesManager extends BaseManager {
|
|
75
155
|
newPath = [model.id, ...newPath];
|
76
156
|
const crUpdates = [];
|
77
157
|
const customTypes = await this.readAllCustomTypes();
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
158
|
+
for (const customType of customTypes.models) {
|
159
|
+
const updatedCustomTypeModel = traverseCustomType({
|
160
|
+
customType: customType.model,
|
161
|
+
onField: ({ field }) => {
|
162
|
+
return this.updateFieldContentRelationships({
|
163
|
+
field,
|
164
|
+
previousPath,
|
165
|
+
newPath
|
166
|
+
});
|
167
|
+
}
|
168
|
+
});
|
169
|
+
crUpdates.push(this.sliceMachinePluginRunner.callHook("custom-type:update", {
|
170
|
+
model: updatedCustomTypeModel
|
171
|
+
}));
|
172
|
+
}
|
89
173
|
const { libraries } = await this.slices.readAllSliceLibraries();
|
90
174
|
for (const library of libraries) {
|
91
175
|
const slices = await this.slices.readAllSlicesForLibrary({
|
92
176
|
libraryID: library.libraryID
|
93
177
|
});
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
178
|
+
for (const slice of slices.models) {
|
179
|
+
const updatedSliceModel = traverseSharedSlice({
|
180
|
+
path: ["."],
|
181
|
+
slice: slice.model,
|
182
|
+
onField: ({ field }) => {
|
183
|
+
return this.updateFieldContentRelationships({
|
184
|
+
field,
|
185
|
+
previousPath,
|
186
|
+
newPath
|
187
|
+
});
|
188
|
+
}
|
189
|
+
});
|
190
|
+
crUpdates.push(this.sliceMachinePluginRunner.callHook("slice:update", {
|
191
|
+
libraryID: library.libraryID,
|
192
|
+
model: updatedSliceModel
|
193
|
+
}));
|
194
|
+
}
|
106
195
|
}
|
107
196
|
const crUpdatesResult = await Promise.all(crUpdates);
|
108
197
|
if (crUpdatesResult.some((result) => result.errors.length > 0)) {
|
@@ -267,117 +356,13 @@ const InferSliceResponse = z.object({
|
|
267
356
|
}),
|
268
357
|
langSmithUrl: z.string().url().optional()
|
269
358
|
});
|
270
|
-
function
|
271
|
-
const { previousPath, newPath } = args;
|
272
|
-
const customType = shallowCloneIfObject(args.customType);
|
273
|
-
const [previousId] = previousPath;
|
274
|
-
const [newId] = newPath;
|
275
|
-
if (!previousId || !newId || typeof customType === "string") {
|
276
|
-
return customType;
|
277
|
-
}
|
278
|
-
if (customType.fields) {
|
279
|
-
const newFields = customType.fields.map((fieldArg) => {
|
280
|
-
const field = shallowCloneIfObject(fieldArg);
|
281
|
-
const previousId2 = previousPath[1];
|
282
|
-
const newId2 = newPath[1];
|
283
|
-
if (!previousId2 || !newId2) {
|
284
|
-
return field;
|
285
|
-
}
|
286
|
-
if (typeof field === "string") {
|
287
|
-
if (field === previousId2 && field !== newId2) {
|
288
|
-
return newId2;
|
289
|
-
}
|
290
|
-
return field;
|
291
|
-
}
|
292
|
-
if (field.id === previousId2 && field.id !== newId2) {
|
293
|
-
field.id = newId2;
|
294
|
-
}
|
295
|
-
return {
|
296
|
-
...field,
|
297
|
-
customtypes: field.customtypes.map((customType2) => {
|
298
|
-
return updateCRCustomType({
|
299
|
-
customType: customType2,
|
300
|
-
previousPath,
|
301
|
-
newPath
|
302
|
-
});
|
303
|
-
})
|
304
|
-
};
|
305
|
-
});
|
306
|
-
return {
|
307
|
-
id: customType.id,
|
308
|
-
fields: newFields
|
309
|
-
};
|
310
|
-
}
|
311
|
-
return customType;
|
312
|
-
}
|
313
|
-
function updateCRCustomTypes(args) {
|
314
|
-
const { customTypes, ...updateMeta } = args;
|
315
|
-
return customTypes.map((customType) => {
|
316
|
-
return updateCRCustomType({ customType, ...updateMeta });
|
317
|
-
});
|
318
|
-
}
|
319
|
-
function updateFieldContentRelationships(args) {
|
320
|
-
var _a, _b;
|
321
|
-
const { field, ...updateMeta } = args;
|
322
|
-
if (field.type !== "Link" || ((_a = field.config) == null ? void 0 : _a.select) !== "document" || !((_b = field.config) == null ? void 0 : _b.customtypes)) {
|
323
|
-
return field;
|
324
|
-
}
|
325
|
-
const newCustomTypes = updateCRCustomTypes({
|
326
|
-
...updateMeta,
|
327
|
-
customTypes: field.config.customtypes
|
328
|
-
});
|
329
|
-
return {
|
330
|
-
...field,
|
331
|
-
config: { ...field.config, customtypes: newCustomTypes }
|
332
|
-
};
|
333
|
-
}
|
334
|
-
function updateCustomTypeContentRelationships(args) {
|
335
|
-
const { models, previousPath, newPath, onUpdate } = args;
|
336
|
-
for (const customType of models) {
|
337
|
-
const updatedCustomTypeModel = traverseCustomType({
|
338
|
-
customType: customType.model,
|
339
|
-
onField: ({ field }) => {
|
340
|
-
return updateFieldContentRelationships({
|
341
|
-
field,
|
342
|
-
previousPath,
|
343
|
-
newPath
|
344
|
-
});
|
345
|
-
}
|
346
|
-
});
|
347
|
-
onUpdate(updatedCustomTypeModel);
|
348
|
-
}
|
349
|
-
}
|
350
|
-
function updateSharedSliceContentRelationships(args) {
|
351
|
-
const { models, previousPath, newPath, onUpdate } = args;
|
352
|
-
for (const slice of models) {
|
353
|
-
const updatedSliceModel = traverseSharedSlice({
|
354
|
-
path: ["."],
|
355
|
-
slice: slice.model,
|
356
|
-
onField: ({ field }) => {
|
357
|
-
return updateFieldContentRelationships({
|
358
|
-
field,
|
359
|
-
previousPath,
|
360
|
-
newPath
|
361
|
-
});
|
362
|
-
}
|
363
|
-
});
|
364
|
-
onUpdate(updatedSliceModel);
|
365
|
-
}
|
366
|
-
}
|
367
|
-
function shallowCloneIfObject(value) {
|
359
|
+
function shallowClone(value) {
|
368
360
|
if (typeof value === "object") {
|
369
361
|
return { ...value };
|
370
362
|
}
|
371
363
|
return value;
|
372
364
|
}
|
373
|
-
function pushIfDefined(array, value) {
|
374
|
-
if (value) {
|
375
|
-
array.push(value);
|
376
|
-
}
|
377
|
-
}
|
378
365
|
export {
|
379
|
-
CustomTypesManager
|
380
|
-
updateCustomTypeContentRelationships,
|
381
|
-
updateSharedSliceContentRelationships
|
366
|
+
CustomTypesManager
|
382
367
|
};
|
383
368
|
//# sourceMappingURL=CustomTypesManager.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CustomTypesManager.js","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 CustomTypeFieldIdChangedMeta = NonNullable<\n\tNonNullable<CustomTypeUpdateHookData[\"updateMeta\"]>[\"fieldIdChanged\"]\n>;\n\ntype CrCustomTypes = readonly CrCustomType[];\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: CustomTypeUpdateHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeUpdateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { model, updateMeta } = args;\n\n\t\tif (updateMeta?.fieldIdChanged) {\n\t\t\tlet { previousPath, newPath } = updateMeta.fieldIdChanged;\n\n\t\t\tif (previousPath.join(\".\") !== newPath.join(\".\")) {\n\t\t\t\tpreviousPath = [model.id, ...previousPath];\n\t\t\t\tnewPath = [model.id, ...newPath];\n\n\t\t\t\tconst crUpdates: Promise<{ errors: HookError[] }>[] = [];\n\n\t\t\t\t// Find existing content relationships that link to the renamed field id in\n\t\t\t\t// any custom type and update them to use the new one.\n\t\t\t\tconst customTypes = await this.readAllCustomTypes();\n\n\t\t\t\tupdateCustomTypeContentRelationships({\n\t\t\t\t\tmodels: customTypes.models,\n\t\t\t\t\tonUpdate: (model) => {\n\t\t\t\t\t\tpushIfDefined(\n\t\t\t\t\t\t\tcrUpdates,\n\t\t\t\t\t\t\tthis.sliceMachinePluginRunner?.callHook(\"custom-type:update\", {\n\t\t\t\t\t\t\t\tmodel,\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\n\t\t\t\t// Find existing slice with content relationships that link to the renamed\n\t\t\t\t// field id in all libraries and update them to use the new one.\n\t\t\t\tconst { libraries } = await this.slices.readAllSliceLibraries();\n\n\t\t\t\tfor (const library of libraries) {\n\t\t\t\t\tconst slices = await this.slices.readAllSlicesForLibrary({\n\t\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t\t});\n\n\t\t\t\t\tupdateSharedSliceContentRelationships({\n\t\t\t\t\t\tmodels: slices.models,\n\t\t\t\t\t\tonUpdate: (model) => {\n\t\t\t\t\t\t\tpushIfDefined(\n\t\t\t\t\t\t\t\tcrUpdates,\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,\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\tpreviousPath,\n\t\t\t\t\t\tnewPath,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// Process all the Content Relationship updates at once.\n\t\t\t\tconst crUpdatesResult = await Promise.all(crUpdates);\n\n\t\t\t\tif (crUpdatesResult.some((result) => result.errors.length > 0)) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\terrors: crUpdatesResult.flatMap((result) => result.errors),\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<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\tif (args.updateMeta?.fieldIdChanged) {\n\t\t\tawait this.updateContentRelationships(args);\n\t\t}\n\n\t\treturn { errors: hookResult.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<T extends CrCustomType | CrCustomTypeFieldLeaf>(\n\targs: {\n\t\tcustomType: T;\n\t} & CustomTypeFieldIdChangedMeta,\n): T {\n\tconst { previousPath, newPath } = args;\n\n\tconst customType = shallowCloneIfObject(args.customType);\n\n\tconst [previousId] = previousPath;\n\tconst [newId] = newPath;\n\n\tif (!previousId || !newId || typeof customType === \"string\") {\n\t\treturn customType;\n\t}\n\n\tif (customType.fields) {\n\t\tconst newFields = customType.fields.map((fieldArg) => {\n\t\t\tconst field = shallowCloneIfObject(fieldArg);\n\n\t\t\tconst previousId = previousPath[1];\n\t\t\tconst newId = newPath[1];\n\n\t\t\tif (!previousId || !newId) {\n\t\t\t\treturn field;\n\t\t\t}\n\n\t\t\tif (typeof field === \"string\") {\n\t\t\t\tif (field === previousId && field !== newId) {\n\t\t\t\t\t// We have reached a field id that matches the id that was renamed,\n\t\t\t\t\t// so we update it new one. The field is a string, so return the new\n\t\t\t\t\t// id.\n\t\t\t\t\treturn newId;\n\t\t\t\t}\n\n\t\t\t\treturn field;\n\t\t\t}\n\n\t\t\tif (field.id === previousId && field.id !== newId) {\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.\n\t\t\t\t// Since field is not a string, we don't exit, as we might have\n\t\t\t\t// something to update further down in customtypes.\n\t\t\t\tfield.id = newId;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...field,\n\t\t\t\tcustomtypes: field.customtypes.map((customType) => {\n\t\t\t\t\treturn updateCRCustomType({\n\t\t\t\t\t\tcustomType,\n\t\t\t\t\t\tpreviousPath,\n\t\t\t\t\t\tnewPath,\n\t\t\t\t\t});\n\t\t\t\t}),\n\t\t\t};\n\t\t});\n\n\t\t// @ts-expect-error We know that at this level we are returning the\n\t\t// right properties, but TypeScript will not trust it because it might\n\t\t// also have customtypes. This is because the type is not fully\n\t\t// recursive, it just has two levels of depth.\n\t\treturn {\n\t\t\tid: customType.id,\n\t\t\tfields: newFields,\n\t\t};\n\t}\n\n\treturn customType;\n}\n\n/**\n * Map over the custom types of a Content Relationship Link and update the API\n * IDs that were changed during the custom type update.\n */\nfunction updateCRCustomTypes(\n\targs: { customTypes: CrCustomTypes } & CustomTypeFieldIdChangedMeta,\n): CrCustomTypes {\n\tconst { customTypes, ...updateMeta } = args;\n\n\treturn customTypes.map((customType) => {\n\t\treturn updateCRCustomType({ customType, ...updateMeta });\n\t});\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 = updateCRCustomTypes({\n\t\t...updateMeta,\n\t\tcustomTypes: field.config.customtypes,\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: CustomType) => void;\n\t} & CustomTypeFieldIdChangedMeta,\n): void {\n\tconst { models, previousPath, newPath, onUpdate } = args;\n\n\tfor (const customType of models) {\n\t\tconst updatedCustomTypeModel = traverseCustomType({\n\t\t\tcustomType: customType.model,\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\tonUpdate(updatedCustomTypeModel);\n\t}\n}\n\nexport function updateSharedSliceContentRelationships(\n\targs: {\n\t\tmodels: { model: SharedSlice }[];\n\t\tonUpdate: (model: SharedSlice) => void;\n\t} & CustomTypeFieldIdChangedMeta,\n): void {\n\tconst { models, previousPath, newPath, onUpdate } = args;\n\n\tfor (const slice of models) {\n\t\tconst updatedSliceModel = traverseSharedSlice({\n\t\t\tpath: [\".\"],\n\t\t\tslice: slice.model,\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\tonUpdate(updatedSliceModel);\n\t}\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\nfunction pushIfDefined<T>(array: T[],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A,MACb,SAAS,CAAC,EAAE,YAAW;AACtB,eAAO,gCAAgC;AAAA,UACtC;AAAA,UACA;AAAA,UACA;AAAA,QAAA,CACA;AAAA,MACF;AAAA,IAAA,CACA;AAED,aAAS,iBAAiB;AAAA,EAC3B;AACD;AAEA,SAAS,qBAAwB,OAAQ;AACpC,MAAA,OAAO,UAAU,UAAU;AACvB,WAAA,EAAE,GAAG;EACb;AAEO,SAAA;AACR;AAEA,SAAS,cAAiB,OAAY,OAAoB;AACzD,MAAI,OAAO;AACV,UAAM,KAAK,KAAK;AAAA,EACjB;AACD;"}
|
1
|
+
{"version":3,"file":"CustomTypesManager.js","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 CustomTypeFieldIdChangedMeta = NonNullable<\n\tNonNullable<CustomTypeUpdateHookData[\"updateMeta\"]>[\"fieldIdChanged\"]\n>;\n\ntype CrCustomTypes = readonly CrCustomType[];\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\tprivate updateCRCustomType(\n\t\targs: { customType: CrCustomType } & CustomTypeFieldIdChangedMeta,\n\t): CrCustomType {\n\t\tconst { previousPath, newPath } = args;\n\n\t\tconst customType = shallowClone(args.customType);\n\n\t\tconst [previousId] = previousPath;\n\t\tconst [newId] = newPath;\n\n\t\tif (!previousId || !newId || typeof customType === \"string\") {\n\t\t\treturn customType;\n\t\t}\n\n\t\tif (customType.fields) {\n\t\t\tconst newFields = customType.fields.map((fieldArg) => {\n\t\t\t\tconst field = shallowClone(fieldArg);\n\n\t\t\t\tconst previousId = previousPath[1];\n\t\t\t\tconst newId = newPath[1];\n\n\t\t\t\tif (!previousId || !newId) {\n\t\t\t\t\treturn field;\n\t\t\t\t}\n\n\t\t\t\tif (typeof field === \"string\") {\n\t\t\t\t\tif (field === previousId && field !== newId) {\n\t\t\t\t\t\t// We have reached a field id that matches the id that was renamed,\n\t\t\t\t\t\t// so we update it new one. The field is a string, so return the new\n\t\t\t\t\t\t// id.\n\t\t\t\t\t\treturn newId;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn field;\n\t\t\t\t}\n\n\t\t\t\tif (field.id === previousId && field.id !== newId) {\n\t\t\t\t\t// We have reached a field id that matches the id that was renamed,\n\t\t\t\t\t// so we update it new one.\n\t\t\t\t\t// Since field is not a string, we don't exit, as we might have\n\t\t\t\t\t// something to update further down in customtypes.\n\t\t\t\t\tfield.id = newId;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...field,\n\t\t\t\t\tcustomtypes: field.customtypes.map((customTypeArg) => {\n\t\t\t\t\t\tconst customType = shallowClone(customTypeArg);\n\t\t\t\t\t\tconst previousId = previousPath[2];\n\t\t\t\t\t\tconst newId = newPath[2];\n\n\t\t\t\t\t\tif (!previousId || !newId) {\n\t\t\t\t\t\t\treturn customType;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (typeof customType === \"string\") {\n\t\t\t\t\t\t\tif (customType === previousId && customType !== newId) {\n\t\t\t\t\t\t\t\t// Matches the previous id, so we update it.\n\t\t\t\t\t\t\t\treturn newId;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn customType;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (customType.id === previousId && customType.id !== newId) {\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 { ...customType, id: newId };\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn customType;\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t});\n\n\t\t\treturn { ...customType, fields: newFields };\n\t\t}\n\n\t\treturn customType;\n\t}\n\n\t/**\n\t * Map over the custom types of a Content Relationship Link and update the API\n\t * IDs that were changed during the custom type update.\n\t */\n\tprivate updateCRCustomTypes(\n\t\targs: { customTypes: CrCustomTypes } & CustomTypeFieldIdChangedMeta,\n\t): CrCustomTypes {\n\t\tconst { customTypes, ...updateMeta } = args;\n\n\t\treturn customTypes.map((customType) => {\n\t\t\treturn this.updateCRCustomType({ customType, ...updateMeta });\n\t\t});\n\t}\n\n\t/**\n\t * Update the Content Relationship API IDs of a single field. The change is\n\t * determined by the `previousPath` and `newPath` properties.\n\t */\n\tprivate updateFieldContentRelationships<\n\t\tT extends UID | NestableWidget | Group | NestedGroup,\n\t>(args: { field: T } & CustomTypeFieldIdChangedMeta): T {\n\t\tconst { field, ...updateMeta } = args;\n\t\tif (\n\t\t\tfield.type !== \"Link\" ||\n\t\t\tfield.config?.select !== \"document\" ||\n\t\t\t!field.config?.customtypes\n\t\t) {\n\t\t\t// not a content relationship field\n\t\t\treturn field;\n\t\t}\n\n\t\tconst newCustomTypes = this.updateCRCustomTypes({\n\t\t\t...updateMeta,\n\t\t\tcustomTypes: field.config.customtypes,\n\t\t});\n\n\t\treturn {\n\t\t\t...field,\n\t\t\tconfig: { ...field.config, customtypes: newCustomTypes },\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: CustomTypeUpdateHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeUpdateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { model, updateMeta } = args;\n\n\t\tif (updateMeta?.fieldIdChanged) {\n\t\t\tlet { previousPath, newPath } = updateMeta.fieldIdChanged;\n\n\t\t\tif (previousPath.join(\".\") !== newPath.join(\".\")) {\n\t\t\t\tpreviousPath = [model.id, ...previousPath];\n\t\t\t\tnewPath = [model.id, ...newPath];\n\n\t\t\t\tconst crUpdates: Promise<{ errors: HookError[] }>[] = [];\n\n\t\t\t\t// Find existing content relationships that link to the renamed field id in\n\t\t\t\t// any custom type and update them to use the new one.\n\t\t\t\tconst customTypes = await this.readAllCustomTypes();\n\n\t\t\t\tfor (const customType of customTypes.models) {\n\t\t\t\t\tconst updatedCustomTypeModel = traverseCustomType({\n\t\t\t\t\t\tcustomType: customType.model,\n\t\t\t\t\t\tonField: ({ field }) => {\n\t\t\t\t\t\t\treturn this.updateFieldContentRelationships({\n\t\t\t\t\t\t\t\tfield,\n\t\t\t\t\t\t\t\tpreviousPath,\n\t\t\t\t\t\t\t\tnewPath,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\n\t\t\t\t\tcrUpdates.push(\n\t\t\t\t\t\tthis.sliceMachinePluginRunner.callHook(\"custom-type:update\", {\n\t\t\t\t\t\t\tmodel: updatedCustomTypeModel,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Find existing slice with content relationships that link to the renamed\n\t\t\t\t// field id in all libraries and update them to use the new one.\n\t\t\t\tconst { libraries } = await this.slices.readAllSliceLibraries();\n\n\t\t\t\tfor (const library of libraries) {\n\t\t\t\t\tconst slices = await this.slices.readAllSlicesForLibrary({\n\t\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t\t});\n\n\t\t\t\t\tfor (const slice of slices.models) {\n\t\t\t\t\t\tconst updatedSliceModel = traverseSharedSlice({\n\t\t\t\t\t\t\tpath: [\".\"],\n\t\t\t\t\t\t\tslice: slice.model,\n\t\t\t\t\t\t\tonField: ({ field }) => {\n\t\t\t\t\t\t\t\treturn this.updateFieldContentRelationships({\n\t\t\t\t\t\t\t\t\tfield,\n\t\t\t\t\t\t\t\t\tpreviousPath,\n\t\t\t\t\t\t\t\t\tnewPath,\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\n\t\t\t\t\t\tcrUpdates.push(\n\t\t\t\t\t\t\tthis.sliceMachinePluginRunner.callHook(\"slice:update\", {\n\t\t\t\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t\t\t\t\tmodel: updatedSliceModel,\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\n\t\t\t\t// Process all the Content Relationship updates at once.\n\t\t\t\tconst crUpdatesResult = await Promise.all(crUpdates);\n\n\t\t\t\tif (crUpdatesResult.some((result) => result.errors.length > 0)) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\terrors: crUpdatesResult.flatMap((result) => result.errors),\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<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\tif (args.updateMeta?.fieldIdChanged) {\n\t\t\tawait this.updateContentRelationships(args);\n\t\t}\n\n\t\treturn { errors: hookResult.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 shallowClone<T>(value: T): T {\n\tif (typeof value === \"object\") {\n\t\treturn { ...value };\n\t}\n\n\treturn value;\n}\n"],"names":["errors","previousId","newId","customType"],"mappings":";;;;;;;;;;;AAyGM,MAAO,2BAA2B,YAAW;AAAA,EAClD,MAAM,wBAAqB;;AAC1B,6BAAyB,KAAK,wBAAwB;AAEtD,UAAM,aAAa,MAAM,KAAK,yBAAyB,SACtD,4BACA,MAAS;AAEV,UAAM,EAAE,MAAM,OAAA,IAAW,iBACxB,EAAE,KAAK;AAAA,MACN,KAAK,EAAE,MAAM,EAAE,MAAM;AAAA,IAAA,CACrB,GACD,UAAU;AAGJ,WAAA;AAAA,MACN,OAAK,UAAK,CAAC,MAAN,mBAAS,QAAO,CAAE;AAAA,MACvB;AAAA,IAAA;AAAA,EAEF;AAAA,EAEA,MAAM,mBACL,MAA+C;AAE/C,6BAAyB,KAAK,wBAAwB;AAEtD,UAAM,MAAsD;AAAA,MAC3D,QAAQ,CAAE;AAAA,M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gB;AAAA,MACxC;AAAA,IAAA,CACA;AAED,UAAM,MAAM,IAAI,IAAI,kBAAkB,cAAc,iBAAiB;AACjE,QAAA,SAAS,aAAa;AAE1B,UAAM,WAAW,MAAM,MAAM,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,qBAAqB,EAAE,OAAO;AAAA,EACnC,OAAO,EAAE,OAAA,EAAS,UAAU,CAAC,OAAO,QAAO;AACpC,UAAA,SAAS,YAAY,OAAO,KAAK;AACnC,QAAA,OAAO,SAAS,SAAS;AAC5B,aAAO,OAAO;AAAA,IACf;AACA,QAAI,SAAS;AAAA,MACZ,MAAM,EAAE,aAAa;AAAA,MACrB,SAAS,yBAAyB,KAAK,UAAU,OAAO,MAAM,CAAC;AAAA,IAAA,CAC/D;AAED,WAAO,EAAE;AAAA,EAAA,CACT;AAAA,EACD,cAAc,EAAE,OAAS,EAAA,IAAA,EAAM,SAAU;AACzC,CAAA;AAED,SAAS,aAAgB,OAAQ;AAC5B,MAAA,OAAO,UAAU,UAAU;AACvB,WAAA,EAAE,GAAG;EACb;AAEO,SAAA;AACR;"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@slicemachine/manager",
|
3
|
-
"version": "0.24.14-alpha.jp-update-cr-links-
|
3
|
+
"version": "0.24.14-alpha.jp-update-cr-links-remove-recursion.1",
|
4
4
|
"description": "Manage all aspects of a Slice Machine project.",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -70,7 +70,7 @@
|
|
70
70
|
"@prismicio/mocks": "2.13.0",
|
71
71
|
"@prismicio/types-internal": "3.10.0-alpha.0",
|
72
72
|
"@segment/analytics-node": "^2.1.2",
|
73
|
-
"@slicemachine/plugin-kit": "0.4.76-alpha.jp-update-cr-links-
|
73
|
+
"@slicemachine/plugin-kit": "0.4.76-alpha.jp-update-cr-links-remove-recursion.1",
|
74
74
|
"cookie": "^1.0.1",
|
75
75
|
"cors": "^2.8.5",
|
76
76
|
"execa": "^7.1.1",
|