@stackbit/cms-core 0.7.5-staging.1 → 0.7.5
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/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/utils/custom-actions.d.ts +53 -0
- package/dist/utils/custom-actions.d.ts.map +1 -0
- package/dist/utils/custom-actions.js +586 -0
- package/dist/utils/custom-actions.js.map +1 -0
- package/dist/utils/tree-views.d.ts +10 -0
- package/dist/utils/tree-views.d.ts.map +1 -0
- package/dist/utils/tree-views.js +64 -0
- package/dist/utils/tree-views.js.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { CustomActionGlobal, CustomActionBulk, CustomActionDocument, CustomActionObjectModel, CustomActionObjectField, CustomActionField, CustomActionState, CustomActionInputField } from '@stackbit/types';
|
|
2
|
+
import { User } from './index';
|
|
3
|
+
export declare type ContentStoreCustomActionMap = Record<string, ContentStoreCustomAction>;
|
|
4
|
+
export declare type ContentStoreCustomAction = ContentStoreCustomActionGlobal | ContentStoreCustomActionBulk | ContentStoreCustomActionDocument | ContentStoreCustomActionObjectModel | ContentStoreCustomActionObjectField | ContentStoreCustomActionField;
|
|
5
|
+
export declare type ContentStoreCustomActionGlobal = CustomActionGlobal & ContentStoreCustomActionCommonProps;
|
|
6
|
+
export declare type ContentStoreCustomActionBulk = CustomActionBulk & ContentStoreCustomActionCommonProps;
|
|
7
|
+
export declare type ContentStoreCustomActionDocument = CustomActionDocument & ContentStoreCustomActionCommonProps & {
|
|
8
|
+
type: 'document';
|
|
9
|
+
documentSpec: APICustomActionDocumentSpecifier;
|
|
10
|
+
};
|
|
11
|
+
export declare type ContentStoreCustomActionObjectModel = CustomActionObjectModel & ContentStoreCustomActionCommonProps & {
|
|
12
|
+
type: 'objectModel';
|
|
13
|
+
documentSpec: APICustomActionDocumentSpecifier;
|
|
14
|
+
fieldPath: (string | number)[];
|
|
15
|
+
};
|
|
16
|
+
export declare type ContentStoreCustomActionObjectField = Omit<CustomActionObjectField, 'type'> & ContentStoreCustomActionCommonProps & {
|
|
17
|
+
type: 'objectField';
|
|
18
|
+
documentSpec: APICustomActionDocumentSpecifier;
|
|
19
|
+
fieldPath: (string | number)[];
|
|
20
|
+
};
|
|
21
|
+
export declare type ContentStoreCustomActionField = CustomActionField & ContentStoreCustomActionCommonProps & {
|
|
22
|
+
type: 'field';
|
|
23
|
+
documentSpec: APICustomActionDocumentSpecifier;
|
|
24
|
+
fieldPath: (string | number)[];
|
|
25
|
+
};
|
|
26
|
+
export declare type ContentStoreCustomActionCommonProps = {
|
|
27
|
+
type: string;
|
|
28
|
+
actionId: string;
|
|
29
|
+
label: string;
|
|
30
|
+
runningHandler?: boolean;
|
|
31
|
+
lastResultState?: CustomActionState;
|
|
32
|
+
};
|
|
33
|
+
export declare type CustomActionType = 'global' | 'bulk' | 'document' | 'object' | 'field';
|
|
34
|
+
export declare type APICustomAction = APICustomActionGlobal | APICustomActionBulk | APICustomActionDocument | APICustomActionObject | APICustomActionField;
|
|
35
|
+
export interface APICustomActionGlobal extends APICustomActionCommonProps {
|
|
36
|
+
type: 'global';
|
|
37
|
+
}
|
|
38
|
+
export interface APICustomActionBulk extends APICustomActionCommonProps {
|
|
39
|
+
type: 'bulk';
|
|
40
|
+
}
|
|
41
|
+
export interface APICustomActionDocument extends APICustomActionCommonProps {
|
|
42
|
+
type: 'document';
|
|
43
|
+
}
|
|
44
|
+
export interface APICustomActionObject extends APICustomActionCommonProps {
|
|
45
|
+
type: 'object';
|
|
46
|
+
}
|
|
47
|
+
export interface APICustomActionField extends APICustomActionCommonProps {
|
|
48
|
+
type: 'field';
|
|
49
|
+
}
|
|
50
|
+
export interface APICustomActionCommonProps {
|
|
51
|
+
type: CustomActionType;
|
|
52
|
+
actionId: string;
|
|
53
|
+
name: string;
|
|
54
|
+
label: string;
|
|
55
|
+
icon?: string;
|
|
56
|
+
state: CustomActionState | 'unknown';
|
|
57
|
+
inputFields?: CustomActionInputField[];
|
|
58
|
+
needsResolving?: boolean;
|
|
59
|
+
}
|
|
60
|
+
export declare type APIRunCustomActionRequest = APIRunCustomActionRequestGlobal | APIRunCustomActionRequestBulk | APIRunCustomActionRequestDocument | APIRunCustomActionRequestObject | APIRunCustomActionRequestField;
|
|
61
|
+
export interface APIRunCustomActionRequestGlobal extends APIRunCustomActionRequestCommonParams {
|
|
62
|
+
actionType: 'global';
|
|
63
|
+
}
|
|
64
|
+
export interface APIRunCustomActionRequestBulk extends APIRunCustomActionRequestCommonParams {
|
|
65
|
+
actionType: 'bulk';
|
|
66
|
+
documents: APICustomActionDocumentSpecifier[];
|
|
67
|
+
}
|
|
68
|
+
export interface APIRunCustomActionRequestDocument extends APIRunCustomActionRequestCommonParams {
|
|
69
|
+
actionType: 'document';
|
|
70
|
+
}
|
|
71
|
+
export interface APIRunCustomActionRequestObject extends APIRunCustomActionRequestCommonParams {
|
|
72
|
+
actionType: 'object';
|
|
73
|
+
}
|
|
74
|
+
export interface APIRunCustomActionRequestField extends APIRunCustomActionRequestCommonParams {
|
|
75
|
+
actionType: 'field';
|
|
76
|
+
}
|
|
77
|
+
interface APIRunCustomActionRequestCommonParams {
|
|
78
|
+
actionType: string;
|
|
79
|
+
actionId: string;
|
|
80
|
+
actionName: string;
|
|
81
|
+
locale?: string;
|
|
82
|
+
user?: User;
|
|
83
|
+
pageUrl?: string;
|
|
84
|
+
currentPageDocument?: APICustomActionDocumentSpecifier;
|
|
85
|
+
inputData?: Record<string, any>;
|
|
86
|
+
}
|
|
87
|
+
export interface APIGetCustomActionRequest {
|
|
88
|
+
customActionIds: string[];
|
|
89
|
+
locale?: string;
|
|
90
|
+
user?: User;
|
|
91
|
+
pageUrl?: string;
|
|
92
|
+
currentPageDocument?: APICustomActionDocumentSpecifier;
|
|
93
|
+
}
|
|
94
|
+
export interface APICustomActionDocumentSpecifier {
|
|
95
|
+
srcType: string;
|
|
96
|
+
srcProjectId: string;
|
|
97
|
+
srcDocumentId: string;
|
|
98
|
+
}
|
|
99
|
+
export interface CustomActionStateChange {
|
|
100
|
+
actionType: CustomActionType;
|
|
101
|
+
actionId: string;
|
|
102
|
+
actionName: string;
|
|
103
|
+
state: CustomActionState;
|
|
104
|
+
success?: string;
|
|
105
|
+
error?: string;
|
|
106
|
+
}
|
|
107
|
+
export {};
|
|
108
|
+
//# sourceMappingURL=custom-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-actions.d.ts","sourceRoot":"","sources":["../../src/types/custom-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,oBAAY,2BAA2B,GAAG,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;AAEnF,oBAAY,wBAAwB,GAC9B,8BAA8B,GAC9B,4BAA4B,GAC5B,gCAAgC,GAChC,mCAAmC,GACnC,mCAAmC,GACnC,6BAA6B,CAAC;AAEpC,oBAAY,8BAA8B,GAAG,kBAAkB,GAAG,mCAAmC,CAAC;AACtG,oBAAY,4BAA4B,GAAG,gBAAgB,GAAG,mCAAmC,CAAC;AAClG,oBAAY,gCAAgC,GAAG,oBAAoB,GAC/D,mCAAmC,GAAG;IAClC,IAAI,EAAE,UAAU,CAAC;IACjB,YAAY,EAAE,gCAAgC,CAAC;CAClD,CAAC;AACN,oBAAY,mCAAmC,GAAG,uBAAuB,GACrE,mCAAmC,GAAG;IAClC,IAAI,EAAE,aAAa,CAAC;IACpB,YAAY,EAAE,gCAAgC,CAAC;IAC/C,SAAS,EAAE,CAAC,MAAM,GAAG,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M,EAAE,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mBAAmB,CAAC,EAAE,gCAAgC,CAAC;CAC1D;AAED,MAAM,WAAW,gCAAgC;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,uBAAuB;IACpC,UAAU,EAAE,gBAAgB,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,iBAAiB,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-actions.js","sourceRoot":"","sources":["../../src/types/custom-actions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Config } from '@stackbit/sdk';
|
|
2
|
+
import * as StackbitTypes from '@stackbit/types';
|
|
3
|
+
import * as ContentStoreTypes from '../types';
|
|
4
|
+
import { CustomActionStateChange, APICustomAction, APICustomActionDocumentSpecifier, APICustomActionDocument, APICustomActionObject, APICustomActionField, APIGetCustomActionRequest, APIRunCustomActionRequest, ContentStoreCustomActionMap, APICustomActionGlobal, APICustomActionBulk } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* Removes "run" and "state" functions from actions of models, nested objects and fields.
|
|
7
|
+
* Sets "needsResolving" flag to let client know if the action needs additional resolving.
|
|
8
|
+
* @param {StackbitTypes.ModelMap} modelMap
|
|
9
|
+
*/
|
|
10
|
+
export declare function stripModelActions({ modelMap }: {
|
|
11
|
+
modelMap: StackbitTypes.ModelMap;
|
|
12
|
+
}): StackbitTypes.ModelMap;
|
|
13
|
+
export declare function getGlobalAndBulkAPIActions({ stackbitConfig, customActionMap, contentSourceDataById, userLogger, pageUrl, user, locale, currentPageDocument }: {
|
|
14
|
+
stackbitConfig: Config | null;
|
|
15
|
+
customActionMap: ContentStoreCustomActionMap;
|
|
16
|
+
contentSourceDataById: Record<string, ContentStoreTypes.ContentSourceData>;
|
|
17
|
+
userLogger: StackbitTypes.Logger;
|
|
18
|
+
pageUrl?: string;
|
|
19
|
+
user?: ContentStoreTypes.User;
|
|
20
|
+
locale?: string;
|
|
21
|
+
currentPageDocument?: APICustomActionDocumentSpecifier;
|
|
22
|
+
}): Promise<(APICustomActionGlobal | APICustomActionBulk)[]>;
|
|
23
|
+
export declare function convertDocumentActionToAPICustomDocumentAction({ action, customActionMap, csiDocument }: {
|
|
24
|
+
action: StackbitTypes.CustomActionDocument;
|
|
25
|
+
customActionMap: ContentStoreCustomActionMap;
|
|
26
|
+
csiDocument: StackbitTypes.DocumentWithSource;
|
|
27
|
+
}): APICustomActionDocument;
|
|
28
|
+
export declare function convertObjectModelActionToAPICustomObjectAction({ action, customActionMap, csiParentDocument, fieldPath }: {
|
|
29
|
+
action: StackbitTypes.CustomActionObjectModel;
|
|
30
|
+
customActionMap: ContentStoreCustomActionMap;
|
|
31
|
+
csiParentDocument: StackbitTypes.DocumentWithSource;
|
|
32
|
+
fieldPath: (string | number)[];
|
|
33
|
+
}): APICustomActionObject;
|
|
34
|
+
export declare function convertFieldActionToAPICustomAction<T extends StackbitTypes.CustomActionField | StackbitTypes.CustomActionObjectField>({ action, customActionMap, csiParentDocument, fieldPath }: {
|
|
35
|
+
action: T;
|
|
36
|
+
customActionMap: ContentStoreCustomActionMap;
|
|
37
|
+
csiParentDocument: StackbitTypes.DocumentWithSource;
|
|
38
|
+
fieldPath: (string | number)[];
|
|
39
|
+
}): T extends StackbitTypes.CustomActionField ? APICustomActionField : APICustomActionObject;
|
|
40
|
+
export declare function resolveCustomActionsById({ getActionRequest, customActionMap, contentSourceDataById, userLogger }: {
|
|
41
|
+
getActionRequest: APIGetCustomActionRequest;
|
|
42
|
+
customActionMap: ContentStoreCustomActionMap;
|
|
43
|
+
contentSourceDataById: Record<string, ContentStoreTypes.ContentSourceData>;
|
|
44
|
+
userLogger: StackbitTypes.Logger;
|
|
45
|
+
}): Promise<APICustomAction[]>;
|
|
46
|
+
export declare function runCustomAction({ runActionRequest, customActionMap, contentSourceDataById, userLogger, stackbitConfig }: {
|
|
47
|
+
runActionRequest: APIRunCustomActionRequest;
|
|
48
|
+
customActionMap: ContentStoreCustomActionMap;
|
|
49
|
+
contentSourceDataById: Record<string, ContentStoreTypes.ContentSourceData>;
|
|
50
|
+
userLogger: StackbitTypes.Logger;
|
|
51
|
+
stackbitConfig: Config | null;
|
|
52
|
+
}): Promise<CustomActionStateChange>;
|
|
53
|
+
//# sourceMappingURL=custom-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-actions.d.ts","sourceRoot":"","sources":["../../src/utils/custom-actions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAA6B,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,aAAa,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,iBAAiB,MAAM,UAAU,CAAC;AAC9C,OAAO,EACH,uBAAuB,EACvB,eAAe,EACf,gCAAgC,EAChC,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,EACzB,yBAAyB,EAEzB,2BAA2B,EAM3B,qBAAqB,EACrB,mBAAmB,EAGtB,MAAM,UAAU,CAAC;AAUlB;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,aAAa,CAAC,QAAQ,CAAA;CAAE,GAAG,aAAa,CAAC,QAAQ,CAiB5G;AAED,wBAAsB,0BAA0B,CAAC,EAC7C,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,OAAO,EACP,IAAI,EACJ,MAAM,EACN,mBAAmB,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BAAkB,CAAC;IACpD,SAAS,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;CAClC,GAAG,CAAC,SAAS,aAAa,CAAC,iBAAiB,GAAG,oBAAoB,GAAG,qBAAqB,CA0C3F;AAED,wBAAsB,wBAAwB,CAAC,EAC3C,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,UAAU,EACb,EAAE;IACC,gBAAgB,EAAE,yBAAyB,CAAC;IAC5C,eAAe,EAAE,2BAA2B,CAAC;IAC7C,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAC3E,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC;CACpC,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAkG7B;AAED,wBAAgB,eAAe,CAAC,EAC5B,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,UAAU,EACV,cAAc,EACjB,EAAE;IACC,gBAAgB,EAAE,yBAAyB,CAAC;IAC5C,eAAe,EAAE,2BAA2B,CAAC;IAC7C,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAC3E,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC;IACjC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAwJnC"}
|
|
@@ -0,0 +1,586 @@
|
|
|
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
|
+
try {
|
|
233
|
+
let state;
|
|
234
|
+
if (storeAction.runningHandler) {
|
|
235
|
+
state = 'running';
|
|
236
|
+
}
|
|
237
|
+
else if (storeAction.state) {
|
|
238
|
+
const pageDocument = getCSIDocumentWithSourceFromDocumentSpec(currentPageDocument, configDelegate);
|
|
239
|
+
const commonStateOptions = {
|
|
240
|
+
actionId: actionId,
|
|
241
|
+
currentLocale: locale,
|
|
242
|
+
currentUser: user
|
|
243
|
+
? {
|
|
244
|
+
name: user.name,
|
|
245
|
+
email: user.email
|
|
246
|
+
}
|
|
247
|
+
: undefined,
|
|
248
|
+
currentPageUrl: pageUrl,
|
|
249
|
+
currentPageDocument: pageDocument,
|
|
250
|
+
...configDelegate
|
|
251
|
+
};
|
|
252
|
+
if (storeAction.type === 'global' || storeAction.type === 'bulk') {
|
|
253
|
+
state = await storeAction.state(commonStateOptions);
|
|
254
|
+
}
|
|
255
|
+
else if (storeAction.type === 'document') {
|
|
256
|
+
const { document, model } = getCSIDocumentAndModelWithSourceFromDocumentSpec({
|
|
257
|
+
documentSpec: storeAction.documentSpec,
|
|
258
|
+
contentSourceDataById
|
|
259
|
+
});
|
|
260
|
+
state = await storeAction.state({
|
|
261
|
+
...commonStateOptions,
|
|
262
|
+
document: document,
|
|
263
|
+
model: model
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
else if (storeAction.type === 'objectModel') {
|
|
267
|
+
const stateObjectParams = getHandlerParamsForObjectModelAction({
|
|
268
|
+
storeAction,
|
|
269
|
+
contentSourceDataById
|
|
270
|
+
});
|
|
271
|
+
state = await storeAction.state({
|
|
272
|
+
...commonStateOptions,
|
|
273
|
+
...stateObjectParams
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
else if (storeAction.type === 'objectField') {
|
|
277
|
+
const stateObjectParams = getHandlerParamsForObjectFieldAction({
|
|
278
|
+
storeAction,
|
|
279
|
+
contentSourceDataById
|
|
280
|
+
});
|
|
281
|
+
state = await storeAction.state({
|
|
282
|
+
...commonStateOptions,
|
|
283
|
+
...stateObjectParams
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
else if (storeAction.type === 'field') {
|
|
287
|
+
const stateFieldParams = getHandlerParamsForFieldAction({
|
|
288
|
+
storeAction,
|
|
289
|
+
contentSourceDataById
|
|
290
|
+
});
|
|
291
|
+
state = await storeAction.state({
|
|
292
|
+
...commonStateOptions,
|
|
293
|
+
...stateFieldParams
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
const _exhaustiveCheck = storeAction;
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
state = (_a = storeAction === null || storeAction === void 0 ? void 0 : storeAction.lastResultState) !== null && _a !== void 0 ? _a : 'enabled';
|
|
303
|
+
}
|
|
304
|
+
result.push((0, utils_1.omitByNil)({
|
|
305
|
+
actionId: actionId,
|
|
306
|
+
type: storeActionTypeToAPIActionType(storeAction.type),
|
|
307
|
+
name: storeAction.name,
|
|
308
|
+
label: storeAction.label,
|
|
309
|
+
icon: storeAction.icon,
|
|
310
|
+
state: state,
|
|
311
|
+
inputFields: storeAction.inputFields
|
|
312
|
+
}));
|
|
313
|
+
}
|
|
314
|
+
catch (error) {
|
|
315
|
+
userLogger.warn(`getCustomActionsById: error resolving custom action, id: '${actionId}', error: ${error.message}`);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return result;
|
|
319
|
+
}
|
|
320
|
+
exports.resolveCustomActionsById = resolveCustomActionsById;
|
|
321
|
+
function runCustomAction({ runActionRequest, customActionMap, contentSourceDataById, userLogger, stackbitConfig }) {
|
|
322
|
+
var _a, _b;
|
|
323
|
+
const storeAction = customActionMap[runActionRequest.actionId];
|
|
324
|
+
if (!storeAction) {
|
|
325
|
+
throw new Error(`Error running action: action not found, action name: '${runActionRequest.actionName}' action ID: '${runActionRequest.actionId}'.`);
|
|
326
|
+
}
|
|
327
|
+
const prevResultState = storeAction.lastResultState;
|
|
328
|
+
if (storeAction.lastResultState && storeAction.lastResultState !== 'enabled') {
|
|
329
|
+
throw new Error(`Error running action: action is not enabled, action name: '${runActionRequest.actionName}' action ID: '${runActionRequest.actionId}'.`);
|
|
330
|
+
}
|
|
331
|
+
try {
|
|
332
|
+
const actionLogger = userLogger.createLogger({ label: `action:${storeAction.name}` });
|
|
333
|
+
const configDelegate = (0, config_delegate_1.createConfigDelegate)({ contentSourceDataById: contentSourceDataById, logger: actionLogger });
|
|
334
|
+
const currentPageDocument = getCSIDocumentWithSourceFromDocumentSpec(runActionRequest.currentPageDocument, configDelegate);
|
|
335
|
+
storeAction.runningHandler = true;
|
|
336
|
+
storeAction.lastResultState = 'running';
|
|
337
|
+
const commonRunOptions = {
|
|
338
|
+
actionId: storeAction.actionId,
|
|
339
|
+
inputData: runActionRequest.inputData,
|
|
340
|
+
currentLocale: runActionRequest.locale,
|
|
341
|
+
currentUser: runActionRequest.user,
|
|
342
|
+
currentPageUrl: runActionRequest.pageUrl,
|
|
343
|
+
currentPageDocument: currentPageDocument,
|
|
344
|
+
getContentSourceActionsForSource: (0, document_hooks_1.getContentSourceActionsForSourceThunk)({
|
|
345
|
+
getContentSourceDataById: () => contentSourceDataById,
|
|
346
|
+
logger: userLogger,
|
|
347
|
+
user: runActionRequest.user,
|
|
348
|
+
stackbitConfig: stackbitConfig
|
|
349
|
+
}),
|
|
350
|
+
getUserContextForContentSourceType: (0, content_store_utils_1.getUserContextForSrcTypeThunk)(runActionRequest.user),
|
|
351
|
+
...configDelegate
|
|
352
|
+
};
|
|
353
|
+
let promise;
|
|
354
|
+
if (storeAction.type === 'global') {
|
|
355
|
+
promise = storeAction.run(commonRunOptions);
|
|
356
|
+
}
|
|
357
|
+
else if (storeAction.type === 'bulk') {
|
|
358
|
+
const documents = runActionRequest.documents.map((documentSpec) => {
|
|
359
|
+
const { document } = getCSIDocumentAndModelWithSourceFromDocumentSpec({
|
|
360
|
+
documentSpec,
|
|
361
|
+
contentSourceDataById
|
|
362
|
+
});
|
|
363
|
+
return document;
|
|
364
|
+
});
|
|
365
|
+
promise = storeAction.run({
|
|
366
|
+
...commonRunOptions,
|
|
367
|
+
documents
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
else if (storeAction.type === 'document') {
|
|
371
|
+
const { document, model } = getCSIDocumentAndModelWithSourceFromDocumentSpec({
|
|
372
|
+
documentSpec: storeAction.documentSpec,
|
|
373
|
+
contentSourceDataById
|
|
374
|
+
});
|
|
375
|
+
promise = storeAction.run({
|
|
376
|
+
...commonRunOptions,
|
|
377
|
+
document,
|
|
378
|
+
model,
|
|
379
|
+
contentSourceActions: commonRunOptions.getContentSourceActionsForSource({
|
|
380
|
+
srcType: storeAction.documentSpec.srcType,
|
|
381
|
+
srcProjectId: storeAction.documentSpec.srcProjectId
|
|
382
|
+
})
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
else if (storeAction.type === 'objectModel') {
|
|
386
|
+
const handlerObjectParams = getHandlerParamsForObjectModelAction({
|
|
387
|
+
storeAction,
|
|
388
|
+
contentSourceDataById
|
|
389
|
+
});
|
|
390
|
+
promise = storeAction.run({
|
|
391
|
+
...commonRunOptions,
|
|
392
|
+
...handlerObjectParams,
|
|
393
|
+
contentSourceActions: commonRunOptions.getContentSourceActionsForSource({
|
|
394
|
+
srcType: storeAction.documentSpec.srcType,
|
|
395
|
+
srcProjectId: storeAction.documentSpec.srcProjectId
|
|
396
|
+
})
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
else if (storeAction.type === 'objectField') {
|
|
400
|
+
const handlerObjectParams = getHandlerParamsForObjectFieldAction({
|
|
401
|
+
storeAction,
|
|
402
|
+
contentSourceDataById
|
|
403
|
+
});
|
|
404
|
+
promise = storeAction.run({
|
|
405
|
+
...commonRunOptions,
|
|
406
|
+
...handlerObjectParams,
|
|
407
|
+
contentSourceActions: commonRunOptions.getContentSourceActionsForSource({
|
|
408
|
+
srcType: storeAction.documentSpec.srcType,
|
|
409
|
+
srcProjectId: storeAction.documentSpec.srcProjectId
|
|
410
|
+
})
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
else if (storeAction.type === 'field') {
|
|
414
|
+
const handlerFieldParams = getHandlerParamsForFieldAction({ storeAction, contentSourceDataById });
|
|
415
|
+
promise = storeAction.run({
|
|
416
|
+
...commonRunOptions,
|
|
417
|
+
...handlerFieldParams,
|
|
418
|
+
contentSourceActions: commonRunOptions.getContentSourceActionsForSource({
|
|
419
|
+
srcType: storeAction.documentSpec.srcType,
|
|
420
|
+
srcProjectId: storeAction.documentSpec.srcProjectId
|
|
421
|
+
})
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
throw new Error(`action type ${storeAction.type} not supported`);
|
|
426
|
+
}
|
|
427
|
+
return promise
|
|
428
|
+
.then((actionResult) => {
|
|
429
|
+
var _a;
|
|
430
|
+
storeAction.runningHandler = false;
|
|
431
|
+
storeAction.lastResultState = actionResult === null || actionResult === void 0 ? void 0 : actionResult.state;
|
|
432
|
+
userLogger.debug(`Action completed: ${storeAction.actionId}`);
|
|
433
|
+
return Promise.resolve((0, utils_1.omitByNil)({
|
|
434
|
+
actionId: storeAction.actionId,
|
|
435
|
+
actionName: storeAction.name,
|
|
436
|
+
actionType: storeActionTypeToAPIActionType(storeAction.type),
|
|
437
|
+
// TODO: resolve the state if state function is defined
|
|
438
|
+
state: (_a = actionResult === null || actionResult === void 0 ? void 0 : actionResult.state) !== null && _a !== void 0 ? _a : 'enabled',
|
|
439
|
+
success: actionResult === null || actionResult === void 0 ? void 0 : actionResult.success,
|
|
440
|
+
error: actionResult === null || actionResult === void 0 ? void 0 : actionResult.error
|
|
441
|
+
}));
|
|
442
|
+
})
|
|
443
|
+
.catch((error) => {
|
|
444
|
+
storeAction.runningHandler = false;
|
|
445
|
+
storeAction.lastResultState = prevResultState;
|
|
446
|
+
userLogger.debug(`Error running action: ${error.message}`);
|
|
447
|
+
return Promise.resolve({
|
|
448
|
+
actionId: storeAction.actionId,
|
|
449
|
+
actionName: storeAction.name,
|
|
450
|
+
actionType: storeActionTypeToAPIActionType(storeAction.type),
|
|
451
|
+
// TODO: resolve the state if state function is defined
|
|
452
|
+
state: prevResultState !== null && prevResultState !== void 0 ? prevResultState : 'enabled',
|
|
453
|
+
error: `Error running action: ${error.message}`
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
catch (error) {
|
|
458
|
+
if (storeAction) {
|
|
459
|
+
storeAction.runningHandler = false;
|
|
460
|
+
storeAction.lastResultState = prevResultState;
|
|
461
|
+
}
|
|
462
|
+
userLogger.debug(`Error running action: ${error.message}`);
|
|
463
|
+
return Promise.resolve({
|
|
464
|
+
actionId: runActionRequest.actionId,
|
|
465
|
+
actionName: (_a = storeAction === null || storeAction === void 0 ? void 0 : storeAction.name) !== null && _a !== void 0 ? _a : runActionRequest.actionName,
|
|
466
|
+
actionType: (_b = storeActionTypeToAPIActionType(storeAction === null || storeAction === void 0 ? void 0 : storeAction.type)) !== null && _b !== void 0 ? _b : runActionRequest.actionType,
|
|
467
|
+
// TODO: resolve the state if state function is defined
|
|
468
|
+
state: prevResultState !== null && prevResultState !== void 0 ? prevResultState : 'enabled',
|
|
469
|
+
error: `Error running action: ${error.message}`
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
exports.runCustomAction = runCustomAction;
|
|
474
|
+
function getCSIDocumentWithSourceFromDocumentSpec(documentSpec, configDelegate) {
|
|
475
|
+
return documentSpec
|
|
476
|
+
? configDelegate.getDocumentById({
|
|
477
|
+
id: documentSpec.srcDocumentId,
|
|
478
|
+
srcType: documentSpec.srcType,
|
|
479
|
+
srcProjectId: documentSpec.srcProjectId
|
|
480
|
+
})
|
|
481
|
+
: undefined;
|
|
482
|
+
}
|
|
483
|
+
function getHandlerParamsForObjectModelAction({ storeAction, contentSourceDataById }) {
|
|
484
|
+
const fieldActionCommonParams = getHandlerParamsForFieldAction({
|
|
485
|
+
storeAction,
|
|
486
|
+
contentSourceDataById
|
|
487
|
+
});
|
|
488
|
+
if (!fieldActionCommonParams.documentField) {
|
|
489
|
+
throw new Error(`object document field not found at field path: ${storeAction.fieldPath.join('.')}`);
|
|
490
|
+
}
|
|
491
|
+
const documentField = fieldActionCommonParams.documentField;
|
|
492
|
+
const documentSpec = storeAction.documentSpec;
|
|
493
|
+
const contentSourceData = (0, content_store_utils_1.getContentSourceDataByTypeAndProjectIdOrThrow)(documentSpec.srcType, documentSpec.srcProjectId, contentSourceDataById);
|
|
494
|
+
const objectModel = contentSourceData.modelMap[documentField.modelName];
|
|
495
|
+
if (!objectModel || objectModel.type !== 'object') {
|
|
496
|
+
throw new Error(`object model '${documentField.modelName}' not found`);
|
|
497
|
+
}
|
|
498
|
+
return {
|
|
499
|
+
...fieldActionCommonParams,
|
|
500
|
+
documentField,
|
|
501
|
+
modelField: fieldActionCommonParams.modelField,
|
|
502
|
+
objectModel: {
|
|
503
|
+
...objectModel,
|
|
504
|
+
srcType: documentSpec.srcType,
|
|
505
|
+
srcProjectId: documentSpec.srcProjectId
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
function getHandlerParamsForObjectFieldAction({ storeAction, contentSourceDataById }) {
|
|
510
|
+
const fieldActionCommonParams = getHandlerParamsForFieldAction({
|
|
511
|
+
storeAction,
|
|
512
|
+
contentSourceDataById
|
|
513
|
+
});
|
|
514
|
+
if (!fieldActionCommonParams.documentField) {
|
|
515
|
+
throw new Error(`object document field not found at field path: ${storeAction.fieldPath.join('.')}`);
|
|
516
|
+
}
|
|
517
|
+
return {
|
|
518
|
+
...fieldActionCommonParams,
|
|
519
|
+
documentField: fieldActionCommonParams.documentField,
|
|
520
|
+
modelField: fieldActionCommonParams.modelField
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
function getHandlerParamsForFieldAction({ storeAction, contentSourceDataById }) {
|
|
524
|
+
const documentSpec = storeAction.documentSpec;
|
|
525
|
+
const contentSourceData = (0, content_store_utils_1.getContentSourceDataByTypeAndProjectIdOrThrow)(documentSpec.srcType, documentSpec.srcProjectId, contentSourceDataById);
|
|
526
|
+
const document = contentSourceData.documentMap[documentSpec.srcDocumentId];
|
|
527
|
+
const csiDocument = contentSourceData.csiDocumentMap[documentSpec.srcDocumentId];
|
|
528
|
+
if (!document || !csiDocument) {
|
|
529
|
+
throw new Error(`document not found for srcType: ${documentSpec.srcType}, srcProjectId: ${documentSpec.srcProjectId}, srcDocumentId: ${documentSpec.srcDocumentId}`);
|
|
530
|
+
}
|
|
531
|
+
const model = contentSourceData.modelMap[document.srcModelName];
|
|
532
|
+
if (!model) {
|
|
533
|
+
throw new Error(`model '${document.srcModelName}' not found`);
|
|
534
|
+
}
|
|
535
|
+
const mappedCSIDocument = (0, store_to_csi_docs_converter_1.mapStoreDocumentToCSIDocumentWithSource)({ document, csiDocument });
|
|
536
|
+
// the documentField should be localized because fieldPath includes locales
|
|
537
|
+
const { modelField, documentField } = (0, content_store_utils_1.getModelAndDocumentFieldForLocalizedFieldPath)({
|
|
538
|
+
document,
|
|
539
|
+
model,
|
|
540
|
+
fieldPath: storeAction.fieldPath,
|
|
541
|
+
modelMap: contentSourceData.modelMap
|
|
542
|
+
});
|
|
543
|
+
const csiDocumentField = (0, store_to_csi_docs_converter_1.mapStoreFieldToCSIField)(documentField);
|
|
544
|
+
return {
|
|
545
|
+
parentDocument: mappedCSIDocument,
|
|
546
|
+
parentModel: {
|
|
547
|
+
...model,
|
|
548
|
+
srcType: documentSpec.srcType,
|
|
549
|
+
srcProjectId: documentSpec.srcProjectId
|
|
550
|
+
},
|
|
551
|
+
documentField: csiDocumentField,
|
|
552
|
+
modelField: modelField,
|
|
553
|
+
fieldPath: storeAction.fieldPath
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
function getCSIDocumentAndModelWithSourceFromDocumentSpec({ documentSpec, contentSourceDataById }) {
|
|
557
|
+
const contentSourceData = (0, content_store_utils_1.getContentSourceDataByTypeAndProjectIdOrThrow)(documentSpec.srcType, documentSpec.srcProjectId, contentSourceDataById);
|
|
558
|
+
const document = contentSourceData.documentMap[documentSpec.srcDocumentId];
|
|
559
|
+
const csiDocument = contentSourceData.csiDocumentMap[documentSpec.srcDocumentId];
|
|
560
|
+
if (!document || !csiDocument) {
|
|
561
|
+
throw new Error(`document not found, srcType: ${documentSpec.srcType}, srcProjectId: ${documentSpec.srcProjectId}, srcDocumentId: ${documentSpec.srcDocumentId}`);
|
|
562
|
+
}
|
|
563
|
+
const mappedDocument = (0, store_to_csi_docs_converter_1.mapStoreDocumentToCSIDocumentWithSource)({
|
|
564
|
+
document,
|
|
565
|
+
csiDocument
|
|
566
|
+
});
|
|
567
|
+
const model = contentSourceData.modelMap[mappedDocument.modelName];
|
|
568
|
+
if (!model) {
|
|
569
|
+
throw new Error(`model '${mappedDocument.modelName}' not found`);
|
|
570
|
+
}
|
|
571
|
+
return {
|
|
572
|
+
document: mappedDocument,
|
|
573
|
+
model: {
|
|
574
|
+
...model,
|
|
575
|
+
srcType: documentSpec.srcType,
|
|
576
|
+
srcProjectId: documentSpec.srcProjectId
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
function storeActionTypeToAPIActionType(storeActionType) {
|
|
581
|
+
if (storeActionType === 'objectModel' || storeActionType === 'objectField') {
|
|
582
|
+
return 'object';
|
|
583
|
+
}
|
|
584
|
+
return storeActionType;
|
|
585
|
+
}
|
|
586
|
+
//# 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,EA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,CAAC;KACnB;IACD,OAAO,eAAe,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Config } from '@stackbit/sdk';
|
|
2
|
+
import * as CSITypes from '@stackbit/types';
|
|
3
|
+
import { ContentStoreTypes } from '../';
|
|
4
|
+
export declare function getSanitizedTreeViews({ configDelegate, stackbitConfig, contentSourceDataById, logger }: {
|
|
5
|
+
configDelegate: CSITypes.ConfigDelegate;
|
|
6
|
+
stackbitConfig: Config | null;
|
|
7
|
+
contentSourceDataById: Record<string, ContentStoreTypes.ContentSourceData>;
|
|
8
|
+
logger: CSITypes.Logger;
|
|
9
|
+
}): Promise<CSITypes.TreeViewNode[]>;
|
|
10
|
+
//# sourceMappingURL=tree-views.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-views.d.ts","sourceRoot":"","sources":["../../src/utils/tree-views.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,KAAK,CAAC;AAGxC,wBAAsB,qBAAqB,CAAC,EACxC,cAAc,EACd,cAAc,EACd,qBAAqB,EACrB,MAAM,EACT,EAAE;IACC,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC;IACxC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAC3E,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC;CAC3B,GAAG,OAAO,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,CAuDnC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
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.getSanitizedTreeViews = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const content_store_utils_1 = require("../content-store-utils");
|
|
9
|
+
async function getSanitizedTreeViews({ configDelegate, stackbitConfig, contentSourceDataById, logger }) {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const treeViews = (_b = (await ((_a = stackbitConfig === null || stackbitConfig === void 0 ? void 0 : stackbitConfig.treeViews) === null || _a === void 0 ? void 0 : _a.call(stackbitConfig, configDelegate)))) !== null && _b !== void 0 ? _b : [];
|
|
12
|
+
const mapTreeViews = (treeViews) => treeViews
|
|
13
|
+
.map((treeView) => {
|
|
14
|
+
var _a, _b, _c, _d, _e, _f;
|
|
15
|
+
if ('document' in treeView && treeView.document) {
|
|
16
|
+
const contentSourceId = (0, content_store_utils_1.getContentSourceId)(treeView.document.srcType, treeView.document.srcProjectId);
|
|
17
|
+
const document = (_a = contentSourceDataById[contentSourceId]) === null || _a === void 0 ? void 0 : _a.documentMap[treeView.document.id];
|
|
18
|
+
// explicit check because developers can skip TS check and just not define required properties of document object
|
|
19
|
+
if (document) {
|
|
20
|
+
treeView = {
|
|
21
|
+
...treeView,
|
|
22
|
+
stableId: (_b = treeView.stableId) !== null && _b !== void 0 ? _b : document.srcObjectId,
|
|
23
|
+
label: (_c = treeView.label) !== null && _c !== void 0 ? _c : document.getPreview({ delegate: configDelegate }).previewTitle,
|
|
24
|
+
document: {
|
|
25
|
+
srcType: treeView.document.srcType,
|
|
26
|
+
srcProjectId: treeView.document.srcProjectId,
|
|
27
|
+
id: treeView.document.id
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
logger.warn(`One of required properties is missing in tree view document, document skipped from tree view,
|
|
33
|
+
srcType: ${(_d = treeView.document) === null || _d === void 0 ? void 0 : _d.srcType}, srcProjectId: ${(_e = treeView.document) === null || _e === void 0 ? void 0 : _e.srcProjectId}, id: ${(_f = treeView.document) === null || _f === void 0 ? void 0 : _f.id}.`);
|
|
34
|
+
// don't early return because treeView.children can be defined properly
|
|
35
|
+
if (treeView.children) {
|
|
36
|
+
treeView = lodash_1.default.omit(treeView, 'document');
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if ('children' in treeView && treeView.children) {
|
|
44
|
+
// required check because of
|
|
45
|
+
// 1. typecast during omit in previous if
|
|
46
|
+
// 2. developer can ignore TS check and just not define stableId and label
|
|
47
|
+
if (treeView.stableId && treeView.label) {
|
|
48
|
+
treeView = {
|
|
49
|
+
...treeView,
|
|
50
|
+
children: mapTreeViews(treeView.children)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
logger.warn('one of required properties (stableId or label) is missing in tree view, children are skipped from tree view');
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return treeView;
|
|
59
|
+
})
|
|
60
|
+
.filter(Boolean);
|
|
61
|
+
return mapTreeViews(treeViews);
|
|
62
|
+
}
|
|
63
|
+
exports.getSanitizedTreeViews = getSanitizedTreeViews;
|
|
64
|
+
//# sourceMappingURL=tree-views.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-views.js","sourceRoot":"","sources":["../../src/utils/tree-views.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAIvB,gEAA4D;AAErD,KAAK,UAAU,qBAAqB,CAAC,EACxC,cAAc,EACd,cAAc,EACd,qBAAqB,EACrB,MAAM,EAMT;;IACG,MAAM,SAAS,GAAG,MAAA,CAAC,MAAM,CAAA,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,SAAS,+CAAzB,cAAc,EAAc,cAAc,CAAC,CAAA,CAAC,mCAAI,EAAE,CAAC;IAE5E,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AM;oBACH,OAAO,SAAS,CAAC;iBACpB;aACJ;SACJ;QAED,IAAI,UAAU,IAAI,QAAQ,IAAI,QAAQ,CAAC,QAAQ,EAAE;YAC7C,4BAA4B;YAC5B,yCAAyC;YACzC,0EAA0E;YAC1E,IAAI,QAAQ,CAAC,QAAQ,IAAI,QAAQ,CAAC,KAAK,EAAE;gBACrC,QAAQ,GAAG;oBACP,GAAG,QAAQ;oBACX,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC;iBAC5C,CAAC;aACL;iBAAM;gBACH,MAAM,CAAC,IAAI,CAAC,6GAA6G,CAAC,CAAC;gBAC3H,OAAO,SAAS,CAAC;aACpB;SACJ;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC,CAAC;SACD,MAAM,CAAC,OAAO,CAA4B,CAAC;IAEpD,OAAO,YAAY,CAAC,SAAS,CAAC,CAAC;AACnC,CAAC;AAjED,sDAiEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackbit/cms-core",
|
|
3
|
-
"version": "0.7.5
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"description": "stackbit-dev",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"@babel/parser": "^7.11.5",
|
|
26
26
|
"@babel/traverse": "^7.11.5",
|
|
27
27
|
"@iarna/toml": "^2.2.3",
|
|
28
|
-
"@stackbit/sdk": "0.6.5
|
|
29
|
-
"@stackbit/types": "0.8.5
|
|
30
|
-
"@stackbit/utils": "0.2.42
|
|
28
|
+
"@stackbit/sdk": "0.6.5",
|
|
29
|
+
"@stackbit/types": "0.8.5",
|
|
30
|
+
"@stackbit/utils": "0.2.42",
|
|
31
31
|
"chalk": "^4.0.1",
|
|
32
32
|
"esm": "^3.2.25",
|
|
33
33
|
"fs-extra": "^8.1.0",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"slugify": "^1.6.5",
|
|
43
43
|
"uuid": "^9.0.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "1117c7f8f8dfe6c3fd14f6f00ef169afc3933f7d"
|
|
46
46
|
}
|