@webiny/api-apw 0.0.0-unstable.6e5425ee89 → 0.0.0-unstable.7f63ea0744

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/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  import { CreateApwContextParams } from "./scheduler/types";
2
- export declare const createApwHeadlessCmsContext: (params: CreateApwContextParams) => (import("@webiny/api").ContextPlugin<import("./types").ApwContext> | import("@webiny/plugins/types").Plugin<Record<string, any>> | import("@webiny/plugins/types").PluginCollection)[];
3
- export declare const createApwPageBuilderContext: (params: CreateApwContextParams) => (import("@webiny/api").ContextPlugin<import("./types").ApwContext> | import("@webiny/plugins/types").Plugin<Record<string, any>> | import("@webiny/plugins/types").PluginCollection | import("@webiny/handler-graphql").GraphQLSchemaPlugin<import("@webiny/api-mailer/types").MailerContext>)[];
2
+ export declare const createApwPageBuilderContext: (params: CreateApwContextParams) => (import("@webiny/plugins/types").Plugin<Record<string, any>> | import("@webiny/plugins/types").PluginCollection | import("@webiny/api").ContextPlugin<import("./types").ApwContext> | import("@webiny/handler-graphql").GraphQLSchemaPlugin<import("@webiny/api-mailer/types").MailerContext>)[];
4
3
  export declare const createApwGraphQL: () => import("@webiny/api").ContextPlugin<import("./types").ApwContext>[];
package/index.js CHANGED
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.createApwPageBuilderContext = exports.createApwHeadlessCmsContext = exports.createApwGraphQL = void 0;
7
+ exports.createApwPageBuilderContext = exports.createApwGraphQL = void 0;
8
8
  var _graphql = _interopRequireDefault(require("./plugins/graphql"));
9
9
  var _context = require("./plugins/context");
10
10
  var _apiMailer = require("@webiny/api-mailer");
@@ -14,10 +14,6 @@ var _apiAdminSettings = require("@webiny/api-admin-settings");
14
14
  * GraphQL will not work without context, but context will without GraphQL.
15
15
  */
16
16
 
17
- const createApwHeadlessCmsContext = params => {
18
- return [...(0, _apiAdminSettings.createAdminSettingsContext)(), ...(0, _apiMailer.createMailerContext)(), (0, _context.createApwHeadlessCmsContext)(params)];
19
- };
20
- exports.createApwHeadlessCmsContext = createApwHeadlessCmsContext;
21
17
  const createApwPageBuilderContext = params => {
22
18
  return [...(0, _apiAdminSettings.createAdminSettingsContext)(), ...(0, _apiMailer.createMailerContext)(), ...(0, _apiMailer.createMailerGraphQL)(), (0, _context.createApwPageBuilderContext)(params)];
23
19
  };
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["createApwHeadlessCmsContext","params","createAdminSettingsContext","createMailerContext","createHeadlessCms","createApwPageBuilderContext","createMailerGraphQL","createPageBuilder","createApwGraphQL","graphql"],"sources":["index.ts"],"sourcesContent":["/**\n * We have separated context and GraphQL creation so user can initialize only context if required.\n * GraphQL will not work without context, but context will without GraphQL.\n */\nimport graphql from \"~/plugins/graphql\";\nimport {\n createApwHeadlessCmsContext as createHeadlessCms,\n createApwPageBuilderContext as createPageBuilder\n} from \"./plugins/context\";\nimport { CreateApwContextParams } from \"./scheduler/types\";\nimport { createMailerContext, createMailerGraphQL } from \"@webiny/api-mailer\";\nimport { createAdminSettingsContext } from \"@webiny/api-admin-settings\";\n\nexport const createApwHeadlessCmsContext = (params: CreateApwContextParams) => {\n return [...createAdminSettingsContext(), ...createMailerContext(), createHeadlessCms(params)];\n};\n\nexport const createApwPageBuilderContext = (params: CreateApwContextParams) => {\n return [\n ...createAdminSettingsContext(),\n ...createMailerContext(),\n ...createMailerGraphQL(),\n createPageBuilder(params)\n ];\n};\n\nexport const createApwGraphQL = () => {\n return [graphql()];\n};\n"],"mappings":";;;;;;;AAIA;AACA;AAKA;AACA;AAXA;AACA;AACA;AACA;;AAUO,MAAMA,2BAA2B,GAAIC,MAA8B,IAAK;EAC3E,OAAO,CAAC,GAAG,IAAAC,4CAA0B,GAAE,EAAE,GAAG,IAAAC,8BAAmB,GAAE,EAAE,IAAAC,oCAAiB,EAACH,MAAM,CAAC,CAAC;AACjG,CAAC;AAAC;AAEK,MAAMI,2BAA2B,GAAIJ,MAA8B,IAAK;EAC3E,OAAO,CACH,GAAG,IAAAC,4CAA0B,GAAE,EAC/B,GAAG,IAAAC,8BAAmB,GAAE,EACxB,GAAG,IAAAG,8BAAmB,GAAE,EACxB,IAAAC,oCAAiB,EAACN,MAAM,CAAC,CAC5B;AACL,CAAC;AAAC;AAEK,MAAMO,gBAAgB,GAAG,MAAM;EAClC,OAAO,CAAC,IAAAC,gBAAO,GAAE,CAAC;AACtB,CAAC;AAAC"}
1
+ {"version":3,"names":["createApwPageBuilderContext","params","createAdminSettingsContext","createMailerContext","createMailerGraphQL","createPageBuilder","createApwGraphQL","graphql"],"sources":["index.ts"],"sourcesContent":["/**\n * We have separated context and GraphQL creation so user can initialize only context if required.\n * GraphQL will not work without context, but context will without GraphQL.\n */\nimport graphql from \"~/plugins/graphql\";\nimport { createApwPageBuilderContext as createPageBuilder } from \"./plugins/context\";\nimport { CreateApwContextParams } from \"./scheduler/types\";\nimport { createMailerContext, createMailerGraphQL } from \"@webiny/api-mailer\";\nimport { createAdminSettingsContext } from \"@webiny/api-admin-settings\";\n\nexport const createApwPageBuilderContext = (params: CreateApwContextParams) => {\n return [\n ...createAdminSettingsContext(),\n ...createMailerContext(),\n ...createMailerGraphQL(),\n createPageBuilder(params)\n ];\n};\n\nexport const createApwGraphQL = () => {\n return [graphql()];\n};\n"],"mappings":";;;;;;;AAIA;AACA;AAEA;AACA;AARA;AACA;AACA;AACA;;AAOO,MAAMA,2BAA2B,GAAIC,MAA8B,IAAK;EAC3E,OAAO,CACH,GAAG,IAAAC,4CAA0B,GAAE,EAC/B,GAAG,IAAAC,8BAAmB,GAAE,EACxB,GAAG,IAAAC,8BAAmB,GAAE,EACxB,IAAAC,oCAAiB,EAACJ,MAAM,CAAC,CAC5B;AACL,CAAC;AAAC;AAEK,MAAMK,gBAAgB,GAAG,MAAM;EAClC,OAAO,CAAC,IAAAC,gBAAO,GAAE,CAAC;AACtB,CAAC;AAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-apw",
3
- "version": "0.0.0-unstable.6e5425ee89",
3
+ "version": "0.0.0-unstable.7f63ea0744",
4
4
  "keywords": [
5
5
  "apw:base"
6
6
  ],
@@ -14,31 +14,31 @@
14
14
  "author": "Webiny Ltd",
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
- "@aws-sdk/client-cloudwatch-events": "3.216.0",
18
- "@babel/runtime": "7.20.1",
17
+ "@aws-sdk/client-cloudwatch-events": "3.266.0",
18
+ "@babel/runtime": "7.20.13",
19
19
  "@commodo/fields": "1.1.2-beta.20",
20
- "@webiny/api": "0.0.0-unstable.6e5425ee89",
21
- "@webiny/api-admin-settings": "0.0.0-unstable.6e5425ee89",
22
- "@webiny/api-headless-cms": "0.0.0-unstable.6e5425ee89",
23
- "@webiny/api-i18n": "0.0.0-unstable.6e5425ee89",
24
- "@webiny/api-i18n-ddb": "0.0.0-unstable.6e5425ee89",
25
- "@webiny/api-mailer": "0.0.0-unstable.6e5425ee89",
26
- "@webiny/api-page-builder": "0.0.0-unstable.6e5425ee89",
27
- "@webiny/api-security": "0.0.0-unstable.6e5425ee89",
28
- "@webiny/api-tenancy": "0.0.0-unstable.6e5425ee89",
29
- "@webiny/api-wcp": "0.0.0-unstable.6e5425ee89",
30
- "@webiny/db-dynamodb": "0.0.0-unstable.6e5425ee89",
31
- "@webiny/error": "0.0.0-unstable.6e5425ee89",
32
- "@webiny/handler": "0.0.0-unstable.6e5425ee89",
33
- "@webiny/handler-client": "0.0.0-unstable.6e5425ee89",
34
- "@webiny/handler-db": "0.0.0-unstable.6e5425ee89",
35
- "@webiny/handler-graphql": "0.0.0-unstable.6e5425ee89",
36
- "@webiny/handler-logs": "0.0.0-unstable.6e5425ee89",
37
- "@webiny/plugins": "0.0.0-unstable.6e5425ee89",
38
- "@webiny/pubsub": "0.0.0-unstable.6e5425ee89",
39
- "@webiny/utils": "0.0.0-unstable.6e5425ee89",
40
- "@webiny/validation": "0.0.0-unstable.6e5425ee89",
41
- "dayjs": "1.11.6",
20
+ "@webiny/api": "0.0.0-unstable.7f63ea0744",
21
+ "@webiny/api-admin-settings": "0.0.0-unstable.7f63ea0744",
22
+ "@webiny/api-headless-cms": "0.0.0-unstable.7f63ea0744",
23
+ "@webiny/api-i18n": "0.0.0-unstable.7f63ea0744",
24
+ "@webiny/api-i18n-ddb": "0.0.0-unstable.7f63ea0744",
25
+ "@webiny/api-mailer": "0.0.0-unstable.7f63ea0744",
26
+ "@webiny/api-page-builder": "0.0.0-unstable.7f63ea0744",
27
+ "@webiny/api-security": "0.0.0-unstable.7f63ea0744",
28
+ "@webiny/api-tenancy": "0.0.0-unstable.7f63ea0744",
29
+ "@webiny/api-wcp": "0.0.0-unstable.7f63ea0744",
30
+ "@webiny/db-dynamodb": "0.0.0-unstable.7f63ea0744",
31
+ "@webiny/error": "0.0.0-unstable.7f63ea0744",
32
+ "@webiny/handler": "0.0.0-unstable.7f63ea0744",
33
+ "@webiny/handler-client": "0.0.0-unstable.7f63ea0744",
34
+ "@webiny/handler-db": "0.0.0-unstable.7f63ea0744",
35
+ "@webiny/handler-graphql": "0.0.0-unstable.7f63ea0744",
36
+ "@webiny/handler-logs": "0.0.0-unstable.7f63ea0744",
37
+ "@webiny/plugins": "0.0.0-unstable.7f63ea0744",
38
+ "@webiny/pubsub": "0.0.0-unstable.7f63ea0744",
39
+ "@webiny/utils": "0.0.0-unstable.7f63ea0744",
40
+ "@webiny/validation": "0.0.0-unstable.7f63ea0744",
41
+ "dayjs": "1.11.7",
42
42
  "lodash": "4.17.21",
43
43
  "mdbid": "1.0.0"
44
44
  },
@@ -46,14 +46,14 @@
46
46
  "@babel/cli": "^7.19.3",
47
47
  "@babel/core": "^7.19.3",
48
48
  "@babel/preset-env": "^7.19.4",
49
- "@webiny/api-headless-cms-ddb": "^0.0.0-unstable.6e5425ee89",
50
- "@webiny/api-page-builder-so-ddb": "^0.0.0-unstable.6e5425ee89",
51
- "@webiny/api-security-so-ddb": "^0.0.0-unstable.6e5425ee89",
52
- "@webiny/api-tenancy-so-ddb": "^0.0.0-unstable.6e5425ee89",
53
- "@webiny/cli": "^0.0.0-unstable.6e5425ee89",
54
- "@webiny/handler-aws": "^0.0.0-unstable.6e5425ee89",
55
- "@webiny/project-utils": "^0.0.0-unstable.6e5425ee89",
56
- "@webiny/wcp": "^0.0.0-unstable.6e5425ee89",
49
+ "@webiny/api-headless-cms-ddb": "^0.0.0-unstable.7f63ea0744",
50
+ "@webiny/api-page-builder-so-ddb": "^0.0.0-unstable.7f63ea0744",
51
+ "@webiny/api-security-so-ddb": "^0.0.0-unstable.7f63ea0744",
52
+ "@webiny/api-tenancy-so-ddb": "^0.0.0-unstable.7f63ea0744",
53
+ "@webiny/cli": "^0.0.0-unstable.7f63ea0744",
54
+ "@webiny/handler-aws": "^0.0.0-unstable.7f63ea0744",
55
+ "@webiny/project-utils": "^0.0.0-unstable.7f63ea0744",
56
+ "@webiny/wcp": "^0.0.0-unstable.7f63ea0744",
57
57
  "get-yarn-workspaces": "^1.0.2",
58
58
  "graphql": "^15.7.2",
59
59
  "jest": "^28.1.0",
@@ -72,5 +72,5 @@
72
72
  "build": "yarn webiny run build",
73
73
  "watch": "yarn webiny run watch"
74
74
  },
75
- "gitHead": "1e49c5d4b72b2f00661572464188f53b42ed7745"
75
+ "gitHead": "7f63ea0744c9e31977e5dabb95538d22b4db585c"
76
76
  }
@@ -2,4 +2,3 @@ import { ContextPlugin } from "@webiny/api";
2
2
  import { ApwContext } from "../types";
3
3
  import { CreateApwContextParams } from "../scheduler/types";
4
4
  export declare const createApwPageBuilderContext: (params: CreateApwContextParams) => ContextPlugin<ApwContext>;
5
- export declare const createApwHeadlessCmsContext: (params: CreateApwContextParams) => ContextPlugin<ApwContext>;
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.createApwPageBuilderContext = exports.createApwHeadlessCmsContext = void 0;
7
+ exports.createApwPageBuilderContext = void 0;
8
8
  var _hooks = require("./hooks");
9
9
  var _error = _interopRequireDefault(require("@webiny/error"));
10
10
  var _api = require("@webiny/api");
@@ -98,18 +98,4 @@ const createApwPageBuilderContext = params => {
98
98
  context.plugins.register((0, _extendPbPageSettingsSchema.extendPbPageSettingsSchema)());
99
99
  });
100
100
  };
101
- exports.createApwPageBuilderContext = createApwPageBuilderContext;
102
- const createApwHeadlessCmsContext = params => {
103
- return new _api.ContextPlugin(async context => {
104
- if (!context.wcp.canUseFeature("advancedPublishingWorkflow")) {
105
- return;
106
- } else if ((0, _utils.isInstallationPending)(context)) {
107
- return;
108
- }
109
- await setupApwContext(params).apply(context);
110
- await setupApwHeadlessCms().apply(context);
111
- await (0, _hooks.attachApwHooks)().apply(context);
112
- await (0, _security.createCustomAuth)(params).apply(context);
113
- });
114
- };
115
- exports.createApwHeadlessCmsContext = createApwHeadlessCmsContext;
101
+ exports.createApwPageBuilderContext = createApwPageBuilderContext;
@@ -1 +1 @@
1
- {"version":3,"names":["setupApwContext","params","ContextPlugin","context","tenancy","security","i18n","handlerClient","isInstallationPending","getLocale","locale","getContentLocale","WebinyError","getTenant","getCurrentTenant","getPermission","name","getIdentity","scheduler","createScheduler","storageOperations","apw","createApw","createStorageOperations","cms","getCmsContext","plugins","setupApwPageBuilder","apwPageBuilderHooks","setupApwHeadlessCms","apwCmsHooks","createApwPageBuilderContext","wcp","canUseFeature","apply","apwContentPagePlugins","attachApwHooks","createCustomAuth","register","extendPbPageSettingsSchema","createApwHeadlessCmsContext"],"sources":["context.ts"],"sourcesContent":["import { attachApwHooks } from \"./hooks\";\nimport WebinyError from \"@webiny/error\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { ApwContext } from \"~/types\";\nimport { createApw } from \"~/crud\";\nimport { apwPageBuilderHooks } from \"./pageBuilder\";\nimport { createStorageOperations } from \"~/storageOperations\";\nimport { SecurityPermission } from \"@webiny/api-security/types\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { CreateApwContextParams } from \"~/scheduler/types\";\nimport { createScheduler } from \"~/scheduler\";\nimport { createCustomAuth } from \"~/scheduler/handlers/executeAction/security\";\nimport { isInstallationPending } from \"./utils\";\nimport { extendPbPageSettingsSchema } from \"~/plugins/pageBuilder/extendPbPageSettingsSchema\";\nimport { apwContentPagePlugins } from \"~/plugins/pageBuilder/apwContentPagePlugins\";\nimport { apwCmsHooks } from \"~/plugins/cms\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\n\nconst setupApwContext = (params: CreateApwContextParams) =>\n new ContextPlugin<ApwContext>(async context => {\n const { tenancy, security, i18n, handlerClient } = context;\n\n if (isInstallationPending({ tenancy, i18n })) {\n return;\n }\n\n const getLocale = (): I18NLocale => {\n const locale = i18n.getContentLocale();\n if (!locale) {\n throw new WebinyError(\n \"Missing content locale in api-apw/plugins/context.ts\",\n \"LOCALE_ERROR\"\n );\n }\n\n return locale;\n };\n\n const getTenant = (): Tenant => {\n return tenancy.getCurrentTenant();\n };\n\n const getPermission = async (name: string): Promise<SecurityPermission | null> => {\n return security.getPermission(name);\n };\n const getIdentity = () => security.getIdentity();\n\n const scheduler = createScheduler({\n getLocale,\n getIdentity,\n getTenant,\n getPermission,\n storageOperations: params.storageOperations\n });\n\n context.apw = createApw({\n getLocale,\n getIdentity,\n getTenant,\n getPermission,\n storageOperations: createStorageOperations({\n /**\n * TODO: We need to figure out a way to pass \"cms\" from outside (e.g. apps/api/graphql)\n */\n cms: context.cms,\n /**\n * TODO: This is required for \"entryFieldFromStorageTransform\" which access plugins from context.\n */\n getCmsContext: () => context,\n security\n }),\n scheduler,\n handlerClient,\n plugins: context.plugins\n });\n });\n\nconst setupApwPageBuilder = () => {\n return new ContextPlugin<ApwContext>(async context => {\n apwPageBuilderHooks(context);\n });\n};\n\nconst setupApwHeadlessCms = () => {\n return new ContextPlugin<ApwContext>(async context => {\n apwCmsHooks(context);\n });\n};\n\nexport const createApwPageBuilderContext = (params: CreateApwContextParams) => {\n return new ContextPlugin<ApwContext>(async context => {\n if (!context.wcp.canUseFeature(\"advancedPublishingWorkflow\")) {\n return;\n } else if (isInstallationPending(context)) {\n return;\n }\n\n await setupApwContext(params).apply(context);\n await setupApwPageBuilder().apply(context);\n await setupApwHeadlessCms().apply(context);\n await apwContentPagePlugins().apply(context);\n await attachApwHooks().apply(context);\n await createCustomAuth(params).apply(context);\n\n context.plugins.register(extendPbPageSettingsSchema());\n });\n};\n\nexport const createApwHeadlessCmsContext = (params: CreateApwContextParams) => {\n return new ContextPlugin<ApwContext>(async context => {\n if (!context.wcp.canUseFeature(\"advancedPublishingWorkflow\")) {\n return;\n } else if (isInstallationPending(context)) {\n return;\n }\n\n await setupApwContext(params).apply(context);\n await setupApwHeadlessCms().apply(context);\n await attachApwHooks().apply(context);\n await createCustomAuth(params).apply(context);\n });\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAEA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AAGA,MAAMA,eAAe,GAAIC,MAA8B,IACnD,IAAIC,kBAAa,CAAa,MAAMC,OAAO,IAAI;EAC3C,MAAM;IAAEC,OAAO;IAAEC,QAAQ;IAAEC,IAAI;IAAEC;EAAc,CAAC,GAAGJ,OAAO;EAE1D,IAAI,IAAAK,4BAAqB,EAAC;IAAEJ,OAAO;IAAEE;EAAK,CAAC,CAAC,EAAE;IAC1C;EACJ;EAEA,MAAMG,SAAS,GAAG,MAAkB;IAChC,MAAMC,MAAM,GAAGJ,IAAI,CAACK,gBAAgB,EAAE;IACtC,IAAI,CAACD,MAAM,EAAE;MACT,MAAM,IAAIE,cAAW,CACjB,sDAAsD,EACtD,cAAc,CACjB;IACL;IAEA,OAAOF,MAAM;EACjB,CAAC;EAED,MAAMG,SAAS,GAAG,MAAc;IAC5B,OAAOT,OAAO,CAACU,gBA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AM,IAAI,IAAAzB,4BAAqB,EAACL,OAAO,CAAC,EAAE;MACvC;IACJ;IAEA,MAAMH,eAAe,CAACC,MAAM,CAAC,CAACiC,KAAK,CAAC/B,OAAO,CAAC;IAC5C,MAAMwB,mBAAmB,EAAE,CAACO,KAAK,CAAC/B,OAAO,CAAC;IAC1C,MAAM0B,mBAAmB,EAAE,CAACK,KAAK,CAAC/B,OAAO,CAAC;IAC1C,MAAM,IAAAgC,4CAAqB,GAAE,CAACD,KAAK,CAAC/B,OAAO,CAAC;IAC5C,MAAM,IAAAiC,qBAAc,GAAE,CAACF,KAAK,CAAC/B,OAAO,CAAC;IACrC,MAAM,IAAAkC,0BAAgB,EAACpC,MAAM,CAAC,CAACiC,KAAK,CAAC/B,OAAO,CAAC;IAE7CA,OAAO,CAACuB,OAAO,CAACY,QAAQ,CAAC,IAAAC,sDAA0B,GAAE,CAAC;EAC1D,CAAC,CAAC;AACN,CAAC;AAAC;AAEK,MAAMC,2BAA2B,GAAIvC,MAA8B,IAAK;EAC3E,OAAO,IAAIC,kBAAa,CAAa,MAAMC,OAAO,IAAI;IAClD,IAAI,CAACA,OAAO,CAAC6B,GAAG,CAACC,aAAa,CAAC,4BAA4B,CAAC,EAAE;MAC1D;IACJ,CAAC,MAAM,IAAI,IAAAzB,4BAAqB,EAACL,OAAO,CAAC,EAAE;MACvC;IACJ;IAEA,MAAMH,eAAe,CAACC,MAAM,CAAC,CAACiC,KAAK,CAAC/B,OAAO,CAAC;IAC5C,MAAM0B,mBAAmB,EAAE,CAACK,KAAK,CAAC/B,OAAO,CAAC;IAC1C,MAAM,IAAAiC,qBAAc,GAAE,CAACF,KAAK,CAAC/B,OAAO,CAAC;IACrC,MAAM,IAAAkC,0BAAgB,EAACpC,MAAM,CAAC,CAACiC,KAAK,CAAC/B,OAAO,CAAC;EACjD,CAAC,CAAC;AACN,CAAC;AAAC"}
1
+ {"version":3,"names":["setupApwContext","params","ContextPlugin","context","tenancy","security","i18n","handlerClient","isInstallationPending","getLocale","locale","getContentLocale","WebinyError","getTenant","getCurrentTenant","getPermission","name","getIdentity","scheduler","createScheduler","storageOperations","apw","createApw","createStorageOperations","cms","getCmsContext","plugins","setupApwPageBuilder","apwPageBuilderHooks","setupApwHeadlessCms","apwCmsHooks","createApwPageBuilderContext","wcp","canUseFeature","apply","apwContentPagePlugins","attachApwHooks","createCustomAuth","register","extendPbPageSettingsSchema"],"sources":["context.ts"],"sourcesContent":["import { attachApwHooks } from \"./hooks\";\nimport WebinyError from \"@webiny/error\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { ApwContext } from \"~/types\";\nimport { createApw } from \"~/crud\";\nimport { apwPageBuilderHooks } from \"./pageBuilder\";\nimport { createStorageOperations } from \"~/storageOperations\";\nimport { SecurityPermission } from \"@webiny/api-security/types\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { CreateApwContextParams } from \"~/scheduler/types\";\nimport { createScheduler } from \"~/scheduler\";\nimport { createCustomAuth } from \"~/scheduler/handlers/executeAction/security\";\nimport { isInstallationPending } from \"./utils\";\nimport { extendPbPageSettingsSchema } from \"~/plugins/pageBuilder/extendPbPageSettingsSchema\";\nimport { apwContentPagePlugins } from \"~/plugins/pageBuilder/apwContentPagePlugins\";\nimport { apwCmsHooks } from \"~/plugins/cms\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\n\nconst setupApwContext = (params: CreateApwContextParams) =>\n new ContextPlugin<ApwContext>(async context => {\n const { tenancy, security, i18n, handlerClient } = context;\n\n if (isInstallationPending({ tenancy, i18n })) {\n return;\n }\n\n const getLocale = (): I18NLocale => {\n const locale = i18n.getContentLocale();\n if (!locale) {\n throw new WebinyError(\n \"Missing content locale in api-apw/plugins/context.ts\",\n \"LOCALE_ERROR\"\n );\n }\n\n return locale;\n };\n\n const getTenant = (): Tenant => {\n return tenancy.getCurrentTenant();\n };\n\n const getPermission = async (name: string): Promise<SecurityPermission | null> => {\n return security.getPermission(name);\n };\n const getIdentity = () => security.getIdentity();\n\n const scheduler = createScheduler({\n getLocale,\n getIdentity,\n getTenant,\n getPermission,\n storageOperations: params.storageOperations\n });\n\n context.apw = createApw({\n getLocale,\n getIdentity,\n getTenant,\n getPermission,\n storageOperations: createStorageOperations({\n /**\n * TODO: We need to figure out a way to pass \"cms\" from outside (e.g. apps/api/graphql)\n */\n cms: context.cms,\n /**\n * TODO: This is required for \"entryFieldFromStorageTransform\" which access plugins from context.\n */\n getCmsContext: () => context,\n security\n }),\n scheduler,\n handlerClient,\n plugins: context.plugins\n });\n });\n\nconst setupApwPageBuilder = () => {\n return new ContextPlugin<ApwContext>(async context => {\n apwPageBuilderHooks(context);\n });\n};\n\nconst setupApwHeadlessCms = () => {\n return new ContextPlugin<ApwContext>(async context => {\n apwCmsHooks(context);\n });\n};\n\nexport const createApwPageBuilderContext = (params: CreateApwContextParams) => {\n return new ContextPlugin<ApwContext>(async context => {\n if (!context.wcp.canUseFeature(\"advancedPublishingWorkflow\")) {\n return;\n } else if (isInstallationPending(context)) {\n return;\n }\n\n await setupApwContext(params).apply(context);\n await setupApwPageBuilder().apply(context);\n await setupApwHeadlessCms().apply(context);\n await apwContentPagePlugins().apply(context);\n await attachApwHooks().apply(context);\n await createCustomAuth(params).apply(context);\n\n context.plugins.register(extendPbPageSettingsSchema());\n });\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAEA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AAGA,MAAMA,eAAe,GAAIC,MAA8B,IACnD,IAAIC,kBAAa,CAAa,MAAMC,OAAO,IAAI;EAC3C,MAAM;IAAEC,OAAO;IAAEC,QAAQ;IAAEC,IAAI;IAAEC;EAAc,CAAC,GAAGJ,OAAO;EAE1D,IAAI,IAAAK,4BAAqB,EAAC;IAAEJ,OAAO;IAAEE;EAAK,CAAC,CAAC,EAAE;IAC1C;EACJ;EAEA,MAAMG,SAAS,GAAG,MAAkB;IAChC,MAAMC,MAAM,GAAGJ,IAAI,CAACK,gBAAgB,EAAE;IAC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BAA2B,GAAI9B,MAA8B,IAAK;EAC3E,OAAO,IAAIC,kBAAa,CAAa,MAAMC,OAAO,IAAI;IAClD,IAAI,CAACA,OAAO,CAAC6B,GAAG,CAACC,aAAa,CAAC,4BAA4B,CAAC,EAAE;MAC1D;IACJ,CAAC,MAAM,IAAI,IAAAzB,4BAAqB,EAACL,OAAO,CAAC,EAAE;MACvC;IACJ;IAEA,MAAMH,eAAe,CAACC,MAAM,CAAC,CAACiC,KAAK,CAAC/B,OAAO,CAAC;IAC5C,MAAMwB,mBAAmB,EAAE,CAACO,KAAK,CAAC/B,OAAO,CAAC;IAC1C,MAAM0B,mBAAmB,EAAE,CAACK,KAAK,CAAC/B,OAAO,CAAC;IAC1C,MAAM,IAAAgC,4CAAqB,GAAE,CAACD,KAAK,CAAC/B,OAAO,CAAC;IAC5C,MAAM,IAAAiC,qBAAc,GAAE,CAACF,KAAK,CAAC/B,OAAO,CAAC;IACrC,MAAM,IAAAkC,0BAAgB,EAACpC,MAAM,CAAC,CAACiC,KAAK,CAAC/B,OAAO,CAAC;IAE7CA,OAAO,CAACuB,OAAO,CAACY,QAAQ,CAAC,IAAAC,sDAA0B,GAAE,CAAC;EAC1D,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -5,12 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _plugins = require("@webiny/handler-graphql/plugins");
9
8
  var _workflow = _interopRequireDefault(require("./graphql/workflow.gql"));
10
9
  var _contentReview = _interopRequireDefault(require("./graphql/contentReview.gql"));
11
10
  var _reviewer = _interopRequireDefault(require("./graphql/reviewer.gql"));
12
11
  var _comment = _interopRequireDefault(require("./graphql/comment.gql"));
13
12
  var _changeRequest = _interopRequireDefault(require("./graphql/changeRequest.gql"));
13
+ var _plugins = require("@webiny/handler-graphql/plugins");
14
14
  var _api = require("@webiny/api");
15
15
  const emptyResolver = () => ({});
16
16
  const baseSchema = new _plugins.GraphQLSchemaPlugin({
@@ -1 +1 @@
1
- {"version":3,"names":["emptyResolver","baseSchema","GraphQLSchemaPlugin","typeDefs","resolvers","Query","apw","Mutation","ContextPlugin","context","wcp","canUseFeature","plugins","register","workflowSchema","contentReviewSchema","reviewerSchema","commentSchema","changeRequestedSchema"],"sources":["graphql.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins\";\nimport workflowSchema from \"./graphql/workflow.gql\";\nimport contentReviewSchema from \"./graphql/contentReview.gql\";\nimport reviewerSchema from \"./graphql/reviewer.gql\";\nimport commentSchema from \"./graphql/comment.gql\";\nimport changeRequestedSchema from \"./graphql/changeRequest.gql\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { ApwContext } from \"~/types\";\n\nconst emptyResolver = () => ({});\n\nconst baseSchema = new GraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n input ApwRefFieldInput {\n id: ID!\n modelId: String\n }\n\n input ApwRefFieldWhereInput {\n id: String\n id_not: String\n id_in: [String!]\n id_not_in: [String]\n entryId: String\n entryId_not: String\n entryId_in: [String!]\n entryId_not_in: [String!]\n }\n\n type ApwRefField {\n modelId: String!\n entryId: ID!\n id: ID!\n }\n\n type ApwMeta {\n hasMoreItems: Boolean\n totalCount: Int\n cursor: String\n }\n type ApwCreatedBy {\n id: ID\n displayName: String\n type: String\n }\n type ApwError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n extend type Query {\n apw: ApwQuery\n }\n extend type Mutation {\n apw: ApwMutation\n }\n `,\n resolvers: {\n Query: {\n apw: emptyResolver\n },\n Mutation: {\n apw: emptyResolver\n }\n }\n});\n\nexport default () => {\n return new ContextPlugin<ApwContext>(context => {\n if (!context.wcp.canUseFeature(\"advancedPublishingWorkflow\")) {\n return;\n }\n\n context.plugins.register([\n baseSchema,\n workflowSchema,\n contentReviewSchema,\n reviewerSchema,\n commentSchema,\n changeRequestedSchema\n ]);\n });\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,MAAMA,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC;AAEhC,MAAMC,UAAU,GAAG,IAAIC,4BAAmB,CAAC;EACvCC,QAAQ,EAAE,aAAe;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EACDC,SAAS,EAAE;IACPC,KAAK,EAAE;MACHC,GAAG,EAAEN;IACT,CAAC;IACDO,QAAQ,EAAE;MACND,GAAG,EAAEN;IACT;EACJ;AACJ,CAAC,CAAC;AAAC,eAEY,MAAM;EACjB,OAAO,IAAIQ,kBAAa,CAAaC,OAAO,IAAI;IAC5C,IAAI,CAACA,OAAO,CAACC,GAAG,CAACC,aAAa,CAAC,4BAA4B,CAAC,EAAE;MAC1D;IACJ;IAEAF,OAAO,CAACG,OAAO,CAACC,QAAQ,CAAC,CACrBZ,UAAU,EACVa,iBAAc,EACdC,sBAAmB,EACnBC,iBAAc,EACdC,gBAAa,EACbC,sBAAqB,CACxB,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAAA"}
1
+ {"version":3,"names":["emptyResolver","baseSchema","GraphQLSchemaPlugin","typeDefs","resolvers","Query","apw","Mutation","ContextPlugin","context","wcp","canUseFeature","plugins","register","workflowSchema","contentReviewSchema","reviewerSchema","commentSchema","changeRequestedSchema"],"sources":["graphql.ts"],"sourcesContent":["import workflowSchema from \"./graphql/workflow.gql\";\nimport contentReviewSchema from \"./graphql/contentReview.gql\";\nimport reviewerSchema from \"./graphql/reviewer.gql\";\nimport commentSchema from \"./graphql/comment.gql\";\nimport changeRequestedSchema from \"./graphql/changeRequest.gql\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { ApwContext } from \"~/types\";\n\nconst emptyResolver = () => ({});\n\nconst baseSchema = new GraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n input ApwRefFieldInput {\n id: ID!\n modelId: String\n }\n\n input ApwRefFieldWhereInput {\n id: String\n id_not: String\n id_in: [String!]\n id_not_in: [String]\n entryId: String\n entryId_not: String\n entryId_in: [String!]\n entryId_not_in: [String!]\n }\n\n type ApwRefField {\n modelId: String!\n entryId: ID!\n id: ID!\n }\n\n type ApwMeta {\n hasMoreItems: Boolean\n totalCount: Int\n cursor: String\n }\n type ApwCreatedBy {\n id: ID\n displayName: String\n type: String\n }\n type ApwError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n extend type Query {\n apw: ApwQuery\n }\n extend type Mutation {\n apw: ApwMutation\n }\n `,\n resolvers: {\n Query: {\n apw: emptyResolver\n },\n Mutation: {\n apw: emptyResolver\n }\n }\n});\n\nexport default () => {\n return new ContextPlugin<ApwContext>(context => {\n if (!context.wcp.canUseFeature(\"advancedPublishingWorkflow\")) {\n return;\n }\n\n context.plugins.register([\n baseSchema,\n workflowSchema,\n contentReviewSchema,\n reviewerSchema,\n commentSchema,\n changeRequestedSchema\n ]);\n });\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,MAAMA,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC;AAEhC,MAAMC,UAAU,GAAG,IAAIC,4BAAmB,CAAC;EACvCC,QAAQ,EAAE,aAAe;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EACDC,SAAS,EAAE;IACPC,KAAK,EAAE;MACHC,GAAG,EAAEN;IACT,CAAC;IACDO,QAAQ,EAAE;MACND,GAAG,EAAEN;IACT;EACJ;AACJ,CAAC,CAAC;AAAC,eAEY,MAAM;EACjB,OAAO,IAAIQ,kBAAa,CAAaC,OAAO,IAAI;IAC5C,IAAI,CAACA,OAAO,CAACC,GAAG,CAACC,aAAa,CAAC,4BAA4B,CAAC,EAAE;MAC1D;IACJ;IAEAF,OAAO,CAACG,OAAO,CAACC,QAAQ,CAAC,CACrBZ,UAAU,EACVa,iBAAc,EACdC,sBAAmB,EACnBC,iBAAc,EACdC,gBAAa,EACbC,sBAAqB,CACxB,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAAA"}
@@ -9,5 +9,5 @@ export interface HandlerArgs {
9
9
  interface Configuration {
10
10
  storageOperations: ApwScheduleActionStorageOperations;
11
11
  }
12
- export declare const executeActionHandlerPlugins: (config: Configuration) => ((import("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin").ValueFilterPlugin[][] | import("@webiny/handler").HandlerResultPlugin<import("@webiny/handler/types").Context> | ContextPlugin<import("@webiny/handler-db/types").DbContext>[])[] | import("@webiny/handler").EventPlugin<HandlerArgs, import("@webiny/handler/types").Context, any> | ContextPlugin<import("@webiny/api/types").Context>)[];
12
+ export declare const executeActionHandlerPlugins: (config: Configuration) => ((import("@webiny/handler").HandlerResultPlugin<import("@webiny/handler/types").Context> | import("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin").ValueFilterPlugin[][] | ContextPlugin<import("@webiny/handler-db/types").DbContext>[])[] | import("@webiny/handler").EventPlugin<HandlerArgs, import("@webiny/handler/types").Context, any> | ContextPlugin<import("@webiny/api/types").Context>)[];
13
13
  export {};
@@ -19,4 +19,4 @@ export interface Configuration {
19
19
  executeAction: string;
20
20
  };
21
21
  }
22
- export declare const scheduleActionHandlerPlugins: (config: Configuration) => ((import("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin").ValueFilterPlugin[][] | import("@webiny/handler").HandlerResultPlugin<import("@webiny/handler/types").Context> | import("@webiny/api").ContextPlugin<import("@webiny/handler-db/types").DbContext>[])[] | import("@webiny/handler-aws").RawEventHandler<HandlerArgs, import("@webiny/handler/types").Context, any>)[];
22
+ export declare const scheduleActionHandlerPlugins: (config: Configuration) => ((import("@webiny/handler").HandlerResultPlugin<import("@webiny/handler/types").Context> | import("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin").ValueFilterPlugin[][] | import("@webiny/api").ContextPlugin<import("@webiny/handler-db/types").DbContext>[])[] | import("@webiny/handler-aws").RawEventHandler<HandlerArgs, import("@webiny/handler/types").Context, any>)[];
@@ -19,7 +19,7 @@ export declare const encodeToken: ({ id, tenant, locale }: EncodeTokenParams) =>
19
19
  export declare const TOKEN_PREFIX = "apw-";
20
20
  export declare const decodeToken: (token: string) => Partial<EncodeTokenParams>;
21
21
  export declare const documentClient: DocumentClient;
22
- export declare const basePlugins: () => (import("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin").ValueFilterPlugin[][] | import("@webiny/handler").HandlerResultPlugin<import("@webiny/handler/types").Context> | import("@webiny/api").ContextPlugin<import("@webiny/handler-db/types").DbContext>[])[];
22
+ export declare const basePlugins: () => (import("@webiny/handler").HandlerResultPlugin<import("@webiny/handler/types").Context> | import("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin").ValueFilterPlugin[][] | import("@webiny/api").ContextPlugin<import("@webiny/handler-db/types").DbContext>[])[];
23
23
  /**
24
24
  * Get APW settings record from DDB.
25
25
  */
@@ -48,7 +48,9 @@ const createWorkflowStorageOperations = params => {
48
48
  async listWorkflows(params) {
49
49
  const model = await getWorkflowModel();
50
50
  security.disableAuthorization();
51
- const [entries, meta] = await cms.listLatestEntries(model, (0, _objectSpread2.default)({}, params));
51
+ const [entries, meta] = await cms.listLatestEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
52
+ where: (0, _objectSpread2.default)({}, params.where || {})
53
+ }));
52
54
  security.enableAuthorization();
53
55
  return [entries.map(entry => (0, _index.getFieldValues)(entry, _index.baseFields)), meta];
54
56
  },
@@ -1 +1 @@
1
- {"version":3,"names":["formatReviewersForRefInput","data","modelId","steps","map","step","reviewers","id","createWorkflowStorageOperations","params","cms","security","getWorkflowModel","disableAuthorization","model","getModel","WORKFLOW_MODEL_ID","enableAuthorization","WebinyError","getWorkflow","entry","getEntryById","getFieldValues","baseFields","listWorkflows","entries","meta","listLatestEntries","createWorkflow","reviewerModel","getReviewerModel","createEntry","updateWorkflow","existingEntry","input","updateEntry","deleteWorkflow","deleteEntry"],"sources":["workflowStorageOperations.ts"],"sourcesContent":["import { CreateApwWorkflowParams } from \"~/types\";\nimport { ApwStorageOperations, ApwWorkflowStorageOperations } from \"./types\";\nimport {\n baseFields,\n CreateApwStorageOperationsParams,\n getFieldValues\n} from \"~/storageOperations/index\";\nimport WebinyError from \"@webiny/error\";\nimport { WORKFLOW_MODEL_ID } from \"~/storageOperations/models/workflow.model\";\n\ntype ReviewersRefInput = CreateApwWorkflowParams<{ modelId: string; id: string }>;\n\nconst formatReviewersForRefInput = (\n data: CreateApwWorkflowParams,\n modelId: string\n): ReviewersRefInput => {\n return {\n ...data,\n steps: data.steps.map(step => ({\n ...step,\n reviewers: step.reviewers.map(id => ({\n id,\n modelId\n }))\n }))\n };\n};\n\nexport const createWorkflowStorageOperations = (\n params: CreateApwStorageOperationsParams\n): ApwWorkflowStorageOperations => {\n const { cms, security } = params;\n const getWorkflowModel = async () => {\n security.disableAuthorization();\n const model = await cms.getModel(WORKFLOW_MODEL_ID);\n security.enableAuthorization();\n if (!model) {\n throw new WebinyError(\n `Could not find \"${WORKFLOW_MODEL_ID}\" model.`,\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n return model;\n };\n const getWorkflow: ApwWorkflowStorageOperations[\"getWorkflow\"] = async ({ id }) => {\n const model = await getWorkflowModel();\n security.disableAuthorization();\n const entry = await cms.getEntryById(model, id);\n security.enableAuthorization();\n return getFieldValues(entry, baseFields);\n };\n return {\n getWorkflowModel,\n getWorkflow,\n async listWorkflows(params) {\n const model = await getWorkflowModel();\n security.disableAuthorization();\n const [entries, meta] = await cms.listLatestEntries(model, {\n ...params\n });\n security.enableAuthorization();\n return [entries.map(entry => getFieldValues(entry, baseFields)), meta];\n },\n async createWorkflow(this: ApwStorageOperations, params) {\n const model = await getWorkflowModel();\n const reviewerModel = await this.getReviewerModel();\n\n const data = formatReviewersForRefInput(params.data, reviewerModel.modelId);\n security.disableAuthorization();\n const entry = await cms.createEntry(model, data);\n security.enableAuthorization();\n\n return getFieldValues(entry, baseFields);\n },\n async updateWorkflow(this: ApwStorageOperations, params) {\n const model = await getWorkflowModel();\n const reviewerModel = await this.getReviewerModel();\n /**\n * We're fetching the existing entry here because we're not accepting \"app\" field as input,\n * but, we still need to retain its value after the \"update\" operation.\n */\n const existingEntry = await getWorkflow({ id: params.id });\n const input = {\n ...existingEntry,\n ...params.data\n };\n const data = formatReviewersForRefInput(\n input as CreateApwWorkflowParams,\n reviewerModel.modelId\n );\n security.disableAuthorization();\n const entry = await cms.updateEntry(model, params.id, data);\n security.enableAuthorization();\n return getFieldValues(entry, baseFields);\n },\n async deleteWorkflow(params) {\n const model = await getWorkflowModel();\n security.disableAuthorization();\n await cms.deleteEntry(model, params.id);\n security.enableAuthorization();\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;;AAEA;AAKA;AACA;AAIA,MAAMA,0BAA0B,GAAG,CAC/BC,IAA6B,EAC7BC,OAAe,KACK;EACpB,mEACOD,IAAI;IACPE,KAAK,EAAEF,IAAI,CAACE,KAAK,CAACC,GAAG,CAACC,IAAI,gEACnBA,IAAI;MACPC,SAAS,EAAED,IAAI,CAACC,SAAS,CAACF,GAAG,CAACG,EAAE,KAAK;QACjCA,EAAE;QACFL;MACJ,CAAC,CAAC;IAAC,EACL;EAAC;AAEX,CAAC;AAEM,MAAMM,+BAA+B,GACxCC,MAAwC,IACT;EAC/B,MAAM;IAAEC,GAAG;IAAEC;EAAS,CAAC,GAAGF,MAAM;EAChC,MA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B,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC"}
1
+ {"version":3,"names":["formatReviewersForRefInput","data","modelId","steps","map","step","reviewers","id","createWorkflowStorageOperations","params","cms","security","getWorkflowModel","disableAuthorization","model","getModel","WORKFLOW_MODEL_ID","enableAuthorization","WebinyError","getWorkflow","entry","getEntryById","getFieldValues","baseFields","listWorkflows","entries","meta","listLatestEntries","where","createWorkflow","reviewerModel","getReviewerModel","createEntry","updateWorkflow","existingEntry","input","updateEntry","deleteWorkflow","deleteEntry"],"sources":["workflowStorageOperations.ts"],"sourcesContent":["import { CreateApwWorkflowParams } from \"~/types\";\nimport { ApwStorageOperations, ApwWorkflowStorageOperations } from \"./types\";\nimport {\n baseFields,\n CreateApwStorageOperationsParams,\n getFieldValues\n} from \"~/storageOperations/index\";\nimport WebinyError from \"@webiny/error\";\nimport { WORKFLOW_MODEL_ID } from \"~/storageOperations/models/workflow.model\";\n\ntype ReviewersRefInput = CreateApwWorkflowParams<{ modelId: string; id: string }>;\n\nconst formatReviewersForRefInput = (\n data: CreateApwWorkflowParams,\n modelId: string\n): ReviewersRefInput => {\n return {\n ...data,\n steps: data.steps.map(step => ({\n ...step,\n reviewers: step.reviewers.map(id => ({\n id,\n modelId\n }))\n }))\n };\n};\n\nexport const createWorkflowStorageOperations = (\n params: CreateApwStorageOperationsParams\n): ApwWorkflowStorageOperations => {\n const { cms, security } = params;\n const getWorkflowModel = async () => {\n security.disableAuthorization();\n const model = await cms.getModel(WORKFLOW_MODEL_ID);\n security.enableAuthorization();\n if (!model) {\n throw new WebinyError(\n `Could not find \"${WORKFLOW_MODEL_ID}\" model.`,\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n return model;\n };\n const getWorkflow: ApwWorkflowStorageOperations[\"getWorkflow\"] = async ({ id }) => {\n const model = await getWorkflowModel();\n security.disableAuthorization();\n const entry = await cms.getEntryById(model, id);\n security.enableAuthorization();\n return getFieldValues(entry, baseFields);\n };\n return {\n getWorkflowModel,\n getWorkflow,\n async listWorkflows(params) {\n const model = await getWorkflowModel();\n security.disableAuthorization();\n const [entries, meta] = await cms.listLatestEntries(model, {\n ...params,\n where: {\n ...(params.where || {})\n }\n });\n security.enableAuthorization();\n return [entries.map(entry => getFieldValues(entry, baseFields)), meta];\n },\n async createWorkflow(this: ApwStorageOperations, params) {\n const model = await getWorkflowModel();\n const reviewerModel = await this.getReviewerModel();\n\n const data = formatReviewersForRefInput(params.data, reviewerModel.modelId);\n security.disableAuthorization();\n const entry = await cms.createEntry(model, data);\n security.enableAuthorization();\n\n return getFieldValues(entry, baseFields);\n },\n async updateWorkflow(this: ApwStorageOperations, params) {\n const model = await getWorkflowModel();\n const reviewerModel = await this.getReviewerModel();\n /**\n * We're fetching the existing entry here because we're not accepting \"app\" field as input,\n * but, we still need to retain its value after the \"update\" operation.\n */\n const existingEntry = await getWorkflow({ id: params.id });\n const input = {\n ...existingEntry,\n ...params.data\n };\n const data = formatReviewersForRefInput(\n input as CreateApwWorkflowParams,\n reviewerModel.modelId\n );\n security.disableAuthorization();\n const entry = await cms.updateEntry(model, params.id, data);\n security.enableAuthorization();\n return getFieldValues(entry, baseFields);\n },\n async deleteWorkflow(params) {\n const model = await getWorkflowModel();\n security.disableAuthorization();\n await cms.deleteEntry(model, params.id);\n security.enableAuthorization();\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;;AAEA;AAKA;AACA;AAIA,MAAMA,0BAA0B,GAAG,CAC/BC,IAA6B,EAC7BC,OAAe,KACK;EACpB,mEACOD,IAAI;IACPE,KAAK,EAAEF,IAAI,CAACE,KAAK,CAACC,GAAG,CAACC,IAAI,gEACnBA,IAAI;MACPC,SAAS,EAAED,IAAI,CAACC,SAAS,CAACF,GAAG,CAACG,EAAE,KAAK;QACjCA,EAAE;QACFL;MACJ,CAAC,CAAC;IAAC,EACL;EAAC;AAEX,CAAC;AAEM,MAAMM,+BAA+B,GACxCC,MAAwC,IACT;EAC/B,MAAM;IAAEC,GAAG;IAAEC;EA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,CAAC4B,WAAW,CAACxB,KAAK,EAAEL,MAAM,CAACF,EAAE,CAAC;MACvCI,QAAQ,CAACM,mBAAmB,EAAE;MAC9B,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC"}
@@ -1,3 +1,3 @@
1
1
  import { Response, ErrorResponse } from "@webiny/handler-graphql";
2
- declare const _default: (fn: () => Promise<any>) => Promise<Response<any> | ErrorResponse>;
2
+ declare const _default: (fn: () => Promise<any>) => Promise<ErrorResponse | Response<any>>;
3
3
  export default _default;