@webiny/api-apw 0.0.0-unstable.cc58a6566b → 0.0.0-unstable.d13302545b

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.
Files changed (54) hide show
  1. package/index.d.ts +1 -1
  2. package/package.json +42 -44
  3. package/plugins/graphql/changeRequest.gql.js +2 -2
  4. package/plugins/graphql/changeRequest.gql.js.map +1 -1
  5. package/plugins/graphql/comment.gql.js +2 -2
  6. package/plugins/graphql/comment.gql.js.map +1 -1
  7. package/plugins/graphql/contentReview.gql.js +5 -5
  8. package/plugins/graphql/contentReview.gql.js.map +1 -1
  9. package/plugins/graphql/reviewer.gql.js +2 -2
  10. package/plugins/graphql/reviewer.gql.js.map +1 -1
  11. package/plugins/graphql/workflow.gql.js +2 -2
  12. package/plugins/graphql/workflow.gql.js.map +1 -1
  13. package/plugins/graphql.js +1 -1
  14. package/plugins/graphql.js.map +1 -1
  15. package/plugins/hooks/notifications/changeRequestAfterCreate.js +3 -8
  16. package/plugins/hooks/notifications/changeRequestAfterCreate.js.map +1 -1
  17. package/plugins/hooks/notifications/commentAfterCreate.js +3 -8
  18. package/plugins/hooks/notifications/commentAfterCreate.js.map +1 -1
  19. package/plugins/hooks/notifications/contentReviewAfterCreate.js +3 -8
  20. package/plugins/hooks/notifications/contentReviewAfterCreate.js.map +1 -1
  21. package/plugins/hooks/notifications/reviewers.js +15 -14
  22. package/plugins/hooks/notifications/reviewers.js.map +1 -1
  23. package/scheduler/createScheduleActionMethods.js +2 -7
  24. package/scheduler/createScheduleActionMethods.js.map +1 -1
  25. package/scheduler/handlers/executeAction/index.d.ts +1 -1
  26. package/scheduler/handlers/executeAction/index.js +27 -6
  27. package/scheduler/handlers/executeAction/index.js.map +1 -1
  28. package/scheduler/handlers/scheduleAction/index.d.ts +1 -1
  29. package/scheduler/handlers/scheduleAction/index.js +5 -1
  30. package/scheduler/handlers/scheduleAction/index.js.map +1 -1
  31. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js +2 -0
  32. package/scheduler/handlers/scheduleAction/scheduleAction.utils.js.map +1 -1
  33. package/scheduler/handlers/utils.d.ts +1 -1
  34. package/scheduler/types.d.ts +2 -20
  35. package/scheduler/types.js +0 -5
  36. package/scheduler/types.js.map +1 -1
  37. package/storageOperations/changeRequestStorageOperations.js +20 -20
  38. package/storageOperations/changeRequestStorageOperations.js.map +1 -1
  39. package/storageOperations/commentStorageOperations.js +23 -23
  40. package/storageOperations/commentStorageOperations.js.map +1 -1
  41. package/storageOperations/contentReviewStorageOperations.js +20 -20
  42. package/storageOperations/contentReviewStorageOperations.js.map +1 -1
  43. package/storageOperations/models/contentModelPluginFactory.d.ts +3 -3
  44. package/storageOperations/models/contentModelPluginFactory.js +4 -3
  45. package/storageOperations/models/contentModelPluginFactory.js.map +1 -1
  46. package/storageOperations/models/index.js +0 -2
  47. package/storageOperations/models/index.js.map +1 -1
  48. package/storageOperations/reviewerStorageOperations.js +23 -28
  49. package/storageOperations/reviewerStorageOperations.js.map +1 -1
  50. package/storageOperations/workflowStorageOperations.js +20 -20
  51. package/storageOperations/workflowStorageOperations.js.map +1 -1
  52. package/types.d.ts +6 -5
  53. package/types.js.map +1 -1
  54. package/utils/resolve.d.ts +1 -1
@@ -16,9 +16,9 @@ const createChangeRequestStorageOperations = params => {
16
16
  security
17
17
  } = params;
18
18
  const getChangeRequestModel = async () => {
19
- security.disableAuthorization();
20
- const model = await cms.getModel("apwChangeRequestModelDefinition");
21
- security.enableAuthorization();
19
+ const model = await security.withoutAuthorization(async () => {
20
+ return cms.getModel("apwChangeRequestModelDefinition");
21
+ });
22
22
  if (!model) {
23
23
  throw new _error.default("Could not find `apwChangeRequestModelDefinition` model.", "MODEL_NOT_FOUND_ERROR");
24
24
  }
@@ -28,9 +28,9 @@ const createChangeRequestStorageOperations = params => {
28
28
  id
29
29
  }) => {
30
30
  const model = await getChangeRequestModel();
31
- security.disableAuthorization();
32
- const entry = await cms.getEntryById(model, id);
33
- security.enableAuthorization();
31
+ const entry = await security.withoutAuthorization(async () => {
32
+ return cms.getEntryById(model, id);
33
+ });
34
34
  return (0, _fieldResolver.getFieldValues)({
35
35
  entry,
36
36
  fields: _index.baseFields,
@@ -43,11 +43,11 @@ const createChangeRequestStorageOperations = params => {
43
43
  getChangeRequest,
44
44
  async listChangeRequests(params) {
45
45
  const model = await getChangeRequestModel();
46
- security.disableAuthorization();
47
- const [entries, meta] = await cms.listLatestEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
48
- where: (0, _objectSpread2.default)({}, params.where)
49
- }));
50
- security.enableAuthorization();
46
+ const [entries, meta] = await security.withoutAuthorization(async () => {
47
+ return cms.listLatestEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
48
+ where: (0, _objectSpread2.default)({}, params.where)
49
+ }));
50
+ });
51
51
  try {
52
52
  const all = await Promise.all(entries.map(entry => (0, _fieldResolver.getFieldValues)({
53
53
  entry,
@@ -62,9 +62,9 @@ const createChangeRequestStorageOperations = params => {
62
62
  },
63
63
  async createChangeRequest(params) {
64
64
  const model = await getChangeRequestModel();
65
- security.disableAuthorization();
66
- const entry = await cms.createEntry(model, params.data);
67
- security.enableAuthorization();
65
+ const entry = await security.withoutAuthorization(async () => {
66
+ return cms.createEntry(model, params.data);
67
+ });
68
68
  return (0, _fieldResolver.getFieldValues)({
69
69
  entry,
70
70
  fields: _index.baseFields,
@@ -81,9 +81,9 @@ const createChangeRequestStorageOperations = params => {
81
81
  const existingEntry = await getChangeRequest({
82
82
  id: params.id
83
83
  });
84
- security.disableAuthorization();
85
- const entry = await cms.updateEntry(model, params.id, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, existingEntry), params.data));
86
- security.enableAuthorization();
84
+ const entry = await security.withoutAuthorization(async () => {
85
+ return cms.updateEntry(model, params.id, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, existingEntry), params.data));
86
+ });
87
87
  return (0, _fieldResolver.getFieldValues)({
88
88
  entry,
89
89
  fields: _index.baseFields,
@@ -93,9 +93,9 @@ const createChangeRequestStorageOperations = params => {
93
93
  },
94
94
  async deleteChangeRequest(params) {
95
95
  const model = await getChangeRequestModel();
96
- security.disableAuthorization();
97
- await cms.deleteEntry(model, params.id);
98
- security.enableAuthorization();
96
+ await security.withoutAuthorization(async () => {
97
+ return cms.deleteEntry(model, params.id);
98
+ });
99
99
  return true;
100
100
  }
101
101
  };
@@ -1 +1 @@
1
- {"version":3,"names":["createChangeRequestStorageOperations","params","cms","getCmsContext","security","getChangeRequestModel","disableAuthorization","model","getModel","enableAuthorization","WebinyError","getChangeRequest","id","entry","getEntryById","getFieldValues","fields","baseFields","context","transformers","getTransformer","listChangeRequests","entries","meta","listLatestEntries","where","all","Promise","map","ex","message","code","data","createChangeRequest","createEntry","updateChangeRequest","existingEntry","updateEntry","deleteChangeRequest","deleteEntry"],"sources":["changeRequestStorageOperations.ts"],"sourcesContent":["import { ApwChangeRequestStorageOperations } from \"./types\";\nimport { baseFields, CreateApwStorageOperationsParams } from \"~/storageOperations/index\";\nimport { getFieldValues, getTransformer } from \"~/utils/fieldResolver\";\nimport WebinyError from \"@webiny/error\";\nimport { ApwChangeRequest } from \"~/types\";\n\nexport const createChangeRequestStorageOperations = (\n params: CreateApwStorageOperationsParams\n): ApwChangeRequestStorageOperations => {\n const { cms, getCmsContext, security } = params;\n const getChangeRequestModel = async () => {\n security.disableAuthorization();\n const model = await cms.getModel(\"apwChangeRequestModelDefinition\");\n security.enableAuthorization();\n if (!model) {\n throw new WebinyError(\n \"Could not find `apwChangeRequestModelDefinition` model.\",\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n return model;\n };\n const getChangeRequest: ApwChangeRequestStorageOperations[\"getChangeRequest\"] = async ({\n id\n }) => {\n const model = await getChangeRequestModel();\n security.disableAuthorization();\n const entry = await cms.getEntryById(model, id);\n security.enableAuthorization();\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n };\n return {\n getChangeRequestModel,\n getChangeRequest,\n async listChangeRequests(params) {\n const model = await getChangeRequestModel();\n security.disableAuthorization();\n const [entries, meta] = await cms.listLatestEntries(model, {\n ...params,\n where: {\n ...params.where\n }\n });\n security.enableAuthorization();\n try {\n const all = await Promise.all(\n entries.map(entry =>\n getFieldValues<ApwChangeRequest>({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n })\n )\n );\n return [all, meta];\n } catch (ex) {\n throw new WebinyError(ex.message, ex.code, ex.data);\n }\n },\n async createChangeRequest(params) {\n const model = await getChangeRequestModel();\n security.disableAuthorization();\n const entry = await cms.createEntry(model, params.data);\n security.enableAuthorization();\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n },\n async updateChangeRequest(params) {\n const model = await getChangeRequestModel();\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 getChangeRequest({ id: params.id });\n\n security.disableAuthorization();\n const entry = await cms.updateEntry(model, params.id, {\n ...existingEntry,\n ...params.data\n });\n security.enableAuthorization();\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n },\n async deleteChangeRequest(params) {\n const model = await getChangeRequestModel();\n security.disableAuthorization();\n await cms.deleteEntry(model, params.id);\n security.enableAuthorization();\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;;AACA;AACA;AACA;AAGO,MAAMA,oCAAoC,GAC7CC,MAAwC,IACJ;EACpC,MAAM;IAAEC,GAAG;IAAEC,aAAa;IAAEC;EAAS,CAAC,GAAGH,MAAM;EAC/C,MAAMI,qBAAqB,GAAG,YAAY;IACtCD,QAAQ,CAACE,oBAAoB,EAAE;IAC/B,MAAMC,KAAK,GAAG,MAAML,GAAG,CAACM,QAAQ,CAAC,iCAAiC,CAAC;IACnEJ,QA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f,aAAa,EAAE;QACxBgB,YAAY,EAAE,CAAC,IAAAC,6BAAc,EAACb,KAAK,EAAE,MAAM,CAAC;MAChD,CAAC,CAAC;IACN,CAAC;IACD,MAAM+B,mBAAmB,CAACrC,MAAM,EAAE;MAC9B,MAAMM,KAAK,GAAG,MAAMF,qBAAqB,EAAE;MAC3CD,QAAQ,CAACE,oBAAoB,EAAE;MAC/B,MAAMJ,GAAG,CAACqC,WAAW,CAAChC,KAAK,EAAEN,MAAM,CAACW,EAAE,CAAC;MACvCR,QAAQ,CAACK,mBAAmB,EAAE;MAC9B,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC"}
1
+ {"version":3,"names":["createChangeRequestStorageOperations","params","cms","getCmsContext","security","getChangeRequestModel","model","withoutAuthorization","getModel","WebinyError","getChangeRequest","id","entry","getEntryById","getFieldValues","fields","baseFields","context","transformers","getTransformer","listChangeRequests","entries","meta","listLatestEntries","where","all","Promise","map","ex","message","code","data","createChangeRequest","createEntry","updateChangeRequest","existingEntry","updateEntry","deleteChangeRequest","deleteEntry"],"sources":["changeRequestStorageOperations.ts"],"sourcesContent":["import { ApwChangeRequestStorageOperations } from \"./types\";\nimport { baseFields, CreateApwStorageOperationsParams } from \"~/storageOperations/index\";\nimport { getFieldValues, getTransformer } from \"~/utils/fieldResolver\";\nimport WebinyError from \"@webiny/error\";\nimport { ApwChangeRequest } from \"~/types\";\n\nexport const createChangeRequestStorageOperations = (\n params: CreateApwStorageOperationsParams\n): ApwChangeRequestStorageOperations => {\n const { cms, getCmsContext, security } = params;\n const getChangeRequestModel = async () => {\n const model = await security.withoutAuthorization(async () => {\n return cms.getModel(\"apwChangeRequestModelDefinition\");\n });\n if (!model) {\n throw new WebinyError(\n \"Could not find `apwChangeRequestModelDefinition` model.\",\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n return model;\n };\n const getChangeRequest: ApwChangeRequestStorageOperations[\"getChangeRequest\"] = async ({\n id\n }) => {\n const model = await getChangeRequestModel();\n\n const entry = await security.withoutAuthorization(async () => {\n return cms.getEntryById(model, id);\n });\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n };\n return {\n getChangeRequestModel,\n getChangeRequest,\n async listChangeRequests(params) {\n const model = await getChangeRequestModel();\n\n const [entries, meta] = await security.withoutAuthorization(async () => {\n return cms.listLatestEntries(model, {\n ...params,\n where: {\n ...params.where\n }\n });\n });\n try {\n const all = await Promise.all(\n entries.map(entry =>\n getFieldValues<ApwChangeRequest>({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n })\n )\n );\n return [all, meta];\n } catch (ex) {\n throw new WebinyError(ex.message, ex.code, ex.data);\n }\n },\n async createChangeRequest(params) {\n const model = await getChangeRequestModel();\n\n const entry = await security.withoutAuthorization(async () => {\n return cms.createEntry(model, params.data);\n });\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n },\n async updateChangeRequest(params) {\n const model = await getChangeRequestModel();\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 getChangeRequest({ id: params.id });\n\n const entry = await security.withoutAuthorization(async () => {\n return cms.updateEntry(model, params.id, {\n ...existingEntry,\n ...params.data\n });\n });\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n },\n async deleteChangeRequest(params) {\n const model = await getChangeRequestModel();\n\n await security.withoutAuthorization(async () => {\n return cms.deleteEntry(model, params.id);\n });\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;;AACA;AACA;AACA;AAGO,MAAMA,oCAAoC,GAC7CC,MAAwC,IACJ;EACpC,MAAM;IAAEC,GAAG;IAAEC,aAAa;IAAEC;EAAS,CAAC,GAAGH,MAAM;EAC/C,MAAMI,qBAAqB,GAAG,YAAY;IACtC,MAA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AAc,EAAC;QAClBF,KAAK;QACLG,MAAM,EAAEC,iBAAU;QAClBC,OAAO,EAAEd,aAAa,EAAE;QACxBe,YAAY,EAAE,CAAC,IAAAC,6BAAc,EAACb,KAAK,EAAE,MAAM,CAAC;MAChD,CAAC,CAAC;IACN,CAAC;IACD,MAAM+B,mBAAmB,CAACpC,MAAM,EAAE;MAC9B,MAAMK,KAAK,GAAG,MAAMD,qBAAqB,EAAE;MAE3C,MAAMD,QAAQ,CAACG,oBAAoB,CAAC,YAAY;QAC5C,OAAOL,GAAG,CAACoC,WAAW,CAAChC,KAAK,EAAEL,MAAM,CAACU,EAAE,CAAC;MAC5C,CAAC,CAAC;MACF,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC"}
@@ -24,9 +24,9 @@ const createCommentStorageOperations = ({
24
24
  security
25
25
  }) => {
26
26
  const getCommentModel = async () => {
27
- security.disableAuthorization();
28
- const model = await cms.getModel(_comment.COMMENT_MODEL_ID);
29
- security.enableAuthorization();
27
+ const model = await security.withoutAuthorization(async () => {
28
+ return cms.getModel(_comment.COMMENT_MODEL_ID);
29
+ });
30
30
  if (!model) {
31
31
  throw new _error.default(`Could not find "${_comment.COMMENT_MODEL_ID}" model.`, "MODEL_NOT_FOUND_ERROR");
32
32
  }
@@ -36,9 +36,9 @@ const createCommentStorageOperations = ({
36
36
  id
37
37
  }) => {
38
38
  const model = await getCommentModel();
39
- security.disableAuthorization();
40
- const entry = await cms.getEntryById(model, id);
41
- security.enableAuthorization();
39
+ const entry = await security.withoutAuthorization(async () => {
40
+ return cms.getEntryById(model, id);
41
+ });
42
42
  return (0, _fieldResolver.getFieldValues)({
43
43
  entry,
44
44
  fields: _index.baseFields,
@@ -54,9 +54,9 @@ const createCommentStorageOperations = ({
54
54
  },
55
55
  async listComments(params) {
56
56
  const model = await getCommentModel();
57
- security.disableAuthorization();
58
- const [entries, meta] = await cms.listLatestEntries(model, params);
59
- security.enableAuthorization();
57
+ const [entries, meta] = await security.withoutAuthorization(async () => {
58
+ return cms.listLatestEntries(model, params);
59
+ });
60
60
  const values = await Promise.all(entries.map(entry => (0, _fieldResolver.getFieldValues)({
61
61
  entry,
62
62
  fields: _index.baseFields,
@@ -69,14 +69,14 @@ const createCommentStorageOperations = ({
69
69
  async createComment(params) {
70
70
  const model = await getCommentModel();
71
71
  const refModel = await this.getChangeRequestModel();
72
- security.disableAuthorization();
73
- const entry = await cms.createEntry(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params.data), {}, {
74
- changeRequest: {
75
- id: params.data.changeRequest,
76
- modelId: refModel.modelId
77
- }
78
- }));
79
- security.enableAuthorization();
72
+ const entry = await security.withoutAuthorization(async () => {
73
+ return cms.createEntry(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params.data), {}, {
74
+ changeRequest: {
75
+ id: params.data.changeRequest,
76
+ modelId: refModel.modelId
77
+ }
78
+ }));
79
+ });
80
80
  const values = await (0, _fieldResolver.getFieldValues)({
81
81
  entry,
82
82
  fields: _index.baseFields,
@@ -94,9 +94,9 @@ const createCommentStorageOperations = ({
94
94
  const existingEntry = await getComment({
95
95
  id: params.id
96
96
  });
97
- security.disableAuthorization();
98
- const entry = await cms.updateEntry(model, params.id, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, existingEntry), params.data));
99
- security.enableAuthorization();
97
+ const entry = await security.withoutAuthorization(async () => {
98
+ return cms.updateEntry(model, params.id, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, existingEntry), params.data));
99
+ });
100
100
  const values = await (0, _fieldResolver.getFieldValues)({
101
101
  entry,
102
102
  fields: _index.baseFields,
@@ -107,9 +107,9 @@ const createCommentStorageOperations = ({
107
107
  },
108
108
  async deleteComment(params) {
109
109
  const model = await getCommentModel();
110
- security.disableAuthorization();
111
- await cms.deleteEntry(model, params.id);
112
- security.enableAuthorization();
110
+ await security.withoutAuthorization(async () => {
111
+ return cms.deleteEntry(model, params.id);
112
+ });
113
113
  return true;
114
114
  }
115
115
  };
@@ -1 +1 @@
1
- {"version":3,"names":["pickIdFromChangeRequest","obj","rawValue","id","createCommentStorageOperations","cms","getCmsContext","security","getCommentModel","disableAuthorization","model","getModel","COMMENT_MODEL_ID","enableAuthorization","WebinyError","getComment","entry","getEntryById","getFieldValues","fields","baseFields","context","transformers","getTransformer","params","values","listComments","entries","meta","listLatestEntries","Promise","all","map","value","createComment","refModel","getChangeRequestModel","createEntry","data","changeRequest","modelId","updateComment","existingEntry","updateEntry","deleteComment","deleteEntry"],"sources":["commentStorageOperations.ts"],"sourcesContent":["import { ApwStorageOperations } from \"./types\";\nimport { ApwCommentStorageOperations } from \"./types\";\nimport { baseFields, CreateApwStorageOperationsParams } from \"~/storageOperations/index\";\nimport { getFieldValues, getTransformer } from \"~/utils/fieldResolver\";\nimport WebinyError from \"@webiny/error\";\nimport { ApwComment } from \"~/types\";\nimport { CmsEntryListParams } from \"@webiny/api-headless-cms/types\";\nimport { COMMENT_MODEL_ID } from \"~/storageOperations/models/comment.model\";\n\nconst pickIdFromChangeRequest = (obj: Record<string, any>): ApwComment => {\n const rawValue = obj[\"changeRequest\"];\n if (!rawValue) {\n return obj as unknown as ApwComment;\n }\n obj[\"changeRequest\"] = rawValue.id;\n return obj as unknown as ApwComment;\n};\n\nexport const createCommentStorageOperations = ({\n cms,\n getCmsContext,\n security\n}: CreateApwStorageOperationsParams): ApwCommentStorageOperations => {\n const getCommentModel = async () => {\n security.disableAuthorization();\n const model = await cms.getModel(COMMENT_MODEL_ID);\n security.enableAuthorization();\n if (!model) {\n throw new WebinyError(\n `Could not find \"${COMMENT_MODEL_ID}\" model.`,\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n return model;\n };\n const getComment: ApwCommentStorageOperations[\"getComment\"] = async ({ id }) => {\n const model = await getCommentModel();\n security.disableAuthorization();\n const entry = await cms.getEntryById(model, id);\n security.enableAuthorization();\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n };\n return {\n getCommentModel,\n getComment: async params => {\n const values = await getComment(params);\n return pickIdFromChangeRequest(values);\n },\n async listComments(params) {\n const model = await getCommentModel();\n security.disableAuthorization();\n const [entries, meta] = await cms.listLatestEntries(\n model,\n params as CmsEntryListParams\n );\n security.enableAuthorization();\n const values = await Promise.all(\n entries.map(entry =>\n getFieldValues<ApwComment>({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n })\n )\n );\n const all = values.map(value => pickIdFromChangeRequest(value));\n return [all, meta];\n },\n async createComment(this: ApwStorageOperations, params) {\n const model = await getCommentModel();\n const refModel = await this.getChangeRequestModel();\n security.disableAuthorization();\n const entry = await cms.createEntry(model, {\n ...params.data,\n changeRequest: {\n id: params.data.changeRequest,\n modelId: refModel.modelId\n }\n });\n security.enableAuthorization();\n\n const values = await getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n return pickIdFromChangeRequest(values);\n },\n async updateComment(params) {\n const model = await getCommentModel();\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 getComment({ id: params.id });\n\n security.disableAuthorization();\n const entry = await cms.updateEntry(model, params.id, {\n ...existingEntry,\n ...params.data\n });\n security.enableAuthorization();\n const values = await getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n return pickIdFromChangeRequest(values);\n },\n async deleteComment(params) {\n const model = await getCommentModel();\n security.disableAuthorization();\n await cms.deleteEntry(model, params.id);\n security.enableAuthorization();\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;;AAEA;AACA;AACA;AAGA;AAEA,MAAMA,uBAAuB,GAAIC,GAAwB,IAAiB;EACtE,MAAMC,QAAQ,GAAGD,GAAG,CAAC,eAAe,CAAC;EACrC,IAAI,CAACC,QAAQ,EAAE;IACX,OAAOD,GAAG;EACd;EACAA,GAAG,C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MACF,OAAOV,uBAAuB,CAACyB,MAAM,CAAC;IAC1C,CAAC;IACD,MAAMgB,aAAa,CAACjB,MAAM,EAAE;MACxB,MAAMd,KAAK,GAAG,MAAMF,eAAe,EAAE;MACrC;AACZ;AACA;AACA;MACY,MAAMkC,aAAa,GAAG,MAAM3B,UAAU,CAAC;QAAEZ,EAAE,EAAEqB,MAAM,CAACrB;MAAG,CAAC,CAAC;MAEzDI,QAAQ,CAACE,oBAAoB,EAAE;MAC/B,MAAMO,KAAK,GAAG,MAAMX,GAAG,CAACsC,WAAW,CAACjC,KAAK,EAAEc,MAAM,CAACrB,EAAE,8DAC7CuC,aAAa,GACblB,MAAM,CAACc,IAAI,EAChB;MACF/B,QAAQ,CAACM,mBAAmB,EAAE;MAC9B,MAAMY,MAAM,GAAG,MAAM,IAAAP,6BAAc,EAAC;QAChCF,KAAK;QACLG,MAAM,EAAEC,iBAAU;QAClBC,OAAO,EAAEf,aAAa,EAAE;QACxBgB,YAAY,EAAE,CAAC,IAAAC,6BAAc,EAACb,KAAK,EAAE,MAAM,CAAC;MAChD,CAAC,CAAC;MACF,OAAOV,uBAAuB,CAACyB,MAAM,CAAC;IAC1C,CAAC;IACD,MAAMmB,aAAa,CAACpB,MAAM,EAAE;MACxB,MAAMd,KAAK,GAAG,MAAMF,eAAe,EAAE;MACrCD,QAAQ,CAACE,oBAAoB,EAAE;MAC/B,MAAMJ,GAAG,CAACwC,WAAW,CAACnC,KAAK,EAAEc,MAAM,CAACrB,EAAE,CAAC;MACvCI,QAAQ,CAACM,mBAAmB,EAAE;MAC9B,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC"}
1
+ {"version":3,"names":["pickIdFromChangeRequest","obj","rawValue","id","createCommentStorageOperations","cms","getCmsContext","security","getCommentModel","model","withoutAuthorization","getModel","COMMENT_MODEL_ID","WebinyError","getComment","entry","getEntryById","getFieldValues","fields","baseFields","context","transformers","getTransformer","params","values","listComments","entries","meta","listLatestEntries","Promise","all","map","value","createComment","refModel","getChangeRequestModel","createEntry","data","changeRequest","modelId","updateComment","existingEntry","updateEntry","deleteComment","deleteEntry"],"sources":["commentStorageOperations.ts"],"sourcesContent":["import { ApwStorageOperations } from \"./types\";\nimport { ApwCommentStorageOperations } from \"./types\";\nimport { baseFields, CreateApwStorageOperationsParams } from \"~/storageOperations/index\";\nimport { getFieldValues, getTransformer } from \"~/utils/fieldResolver\";\nimport WebinyError from \"@webiny/error\";\nimport { ApwComment } from \"~/types\";\nimport { CmsEntryListParams } from \"@webiny/api-headless-cms/types\";\nimport { COMMENT_MODEL_ID } from \"~/storageOperations/models/comment.model\";\n\nconst pickIdFromChangeRequest = (obj: Record<string, any>): ApwComment => {\n const rawValue = obj[\"changeRequest\"];\n if (!rawValue) {\n return obj as unknown as ApwComment;\n }\n obj[\"changeRequest\"] = rawValue.id;\n return obj as unknown as ApwComment;\n};\n\nexport const createCommentStorageOperations = ({\n cms,\n getCmsContext,\n security\n}: CreateApwStorageOperationsParams): ApwCommentStorageOperations => {\n const getCommentModel = async () => {\n const model = await security.withoutAuthorization(async () => {\n return cms.getModel(COMMENT_MODEL_ID);\n });\n\n if (!model) {\n throw new WebinyError(\n `Could not find \"${COMMENT_MODEL_ID}\" model.`,\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n return model;\n };\n const getComment: ApwCommentStorageOperations[\"getComment\"] = async ({ id }) => {\n const model = await getCommentModel();\n const entry = await security.withoutAuthorization(async () => {\n return cms.getEntryById(model, id);\n });\n\n return getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n };\n return {\n getCommentModel,\n getComment: async params => {\n const values = await getComment(params);\n return pickIdFromChangeRequest(values);\n },\n async listComments(params) {\n const model = await getCommentModel();\n const [entries, meta] = await security.withoutAuthorization(async () => {\n return cms.listLatestEntries(model, params as CmsEntryListParams);\n });\n const values = await Promise.all(\n entries.map(entry =>\n getFieldValues<ApwComment>({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n })\n )\n );\n const all = values.map(value => pickIdFromChangeRequest(value));\n return [all, meta];\n },\n async createComment(this: ApwStorageOperations, params) {\n const model = await getCommentModel();\n const refModel = await this.getChangeRequestModel();\n\n const entry = await security.withoutAuthorization(async () => {\n return cms.createEntry(model, {\n ...params.data,\n changeRequest: {\n id: params.data.changeRequest,\n modelId: refModel.modelId\n }\n });\n });\n\n const values = await getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n return pickIdFromChangeRequest(values);\n },\n async updateComment(params) {\n const model = await getCommentModel();\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 getComment({ id: params.id });\n\n const entry = await security.withoutAuthorization(async () => {\n return cms.updateEntry(model, params.id, {\n ...existingEntry,\n ...params.data\n });\n });\n\n const values = await getFieldValues({\n entry,\n fields: baseFields,\n context: getCmsContext(),\n transformers: [getTransformer(model, \"body\")]\n });\n return pickIdFromChangeRequest(values);\n },\n async deleteComment(params) {\n const model = await getCommentModel();\n await security.withoutAuthorization(async () => {\n return cms.deleteEntry(model, params.id);\n });\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;;AAEA;AACA;AACA;AAGA;AAEA,MAAMA,uBAAuB,GAAIC,GAAwB,IAAiB;EACtE,MAAMC,QAAQ,GAAGD,GAAG,CAAC,eAAe,CAAC;EACrC,IAAI,CAACC,QAAQ,EAAE;IACX,OAAOD,GAAG;EACd;EACAA,GAAG,CAAC,eAAe,CAAC,GAAGC,QAAQ,CAACC,EAAE;EAClC,OAAOF,GAAG;AACd,CAAC;AAEM,MAAMG,8BAA8B,GAAG,CAAC;EAC3CC,GAAG;EACHC,aAAa;EACbC;AAC8B,CAAC,KAAkC;EACjE,MAAMC,eAAe,GAAG,YAAY;IAChC,MAAMC,KAAK,GAAG,MAAMF,QAAQ,CAACG,oBAAoB,C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,GAAG,MAAMR,QAAQ,CAACG,oBAAoB,CAAC,YAAY;QAC1D,OAAOL,GAAG,CAACqC,WAAW,CAACjC,KAAK,EAAEc,MAAM,CAACpB,EAAE,8DAChCsC,aAAa,GACblB,MAAM,CAACc,IAAI,EAChB;MACN,CAAC,CAAC;MAEF,MAAMb,MAAM,GAAG,MAAM,IAAAP,6BAAc,EAAC;QAChCF,KAAK;QACLG,MAAM,EAAEC,iBAAU;QAClBC,OAAO,EAAEd,aAAa,EAAE;QACxBe,YAAY,EAAE,CAAC,IAAAC,6BAAc,EAACb,KAAK,EAAE,MAAM,CAAC;MAChD,CAAC,CAAC;MACF,OAAOT,uBAAuB,CAACwB,MAAM,CAAC;IAC1C,CAAC;IACD,MAAMmB,aAAa,CAACpB,MAAM,EAAE;MACxB,MAAMd,KAAK,GAAG,MAAMD,eAAe,EAAE;MACrC,MAAMD,QAAQ,CAACG,oBAAoB,CAAC,YAAY;QAC5C,OAAOL,GAAG,CAACuC,WAAW,CAACnC,KAAK,EAAEc,MAAM,CAACpB,EAAE,CAAC;MAC5C,CAAC,CAAC;MACF,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC"}
@@ -14,9 +14,9 @@ const createContentReviewStorageOperations = ({
14
14
  security
15
15
  }) => {
16
16
  const getContentReviewModel = async () => {
17
- security.disableAuthorization();
18
- const model = await cms.getModel(_contentReview.CONTENT_REVIEW_MODEL_ID);
19
- security.enableAuthorization();
17
+ const model = await security.withoutAuthorization(async () => {
18
+ return cms.getModel(_contentReview.CONTENT_REVIEW_MODEL_ID);
19
+ });
20
20
  if (!model) {
21
21
  throw new _error.default(`Could not find "${_contentReview.CONTENT_REVIEW_MODEL_ID}" model.`, "MODEL_NOT_FOUND_ERROR");
22
22
  }
@@ -26,9 +26,9 @@ const createContentReviewStorageOperations = ({
26
26
  id
27
27
  }) => {
28
28
  const model = await getContentReviewModel();
29
- security.disableAuthorization();
30
- const entry = await cms.getEntryById(model, id);
31
- security.enableAuthorization();
29
+ const entry = await security.withoutAuthorization(async () => {
30
+ return cms.getEntryById(model, id);
31
+ });
32
32
  return (0, _index.getFieldValues)(entry, _index.baseFields);
33
33
  };
34
34
  return {
@@ -36,18 +36,18 @@ const createContentReviewStorageOperations = ({
36
36
  getContentReview,
37
37
  async listContentReviews(params) {
38
38
  const model = await getContentReviewModel();
39
- security.disableAuthorization();
40
- const [entries, meta] = await cms.listLatestEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
41
- where: (0, _objectSpread2.default)({}, params.where)
42
- }));
43
- security.enableAuthorization();
39
+ const [entries, meta] = await security.withoutAuthorization(async () => {
40
+ return cms.listLatestEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
41
+ where: (0, _objectSpread2.default)({}, params.where)
42
+ }));
43
+ });
44
44
  return [entries.map(entry => (0, _index.getFieldValues)(entry, _index.baseFields)), meta];
45
45
  },
46
46
  async createContentReview(params) {
47
47
  const model = await getContentReviewModel();
48
- security.disableAuthorization();
49
- const entry = await cms.createEntry(model, params.data);
50
- security.enableAuthorization();
48
+ const entry = await security.withoutAuthorization(async () => {
49
+ return cms.createEntry(model, params.data);
50
+ });
51
51
  return (0, _index.getFieldValues)(entry, _index.baseFields);
52
52
  },
53
53
  async updateContentReview(params) {
@@ -59,16 +59,16 @@ const createContentReviewStorageOperations = ({
59
59
  const existingEntry = await getContentReview({
60
60
  id: params.id
61
61
  });
62
- security.disableAuthorization();
63
- const entry = await cms.updateEntry(model, params.id, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, existingEntry), params.data));
64
- security.enableAuthorization();
62
+ const entry = await security.withoutAuthorization(async () => {
63
+ return cms.updateEntry(model, params.id, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, existingEntry), params.data));
64
+ });
65
65
  return (0, _index.getFieldValues)(entry, _index.baseFields);
66
66
  },
67
67
  async deleteContentReview(params) {
68
68
  const model = await getContentReviewModel();
69
- security.disableAuthorization();
70
- await cms.deleteEntry(model, params.id);
71
- security.enableAuthorization();
69
+ await security.withoutAuthorization(async () => {
70
+ return cms.deleteEntry(model, params.id);
71
+ });
72
72
  return true;
73
73
  }
74
74
  };
@@ -1 +1 @@
1
- {"version":3,"names":["createContentReviewStorageOperations","cms","security","getContentReviewModel","disableAuthorization","model","getModel","CONTENT_REVIEW_MODEL_ID","enableAuthorization","WebinyError","getContentReview","id","entry","getEntryById","getFieldValues","baseFields","listContentReviews","params","entries","meta","listLatestEntries","where","map","createContentReview","createEntry","data","updateContentReview","existingEntry","updateEntry","deleteContentReview","deleteEntry"],"sources":["contentReviewStorageOperations.ts"],"sourcesContent":["import { ApwContentReviewStorageOperations } from \"./types\";\nimport {\n baseFields,\n CreateApwStorageOperationsParams,\n getFieldValues\n} from \"~/storageOperations/index\";\nimport WebinyError from \"@webiny/error\";\nimport { CONTENT_REVIEW_MODEL_ID } from \"~/storageOperations/models/contentReview.model\";\n\nexport const createContentReviewStorageOperations = ({\n cms,\n security\n}: CreateApwStorageOperationsParams): ApwContentReviewStorageOperations => {\n const getContentReviewModel = async () => {\n security.disableAuthorization();\n const model = await cms.getModel(CONTENT_REVIEW_MODEL_ID);\n security.enableAuthorization();\n if (!model) {\n throw new WebinyError(\n `Could not find \"${CONTENT_REVIEW_MODEL_ID}\" model.`,\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n return model;\n };\n const getContentReview: ApwContentReviewStorageOperations[\"getContentReview\"] = async ({\n id\n }) => {\n const model = await getContentReviewModel();\n security.disableAuthorization();\n const entry = await cms.getEntryById(model, id);\n security.enableAuthorization();\n return getFieldValues(entry, baseFields);\n };\n return {\n getContentReviewModel,\n getContentReview,\n async listContentReviews(params) {\n const model = await getContentReviewModel();\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 createContentReview(params) {\n const model = await getContentReviewModel();\n security.disableAuthorization();\n const entry = await cms.createEntry(model, params.data);\n security.enableAuthorization();\n return getFieldValues(entry, baseFields);\n },\n async updateContentReview(params) {\n const model = await getContentReviewModel();\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 getContentReview({ id: params.id });\n\n security.disableAuthorization();\n const entry = await cms.updateEntry(model, params.id, {\n ...existingEntry,\n ...params.data\n });\n security.enableAuthorization();\n return getFieldValues(entry, baseFields);\n },\n async deleteContentReview(params) {\n const model = await getContentReviewModel();\n security.disableAuthorization();\n await cms.deleteEntry(model, params.id);\n security.enableAuthorization();\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;;AACA;AAKA;AACA;AAEO,MAAMA,oCAAoC,GAAG,CAAC;EACjDC,GAAG;EACHC;AAC8B,CAAC,KAAwC;EACvE,MAAMC,qBAAqB,GAAG,YAAY;IACtCD,QAAQ,CAACE,oBAAoB,EAAE;IAC/B,MAAMC,KAAK,GAAG,MAAMJ,GAAG,CAACK,QAAQ,CAACC,sCAAuB,CAAC;IACzDL,QAAQ,CAACM,mBAAmB,EAAE;IAC9B,IAAI,CAACH,KAAK,EAAE;MACR,MAAM,IAAII,cAAW,CAChB,mBAAkBF,sCAAwB,UAAS,EACpD,uBAAuB,CAC1B;IACL;IACA,OAAOF,KAAK;EAChB,CAAC;EACD,MAAMK,gBAAuE,GAAG,OAAO;IACnFC;EACJ,CAAC,KAAK;IACF,MAAMN,KAAK,GAAG,MAAMF,qBAAqB,EAAE;IAC3CD,QAAQ,CAACE,oBAAoB,EAAE;IAC/B,MAAMQ,KAAK,GAAG,MAAMX,GAAG,CAACY,YAAY,CAACR,KAAK,EAAEM,EAAE,CAAC;IAC/CT,QAAQ,CAACM,mBAAmB,EAAE;IAC9B,OAAO,IAAAM,qBAAc,EAACF,KAAK,EAAEG,iBAAU,CAAC;EAC5C,CAAC;EACD,OAAO;IACHZ,qBAAqB;IACrBO,gBAAgB;IAChB,MAAM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ACF,KAAK,EAAEG,iBAAU,CAAC;IAC5C,CAAC;IACD,MAAMc,mBAAmB,CAACZ,MAAM,EAAE;MAC9B,MAAMZ,KAAK,GAAG,MAAMF,qBAAqB,EAAE;MAC3CD,QAAQ,CAACE,oBAAoB,EAAE;MAC/B,MAAMH,GAAG,CAAC6B,WAAW,CAACzB,KAAK,EAAEY,MAAM,CAACN,EAAE,CAAC;MACvCT,QAAQ,CAACM,mBAAmB,EAAE;MAC9B,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC"}
1
+ {"version":3,"names":["createContentReviewStorageOperations","cms","security","getContentReviewModel","model","withoutAuthorization","getModel","CONTENT_REVIEW_MODEL_ID","WebinyError","getContentReview","id","entry","getEntryById","getFieldValues","baseFields","listContentReviews","params","entries","meta","listLatestEntries","where","map","createContentReview","createEntry","data","updateContentReview","existingEntry","updateEntry","deleteContentReview","deleteEntry"],"sources":["contentReviewStorageOperations.ts"],"sourcesContent":["import { ApwContentReviewStorageOperations } from \"./types\";\nimport {\n baseFields,\n CreateApwStorageOperationsParams,\n getFieldValues\n} from \"~/storageOperations/index\";\nimport WebinyError from \"@webiny/error\";\nimport { CONTENT_REVIEW_MODEL_ID } from \"~/storageOperations/models/contentReview.model\";\n\nexport const createContentReviewStorageOperations = ({\n cms,\n security\n}: CreateApwStorageOperationsParams): ApwContentReviewStorageOperations => {\n const getContentReviewModel = async () => {\n const model = await security.withoutAuthorization(async () => {\n return cms.getModel(CONTENT_REVIEW_MODEL_ID);\n });\n if (!model) {\n throw new WebinyError(\n `Could not find \"${CONTENT_REVIEW_MODEL_ID}\" model.`,\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n return model;\n };\n const getContentReview: ApwContentReviewStorageOperations[\"getContentReview\"] = async ({\n id\n }) => {\n const model = await getContentReviewModel();\n const entry = await security.withoutAuthorization(async () => {\n return cms.getEntryById(model, id);\n });\n return getFieldValues(entry, baseFields);\n };\n return {\n getContentReviewModel,\n getContentReview,\n async listContentReviews(params) {\n const model = await getContentReviewModel();\n\n const [entries, meta] = await security.withoutAuthorization(async () => {\n return cms.listLatestEntries(model, {\n ...params,\n where: {\n ...params.where\n }\n });\n });\n\n return [entries.map(entry => getFieldValues(entry, baseFields)), meta];\n },\n async createContentReview(params) {\n const model = await getContentReviewModel();\n\n const entry = await security.withoutAuthorization(async () => {\n return cms.createEntry(model, params.data);\n });\n return getFieldValues(entry, baseFields);\n },\n async updateContentReview(params) {\n const model = await getContentReviewModel();\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 getContentReview({ id: params.id });\n\n const entry = await security.withoutAuthorization(async () => {\n return cms.updateEntry(model, params.id, {\n ...existingEntry,\n ...params.data\n });\n });\n return getFieldValues(entry, baseFields);\n },\n async deleteContentReview(params) {\n const model = await getContentReviewModel();\n\n await security.withoutAuthorization(async () => {\n return cms.deleteEntry(model, params.id);\n });\n\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;;AACA;AAKA;AACA;AAEO,MAAMA,oCAAoC,GAAG,CAAC;EACjDC,GAAG;EACHC;AAC8B,CAAC,KAAwC;EACvE,MAAMC,qBAAqB,GAAG,YAAY;IACtC,MAAMC,KAAK,GAAG,MAAMF,QAAQ,CAACG,oBAAoB,CAAC,YAAY;MAC1D,OAAOJ,GAAG,CAACK,QAAQ,CAACC,sCAAuB,CAAC;IAChD,CAAC,CAAC;IACF,IAAI,CAACH,KAAK,EAAE;MACR,MAAM,IAAII,cAAW,CAChB,mBAAkBD,sCAAwB,UAAS,EACpD,uBAAuB,CAC1B;IACL;IACA,OAAOH,KAAK;EAChB,CAAC;EACD,MAAMK,gBAAuE,GAAG,OAAO;IACnFC;EACJ,CAAC,KAAK;IACF,MAAMN,KAAK,GAAG,MAAMD,qBAAqB,EAAE;IAC3C,MAAMQ,KAAK,GAAG,MAAMT,QAAQ,CAACG,oBAAoB,CAAC,YAAY;MAC1D,OAAOJ,GAAG,CAACW,YA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J,GAAG,CAAC0B,WAAW,CAACvB,KAAK,EAAEY,MAAM,CAACN,EAAE,8DAChCgB,aAAa,GACbV,MAAM,CAACQ,IAAI,EAChB;MACN,CAAC,CAAC;MACF,OAAO,IAAAX,qBAAc,EAACF,KAAK,EAAEG,iBAAU,CAAC;IAC5C,CAAC;IACD,MAAMc,mBAAmB,CAACZ,MAAM,EAAE;MAC9B,MAAMZ,KAAK,GAAG,MAAMD,qBAAqB,EAAE;MAE3C,MAAMD,QAAQ,CAACG,oBAAoB,CAAC,YAAY;QAC5C,OAAOJ,GAAG,CAAC4B,WAAW,CAACzB,KAAK,EAAEY,MAAM,CAACN,EAAE,CAAC;MAC5C,CAAC,CAAC;MAEF,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC"}
@@ -1,8 +1,8 @@
1
- import { CmsModelPlugin } from "@webiny/api-headless-cms";
2
- import { CmsModel, CmsGroup } from "@webiny/api-headless-cms/types";
1
+ import { CmsModelPlugin, CmsPrivateModelFull } from "@webiny/api-headless-cms";
2
+ import { CmsGroup } from "@webiny/api-headless-cms/types";
3
3
  interface Params {
4
4
  group: Pick<CmsGroup, "id" | "name">;
5
- modelDefinition: Omit<CmsModel, "locale" | "tenant" | "webinyVersion" | "group">;
5
+ modelDefinition: Omit<CmsPrivateModelFull, "group" | "noValidate">;
6
6
  }
7
7
  export declare const contentModelPluginFactory: (params: Params) => CmsModelPlugin;
8
8
  export {};
@@ -12,8 +12,9 @@ const contentModelPluginFactory = params => {
12
12
  group,
13
13
  modelDefinition
14
14
  } = params;
15
- return (0, _apiHeadlessCms.createCmsModel)((0, _objectSpread2.default)({
16
- group
17
- }, modelDefinition));
15
+ return (0, _apiHeadlessCms.createCmsModel)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, modelDefinition), {}, {
16
+ group,
17
+ noValidate: true
18
+ }));
18
19
  };
19
20
  exports.contentModelPluginFactory = contentModelPluginFactory;
@@ -1 +1 @@
1
- {"version":3,"names":["contentModelPluginFactory","params","group","modelDefinition","createCmsModel"],"sources":["contentModelPluginFactory.ts"],"sourcesContent":["import { CmsModelPlugin, createCmsModel } from \"@webiny/api-headless-cms\";\nimport { CmsModel, CmsGroup } from \"@webiny/api-headless-cms/types\";\n\ninterface Params {\n group: Pick<CmsGroup, \"id\" | \"name\">;\n modelDefinition: Omit<CmsModel, \"locale\" | \"tenant\" | \"webinyVersion\" | \"group\">;\n}\n\nexport const contentModelPluginFactory = (params: Params): CmsModelPlugin => {\n const { group, modelDefinition } = params;\n\n return createCmsModel({\n group,\n ...modelDefinition\n });\n};\n"],"mappings":";;;;;;;;AAAA;AAQO,MAAMA,yBAAyB,GAAIC,MAAc,IAAqB;EACzE,MAAM;IAAEC,KAAK;IAAEC;EAAgB,CAAC,GAAGF,MAAM;EAEzC,OAAO,IAAAG,8BAAc;IACjBF;EAAK,GACFC,eAAe,EACpB;AACN,CAAC;AAAC"}
1
+ {"version":3,"names":["contentModelPluginFactory","params","group","modelDefinition","createCmsModel","noValidate"],"sources":["contentModelPluginFactory.ts"],"sourcesContent":["import { CmsModelPlugin, CmsPrivateModelFull, createCmsModel } from \"@webiny/api-headless-cms\";\nimport { CmsGroup } from \"@webiny/api-headless-cms/types\";\n\ninterface Params {\n group: Pick<CmsGroup, \"id\" | \"name\">;\n modelDefinition: Omit<CmsPrivateModelFull, \"group\" | \"noValidate\">;\n}\n\nexport const contentModelPluginFactory = (params: Params): CmsModelPlugin => {\n const { group, modelDefinition } = params;\n\n return createCmsModel({\n ...modelDefinition,\n group,\n noValidate: true\n });\n};\n"],"mappings":";;;;;;;;AAAA;AAQO,MAAMA,yBAAyB,GAAIC,MAAc,IAAqB;EACzE,MAAM;IAAEC,KAAK;IAAEC;EAAgB,CAAC,GAAGF,MAAM;EAEzC,OAAO,IAAAG,8BAAc,8DACdD,eAAe;IAClBD,KAAK;IACLG,UAAU,EAAE;EAAI,GAClB;AACN,CAAC;AAAC"}
@@ -29,7 +29,6 @@ const createApwModels = context => {
29
29
  })) {
30
30
  return;
31
31
  }
32
- context.security.disableAuthorization();
33
32
  const locale = context.i18n.getContentLocale();
34
33
  if (!locale) {
35
34
  throw new _error.default("Missing content locale in api-apw/storageOperations/index.ts", "LOCALE_ERROR");
@@ -86,6 +85,5 @@ const createApwModels = context => {
86
85
  * Register them so that they are accessible in cms context
87
86
  */
88
87
  context.plugins.register([cmsGroupPlugin, cmsModelPlugins]);
89
- context.security.enableAuthorization();
90
88
  };
91
89
  exports.createApwModels = createApwModels;
@@ -1 +1 @@
1
- {"version":3,"names":["createApwModels","context","cms","console","warn","isInstallationPending","tenancy","i18n","security","disableAuthorization","locale","getContentLocale","WebinyError","groupId","cmsGroupPlugin","CmsGroupPlugin","id","slug","name","description","icon","isPrivate","changeRequestModelDefinition","createChangeRequestModelDefinition","reviewerModelDefinition","createReviewerModelDefinition","workflowModelDefinition","createWorkflowModelDefinition","reviewerModelId","modelId","commentModelDefinition","createCommentModelDefinition","contentReviewModelDefinition","createContentReviewModelDefinition","modelDefinitions","cmsModelPlugins","modelDefinition","cmsModelPlugin","contentModelPluginFactory","group","contentModelGroup","contentModel","titleFieldId","push","plugins","register","enableAuthorization"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsGroupPlugin } from \"@webiny/api-headless-cms\";\nimport { contentModelPluginFactory } from \"./contentModelPluginFactory\";\nimport { createWorkflowModelDefinition } from \"./workflow.model\";\nimport { createContentReviewModelDefinition } from \"./contentReview.model\";\nimport { createReviewerModelDefinition } from \"./reviewer.model\";\nimport { createCommentModelDefinition } from \"./comment.model\";\nimport { createChangeRequestModelDefinition } from \"./changeRequest.model\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport { isInstallationPending } from \"~/plugins/utils\";\n\nexport const createApwModels = (context: CmsContext) => {\n /**\n * This should never happen in the actual project.\n * It is to make sure that we load setup context before the CRUD init in our internal code.\n */\n if (!context.cms) {\n console.warn(\"Creating model before cms init.\");\n return;\n }\n\n if (isInstallationPending({ tenancy: context.tenancy, i18n: context.i18n })) {\n return;\n }\n\n context.security.disableAuthorization();\n\n const locale = context.i18n.getContentLocale();\n if (!locale) {\n throw new WebinyError(\n \"Missing content locale in api-apw/storageOperations/index.ts\",\n \"LOCALE_ERROR\"\n );\n }\n /**\n * TODO:@ashutosh\n * We need to move these plugin in an installation plugin\n */\n const groupId = \"contentModelGroup_apw\";\n /**\n * Create a CmsGroup.\n */\n const cmsGroupPlugin = new CmsGroupPlugin({\n id: groupId,\n slug: \"apw\",\n name: \"APW\",\n description: \"Group for Advanced Publishing Workflow\",\n icon: \"fas/star\",\n isPrivate: true\n });\n\n /**\n * Create CmsModel plugins.\n */\n const changeRequestModelDefinition = createChangeRequestModelDefinition();\n const reviewerModelDefinition = createReviewerModelDefinition();\n const workflowModelDefinition = createWorkflowModelDefinition({\n reviewerModelId: reviewerModelDefinition.modelId\n });\n const commentModelDefinition = createCommentModelDefinition({\n modelId: changeRequestModelDefinition.modelId\n });\n const contentReviewModelDefinition = createContentReviewModelDefinition({\n reviewerModelId: reviewerModelDefinition.modelId\n });\n\n const modelDefinitions = [\n workflowModelDefinition,\n contentReviewModelDefinition,\n reviewerModelDefinition,\n changeRequestModelDefinition,\n commentModelDefinition\n ];\n\n const cmsModelPlugins = [];\n for (const modelDefinition of modelDefinitions) {\n const cmsModelPlugin = contentModelPluginFactory({\n group: cmsGroupPlugin.contentModelGroup,\n modelDefinition\n });\n /**\n * We want \"title\" field as the \"titleField\" for \"ContentReview\" model.\n * so that we can later search entries by title.\n */\n if (cmsModelPlugin.contentModel.modelId === \"apwContentReviewModelDefinition\") {\n cmsModelPlugin.contentModel.titleFieldId = \"title\";\n }\n cmsModelPlugins.push(cmsModelPlugin);\n }\n\n /**\n * Register them so that they are accessible in cms context\n */\n context.plugins.register([cmsGroupPlugin, cmsModelPlugins]);\n\n context.security.enableAuthorization();\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEO,MAAMA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BR,uBAAuB,EACvBM,4BAA4B,EAC5BR,uBAAuB,EACvBF,4BAA4B,EAC5BQ,sBAAsB,CACzB;EAED,MAAMK,eAAe,GAAG,EAAE;EAC1B,KAAK,MAAMC,eAAe,IAAIF,gBAAgB,EAAE;IAC5C,MAAMG,cAAc,GAAG,IAAAC,oDAAyB,EAAC;MAC7CC,KAAK,EAAEzB,cAAc,CAAC0B,iBAAiB;MACvCJ;IACJ,CAAC,CAAC;IACF;AACR;AACA;AACA;IACQ,IAAIC,cAAc,CAACI,YAAY,CAACZ,OAAO,KAAK,iCAAiC,EAAE;MAC3EQ,cAAc,CAACI,YAAY,CAACC,YAAY,GAAG,OAAO;IACtD;IACAP,eAAe,CAACQ,IAAI,CAACN,cAAc,CAAC;EACxC;;EAEA;AACJ;AACA;EACIpC,OAAO,CAAC2C,OAAO,CAACC,QAAQ,CAAC,CAAC/B,cAAc,EAAEqB,eAAe,CAAC,CAAC;EAE3DlC,OAAO,CAACO,QAAQ,CAACsC,mBAAmB,EAAE;AAC1C,CAAC;AAAC"}
1
+ {"version":3,"names":["createApwModels","context","cms","console","warn","isInstallationPending","tenancy","i18n","locale","getContentLocale","WebinyError","groupId","cmsGroupPlugin","CmsGroupPlugin","id","slug","name","description","icon","isPrivate","changeRequestModelDefinition","createChangeRequestModelDefinition","reviewerModelDefinition","createReviewerModelDefinition","workflowModelDefinition","createWorkflowModelDefinition","reviewerModelId","modelId","commentModelDefinition","createCommentModelDefinition","contentReviewModelDefinition","createContentReviewModelDefinition","modelDefinitions","cmsModelPlugins","modelDefinition","cmsModelPlugin","contentModelPluginFactory","group","contentModelGroup","contentModel","titleFieldId","push","plugins","register"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsGroupPlugin, CmsModelPlugin } from \"@webiny/api-headless-cms\";\nimport { contentModelPluginFactory } from \"./contentModelPluginFactory\";\nimport { createWorkflowModelDefinition } from \"./workflow.model\";\nimport { createContentReviewModelDefinition } from \"./contentReview.model\";\nimport { createReviewerModelDefinition } from \"./reviewer.model\";\nimport { createCommentModelDefinition } from \"./comment.model\";\nimport { createChangeRequestModelDefinition } from \"./changeRequest.model\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport { isInstallationPending } from \"~/plugins/utils\";\n\nexport const createApwModels = (context: CmsContext) => {\n /**\n * This should never happen in the actual project.\n * It is to make sure that we load setup context before the CRUD init in our internal code.\n */\n if (!context.cms) {\n console.warn(\"Creating model before cms init.\");\n return;\n }\n\n if (isInstallationPending({ tenancy: context.tenancy, i18n: context.i18n })) {\n return;\n }\n\n const locale = context.i18n.getContentLocale();\n if (!locale) {\n throw new WebinyError(\n \"Missing content locale in api-apw/storageOperations/index.ts\",\n \"LOCALE_ERROR\"\n );\n }\n /**\n * TODO:@ashutosh\n * We need to move these plugin in an installation plugin\n */\n const groupId = \"contentModelGroup_apw\";\n /**\n * Create a CmsGroup.\n */\n const cmsGroupPlugin = new CmsGroupPlugin({\n id: groupId,\n slug: \"apw\",\n name: \"APW\",\n description: \"Group for Advanced Publishing Workflow\",\n icon: \"fas/star\",\n isPrivate: true\n });\n\n /**\n * Create CmsModel plugins.\n */\n const changeRequestModelDefinition = createChangeRequestModelDefinition();\n const reviewerModelDefinition = createReviewerModelDefinition();\n const workflowModelDefinition = createWorkflowModelDefinition({\n reviewerModelId: reviewerModelDefinition.modelId\n });\n const commentModelDefinition = createCommentModelDefinition({\n modelId: changeRequestModelDefinition.modelId\n });\n const contentReviewModelDefinition = createContentReviewModelDefinition({\n reviewerModelId: reviewerModelDefinition.modelId\n });\n\n const modelDefinitions = [\n workflowModelDefinition,\n contentReviewModelDefinition,\n reviewerModelDefinition,\n changeRequestModelDefinition,\n commentModelDefinition\n ];\n\n const cmsModelPlugins: CmsModelPlugin[] = [];\n for (const modelDefinition of modelDefinitions) {\n const cmsModelPlugin = contentModelPluginFactory({\n group: cmsGroupPlugin.contentModelGroup,\n modelDefinition\n });\n /**\n * We want \"title\" field as the \"titleField\" for \"ContentReview\" model.\n * so that we can later search entries by title.\n */\n if (cmsModelPlugin.contentModel.modelId === \"apwContentReviewModelDefinition\") {\n cmsModelPlugin.contentModel.titleFieldId = \"title\";\n }\n cmsModelPlugins.push(cmsModelPlugin);\n }\n\n /**\n * Register them so that they are accessible in cms context\n */\n context.plugins.register([cmsGroupPlugin, cmsModelPlugins]);\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEO,MAAMA,eAAe,GAAIC,OAAmB,IAAK;EACpD;AACJ;AACA;AACA;EACI,IAAI,CAACA,OAAO,CAACC,GAAG,EAAE;IACdC,OAAO,CAACC,IAAI,CAAC,iCAAiC,CAAC;IAC/C;EACJ;EAEA,IAAI,IAAAC,4BAAqB,EAAC;IAAEC,OAAO,EAAEL,OAAO,CAACK,OAAO;IAAEC,IAAI,EAAEN,OAAO,CAACM;EAAK,CAAC,CAAC,EAAE;IACzE;EACJ;EAEA,MAAMC,MAAM,GAAGP,OAAO,CAACM,IAAI,CAACE,gBAAgB,EAAE;EAC9C,IAAI,CAACD,MAAM,EAAE;IACT,MAAM,IAAIE,cAAW,CACjB,8DAA8D,EAC9D,cAAc,CACjB;EACL;EACA;AACJ;AACA;AACA;EACI,MAAMC,OAAO,GAAG,uBAAuB;EACvC;AACJ;AACA;EACI,MAAMC,cAAc,GAAG,IAAIC,8BAAc,CAAC;IACtCC,EAAE,EAAEH,OAAO;IACXI,IAAI,EAAE,KAAK;IACXC,IAAI,EAAE,KAAK;IACXC,WAAW,EAAE,wCAAwC;IACrDC,IAAI,EAAE,UAAU;IAChBC,SAAS,EAAE;EACf,CAAC,CAAC;;EAEF;AACJ;AACA;EACI,MAAMC,4BAA4B,GAAG,IAAAC,iDAAkC,GAAE;EACzE,MAAMC,uBAAuB,GAAG,IAAAC,uCAA6B,GAAE;EAC/D,MAAMC,uBAAuB,GAAG,IAAAC,uCAA6B,EAAC;IAC1DC,eAAe,EAAEJ,uBAAuB,CAACK;EAC7C,CAAC,CAAC;EACF,MAAMC,sBAAsB,GAAG,IAAAC,qCAA4B,EAAC;IACxDF,OAAO,EAAEP,4BAA4B,CAACO;EAC1C,CAAC,CAAC;EACF,MAAMG,4BAA4B,GAAG,IAAAC,iDAAkC,EAAC;IACpEL,eAAe,EAAEJ,uBAAuB,CAACK;EAC7C,CAAC,CAAC;EAEF,MAAMK,gBAAgB,GAAG,CACrBR,uBAAuB,EACvBM,4BAA4B,EAC5BR,uBAAuB,EACvBF,4BAA4B,EAC5BQ,sBAAsB,CACzB;EAED,MAAMK,eAAiC,GAAG,EAAE;EAC5C,KAAK,MAAMC,eAAe,IAAIF,gBAAgB,EAAE;IAC5C,MAAMG,cAAc,GAAG,IAAAC,oDAAyB,EAAC;MAC7CC,KAAK,EAAEzB,cAAc,CAAC0B,iBAAiB;MACvCJ;IACJ,CAAC,CAAC;IACF;AACR;AACA;AACA;IACQ,IAAIC,cAAc,CAACI,YAAY,CAACZ,OAAO,KAAK,iCAAiC,EAAE;MAC3EQ,cAAc,CAACI,YAAY,CAACC,YAAY,GAAG,OAAO;IACtD;IACAP,eAAe,CAACQ,IAAI,CAACN,cAAc,CAAC;EACxC;;EAEA;AACJ;AACA;EACIlC,OAAO,CAACyC,OAAO,CAACC,QAAQ,CAAC,CAAC/B,cAAc,EAAEqB,eAAe,CAAC,CAAC;AAC/D,CAAC;AAAC"}
@@ -13,26 +13,21 @@ const createReviewerStorageOperations = ({
13
13
  security
14
14
  }) => {
15
15
  const getReviewerModel = async () => {
16
- security.disableAuthorization();
17
- try {
18
- const model = await cms.getModel("apwReviewerModelDefinition");
19
- if (!model) {
20
- throw new _error.default("Could not find `apwReviewerModelDefinition` model.", "MODEL_NOT_FOUND_ERROR");
21
- }
22
- return model;
23
- } catch (ex) {
24
- throw ex;
25
- } finally {
26
- security.enableAuthorization();
16
+ const model = await security.withoutAuthorization(async () => {
17
+ return cms.getModel("apwReviewerModelDefinition");
18
+ });
19
+ if (!model) {
20
+ throw new _error.default("Could not find `apwReviewerModelDefinition` model.", "MODEL_NOT_FOUND_ERROR");
27
21
  }
22
+ return model;
28
23
  };
29
24
  const getReviewer = async ({
30
25
  id
31
26
  }) => {
32
27
  const model = await getReviewerModel();
33
- security.disableAuthorization();
34
- const entry = await cms.getEntryById(model, id);
35
- security.enableAuthorization();
28
+ const entry = await security.withoutAuthorization(async () => {
29
+ return cms.getEntryById(model, id);
30
+ });
36
31
  return (0, _index.getFieldValues)(entry, _index.baseFields);
37
32
  };
38
33
  return {
@@ -40,18 +35,18 @@ const createReviewerStorageOperations = ({
40
35
  getReviewer,
41
36
  async listReviewers(params) {
42
37
  const model = await getReviewerModel();
43
- security.disableAuthorization();
44
- const [entries, meta] = await cms.listLatestEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
45
- where: (0, _objectSpread2.default)({}, params.where)
46
- }));
47
- security.enableAuthorization();
38
+ const [entries, meta] = await security.withoutAuthorization(async () => {
39
+ return cms.listLatestEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
40
+ where: (0, _objectSpread2.default)({}, params.where)
41
+ }));
42
+ });
48
43
  return [entries.map(entry => (0, _index.getFieldValues)(entry, _index.baseFields)), meta];
49
44
  },
50
45
  async createReviewer(params) {
51
46
  const model = await getReviewerModel();
52
- security.disableAuthorization();
53
- const entry = await cms.createEntry(model, params.data);
54
- security.enableAuthorization();
47
+ const entry = await security.withoutAuthorization(async () => {
48
+ return cms.createEntry(model, params.data);
49
+ });
55
50
  return (0, _index.getFieldValues)(entry, _index.baseFields);
56
51
  },
57
52
  async updateReviewer(params) {
@@ -63,16 +58,16 @@ const createReviewerStorageOperations = ({
63
58
  const existingEntry = await getReviewer({
64
59
  id: params.id
65
60
  });
66
- security.disableAuthorization();
67
- const entry = await cms.updateEntry(model, params.id, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, existingEntry), params.data));
68
- security.enableAuthorization();
61
+ const entry = await security.withoutAuthorization(async () => {
62
+ return cms.updateEntry(model, params.id, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, existingEntry), params.data));
63
+ });
69
64
  return (0, _index.getFieldValues)(entry, _index.baseFields);
70
65
  },
71
66
  async deleteReviewer(params) {
72
67
  const model = await getReviewerModel();
73
- security.disableAuthorization();
74
- await cms.deleteEntry(model, params.id);
75
- security.enableAuthorization();
68
+ await security.withoutAuthorization(async () => {
69
+ return cms.deleteEntry(model, params.id);
70
+ });
76
71
  return true;
77
72
  }
78
73
  };
@@ -1 +1 @@
1
- {"version":3,"names":["createReviewerStorageOperations","cms","security","getReviewerModel","disableAuthorization","model","getModel","WebinyError","ex","enableAuthorization","getReviewer","id","entry","getEntryById","getFieldValues","baseFields","listReviewers","params","entries","meta","listLatestEntries","where","map","createReviewer","createEntry","data","updateReviewer","existingEntry","updateEntry","deleteReviewer","deleteEntry"],"sources":["reviewerStorageOperations.ts"],"sourcesContent":["import { ApwReviewerStorageOperations } from \"./types\";\nimport {\n baseFields,\n CreateApwStorageOperationsParams,\n getFieldValues\n} from \"~/storageOperations/index\";\nimport WebinyError from \"@webiny/error\";\n\nexport const createReviewerStorageOperations = ({\n cms,\n security\n}: CreateApwStorageOperationsParams): ApwReviewerStorageOperations => {\n const getReviewerModel = async () => {\n security.disableAuthorization();\n try {\n const model = await cms.getModel(\"apwReviewerModelDefinition\");\n if (!model) {\n throw new WebinyError(\n \"Could not find `apwReviewerModelDefinition` model.\",\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n return model;\n } catch (ex) {\n throw ex;\n } finally {\n security.enableAuthorization();\n }\n };\n const getReviewer: ApwReviewerStorageOperations[\"getReviewer\"] = async ({ id }) => {\n const model = await getReviewerModel();\n security.disableAuthorization();\n const entry = await cms.getEntryById(model, id);\n security.enableAuthorization();\n return getFieldValues(entry, baseFields);\n };\n return {\n getReviewerModel,\n getReviewer,\n async listReviewers(params) {\n const model = await getReviewerModel();\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 createReviewer(params) {\n const model = await getReviewerModel();\n security.disableAuthorization();\n const entry = await cms.createEntry(model, params.data);\n security.enableAuthorization();\n return getFieldValues(entry, baseFields);\n },\n async updateReviewer(params) {\n const model = await 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 getReviewer({ id: params.id });\n\n security.disableAuthorization();\n const entry = await cms.updateEntry(model, params.id, {\n ...existingEntry,\n ...params.data\n });\n security.enableAuthorization();\n return getFieldValues(entry, baseFields);\n },\n async deleteReviewer(params) {\n const model = await getReviewerModel();\n security.disableAuthorization();\n await cms.deleteEntry(model, params.id);\n security.enableAuthorization();\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;;AACA;AAKA;AAEO,MAAMA,+BAA+B,GAAG,CAAC;EAC5CC,GAAG;EACHC;AAC8B,CAAC,KAAmC;EAClE,MAAMC,gBAAgB,GAAG,YAAY;IACjCD,QAAQ,CAACE,oBAAoB,EAAE;IAC/B,IAAI;MACA,MAAMC,KAAK,GAAG,MAAMJ,GAAG,CAACK,QAAQ,CAAC,4BAA4B,CAAC;MAC9D,IAAI,CAACD,KAAK,EAAE;QACR,MAAM,IAAIE,cAAW,CACjB,oDAAoD,EACpD,uBAAuB,CAC1B;MACL;MACA,OAAOF,KAAK;IAChB,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,MAAMA,EAAE;IACZ,CAAC,SAAS;MACNN,QAAQ,CAACO,mBAAmB,EAAE;IAClC;EACJ,CAAC;EACD,MAAMC,WAAwD,GAAG,OAAO;IAAEC;EAAG,CAAC,KAAK;IAC/E,MAAMN,KAAK,GAAG,MAAMF,gBAAgB,EAAE;IACtCD,QAAQ,CAACE,oBAAoB,EAAE;IAC/B,MAAMQ,KAAK,GAAG,MAAMX,GAAG,CAACY,YAAY,CAACR,KAAK,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2B,WAAW,CAACvB,KAAK,EAAEY,MAAM,CAACN,EAAE,8DAC7CgB,aAAa,GACbV,MAAM,CAACQ,IAAI,EAChB;MACFvB,QAAQ,CAACO,mBAAmB,EAAE;MAC9B,OAAO,IAAAK,qBAAc,EAACF,KAAK,EAAEG,iBAAU,CAAC;IAC5C,CAAC;IACD,MAAMc,cAAc,CAACZ,MAAM,EAAE;MACzB,MAAMZ,KAAK,GAAG,MAAMF,gBAAgB,EAAE;MACtCD,QAAQ,CAACE,oBAAoB,EAAE;MAC/B,MAAMH,GAAG,CAAC6B,WAAW,CAACzB,KAAK,EAAEY,MAAM,CAACN,EAAE,CAAC;MACvCT,QAAQ,CAACO,mBAAmB,EAAE;MAC9B,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC"}
1
+ {"version":3,"names":["createReviewerStorageOperations","cms","security","getReviewerModel","model","withoutAuthorization","getModel","WebinyError","getReviewer","id","entry","getEntryById","getFieldValues","baseFields","listReviewers","params","entries","meta","listLatestEntries","where","map","createReviewer","createEntry","data","updateReviewer","existingEntry","updateEntry","deleteReviewer","deleteEntry"],"sources":["reviewerStorageOperations.ts"],"sourcesContent":["import { ApwReviewerStorageOperations } from \"./types\";\nimport {\n baseFields,\n CreateApwStorageOperationsParams,\n getFieldValues\n} from \"~/storageOperations/index\";\nimport WebinyError from \"@webiny/error\";\n\nexport const createReviewerStorageOperations = ({\n cms,\n security\n}: CreateApwStorageOperationsParams): ApwReviewerStorageOperations => {\n const getReviewerModel = async () => {\n const model = await security.withoutAuthorization(async () => {\n return cms.getModel(\"apwReviewerModelDefinition\");\n });\n if (!model) {\n throw new WebinyError(\n \"Could not find `apwReviewerModelDefinition` model.\",\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n return model;\n };\n const getReviewer: ApwReviewerStorageOperations[\"getReviewer\"] = async ({ id }) => {\n const model = await getReviewerModel();\n\n const entry = await security.withoutAuthorization(async () => {\n return cms.getEntryById(model, id);\n });\n return getFieldValues(entry, baseFields);\n };\n return {\n getReviewerModel,\n getReviewer,\n async listReviewers(params) {\n const model = await getReviewerModel();\n\n const [entries, meta] = await security.withoutAuthorization(async () => {\n return cms.listLatestEntries(model, {\n ...params,\n where: {\n ...params.where\n }\n });\n });\n return [entries.map(entry => getFieldValues(entry, baseFields)), meta];\n },\n async createReviewer(params) {\n const model = await getReviewerModel();\n const entry = await security.withoutAuthorization(async () => {\n return cms.createEntry(model, params.data);\n });\n return getFieldValues(entry, baseFields);\n },\n async updateReviewer(params) {\n const model = await 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 getReviewer({ id: params.id });\n\n const entry = await security.withoutAuthorization(async () => {\n return cms.updateEntry(model, params.id, {\n ...existingEntry,\n ...params.data\n });\n });\n return getFieldValues(entry, baseFields);\n },\n async deleteReviewer(params) {\n const model = await getReviewerModel();\n\n await security.withoutAuthorization(async () => {\n return cms.deleteEntry(model, params.id);\n });\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;;AACA;AAKA;AAEO,MAAMA,+BAA+B,GAAG,CAAC;EAC5CC,GAAG;EACHC;AAC8B,CAAC,KAAmC;EAClE,MAAMC,gBAAgB,GAAG,YAAY;IACjC,MAAMC,KAAK,GAAG,MAAMF,QAAQ,CAACG,oBAAoB,CAAC,YAAY;MAC1D,OAAOJ,GAAG,CAACK,QAAQ,CAAC,4BAA4B,CAAC;IACrD,CAAC,CAAC;IACF,IAAI,CAACF,KAAK,EAAE;MACR,MAAM,IAAIG,cAAW,CACjB,oDAAoD,EACpD,uBAAuB,CAC1B;IACL;IACA,OAAOH,KAAK;EAChB,CAAC;EACD,MAAMI,WAAwD,GAAG,OAAO;IAAEC;EAAG,CAAC,KAAK;IAC/E,MAAML,KAAK,GAAG,MAAMD,gBAAgB,EAAE;IAEtC,MAAMO,KAAK,GAAG,MAAMR,QAAQ,CAACG,oBAAoB,CAAC,YAAY;MAC1D,OAAOJ,G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