@webiny/api-headless-cms 5.23.1 → 5.24.0-beta.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/content/graphQLHandlerFactory.js +8 -2
- package/content/plugins/crud/contentEntry/afterDelete.d.ts +3 -2
- package/content/plugins/crud/contentEntry/beforeCreate.d.ts +3 -2
- package/content/plugins/crud/contentEntry/beforeUpdate.d.ts +3 -2
- package/content/plugins/crud/contentEntry/markLockedFields.d.ts +2 -1
- package/content/plugins/crud/contentModel/afterCreate.d.ts +3 -2
- package/content/plugins/crud/contentModel/afterDelete.d.ts +3 -2
- package/content/plugins/crud/contentModel/afterUpdate.d.ts +3 -2
- package/content/plugins/crud/contentModel/beforeCreate.d.ts +3 -2
- package/content/plugins/crud/contentModel/beforeDelete.d.ts +3 -2
- package/content/plugins/crud/contentModel/beforeUpdate.d.ts +3 -2
- package/content/plugins/crud/contentModel/beforeUpdate.js +69 -0
- package/content/plugins/crud/contentModel/contentModelManagerFactory.d.ts +2 -2
- package/content/plugins/crud/contentModel/models.js +9 -0
- package/content/plugins/crud/contentModelGroup/beforeCreate.d.ts +3 -2
- package/content/plugins/crud/contentModelGroup/beforeDelete.d.ts +3 -2
- package/content/plugins/crud/contentModelGroup/beforeUpdate.d.ts +3 -2
- package/content/plugins/graphqlFields/datetime.js +3 -1
- package/content/plugins/graphqlFields/object.js +9 -13
- package/content/plugins/graphqlFields/ref.js +25 -5
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.d.ts +1 -1
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js +1 -0
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.d.ts +1 -1
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js +1 -0
- package/content/plugins/modelManager/DefaultCmsModelManager.d.ts +3 -3
- package/content/plugins/schema/createFieldResolvers.d.ts +8 -7
- package/content/plugins/schema/createFieldResolvers.js +25 -12
- package/content/plugins/schema/createManageResolvers.d.ts +7 -6
- package/content/plugins/schema/createManageSDL.d.ts +5 -4
- package/content/plugins/schema/createPreviewResolvers.d.ts +8 -6
- package/content/plugins/schema/createReadResolvers.d.ts +8 -6
- package/content/plugins/schema/createReadSDL.d.ts +7 -6
- package/content/plugins/schema/resolvers/manage/resolveCreate.d.ts +5 -4
- package/content/plugins/schema/resolvers/manage/resolveCreate.js +2 -4
- package/content/plugins/schema/resolvers/manage/resolveCreateFrom.d.ts +5 -4
- package/content/plugins/schema/resolvers/manage/resolveCreateFrom.js +2 -4
- package/content/plugins/schema/resolvers/manage/resolveDelete.d.ts +6 -1
- package/content/plugins/schema/resolvers/manage/resolveDelete.js +4 -8
- package/content/plugins/schema/resolvers/manage/resolveGet.d.ts +6 -1
- package/content/plugins/schema/resolvers/manage/resolveGetByIds.d.ts +6 -1
- package/content/plugins/schema/resolvers/manage/resolveGetByIds.js +2 -4
- package/content/plugins/schema/resolvers/manage/resolveGetRevisions.d.ts +6 -1
- package/content/plugins/schema/resolvers/manage/resolveGetRevisions.js +2 -4
- package/content/plugins/schema/resolvers/manage/resolveList.d.ts +4 -2
- package/content/plugins/schema/resolvers/manage/resolveList.js +2 -4
- package/content/plugins/schema/resolvers/manage/resolvePublish.d.ts +6 -1
- package/content/plugins/schema/resolvers/manage/resolveRepublish.d.ts +6 -1
- package/content/plugins/schema/resolvers/manage/resolveRequestChanges.d.ts +3 -2
- package/content/plugins/schema/resolvers/manage/resolveRequestChanges.js +2 -4
- package/content/plugins/schema/resolvers/manage/resolveRequestReview.d.ts +3 -2
- package/content/plugins/schema/resolvers/manage/resolveRequestReview.js +2 -4
- package/content/plugins/schema/resolvers/manage/resolveUnpublish.d.ts +6 -1
- package/content/plugins/schema/resolvers/manage/resolveUpdate.d.ts +5 -4
- package/content/plugins/schema/resolvers/manage/resolveUpdate.js +2 -4
- package/content/plugins/schema/resolvers/preview/resolveGet.d.ts +4 -2
- package/content/plugins/schema/resolvers/preview/resolveList.d.ts +4 -2
- package/content/plugins/schema/resolvers/preview/resolveList.js +2 -4
- package/content/plugins/schema/resolvers/read/resolveGet.d.ts +4 -2
- package/content/plugins/schema/resolvers/read/resolveList.d.ts +4 -2
- package/content/plugins/schema/resolvers/read/resolveList.js +2 -4
- package/content/plugins/storage/StorageTransformPlugin.d.ts +2 -2
- package/content/plugins/storage/object.js +9 -8
- package/content/plugins/utils/createTypeName.d.ts +3 -3
- package/content/plugins/utils/getEntryTitle.d.ts +1 -1
- package/content/plugins/utils/getSchemaFromFieldPlugins.d.ts +7 -6
- package/content/plugins/utils/getSchemaFromFieldPlugins.js +6 -6
- package/content/plugins/utils/pluralizedTypeName.d.ts +1 -1
- package/content/plugins/utils/renderFields.d.ts +11 -12
- package/content/plugins/utils/renderFields.js +1 -1
- package/content/plugins/utils/renderGetFilterFields.d.ts +5 -4
- package/content/plugins/utils/renderGetFilterFields.js +23 -13
- package/content/plugins/utils/renderInputFields.d.ts +10 -10
- package/content/plugins/utils/renderListFilterFields.d.ts +7 -6
- package/content/plugins/utils/renderListFilterFields.js +24 -12
- package/content/plugins/utils/renderSortEnum.js +5 -5
- package/migrateCMSPermissions.d.ts +2 -2
- package/migrateCMSPermissions.js +4 -0
- package/package.json +24 -23
- package/plugins/graphql/system.d.ts +4 -3
- package/plugins/graphql/system.js +5 -3
- package/plugins/upgrades/v5.5.0/index.js +4 -0
- package/types.d.ts +12 -12
- package/utils.d.ts +4 -4
|
@@ -68,6 +68,11 @@ const generateSchema = async args => {
|
|
|
68
68
|
context
|
|
69
69
|
} = args;
|
|
70
70
|
context.plugins.register(await (0, _buildSchemaPlugins.default)(context));
|
|
71
|
+
/**
|
|
72
|
+
* Really hard to type this to satisfy the makeExecutableSchema
|
|
73
|
+
*/
|
|
74
|
+
// TODO @ts-refactor
|
|
75
|
+
|
|
71
76
|
const typeDefs = [];
|
|
72
77
|
const resolvers = []; // Get schema definitions from plugins
|
|
73
78
|
|
|
@@ -133,7 +138,7 @@ const checkEndpointAccess = async context => {
|
|
|
133
138
|
|
|
134
139
|
const graphQLHandlerFactory = (options = {}) => {
|
|
135
140
|
const debug = (0, _boolean.boolean)(options.debug);
|
|
136
|
-
|
|
141
|
+
const handler = {
|
|
137
142
|
type: "handler",
|
|
138
143
|
name: "handler-graphql-content-model",
|
|
139
144
|
|
|
@@ -173,7 +178,8 @@ const graphQLHandlerFactory = (options = {}) => {
|
|
|
173
178
|
return respond(http, result);
|
|
174
179
|
}
|
|
175
180
|
|
|
176
|
-
}
|
|
181
|
+
};
|
|
182
|
+
return [...(debug ? (0, _debugPlugins.default)() : []), handler];
|
|
177
183
|
};
|
|
178
184
|
|
|
179
185
|
exports.graphQLHandlerFactory = graphQLHandlerFactory;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Topic } from "@webiny/pubsub/types";
|
|
2
2
|
import { AfterEntryDeleteTopicParams, CmsContext } from "../../../../types";
|
|
3
|
-
|
|
3
|
+
interface AssignAfterEntryDeleteParams {
|
|
4
4
|
context: CmsContext;
|
|
5
5
|
onAfterEntryDelete: Topic<AfterEntryDeleteTopicParams>;
|
|
6
6
|
}
|
|
7
|
-
export declare const assignAfterEntryDelete: (params:
|
|
7
|
+
export declare const assignAfterEntryDelete: (params: AssignAfterEntryDeleteParams) => void;
|
|
8
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Topic } from "@webiny/pubsub/types";
|
|
2
2
|
import { BeforeEntryCreateTopicParams, CmsContext } from "../../../../types";
|
|
3
|
-
|
|
3
|
+
interface AssignBeforeEntryCreateParams {
|
|
4
4
|
context: CmsContext;
|
|
5
5
|
onBeforeEntryCreate: Topic<BeforeEntryCreateTopicParams>;
|
|
6
6
|
}
|
|
7
|
-
export declare const assignBeforeEntryCreate: (params:
|
|
7
|
+
export declare const assignBeforeEntryCreate: (params: AssignBeforeEntryCreateParams) => void;
|
|
8
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Topic } from "@webiny/pubsub/types";
|
|
2
2
|
import { BeforeEntryUpdateTopicParams, CmsContext } from "../../../../types";
|
|
3
|
-
|
|
3
|
+
interface AssignBeforeEntryUpdateParams {
|
|
4
4
|
context: CmsContext;
|
|
5
5
|
onBeforeEntryUpdate: Topic<BeforeEntryUpdateTopicParams>;
|
|
6
6
|
}
|
|
7
|
-
export declare const assignBeforeEntryUpdate: (params:
|
|
7
|
+
export declare const assignBeforeEntryUpdate: (params: AssignBeforeEntryUpdateParams) => void;
|
|
8
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CmsEntry, CmsModel, CmsContext } from "../../../../types";
|
|
2
|
-
|
|
2
|
+
interface MarkLockedFieldsParams {
|
|
3
3
|
model: CmsModel;
|
|
4
4
|
entry: CmsEntry;
|
|
5
5
|
context: CmsContext;
|
|
@@ -10,3 +10,4 @@ export interface MarkFieldsUnlockedParams {
|
|
|
10
10
|
model: CmsModel;
|
|
11
11
|
}
|
|
12
12
|
export declare const markUnlockedFields: (params: MarkFieldsUnlockedParams) => Promise<void>;
|
|
13
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { AfterModelCreateTopicParams, CmsContext } from "../../../../types";
|
|
2
2
|
import { Topic } from "@webiny/pubsub/types";
|
|
3
|
-
|
|
3
|
+
interface AssignAfterModelCreateParams {
|
|
4
4
|
onAfterModelCreate: Topic<AfterModelCreateTopicParams>;
|
|
5
5
|
context: CmsContext;
|
|
6
6
|
}
|
|
7
|
-
export declare const assignAfterModelCreate: (params:
|
|
7
|
+
export declare const assignAfterModelCreate: (params: AssignAfterModelCreateParams) => void;
|
|
8
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { AfterModelDeleteTopicParams, CmsContext } from "../../../../types";
|
|
2
2
|
import { Topic } from "@webiny/pubsub/types";
|
|
3
|
-
|
|
3
|
+
interface AssignAfterModelDeleteParams {
|
|
4
4
|
onAfterModelDelete: Topic<AfterModelDeleteTopicParams>;
|
|
5
5
|
context: CmsContext;
|
|
6
6
|
}
|
|
7
|
-
export declare const assignAfterModelDelete: (params:
|
|
7
|
+
export declare const assignAfterModelDelete: (params: AssignAfterModelDeleteParams) => void;
|
|
8
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { AfterModelUpdateTopicParams, CmsContext } from "../../../../types";
|
|
2
2
|
import { Topic } from "@webiny/pubsub/types";
|
|
3
|
-
|
|
3
|
+
interface AssignAfterModelUpdateParams {
|
|
4
4
|
onAfterModelUpdate: Topic<AfterModelUpdateTopicParams>;
|
|
5
5
|
context: CmsContext;
|
|
6
6
|
}
|
|
7
|
-
export declare const assignAfterModelUpdate: (params:
|
|
7
|
+
export declare const assignAfterModelUpdate: (params: AssignAfterModelUpdateParams) => void;
|
|
8
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BeforeModelCreateTopicParams, HeadlessCmsStorageOperations } from "../../../../types";
|
|
2
2
|
import { Topic } from "@webiny/pubsub/types";
|
|
3
3
|
import { PluginsContainer } from "@webiny/plugins";
|
|
4
|
-
|
|
4
|
+
interface AssignBeforeModelCreateParams {
|
|
5
5
|
onBeforeModelCreate: Topic<BeforeModelCreateTopicParams>;
|
|
6
6
|
onBeforeModelCreateFrom: Topic<BeforeModelCreateTopicParams>;
|
|
7
7
|
storageOperations: HeadlessCmsStorageOperations;
|
|
@@ -11,4 +11,5 @@ export interface Params {
|
|
|
11
11
|
* We attach both on before create and createFrom events here.
|
|
12
12
|
* Callables are identical.
|
|
13
13
|
*/
|
|
14
|
-
export declare const assignBeforeModelCreate: (params:
|
|
14
|
+
export declare const assignBeforeModelCreate: (params: AssignBeforeModelCreateParams) => void;
|
|
15
|
+
export {};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Topic } from "@webiny/pubsub/types";
|
|
2
2
|
import { BeforeModelDeleteTopicParams, HeadlessCmsStorageOperations } from "../../../../types";
|
|
3
3
|
import { PluginsContainer } from "@webiny/plugins";
|
|
4
|
-
|
|
4
|
+
interface AssignBeforeModelDeleteParams {
|
|
5
5
|
onBeforeModelDelete: Topic<BeforeModelDeleteTopicParams>;
|
|
6
6
|
storageOperations: HeadlessCmsStorageOperations;
|
|
7
7
|
plugins: PluginsContainer;
|
|
8
8
|
}
|
|
9
|
-
export declare const assignBeforeModelDelete: (params:
|
|
9
|
+
export declare const assignBeforeModelDelete: (params: AssignBeforeModelDeleteParams) => void;
|
|
10
|
+
export {};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Topic } from "@webiny/pubsub/types";
|
|
2
2
|
import { BeforeModelUpdateTopicParams, HeadlessCmsStorageOperations } from "../../../../types";
|
|
3
3
|
import { PluginsContainer } from "@webiny/plugins";
|
|
4
|
-
|
|
4
|
+
interface AssignBeforeModelUpdateParams {
|
|
5
5
|
onBeforeModelUpdate: Topic<BeforeModelUpdateTopicParams>;
|
|
6
6
|
storageOperations: HeadlessCmsStorageOperations;
|
|
7
7
|
plugins: PluginsContainer;
|
|
8
8
|
}
|
|
9
|
-
export declare const assignBeforeModelUpdate: (params:
|
|
9
|
+
export declare const assignBeforeModelUpdate: (params: AssignBeforeModelUpdateParams) => void;
|
|
10
|
+
export {};
|
|
@@ -7,10 +7,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.assignBeforeModelUpdate = void 0;
|
|
9
9
|
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
13
|
+
|
|
10
14
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
15
|
|
|
12
16
|
var _CmsModelPlugin = require("../../CmsModelPlugin");
|
|
13
17
|
|
|
18
|
+
var _createManageSDL = require("../../schema/createManageSDL");
|
|
19
|
+
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
+
|
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
23
|
+
|
|
14
24
|
const defaultTitleFieldId = "id";
|
|
15
25
|
const allowedTitleFieldTypes = ["text", "number"];
|
|
16
26
|
|
|
@@ -53,6 +63,49 @@ const getContentModelTitleFieldId = (fields, titleFieldId) => {
|
|
|
53
63
|
return target.fieldId;
|
|
54
64
|
};
|
|
55
65
|
|
|
66
|
+
const extractInvalidField = (model, err) => {
|
|
67
|
+
const sdl = err.source.body; // Find the invalid type
|
|
68
|
+
|
|
69
|
+
const {
|
|
70
|
+
line: lineNumber
|
|
71
|
+
} = err.locations[0];
|
|
72
|
+
const sdlLines = sdl.split("\n");
|
|
73
|
+
let sdlLine;
|
|
74
|
+
let gqlType;
|
|
75
|
+
|
|
76
|
+
for (let i = lineNumber; i > 0; i--) {
|
|
77
|
+
if (sdlLine && sdlLine.includes("type ")) {
|
|
78
|
+
gqlType = sdlLine.match(/type\s+(.*?)\s+{/);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
sdlLine = sdlLines[i];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let invalidField;
|
|
86
|
+
|
|
87
|
+
if (Array.isArray(gqlType)) {
|
|
88
|
+
const fieldRegex = new RegExp(`([^\\s+].*?):\\s+\\[?${gqlType[1]}!?\\]?`);
|
|
89
|
+
invalidField = sdl.match(fieldRegex)[1];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let message = `See more details in the browser console.`;
|
|
93
|
+
|
|
94
|
+
if (invalidField) {
|
|
95
|
+
message = `Please review the definition of "${invalidField}" field.`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
data: {
|
|
100
|
+
modelId: model.modelId,
|
|
101
|
+
sdl,
|
|
102
|
+
invalidField
|
|
103
|
+
},
|
|
104
|
+
code: "INVALID_MODEL_DEFINITION",
|
|
105
|
+
message: [`Model "${model.modelId}" was not saved!`, message].join("\n")
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
|
|
56
109
|
const assignBeforeModelUpdate = params => {
|
|
57
110
|
const {
|
|
58
111
|
onBeforeModelUpdate,
|
|
@@ -90,6 +143,22 @@ const assignBeforeModelUpdate = params => {
|
|
|
90
143
|
}
|
|
91
144
|
}
|
|
92
145
|
|
|
146
|
+
if (fields.length) {
|
|
147
|
+
// Make sure that this model can be safely converted to a GraphQL SDL
|
|
148
|
+
const schema = (0, _createManageSDL.createManageSDL)({
|
|
149
|
+
model,
|
|
150
|
+
fieldTypePlugins: fieldTypePlugins.reduce((acc, pl) => _objectSpread(_objectSpread({}, acc), {}, {
|
|
151
|
+
[pl.fieldType]: pl
|
|
152
|
+
}), {})
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
(0, _graphqlTag.default)(schema);
|
|
157
|
+
} catch (err) {
|
|
158
|
+
throw new _error.default(extractInvalidField(model, err));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
93
162
|
model.titleFieldId = getContentModelTitleFieldId(fields, titleFieldId);
|
|
94
163
|
const cmsLockedFieldPlugins = plugins.byType("cms-model-locked-field"); // We must not allow removal or changes in fields that are already in use in content entries.
|
|
95
164
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CmsModel, CmsContext } from "../../../../types";
|
|
2
|
-
export declare const contentModelManagerFactory: (context: CmsContext, model: CmsModel) => Promise<
|
|
1
|
+
import { CmsModel, CmsContext, CmsModelManager } from "../../../../types";
|
|
2
|
+
export declare const contentModelManagerFactory: (context: CmsContext, model: CmsModel) => Promise<CmsModelManager>;
|
|
@@ -17,6 +17,15 @@ var _fields = require("@commodo/fields");
|
|
|
17
17
|
|
|
18
18
|
var _idValidation = _interopRequireDefault(require("./idValidation"));
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Package commodo-fields-object does not have types
|
|
22
|
+
*/
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Package commodo-fields does not have object.
|
|
27
|
+
*/
|
|
28
|
+
// @ts-ignore
|
|
20
29
|
const requiredShortString = _validation.validation.create("required,maxLength:255");
|
|
21
30
|
|
|
22
31
|
const shortString = _validation.validation.create("maxLength:255");
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { BeforeGroupCreateTopicParams, HeadlessCmsStorageOperations } from "../../../../types";
|
|
2
2
|
import { Topic } from "@webiny/pubsub/types";
|
|
3
3
|
import { PluginsContainer } from "@webiny/plugins";
|
|
4
|
-
|
|
4
|
+
interface AssignBeforeGroupCreateParams {
|
|
5
5
|
onBeforeCreate: Topic<BeforeGroupCreateTopicParams>;
|
|
6
6
|
plugins: PluginsContainer;
|
|
7
7
|
storageOperations: HeadlessCmsStorageOperations;
|
|
8
8
|
}
|
|
9
|
-
export declare const assignBeforeGroupCreate: (params:
|
|
9
|
+
export declare const assignBeforeGroupCreate: (params: AssignBeforeGroupCreateParams) => void;
|
|
10
|
+
export {};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Topic } from "@webiny/pubsub/types";
|
|
2
2
|
import { BeforeGroupDeleteTopicParams, HeadlessCmsStorageOperations } from "../../../../types";
|
|
3
3
|
import { PluginsContainer } from "@webiny/plugins";
|
|
4
|
-
|
|
4
|
+
interface AssignBeforeGroupDeleteParams {
|
|
5
5
|
onBeforeDelete: Topic<BeforeGroupDeleteTopicParams>;
|
|
6
6
|
plugins: PluginsContainer;
|
|
7
7
|
storageOperations: HeadlessCmsStorageOperations;
|
|
8
8
|
}
|
|
9
|
-
export declare const assignBeforeGroupDelete: (params:
|
|
9
|
+
export declare const assignBeforeGroupDelete: (params: AssignBeforeGroupDeleteParams) => void;
|
|
10
|
+
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Topic } from "@webiny/pubsub/types";
|
|
2
2
|
import { BeforeGroupUpdateTopicParams } from "../../../../types";
|
|
3
3
|
import { PluginsContainer } from "@webiny/plugins";
|
|
4
|
-
|
|
4
|
+
interface AssignBeforeGroupUpdateParams {
|
|
5
5
|
onBeforeUpdate: Topic<BeforeGroupUpdateTopicParams>;
|
|
6
6
|
plugins: PluginsContainer;
|
|
7
7
|
}
|
|
8
|
-
export declare const assignBeforeGroupUpdate: (params:
|
|
8
|
+
export declare const assignBeforeGroupUpdate: (params: AssignBeforeGroupUpdateParams) => void;
|
|
9
|
+
export {};
|
|
@@ -15,7 +15,9 @@ const fieldGraphQLTypes = {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
const getFieldGraphQLType = field => {
|
|
18
|
-
|
|
18
|
+
var _field$settings;
|
|
19
|
+
|
|
20
|
+
const type = (_field$settings = field.settings) === null || _field$settings === void 0 ? void 0 : _field$settings.type;
|
|
19
21
|
|
|
20
22
|
if (!type || !fieldGraphQLTypes[type]) {
|
|
21
23
|
return "DateTime";
|
|
@@ -17,23 +17,19 @@ var _createTypeName = require("../utils/createTypeName");
|
|
|
17
17
|
|
|
18
18
|
var _requiredField = require("./requiredField");
|
|
19
19
|
|
|
20
|
-
const typeFromField =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
const typeFromField = params => {
|
|
21
|
+
const {
|
|
22
|
+
typeOfType,
|
|
23
|
+
model,
|
|
24
|
+
type,
|
|
25
|
+
field,
|
|
26
|
+
fieldTypePlugins
|
|
27
|
+
} = params;
|
|
27
28
|
const typeSuffix = typeOfType === "input" ? "Input" : "";
|
|
28
29
|
const typeName = (0, _createTypeName.createTypeName)(model.modelId);
|
|
29
30
|
const mTypeName = (0, _createTypeName.createManageTypeName)(typeName); // `field` is an "object" field
|
|
30
31
|
|
|
31
|
-
const fields = field.settings.fields;
|
|
32
|
-
|
|
33
|
-
if (!fields || fields.length === 0) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
|
|
32
|
+
const fields = field.settings.fields || [];
|
|
37
33
|
const fieldTypeName = `${mTypeName}_${(0, _upperFirst.default)(field.fieldId)}`;
|
|
38
34
|
const typeFields = [];
|
|
39
35
|
const nestedTypes = []; // Once the loop below starts, we'll be executing a recursive "object" type generation.
|
|
@@ -53,6 +53,19 @@ const appendTypename = (entries, typename) => {
|
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* We cast settings.models as object to have modelId because internally we know that it is so.
|
|
58
|
+
* Internal stuff so we are sure that settings.models contains what we require.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
const getFieldModels = field => {
|
|
63
|
+
if (!field.settings || Array.isArray(field.settings.models) === false) {
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return field.settings.models;
|
|
68
|
+
};
|
|
56
69
|
|
|
57
70
|
const modelIdToTypeName = new Map();
|
|
58
71
|
const plugin = {
|
|
@@ -83,14 +96,20 @@ const plugin = {
|
|
|
83
96
|
cms
|
|
84
97
|
} = context; // Get field value for this entry
|
|
85
98
|
|
|
86
|
-
const
|
|
99
|
+
const initialValue = parent[field.fieldId];
|
|
87
100
|
|
|
88
|
-
if (!
|
|
101
|
+
if (!initialValue) {
|
|
89
102
|
return null;
|
|
90
103
|
}
|
|
91
104
|
|
|
92
105
|
if (field.multipleValues) {
|
|
93
|
-
|
|
106
|
+
/**
|
|
107
|
+
* We cast because value really can be array and single value.
|
|
108
|
+
* At this point, we are 99% sure that it is an array (+ we check for it)
|
|
109
|
+
*/
|
|
110
|
+
const value = initialValue;
|
|
111
|
+
|
|
112
|
+
if (Array.isArray(value) === false || value.length === 0) {
|
|
94
113
|
return [];
|
|
95
114
|
}
|
|
96
115
|
|
|
@@ -120,8 +139,9 @@ const plugin = {
|
|
|
120
139
|
return appendTypename(entries, modelIdToTypeName.get(modelId));
|
|
121
140
|
});
|
|
122
141
|
return await Promise.all(getters).then(results => results.reduce((result, item) => result.concat(item), []));
|
|
123
|
-
}
|
|
142
|
+
}
|
|
124
143
|
|
|
144
|
+
const value = initialValue; // Get model manager, to get access to CRUD methods
|
|
125
145
|
|
|
126
146
|
const model = await cms.getModelManager(value.modelId);
|
|
127
147
|
let revisions; // `read` API works with `published` data
|
|
@@ -164,7 +184,7 @@ const plugin = {
|
|
|
164
184
|
const unionFieldsTypeDef = unionFields.map(({
|
|
165
185
|
field,
|
|
166
186
|
typeName
|
|
167
|
-
}) => `union ${typeName} = ${field.
|
|
187
|
+
}) => `union ${typeName} = ${getFieldModels(field).map(({
|
|
168
188
|
modelId
|
|
169
189
|
}) => (0, _createTypeName.createReadTypeName)(modelId)).join(" | ")}`).join("\n");
|
|
170
190
|
const filteringTypeDef = `
|
|
@@ -2,7 +2,7 @@ import { AuthenticationPlugin } from "@webiny/api-security/plugins/Authenticatio
|
|
|
2
2
|
import { SecurityIdentity } from "@webiny/api-security/types";
|
|
3
3
|
import { CmsContext } from "../../../types";
|
|
4
4
|
export declare class InternalAuthenticationPlugin extends AuthenticationPlugin {
|
|
5
|
-
private _identityType;
|
|
5
|
+
private readonly _identityType;
|
|
6
6
|
constructor(identityType: string);
|
|
7
7
|
authenticate(context: CmsContext): Promise<undefined | SecurityIdentity>;
|
|
8
8
|
}
|
|
@@ -11,6 +11,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
11
11
|
|
|
12
12
|
var _AuthenticationPlugin = require("@webiny/api-security/plugins/AuthenticationPlugin");
|
|
13
13
|
|
|
14
|
+
// TODO @ts-refactor @pavel
|
|
14
15
|
// @ts-nocheck
|
|
15
16
|
class InternalAuthenticationPlugin extends _AuthenticationPlugin.AuthenticationPlugin {
|
|
16
17
|
constructor(identityType) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AuthorizationPlugin } from "@webiny/api-security/plugins/AuthorizationPlugin";
|
|
2
2
|
import { CmsContext } from "../../../types";
|
|
3
3
|
export declare class InternalAuthorizationPlugin extends AuthorizationPlugin {
|
|
4
|
-
private _identityType;
|
|
4
|
+
private readonly _identityType;
|
|
5
5
|
constructor(identityType: string);
|
|
6
6
|
getPermissions(context: CmsContext): any;
|
|
7
7
|
}
|
|
@@ -11,6 +11,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
11
11
|
|
|
12
12
|
var _AuthorizationPlugin = require("@webiny/api-security/plugins/AuthorizationPlugin");
|
|
13
13
|
|
|
14
|
+
// TODO @ts-refactor @pavel
|
|
14
15
|
// @ts-nocheck
|
|
15
16
|
class InternalAuthorizationPlugin extends _AuthorizationPlugin.AuthorizationPlugin {
|
|
16
17
|
constructor(identityType) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { CmsModelManager, CmsModel, CmsContext, CmsEntryListParams } from "../../../types";
|
|
1
|
+
import { CmsModelManager, CmsModel, CmsContext, CmsEntryListParams, CreateCmsEntryInput, UpdateCmsEntryInput } from "../../../types";
|
|
2
2
|
export declare class DefaultCmsModelManager implements CmsModelManager {
|
|
3
3
|
private readonly _context;
|
|
4
4
|
private readonly _model;
|
|
5
5
|
constructor(context: CmsContext, model: CmsModel);
|
|
6
|
-
create(data:
|
|
6
|
+
create(data: CreateCmsEntryInput): Promise<import("../../../types").CmsEntry>;
|
|
7
7
|
delete(id: string): Promise<void>;
|
|
8
8
|
get(id: string): Promise<import("../../../types").CmsEntry>;
|
|
9
9
|
listPublished(params: CmsEntryListParams): Promise<[import("../../../types").CmsEntry[], import("../../../types").CmsEntryMeta]>;
|
|
10
10
|
listLatest(params: CmsEntryListParams): Promise<[import("../../../types").CmsEntry[], import("../../../types").CmsEntryMeta]>;
|
|
11
11
|
getPublishedByIds(ids: string[]): Promise<import("../../../types").CmsEntry[]>;
|
|
12
12
|
getLatestByIds(ids: string[]): Promise<import("../../../types").CmsEntry[]>;
|
|
13
|
-
update(id:
|
|
13
|
+
update(id: string, data: UpdateCmsEntryInput): Promise<import("../../../types").CmsEntry>;
|
|
14
14
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CmsModelField } from "../../../types";
|
|
1
|
+
import { CmsModelField, ApiEndpoint, CmsModel, CmsFieldTypePlugins } from "../../../types";
|
|
2
2
|
import { Resolvers } from "@webiny/handler-graphql/types";
|
|
3
3
|
interface CreateFieldResolvers {
|
|
4
4
|
graphQLType: string;
|
|
@@ -6,14 +6,15 @@ interface CreateFieldResolvers {
|
|
|
6
6
|
isRoot: boolean;
|
|
7
7
|
extraResolvers?: Resolvers<any>;
|
|
8
8
|
}
|
|
9
|
+
interface CreateFieldResolversFactoryParams {
|
|
10
|
+
endpointType: ApiEndpoint;
|
|
11
|
+
models: CmsModel[];
|
|
12
|
+
model: CmsModel;
|
|
13
|
+
fieldTypePlugins: CmsFieldTypePlugins;
|
|
14
|
+
}
|
|
9
15
|
/**
|
|
10
16
|
* We use a factory to avoid passing the parameters for recursive invocations.
|
|
11
17
|
* This way they will always be in the function scope and we can only pass "fields".
|
|
12
18
|
*/
|
|
13
|
-
export declare
|
|
14
|
-
endpointType: any;
|
|
15
|
-
models: any;
|
|
16
|
-
model: any;
|
|
17
|
-
fieldTypePlugins: any;
|
|
18
|
-
}): (params: CreateFieldResolvers) => {};
|
|
19
|
+
export declare const createFieldResolversFactory: (factoryParams: CreateFieldResolversFactoryParams) => (params: CreateFieldResolvers) => {};
|
|
19
20
|
export {};
|
|
@@ -5,12 +5,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.createFieldResolversFactory =
|
|
8
|
+
exports.createFieldResolversFactory = void 0;
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
12
|
-
var _get = _interopRequireDefault(require("lodash/get"));
|
|
13
|
-
|
|
14
12
|
var _set = _interopRequireDefault(require("lodash/set"));
|
|
15
13
|
|
|
16
14
|
var _entryStorage = require("../utils/entryStorage");
|
|
@@ -19,16 +17,28 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
19
17
|
|
|
20
18
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
19
|
|
|
20
|
+
const getCreateResolver = (plugins, field, endpointType) => {
|
|
21
|
+
if (!plugins[field.type]) {
|
|
22
|
+
return null;
|
|
23
|
+
} else if (!plugins[field.type][endpointType]) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return plugins[field.type][endpointType].createResolver;
|
|
28
|
+
};
|
|
22
29
|
/**
|
|
23
30
|
* We use a factory to avoid passing the parameters for recursive invocations.
|
|
24
31
|
* This way they will always be in the function scope and we can only pass "fields".
|
|
25
32
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
const createFieldResolversFactory = factoryParams => {
|
|
36
|
+
const {
|
|
37
|
+
endpointType,
|
|
38
|
+
models,
|
|
39
|
+
model,
|
|
40
|
+
fieldTypePlugins
|
|
41
|
+
} = factoryParams;
|
|
32
42
|
return function createFieldResolvers(params) {
|
|
33
43
|
const {
|
|
34
44
|
graphQLType,
|
|
@@ -46,7 +56,7 @@ function createFieldResolversFactory({
|
|
|
46
56
|
continue;
|
|
47
57
|
}
|
|
48
58
|
|
|
49
|
-
const createResolver = (
|
|
59
|
+
const createResolver = getCreateResolver(fieldTypePlugins, field, endpointType);
|
|
50
60
|
let resolver;
|
|
51
61
|
const fieldResolver = createResolver ? createResolver({
|
|
52
62
|
graphQLType,
|
|
@@ -71,7 +81,8 @@ function createFieldResolversFactory({
|
|
|
71
81
|
|
|
72
82
|
const {
|
|
73
83
|
fieldId
|
|
74
|
-
} = field;
|
|
84
|
+
} = field; // TODO @ts-refactor figure out types for parameters
|
|
85
|
+
// @ts-ignore
|
|
75
86
|
|
|
76
87
|
fieldResolvers[fieldId] = async (parent, args, context, info) => {
|
|
77
88
|
// Get transformed value (eg. data decompression)
|
|
@@ -95,4 +106,6 @@ function createFieldResolversFactory({
|
|
|
95
106
|
[graphQLType]: fieldResolvers
|
|
96
107
|
}, typeResolvers);
|
|
97
108
|
};
|
|
98
|
-
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
exports.createFieldResolversFactory = createFieldResolversFactory;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { CmsModel, CmsFieldTypePlugins, CmsContext } from "../../../types";
|
|
2
|
+
interface CreateManageResolversParams {
|
|
3
|
+
models: CmsModel[];
|
|
4
|
+
model: CmsModel;
|
|
5
|
+
context: CmsContext;
|
|
6
|
+
fieldTypePlugins: CmsFieldTypePlugins;
|
|
7
|
+
}
|
|
2
8
|
interface CreateManageResolvers {
|
|
3
|
-
(params:
|
|
4
|
-
models: CmsModel[];
|
|
5
|
-
model: CmsModel;
|
|
6
|
-
context: CmsContext;
|
|
7
|
-
fieldTypePlugins: CmsFieldTypePlugins;
|
|
8
|
-
}): any;
|
|
9
|
+
(params: CreateManageResolversParams): any;
|
|
9
10
|
}
|
|
10
11
|
export declare const createManageResolvers: CreateManageResolvers;
|
|
11
12
|
export {};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { CmsFieldTypePlugins, CmsModel } from "../../../types";
|
|
2
|
+
interface CreateManageSDLParams {
|
|
3
|
+
model: CmsModel;
|
|
4
|
+
fieldTypePlugins: CmsFieldTypePlugins;
|
|
5
|
+
}
|
|
2
6
|
interface CreateManageSDL {
|
|
3
|
-
(params:
|
|
4
|
-
model: CmsModel;
|
|
5
|
-
fieldTypePlugins: CmsFieldTypePlugins;
|
|
6
|
-
}): string;
|
|
7
|
+
(params: CreateManageSDLParams): string;
|
|
7
8
|
}
|
|
8
9
|
export declare const createManageSDL: CreateManageSDL;
|
|
9
10
|
export {};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { CmsModel, CmsFieldTypePlugins, CmsContext } from "../../../types";
|
|
2
|
+
interface CreateReadResolversParams {
|
|
3
|
+
models: CmsModel[];
|
|
4
|
+
model: CmsModel;
|
|
5
|
+
context: CmsContext;
|
|
6
|
+
fieldTypePlugins: CmsFieldTypePlugins;
|
|
7
|
+
}
|
|
2
8
|
export interface CreateReadResolvers {
|
|
3
|
-
(params:
|
|
4
|
-
models: CmsModel[];
|
|
5
|
-
model: CmsModel;
|
|
6
|
-
context: CmsContext;
|
|
7
|
-
fieldTypePlugins: CmsFieldTypePlugins;
|
|
8
|
-
}): any;
|
|
9
|
+
(params: CreateReadResolversParams): any;
|
|
9
10
|
}
|
|
10
11
|
export declare const createPreviewResolvers: CreateReadResolvers;
|
|
12
|
+
export {};
|