@webiny/api-aco 0.0.0-unstable.7f63ea0744 → 0.0.0-unstable.99666aeb00

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 (107) hide show
  1. package/README.md +6 -6
  2. package/apps/AcoApp.d.ts +16 -0
  3. package/apps/AcoApp.js +108 -0
  4. package/apps/AcoApp.js.map +1 -0
  5. package/apps/AcoApps.d.ts +10 -0
  6. package/apps/AcoApps.js +76 -0
  7. package/apps/AcoApps.js.map +1 -0
  8. package/apps/app.gql.d.ts +3 -0
  9. package/apps/app.gql.js +58 -0
  10. package/apps/app.gql.js.map +1 -0
  11. package/apps/index.d.ts +2 -0
  12. package/apps/index.js +27 -0
  13. package/apps/index.js.map +1 -0
  14. package/createAcoContext.js +50 -13
  15. package/createAcoContext.js.map +1 -1
  16. package/createAcoGraphQL.d.ts +2 -2
  17. package/createAcoGraphQL.js +44 -14
  18. package/createAcoGraphQL.js.map +1 -1
  19. package/createAcoModels.js +0 -25
  20. package/createAcoModels.js.map +1 -1
  21. package/{createAcoFields.d.ts → fields/index.d.ts} +1 -1
  22. package/fields/index.js +12 -0
  23. package/fields/index.js.map +1 -0
  24. package/fields/location.d.ts +2 -0
  25. package/fields/location.js +44 -0
  26. package/fields/location.js.map +1 -0
  27. package/folder/folder.crud.js +18 -0
  28. package/folder/folder.crud.js.map +1 -1
  29. package/folder/folder.gql.js +20 -5
  30. package/folder/folder.gql.js.map +1 -1
  31. package/folder/folder.model.d.ts +3 -3
  32. package/folder/folder.model.js +3 -25
  33. package/folder/folder.model.js.map +1 -1
  34. package/folder/folder.so.d.ts +1 -6
  35. package/folder/folder.so.js +103 -108
  36. package/folder/folder.so.js.map +1 -1
  37. package/folder/folder.types.d.ts +9 -3
  38. package/folder/folder.types.js.map +1 -1
  39. package/folder/onFolderBeforeDelete.hook.js +40 -27
  40. package/folder/onFolderBeforeDelete.hook.js.map +1 -1
  41. package/index.d.ts +5 -1
  42. package/index.js +48 -6
  43. package/index.js.map +1 -1
  44. package/package.json +34 -31
  45. package/plugins/AcoAppModifierPlugin.d.ts +43 -0
  46. package/plugins/AcoAppModifierPlugin.js +59 -0
  47. package/plugins/AcoAppModifierPlugin.js.map +1 -0
  48. package/plugins/AcoAppRegisterPlugin.d.ts +8 -0
  49. package/plugins/AcoAppRegisterPlugin.js +22 -0
  50. package/plugins/AcoAppRegisterPlugin.js.map +1 -0
  51. package/plugins/index.d.ts +2 -0
  52. package/plugins/index.js +27 -0
  53. package/plugins/index.js.map +1 -0
  54. package/record/graphql/createAppResolvers.d.ts +14 -0
  55. package/record/graphql/createAppResolvers.js +108 -0
  56. package/record/graphql/createAppResolvers.js.map +1 -0
  57. package/record/graphql/createAppSchema.d.ts +9 -0
  58. package/record/graphql/createAppSchema.js +142 -0
  59. package/record/graphql/createAppSchema.js.map +1 -0
  60. package/record/record.crud.js +46 -12
  61. package/record/record.crud.js.map +1 -1
  62. package/record/record.gql.d.ts +8 -3
  63. package/record/record.gql.js +36 -113
  64. package/record/record.gql.js.map +1 -1
  65. package/record/record.model.d.ts +10 -4
  66. package/record/record.model.js +39 -28
  67. package/record/record.model.js.map +1 -1
  68. package/record/record.so.d.ts +1 -6
  69. package/record/record.so.js +112 -62
  70. package/record/record.so.js.map +1 -1
  71. package/record/record.types.d.ts +66 -15
  72. package/record/record.types.js.map +1 -1
  73. package/types.d.ts +56 -3
  74. package/types.js +35 -1
  75. package/types.js.map +1 -1
  76. package/utils/acoRecordId.d.ts +6 -0
  77. package/utils/acoRecordId.js +33 -0
  78. package/utils/acoRecordId.js.map +1 -0
  79. package/utils/checkPermissions.d.ts +2 -0
  80. package/utils/checkPermissions.js +14 -0
  81. package/utils/checkPermissions.js.map +1 -0
  82. package/utils/createListSort.d.ts +2 -0
  83. package/utils/createListSort.js +13 -0
  84. package/utils/createListSort.js.map +1 -0
  85. package/utils/createModelField.d.ts +0 -1
  86. package/utils/createModelField.js +2 -4
  87. package/utils/createModelField.js.map +1 -1
  88. package/utils/createOperationsWrapper.d.ts +9 -0
  89. package/utils/createOperationsWrapper.js +29 -0
  90. package/utils/createOperationsWrapper.js.map +1 -0
  91. package/utils/getFieldValues.d.ts +4 -1
  92. package/utils/getFieldValues.js +6 -2
  93. package/utils/getFieldValues.js.map +1 -1
  94. package/utils/getFolderAndItsAncestors.d.ts +7 -0
  95. package/utils/getFolderAndItsAncestors.js +48 -0
  96. package/utils/getFolderAndItsAncestors.js.map +1 -0
  97. package/utils/modelFactory.d.ts +3 -3
  98. package/utils/modelFactory.js +4 -2
  99. package/utils/modelFactory.js.map +1 -1
  100. package/utils/resolve.d.ts +2 -1
  101. package/utils/resolve.js +11 -2
  102. package/utils/resolve.js.map +1 -1
  103. package/createAcoCrud.d.ts +0 -2
  104. package/createAcoCrud.js +0 -17
  105. package/createAcoCrud.js.map +0 -1
  106. package/createAcoFields.js +0 -40
  107. package/createAcoFields.js.map +0 -1
@@ -1,3 +1,8 @@
1
- import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/plugins/GraphQLSchemaPlugin";
2
- import { AcoContext } from "../types";
3
- export declare const searchRecordSchema: GraphQLSchemaPlugin<AcoContext>;
1
+ import { AcoContext, IAcoApp } from "../types";
2
+ import { GraphQLSchemaPlugin } from "@webiny/handler-graphql";
3
+ interface Params {
4
+ context: AcoContext;
5
+ app: IAcoApp;
6
+ }
7
+ export declare const createSchema: (params: Params) => Promise<GraphQLSchemaPlugin<import("@webiny/api/types").Context>>;
8
+ export {};
@@ -3,116 +3,39 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.searchRecordSchema = void 0;
7
- var _responses = require("@webiny/handler-graphql/responses");
8
- var _GraphQLSchemaPlugin = require("@webiny/handler-graphql/plugins/GraphQLSchemaPlugin");
9
- var _resolve = require("../utils/resolve");
10
- const searchRecordSchema = new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
11
- typeDefs: /* GraphQL */`
12
- type SearchRecord {
13
- id: ID!
14
- originalId: ID!
15
- type: String!
16
- location: SearchLocationType!
17
- title: String!
18
- content: String
19
- data: JSON
20
- savedOn: DateTime
21
- createdOn: DateTime
22
- createdBy: AcoUser
23
- }
24
-
25
- type SearchLocationType {
26
- folderId: ID!
27
- }
28
-
29
- input SearchLocationInput {
30
- folderId: ID!
31
- }
32
-
33
- input SearchRecordCreateInput {
34
- originalId: String!
35
- type: String!
36
- title: String!
37
- content: String
38
- location: SearchLocationInput!
39
- data: JSON
40
- }
41
-
42
- input SearchRecordUpdateInput {
43
- title: String
44
- content: String
45
- location: SearchLocationInput
46
- data: JSON
47
- }
48
-
49
- input SearchRecordListWhereInput {
50
- type: String!
51
- location: SearchLocationInput
52
- }
53
-
54
- type SearchRecordResponse {
55
- data: SearchRecord
56
- error: AcoError
57
- }
58
-
59
- type SearchRecordListResponse {
60
- data: [SearchRecord]
61
- error: AcoError
62
- meta: AcoMeta
63
- }
64
-
65
- extend type SearchQuery {
66
- getRecord(id: ID!): SearchRecordResponse
67
- listRecords(
68
- where: SearchRecordListWhereInput
69
- search: String
70
- limit: Int
71
- after: String
72
- sort: [AcoListSort]
73
- ): SearchRecordListResponse
74
- }
75
-
76
- extend type SearchMutation {
77
- createRecord(data: SearchRecordCreateInput!): SearchRecordResponse
78
- updateRecord(id: ID!, data: SearchRecordUpdateInput!): SearchRecordResponse
79
- deleteRecord(id: ID!): AcoBooleanResponse
80
- }
81
- `,
82
- resolvers: {
83
- SearchQuery: {
84
- getRecord: async (_, {
85
- id
86
- }, context) => {
87
- return (0, _resolve.resolve)(() => context.aco.search.get(id));
88
- },
89
- listRecords: async (_, args, context) => {
90
- try {
91
- const [entries, meta] = await context.aco.search.list(args);
92
- return new _responses.ListResponse(entries, meta);
93
- } catch (e) {
94
- return new _responses.ErrorResponse(e);
95
- }
96
- }
97
- },
98
- SearchMutation: {
99
- createRecord: async (_, {
100
- data
101
- }, context) => {
102
- return (0, _resolve.resolve)(() => context.aco.search.create(data));
103
- },
104
- updateRecord: async (_, {
105
- id,
106
- data
107
- }, context) => {
108
- return (0, _resolve.resolve)(() => context.aco.search.update(id, data));
109
- },
110
- deleteRecord: async (_, {
111
- id
112
- }, context) => {
113
- return (0, _resolve.resolve)(() => context.aco.search.delete(id));
114
- }
115
- }
116
- }
117
- });
118
- exports.searchRecordSchema = searchRecordSchema;
6
+ exports.createSchema = void 0;
7
+ var _handlerGraphql = require("@webiny/handler-graphql");
8
+ var _createAppSchema = require("./graphql/createAppSchema");
9
+ var _createAppResolvers = require("./graphql/createAppResolvers");
10
+ const createSchema = async params => {
11
+ const {
12
+ context,
13
+ app
14
+ } = params;
15
+ const plugins = context.plugins.byType("cms-model-field-to-graphql").reduce((fields, plugin) => {
16
+ fields[plugin.fieldType] = plugin;
17
+ return fields;
18
+ }, {});
19
+ const models = await context.security.withoutAuthorization(async () => {
20
+ return (await context.cms.listModels()).filter(model => {
21
+ return !model.isPrivate;
22
+ });
23
+ });
24
+ return context.benchmark.measure(`aco.schema.generate.${app.name}`, async () => {
25
+ const plugin = new _handlerGraphql.GraphQLSchemaPlugin({
26
+ typeDefs: (0, _createAppSchema.createAppSchema)({
27
+ models,
28
+ app,
29
+ plugins
30
+ }),
31
+ resolvers: (0, _createAppResolvers.createAppResolvers)({
32
+ models,
33
+ app,
34
+ plugins
35
+ })
36
+ });
37
+ plugin.name = `aco.graphql.appSchema.searchRecord.${app.name}`;
38
+ return plugin;
39
+ });
40
+ };
41
+ exports.createSchema = createSchema;
@@ -1 +1 @@
1
- {"version":3,"names":["searchRecordSchema","GraphQLSchemaPlugin","typeDefs","resolvers","SearchQuery","getRecord","_","id","context","resolve","aco","search","get","listRecords","args","entries","meta","list","ListResponse","e","ErrorResponse","SearchMutation","createRecord","data","create","updateRecord","update","deleteRecord","delete"],"sources":["record.gql.ts"],"sourcesContent":["import { ErrorResponse, ListResponse } from \"@webiny/handler-graphql/responses\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin\";\n\nimport { resolve } from \"~/utils/resolve\";\n\nimport { AcoContext } from \"~/types\";\n\nexport const searchRecordSchema = new GraphQLSchemaPlugin<AcoContext>({\n typeDefs: /* GraphQL */ `\n type SearchRecord {\n id: ID!\n originalId: ID!\n type: String!\n location: SearchLocationType!\n title: String!\n content: String\n data: JSON\n savedOn: DateTime\n createdOn: DateTime\n createdBy: AcoUser\n }\n\n type SearchLocationType {\n folderId: ID!\n }\n\n input SearchLocationInput {\n folderId: ID!\n }\n\n input SearchRecordCreateInput {\n originalId: String!\n type: String!\n title: String!\n content: String\n location: SearchLocationInput!\n data: JSON\n }\n\n input SearchRecordUpdateInput {\n title: String\n content: String\n location: SearchLocationInput\n data: JSON\n }\n\n input SearchRecordListWhereInput {\n type: String!\n location: SearchLocationInput\n }\n\n type SearchRecordResponse {\n data: SearchRecord\n error: AcoError\n }\n\n type SearchRecordListResponse {\n data: [SearchRecord]\n error: AcoError\n meta: AcoMeta\n }\n\n extend type SearchQuery {\n getRecord(id: ID!): SearchRecordResponse\n listRecords(\n where: SearchRecordListWhereInput\n search: String\n limit: Int\n after: String\n sort: [AcoListSort]\n ): SearchRecordListResponse\n }\n\n extend type SearchMutation {\n createRecord(data: SearchRecordCreateInput!): SearchRecordResponse\n updateRecord(id: ID!, data: SearchRecordUpdateInput!): SearchRecordResponse\n deleteRecord(id: ID!): AcoBooleanResponse\n }\n `,\n resolvers: {\n SearchQuery: {\n getRecord: async (_, { id }, context) => {\n return resolve(() => context.aco.search.get(id));\n },\n listRecords: async (_, args: any, context) => {\n try {\n const [entries, meta] = await context.aco.search.list(args);\n return new ListResponse(entries, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n SearchMutation: {\n createRecord: async (_, { data }, context) => {\n return resolve(() => context.aco.search.create(data));\n },\n updateRecord: async (_, { id, data }, context) => {\n return resolve(() => context.aco.search.update(id, data));\n },\n deleteRecord: async (_, { id }, context) => {\n return resolve(() => context.aco.search.delete(id));\n }\n }\n }\n});\n"],"mappings":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AAC;MACzD,CAAC;MACDE,YAAY,EAAE,OAAOnB,CAAC,EAAE;QAAEC,EAAE;QAAEgB;MAAK,CAAC,EAAEf,OAAO,KAAK;QAC9C,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,GAAG,CAACC,MAAM,CAACe,MAAM,CAACnB,EAAE,EAAEgB,IAAI,CAAC,CAAC;MAC7D,CAAC;MACDI,YAAY,EAAE,OAAOrB,CAAC,EAAE;QAAEC;MAAG,CAAC,EAAEC,OAAO,KAAK;QACxC,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,GAAG,CAACC,MAAM,CAACiB,MAAM,CAACrB,EAAE,CAAC,CAAC;MACvD;IACJ;EACJ;AACJ,CAAC,CAAC;AAAC"}
1
+ {"version":3,"names":["createSchema","params","context","app","plugins","byType","reduce","fields","plugin","fieldType","models","security","withoutAuthorization","cms","listModels","filter","model","isPrivate","benchmark","measure","name","GraphQLSchemaPlugin","typeDefs","createAppSchema","resolvers","createAppResolvers"],"sources":["record.gql.ts"],"sourcesContent":["import { AcoContext, IAcoApp } from \"~/types\";\nimport { CmsFieldTypePlugins, CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { createAppSchema } from \"./graphql/createAppSchema\";\nimport { createAppResolvers } from \"./graphql/createAppResolvers\";\n\ninterface Params {\n context: AcoContext;\n app: IAcoApp;\n}\n\nexport const createSchema = async (params: Params) => {\n const { context, app } = params;\n const plugins = context.plugins\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce<CmsFieldTypePlugins>((fields, plugin) => {\n fields[plugin.fieldType] = plugin;\n return fields;\n }, {});\n const models = await context.security.withoutAuthorization(async () => {\n return (await context.cms.listModels()).filter(model => {\n return !model.isPrivate;\n });\n });\n\n return context.benchmark.measure(`aco.schema.generate.${app.name}`, async () => {\n const plugin = new GraphQLSchemaPlugin({\n typeDefs: createAppSchema({\n models,\n app,\n plugins\n }),\n resolvers: createAppResolvers({\n models,\n app,\n plugins\n })\n });\n plugin.name = `aco.graphql.appSchema.searchRecord.${app.name}`;\n return plugin;\n });\n};\n"],"mappings":";;;;;;AAEA;AACA;AACA;AAOO,MAAMA,YAAY,GAAG,MAAOC,MAAc,IAAK;EAClD,MAAM;IAAEC,OAAO;IAAEC;EAAI,CAAC,GAAGF,MAAM;EAC/B,MAAMG,OAAO,GAAGF,OAAO,CAACE,OAAO,CAC1BC,MAAM,CAA+B,4BAA4B,CAAC,CAClEC,MAAM,CAAsB,CAACC,MAAM,EAAEC,MAAM,KAAK;IAC7CD,MAAM,CAACC,MAAM,CAACC,SAAS,CAAC,GAAGD,MAAM;IACjC,OAAOD,MAAM;EACjB,CAAC,EAAE,CAAC,CAAC,CAAC;EACV,MAAMG,MAAM,GAAG,MAAMR,OAAO,CAACS,QAAQ,CAACC,oBAAoB,CAAC,YAAY;IACnE,OAAO,CAAC,MAAMV,OAAO,CAACW,GAAG,CAACC,UAAU,EAAE,EAAEC,MAAM,CAACC,KAAK,IAAI;MACpD,OAAO,CAACA,KAAK,CAACC,SAAS;IAC3B,CAAC,CAAC;EACN,CAAC,CAAC;EAEF,OAAOf,OAAO,CAACgB,SAAS,CAACC,OAAO,CAAE,uBAAsBhB,GAAG,CAACiB,IAAK,EAAC,EAAE,YAAY;IAC5E,MAAMZ,MAAM,GAAG,IAAIa,mCAAmB,CAAC;MACnCC,QAAQ,EAAE,IAAAC,gCAAe,EAAC;QACtBb,MAAM;QACNP,GAAG;QACHC;MACJ,CAAC,CAAC;MACFoB,SAAS,EAAE,IAAAC,sCAAkB,EAAC;QAC1Bf,MAAM;QACNP,GAAG;QACHC;MACJ,CAAC;IACL,CAAC,CAAC;IACFI,MAAM,CAACY,IAAI,GAAI,sCAAqCjB,GAAG,CAACiB,IAAK,EAAC;IAC9D,OAAOZ,MAAM;EACjB,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -1,4 +1,10 @@
1
- import { CmsModel } from "@webiny/api-headless-cms/types";
2
- export declare type SearchRecordModelDefinition = Pick<CmsModel, "name" | "modelId" | "layout" | "titleFieldId" | "description" | "fields" | "isPrivate">;
3
- export declare const SEARCH_RECORD_MODEL_ID = "acoSearchRecordModelDefinition";
4
- export declare const createSearchModelDefinition: () => SearchRecordModelDefinition;
1
+ import { CmsModelField } from "@webiny/api-headless-cms/types";
2
+ import { CmsPrivateModelFull } from "@webiny/api-headless-cms";
3
+ export declare type SearchRecordModelDefinition = Omit<CmsPrivateModelFull, "noValidate" | "group">;
4
+ export declare const SEARCH_RECORD_MODEL_ID = "acoSearchRecord";
5
+ interface CreateSearchModelDefinitionParams {
6
+ fields?: CmsModelField[];
7
+ }
8
+ export declare const DEFAULT_FIELDS: string[];
9
+ export declare const createSearchModelDefinition: (params?: CreateSearchModelDefinitionParams) => SearchRecordModelDefinition;
10
+ export {};
@@ -3,24 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.createSearchModelDefinition = exports.SEARCH_RECORD_MODEL_ID = void 0;
6
+ exports.createSearchModelDefinition = exports.SEARCH_RECORD_MODEL_ID = exports.DEFAULT_FIELDS = void 0;
7
7
  var _createModelField = require("../utils/createModelField");
8
- const originalIdField = () => (0, _createModelField.createModelField)({
9
- label: "Original Id",
10
- type: "text",
11
- parent: "searchRecord",
12
- validation: [{
13
- name: "required",
14
- message: "Value is required."
15
- }, {
16
- name: "unique",
17
- message: "Value must be unique."
18
- }]
19
- });
20
8
  const typeField = () => (0, _createModelField.createModelField)({
21
9
  label: "Type",
22
10
  type: "text",
23
- parent: "searchRecord",
24
11
  validation: [{
25
12
  name: "required",
26
13
  message: "Value is required."
@@ -29,18 +16,23 @@ const typeField = () => (0, _createModelField.createModelField)({
29
16
  const titleField = () => (0, _createModelField.createModelField)({
30
17
  label: "Title",
31
18
  type: "text",
32
- parent: "searchRecord"
19
+ validation: [{
20
+ name: "required",
21
+ message: "Value is required."
22
+ }]
33
23
  });
34
24
  const contentField = () => (0, _createModelField.createModelField)({
35
25
  label: "Content",
36
- type: "text",
37
- parent: "searchRecord"
26
+ type: "text"
38
27
  });
39
28
  const locationField = fields => (0, _createModelField.createModelField)({
40
29
  label: "Location",
41
30
  type: "object",
42
- parent: "searchRecord",
43
31
  multipleValues: false,
32
+ validation: [{
33
+ name: "required",
34
+ message: "The location field must be populated."
35
+ }],
44
36
  settings: {
45
37
  fields
46
38
  }
@@ -48,26 +40,45 @@ const locationField = fields => (0, _createModelField.createModelField)({
48
40
  const locationFolderIdField = () => (0, _createModelField.createModelField)({
49
41
  label: "Folder Id",
50
42
  type: "text",
51
- parent: "searchRecord Location",
52
43
  validation: [{
53
44
  name: "required",
54
45
  message: "Value is required."
55
46
  }]
56
47
  });
57
- const dataField = () => (0, _createModelField.createModelField)({
58
- label: "Data",
59
- type: "wby-aco-json",
60
- parent: "searchRecord"
48
+ const dataField = fields => {
49
+ return (0, _createModelField.createModelField)({
50
+ label: "Data",
51
+ type: "object",
52
+ multipleValues: false,
53
+ validation: [{
54
+ name: "required",
55
+ message: "The data field must be populated."
56
+ }],
57
+ settings: {
58
+ fields
59
+ }
60
+ });
61
+ };
62
+ const tagsField = () => (0, _createModelField.createModelField)({
63
+ label: "Tags",
64
+ type: "text",
65
+ multipleValues: true,
66
+ validation: [{
67
+ name: "required",
68
+ message: "The tags field must be populated."
69
+ }]
61
70
  });
62
- const SEARCH_RECORD_MODEL_ID = "acoSearchRecordModelDefinition";
71
+ const SEARCH_RECORD_MODEL_ID = "acoSearchRecord";
63
72
  exports.SEARCH_RECORD_MODEL_ID = SEARCH_RECORD_MODEL_ID;
64
- const createSearchModelDefinition = () => {
73
+ const DEFAULT_FIELDS = ["type", "title", "content", "location", "data", "tags"];
74
+ exports.DEFAULT_FIELDS = DEFAULT_FIELDS;
75
+ const createSearchModelDefinition = params => {
65
76
  return {
66
77
  name: "ACO - Search Record",
67
78
  modelId: SEARCH_RECORD_MODEL_ID,
68
- titleFieldId: "originalId",
69
- layout: [["searchRecord_originalId"], ["searchRecord_type"], ["searchRecord_title"], ["searchRecord_content"], ["searchRecord_location"], ["searchRecord_data"]],
70
- fields: [originalIdField(), typeField(), titleField(), contentField(), locationField([locationFolderIdField()]), dataField()],
79
+ titleFieldId: "title",
80
+ layout: DEFAULT_FIELDS.map(field => [field]),
81
+ fields: [typeField(), titleField(), contentField(), locationField([locationFolderIdField()]), dataField(params === null || params === void 0 ? void 0 : params.fields), tagsField()],
71
82
  description: "ACO - Search record model",
72
83
  isPrivate: true
73
84
  };
@@ -1 +1 @@
1
- {"version":3,"names":["originalIdField","createModelField","label","type","parent","validation","name","message","typeField","titleField","contentField","locationField","fields","multipleValues","settings","locationFolderIdField","dataField","SEARCH_RECORD_MODEL_ID","createSearchModelDefinition","modelId","titleFieldId","layout","description","isPrivate"],"sources":["record.model.ts"],"sourcesContent":["import { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nimport { createModelField } from \"~/utils/createModelField\";\n\nexport type SearchRecordModelDefinition = Pick<\n CmsModel,\n \"name\" | \"modelId\" | \"layout\" | \"titleFieldId\" | \"description\" | \"fields\" | \"isPrivate\"\n>;\n\nconst originalIdField = () =>\n createModelField({\n label: \"Original Id\",\n type: \"text\",\n parent: \"searchRecord\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n },\n {\n name: \"unique\",\n message: \"Value must be unique.\"\n }\n ]\n });\n\nconst typeField = () =>\n createModelField({\n label: \"Type\",\n type: \"text\",\n parent: \"searchRecord\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n }\n ]\n });\n\nconst titleField = () =>\n createModelField({\n label: \"Title\",\n type: \"text\",\n parent: \"searchRecord\"\n });\n\nconst contentField = () =>\n createModelField({\n label: \"Content\",\n type: \"text\",\n parent: \"searchRecord\"\n });\n\nconst locationField = (fields: CmsModelField[]) =>\n createModelField({\n label: \"Location\",\n type: \"object\",\n parent: \"searchRecord\",\n multipleValues: false,\n settings: { fields }\n });\n\nconst locationFolderIdField = () =>\n createModelField({\n label: \"Folder Id\",\n type: \"text\",\n parent: \"searchRecord Location\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n }\n ]\n });\n\nconst dataField = () =>\n createModelField({\n label: \"Data\",\n type: \"wby-aco-json\",\n parent: \"searchRecord\"\n });\n\nexport const SEARCH_RECORD_MODEL_ID = \"acoSearchRecordModelDefinition\";\n\nexport const createSearchModelDefinition = (): SearchRecordModelDefinition => {\n return {\n name: \"ACO - Search Record\",\n modelId: SEARCH_RECORD_MODEL_ID,\n titleFieldId: \"originalId\",\n layout: [\n [\"searchRecord_originalId\"],\n [\"searchRecord_type\"],\n [\"searchRecord_title\"],\n [\"searchRecord_content\"],\n [\"searchRecord_location\"],\n [\"searchRecord_data\"]\n ],\n fields: [\n originalIdField(),\n typeField(),\n titleField(),\n contentField(),\n locationField([locationFolderIdField()]),\n dataField()\n ],\n description: \"ACO - Search record model\",\n isPrivate: true\n };\n};\n"],"mappings":";;;;;;AAEA;AAOA,MAAMA,eAAe,GAAG,MACpB,IAAAC,kCAAgB,EAAC;EACbC,KAAK,EAAE,aAAa;EACpBC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,cAAc;EACtBC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC,EACD;IACID,IAAI,EAAE,QAAQ;IACdC,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAMC,SAAS,GAAG,MACd,IAAAP,kCAAgB,EAAC;EACbC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,cAAc;EACtBC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAME,UAAU,GAAG,MACf,IAAAR,kCAAgB,EAAC;EACbC,KAAK,EAAE,OAAO;EACdC,IAAI,E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a,CAAC,CAACI,qBAAqB,EAAE,CAAC,CAAC,EACxCC,SAAS,EAAE,CACd;IACDM,WAAW,EAAE,2BAA2B;IACxCC,SAAS,EAAE;EACf,CAAC;AACL,CAAC;AAAC"}
1
+ {"version":3,"names":["typeField","createModelField","label","type","validation","name","message","titleField","contentField","locationField","fields","multipleValues","settings","locationFolderIdField","dataField","tagsField","SEARCH_RECORD_MODEL_ID","DEFAULT_FIELDS","createSearchModelDefinition","params","modelId","titleFieldId","layout","map","field","description","isPrivate"],"sources":["record.model.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport { createModelField } from \"~/utils/createModelField\";\nimport { CmsPrivateModelFull } from \"@webiny/api-headless-cms\";\n\nexport type SearchRecordModelDefinition = Omit<CmsPrivateModelFull, \"noValidate\" | \"group\">;\n\nconst typeField = () =>\n createModelField({\n label: \"Type\",\n type: \"text\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n }\n ]\n });\n\nconst titleField = () =>\n createModelField({\n label: \"Title\",\n type: \"text\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n }\n ]\n });\n\nconst contentField = () =>\n createModelField({\n label: \"Content\",\n type: \"text\"\n });\n\nconst locationField = (fields: CmsModelField[]) =>\n createModelField({\n label: \"Location\",\n type: \"object\",\n multipleValues: false,\n validation: [\n {\n name: \"required\",\n message: \"The location field must be populated.\"\n }\n ],\n settings: {\n fields\n }\n });\n\nconst locationFolderIdField = () =>\n createModelField({\n label: \"Folder Id\",\n type: \"text\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n }\n ]\n });\n\nconst dataField = (fields?: CmsModelField[]) => {\n return createModelField({\n label: \"Data\",\n type: \"object\",\n multipleValues: false,\n validation: [\n {\n name: \"required\",\n message: \"The data field must be populated.\"\n }\n ],\n settings: {\n fields\n }\n });\n};\n\nconst tagsField = () =>\n createModelField({\n label: \"Tags\",\n type: \"text\",\n multipleValues: true,\n validation: [\n {\n name: \"required\",\n message: \"The tags field must be populated.\"\n }\n ]\n });\n\nexport const SEARCH_RECORD_MODEL_ID = \"acoSearchRecord\";\n\ninterface CreateSearchModelDefinitionParams {\n fields?: CmsModelField[];\n}\n\nexport const DEFAULT_FIELDS = [\"type\", \"title\", \"content\", \"location\", \"data\", \"tags\"];\n\nexport const createSearchModelDefinition = (\n params?: CreateSearchModelDefinitionParams\n): SearchRecordModelDefinition => {\n return {\n name: \"ACO - Search Record\",\n modelId: SEARCH_RECORD_MODEL_ID,\n titleFieldId: \"title\",\n layout: DEFAULT_FIELDS.map(field => [field]),\n fields: [\n typeField(),\n titleField(),\n contentField(),\n locationField([locationFolderIdField()]),\n dataField(params?.fields),\n tagsField()\n ],\n description: \"ACO - Search record model\",\n isPrivate: true\n };\n};\n"],"mappings":";;;;;;AACA;AAKA,MAAMA,SAAS,GAAG,MACd,IAAAC,kCAAgB,EAAC;EACbC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAE,MAAM;EACZC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAMC,UAAU,GAAG,MACf,IAAAN,kCAAgB,EAAC;EACbC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAME,YAAY,GAAG,MACjB,IAAAP,kCAAgB,EAAC;EACbC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAE;AACV,CAAC,CAAC;AAEN,MAAMM,aAAa,GAAIC,MAAuB,IAC1C,IAAAT,kCAAgB,EAAC;EACbC,KAAK,EAAE,UAAU;EACjBC,IAAI,EAAE,QAAQ;EACdQ,cAAc,EAAE,KAAK;EACrBP,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC,CACJ;EACDM,QAA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BAAqB,EAAE,CAAC,CAAC,EACxCC,SAAS,CAACK,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAET,MAAM,CAAC,EACzBK,SAAS,EAAE,CACd;IACDU,WAAW,EAAE,2BAA2B;IACxCC,SAAS,EAAE;EACf,CAAC;AACL,CAAC;AAAC"}
@@ -1,8 +1,3 @@
1
- import { CmsModel } from "@webiny/api-headless-cms/types";
2
1
  import { CreateAcoStorageOperationsParams } from "../createAcoStorageOperations";
3
- import { AcoSearchRecordStorageOperations as BaseAcoSearchRecordStorageOperations } from "./record.types";
4
- interface AcoSearchRecordStorageOperations extends BaseAcoSearchRecordStorageOperations {
5
- getRecordModel(): Promise<CmsModel>;
6
- }
2
+ import { AcoSearchRecordStorageOperations } from "./record.types";
7
3
  export declare const createSearchRecordOperations: (params: CreateAcoStorageOperationsParams) => AcoSearchRecordStorageOperations;
8
- export {};
@@ -5,95 +5,145 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.createSearchRecordOperations = void 0;
8
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
8
9
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
10
  var _error = _interopRequireDefault(require("@webiny/error"));
10
- var _record = require("./record.model");
11
- var _createAcoStorageOperations = require("../createAcoStorageOperations");
12
11
  var _getFieldValues = require("../utils/getFieldValues");
12
+ var _acoRecordId = require("../utils/acoRecordId");
13
+ var _record = require("./record.model");
14
+ const _excluded = ["tags", "data"];
13
15
  const createSearchRecordOperations = params => {
14
16
  const {
15
17
  cms,
16
18
  security
17
19
  } = params;
18
- const getRecordModel = async () => {
19
- security.disableAuthorization();
20
- const model = await cms.getModel(_record.SEARCH_RECORD_MODEL_ID);
21
- security.enableAuthorization();
22
- if (!model) {
23
- throw new _error.default(`Could not find "${_record.SEARCH_RECORD_MODEL_ID}" model.`, "MODEL_NOT_FOUND_ERROR");
24
- }
25
- return model;
26
- };
27
- const getRecord = async ({
28
- id
29
- }) => {
30
- const model = await getRecordModel();
31
- security.disableAuthorization();
32
-
20
+ const getRecord = async (model, id) => {
33
21
  /**
34
- * The record "id" is generated on creation.
35
- * Still, we need to get/update/delete records by the original entry id.
22
+ * The record "id" has been passed by the original entry.
23
+ * We need to retrieve it via `cms.storageOperations.entries.getLatestByIds()` method and return the first one.
36
24
  */
37
- const entry = await cms.getEntry(model, {
38
- where: {
39
- originalId: id,
40
- latest: true
41
- }
25
+ const revisions = await cms.storageOperations.entries.getLatestByIds(model, {
26
+ ids: [(0, _acoRecordId.attachAcoRecordPrefix)(id)]
42
27
  });
43
- if (!entry) {
44
- throw new _error.default("Could not load record.", "GET_ENTRY_ERROR", {
28
+ if (revisions.length === 0) {
29
+ throw new _error.default("Record not found.", "NOT_FOUND", {
45
30
  id
46
31
  });
47
32
  }
48
- security.enableAuthorization();
49
- return (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields);
33
+ return revisions[0];
50
34
  };
51
35
  return {
52
- getRecordModel,
53
- getRecord,
54
- async listRecords(params) {
55
- const model = await getRecordModel();
56
- security.disableAuthorization();
57
- const [entries, meta] = await cms.listLatestEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
58
- where: (0, _objectSpread2.default)({}, params.where || {})
59
- }));
60
- security.enableAuthorization();
61
- return [entries.map(entry => (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields)), meta];
36
+ async getRecord(model, {
37
+ id
38
+ }) {
39
+ return security.withoutAuthorization(async () => {
40
+ const record = await getRecord(model, id);
41
+ return (0, _getFieldValues.getRecordFieldValues)(record);
42
+ });
62
43
  },
63
- async createRecord({
64
- data
44
+ listRecords(model, params) {
45
+ return security.withoutAuthorization(async () => {
46
+ const {
47
+ sort,
48
+ where
49
+ } = params;
50
+ const [entries, meta] = await cms.listLatestEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
51
+ sort,
52
+ where: (0, _objectSpread2.default)({}, where || {})
53
+ }));
54
+ return [entries.map(entry => (0, _getFieldValues.getRecordFieldValues)(entry)), meta];
55
+ });
56
+ },
57
+ listTags(model, params) {
58
+ return security.withoutAuthorization(async () => {
59
+ const {
60
+ where
61
+ } = params;
62
+ const items = await cms.getUniqueFieldValues(model, {
63
+ where: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, where || {}), {}, {
64
+ latest: true
65
+ }),
66
+ fieldId: "tags"
67
+ });
68
+ const meta = {
69
+ hasMoreItems: false,
70
+ totalCount: items.length,
71
+ cursor: null
72
+ };
73
+ const tags = items.map(item => {
74
+ return {
75
+ tag: item.value,
76
+ count: item.count
77
+ };
78
+ });
79
+ return [tags, meta];
80
+ });
81
+ },
82
+ createRecord(model, {
83
+ data: SearchRecordData
65
84
  }) {
66
- const model = await getRecordModel();
67
- security.disableAuthorization();
68
- const entry = await cms.createEntry(model, data);
69
- security.enableAuthorization();
70
- return (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields);
85
+ return security.withoutAuthorization(async () => {
86
+ const {
87
+ tags = [],
88
+ data = {}
89
+ } = SearchRecordData,
90
+ rest = (0, _objectWithoutProperties2.default)(SearchRecordData, _excluded);
91
+ const entry = await cms.createEntry(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({
92
+ tags,
93
+ data
94
+ }, rest), {}, {
95
+ id: (0, _acoRecordId.attachAcoRecordPrefix)(rest.id)
96
+ }));
97
+ return (0, _getFieldValues.getRecordFieldValues)(entry);
98
+ });
71
99
  },
72
- async updateRecord({
100
+ updateRecord(model, {
73
101
  id,
74
102
  data
75
103
  }) {
76
- const model = await getRecordModel();
77
- security.disableAuthorization();
78
- const original = await getRecord({
79
- id
104
+ return security.withoutAuthorization(async () => {
105
+ const original = await this.getRecord(model, {
106
+ id
107
+ });
108
+ const input = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, original), data);
109
+ const entry = await cms.updateEntry(model, (0, _acoRecordId.attachAcoRecordPrefix)(original.id), input);
110
+ return (0, _getFieldValues.getRecordFieldValues)(entry);
111
+ });
112
+ },
113
+ moveRecord(model, params) {
114
+ const {
115
+ id,
116
+ folderId
117
+ } = params;
118
+ return security.withoutAuthorization(async () => {
119
+ const original = await this.getRecord(model, {
120
+ id
121
+ });
122
+ const input = {
123
+ wbyAco_location: {
124
+ folderId
125
+ }
126
+ };
127
+ /**
128
+ * We only apply the location to the search record model as we do not want to override the users data.
129
+ */
130
+ const lookFor = `${_record.SEARCH_RECORD_MODEL_ID}-`;
131
+ if (model.modelId.substring(0, lookFor.length) === lookFor) {
132
+ input.location = {
133
+ folderId
134
+ };
135
+ }
136
+ await cms.updateEntry(model, (0, _acoRecordId.attachAcoRecordPrefix)(original.id), input);
137
+ return true;
80
138
  });
81
- const input = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, original), data);
82
- const entry = await cms.updateEntry(model, original.id, input);
83
- security.enableAuthorization();
84
- return (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields);
85
139
  },
86
- async deleteRecord({
140
+ deleteRecord(model, {
87
141
  id
88
142
  }) {
89
- const model = await getRecordModel();
90
- security.disableAuthorization();
91
- const entry = await getRecord({
92
- id
143
+ return security.withoutAuthorization(async () => {
144
+ await cms.deleteEntry(model, (0, _acoRecordId.attachAcoRecordPrefix)(id));
145
+ return true;
93
146
  });
94
- await cms.deleteEntry(model, entry.id);
95
- security.enableAuthorization();
96
- return true;
97
147
  }
98
148
  };
99
149
  };