@stackbit/cms-core 0.7.6-develop.2 → 0.8.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/.tsbuildinfo +1 -1
- package/dist/content-store-utils.d.ts +44 -0
- package/dist/content-store-utils.d.ts.map +1 -1
- package/dist/content-store-utils.js +213 -1
- 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 +45 -6
- package/dist/content-store.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/types/content-store-document-fields.d.ts +105 -0
- package/dist/types/content-store-document-fields.d.ts.map +1 -1
- package/dist/types/content-store-documents.d.ts +4 -1
- package/dist/types/content-store-documents.d.ts.map +1 -1
- package/dist/types/content-store-types.d.ts +10 -10
- package/dist/types/content-store-types.d.ts.map +1 -1
- package/dist/types/custom-actions.d.ts +108 -0
- package/dist/types/custom-actions.d.ts.map +1 -0
- package/dist/types/custom-actions.js +3 -0
- package/dist/types/custom-actions.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/utils/csi-to-store-docs-converter.d.ts +2 -1
- package/dist/utils/csi-to-store-docs-converter.d.ts.map +1 -1
- package/dist/utils/csi-to-store-docs-converter.js +144 -11
- package/dist/utils/csi-to-store-docs-converter.js.map +1 -1
- package/dist/utils/custom-actions.d.ts +53 -0
- package/dist/utils/custom-actions.d.ts.map +1 -0
- package/dist/utils/custom-actions.js +564 -0
- package/dist/utils/custom-actions.js.map +1 -0
- package/dist/utils/document-hooks.d.ts +9 -0
- package/dist/utils/document-hooks.d.ts.map +1 -1
- package/dist/utils/document-hooks.js +3 -2
- package/dist/utils/document-hooks.js.map +1 -1
- package/dist/utils/search-utils.d.ts +1 -1
- package/dist/utils/search-utils.d.ts.map +1 -1
- package/dist/utils/store-to-api-docs-converter.d.ts.map +1 -1
- package/dist/utils/store-to-api-docs-converter.js +77 -29
- package/dist/utils/store-to-api-docs-converter.js.map +1 -1
- package/dist/utils/store-to-csi-docs-converter.d.ts +3 -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 +247 -0
- package/src/content-store.ts +62 -7
- package/src/index.ts +0 -1
- package/src/types/content-store-document-fields.ts +55 -2
- package/src/types/content-store-documents.ts +4 -1
- package/src/types/content-store-types.ts +10 -10
- package/src/types/custom-actions.ts +154 -0
- package/src/types/index.ts +1 -0
- package/src/utils/csi-to-store-docs-converter.ts +220 -12
- package/src/utils/custom-actions.ts +707 -0
- package/src/utils/document-hooks.ts +3 -3
- package/src/utils/search-utils.ts +1 -1
- package/src/utils/store-to-api-docs-converter.ts +88 -33
- package/src/utils/store-to-csi-docs-converter.ts +4 -4
|
@@ -0,0 +1,564 @@
|
|
|
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.runCustomAction = exports.resolveCustomActionsById = exports.convertFieldActionToAPICustomAction = exports.convertObjectModelActionToAPICustomObjectAction = exports.convertDocumentActionToAPICustomDocumentAction = exports.getGlobalAndBulkAPIActions = exports.stripModelActions = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const sdk_1 = require("@stackbit/sdk");
|
|
9
|
+
const utils_1 = require("@stackbit/utils");
|
|
10
|
+
const config_delegate_1 = require("./config-delegate");
|
|
11
|
+
const document_hooks_1 = require("./document-hooks");
|
|
12
|
+
const store_to_csi_docs_converter_1 = require("./store-to-csi-docs-converter");
|
|
13
|
+
const content_store_utils_1 = require("../content-store-utils");
|
|
14
|
+
/**
|
|
15
|
+
* Removes "run" and "state" functions from actions of models, nested objects and fields.
|
|
16
|
+
* Sets "needsResolving" flag to let client know if the action needs additional resolving.
|
|
17
|
+
* @param {StackbitTypes.ModelMap} modelMap
|
|
18
|
+
*/
|
|
19
|
+
function stripModelActions({ modelMap }) {
|
|
20
|
+
return lodash_1.default.mapValues(modelMap, (model) => {
|
|
21
|
+
if ('actions' in model) {
|
|
22
|
+
const { actions, ...restModel } = model;
|
|
23
|
+
model = restModel;
|
|
24
|
+
}
|
|
25
|
+
model = (0, sdk_1.mapModelFieldsRecursively)(model, (field) => {
|
|
26
|
+
if ('actions' in field && Array.isArray(field.actions)) {
|
|
27
|
+
const { actions, ...restField } = field;
|
|
28
|
+
field = restField;
|
|
29
|
+
}
|
|
30
|
+
return field;
|
|
31
|
+
});
|
|
32
|
+
return model;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
exports.stripModelActions = stripModelActions;
|
|
36
|
+
async function getGlobalAndBulkAPIActions({ stackbitConfig, customActionMap, contentSourceDataById, userLogger, pageUrl, user, locale, currentPageDocument }) {
|
|
37
|
+
if (!stackbitConfig || !Array.isArray(stackbitConfig.actions)) {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
const configDelegate = (0, config_delegate_1.createConfigDelegate)({
|
|
41
|
+
contentSourceDataById: contentSourceDataById,
|
|
42
|
+
logger: userLogger
|
|
43
|
+
});
|
|
44
|
+
return (0, utils_1.mapPromise)(stackbitConfig.actions, async (action) => {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
const actionId = `config.actions.${action.name}`;
|
|
47
|
+
const prevStoreAction = customActionMap[actionId];
|
|
48
|
+
const storeAction = {
|
|
49
|
+
// if configuration is updated, the new action properties will override the stored action properties
|
|
50
|
+
...action,
|
|
51
|
+
actionId,
|
|
52
|
+
label: (_a = action.label) !== null && _a !== void 0 ? _a : lodash_1.default.startCase(action.name),
|
|
53
|
+
runningHandler: prevStoreAction === null || prevStoreAction === void 0 ? void 0 : prevStoreAction.runningHandler,
|
|
54
|
+
lastResultState: prevStoreAction === null || prevStoreAction === void 0 ? void 0 : prevStoreAction.lastResultState
|
|
55
|
+
};
|
|
56
|
+
customActionMap[actionId] = storeAction;
|
|
57
|
+
let state;
|
|
58
|
+
if (storeAction.runningHandler) {
|
|
59
|
+
state = 'running';
|
|
60
|
+
}
|
|
61
|
+
else if (storeAction.state) {
|
|
62
|
+
const pageDocument = getCSIDocumentWithSourceFromDocumentSpec(currentPageDocument, configDelegate);
|
|
63
|
+
state = await storeAction.state({
|
|
64
|
+
actionId: actionId,
|
|
65
|
+
currentLocale: locale,
|
|
66
|
+
currentUser: user ? { name: user.name, email: user.email } : undefined,
|
|
67
|
+
currentPageUrl: pageUrl,
|
|
68
|
+
currentPageDocument: pageDocument,
|
|
69
|
+
...configDelegate
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
state = (_b = storeAction.lastResultState) !== null && _b !== void 0 ? _b : 'enabled';
|
|
74
|
+
}
|
|
75
|
+
return (0, utils_1.omitByNil)({
|
|
76
|
+
actionId: actionId,
|
|
77
|
+
type: storeAction.type,
|
|
78
|
+
name: storeAction.name,
|
|
79
|
+
label: storeAction.label,
|
|
80
|
+
icon: storeAction.icon,
|
|
81
|
+
state: state,
|
|
82
|
+
inputFields: storeAction.inputFields
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
exports.getGlobalAndBulkAPIActions = getGlobalAndBulkAPIActions;
|
|
87
|
+
function convertDocumentActionToAPICustomDocumentAction({ action, customActionMap, csiDocument }) {
|
|
88
|
+
var _a, _b;
|
|
89
|
+
const actionId = `${csiDocument.srcType}:${csiDocument.srcProjectId}:${csiDocument.id}:${action.name}`;
|
|
90
|
+
const prevStoreAction = customActionMap[actionId];
|
|
91
|
+
const storeAction = {
|
|
92
|
+
// if configuration is updated, the new action properties will override the stored action properties
|
|
93
|
+
...action,
|
|
94
|
+
type: 'document',
|
|
95
|
+
actionId,
|
|
96
|
+
label: (_a = action.label) !== null && _a !== void 0 ? _a : lodash_1.default.startCase(action.name),
|
|
97
|
+
runningHandler: prevStoreAction === null || prevStoreAction === void 0 ? void 0 : prevStoreAction.runningHandler,
|
|
98
|
+
lastResultState: prevStoreAction === null || prevStoreAction === void 0 ? void 0 : prevStoreAction.lastResultState,
|
|
99
|
+
documentSpec: {
|
|
100
|
+
srcType: csiDocument.srcType,
|
|
101
|
+
srcProjectId: csiDocument.srcProjectId,
|
|
102
|
+
srcDocumentId: csiDocument.id
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
customActionMap[actionId] = storeAction;
|
|
106
|
+
let state;
|
|
107
|
+
let needsResolving = false;
|
|
108
|
+
if (storeAction === null || storeAction === void 0 ? void 0 : storeAction.runningHandler) {
|
|
109
|
+
state = 'running';
|
|
110
|
+
}
|
|
111
|
+
else if (action.state) {
|
|
112
|
+
state = 'unknown';
|
|
113
|
+
needsResolving = true;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
state = (_b = storeAction === null || storeAction === void 0 ? void 0 : storeAction.lastResultState) !== null && _b !== void 0 ? _b : 'enabled';
|
|
117
|
+
}
|
|
118
|
+
return (0, utils_1.omitByNil)({
|
|
119
|
+
actionId: actionId,
|
|
120
|
+
type: 'document',
|
|
121
|
+
name: storeAction.name,
|
|
122
|
+
label: storeAction.label,
|
|
123
|
+
icon: storeAction.icon,
|
|
124
|
+
state: state,
|
|
125
|
+
inputFields: storeAction.inputFields,
|
|
126
|
+
needsResolving: needsResolving
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
exports.convertDocumentActionToAPICustomDocumentAction = convertDocumentActionToAPICustomDocumentAction;
|
|
130
|
+
function convertObjectModelActionToAPICustomObjectAction({ action, customActionMap, csiParentDocument, fieldPath }) {
|
|
131
|
+
var _a, _b;
|
|
132
|
+
const actionId = `${csiParentDocument.srcType}:${csiParentDocument.srcProjectId}:${csiParentDocument.id}:${fieldPath.join('.')}:${action.name}`;
|
|
133
|
+
const prevStoreAction = customActionMap[actionId];
|
|
134
|
+
const storeAction = {
|
|
135
|
+
// if configuration is updated, the new action properties will override the stored action properties
|
|
136
|
+
...action,
|
|
137
|
+
type: 'objectModel',
|
|
138
|
+
actionId,
|
|
139
|
+
label: (_a = action.label) !== null && _a !== void 0 ? _a : lodash_1.default.startCase(action.name),
|
|
140
|
+
runningHandler: prevStoreAction === null || prevStoreAction === void 0 ? void 0 : prevStoreAction.runningHandler,
|
|
141
|
+
lastResultState: prevStoreAction === null || prevStoreAction === void 0 ? void 0 : prevStoreAction.lastResultState,
|
|
142
|
+
documentSpec: {
|
|
143
|
+
srcType: csiParentDocument.srcType,
|
|
144
|
+
srcProjectId: csiParentDocument.srcProjectId,
|
|
145
|
+
srcDocumentId: csiParentDocument.id
|
|
146
|
+
},
|
|
147
|
+
fieldPath
|
|
148
|
+
};
|
|
149
|
+
customActionMap[actionId] = storeAction;
|
|
150
|
+
let state;
|
|
151
|
+
let needsResolving = false;
|
|
152
|
+
if (storeAction === null || storeAction === void 0 ? void 0 : storeAction.runningHandler) {
|
|
153
|
+
state = 'running';
|
|
154
|
+
}
|
|
155
|
+
else if (action.state) {
|
|
156
|
+
state = 'unknown';
|
|
157
|
+
needsResolving = true;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
state = (_b = storeAction === null || storeAction === void 0 ? void 0 : storeAction.lastResultState) !== null && _b !== void 0 ? _b : 'enabled';
|
|
161
|
+
}
|
|
162
|
+
return (0, utils_1.omitByNil)({
|
|
163
|
+
actionId: actionId,
|
|
164
|
+
type: 'object',
|
|
165
|
+
name: storeAction.name,
|
|
166
|
+
label: storeAction.label,
|
|
167
|
+
icon: storeAction.icon,
|
|
168
|
+
state: state,
|
|
169
|
+
inputFields: storeAction.inputFields,
|
|
170
|
+
needsResolving: needsResolving
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
exports.convertObjectModelActionToAPICustomObjectAction = convertObjectModelActionToAPICustomObjectAction;
|
|
174
|
+
function convertFieldActionToAPICustomAction({ action, customActionMap, csiParentDocument, fieldPath }) {
|
|
175
|
+
var _a, _b, _c;
|
|
176
|
+
const actionId = `${csiParentDocument.srcType}:${csiParentDocument.srcProjectId}:${csiParentDocument.id}:${fieldPath.join('.')}:${action.name}`;
|
|
177
|
+
const prevStoreAction = customActionMap[actionId];
|
|
178
|
+
const storeAction = {
|
|
179
|
+
// if configuration is updated, the new action properties will override the stored action properties
|
|
180
|
+
...action,
|
|
181
|
+
type: action.type === 'object' ? 'objectField' : 'field',
|
|
182
|
+
actionId,
|
|
183
|
+
label: (_a = action.label) !== null && _a !== void 0 ? _a : lodash_1.default.startCase(action.name),
|
|
184
|
+
runningHandler: prevStoreAction === null || prevStoreAction === void 0 ? void 0 : prevStoreAction.runningHandler,
|
|
185
|
+
lastResultState: prevStoreAction === null || prevStoreAction === void 0 ? void 0 : prevStoreAction.lastResultState,
|
|
186
|
+
documentSpec: {
|
|
187
|
+
srcType: csiParentDocument.srcType,
|
|
188
|
+
srcProjectId: csiParentDocument.srcProjectId,
|
|
189
|
+
srcDocumentId: csiParentDocument.id
|
|
190
|
+
},
|
|
191
|
+
fieldPath
|
|
192
|
+
};
|
|
193
|
+
customActionMap[actionId] = storeAction;
|
|
194
|
+
let state;
|
|
195
|
+
let needsResolving = false;
|
|
196
|
+
if (storeAction === null || storeAction === void 0 ? void 0 : storeAction.runningHandler) {
|
|
197
|
+
state = 'running';
|
|
198
|
+
}
|
|
199
|
+
else if (action.state) {
|
|
200
|
+
state = 'unknown';
|
|
201
|
+
needsResolving = true;
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
state = (_b = storeAction === null || storeAction === void 0 ? void 0 : storeAction.lastResultState) !== null && _b !== void 0 ? _b : 'enabled';
|
|
205
|
+
}
|
|
206
|
+
return (0, utils_1.omitByNil)({
|
|
207
|
+
actionId: actionId,
|
|
208
|
+
type: (_c = action.type) !== null && _c !== void 0 ? _c : 'field',
|
|
209
|
+
name: storeAction.name,
|
|
210
|
+
label: storeAction.label,
|
|
211
|
+
icon: storeAction.icon,
|
|
212
|
+
state: state,
|
|
213
|
+
inputFields: storeAction.inputFields,
|
|
214
|
+
needsResolving: needsResolving
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
exports.convertFieldActionToAPICustomAction = convertFieldActionToAPICustomAction;
|
|
218
|
+
async function resolveCustomActionsById({ getActionRequest, customActionMap, contentSourceDataById, userLogger }) {
|
|
219
|
+
var _a;
|
|
220
|
+
const result = [];
|
|
221
|
+
const { customActionIds, locale, user, pageUrl, currentPageDocument } = getActionRequest;
|
|
222
|
+
const configDelegate = (0, config_delegate_1.createConfigDelegate)({
|
|
223
|
+
contentSourceDataById,
|
|
224
|
+
logger: userLogger
|
|
225
|
+
});
|
|
226
|
+
for (const actionId of customActionIds) {
|
|
227
|
+
const storeAction = customActionMap[actionId];
|
|
228
|
+
if (!storeAction) {
|
|
229
|
+
userLogger.debug(`getCustomActionsById: custom action not found, id: '${actionId}'`);
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
let state;
|
|
233
|
+
if (storeAction.runningHandler) {
|
|
234
|
+
state = 'running';
|
|
235
|
+
}
|
|
236
|
+
else if (storeAction.state) {
|
|
237
|
+
const pageDocument = getCSIDocumentWithSourceFromDocumentSpec(currentPageDocument, configDelegate);
|
|
238
|
+
const commonStateOptions = {
|
|
239
|
+
actionId: actionId,
|
|
240
|
+
currentLocale: locale,
|
|
241
|
+
currentUser: user ? { name: user.name, email: user.email } : undefined,
|
|
242
|
+
currentPageUrl: pageUrl,
|
|
243
|
+
currentPageDocument: pageDocument,
|
|
244
|
+
...configDelegate
|
|
245
|
+
};
|
|
246
|
+
if (storeAction.type === 'global' || storeAction.type === 'bulk') {
|
|
247
|
+
state = await storeAction.state(commonStateOptions);
|
|
248
|
+
}
|
|
249
|
+
else if (storeAction.type === 'document') {
|
|
250
|
+
const { document, model } = getCSIDocumentAndModelWithSourceFromDocumentSpec({
|
|
251
|
+
documentSpec: storeAction.documentSpec,
|
|
252
|
+
contentSourceDataById
|
|
253
|
+
});
|
|
254
|
+
state = await storeAction.state({
|
|
255
|
+
...commonStateOptions,
|
|
256
|
+
document: document,
|
|
257
|
+
model: model
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
else if (storeAction.type === 'objectModel') {
|
|
261
|
+
const stateObjectParams = getHandlerParamsForObjectModelAction({ storeAction, contentSourceDataById });
|
|
262
|
+
state = await storeAction.state({
|
|
263
|
+
...commonStateOptions,
|
|
264
|
+
...stateObjectParams
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
else if (storeAction.type === 'objectField') {
|
|
268
|
+
const stateObjectParams = getHandlerParamsForObjectFieldAction({ storeAction, contentSourceDataById });
|
|
269
|
+
state = await storeAction.state({
|
|
270
|
+
...commonStateOptions,
|
|
271
|
+
...stateObjectParams
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
else if (storeAction.type === 'field') {
|
|
275
|
+
const stateFieldParams = getHandlerParamsForFieldAction({ storeAction, contentSourceDataById });
|
|
276
|
+
state = await storeAction.state({
|
|
277
|
+
...commonStateOptions,
|
|
278
|
+
...stateFieldParams
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
const _exhaustiveCheck = storeAction;
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
state = (_a = storeAction === null || storeAction === void 0 ? void 0 : storeAction.lastResultState) !== null && _a !== void 0 ? _a : 'enabled';
|
|
288
|
+
}
|
|
289
|
+
result.push((0, utils_1.omitByNil)({
|
|
290
|
+
actionId: actionId,
|
|
291
|
+
type: storeActionTypeToAPIActionType(storeAction.type),
|
|
292
|
+
name: storeAction.name,
|
|
293
|
+
label: storeAction.label,
|
|
294
|
+
icon: storeAction.icon,
|
|
295
|
+
state: state,
|
|
296
|
+
inputFields: storeAction.inputFields
|
|
297
|
+
}));
|
|
298
|
+
}
|
|
299
|
+
return result;
|
|
300
|
+
}
|
|
301
|
+
exports.resolveCustomActionsById = resolveCustomActionsById;
|
|
302
|
+
function runCustomAction({ runActionRequest, customActionMap, contentSourceDataById, userLogger, stackbitConfig }) {
|
|
303
|
+
var _a, _b;
|
|
304
|
+
const storeAction = customActionMap[runActionRequest.actionId];
|
|
305
|
+
if (!storeAction) {
|
|
306
|
+
throw new Error(`Error running action: action not found, action name: '${runActionRequest.actionName}' action ID: '${runActionRequest.actionId}'.`);
|
|
307
|
+
}
|
|
308
|
+
const prevResultState = storeAction.lastResultState;
|
|
309
|
+
if (storeAction.lastResultState && storeAction.lastResultState !== 'enabled') {
|
|
310
|
+
throw new Error(`Error running action: action is not enabled, action name: '${runActionRequest.actionName}' action ID: '${runActionRequest.actionId}'.`);
|
|
311
|
+
}
|
|
312
|
+
try {
|
|
313
|
+
const actionLogger = userLogger.createLogger({ label: `action:${storeAction.name}` });
|
|
314
|
+
const configDelegate = (0, config_delegate_1.createConfigDelegate)({ contentSourceDataById: contentSourceDataById, logger: actionLogger });
|
|
315
|
+
const currentPageDocument = getCSIDocumentWithSourceFromDocumentSpec(runActionRequest.currentPageDocument, configDelegate);
|
|
316
|
+
storeAction.runningHandler = true;
|
|
317
|
+
storeAction.lastResultState = 'running';
|
|
318
|
+
const commonRunOptions = {
|
|
319
|
+
actionId: storeAction.actionId,
|
|
320
|
+
inputData: runActionRequest.inputData,
|
|
321
|
+
currentLocale: runActionRequest.locale,
|
|
322
|
+
currentUser: runActionRequest.user,
|
|
323
|
+
currentPageUrl: runActionRequest.pageUrl,
|
|
324
|
+
currentPageDocument: currentPageDocument,
|
|
325
|
+
getContentSourceActionsForSource: (0, document_hooks_1.getContentSourceActionsForSourceThunk)({
|
|
326
|
+
getContentSourceDataById: () => contentSourceDataById,
|
|
327
|
+
logger: userLogger,
|
|
328
|
+
user: runActionRequest.user,
|
|
329
|
+
stackbitConfig: stackbitConfig
|
|
330
|
+
}),
|
|
331
|
+
getUserContextForContentSourceType: (0, content_store_utils_1.getUserContextForSrcTypeThunk)(runActionRequest.user),
|
|
332
|
+
...configDelegate
|
|
333
|
+
};
|
|
334
|
+
let promise;
|
|
335
|
+
if (storeAction.type === 'global') {
|
|
336
|
+
promise = storeAction.run(commonRunOptions);
|
|
337
|
+
}
|
|
338
|
+
else if (storeAction.type === 'bulk') {
|
|
339
|
+
const documents = runActionRequest.documents.map((documentSpec) => {
|
|
340
|
+
const { document } = getCSIDocumentAndModelWithSourceFromDocumentSpec({
|
|
341
|
+
documentSpec,
|
|
342
|
+
contentSourceDataById
|
|
343
|
+
});
|
|
344
|
+
return document;
|
|
345
|
+
});
|
|
346
|
+
promise = storeAction.run({
|
|
347
|
+
...commonRunOptions,
|
|
348
|
+
documents
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
else if (storeAction.type === 'document') {
|
|
352
|
+
const { document, model } = getCSIDocumentAndModelWithSourceFromDocumentSpec({
|
|
353
|
+
documentSpec: storeAction.documentSpec,
|
|
354
|
+
contentSourceDataById
|
|
355
|
+
});
|
|
356
|
+
promise = storeAction.run({
|
|
357
|
+
...commonRunOptions,
|
|
358
|
+
document,
|
|
359
|
+
model,
|
|
360
|
+
contentSourceActions: commonRunOptions.getContentSourceActionsForSource({
|
|
361
|
+
srcType: storeAction.documentSpec.srcType,
|
|
362
|
+
srcProjectId: storeAction.documentSpec.srcProjectId
|
|
363
|
+
})
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
else if (storeAction.type === 'objectModel') {
|
|
367
|
+
const handlerObjectParams = getHandlerParamsForObjectModelAction({
|
|
368
|
+
storeAction,
|
|
369
|
+
contentSourceDataById
|
|
370
|
+
});
|
|
371
|
+
promise = storeAction.run({
|
|
372
|
+
...commonRunOptions,
|
|
373
|
+
...handlerObjectParams,
|
|
374
|
+
contentSourceActions: commonRunOptions.getContentSourceActionsForSource({
|
|
375
|
+
srcType: storeAction.documentSpec.srcType,
|
|
376
|
+
srcProjectId: storeAction.documentSpec.srcProjectId
|
|
377
|
+
})
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
else if (storeAction.type === 'objectField') {
|
|
381
|
+
const handlerObjectParams = getHandlerParamsForObjectFieldAction({
|
|
382
|
+
storeAction,
|
|
383
|
+
contentSourceDataById
|
|
384
|
+
});
|
|
385
|
+
promise = storeAction.run({
|
|
386
|
+
...commonRunOptions,
|
|
387
|
+
...handlerObjectParams,
|
|
388
|
+
contentSourceActions: commonRunOptions.getContentSourceActionsForSource({
|
|
389
|
+
srcType: storeAction.documentSpec.srcType,
|
|
390
|
+
srcProjectId: storeAction.documentSpec.srcProjectId
|
|
391
|
+
})
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
else if (storeAction.type === 'field') {
|
|
395
|
+
const handlerFieldParams = getHandlerParamsForFieldAction({ storeAction, contentSourceDataById });
|
|
396
|
+
promise = storeAction.run({
|
|
397
|
+
...commonRunOptions,
|
|
398
|
+
...handlerFieldParams,
|
|
399
|
+
contentSourceActions: commonRunOptions.getContentSourceActionsForSource({
|
|
400
|
+
srcType: storeAction.documentSpec.srcType,
|
|
401
|
+
srcProjectId: storeAction.documentSpec.srcProjectId
|
|
402
|
+
})
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
throw new Error(`action type ${storeAction.type} not supported`);
|
|
407
|
+
}
|
|
408
|
+
return promise
|
|
409
|
+
.then((actionResult) => {
|
|
410
|
+
var _a;
|
|
411
|
+
storeAction.runningHandler = false;
|
|
412
|
+
storeAction.lastResultState = actionResult === null || actionResult === void 0 ? void 0 : actionResult.state;
|
|
413
|
+
userLogger.debug(`Action completed: ${storeAction.actionId}`);
|
|
414
|
+
return Promise.resolve((0, utils_1.omitByNil)({
|
|
415
|
+
actionId: storeAction.actionId,
|
|
416
|
+
actionName: storeAction.name,
|
|
417
|
+
actionType: storeActionTypeToAPIActionType(storeAction.type),
|
|
418
|
+
// TODO: resolve the state if state function is defined
|
|
419
|
+
state: (_a = actionResult === null || actionResult === void 0 ? void 0 : actionResult.state) !== null && _a !== void 0 ? _a : 'enabled',
|
|
420
|
+
success: actionResult === null || actionResult === void 0 ? void 0 : actionResult.success,
|
|
421
|
+
error: actionResult === null || actionResult === void 0 ? void 0 : actionResult.error
|
|
422
|
+
}));
|
|
423
|
+
})
|
|
424
|
+
.catch((error) => {
|
|
425
|
+
storeAction.runningHandler = false;
|
|
426
|
+
storeAction.lastResultState = prevResultState;
|
|
427
|
+
userLogger.debug(`Error running action: ${error.message}`);
|
|
428
|
+
return Promise.resolve({
|
|
429
|
+
actionId: storeAction.actionId,
|
|
430
|
+
actionName: storeAction.name,
|
|
431
|
+
actionType: storeActionTypeToAPIActionType(storeAction.type),
|
|
432
|
+
// TODO: resolve the state if state function is defined
|
|
433
|
+
state: prevResultState !== null && prevResultState !== void 0 ? prevResultState : 'enabled',
|
|
434
|
+
error: `Error running action: ${error.message}`
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
catch (error) {
|
|
439
|
+
if (storeAction) {
|
|
440
|
+
storeAction.runningHandler = false;
|
|
441
|
+
storeAction.lastResultState = prevResultState;
|
|
442
|
+
}
|
|
443
|
+
userLogger.debug(`Error running action: ${error.message}`);
|
|
444
|
+
return Promise.resolve({
|
|
445
|
+
actionId: runActionRequest.actionId,
|
|
446
|
+
actionName: (_a = storeAction === null || storeAction === void 0 ? void 0 : storeAction.name) !== null && _a !== void 0 ? _a : runActionRequest.actionName,
|
|
447
|
+
actionType: (_b = storeActionTypeToAPIActionType(storeAction === null || storeAction === void 0 ? void 0 : storeAction.type)) !== null && _b !== void 0 ? _b : runActionRequest.actionType,
|
|
448
|
+
// TODO: resolve the state if state function is defined
|
|
449
|
+
state: prevResultState !== null && prevResultState !== void 0 ? prevResultState : 'enabled',
|
|
450
|
+
error: `Error running action: ${error.message}`
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
exports.runCustomAction = runCustomAction;
|
|
455
|
+
function getCSIDocumentWithSourceFromDocumentSpec(documentSpec, configDelegate) {
|
|
456
|
+
return documentSpec
|
|
457
|
+
? configDelegate.getDocumentById({
|
|
458
|
+
id: documentSpec.srcDocumentId,
|
|
459
|
+
srcType: documentSpec.srcType,
|
|
460
|
+
srcProjectId: documentSpec.srcProjectId
|
|
461
|
+
})
|
|
462
|
+
: undefined;
|
|
463
|
+
}
|
|
464
|
+
function getHandlerParamsForObjectModelAction({ storeAction, contentSourceDataById }) {
|
|
465
|
+
const fieldActionCommonParams = getHandlerParamsForFieldAction({
|
|
466
|
+
storeAction,
|
|
467
|
+
contentSourceDataById
|
|
468
|
+
});
|
|
469
|
+
const documentField = fieldActionCommonParams.documentField;
|
|
470
|
+
const documentSpec = storeAction.documentSpec;
|
|
471
|
+
const contentSourceData = (0, content_store_utils_1.getContentSourceDataByTypeAndProjectIdOrThrow)(documentSpec.srcType, documentSpec.srcProjectId, contentSourceDataById);
|
|
472
|
+
const objectModel = contentSourceData.modelMap[documentField.modelName];
|
|
473
|
+
if (!objectModel || objectModel.type !== 'object') {
|
|
474
|
+
throw new Error(`object model '${documentField.modelName}' not found`);
|
|
475
|
+
}
|
|
476
|
+
return {
|
|
477
|
+
...fieldActionCommonParams,
|
|
478
|
+
documentField,
|
|
479
|
+
modelField: fieldActionCommonParams.modelField,
|
|
480
|
+
objectModel: {
|
|
481
|
+
...objectModel,
|
|
482
|
+
srcType: documentSpec.srcType,
|
|
483
|
+
srcProjectId: documentSpec.srcProjectId
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
function getHandlerParamsForObjectFieldAction({ storeAction, contentSourceDataById }) {
|
|
488
|
+
const fieldActionCommonParams = getHandlerParamsForFieldAction({
|
|
489
|
+
storeAction,
|
|
490
|
+
contentSourceDataById
|
|
491
|
+
});
|
|
492
|
+
return {
|
|
493
|
+
...fieldActionCommonParams,
|
|
494
|
+
documentField: fieldActionCommonParams.documentField,
|
|
495
|
+
modelField: fieldActionCommonParams.modelField
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
function getHandlerParamsForFieldAction({ storeAction, contentSourceDataById }) {
|
|
499
|
+
const documentSpec = storeAction.documentSpec;
|
|
500
|
+
const contentSourceData = (0, content_store_utils_1.getContentSourceDataByTypeAndProjectIdOrThrow)(documentSpec.srcType, documentSpec.srcProjectId, contentSourceDataById);
|
|
501
|
+
const document = contentSourceData.documentMap[documentSpec.srcDocumentId];
|
|
502
|
+
const csiDocument = contentSourceData.csiDocumentMap[documentSpec.srcDocumentId];
|
|
503
|
+
if (!document || !csiDocument) {
|
|
504
|
+
throw new Error(`document not found for srcType: ${documentSpec.srcType}, srcProjectId: ${documentSpec.srcProjectId}, srcDocumentId: ${documentSpec.srcDocumentId}`);
|
|
505
|
+
}
|
|
506
|
+
const model = contentSourceData.modelMap[document.srcModelName];
|
|
507
|
+
if (!model) {
|
|
508
|
+
throw new Error(`model '${document.srcModelName}' not found`);
|
|
509
|
+
}
|
|
510
|
+
const mappedCSIDocument = (0, store_to_csi_docs_converter_1.mapStoreDocumentToCSIDocumentWithSource)({ document, csiDocument });
|
|
511
|
+
// the documentField should be localized because fieldPath includes locales
|
|
512
|
+
const { modelField, documentField } = (0, content_store_utils_1.getModelAndDocumentFieldForLocalizedFieldPath)({
|
|
513
|
+
document,
|
|
514
|
+
model,
|
|
515
|
+
fieldPath: storeAction.fieldPath,
|
|
516
|
+
modelMap: contentSourceData.modelMap
|
|
517
|
+
});
|
|
518
|
+
const csiDocumentField = (0, store_to_csi_docs_converter_1.mapStoreFieldToCSIField)(documentField);
|
|
519
|
+
if (!csiDocumentField) {
|
|
520
|
+
throw new Error(`object not found at field path: ${storeAction.fieldPath}`);
|
|
521
|
+
}
|
|
522
|
+
return {
|
|
523
|
+
parentDocument: mappedCSIDocument,
|
|
524
|
+
parentModel: {
|
|
525
|
+
...model,
|
|
526
|
+
srcType: documentSpec.srcType,
|
|
527
|
+
srcProjectId: documentSpec.srcProjectId
|
|
528
|
+
},
|
|
529
|
+
documentField: csiDocumentField,
|
|
530
|
+
modelField: modelField,
|
|
531
|
+
fieldPath: storeAction.fieldPath
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
function getCSIDocumentAndModelWithSourceFromDocumentSpec({ documentSpec, contentSourceDataById }) {
|
|
535
|
+
const contentSourceData = (0, content_store_utils_1.getContentSourceDataByTypeAndProjectIdOrThrow)(documentSpec.srcType, documentSpec.srcProjectId, contentSourceDataById);
|
|
536
|
+
const document = contentSourceData.documentMap[documentSpec.srcDocumentId];
|
|
537
|
+
const csiDocument = contentSourceData.csiDocumentMap[documentSpec.srcDocumentId];
|
|
538
|
+
if (!document || !csiDocument) {
|
|
539
|
+
throw new Error(`document not found, srcType: ${documentSpec.srcType}, srcProjectId: ${documentSpec.srcProjectId}, srcDocumentId: ${documentSpec.srcDocumentId}`);
|
|
540
|
+
}
|
|
541
|
+
const mappedDocument = (0, store_to_csi_docs_converter_1.mapStoreDocumentToCSIDocumentWithSource)({
|
|
542
|
+
document,
|
|
543
|
+
csiDocument
|
|
544
|
+
});
|
|
545
|
+
const model = contentSourceData.modelMap[mappedDocument.modelName];
|
|
546
|
+
if (!model) {
|
|
547
|
+
throw new Error(`model '${mappedDocument.modelName}' not found`);
|
|
548
|
+
}
|
|
549
|
+
return {
|
|
550
|
+
document: mappedDocument,
|
|
551
|
+
model: {
|
|
552
|
+
...model,
|
|
553
|
+
srcType: documentSpec.srcType,
|
|
554
|
+
srcProjectId: documentSpec.srcProjectId
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
function storeActionTypeToAPIActionType(storeActionType) {
|
|
559
|
+
if (storeActionType === 'objectModel' || storeActionType === 'objectField') {
|
|
560
|
+
return 'object';
|
|
561
|
+
}
|
|
562
|
+
return storeActionType;
|
|
563
|
+
}
|
|
564
|
+
//# sourceMappingURL=custom-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-actions.js","sourceRoot":"","sources":["../../src/utils/custom-actions.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AACvB,uCAAkE;AAElE,2CAAwD;AAuBxD,uDAAyD;AACzD,qDAAyE;AACzE,+EAAiH;AACjH,gEAIgC;AAEhC;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAwC;IAChF,OAAO,gBAAC,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;QACnC,IAAI,SAAS,IAAI,KAAK,EAAE;YACpB,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;YACxC,KAAK,GAAG,SAAS,CAAC;SACrB;QAED,KAAK,GAAG,IAAA,+BAAyB,EAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;YAC/C,IAAI,SAAS,IAAI,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;gBACpD,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;gBACxC,KAAK,GAAG,SAAS,CAAC;aACrB;YACD,OAAO,KAAK,CAAC;QACjB,CAAC,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC,CAAC;AACP,CAAC;AAjBD,8CAiBC;AAEM,KAAK,UAAU,0BAA0B,CAAC,EAC7C,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,OAAO,EACP,IAAI,EACJ,MAAM,EACN,mBAAmB,EAUtB;IACG,IAAI,CAAC,cAAc,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE;QAC3D,OAAO,EAAE,CAAC;KACb;IAED,MAAM,cAAc,GAAG,IAAA,sCAA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cAAc;QACxB,KAAK,EAAE;YACH,GAAG,KAAK;YACR,OAAO,EAAE,YAAY,CAAC,OAAO;YAC7B,YAAY,EAAE,YAAY,CAAC,YAAY;SAC1C;KACJ,CAAC;AACN,CAAC;AAED,SAAS,8BAA8B,CAAC,eAAiD;IACrF,IAAI,eAAe,KAAK,aAAa,IAAI,eAAe,KAAK,aAAa,EAAE;QACxE,OAAO,QAAQ,CAAC;KACnB;IACD,OAAO,eAAe,CAAC;AAC3B,CAAC"}
|
|
@@ -18,5 +18,14 @@ export declare function createDocumentHooked(options: DocumentHookOptions<'creat
|
|
|
18
18
|
export declare function updateDocumentHooked(options: DocumentHookOptions<'updateDocument'>): ReturnTypeOfCSIMethod<'updateDocument'>;
|
|
19
19
|
export declare function deleteDocumentHooked(options: DocumentHookOptions<'deleteDocument'>): ReturnTypeOfCSIMethod<'deleteDocument'>;
|
|
20
20
|
export declare function publishDocumentHooked(options: DocumentHookOptions<'publishDocuments'>): ReturnTypeOfCSIMethod<'publishDocuments'>;
|
|
21
|
+
export declare function getContentSourceActionsForSourceThunk({ getContentSourceDataById, logger, user, stackbitConfig }: {
|
|
22
|
+
getContentSourceDataById: () => Record<string, ContentStoreTypes.ContentSourceData>;
|
|
23
|
+
logger: StackbitTypes.Logger;
|
|
24
|
+
user?: ContentStoreTypes.User;
|
|
25
|
+
stackbitConfig: Config | null;
|
|
26
|
+
}): (options: {
|
|
27
|
+
srcType: string;
|
|
28
|
+
srcProjectId?: string;
|
|
29
|
+
}) => StackbitTypes.ContentSourceActions | undefined;
|
|
21
30
|
export {};
|
|
22
31
|
//# sourceMappingURL=document-hooks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-hooks.d.ts","sourceRoot":"","sources":["../../src/utils/document-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,KAAK,aAAa,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK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,CAuBlI;AAED,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,GAAG,qBAAqB,CAAC,gBAAgB,CAAC,CAsBlI;AAED,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,mBAAmB,CAAC,kBAAkB,CAAC,GAAG,qBAAqB,CAAC,kBAAkB,CAAC,CAsBvI;AAkCD,wBAAgB,qCAAqC,CAAC,EAClD,wBAAwB,EACxB,MAAM,EACN,IAAI,EACJ,cAAc,EACjB,EAAE;IACC,wBAAwB,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IACpF,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC;IAC7B,IAAI,CAAC,EAAE,iBAAiB,CAAC,IAAI,CAAC;IAC9B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC,GAAG,CAAC,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,aAAa,CAAC,oBAAoB,GAAG,SAAS,CAW1G"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.publishDocumentHooked = exports.deleteDocumentHooked = exports.updateDocumentHooked = exports.createDocumentHooked = void 0;
|
|
3
|
+
exports.getContentSourceActionsForSourceThunk = exports.publishDocumentHooked = exports.deleteDocumentHooked = exports.updateDocumentHooked = exports.createDocumentHooked = void 0;
|
|
4
4
|
const content_store_utils_1 = require("../content-store-utils");
|
|
5
5
|
const config_delegate_1 = require("./config-delegate");
|
|
6
6
|
async function createDocumentHooked(options) {
|
|
@@ -129,7 +129,7 @@ function getDocumentHookOptions(options) {
|
|
|
129
129
|
user: options.user,
|
|
130
130
|
stackbitConfig: options.stackbitConfig
|
|
131
131
|
}),
|
|
132
|
-
getUserContextForContentSourceType: (
|
|
132
|
+
getUserContextForContentSourceType: (0, content_store_utils_1.getUserContextForSrcTypeThunk)(options.user),
|
|
133
133
|
...configDelegate
|
|
134
134
|
};
|
|
135
135
|
}
|
|
@@ -145,6 +145,7 @@ function getContentSourceActionsForSourceThunk({ getContentSourceDataById, logge
|
|
|
145
145
|
});
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
|
+
exports.getContentSourceActionsForSourceThunk = getContentSourceActionsForSourceThunk;
|
|
148
149
|
function getContentSourceActionsForSource({ srcType, srcProjectId, logger, user, stackbitConfig, getContentSourceDataById }) {
|
|
149
150
|
const contentSourcesData = (0, content_store_utils_1.findContentSourcesDataForTypeOrId)({
|
|
150
151
|
contentSourceDataById: getContentSourceDataById(),
|