@stackbit/cms-core 0.2.1 → 0.3.0-develop.0
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/content-store-utils.d.ts +5 -1
- package/dist/content-store-utils.d.ts.map +1 -1
- package/dist/content-store-utils.js +28 -3
- package/dist/content-store-utils.js.map +1 -1
- package/dist/content-store.d.ts +12 -1
- package/dist/content-store.d.ts.map +1 -1
- package/dist/content-store.js +399 -177
- package/dist/content-store.js.map +1 -1
- package/dist/types/content-store-document-fields.d.ts +26 -4
- package/dist/types/content-store-document-fields.d.ts.map +1 -1
- package/dist/types/content-store-documents.d.ts +14 -3
- package/dist/types/content-store-documents.d.ts.map +1 -1
- package/dist/types/content-store-types.d.ts +7 -1
- package/dist/types/content-store-types.d.ts.map +1 -1
- package/dist/utils/backward-compatibility.d.ts +184 -0
- package/dist/utils/backward-compatibility.d.ts.map +1 -0
- package/dist/utils/backward-compatibility.js +151 -0
- package/dist/utils/backward-compatibility.js.map +1 -0
- package/dist/utils/config-delegate.d.ts +11 -0
- package/dist/utils/config-delegate.d.ts.map +1 -0
- package/dist/utils/config-delegate.js +226 -0
- package/dist/utils/config-delegate.js.map +1 -0
- package/dist/utils/create-update-csi-docs.d.ts +7 -5
- package/dist/utils/create-update-csi-docs.d.ts.map +1 -1
- package/dist/utils/create-update-csi-docs.js +24 -24
- package/dist/utils/create-update-csi-docs.js.map +1 -1
- package/dist/utils/csi-to-store-docs-converter.d.ts +17 -3
- package/dist/utils/csi-to-store-docs-converter.d.ts.map +1 -1
- package/dist/utils/csi-to-store-docs-converter.js +187 -47
- package/dist/utils/csi-to-store-docs-converter.js.map +1 -1
- package/dist/utils/site-map.d.ts.map +1 -1
- package/dist/utils/site-map.js +4 -1
- package/dist/utils/site-map.js.map +1 -1
- package/dist/utils/store-to-api-docs-converter.d.ts +6 -1
- package/dist/utils/store-to-api-docs-converter.d.ts.map +1 -1
- package/dist/utils/store-to-api-docs-converter.js +140 -51
- package/dist/utils/store-to-api-docs-converter.js.map +1 -1
- package/dist/utils/store-to-csi-docs-converter.d.ts +1 -0
- package/dist/utils/store-to-csi-docs-converter.d.ts.map +1 -1
- package/dist/utils/store-to-csi-docs-converter.js +2 -1
- package/dist/utils/store-to-csi-docs-converter.js.map +1 -1
- package/package.json +5 -5
- package/src/content-store-utils.ts +40 -6
- package/src/content-store.ts +552 -299
- package/src/types/content-store-document-fields.ts +16 -4
- package/src/types/content-store-documents.ts +12 -3
- package/src/types/content-store-types.ts +4 -1
- package/src/utils/backward-compatibility.ts +269 -0
- package/src/utils/config-delegate.ts +277 -0
- package/src/utils/create-update-csi-docs.ts +47 -50
- package/src/utils/csi-to-store-docs-converter.ts +256 -43
- package/src/utils/site-map.ts +19 -7
- package/src/utils/store-to-api-docs-converter.ts +185 -52
- package/src/utils/store-to-csi-docs-converter.ts +1 -1
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import * as CSITypes from '@stackbit/types';
|
|
2
|
+
/**
|
|
3
|
+
* AnyContentSourceInterface is the union of the previous ContentSourceInterface
|
|
4
|
+
* versions.
|
|
5
|
+
*
|
|
6
|
+
* When changing the ContentSourceInterface in a way that it may break previous
|
|
7
|
+
* content source modules, create a new type by omitting the changed methods and
|
|
8
|
+
* redefine them with their new signatures. Then add the new type to the union.
|
|
9
|
+
*/
|
|
10
|
+
export declare type AnyContentSourceInterface = ContentSourceInterface_v0_1_0 | ContentSourceInterface_v0_2_0;
|
|
11
|
+
export declare type ContentSourceInterface_v0_2_0 = CSITypes.ContentSourceInterface;
|
|
12
|
+
export declare type ContentSourceInterface_v0_1_0 = Omit<CSITypes.ContentSourceInterface, 'getVersion' | 'init' | 'destroy' | 'getSchema' | 'onFilesChange' | 'startWatchingContentUpdates' | 'stopWatchingContentUpdates' | 'hasAccess' | 'getDocuments' | 'createDocument' | 'updateDocument'> & {
|
|
13
|
+
init(options: {
|
|
14
|
+
logger: CSITypes.Logger;
|
|
15
|
+
userLogger: CSITypes.Logger;
|
|
16
|
+
userCommandSpawner?: CSITypes.UserCommandSpawner;
|
|
17
|
+
localDev: boolean;
|
|
18
|
+
webhookUrl?: string;
|
|
19
|
+
devAppRestartNeeded?: () => void;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
getModels(): Promise<CSITypes.Model[]>;
|
|
22
|
+
getLocales(): Promise<CSITypes.Locale[]>;
|
|
23
|
+
onFilesChange?(options: {
|
|
24
|
+
updatedFiles: string[];
|
|
25
|
+
}): Promise<{
|
|
26
|
+
schemaChanged?: boolean;
|
|
27
|
+
contentChangeEvent?: CSITypes.ContentChangeEvent;
|
|
28
|
+
}>;
|
|
29
|
+
startWatchingContentUpdates(options: {
|
|
30
|
+
getModelMap: () => CSITypes.ModelMap;
|
|
31
|
+
getDocument: ({ documentId }: {
|
|
32
|
+
documentId: string;
|
|
33
|
+
}) => CSITypes.Document | undefined;
|
|
34
|
+
getAsset: ({ assetId }: {
|
|
35
|
+
assetId: string;
|
|
36
|
+
}) => CSITypes.Asset | undefined;
|
|
37
|
+
onContentChange: (contentChangeEvent: CSITypes.ContentChangeEvent) => Promise<void>;
|
|
38
|
+
onSchemaChange: () => void;
|
|
39
|
+
}): void;
|
|
40
|
+
stopWatchingContentUpdates(): void;
|
|
41
|
+
hasAccess(options: {
|
|
42
|
+
userContext?: unknown;
|
|
43
|
+
}): boolean | Promise<{
|
|
44
|
+
hasConnection: boolean;
|
|
45
|
+
hasPermissions: boolean;
|
|
46
|
+
}>;
|
|
47
|
+
getDocuments(options: {
|
|
48
|
+
modelMap: CSITypes.ModelMap;
|
|
49
|
+
}): Promise<CSITypes.Document[]>;
|
|
50
|
+
createDocument(options: {
|
|
51
|
+
updateOperationFields: Record<string, CSITypes.UpdateOperationField>;
|
|
52
|
+
model: CSITypes.Model;
|
|
53
|
+
modelMap: CSITypes.ModelMap;
|
|
54
|
+
locale?: string;
|
|
55
|
+
defaultLocaleDocumentId?: string;
|
|
56
|
+
userContext?: unknown;
|
|
57
|
+
}): Promise<CSITypes.Document>;
|
|
58
|
+
updateDocument(options: {
|
|
59
|
+
document: CSITypes.Document;
|
|
60
|
+
operations: CSITypes.UpdateOperation[];
|
|
61
|
+
modelMap: CSITypes.ModelMap;
|
|
62
|
+
userContext?: unknown;
|
|
63
|
+
}): Promise<CSITypes.Document>;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* BackCompatContentSourceInterface redefines the ContentSourceInterface such
|
|
67
|
+
* that when its methods are called, it can correctly invoke the previous
|
|
68
|
+
* content source module versions.
|
|
69
|
+
*
|
|
70
|
+
* The parameters of its methods must be intersections of the parameters in the
|
|
71
|
+
* previous versions. For example, if a method in an older version received
|
|
72
|
+
* 'options.x', and a method in the newer version receives 'options.y', the
|
|
73
|
+
* matching method should receive both options '{ x } & { y }' to ensure that
|
|
74
|
+
* both the older and the newer content sources will receive what they need.
|
|
75
|
+
*
|
|
76
|
+
* The method return values must match the most recent content source versions.
|
|
77
|
+
*/
|
|
78
|
+
export declare type BackCompatContentSourceInterface = Omit<CSITypes.ContentSourceInterface, 'getVersion' | 'onFilesChange' | 'startWatchingContentUpdates' | 'hasAccess' | 'getDocuments' | 'createDocument' | 'updateDocument'> & {
|
|
79
|
+
getVersion(): GetVersionReturn;
|
|
80
|
+
onFilesChange(options: BCOnFilesChangeOptions): OnFilesChangeReturn;
|
|
81
|
+
startWatchingContentUpdates?(options: BCStartWatchingOptions): StartWatchingReturn;
|
|
82
|
+
hasAccess(options: BCHasAccessOptions): HasAccessReturn;
|
|
83
|
+
getDocuments(options: BCGetDocumentsOptions): GetDocumentsReturn;
|
|
84
|
+
createDocument(options: BCCreateDocumentOptions): CreateDocumentReturn;
|
|
85
|
+
updateDocument(options: BCUpdateDocumentOptions): UpdateDocumentReturn;
|
|
86
|
+
};
|
|
87
|
+
export declare function backwardCompatibleContentSource(contentSource: AnyContentSourceInterface): BackCompatContentSourceInterface;
|
|
88
|
+
declare type ReturnTypeOfMethod<Method extends keyof CSITypes.ContentSourceInterface> = ReturnType<NonNullable<CSITypes.ContentSourceInterface[Method]>>;
|
|
89
|
+
declare type GetVersionReturn = Promise<{
|
|
90
|
+
interfaceVersion: string;
|
|
91
|
+
contentSourceVersion: string;
|
|
92
|
+
}>;
|
|
93
|
+
export declare function getVersion(contentSource: AnyContentSourceInterface): GetVersionReturn;
|
|
94
|
+
declare type DestroyReturn = ReturnTypeOfMethod<'destroy'>;
|
|
95
|
+
export declare function destroy(contentSource: AnyContentSourceInterface): DestroyReturn;
|
|
96
|
+
declare type BCOnFilesChangeOptions = {
|
|
97
|
+
updatedFiles: string[];
|
|
98
|
+
};
|
|
99
|
+
declare type OnFilesChangeReturn = ReturnTypeOfMethod<'onFilesChange'>;
|
|
100
|
+
/**
|
|
101
|
+
* Converts the old onFilesChange API to the new one
|
|
102
|
+
* OLD: onFilesChange?(options: { updatedFiles: string[]; }):
|
|
103
|
+
* Promise<{ schemaChanged?: boolean; contentChangeEvent?: ContentChangeEvent<DocumentContext, AssetContext> }>
|
|
104
|
+
* NEW: onFilesChange?(options: { updatedFiles: string[]; }):
|
|
105
|
+
* Promise<{ invalidateSchema?: boolean; contentChanges?: ContentChanges<DocumentContext, AssetContext> }>
|
|
106
|
+
*/
|
|
107
|
+
export declare function onFilesChange(contentSource: AnyContentSourceInterface, options: BCOnFilesChangeOptions): OnFilesChangeReturn;
|
|
108
|
+
declare type BCStartWatchingOptions = {
|
|
109
|
+
getModelMap: () => CSITypes.ModelMap;
|
|
110
|
+
getDocument: ({ documentId }: {
|
|
111
|
+
documentId: string;
|
|
112
|
+
}) => CSITypes.Document | undefined;
|
|
113
|
+
getAsset: ({ assetId }: {
|
|
114
|
+
assetId: string;
|
|
115
|
+
}) => CSITypes.Asset | undefined;
|
|
116
|
+
onContentChange: (contentChangeEvent: CSITypes.ContentChangeEvent) => Promise<void>;
|
|
117
|
+
onSchemaChange: () => void;
|
|
118
|
+
};
|
|
119
|
+
declare type StartWatchingReturn = ReturnTypeOfMethod<'startWatchingContentUpdates'>;
|
|
120
|
+
/**
|
|
121
|
+
* Converts between the old startWatchingContentUpdates API and the new one.
|
|
122
|
+
* OLD: startWatchingContentUpdates(options: startWatchingContentUpdatesOptionsOld): void;
|
|
123
|
+
* NEW: startWatchingContentUpdates?(): void;
|
|
124
|
+
*/
|
|
125
|
+
export declare function startWatchingContentUpdates(contentSource: AnyContentSourceInterface, options: BCStartWatchingOptions): StartWatchingReturn;
|
|
126
|
+
/**
|
|
127
|
+
* Converts the old getModels() and getLocales() API methods to the new getSchema() API method.
|
|
128
|
+
* OLD:
|
|
129
|
+
* getModels(): Promise<Model[]>;
|
|
130
|
+
* getLocales(): Promise<Locale[]>
|
|
131
|
+
* NEW:
|
|
132
|
+
* getSchema(): Promise<Schema<SchemaContext>>
|
|
133
|
+
*/
|
|
134
|
+
export declare function getSchema(contentSource: AnyContentSourceInterface): Promise<CSITypes.Schema>;
|
|
135
|
+
declare type HasAccessReturn = ReturnTypeOfMethod<'hasAccess'>;
|
|
136
|
+
declare type BCHasAccessOptions = {
|
|
137
|
+
userContext?: unknown;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Converts the old hasAccess API to the new one
|
|
141
|
+
* OLD: hasAccess(options: { userContext?: UserContext }): Promise<boolean>
|
|
142
|
+
* NEW: hasAccess(options: { userContext?: UserContext }): Promise<{ hasConnection: boolean; hasPermissions: boolean }>
|
|
143
|
+
*/
|
|
144
|
+
export declare function hasAccess(contentSource: AnyContentSourceInterface, options: BCHasAccessOptions): HasAccessReturn;
|
|
145
|
+
declare type BCGetDocumentsOptions = {
|
|
146
|
+
modelMap: CSITypes.ModelMap;
|
|
147
|
+
};
|
|
148
|
+
declare type GetDocumentsReturn = ReturnTypeOfMethod<'getDocuments'>;
|
|
149
|
+
/**
|
|
150
|
+
* Converts the old getDocuments API to the new one
|
|
151
|
+
* OLD: getDocuments(options: { modelMap: ModelMap }): Promise<Document[]>
|
|
152
|
+
* NEW: getDocuments(): Promise<Document[]>
|
|
153
|
+
*/
|
|
154
|
+
export declare function getDocuments(contentSource: AnyContentSourceInterface, options: BCGetDocumentsOptions): GetDocumentsReturn;
|
|
155
|
+
declare type BCCreateDocumentOptions = {
|
|
156
|
+
updateOperationFields: Record<string, CSITypes.UpdateOperationField>;
|
|
157
|
+
model: CSITypes.Model;
|
|
158
|
+
modelMap: CSITypes.ModelMap;
|
|
159
|
+
locale?: string;
|
|
160
|
+
defaultLocaleDocumentId?: string;
|
|
161
|
+
userContext?: unknown;
|
|
162
|
+
};
|
|
163
|
+
declare type CreateDocumentReturn = ReturnTypeOfMethod<'createDocument'>;
|
|
164
|
+
/**
|
|
165
|
+
* Converts the old createDocument API to the new one
|
|
166
|
+
* OLD: createDocument(options: Options & { modelMap: ModelMap }): Promise<Document<DocumentContext>>
|
|
167
|
+
* NEW: createDocument(options: Options): Promise<{ documentId: string }>
|
|
168
|
+
*/
|
|
169
|
+
export declare function createDocument(contentSource: AnyContentSourceInterface, options: BCCreateDocumentOptions): CreateDocumentReturn;
|
|
170
|
+
declare type UpdateDocumentReturn = ReturnTypeOfMethod<'updateDocument'>;
|
|
171
|
+
declare type BCUpdateDocumentOptions = {
|
|
172
|
+
document: CSITypes.Document;
|
|
173
|
+
operations: CSITypes.UpdateOperation[];
|
|
174
|
+
modelMap: CSITypes.ModelMap;
|
|
175
|
+
userContext?: unknown;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Converts the old updateDocument API to the new one
|
|
179
|
+
* OLD: updateDocument(options: Options & { modelMap: ModelMap }): Promise<CSITypes.Document>;
|
|
180
|
+
* NEW: updateDocument(options: Options): Promise<void>
|
|
181
|
+
*/
|
|
182
|
+
export declare function updateDocument(contentSource: AnyContentSourceInterface, options: BCUpdateDocumentOptions): UpdateDocumentReturn;
|
|
183
|
+
export {};
|
|
184
|
+
//# sourceMappingURL=backward-compatibility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backward-compatibility.d.ts","sourceRoot":"","sources":["../../src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Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateDocument = exports.createDocument = exports.getDocuments = exports.hasAccess = exports.getSchema = exports.startWatchingContentUpdates = exports.onFilesChange = exports.destroy = exports.getVersion = exports.backwardCompatibleContentSource = void 0;
|
|
4
|
+
function backwardCompatibleContentSource(contentSource) {
|
|
5
|
+
return new Proxy(contentSource, {
|
|
6
|
+
get(target, prop) {
|
|
7
|
+
switch (prop) {
|
|
8
|
+
case 'getVersion':
|
|
9
|
+
return getVersion.bind(undefined, target);
|
|
10
|
+
case 'destroy':
|
|
11
|
+
return destroy.bind(undefined, target);
|
|
12
|
+
case 'onFilesChange':
|
|
13
|
+
return onFilesChange.bind(undefined, target);
|
|
14
|
+
case 'startWatchingContentUpdates':
|
|
15
|
+
return startWatchingContentUpdates.bind(undefined, target);
|
|
16
|
+
case 'getSchema':
|
|
17
|
+
return getSchema.bind(undefined, target);
|
|
18
|
+
case 'hasAccess':
|
|
19
|
+
return hasAccess.bind(undefined, target);
|
|
20
|
+
case 'getDocuments':
|
|
21
|
+
return getDocuments.bind(undefined, target);
|
|
22
|
+
case 'createDocument':
|
|
23
|
+
return createDocument.bind(undefined, target);
|
|
24
|
+
case 'updateDocument':
|
|
25
|
+
return updateDocument.bind(undefined, target);
|
|
26
|
+
default:
|
|
27
|
+
return target[prop];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
exports.backwardCompatibleContentSource = backwardCompatibleContentSource;
|
|
33
|
+
async function getVersion(contentSource) {
|
|
34
|
+
if ('getVersion' in contentSource) {
|
|
35
|
+
return contentSource.getVersion();
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
interfaceVersion: '0.1.0',
|
|
39
|
+
contentSourceVersion: ''
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
exports.getVersion = getVersion;
|
|
43
|
+
async function destroy(contentSource) {
|
|
44
|
+
if ('destroy' in contentSource) {
|
|
45
|
+
return contentSource.destroy();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.destroy = destroy;
|
|
49
|
+
/**
|
|
50
|
+
* Converts the old onFilesChange API to the new one
|
|
51
|
+
* OLD: onFilesChange?(options: { updatedFiles: string[]; }):
|
|
52
|
+
* Promise<{ schemaChanged?: boolean; contentChangeEvent?: ContentChangeEvent<DocumentContext, AssetContext> }>
|
|
53
|
+
* NEW: onFilesChange?(options: { updatedFiles: string[]; }):
|
|
54
|
+
* Promise<{ invalidateSchema?: boolean; contentChanges?: ContentChanges<DocumentContext, AssetContext> }>
|
|
55
|
+
*/
|
|
56
|
+
async function onFilesChange(contentSource, options) {
|
|
57
|
+
var _a;
|
|
58
|
+
const value = await ((_a = contentSource.onFilesChange) === null || _a === void 0 ? void 0 : _a.call(contentSource, options));
|
|
59
|
+
if (!value) {
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
// if there are properties from the new API return the value as is
|
|
63
|
+
if ('invalidateSchema' in value || 'contentChanges' in value) {
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
// if there are properties from the old API return convert to the new API value
|
|
67
|
+
const result = {};
|
|
68
|
+
if ('schemaChanged' in value) {
|
|
69
|
+
result.invalidateSchema = value.schemaChanged;
|
|
70
|
+
}
|
|
71
|
+
if ('contentChangeEvent' in value) {
|
|
72
|
+
result.contentChanges = value.contentChangeEvent;
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
exports.onFilesChange = onFilesChange;
|
|
77
|
+
/**
|
|
78
|
+
* Converts between the old startWatchingContentUpdates API and the new one.
|
|
79
|
+
* OLD: startWatchingContentUpdates(options: startWatchingContentUpdatesOptionsOld): void;
|
|
80
|
+
* NEW: startWatchingContentUpdates?(): void;
|
|
81
|
+
*/
|
|
82
|
+
function startWatchingContentUpdates(contentSource, options) {
|
|
83
|
+
var _a;
|
|
84
|
+
(_a = contentSource.startWatchingContentUpdates) === null || _a === void 0 ? void 0 : _a.call(contentSource, options);
|
|
85
|
+
}
|
|
86
|
+
exports.startWatchingContentUpdates = startWatchingContentUpdates;
|
|
87
|
+
/**
|
|
88
|
+
* Converts the old getModels() and getLocales() API methods to the new getSchema() API method.
|
|
89
|
+
* OLD:
|
|
90
|
+
* getModels(): Promise<Model[]>;
|
|
91
|
+
* getLocales(): Promise<Locale[]>
|
|
92
|
+
* NEW:
|
|
93
|
+
* getSchema(): Promise<Schema<SchemaContext>>
|
|
94
|
+
*/
|
|
95
|
+
async function getSchema(contentSource) {
|
|
96
|
+
if ('getSchema' in contentSource) {
|
|
97
|
+
return contentSource.getSchema();
|
|
98
|
+
}
|
|
99
|
+
const models = await contentSource.getModels();
|
|
100
|
+
const locales = await contentSource.getLocales();
|
|
101
|
+
return { models, locales, context: null };
|
|
102
|
+
}
|
|
103
|
+
exports.getSchema = getSchema;
|
|
104
|
+
/**
|
|
105
|
+
* Converts the old hasAccess API to the new one
|
|
106
|
+
* OLD: hasAccess(options: { userContext?: UserContext }): Promise<boolean>
|
|
107
|
+
* NEW: hasAccess(options: { userContext?: UserContext }): Promise<{ hasConnection: boolean; hasPermissions: boolean }>
|
|
108
|
+
*/
|
|
109
|
+
async function hasAccess(contentSource, options) {
|
|
110
|
+
const result = await contentSource.hasAccess(options);
|
|
111
|
+
if (typeof result === 'boolean') {
|
|
112
|
+
return {
|
|
113
|
+
hasConnection: result,
|
|
114
|
+
hasPermissions: result
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
exports.hasAccess = hasAccess;
|
|
120
|
+
/**
|
|
121
|
+
* Converts the old getDocuments API to the new one
|
|
122
|
+
* OLD: getDocuments(options: { modelMap: ModelMap }): Promise<Document[]>
|
|
123
|
+
* NEW: getDocuments(): Promise<Document[]>
|
|
124
|
+
*/
|
|
125
|
+
async function getDocuments(contentSource, options) {
|
|
126
|
+
return contentSource.getDocuments(options);
|
|
127
|
+
}
|
|
128
|
+
exports.getDocuments = getDocuments;
|
|
129
|
+
/**
|
|
130
|
+
* Converts the old createDocument API to the new one
|
|
131
|
+
* OLD: createDocument(options: Options & { modelMap: ModelMap }): Promise<Document<DocumentContext>>
|
|
132
|
+
* NEW: createDocument(options: Options): Promise<{ documentId: string }>
|
|
133
|
+
*/
|
|
134
|
+
async function createDocument(contentSource, options) {
|
|
135
|
+
const result = await contentSource.createDocument(options);
|
|
136
|
+
if ('id' in result) {
|
|
137
|
+
return { documentId: result.id };
|
|
138
|
+
}
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
exports.createDocument = createDocument;
|
|
142
|
+
/**
|
|
143
|
+
* Converts the old updateDocument API to the new one
|
|
144
|
+
* OLD: updateDocument(options: Options & { modelMap: ModelMap }): Promise<CSITypes.Document>;
|
|
145
|
+
* NEW: updateDocument(options: Options): Promise<void>
|
|
146
|
+
*/
|
|
147
|
+
async function updateDocument(contentSource, options) {
|
|
148
|
+
await contentSource.updateDocument(options);
|
|
149
|
+
}
|
|
150
|
+
exports.updateDocument = updateDocument;
|
|
151
|
+
//# sourceMappingURL=backward-compatibility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backward-compatibility.js","sourceRoot":"","sources":["../../src/utils/backward-compatibility.ts"],"names":[],"mappings":";;;AA2FA,SAAgB,+BAA+B,CAAC,aAAwC;IACpF,OAAO,IAAI,KAAK,CAAC,aAAa,EAAE;QAC5B,GAAG,CAAC,MAAiC,EAAE,IAA2C;YAC9E,QAAQ,IAAI,EAAE;gBACV,KAAK,YAAY;oBACb,OAAO,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;gBAC9C,KAAK,SAAS;oBACV,OAAO,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;gBAC3C,KAAK,eAAe;oBAChB,OAAO,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;gBACjD,KAAK,6BAA6B;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;;;;GAIG;AACI,KAAK,UAAU,YAAY,CAAC,aAAwC,EAAE,OAA8B;IACvG,OAAO,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AAC/C,CAAC;AAFD,oCAEC;AAWD;;;;GAIG;AACI,KAAK,UAAU,cAAc,CAAC,aAAwC,EAAE,OAAgC;IAC3G,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAC3D,IAAI,IAAI,IAAI,MAAM,EAAE;QAChB,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;KACpC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAND,wCAMC;AASD;;;;GAIG;AACI,KAAK,UAAU,cAAc,CAAC,aAAwC,EAAE,OAAgC;IAC3G,MAAM,aAAa,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AAChD,CAAC;AAFD,wCAEC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as CSITypes from '@stackbit/types';
|
|
2
|
+
import * as ContentStoreTypes from '../types';
|
|
3
|
+
export declare function getCreateConfigDelegateThunk({ getContentSourceDataById, logger }: {
|
|
4
|
+
getContentSourceDataById: () => Record<string, ContentStoreTypes.ContentSourceData>;
|
|
5
|
+
logger: CSITypes.Logger;
|
|
6
|
+
}): () => CSITypes.ConfigDelegate;
|
|
7
|
+
export declare function createConfigDelegate({ contentSourceDataById, logger }: {
|
|
8
|
+
contentSourceDataById: Record<string, ContentStoreTypes.ContentSourceData>;
|
|
9
|
+
logger: CSITypes.Logger;
|
|
10
|
+
}): CSITypes.ConfigDelegate;
|
|
11
|
+
//# sourceMappingURL=config-delegate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-delegate.d.ts","sourceRoot":"","sources":["../../src/utils/config-delegate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,iBAAiB,MAAM,UAAU,CAAC;AAI9C,wBAAgB,4BAA4B,CAAC,EACzC,wBAAwB,EACxB,MAAM,EACT,EAAE;IACC,wBAAwB,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IACpF,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC;CAC3B,GAAG,MAAM,QAAQ,CAAC,cAAc,CAMhC;AAED,wBAAgB,oBAAoB,CAAC,EACjC,qBAAqB,EACrB,MAAM,EACT,EAAE;IACC,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAC3E,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC;CAC3B,GAAG,QAAQ,CAAC,cAAc,CAsI1B"}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createConfigDelegate = exports.getCreateConfigDelegateThunk = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const types_1 = require("@stackbit/types");
|
|
9
|
+
const content_store_utils_1 = require("../content-store-utils");
|
|
10
|
+
const store_to_csi_docs_converter_1 = require("./store-to-csi-docs-converter");
|
|
11
|
+
function getCreateConfigDelegateThunk({ getContentSourceDataById, logger }) {
|
|
12
|
+
return () => createConfigDelegate({
|
|
13
|
+
contentSourceDataById: getContentSourceDataById(),
|
|
14
|
+
logger: logger
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
exports.getCreateConfigDelegateThunk = getCreateConfigDelegateThunk;
|
|
18
|
+
function createConfigDelegate({ contentSourceDataById, logger }) {
|
|
19
|
+
return {
|
|
20
|
+
getDocumentById: ({ id, srcType, srcProjectId }) => {
|
|
21
|
+
const document = findDocumentByIdAndSourceTypeOrId({
|
|
22
|
+
contentSourceDataById,
|
|
23
|
+
documentId: id,
|
|
24
|
+
srcType,
|
|
25
|
+
srcProjectId,
|
|
26
|
+
logger
|
|
27
|
+
});
|
|
28
|
+
if (document) {
|
|
29
|
+
return (0, store_to_csi_docs_converter_1.mapStoreDocumentToCSIDocumentWithSource)(document);
|
|
30
|
+
}
|
|
31
|
+
return undefined;
|
|
32
|
+
},
|
|
33
|
+
getModelByName: ({ modelName, srcType, srcProjectId }) => {
|
|
34
|
+
return findModelByNameAndSourceTypeOrId({
|
|
35
|
+
contentSourceDataById,
|
|
36
|
+
modelName,
|
|
37
|
+
srcType,
|
|
38
|
+
srcProjectId,
|
|
39
|
+
logger
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
getDefaultLocaleBySource: ({ srcType, srcProjectId }) => {
|
|
43
|
+
var _a;
|
|
44
|
+
// if srcType and srcProjectId are provided, use them to get the specific contentSourceData without trying to infer the right model
|
|
45
|
+
if (srcType && srcProjectId) {
|
|
46
|
+
const contentSourceId = (0, content_store_utils_1.getContentSourceId)(srcType, srcProjectId);
|
|
47
|
+
return (_a = contentSourceDataById[contentSourceId]) === null || _a === void 0 ? void 0 : _a.defaultLocaleCode;
|
|
48
|
+
}
|
|
49
|
+
const contentSourcesData = findContentSourcesDataForTypeOrId({
|
|
50
|
+
contentSourceDataById,
|
|
51
|
+
srcType,
|
|
52
|
+
srcProjectId
|
|
53
|
+
});
|
|
54
|
+
if (contentSourcesData.length === 1) {
|
|
55
|
+
return contentSourcesData[0].defaultLocaleCode;
|
|
56
|
+
}
|
|
57
|
+
else if (contentSourcesData.length > 1) {
|
|
58
|
+
logger.warn(`The getDefaultLocaleBySource() found more than one content sources for '${srcType}'. ` +
|
|
59
|
+
`Please specify 'srcType' and 'srcProjectId' to narrow down the search.`);
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
},
|
|
63
|
+
getDocumentFieldForFieldPath: ({ document, fromField, fieldPath, locale }) => {
|
|
64
|
+
const fieldPathArr = lodash_1.default.toPath(fieldPath);
|
|
65
|
+
const contentSourceId = (0, content_store_utils_1.getContentSourceId)(document.srcType, document.srcProjectId);
|
|
66
|
+
const contentSource = contentSourceDataById[contentSourceId];
|
|
67
|
+
if (!contentSource) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
function getNestedFieldFromFieldsForPath(fields, fieldPathArr, currentContentSource) {
|
|
71
|
+
const fieldName = fieldPathArr[0];
|
|
72
|
+
fieldPathArr = fieldPathArr.slice(1);
|
|
73
|
+
if (!fieldName) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
const field = fields[fieldName];
|
|
77
|
+
if (!field) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
const resolvedLocale = locale !== null && locale !== void 0 ? locale : currentContentSource.defaultLocaleCode;
|
|
81
|
+
const nonLocalizedField = (0, types_1.getLocalizedFieldForLocale)(field, resolvedLocale);
|
|
82
|
+
if (!nonLocalizedField) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
if (fieldPathArr.length === 0) {
|
|
86
|
+
return nonLocalizedField;
|
|
87
|
+
}
|
|
88
|
+
return getNestedFieldFromLocalizedFieldForPath(nonLocalizedField, fieldPathArr, currentContentSource);
|
|
89
|
+
}
|
|
90
|
+
function getNestedFieldFromLocalizedFieldForPath(nonLocalizedField, fieldPathArr, currentContentSource) {
|
|
91
|
+
if (nonLocalizedField.type === 'object' || nonLocalizedField.type === 'model') {
|
|
92
|
+
return getNestedFieldFromFieldsForPath(nonLocalizedField.fields, fieldPathArr, currentContentSource);
|
|
93
|
+
}
|
|
94
|
+
else if (nonLocalizedField.type === 'reference') {
|
|
95
|
+
const refDocument = currentContentSource.documentMap[nonLocalizedField.refId];
|
|
96
|
+
if (!refDocument) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
const fields = (0, store_to_csi_docs_converter_1.mapStoreDocumentToCSIDocumentWithSource)(refDocument).fields;
|
|
100
|
+
return getNestedFieldFromFieldsForPath(fields, fieldPathArr, currentContentSource);
|
|
101
|
+
}
|
|
102
|
+
else if (nonLocalizedField.type === 'cross-reference') {
|
|
103
|
+
const contentSourceId = (0, content_store_utils_1.getContentSourceId)(nonLocalizedField.refSrcType, nonLocalizedField.refProjectId);
|
|
104
|
+
const contentSource = contentSourceDataById[contentSourceId];
|
|
105
|
+
if (!contentSource) {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
const refDocument = contentSource.documentMap[nonLocalizedField.refId];
|
|
109
|
+
if (!refDocument) {
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
const fields = (0, store_to_csi_docs_converter_1.mapStoreDocumentToCSIDocumentWithSource)(refDocument).fields;
|
|
113
|
+
return getNestedFieldFromFieldsForPath(fields, fieldPathArr, contentSource);
|
|
114
|
+
}
|
|
115
|
+
else if (nonLocalizedField.type === 'list') {
|
|
116
|
+
const index = lodash_1.default.toNumber(fieldPathArr[0]);
|
|
117
|
+
fieldPathArr = fieldPathArr.slice(1);
|
|
118
|
+
if (lodash_1.default.isNaN(index)) {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
const localizedItem = nonLocalizedField.items[index];
|
|
122
|
+
if (!localizedItem) {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
if (fieldPathArr.length === 0) {
|
|
126
|
+
return localizedItem;
|
|
127
|
+
}
|
|
128
|
+
return getNestedFieldFromLocalizedFieldForPath(localizedItem, fieldPathArr, currentContentSource);
|
|
129
|
+
}
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
if (fromField) {
|
|
133
|
+
const resolvedLocale = locale !== null && locale !== void 0 ? locale : contentSource.defaultLocaleCode;
|
|
134
|
+
const nonLocalizedField = (0, types_1.getLocalizedFieldForLocale)(fromField, resolvedLocale);
|
|
135
|
+
if (!nonLocalizedField) {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
return getNestedFieldFromLocalizedFieldForPath(nonLocalizedField, fieldPathArr, contentSource);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
return getNestedFieldFromFieldsForPath(document.fields, fieldPathArr, contentSource);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
exports.createConfigDelegate = createConfigDelegate;
|
|
147
|
+
function findDocumentByIdAndSourceTypeOrId({ contentSourceDataById, documentId, srcType, srcProjectId, logger }) {
|
|
148
|
+
var _a;
|
|
149
|
+
// if srcType and srcProjectId are provided, use them to get the specific contentSourceData without trying to infer the right document
|
|
150
|
+
if (srcType && srcProjectId) {
|
|
151
|
+
const contentSourceId = (0, content_store_utils_1.getContentSourceId)(srcType, srcProjectId);
|
|
152
|
+
return (_a = contentSourceDataById[contentSourceId]) === null || _a === void 0 ? void 0 : _a.documentMap[documentId];
|
|
153
|
+
}
|
|
154
|
+
const contentSourcesData = findContentSourcesDataForTypeOrId({
|
|
155
|
+
contentSourceDataById,
|
|
156
|
+
srcType,
|
|
157
|
+
srcProjectId
|
|
158
|
+
});
|
|
159
|
+
const matchingDocuments = contentSourcesData.reduce((matchingDocuments, contentSourceData) => {
|
|
160
|
+
const document = contentSourceData.documentMap[documentId];
|
|
161
|
+
if (document) {
|
|
162
|
+
matchingDocuments.push(document);
|
|
163
|
+
}
|
|
164
|
+
return matchingDocuments;
|
|
165
|
+
}, []);
|
|
166
|
+
if (matchingDocuments.length === 1) {
|
|
167
|
+
return matchingDocuments[0];
|
|
168
|
+
}
|
|
169
|
+
else if (matchingDocuments.length > 1) {
|
|
170
|
+
const matchedContentSources = matchingDocuments.map((document) => `srcType: ${document.srcType}, srcProjectId: ${document.srcProjectId}`).join('; ');
|
|
171
|
+
logger.warn(`The getDocumentById() found more than one documents with ID '${documentId}' ` +
|
|
172
|
+
`in the following content sources ${matchedContentSources}. ` +
|
|
173
|
+
`Please specify 'srcType' and/or 'srcProjectId' to narrow down the search.`);
|
|
174
|
+
}
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
function findModelByNameAndSourceTypeOrId({ contentSourceDataById, modelName, srcType, srcProjectId, logger }) {
|
|
178
|
+
// if srcType and srcProjectId are provided, use them to get the specific contentSourceData without trying to infer the right model
|
|
179
|
+
if (srcType && srcProjectId) {
|
|
180
|
+
const contentSourceId = (0, content_store_utils_1.getContentSourceId)(srcType, srcProjectId);
|
|
181
|
+
const contentSourceData = contentSourceDataById[contentSourceId];
|
|
182
|
+
const model = contentSourceData === null || contentSourceData === void 0 ? void 0 : contentSourceData.modelMap[modelName];
|
|
183
|
+
if (model) {
|
|
184
|
+
return {
|
|
185
|
+
...model,
|
|
186
|
+
srcType: contentSourceData.srcType,
|
|
187
|
+
srcProjectId: contentSourceData.srcProjectId
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
192
|
+
const contentSourcesData = findContentSourcesDataForTypeOrId({
|
|
193
|
+
contentSourceDataById,
|
|
194
|
+
srcType,
|
|
195
|
+
srcProjectId
|
|
196
|
+
});
|
|
197
|
+
const matchingModels = contentSourcesData.reduce((matchingModels, contentSourceData) => {
|
|
198
|
+
const model = contentSourceData.modelMap[modelName];
|
|
199
|
+
if (model) {
|
|
200
|
+
matchingModels.push({
|
|
201
|
+
...model,
|
|
202
|
+
srcType: contentSourceData.srcType,
|
|
203
|
+
srcProjectId: contentSourceData.srcProjectId
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
return matchingModels;
|
|
207
|
+
}, []);
|
|
208
|
+
if (matchingModels.length === 1) {
|
|
209
|
+
return matchingModels[0];
|
|
210
|
+
}
|
|
211
|
+
else if (matchingModels.length > 1) {
|
|
212
|
+
const matchedContentSources = matchingModels.map((model) => `srcType: ${model.srcType}, srcProjectId: ${model.srcProjectId}`).join('; ');
|
|
213
|
+
logger.warn(`The getModelByName() found more than one model with name '${modelName}' ` +
|
|
214
|
+
`in the following content sources ${matchedContentSources}. ` +
|
|
215
|
+
`Please specify 'srcType' and/or 'srcProjectId' to narrow down the search.`);
|
|
216
|
+
}
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
function findContentSourcesDataForTypeOrId({ contentSourceDataById, srcType, srcProjectId }) {
|
|
220
|
+
return lodash_1.default.filter(contentSourceDataById, (contentSourceData) => {
|
|
221
|
+
const srcTypeMatch = !srcType || contentSourceData.srcType === srcType;
|
|
222
|
+
const srcProjectIdMatch = !srcProjectId || contentSourceData.srcProjectId === srcProjectId;
|
|
223
|
+
return srcTypeMatch && srcProjectIdMatch;
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=config-delegate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-delegate.js","sourceRoot":"","sources":["../../src/utils/config-delegate.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAEvB,2CAA6D;AAE7D,gEAA4D;AAC5D,+EAAwF;AAExF,SAAgB,4BAA4B,CAAC,EACzC,wBAAwB,EACxB,MAAM,EAIT;IACG,OAAO,GAAG,EAAE,CACR,oBAAoB,CAAC;QACjB,qBAAqB,EAAE,wBAAwB,EAAE;QACjD,MAAM,EAAE,MAAM;KACjB,CAAC,CAAC;AACX,CAAC;AAZD,oEAYC;AAED,SAAgB,oBAAoB,CAAC,EACjC,qBAAqB,EACrB,MAAM,EAIT;IACG,OAAO;QACH,eAAe,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE;YAC/C,MAAM,QAAQ,GAAG,iCAAiC,CAAC;gBAC/C,qBAAqB;gBACrB,UAAU,EAAE,EAAE;gBACd,OAAO;gBACP,YAAY;gBACZ,MAAM;aACT,CAAC,CAAC;YACH,IAAI,QAAQ,EAAE;gBACV,OAAO,IAAA,qEAAuC,EAAC,QAAQ,CAAC,CAAC;aAC5D;YACD,OAAO,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 export declare type CreateDocumentCallback = ({ updateOperationFields, contentSo
|
|
|
6
6
|
updateOperationFields: Record<string, CSITypes.UpdateOperationField>;
|
|
7
7
|
contentSourceData: ContentStoreTypes.ContentSourceData;
|
|
8
8
|
modelName: string;
|
|
9
|
-
}) => Promise<
|
|
9
|
+
}) => Promise<{
|
|
10
|
+
documentId: string;
|
|
11
|
+
}>;
|
|
10
12
|
export declare function getCreateDocumentThunk({ locale, defaultLocaleDocumentId, user }: {
|
|
11
13
|
locale?: string;
|
|
12
14
|
defaultLocaleDocumentId?: string;
|
|
@@ -47,8 +49,8 @@ export declare function getCreateDocumentThunk({ locale, defaultLocaleDocumentId
|
|
|
47
49
|
*
|
|
48
50
|
* Returns an object with two fields:
|
|
49
51
|
* 1. `document` holding the created CSITypes.Document for the passed object.
|
|
50
|
-
* 2. `
|
|
51
|
-
* created recursively for `reference` fields having the `$$type` property.
|
|
52
|
+
* 2. `newRefDocumentIds` containing the list of the created document IDs that
|
|
53
|
+
* were created recursively for `reference` fields having the `$$type` property.
|
|
52
54
|
*/
|
|
53
55
|
export declare function createDocumentRecursively({ object, modelName, contentSourceId, contentSourceDataById, createDocument }: {
|
|
54
56
|
object?: Record<string, any>;
|
|
@@ -57,8 +59,8 @@ export declare function createDocumentRecursively({ object, modelName, contentSo
|
|
|
57
59
|
contentSourceDataById: Record<string, ContentStoreTypes.ContentSourceData>;
|
|
58
60
|
createDocument: CreateDocumentCallback;
|
|
59
61
|
}): Promise<{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
documentId: string;
|
|
63
|
+
newRefDocumentIds: string[];
|
|
62
64
|
}>;
|
|
63
65
|
export declare function convertOperationField({ operationField, fieldPath, modelField, csiModelField, modelMap, csiModelMap, contentSourceId, contentSourceDataById, createDocument }: {
|
|
64
66
|
operationField: ContentStoreTypes.UpdateOperationField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-update-csi-docs.d.ts","sourceRoot":"","sources":["../../src/utils/create-update-csi-docs.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAA4B,kBAAkB,EAAmD,MAAM,iBAAiB,CAAC;AAEhI,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,iBAAiB,MAAM,UAAU,CAAC;AAG9C,oBAAY,sBAAsB,GAAG,CAAC,EAClC,qBAAqB,EACrB,iBAAiB,EACjB,SAAS,EACZ,EAAE;IACC,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IACrE,iBAAiB,EAAE,iBAAiB,CAAC,iBAAiB,CAAC;IACvD,SAAS,EAAE,MAAM,CAAC;CACrB,KAAK,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"create-update-csi-docs.d.ts","sourceRoot":"","sources":["../../src/utils/create-update-csi-docs.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAA4B,kBAAkB,EAAmD,MAAM,iBAAiB,CAAC;AAEhI,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,iBAAiB,MAAM,UAAU,CAAC;AAG9C,oBAAY,sBAAsB,GAAG,CAAC,EAClC,qBAAqB,EACrB,iBAAiB,EACjB,SAAS,EACZ,EAAE;IACC,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IACrE,iBAAiB,EAAE,iBAAiB,CAAC,iBAAiB,CAAC;IACvD,SAAS,EAAE,MAAM,CAAC;CACrB,KAAK,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEtC,wBAAgB,sBAAsB,CAAC,EACnC,MAAM,EACN,uBAAuB,EACvB,IAAI,EACP,EAAE;IACC,MAAM,CAAC,EAAE,MAAM,C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