@webiny/api-headless-cms 0.0.0-mt-1
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/LICENSE +21 -0
- package/README.md +73 -0
- package/content/contextSetup.d.ts +4 -0
- package/content/contextSetup.js +65 -0
- package/content/graphQLHandlerFactory.d.ts +5 -0
- package/content/graphQLHandlerFactory.js +173 -0
- package/content/plugins/CmsGroupPlugin.d.ts +11 -0
- package/content/plugins/CmsGroupPlugin.js +24 -0
- package/content/plugins/CmsModelPlugin.d.ts +11 -0
- package/content/plugins/CmsModelPlugin.js +24 -0
- package/content/plugins/buildSchemaPlugins.d.ts +7 -0
- package/content/plugins/buildSchemaPlugins.js +29 -0
- package/content/plugins/crud/contentEntry/afterDelete.d.ts +7 -0
- package/content/plugins/crud/contentEntry/afterDelete.js +41 -0
- package/content/plugins/crud/contentEntry/beforeCreate.d.ts +7 -0
- package/content/plugins/crud/contentEntry/beforeCreate.js +28 -0
- package/content/plugins/crud/contentEntry/beforeUpdate.d.ts +7 -0
- package/content/plugins/crud/contentEntry/beforeUpdate.js +28 -0
- package/content/plugins/crud/contentEntry/entryDataValidation.d.ts +4 -0
- package/content/plugins/crud/contentEntry/entryDataValidation.js +188 -0
- package/content/plugins/crud/contentEntry/markLockedFields.d.ts +12 -0
- package/content/plugins/crud/contentEntry/markLockedFields.js +117 -0
- package/content/plugins/crud/contentEntry.crud.d.ts +17 -0
- package/content/plugins/crud/contentEntry.crud.js +931 -0
- package/content/plugins/crud/contentModel/afterCreate.d.ts +7 -0
- package/content/plugins/crud/contentModel/afterCreate.js +18 -0
- package/content/plugins/crud/contentModel/afterDelete.d.ts +7 -0
- package/content/plugins/crud/contentModel/afterDelete.js +18 -0
- package/content/plugins/crud/contentModel/afterUpdate.d.ts +7 -0
- package/content/plugins/crud/contentModel/afterUpdate.js +18 -0
- package/content/plugins/crud/contentModel/beforeCreate.d.ts +9 -0
- package/content/plugins/crud/contentModel/beforeCreate.js +146 -0
- package/content/plugins/crud/contentModel/beforeDelete.d.ts +9 -0
- package/content/plugins/crud/contentModel/beforeDelete.js +56 -0
- package/content/plugins/crud/contentModel/beforeUpdate.d.ts +9 -0
- package/content/plugins/crud/contentModel/beforeUpdate.js +128 -0
- package/content/plugins/crud/contentModel/contentModelManagerFactory.d.ts +2 -0
- package/content/plugins/crud/contentModel/contentModelManagerFactory.js +29 -0
- package/content/plugins/crud/contentModel/createFieldModels.d.ts +2 -0
- package/content/plugins/crud/contentModel/createFieldModels.js +22 -0
- package/content/plugins/crud/contentModel/idValidation.d.ts +2 -0
- package/content/plugins/crud/contentModel/idValidation.js +22 -0
- package/content/plugins/crud/contentModel/models.d.ts +3 -0
- package/content/plugins/crud/contentModel/models.js +141 -0
- package/content/plugins/crud/contentModel/validateLayout.d.ts +2 -0
- package/content/plugins/crud/contentModel/validateLayout.js +38 -0
- package/content/plugins/crud/contentModel.crud.d.ts +12 -0
- package/content/plugins/crud/contentModel.crud.js +425 -0
- package/content/plugins/crud/contentModelGroup/beforeCreate.d.ts +9 -0
- package/content/plugins/crud/contentModelGroup/beforeCreate.js +66 -0
- package/content/plugins/crud/contentModelGroup/beforeDelete.d.ts +9 -0
- package/content/plugins/crud/contentModelGroup/beforeDelete.js +48 -0
- package/content/plugins/crud/contentModelGroup/beforeUpdate.d.ts +8 -0
- package/content/plugins/crud/contentModelGroup/beforeUpdate.js +28 -0
- package/content/plugins/crud/contentModelGroup.crud.d.ts +12 -0
- package/content/plugins/crud/contentModelGroup.crud.js +351 -0
- package/content/plugins/crud/index.d.ts +6 -0
- package/content/plugins/crud/index.js +100 -0
- package/content/plugins/graphqlFields/boolean.d.ts +3 -0
- package/content/plugins/graphqlFields/boolean.js +69 -0
- package/content/plugins/graphqlFields/datetime.d.ts +3 -0
- package/content/plugins/graphqlFields/datetime.js +83 -0
- package/content/plugins/graphqlFields/file.d.ts +3 -0
- package/content/plugins/graphqlFields/file.js +49 -0
- package/content/plugins/graphqlFields/index.d.ts +2 -0
- package/content/plugins/graphqlFields/index.js +30 -0
- package/content/plugins/graphqlFields/longText.d.ts +3 -0
- package/content/plugins/graphqlFields/longText.js +62 -0
- package/content/plugins/graphqlFields/number.d.ts +3 -0
- package/content/plugins/graphqlFields/number.js +75 -0
- package/content/plugins/graphqlFields/object.d.ts +3 -0
- package/content/plugins/graphqlFields/object.js +180 -0
- package/content/plugins/graphqlFields/ref.d.ts +3 -0
- package/content/plugins/graphqlFields/ref.js +205 -0
- package/content/plugins/graphqlFields/richText.d.ts +3 -0
- package/content/plugins/graphqlFields/richText.js +55 -0
- package/content/plugins/graphqlFields/text.d.ts +3 -0
- package/content/plugins/graphqlFields/text.js +72 -0
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.d.ts +8 -0
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js +54 -0
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.d.ts +7 -0
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js +35 -0
- package/content/plugins/modelManager/DefaultCmsModelManager.d.ts +15 -0
- package/content/plugins/modelManager/DefaultCmsModelManager.js +62 -0
- package/content/plugins/modelManager/index.d.ts +3 -0
- package/content/plugins/modelManager/index.js +20 -0
- package/content/plugins/schema/baseSchema.d.ts +4 -0
- package/content/plugins/schema/baseSchema.js +98 -0
- package/content/plugins/schema/contentEntries.d.ts +4 -0
- package/content/plugins/schema/contentEntries.js +166 -0
- package/content/plugins/schema/contentModelGroups.d.ts +4 -0
- package/content/plugins/schema/contentModelGroups.js +153 -0
- package/content/plugins/schema/contentModels.d.ts +4 -0
- package/content/plugins/schema/contentModels.js +225 -0
- package/content/plugins/schema/createFieldResolvers.d.ts +19 -0
- package/content/plugins/schema/createFieldResolvers.js +92 -0
- package/content/plugins/schema/createManageResolvers.d.ts +11 -0
- package/content/plugins/schema/createManageResolvers.js +135 -0
- package/content/plugins/schema/createManageSDL.d.ts +9 -0
- package/content/plugins/schema/createManageSDL.js +153 -0
- package/content/plugins/schema/createPreviewResolvers.d.ts +10 -0
- package/content/plugins/schema/createPreviewResolvers.js +55 -0
- package/content/plugins/schema/createReadResolvers.d.ts +10 -0
- package/content/plugins/schema/createReadResolvers.js +55 -0
- package/content/plugins/schema/createReadSDL.d.ts +9 -0
- package/content/plugins/schema/createReadSDL.js +96 -0
- package/content/plugins/schema/resolvers/commonFieldResolvers.d.ts +6 -0
- package/content/plugins/schema/resolvers/commonFieldResolvers.js +14 -0
- package/content/plugins/schema/resolvers/manage/resolveCreate.d.ts +6 -0
- package/content/plugins/schema/resolvers/manage/resolveCreate.js +23 -0
- package/content/plugins/schema/resolvers/manage/resolveCreateFrom.d.ts +7 -0
- package/content/plugins/schema/resolvers/manage/resolveCreateFrom.js +23 -0
- package/content/plugins/schema/resolvers/manage/resolveDelete.d.ts +2 -0
- package/content/plugins/schema/resolvers/manage/resolveDelete.js +30 -0
- package/content/plugins/schema/resolvers/manage/resolveGet.d.ts +2 -0
- package/content/plugins/schema/resolvers/manage/resolveGet.js +21 -0
- package/content/plugins/schema/resolvers/manage/resolveGetByIds.d.ts +2 -0
- package/content/plugins/schema/resolvers/manage/resolveGetByIds.js +23 -0
- package/content/plugins/schema/resolvers/manage/resolveGetRevisions.d.ts +2 -0
- package/content/plugins/schema/resolvers/manage/resolveGetRevisions.js +23 -0
- package/content/plugins/schema/resolvers/manage/resolveList.d.ts +2 -0
- package/content/plugins/schema/resolvers/manage/resolveList.js +23 -0
- package/content/plugins/schema/resolvers/manage/resolvePublish.d.ts +2 -0
- package/content/plugins/schema/resolvers/manage/resolvePublish.js +21 -0
- package/content/plugins/schema/resolvers/manage/resolveRequestChanges.d.ts +6 -0
- package/content/plugins/schema/resolvers/manage/resolveRequestChanges.js +23 -0
- package/content/plugins/schema/resolvers/manage/resolveRequestReview.d.ts +6 -0
- package/content/plugins/schema/resolvers/manage/resolveRequestReview.js +23 -0
- package/content/plugins/schema/resolvers/manage/resolveUnpublish.d.ts +2 -0
- package/content/plugins/schema/resolvers/manage/resolveUnpublish.js +21 -0
- package/content/plugins/schema/resolvers/manage/resolveUpdate.d.ts +7 -0
- package/content/plugins/schema/resolvers/manage/resolveUpdate.js +23 -0
- package/content/plugins/schema/resolvers/preview/resolveGet.d.ts +2 -0
- package/content/plugins/schema/resolvers/preview/resolveGet.js +38 -0
- package/content/plugins/schema/resolvers/preview/resolveList.d.ts +2 -0
- package/content/plugins/schema/resolvers/preview/resolveList.js +23 -0
- package/content/plugins/schema/resolvers/read/resolveGet.d.ts +2 -0
- package/content/plugins/schema/resolvers/read/resolveGet.js +38 -0
- package/content/plugins/schema/resolvers/read/resolveList.d.ts +2 -0
- package/content/plugins/schema/resolvers/read/resolveList.js +23 -0
- package/content/plugins/schema/schemaPlugins.d.ts +3 -0
- package/content/plugins/schema/schemaPlugins.js +92 -0
- package/content/plugins/storage/StorageTransformPlugin.d.ts +30 -0
- package/content/plugins/storage/StorageTransformPlugin.js +36 -0
- package/content/plugins/storage/default.d.ts +3 -0
- package/content/plugins/storage/default.js +28 -0
- package/content/plugins/storage/object.d.ts +3 -0
- package/content/plugins/storage/object.js +119 -0
- package/content/plugins/utils/createTypeName.d.ts +3 -0
- package/content/plugins/utils/createTypeName.js +28 -0
- package/content/plugins/utils/entryStorage.d.ts +17 -0
- package/content/plugins/utils/entryStorage.js +125 -0
- package/content/plugins/utils/getEntryTitle.d.ts +2 -0
- package/content/plugins/utils/getEntryTitle.js +42 -0
- package/content/plugins/utils/getSchemaFromFieldPlugins.d.ts +11 -0
- package/content/plugins/utils/getSchemaFromFieldPlugins.js +30 -0
- package/content/plugins/utils/pluralizedTypeName.d.ts +1 -0
- package/content/plugins/utils/pluralizedTypeName.js +26 -0
- package/content/plugins/utils/renderFields.d.ts +16 -0
- package/content/plugins/utils/renderFields.js +51 -0
- package/content/plugins/utils/renderGetFilterFields.d.ts +9 -0
- package/content/plugins/utils/renderGetFilterFields.js +41 -0
- package/content/plugins/utils/renderInputFields.d.ts +14 -0
- package/content/plugins/utils/renderInputFields.js +53 -0
- package/content/plugins/utils/renderListFilterFields.d.ts +10 -0
- package/content/plugins/utils/renderListFilterFields.js +39 -0
- package/content/plugins/utils/renderSortEnum.d.ts +9 -0
- package/content/plugins/utils/renderSortEnum.js +32 -0
- package/content/plugins/validators/dateGte.d.ts +3 -0
- package/content/plugins/validators/dateGte.js +37 -0
- package/content/plugins/validators/dateLte.d.ts +3 -0
- package/content/plugins/validators/dateLte.js +37 -0
- package/content/plugins/validators/gte.d.ts +3 -0
- package/content/plugins/validators/gte.js +32 -0
- package/content/plugins/validators/in.d.ts +3 -0
- package/content/plugins/validators/in.js +32 -0
- package/content/plugins/validators/index.d.ts +2 -0
- package/content/plugins/validators/index.js +36 -0
- package/content/plugins/validators/lte.d.ts +3 -0
- package/content/plugins/validators/lte.js +32 -0
- package/content/plugins/validators/maxLength.d.ts +3 -0
- package/content/plugins/validators/maxLength.js +32 -0
- package/content/plugins/validators/minLength.d.ts +3 -0
- package/content/plugins/validators/minLength.js +32 -0
- package/content/plugins/validators/pattern.d.ts +3 -0
- package/content/plugins/validators/pattern.js +47 -0
- package/content/plugins/validators/patternPlugins/email.d.ts +3 -0
- package/content/plugins/validators/patternPlugins/email.js +17 -0
- package/content/plugins/validators/patternPlugins/index.d.ts +2 -0
- package/content/plugins/validators/patternPlugins/index.js +19 -0
- package/content/plugins/validators/patternPlugins/lowerCase.d.ts +3 -0
- package/content/plugins/validators/patternPlugins/lowerCase.js +17 -0
- package/content/plugins/validators/patternPlugins/upperCase.d.ts +3 -0
- package/content/plugins/validators/patternPlugins/upperCase.js +17 -0
- package/content/plugins/validators/patternPlugins/url.d.ts +3 -0
- package/content/plugins/validators/patternPlugins/url.js +17 -0
- package/content/plugins/validators/required.d.ts +3 -0
- package/content/plugins/validators/required.js +25 -0
- package/content/plugins/validators/timeGte.d.ts +3 -0
- package/content/plugins/validators/timeGte.js +32 -0
- package/content/plugins/validators/timeLte.d.ts +3 -0
- package/content/plugins/validators/timeLte.js +32 -0
- package/index.d.ts +12 -0
- package/index.js +66 -0
- package/migrateCMSPermissions.d.ts +17 -0
- package/migrateCMSPermissions.js +193 -0
- package/package.json +80 -0
- package/plugins/context.d.ts +4 -0
- package/plugins/context.js +34 -0
- package/plugins/crud/index.d.ts +6 -0
- package/plugins/crud/index.js +100 -0
- package/plugins/crud/settings.crud.d.ts +10 -0
- package/plugins/crud/settings.crud.js +93 -0
- package/plugins/crud/system.crud.d.ts +10 -0
- package/plugins/crud/system.crud.js +182 -0
- package/plugins/graphql/system.d.ts +17 -0
- package/plugins/graphql/system.js +72 -0
- package/plugins/graphql.d.ts +2 -0
- package/plugins/graphql.js +79 -0
- package/plugins/upgrades/index.d.ts +2 -0
- package/plugins/upgrades/index.js +14 -0
- package/plugins/upgrades/v5.5.0/helpers.d.ts +6 -0
- package/plugins/upgrades/v5.5.0/helpers.js +10 -0
- package/plugins/upgrades/v5.5.0/index.d.ts +4 -0
- package/plugins/upgrades/v5.5.0/index.js +129 -0
- package/transformers.d.ts +2 -0
- package/transformers.js +25 -0
- package/types.d.ts +2149 -0
- package/types.js +366 -0
- package/utils.d.ts +25 -0
- package/utils.js +251 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AuthenticationPlugin } from "@webiny/api-security/plugins/AuthenticationPlugin";
|
|
2
|
+
import { SecurityIdentity } from "@webiny/api-security/types";
|
|
3
|
+
import { CmsContext } from "../../../types";
|
|
4
|
+
export declare class InternalAuthenticationPlugin extends AuthenticationPlugin {
|
|
5
|
+
private _identityType;
|
|
6
|
+
constructor(identityType: string);
|
|
7
|
+
authenticate(context: CmsContext): Promise<undefined | SecurityIdentity>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.InternalAuthenticationPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _AuthenticationPlugin = require("@webiny/api-security/plugins/AuthenticationPlugin");
|
|
13
|
+
|
|
14
|
+
// @ts-nocheck
|
|
15
|
+
class InternalAuthenticationPlugin extends _AuthenticationPlugin.AuthenticationPlugin {
|
|
16
|
+
constructor(identityType) {
|
|
17
|
+
super();
|
|
18
|
+
(0, _defineProperty2.default)(this, "_identityType", void 0);
|
|
19
|
+
this._identityType = identityType;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async authenticate(context) {
|
|
23
|
+
const {
|
|
24
|
+
headers
|
|
25
|
+
} = context.http.request;
|
|
26
|
+
const header = headers["Authorization"] || headers["authorization"];
|
|
27
|
+
const apiKey = header ? header.split(" ").pop() : null;
|
|
28
|
+
|
|
29
|
+
if (!apiKey || apiKey !== (await context.cms.getReadAPIKey())) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* This is an internal identity, which has access to `read` endpoint, all content models,
|
|
34
|
+
* content entries, and all content locales.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
id: "read-api-key",
|
|
40
|
+
displayName: "Read API key",
|
|
41
|
+
type: this._identityType,
|
|
42
|
+
permissions: [{
|
|
43
|
+
name: "cms.endpoint.read"
|
|
44
|
+
}, {
|
|
45
|
+
name: "cms.content*"
|
|
46
|
+
}, {
|
|
47
|
+
name: "content.i18n"
|
|
48
|
+
}]
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
exports.InternalAuthenticationPlugin = InternalAuthenticationPlugin;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AuthorizationPlugin } from "@webiny/api-security/plugins/AuthorizationPlugin";
|
|
2
|
+
import { CmsContext } from "../../../types";
|
|
3
|
+
export declare class InternalAuthorizationPlugin extends AuthorizationPlugin {
|
|
4
|
+
private _identityType;
|
|
5
|
+
constructor(identityType: string);
|
|
6
|
+
getPermissions(context: CmsContext): any;
|
|
7
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.InternalAuthorizationPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _AuthorizationPlugin = require("@webiny/api-security/plugins/AuthorizationPlugin");
|
|
13
|
+
|
|
14
|
+
// @ts-nocheck
|
|
15
|
+
class InternalAuthorizationPlugin extends _AuthorizationPlugin.AuthorizationPlugin {
|
|
16
|
+
constructor(identityType) {
|
|
17
|
+
super();
|
|
18
|
+
(0, _defineProperty2.default)(this, "_identityType", void 0);
|
|
19
|
+
this._identityType = identityType;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getPermissions(context) {
|
|
23
|
+
const identity = context.security.getIdentity();
|
|
24
|
+
|
|
25
|
+
if (!identity || identity.type !== this._identityType) {
|
|
26
|
+
return;
|
|
27
|
+
} // Return permissions we defined in the authentication plugin.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
return identity.permissions;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exports.InternalAuthorizationPlugin = InternalAuthorizationPlugin;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CmsModelManager, CmsModel, CmsContext } from "../../../types";
|
|
2
|
+
export declare class DefaultCmsModelManager implements CmsModelManager {
|
|
3
|
+
private readonly _context;
|
|
4
|
+
private readonly _model;
|
|
5
|
+
constructor(context: CmsContext, model: CmsModel);
|
|
6
|
+
create(data: any): Promise<import("../../../types").CmsEntry>;
|
|
7
|
+
delete(id: string): Promise<void>;
|
|
8
|
+
get(id: string): Promise<import("../../../types").CmsEntry>;
|
|
9
|
+
list(args: any): Promise<[import("../../../types").CmsEntry[], import("../../../types").CmsEntryMeta]>;
|
|
10
|
+
listPublished(args: any): Promise<[import("../../../types").CmsEntry[], import("../../../types").CmsEntryMeta]>;
|
|
11
|
+
listLatest(args: any): Promise<[import("../../../types").CmsEntry[], import("../../../types").CmsEntryMeta]>;
|
|
12
|
+
getPublishedByIds(ids: string[]): Promise<import("../../../types").CmsEntry[]>;
|
|
13
|
+
getLatestByIds(ids: string[]): Promise<import("../../../types").CmsEntry[]>;
|
|
14
|
+
update(id: any, data: any): Promise<import("../../../types").CmsEntry>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.DefaultCmsModelManager = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
class DefaultCmsModelManager {
|
|
13
|
+
constructor(context, model) {
|
|
14
|
+
(0, _defineProperty2.default)(this, "_context", void 0);
|
|
15
|
+
(0, _defineProperty2.default)(this, "_model", void 0);
|
|
16
|
+
this._context = context;
|
|
17
|
+
this._model = model;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async create(data) {
|
|
21
|
+
return this._context.cms.createEntry(this._model, data);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async delete(id) {
|
|
25
|
+
if (id.includes("#")) {
|
|
26
|
+
return this._context.cms.deleteEntryRevision(this._model, id);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return this._context.cms.deleteEntry(this._model, id);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async get(id) {
|
|
33
|
+
return this._context.cms.getEntryById(this._model, id);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async list(args) {
|
|
37
|
+
return this._context.cms.listEntries(this._model, args);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async listPublished(args) {
|
|
41
|
+
return this._context.cms.listPublishedEntries(this._model, args);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async listLatest(args) {
|
|
45
|
+
return this._context.cms.listLatestEntries(this._model, args);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async getPublishedByIds(ids) {
|
|
49
|
+
return this._context.cms.getPublishedEntriesByIds(this._model, ids);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async getLatestByIds(ids) {
|
|
53
|
+
return this._context.cms.getLatestEntriesByIds(this._model, ids);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async update(id, data) {
|
|
57
|
+
return this._context.cms.updateEntry(this._model, id, data);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
exports.DefaultCmsModelManager = DefaultCmsModelManager;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _DefaultCmsModelManager = require("./DefaultCmsModelManager");
|
|
9
|
+
|
|
10
|
+
const plugin = {
|
|
11
|
+
type: "cms-content-model-manager",
|
|
12
|
+
name: "content-model-manager-default",
|
|
13
|
+
create: async (context, model) => {
|
|
14
|
+
return new _DefaultCmsModelManager.DefaultCmsModelManager(context, model);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
var _default = () => plugin;
|
|
19
|
+
|
|
20
|
+
exports.default = _default;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _builtInTypes = require("@webiny/handler-graphql/builtInTypes");
|
|
13
|
+
|
|
14
|
+
var _GraphQLSchemaPlugin = require("@webiny/handler-graphql/plugins/GraphQLSchemaPlugin");
|
|
15
|
+
|
|
16
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
+
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
19
|
+
|
|
20
|
+
const baseSchema = context => {
|
|
21
|
+
const scalars = context.plugins.byType("graphql-scalar").map(item => item.scalar);
|
|
22
|
+
return new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
|
|
23
|
+
typeDefs:
|
|
24
|
+
/* GraphQL */
|
|
25
|
+
`
|
|
26
|
+
${scalars.map(scalar => `scalar ${scalar.name}`).join(" ")}
|
|
27
|
+
scalar JSON
|
|
28
|
+
scalar Long
|
|
29
|
+
scalar RefInput
|
|
30
|
+
scalar Number
|
|
31
|
+
scalar Any
|
|
32
|
+
scalar Date
|
|
33
|
+
scalar DateTime
|
|
34
|
+
scalar DateTimeZ
|
|
35
|
+
scalar Time
|
|
36
|
+
|
|
37
|
+
type Query
|
|
38
|
+
|
|
39
|
+
type Mutation {
|
|
40
|
+
_empty: String
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type CmsError {
|
|
44
|
+
code: String
|
|
45
|
+
message: String
|
|
46
|
+
data: JSON
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
type CmsListMeta {
|
|
50
|
+
cursor: String
|
|
51
|
+
hasMoreItems: Boolean
|
|
52
|
+
totalCount: Int
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
type CmsDeleteResponse {
|
|
56
|
+
data: Boolean
|
|
57
|
+
error: CmsError
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
type CmsBooleanResponse {
|
|
61
|
+
data: Boolean
|
|
62
|
+
error: CmsError
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
type CmsCreatedBy {
|
|
66
|
+
id: String
|
|
67
|
+
displayName: String
|
|
68
|
+
type: String
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
type CmsOwnedBy {
|
|
72
|
+
id: String
|
|
73
|
+
displayName: String
|
|
74
|
+
type: String
|
|
75
|
+
}
|
|
76
|
+
`,
|
|
77
|
+
resolvers: _objectSpread(_objectSpread({}, scalars.reduce((acc, s) => {
|
|
78
|
+
acc[s.name] = s;
|
|
79
|
+
return acc;
|
|
80
|
+
}, {})), {}, {
|
|
81
|
+
JSON: _builtInTypes.JsonScalar,
|
|
82
|
+
Long: _builtInTypes.LongScalar,
|
|
83
|
+
RefInput: _builtInTypes.RefInput,
|
|
84
|
+
Number: _builtInTypes.Number,
|
|
85
|
+
Any: _builtInTypes.Any,
|
|
86
|
+
DateTime: _builtInTypes.DateTimeScalar,
|
|
87
|
+
DateTimeZ: _builtInTypes.DateTimeZScalar,
|
|
88
|
+
Date: _builtInTypes.DateScalar,
|
|
89
|
+
Time: _builtInTypes.TimeScalar,
|
|
90
|
+
Mutation: {
|
|
91
|
+
_empty: () => "_empty"
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
var _default = baseSchema;
|
|
98
|
+
exports.default = _default;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
9
|
+
|
|
10
|
+
var _apiSecurity = require("@webiny/api-security");
|
|
11
|
+
|
|
12
|
+
var _GraphQLSchemaPlugin = require("@webiny/handler-graphql/plugins/GraphQLSchemaPlugin");
|
|
13
|
+
|
|
14
|
+
var _getEntryTitle = require("../utils/getEntryTitle");
|
|
15
|
+
|
|
16
|
+
const plugin = context => {
|
|
17
|
+
if (!context.cms.MANAGE) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
|
|
22
|
+
typeDefs:
|
|
23
|
+
/* GraphQL */
|
|
24
|
+
`
|
|
25
|
+
type CmsModelMeta {
|
|
26
|
+
modelId: String
|
|
27
|
+
name: String
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type CmsContentEntry {
|
|
31
|
+
id: ID
|
|
32
|
+
model: CmsModelMeta
|
|
33
|
+
status: String
|
|
34
|
+
title: String
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type CmsContentEntriesResponse {
|
|
38
|
+
data: [CmsContentEntry]
|
|
39
|
+
error: CmsError
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type CmsContentEntryResponse {
|
|
43
|
+
data: CmsContentEntry
|
|
44
|
+
error: CmsError
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
input CmsModelEntryInput {
|
|
48
|
+
modelId: ID!
|
|
49
|
+
entryId: ID!
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
extend type Query {
|
|
53
|
+
# Search content entries for given content models using the query string.
|
|
54
|
+
searchContentEntries(
|
|
55
|
+
modelIds: [ID!]!
|
|
56
|
+
query: String!
|
|
57
|
+
limit: Int
|
|
58
|
+
): CmsContentEntriesResponse
|
|
59
|
+
|
|
60
|
+
# Get content entry meta data
|
|
61
|
+
getContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse
|
|
62
|
+
|
|
63
|
+
# Get content entries meta data
|
|
64
|
+
getContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse
|
|
65
|
+
}
|
|
66
|
+
`,
|
|
67
|
+
resolvers: {
|
|
68
|
+
Query: {
|
|
69
|
+
async searchContentEntries(_, args, context) {
|
|
70
|
+
const {
|
|
71
|
+
modelIds,
|
|
72
|
+
query,
|
|
73
|
+
limit = 10
|
|
74
|
+
} = args;
|
|
75
|
+
const models = await context.cms.listModels();
|
|
76
|
+
const getters = models.filter(model => modelIds.includes(model.modelId)).map(async model => {
|
|
77
|
+
const latest = query === "__latest__";
|
|
78
|
+
const modelManager = await context.cms.getModelManager(model.modelId);
|
|
79
|
+
const [items] = await modelManager.listLatest({
|
|
80
|
+
limit,
|
|
81
|
+
where: latest ? undefined : {
|
|
82
|
+
[`${model.titleFieldId}_contains`]: query
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return items.map(entry => ({
|
|
86
|
+
id: entry.id,
|
|
87
|
+
model: {
|
|
88
|
+
modelId: model.modelId,
|
|
89
|
+
name: model.name
|
|
90
|
+
},
|
|
91
|
+
status: entry.status,
|
|
92
|
+
title: (0, _getEntryTitle.getEntryTitle)(model, entry),
|
|
93
|
+
// We need `savedOn` to sort entries from latest to oldest
|
|
94
|
+
savedOn: entry.savedOn
|
|
95
|
+
}));
|
|
96
|
+
});
|
|
97
|
+
const entries = await Promise.all(getters).then(results => results.reduce((result, item) => result.concat(item), []));
|
|
98
|
+
return new _handlerGraphql.Response(entries.sort((a, b) => Date.parse(b.savedOn) - Date.parse(a.savedOn)).slice(0, limit));
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
async getContentEntry(_, args, context) {
|
|
102
|
+
const {
|
|
103
|
+
modelId,
|
|
104
|
+
entryId
|
|
105
|
+
} = args.entry;
|
|
106
|
+
const models = await context.cms.listModels();
|
|
107
|
+
const model = models.find(m => m.modelId === modelId);
|
|
108
|
+
|
|
109
|
+
if (!model) {
|
|
110
|
+
return new _apiSecurity.NotAuthorizedResponse({
|
|
111
|
+
data: {
|
|
112
|
+
modelId
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const [entry] = await context.cms.getEntriesByIds(model, [entryId]);
|
|
118
|
+
return new _handlerGraphql.Response({
|
|
119
|
+
id: entry.id,
|
|
120
|
+
model: {
|
|
121
|
+
modelId: model.modelId,
|
|
122
|
+
name: model.name
|
|
123
|
+
},
|
|
124
|
+
status: entry.status,
|
|
125
|
+
title: (0, _getEntryTitle.getEntryTitle)(model, entry)
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
async getContentEntries(_, args, context) {
|
|
130
|
+
const models = await context.cms.listModels();
|
|
131
|
+
const entriesByModel = args.entries.map((ref, index) => {
|
|
132
|
+
return {
|
|
133
|
+
entryId: ref.entryId,
|
|
134
|
+
modelId: ref.modelId,
|
|
135
|
+
index
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
const getters = entriesByModel.map(async ({
|
|
139
|
+
modelId,
|
|
140
|
+
entryId
|
|
141
|
+
}) => {
|
|
142
|
+
// Get model manager, to get access to CRUD methods
|
|
143
|
+
const model = models.find(m => m.modelId === modelId);
|
|
144
|
+
const entries = await context.cms.getEntriesByIds(model, [entryId]);
|
|
145
|
+
return entries.map(entry => ({
|
|
146
|
+
id: entry.id,
|
|
147
|
+
model: {
|
|
148
|
+
modelId: model.modelId,
|
|
149
|
+
name: model.name
|
|
150
|
+
},
|
|
151
|
+
status: entry.status,
|
|
152
|
+
title: (0, _getEntryTitle.getEntryTitle)(model, entry)
|
|
153
|
+
}));
|
|
154
|
+
});
|
|
155
|
+
return new _handlerGraphql.Response(await Promise.all(getters).then(results => {
|
|
156
|
+
return results.reduce((result, item) => result.concat(item), []);
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
var _default = plugin;
|
|
166
|
+
exports.default = _default;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
9
|
+
|
|
10
|
+
var _GraphQLSchemaPlugin = require("@webiny/handler-graphql/plugins/GraphQLSchemaPlugin");
|
|
11
|
+
|
|
12
|
+
var _CmsGroupPlugin = require("../CmsGroupPlugin");
|
|
13
|
+
|
|
14
|
+
const plugin = context => {
|
|
15
|
+
let manageSchema = "";
|
|
16
|
+
|
|
17
|
+
if (context.cms.MANAGE) {
|
|
18
|
+
manageSchema =
|
|
19
|
+
/* GraphQL */
|
|
20
|
+
`
|
|
21
|
+
input CmsContentModelGroupInput {
|
|
22
|
+
name: String!
|
|
23
|
+
slug: String
|
|
24
|
+
description: String
|
|
25
|
+
icon: String!
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
type CmsContentModelGroupResponse {
|
|
29
|
+
data: CmsContentModelGroup
|
|
30
|
+
error: CmsError
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type CmsContentModelGroupListResponse {
|
|
34
|
+
data: [CmsContentModelGroup]
|
|
35
|
+
meta: CmsListMeta
|
|
36
|
+
error: CmsError
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
extend type Query {
|
|
40
|
+
getContentModelGroup(id: ID): CmsContentModelGroupResponse
|
|
41
|
+
listContentModelGroups: CmsContentModelGroupListResponse
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
extend type Mutation {
|
|
45
|
+
createContentModelGroup(
|
|
46
|
+
data: CmsContentModelGroupInput!
|
|
47
|
+
): CmsContentModelGroupResponse
|
|
48
|
+
|
|
49
|
+
updateContentModelGroup(
|
|
50
|
+
id: ID!
|
|
51
|
+
data: CmsContentModelGroupInput!
|
|
52
|
+
): CmsContentModelGroupResponse
|
|
53
|
+
|
|
54
|
+
deleteContentModelGroup(id: ID!): CmsDeleteResponse
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let resolvers = {};
|
|
60
|
+
|
|
61
|
+
if (context.cms.MANAGE) {
|
|
62
|
+
resolvers = {
|
|
63
|
+
CmsContentModelGroup: {
|
|
64
|
+
contentModels: async (group, _, context) => {
|
|
65
|
+
const models = await context.cms.silentAuthModel().list();
|
|
66
|
+
return models.filter(m => m.group.id === group.id);
|
|
67
|
+
},
|
|
68
|
+
totalContentModels: async (group, _, context) => {
|
|
69
|
+
const models = await context.cms.silentAuthModel().list();
|
|
70
|
+
return models.filter(m => m.group === group.id).length;
|
|
71
|
+
},
|
|
72
|
+
plugin: async (group, _, context) => {
|
|
73
|
+
const groupPlugin = context.plugins.byType(_CmsGroupPlugin.CmsGroupPlugin.type).find(item => item.contentModelGroup.id === group.id);
|
|
74
|
+
return Boolean(groupPlugin);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
Query: {
|
|
78
|
+
getContentModelGroup: async (_, args, context) => {
|
|
79
|
+
try {
|
|
80
|
+
const {
|
|
81
|
+
id
|
|
82
|
+
} = args;
|
|
83
|
+
const model = await context.cms.getGroup(id);
|
|
84
|
+
return new _handlerGraphql.Response(model);
|
|
85
|
+
} catch (e) {
|
|
86
|
+
return new _handlerGraphql.ErrorResponse(e);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
listContentModelGroups: async (_, __, context) => {
|
|
90
|
+
try {
|
|
91
|
+
const models = await context.cms.listGroups();
|
|
92
|
+
return new _handlerGraphql.Response(models);
|
|
93
|
+
} catch (e) {
|
|
94
|
+
return new _handlerGraphql.ErrorResponse(e);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
Mutation: {
|
|
99
|
+
createContentModelGroup: async (_, args, context) => {
|
|
100
|
+
try {
|
|
101
|
+
const model = await context.cms.createGroup(args.data);
|
|
102
|
+
return new _handlerGraphql.Response(model);
|
|
103
|
+
} catch (e) {
|
|
104
|
+
return new _handlerGraphql.ErrorResponse(e);
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
updateContentModelGroup: async (_, args, context) => {
|
|
108
|
+
try {
|
|
109
|
+
const group = await context.cms.updateGroup(args.id, args.data);
|
|
110
|
+
return new _handlerGraphql.Response(group);
|
|
111
|
+
} catch (e) {
|
|
112
|
+
return new _handlerGraphql.ErrorResponse(e);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
deleteContentModelGroup: async (_, args, context) => {
|
|
116
|
+
try {
|
|
117
|
+
await context.cms.deleteGroup(args.id);
|
|
118
|
+
return new _handlerGraphql.Response(true);
|
|
119
|
+
} catch (e) {
|
|
120
|
+
return new _handlerGraphql.ErrorResponse(e);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
|
|
128
|
+
typeDefs:
|
|
129
|
+
/* GraphQL */
|
|
130
|
+
`
|
|
131
|
+
type CmsContentModelGroup {
|
|
132
|
+
id: ID!
|
|
133
|
+
createdOn: DateTime
|
|
134
|
+
savedOn: DateTime
|
|
135
|
+
name: String!
|
|
136
|
+
contentModels: [CmsContentModel!]
|
|
137
|
+
totalContentModels: Int!
|
|
138
|
+
slug: String!
|
|
139
|
+
description: String
|
|
140
|
+
icon: String
|
|
141
|
+
createdBy: CmsCreatedBy
|
|
142
|
+
|
|
143
|
+
# Returns true if the content model group is registered via a plugin.
|
|
144
|
+
plugin: Boolean!
|
|
145
|
+
}
|
|
146
|
+
${manageSchema}
|
|
147
|
+
`,
|
|
148
|
+
resolvers
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
var _default = plugin;
|
|
153
|
+
exports.default = _default;
|