@webiny/api-apw 5.23.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/LICENSE +21 -0
- package/README.md +33 -0
- package/createApw/createChangeRequestMethods.d.ts +2 -0
- package/createApw/createChangeRequestMethods.js +95 -0
- package/createApw/createCommentMethods.d.ts +2 -0
- package/createApw/createCommentMethods.js +96 -0
- package/createApw/createContentReviewMethods.d.ts +6 -0
- package/createApw/createContentReviewMethods.js +301 -0
- package/createApw/createReviewerMethods.d.ts +2 -0
- package/createApw/createReviewerMethods.js +96 -0
- package/createApw/createWorkflowMethods.d.ts +2 -0
- package/createApw/createWorkflowMethods.js +96 -0
- package/createApw/index.d.ts +2 -0
- package/createApw/index.js +54 -0
- package/index.d.ts +2 -0
- package/index.js +28 -0
- package/package.json +67 -0
- package/plugins/context.d.ts +4 -0
- package/plugins/context.js +89 -0
- package/plugins/createManageCMSPlugin.d.ts +2 -0
- package/plugins/createManageCMSPlugin.js +31 -0
- package/plugins/graphql/changeRequest.gql.d.ts +4 -0
- package/plugins/graphql/changeRequest.gql.js +152 -0
- package/plugins/graphql/comment.gql.d.ts +4 -0
- package/plugins/graphql/comment.gql.js +166 -0
- package/plugins/graphql/contentReview.gql.d.ts +4 -0
- package/plugins/graphql/contentReview.gql.js +224 -0
- package/plugins/graphql/reviewer.gql.d.ts +4 -0
- package/plugins/graphql/reviewer.gql.js +111 -0
- package/plugins/graphql/workflow.gql.d.ts +4 -0
- package/plugins/graphql/workflow.gql.js +199 -0
- package/plugins/graphql.d.ts +3 -0
- package/plugins/graphql.js +84 -0
- package/plugins/hooks/createReviewerFromIdentity.d.ts +2 -0
- package/plugins/hooks/createReviewerFromIdentity.js +44 -0
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.d.ts +2 -0
- package/plugins/hooks/deleteChangeRequestsAfterContentReview.js +66 -0
- package/plugins/hooks/deleteCommentsAfterChangeRequest.d.ts +2 -0
- package/plugins/hooks/deleteCommentsAfterChangeRequest.js +58 -0
- package/plugins/hooks/extendPbPageSchema.d.ts +4 -0
- package/plugins/hooks/extendPbPageSchema.js +24 -0
- package/plugins/hooks/index.d.ts +4 -0
- package/plugins/hooks/index.js +68 -0
- package/plugins/hooks/initializeContentReviewSteps.d.ts +7 -0
- package/plugins/hooks/initializeContentReviewSteps.js +70 -0
- package/plugins/hooks/linkWorkflowToPage.d.ts +9 -0
- package/plugins/hooks/linkWorkflowToPage.js +154 -0
- package/plugins/hooks/updatePendingChangeRequests.d.ts +2 -0
- package/plugins/hooks/updatePendingChangeRequests.js +107 -0
- package/plugins/utils.d.ts +15 -0
- package/plugins/utils.js +69 -0
- package/storageOperations/changeRequestStorageOperations.d.ts +3 -0
- package/storageOperations/changeRequestStorageOperations.js +96 -0
- package/storageOperations/commentStorageOperations.d.ts +3 -0
- package/storageOperations/commentStorageOperations.js +101 -0
- package/storageOperations/contentReviewStorageOperations.d.ts +3 -0
- package/storageOperations/contentReviewStorageOperations.js +72 -0
- package/storageOperations/index.d.ts +9 -0
- package/storageOperations/index.js +63 -0
- package/storageOperations/models/changeRequest.model.d.ts +7 -0
- package/storageOperations/models/changeRequest.model.js +52 -0
- package/storageOperations/models/comment.model.d.ts +9 -0
- package/storageOperations/models/comment.model.js +37 -0
- package/storageOperations/models/contentModelPluginFactory.d.ts +17 -0
- package/storageOperations/models/contentModelPluginFactory.js +33 -0
- package/storageOperations/models/contentReview.model.d.ts +25 -0
- package/storageOperations/models/contentReview.model.js +181 -0
- package/storageOperations/models/index.d.ts +1 -0
- package/storageOperations/models/index.js +87 -0
- package/storageOperations/models/reviewer.model.d.ts +7 -0
- package/storageOperations/models/reviewer.model.js +48 -0
- package/storageOperations/models/utils.d.ts +3 -0
- package/storageOperations/models/utils.js +35 -0
- package/storageOperations/models/workflow.model.d.ts +17 -0
- package/storageOperations/models/workflow.model.js +204 -0
- package/storageOperations/reviewerStorageOperations.d.ts +3 -0
- package/storageOperations/reviewerStorageOperations.js +72 -0
- package/storageOperations/types.d.ts +34 -0
- package/storageOperations/types.js +5 -0
- package/storageOperations/workflowStorageOperations.d.ts +3 -0
- package/storageOperations/workflowStorageOperations.js +72 -0
- package/types.d.ts +646 -0
- package/types.js +63 -0
- package/utils/errors.d.ts +16 -0
- package/utils/errors.js +75 -0
- package/utils/fieldResolver.d.ts +15 -0
- package/utils/fieldResolver.js +58 -0
- package/utils/resolve.d.ts +3 -0
- package/utils/resolve.js +18 -0
@@ -0,0 +1,96 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.createWorkflowMethods = createWorkflowMethods;
|
7
|
+
|
8
|
+
var _pubsub = require("@webiny/pubsub");
|
9
|
+
|
10
|
+
function createWorkflowMethods({
|
11
|
+
storageOperations
|
12
|
+
}) {
|
13
|
+
const onBeforeWorkflowCreate = (0, _pubsub.createTopic)();
|
14
|
+
const onAfterWorkflowCreate = (0, _pubsub.createTopic)();
|
15
|
+
const onBeforeWorkflowUpdate = (0, _pubsub.createTopic)();
|
16
|
+
const onAfterWorkflowUpdate = (0, _pubsub.createTopic)();
|
17
|
+
const onBeforeWorkflowDelete = (0, _pubsub.createTopic)();
|
18
|
+
const onAfterWorkflowDelete = (0, _pubsub.createTopic)();
|
19
|
+
return {
|
20
|
+
/**
|
21
|
+
* Lifecycle events
|
22
|
+
*/
|
23
|
+
onBeforeWorkflowCreate,
|
24
|
+
onAfterWorkflowCreate,
|
25
|
+
onBeforeWorkflowUpdate,
|
26
|
+
onAfterWorkflowUpdate,
|
27
|
+
onBeforeWorkflowDelete,
|
28
|
+
onAfterWorkflowDelete,
|
29
|
+
|
30
|
+
async get(id) {
|
31
|
+
return storageOperations.getWorkflow({
|
32
|
+
id
|
33
|
+
});
|
34
|
+
},
|
35
|
+
|
36
|
+
async list(params) {
|
37
|
+
return storageOperations.listWorkflows(params);
|
38
|
+
},
|
39
|
+
|
40
|
+
async create(data) {
|
41
|
+
await onBeforeWorkflowCreate.publish({
|
42
|
+
input: data
|
43
|
+
});
|
44
|
+
const workflow = await storageOperations.createWorkflow({
|
45
|
+
data
|
46
|
+
});
|
47
|
+
await onAfterWorkflowCreate.publish({
|
48
|
+
workflow
|
49
|
+
});
|
50
|
+
return workflow;
|
51
|
+
},
|
52
|
+
|
53
|
+
async update(id, data) {
|
54
|
+
const original = await storageOperations.getWorkflow({
|
55
|
+
id
|
56
|
+
});
|
57
|
+
await onBeforeWorkflowUpdate.publish({
|
58
|
+
original,
|
59
|
+
input: {
|
60
|
+
id,
|
61
|
+
data
|
62
|
+
}
|
63
|
+
});
|
64
|
+
const workflow = await storageOperations.updateWorkflow({
|
65
|
+
id,
|
66
|
+
data
|
67
|
+
});
|
68
|
+
await onAfterWorkflowUpdate.publish({
|
69
|
+
original,
|
70
|
+
input: {
|
71
|
+
id,
|
72
|
+
data
|
73
|
+
},
|
74
|
+
workflow
|
75
|
+
});
|
76
|
+
return workflow;
|
77
|
+
},
|
78
|
+
|
79
|
+
async delete(id) {
|
80
|
+
const workflow = await storageOperations.getWorkflow({
|
81
|
+
id
|
82
|
+
});
|
83
|
+
await onBeforeWorkflowDelete.publish({
|
84
|
+
workflow
|
85
|
+
});
|
86
|
+
await storageOperations.deleteWorkflow({
|
87
|
+
id
|
88
|
+
});
|
89
|
+
await onAfterWorkflowDelete.publish({
|
90
|
+
workflow
|
91
|
+
});
|
92
|
+
return true;
|
93
|
+
}
|
94
|
+
|
95
|
+
};
|
96
|
+
}
|
@@ -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.createApw = void 0;
|
9
|
+
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
11
|
+
|
12
|
+
var _createWorkflowMethods = require("./createWorkflowMethods");
|
13
|
+
|
14
|
+
var _createReviewerMethods = require("./createReviewerMethods");
|
15
|
+
|
16
|
+
var _createCommentMethods = require("./createCommentMethods");
|
17
|
+
|
18
|
+
var _createChangeRequestMethods = require("./createChangeRequestMethods");
|
19
|
+
|
20
|
+
var _createContentReviewMethods = require("./createContentReviewMethods");
|
21
|
+
|
22
|
+
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; }
|
23
|
+
|
24
|
+
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; }
|
25
|
+
|
26
|
+
const createApw = params => {
|
27
|
+
const workflowGetters = new Map();
|
28
|
+
const workflowMethods = (0, _createWorkflowMethods.createWorkflowMethods)(params);
|
29
|
+
const reviewerMethods = (0, _createReviewerMethods.createReviewerMethods)(params);
|
30
|
+
const changeRequestMethods = (0, _createChangeRequestMethods.createChangeRequestMethods)(params);
|
31
|
+
return {
|
32
|
+
addWorkflowGetter(type, func) {
|
33
|
+
workflowGetters.set(type, func);
|
34
|
+
},
|
35
|
+
|
36
|
+
getWorkflowGetter(type) {
|
37
|
+
if (!workflowGetters.has(type)) {
|
38
|
+
throw new Error(`No loader found for type: "${type}". You must define a loader.`);
|
39
|
+
}
|
40
|
+
|
41
|
+
return workflowGetters.get(type);
|
42
|
+
},
|
43
|
+
|
44
|
+
workflow: workflowMethods,
|
45
|
+
reviewer: reviewerMethods,
|
46
|
+
changeRequest: changeRequestMethods,
|
47
|
+
comment: (0, _createCommentMethods.createCommentMethods)(params),
|
48
|
+
contentReview: (0, _createContentReviewMethods.createContentReviewMethods)(_objectSpread(_objectSpread({}, params), {}, {
|
49
|
+
getReviewer: reviewerMethods.get.bind(reviewerMethods)
|
50
|
+
}))
|
51
|
+
};
|
52
|
+
};
|
53
|
+
|
54
|
+
exports.createApw = createApw;
|
package/index.d.ts
ADDED
@@ -0,0 +1,2 @@
|
|
1
|
+
export declare const createApwContext: () => (import("@webiny/handler").ContextPlugin<import("./types").ApwContext> | (import("@webiny/handler-graphql/plugins").GraphQLSchemaPlugin<import("./types").ApwContext> | import("@webiny/handler").ContextPlugin<import("./types").ApwContext>)[])[];
|
2
|
+
export declare const createApwGraphQL: () => import("@webiny/handler-graphql/plugins").GraphQLSchemaPlugin<import("./types").ApwContext>[];
|
package/index.js
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports.createApwGraphQL = exports.createApwContext = void 0;
|
9
|
+
|
10
|
+
var _graphql = _interopRequireDefault(require("./plugins/graphql"));
|
11
|
+
|
12
|
+
var _context = _interopRequireDefault(require("./plugins/context"));
|
13
|
+
|
14
|
+
/**
|
15
|
+
* We have separated context and GraphQL creation so user can initialize only context if required.
|
16
|
+
* GraphQL will not work without context, but context will without GraphQL.
|
17
|
+
*/
|
18
|
+
const createApwContext = () => {
|
19
|
+
return (0, _context.default)();
|
20
|
+
};
|
21
|
+
|
22
|
+
exports.createApwContext = createApwContext;
|
23
|
+
|
24
|
+
const createApwGraphQL = () => {
|
25
|
+
return (0, _graphql.default)();
|
26
|
+
};
|
27
|
+
|
28
|
+
exports.createApwGraphQL = createApwGraphQL;
|
package/package.json
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
{
|
2
|
+
"name": "@webiny/api-apw",
|
3
|
+
"version": "5.23.0-beta.0",
|
4
|
+
"keywords": [
|
5
|
+
"apw:base"
|
6
|
+
],
|
7
|
+
"main": "index.js",
|
8
|
+
"repository": {
|
9
|
+
"type": "git",
|
10
|
+
"url": "https://github.com/webiny/webiny-js.git",
|
11
|
+
"directory": "packages/api-apw"
|
12
|
+
},
|
13
|
+
"description": "GraphQL API for Webiny Advanced Publishing Workflow.",
|
14
|
+
"contributors": [
|
15
|
+
"Pavel Denisjuk <pavel@webiny.com>",
|
16
|
+
"Sven Al Hamad <sven@webiny.com>",
|
17
|
+
"Adrian Smijulj <adrian@webiny.com>"
|
18
|
+
],
|
19
|
+
"license": "MIT",
|
20
|
+
"dependencies": {
|
21
|
+
"@babel/runtime": "7.16.7",
|
22
|
+
"@webiny/api-headless-cms": "5.23.0-beta.0",
|
23
|
+
"@webiny/api-i18n": "5.23.0-beta.0",
|
24
|
+
"@webiny/api-i18n-content": "5.23.0-beta.0",
|
25
|
+
"@webiny/api-i18n-ddb": "5.23.0-beta.0",
|
26
|
+
"@webiny/api-page-builder": "5.23.0-beta.0",
|
27
|
+
"@webiny/api-page-builder-so-ddb": "5.23.0-beta.0",
|
28
|
+
"@webiny/api-security": "5.23.0-beta.0",
|
29
|
+
"@webiny/api-tenancy": "5.23.0-beta.0",
|
30
|
+
"@webiny/error": "5.23.0-beta.0",
|
31
|
+
"@webiny/handler": "5.23.0-beta.0",
|
32
|
+
"@webiny/handler-aws": "5.23.0-beta.0",
|
33
|
+
"@webiny/handler-graphql": "5.23.0-beta.0",
|
34
|
+
"@webiny/plugins": "5.23.0-beta.0",
|
35
|
+
"@webiny/pubsub": "5.23.0-beta.0",
|
36
|
+
"lodash": "4.17.21"
|
37
|
+
},
|
38
|
+
"devDependencies": {
|
39
|
+
"@babel/cli": "^7.5.5",
|
40
|
+
"@babel/core": "^7.5.5",
|
41
|
+
"@babel/preset-env": "^7.5.5",
|
42
|
+
"@babel/preset-flow": "^7.0.0",
|
43
|
+
"@webiny/api-security-so-ddb": "^5.23.0-beta.0",
|
44
|
+
"@webiny/api-tenancy-so-ddb": "^5.23.0-beta.0",
|
45
|
+
"@webiny/cli": "^5.23.0-beta.0",
|
46
|
+
"@webiny/project-utils": "^5.23.0-beta.0",
|
47
|
+
"apollo-graphql": "^0.4.1",
|
48
|
+
"get-yarn-workspaces": "^1.0.2",
|
49
|
+
"graphql": "^14.6.0",
|
50
|
+
"jest": "^26.6.3",
|
51
|
+
"mdbid": "^1.0.0",
|
52
|
+
"prettier": "^2.3.2",
|
53
|
+
"rimraf": "^3.0.2",
|
54
|
+
"sinon": "^9.0.2",
|
55
|
+
"ttypescript": "^1.5.12",
|
56
|
+
"typescript": "^4.1.3"
|
57
|
+
},
|
58
|
+
"publishConfig": {
|
59
|
+
"access": "public",
|
60
|
+
"directory": "dist"
|
61
|
+
},
|
62
|
+
"scripts": {
|
63
|
+
"build": "yarn webiny run build",
|
64
|
+
"watch": "yarn webiny run watch"
|
65
|
+
},
|
66
|
+
"gitHead": "deb16c58954f7396c848f04806a2028aa53cc97b"
|
67
|
+
}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { ContextPlugin } from "@webiny/handler/plugins/ContextPlugin";
|
2
|
+
import { ApwContext } from "../types";
|
3
|
+
declare const _default: () => (ContextPlugin<ApwContext> | (import("@webiny/handler-graphql/plugins").GraphQLSchemaPlugin<ApwContext> | ContextPlugin<ApwContext>)[])[];
|
4
|
+
export default _default;
|
@@ -0,0 +1,89 @@
|
|
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 _ContextPlugin = require("@webiny/handler/plugins/ContextPlugin");
|
11
|
+
|
12
|
+
var _types = require("../types");
|
13
|
+
|
14
|
+
var _createApw = require("../createApw");
|
15
|
+
|
16
|
+
var _hooks = _interopRequireDefault(require("./hooks"));
|
17
|
+
|
18
|
+
var _storageOperations = require("../storageOperations");
|
19
|
+
|
20
|
+
var _createManageCMSPlugin = require("./createManageCMSPlugin");
|
21
|
+
|
22
|
+
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
23
|
+
|
24
|
+
var _default = () => [new _ContextPlugin.ContextPlugin(async context => {
|
25
|
+
const {
|
26
|
+
tenancy,
|
27
|
+
security,
|
28
|
+
i18nContent
|
29
|
+
} = context;
|
30
|
+
const contentHeadlessCmsContextPlugins = (0, _apiHeadlessCms.createContentHeadlessCmsContext)({
|
31
|
+
storageOperations: context.cms.storageOperations
|
32
|
+
});
|
33
|
+
/**
|
34
|
+
* Register cms plugins required by `api-apw` package.
|
35
|
+
*/
|
36
|
+
|
37
|
+
context.plugins.register([(0, _createManageCMSPlugin.createManageCMSPlugin)(), ...contentHeadlessCmsContextPlugins]);
|
38
|
+
|
39
|
+
const getLocale = () => {
|
40
|
+
// TODO: Check which locale do we need here?
|
41
|
+
return i18nContent.locale;
|
42
|
+
};
|
43
|
+
|
44
|
+
const getTenant = () => {
|
45
|
+
return tenancy.getCurrentTenant();
|
46
|
+
};
|
47
|
+
|
48
|
+
const getPermission = name => security.getPermission(name);
|
49
|
+
|
50
|
+
const getIdentity = () => security.getIdentity();
|
51
|
+
|
52
|
+
context.apw = (0, _createApw.createApw)({
|
53
|
+
getLocale,
|
54
|
+
getIdentity,
|
55
|
+
getTenant,
|
56
|
+
getPermission,
|
57
|
+
storageOperations: (0, _storageOperations.createStorageOperations)({
|
58
|
+
/**
|
59
|
+
* TODO: We need to figure out a way to pass "cms" from outside (e.g. api/code/graphql)
|
60
|
+
*/
|
61
|
+
cms: context.cms,
|
62
|
+
|
63
|
+
/**
|
64
|
+
* TODO: This is required for "entryFieldFromStorageTransform" which access plugins from context.
|
65
|
+
*/
|
66
|
+
getCmsContext: () => context
|
67
|
+
})
|
68
|
+
});
|
69
|
+
/**
|
70
|
+
* TODO: @ashutosh
|
71
|
+
* Move these call into a separate package let say "ap-apw-page-builder"
|
72
|
+
*/
|
73
|
+
|
74
|
+
context.apw.addWorkflowGetter(_types.ApwContentTypes.PAGE, async id => {
|
75
|
+
const page = await context.pageBuilder.getPage(id);
|
76
|
+
return page.settings.apw.workflowId;
|
77
|
+
});
|
78
|
+
context.apw.addWorkflowGetter(_types.ApwContentTypes.CMS_ENTRY, async (id, settings) => {
|
79
|
+
const model = await context.cms.getModel(settings.modelId);
|
80
|
+
const entry = await context.cms.getEntry(model, {
|
81
|
+
where: {
|
82
|
+
id: id
|
83
|
+
}
|
84
|
+
});
|
85
|
+
return entry.values.workflow;
|
86
|
+
});
|
87
|
+
}), (0, _hooks.default)()];
|
88
|
+
|
89
|
+
exports.default = _default;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports.createManageCMSPlugin = void 0;
|
9
|
+
|
10
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
11
|
+
|
12
|
+
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
13
|
+
|
14
|
+
const createManageCMSPlugin = () => {
|
15
|
+
return new _apiHeadlessCms.CmsParametersPlugin(async context => {
|
16
|
+
const locale = context.i18n.getCurrentLocale("content");
|
17
|
+
|
18
|
+
if (!locale) {
|
19
|
+
throw new _error.default(`Could not able to load "locale".`, "MALFORMED_LOCALE", {
|
20
|
+
locale
|
21
|
+
});
|
22
|
+
}
|
23
|
+
|
24
|
+
return {
|
25
|
+
type: "manage",
|
26
|
+
locale: locale.code
|
27
|
+
};
|
28
|
+
});
|
29
|
+
};
|
30
|
+
|
31
|
+
exports.createManageCMSPlugin = createManageCMSPlugin;
|
@@ -0,0 +1,152 @@
|
|
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 _plugins = require("@webiny/handler-graphql/plugins");
|
11
|
+
|
12
|
+
var _handlerGraphql = require("@webiny/handler-graphql");
|
13
|
+
|
14
|
+
var _resolve = _interopRequireDefault(require("../../utils/resolve"));
|
15
|
+
|
16
|
+
const workflowSchema = new _plugins.GraphQLSchemaPlugin({
|
17
|
+
typeDefs:
|
18
|
+
/* GraphQL */
|
19
|
+
`
|
20
|
+
type ApwChangeRequestListItem {
|
21
|
+
# System generated fields
|
22
|
+
id: ID
|
23
|
+
savedOn: DateTime
|
24
|
+
createdOn: DateTime
|
25
|
+
createdBy: ApwCreatedBy
|
26
|
+
# ChangeRequest specific fields
|
27
|
+
step: String!
|
28
|
+
title: String!
|
29
|
+
body: JSON!
|
30
|
+
resolved: Boolean
|
31
|
+
media: JSON
|
32
|
+
}
|
33
|
+
|
34
|
+
type ApwListChangeRequestsResponse {
|
35
|
+
data: [ApwChangeRequestListItem]
|
36
|
+
error: ApwError
|
37
|
+
meta: ApwMeta
|
38
|
+
}
|
39
|
+
|
40
|
+
type ApwChangeRequest {
|
41
|
+
# System generated fields
|
42
|
+
id: ID
|
43
|
+
savedOn: DateTime
|
44
|
+
createdOn: DateTime
|
45
|
+
createdBy: ApwCreatedBy
|
46
|
+
# ChangeRequest specific fields
|
47
|
+
step: String!
|
48
|
+
title: String!
|
49
|
+
body: JSON!
|
50
|
+
resolved: Boolean
|
51
|
+
media: JSON
|
52
|
+
}
|
53
|
+
|
54
|
+
type ApwChangeRequestResponse {
|
55
|
+
data: ApwChangeRequest
|
56
|
+
error: ApwError
|
57
|
+
}
|
58
|
+
|
59
|
+
type ApwDeleteChangeRequestResponse {
|
60
|
+
data: Boolean
|
61
|
+
error: ApwError
|
62
|
+
}
|
63
|
+
|
64
|
+
enum ApwListChangeRequestSort {
|
65
|
+
id_ASC
|
66
|
+
id_DESC
|
67
|
+
savedOn_ASC
|
68
|
+
savedOn_DESC
|
69
|
+
createdOn_ASC
|
70
|
+
createdOn_DESC
|
71
|
+
publishedOn_ASC
|
72
|
+
publishedOn_DESC
|
73
|
+
title_ASC
|
74
|
+
title_DESC
|
75
|
+
}
|
76
|
+
|
77
|
+
input ApwCreateChangeRequestInput {
|
78
|
+
step: String!
|
79
|
+
title: String!
|
80
|
+
body: JSON!
|
81
|
+
resolved: Boolean
|
82
|
+
media: JSON
|
83
|
+
}
|
84
|
+
|
85
|
+
input ApwUpdateChangeRequestInput {
|
86
|
+
title: String
|
87
|
+
body: JSON
|
88
|
+
resolved: Boolean
|
89
|
+
media: JSON
|
90
|
+
}
|
91
|
+
|
92
|
+
input ApwListChangeRequestWhereInput {
|
93
|
+
id: ID
|
94
|
+
step: String
|
95
|
+
}
|
96
|
+
|
97
|
+
input ApwListChangeRequestSearchInput {
|
98
|
+
query: String
|
99
|
+
}
|
100
|
+
|
101
|
+
extend type ApwQuery {
|
102
|
+
getChangeRequest(id: ID!): ApwChangeRequestResponse
|
103
|
+
|
104
|
+
listChangeRequests(
|
105
|
+
where: ApwListChangeRequestWhereInput
|
106
|
+
limit: Int
|
107
|
+
after: String
|
108
|
+
sort: [ApwListChangeRequestSort!]
|
109
|
+
search: ApwListChangeRequestSearchInput
|
110
|
+
): ApwListChangeRequestsResponse
|
111
|
+
}
|
112
|
+
|
113
|
+
extend type ApwMutation {
|
114
|
+
createChangeRequest(data: ApwCreateChangeRequestInput!): ApwChangeRequestResponse
|
115
|
+
|
116
|
+
updateChangeRequest(
|
117
|
+
id: ID!
|
118
|
+
data: ApwUpdateChangeRequestInput!
|
119
|
+
): ApwChangeRequestResponse
|
120
|
+
|
121
|
+
deleteChangeRequest(id: ID!): ApwDeleteChangeRequestResponse
|
122
|
+
}
|
123
|
+
`,
|
124
|
+
resolvers: {
|
125
|
+
ApwQuery: {
|
126
|
+
getChangeRequest: async (_, args, context) => {
|
127
|
+
return (0, _resolve.default)(() => context.apw.changeRequest.get(args.id));
|
128
|
+
},
|
129
|
+
listChangeRequests: async (_, args, context) => {
|
130
|
+
try {
|
131
|
+
const [entries, meta] = await context.apw.changeRequest.list(args);
|
132
|
+
return new _handlerGraphql.ListResponse(entries, meta);
|
133
|
+
} catch (e) {
|
134
|
+
return new _handlerGraphql.ErrorResponse(e);
|
135
|
+
}
|
136
|
+
}
|
137
|
+
},
|
138
|
+
ApwMutation: {
|
139
|
+
createChangeRequest: async (_, args, context) => {
|
140
|
+
return (0, _resolve.default)(() => context.apw.changeRequest.create(args.data));
|
141
|
+
},
|
142
|
+
updateChangeRequest: async (_, args, context) => {
|
143
|
+
return (0, _resolve.default)(() => context.apw.changeRequest.update(args.id, args.data));
|
144
|
+
},
|
145
|
+
deleteChangeRequest: async (_, args, context) => {
|
146
|
+
return (0, _resolve.default)(() => context.apw.changeRequest.delete(args.id));
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
150
|
+
});
|
151
|
+
var _default = workflowSchema;
|
152
|
+
exports.default = _default;
|