@webiny/api-headless-cms 5.20.0-beta.2 → 5.22.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/contextSetup.d.ts +1 -1
- package/content/contextSetup.js +2 -2
- package/content/graphQLHandlerFactory.js +13 -7
- package/content/plugins/crud/contentEntry/afterDelete.d.ts +1 -1
- package/content/plugins/crud/contentEntry/afterDelete.js +2 -2
- package/content/plugins/crud/contentEntry/beforeCreate.d.ts +1 -1
- package/content/plugins/crud/contentEntry/beforeCreate.js +2 -2
- package/content/plugins/crud/contentEntry/beforeUpdate.d.ts +1 -1
- package/content/plugins/crud/contentEntry/beforeUpdate.js +2 -2
- package/content/plugins/crud/contentEntry/entryDataValidation.d.ts +8 -2
- package/content/plugins/crud/contentEntry/entryDataValidation.js +16 -6
- package/content/plugins/crud/contentEntry/markLockedFields.js +2 -2
- package/content/plugins/crud/contentEntry/referenceFieldsMapping.js +2 -2
- package/content/plugins/crud/contentEntry.crud.js +163 -77
- package/content/plugins/crud/contentModel/afterCreate.d.ts +1 -1
- package/content/plugins/crud/contentModel/afterCreate.js +2 -2
- package/content/plugins/crud/contentModel/afterDelete.d.ts +1 -1
- package/content/plugins/crud/contentModel/afterDelete.js +2 -2
- package/content/plugins/crud/contentModel/afterUpdate.d.ts +1 -1
- package/content/plugins/crud/contentModel/afterUpdate.js +2 -2
- package/content/plugins/crud/contentModel/beforeCreate.d.ts +2 -2
- package/content/plugins/crud/contentModel/beforeCreate.js +4 -4
- package/content/plugins/crud/contentModel/beforeDelete.d.ts +1 -1
- package/content/plugins/crud/contentModel/beforeDelete.js +2 -2
- package/content/plugins/crud/contentModel/beforeUpdate.d.ts +1 -1
- package/content/plugins/crud/contentModel/beforeUpdate.js +2 -2
- package/content/plugins/crud/contentModel/models.js +2 -1
- package/content/plugins/crud/contentModel.crud.js +52 -67
- package/content/plugins/crud/contentModelGroup.crud.js +2 -2
- package/content/plugins/crud/index.d.ts +1 -1
- package/content/plugins/crud/index.js +4 -4
- package/content/plugins/graphqlFields/boolean.js +4 -2
- package/content/plugins/graphqlFields/datetime.js +4 -1
- package/content/plugins/graphqlFields/file.js +5 -2
- package/content/plugins/graphqlFields/longText.js +4 -2
- package/content/plugins/graphqlFields/number.js +4 -2
- package/content/plugins/graphqlFields/object.js +3 -1
- package/content/plugins/graphqlFields/ref.js +6 -4
- package/content/plugins/graphqlFields/requiredField.d.ts +2 -0
- package/content/plugins/graphqlFields/requiredField.js +24 -0
- package/content/plugins/graphqlFields/richText.js +5 -2
- package/content/plugins/graphqlFields/text.js +4 -2
- package/content/plugins/schema/baseSchema.js +2 -2
- package/content/plugins/schema/contentModelGroups.js +6 -2
- package/content/plugins/schema/contentModels.js +2 -0
- package/content/plugins/schema/createFieldResolvers.js +2 -2
- package/content/plugins/schema/createManageResolvers.js +2 -2
- package/content/plugins/schema/createPreviewResolvers.js +2 -2
- package/content/plugins/schema/createReadResolvers.js +2 -2
- package/content/plugins/schema/resolvers/preview/resolveGet.js +2 -2
- package/content/plugins/schema/resolvers/read/resolveGet.js +2 -2
- package/content/plugins/storage/object.js +7 -2
- package/content/plugins/utils/entryStorage.js +2 -2
- package/content/plugins/validators/index.js +3 -1
- package/content/plugins/validators/unique.d.ts +7 -0
- package/content/plugins/validators/unique.js +62 -0
- package/index.d.ts +3 -3
- package/package.json +31 -31
- package/plugins/context.d.ts +1 -1
- package/plugins/context.js +4 -4
- package/plugins/crud/index.d.ts +1 -1
- package/plugins/crud/index.js +4 -4
- package/plugins/crud/settings.crud.js +2 -2
- package/plugins/crud/system.crud.js +13 -5
- package/types.d.ts +66 -31
- package/types.js +15 -0
package/content/contextSetup.js
CHANGED
|
@@ -9,7 +9,7 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _handler = require("@webiny/handler");
|
|
13
13
|
|
|
14
14
|
const extractHandlerHttpParameters = context => {
|
|
15
15
|
var _context$http, _context$http$request, _context$http$request2;
|
|
@@ -32,7 +32,7 @@ const extractHandlerHttpParameters = context => {
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
var _default = () => {
|
|
35
|
-
return new
|
|
35
|
+
return new _handler.ContextPlugin(async context => {
|
|
36
36
|
var _context$http2, _context$http2$reques;
|
|
37
37
|
|
|
38
38
|
if (((_context$http2 = context.http) === null || _context$http2 === void 0 ? void 0 : (_context$http2$reques = _context$http2.request) === null || _context$http2$reques === void 0 ? void 0 : _context$http2$reques.method) === "OPTIONS") {
|
|
@@ -23,18 +23,26 @@ var _buildSchemaPlugins = _interopRequireDefault(require("./plugins/buildSchemaP
|
|
|
23
23
|
|
|
24
24
|
var _plugins = require("@webiny/handler-graphql/plugins");
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
var _utils = require("@webiny/utils");
|
|
27
27
|
|
|
28
|
-
function
|
|
28
|
+
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; }
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
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; }
|
|
31
|
+
|
|
32
|
+
const DEFAULT_HEADERS = _objectSpread({
|
|
31
33
|
"Access-Control-Allow-Origin": "*",
|
|
32
34
|
"Access-Control-Allow-Headers": "*",
|
|
33
35
|
"Access-Control-Allow-Methods": "OPTIONS,POST",
|
|
34
36
|
"Content-Type": "application/json"
|
|
35
|
-
};
|
|
37
|
+
}, (0, _utils.getWebinyVersionHeaders)());
|
|
38
|
+
|
|
36
39
|
const DEFAULT_CACHE_MAX_AGE = 30758400; // 1 year
|
|
37
40
|
|
|
41
|
+
const OPTIONS_HEADERS = {
|
|
42
|
+
"Access-Control-Max-Age": `${DEFAULT_CACHE_MAX_AGE}`,
|
|
43
|
+
"Cache-Control": `public, max-age=${DEFAULT_CACHE_MAX_AGE}`
|
|
44
|
+
};
|
|
45
|
+
|
|
38
46
|
const respond = (http, result) => {
|
|
39
47
|
return http.response({
|
|
40
48
|
body: JSON.stringify(result),
|
|
@@ -141,9 +149,7 @@ const graphQLHandlerFactory = (options = {}) => {
|
|
|
141
149
|
if (http.request.method === "OPTIONS") {
|
|
142
150
|
return http.response({
|
|
143
151
|
statusCode: 204,
|
|
144
|
-
headers: _objectSpread(_objectSpread({}, DEFAULT_HEADERS),
|
|
145
|
-
"Cache-Control": "public, max-age=" + DEFAULT_CACHE_MAX_AGE
|
|
146
|
-
})
|
|
152
|
+
headers: _objectSpread(_objectSpread({}, DEFAULT_HEADERS), OPTIONS_HEADERS)
|
|
147
153
|
});
|
|
148
154
|
}
|
|
149
155
|
|
|
@@ -2,6 +2,6 @@ import { Topic } from "@webiny/pubsub/types";
|
|
|
2
2
|
import { AfterEntryDeleteTopicParams, CmsContext } from "../../../../types";
|
|
3
3
|
export interface Params {
|
|
4
4
|
context: CmsContext;
|
|
5
|
-
|
|
5
|
+
onAfterEntryDelete: Topic<AfterEntryDeleteTopicParams>;
|
|
6
6
|
}
|
|
7
7
|
export declare const assignAfterEntryDelete: (params: Params) => void;
|
|
@@ -10,9 +10,9 @@ var _markLockedFields = require("./markLockedFields");
|
|
|
10
10
|
const assignAfterEntryDelete = params => {
|
|
11
11
|
const {
|
|
12
12
|
context,
|
|
13
|
-
|
|
13
|
+
onAfterEntryDelete
|
|
14
14
|
} = params;
|
|
15
|
-
|
|
15
|
+
onAfterEntryDelete.subscribe(async params => {
|
|
16
16
|
const {
|
|
17
17
|
entry,
|
|
18
18
|
model
|
|
@@ -2,6 +2,6 @@ import { Topic } from "@webiny/pubsub/types";
|
|
|
2
2
|
import { BeforeEntryCreateTopicParams, CmsContext } from "../../../../types";
|
|
3
3
|
export interface Params {
|
|
4
4
|
context: CmsContext;
|
|
5
|
-
|
|
5
|
+
onBeforeEntryCreate: Topic<BeforeEntryCreateTopicParams>;
|
|
6
6
|
}
|
|
7
7
|
export declare const assignBeforeEntryCreate: (params: Params) => void;
|
|
@@ -10,9 +10,9 @@ var _markLockedFields = require("./markLockedFields");
|
|
|
10
10
|
const assignBeforeEntryCreate = params => {
|
|
11
11
|
const {
|
|
12
12
|
context,
|
|
13
|
-
|
|
13
|
+
onBeforeEntryCreate
|
|
14
14
|
} = params;
|
|
15
|
-
|
|
15
|
+
onBeforeEntryCreate.subscribe(async params => {
|
|
16
16
|
const {
|
|
17
17
|
entry,
|
|
18
18
|
model
|
|
@@ -2,6 +2,6 @@ import { Topic } from "@webiny/pubsub/types";
|
|
|
2
2
|
import { BeforeEntryUpdateTopicParams, CmsContext } from "../../../../types";
|
|
3
3
|
export interface Params {
|
|
4
4
|
context: CmsContext;
|
|
5
|
-
|
|
5
|
+
onBeforeEntryUpdate: Topic<BeforeEntryUpdateTopicParams>;
|
|
6
6
|
}
|
|
7
7
|
export declare const assignBeforeEntryUpdate: (params: Params) => void;
|
|
@@ -10,9 +10,9 @@ var _markLockedFields = require("./markLockedFields");
|
|
|
10
10
|
const assignBeforeEntryUpdate = params => {
|
|
11
11
|
const {
|
|
12
12
|
context,
|
|
13
|
-
|
|
13
|
+
onBeforeEntryUpdate
|
|
14
14
|
} = params;
|
|
15
|
-
|
|
15
|
+
onBeforeEntryUpdate.subscribe(async params => {
|
|
16
16
|
const {
|
|
17
17
|
entry,
|
|
18
18
|
model
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import { CmsModel, CmsContext } from "../../../../types";
|
|
1
|
+
import { CmsModel, CmsContext, CmsEntry } from "../../../../types";
|
|
2
2
|
declare type InputData = Record<string, any>;
|
|
3
|
-
export
|
|
3
|
+
export interface Params {
|
|
4
|
+
context: CmsContext;
|
|
5
|
+
model: CmsModel;
|
|
6
|
+
data: InputData;
|
|
7
|
+
entry?: CmsEntry;
|
|
8
|
+
}
|
|
9
|
+
export declare const validateModelEntryData: (params: Params) => Promise<void>;
|
|
4
10
|
export {};
|
|
@@ -18,7 +18,8 @@ const validateValue = async (args, fieldValidators, value) => {
|
|
|
18
18
|
validatorList,
|
|
19
19
|
context,
|
|
20
20
|
field,
|
|
21
|
-
|
|
21
|
+
model,
|
|
22
|
+
entry
|
|
22
23
|
} = args;
|
|
23
24
|
|
|
24
25
|
try {
|
|
@@ -36,7 +37,8 @@ const validateValue = async (args, fieldValidators, value) => {
|
|
|
36
37
|
context,
|
|
37
38
|
validator: fieldValidator,
|
|
38
39
|
field,
|
|
39
|
-
|
|
40
|
+
model,
|
|
41
|
+
entry
|
|
40
42
|
});
|
|
41
43
|
|
|
42
44
|
if (!result) {
|
|
@@ -139,11 +141,18 @@ const execValidation = async args => {
|
|
|
139
141
|
return await runFieldValueValidations(args);
|
|
140
142
|
};
|
|
141
143
|
|
|
142
|
-
const validateModelEntryData = async
|
|
144
|
+
const validateModelEntryData = async params => {
|
|
145
|
+
const {
|
|
146
|
+
context,
|
|
147
|
+
model,
|
|
148
|
+
entry,
|
|
149
|
+
data
|
|
150
|
+
} = params;
|
|
143
151
|
/**
|
|
144
152
|
* To later simplify searching for the validations we map them to a name.
|
|
145
153
|
* @see CmsModelFieldValidatorPlugin.validator.validate
|
|
146
154
|
*/
|
|
155
|
+
|
|
147
156
|
const validatorList = context.plugins.byType("cms-model-field-validator").reduce((acc, plugin) => {
|
|
148
157
|
const name = plugin.validator.name;
|
|
149
158
|
|
|
@@ -161,13 +170,14 @@ const validateModelEntryData = async (context, contentModel, data) => {
|
|
|
161
170
|
|
|
162
171
|
const invalidFields = [];
|
|
163
172
|
|
|
164
|
-
for (const field of
|
|
173
|
+
for (const field of model.fields) {
|
|
165
174
|
const error = await execValidation({
|
|
166
|
-
|
|
175
|
+
model,
|
|
167
176
|
validatorList,
|
|
168
177
|
field,
|
|
169
178
|
data,
|
|
170
|
-
context
|
|
179
|
+
context,
|
|
180
|
+
entry
|
|
171
181
|
});
|
|
172
182
|
|
|
173
183
|
if (!error) {
|
|
@@ -13,9 +13,9 @@ var _error = _interopRequireDefault(require("@webiny/error"));
|
|
|
13
13
|
|
|
14
14
|
var _CmsModelPlugin = require("../../CmsModelPlugin");
|
|
15
15
|
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
16
|
+
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; }
|
|
17
17
|
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
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; }
|
|
19
19
|
|
|
20
20
|
const markLockedFields = async params => {
|
|
21
21
|
const {
|
|
@@ -15,9 +15,9 @@ var _dotProp = _interopRequireDefault(require("dot-prop"));
|
|
|
15
15
|
|
|
16
16
|
var _utils = require("@webiny/utils");
|
|
17
17
|
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
18
|
+
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; }
|
|
19
19
|
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
20
|
+
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
21
|
|
|
22
22
|
const buildReferenceFieldPaths = params => {
|
|
23
23
|
const {
|