@webiny/api-aco 0.0.0-unstable.d7f521b032 → 0.0.0-unstable.df6d94b531
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/createAcoGraphQL.js +10 -9
- package/createAcoGraphQL.js.map +1 -1
- package/folder/folder.gql.js +1 -1
- package/folder/folder.gql.js.map +1 -1
- package/folder/folder.model.d.ts +4 -2
- package/folder/folder.model.js +1 -1
- package/folder/folder.model.js.map +1 -1
- package/folder/folder.so.d.ts +1 -6
- package/folder/folder.so.js +103 -108
- package/folder/folder.so.js.map +1 -1
- package/folder/folder.types.d.ts +2 -2
- package/folder/folder.types.js.map +1 -1
- package/folder/onFolderBeforeDelete.hook.js +11 -11
- package/folder/onFolderBeforeDelete.hook.js.map +1 -1
- package/package.json +22 -21
- package/record/record.gql.js +2 -3
- package/record/record.gql.js.map +1 -1
- package/record/record.model.d.ts +4 -2
- package/record/record.model.js +4 -16
- package/record/record.model.js.map +1 -1
- package/record/record.so.d.ts +1 -6
- package/record/record.so.js +57 -59
- package/record/record.so.js.map +1 -1
- package/record/record.types.d.ts +3 -4
- package/record/record.types.js.map +1 -1
- package/types.d.ts +5 -0
- package/types.js +8 -1
- package/types.js.map +1 -1
- package/utils/createListSort.d.ts +2 -0
- package/utils/createListSort.js +13 -0
- package/utils/createListSort.js.map +1 -0
- package/utils/createOperationsWrapper.d.ts +9 -0
- package/utils/createOperationsWrapper.js +29 -0
- package/utils/createOperationsWrapper.js.map +1 -0
- package/utils/getFieldValues.d.ts +1 -1
- package/utils/getFieldValues.js +9 -2
- package/utils/getFieldValues.js.map +1 -1
- package/utils/modelFactory.d.ts +3 -1
- package/utils/modelFactory.js.map +1 -1
package/createAcoGraphQL.js
CHANGED
|
@@ -51,15 +51,16 @@ const baseSchema = new _handlerGraphql.GraphQLSchemaPlugin({
|
|
|
51
51
|
error: AcoError
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
enum
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
enum AcoSortDirection {
|
|
55
|
+
ASC
|
|
56
|
+
DESC
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
input AcoSort {
|
|
60
|
+
id: AcoSortDirection
|
|
61
|
+
createdOn: AcoSortDirection
|
|
62
|
+
savedOn: AcoSortDirection
|
|
63
|
+
title: AcoSortDirection
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
extend type Query {
|
package/createAcoGraphQL.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["emptyResolver","baseSchema","GraphQLSchemaPlugin","typeDefs","resolvers","Query","aco","search","Mutation","createAcoGraphQL","ContextPlugin","context","plugins","register","folderSchema","searchRecordSchema"],"sources":["createAcoGraphQL.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\n\nimport { folderSchema } from \"~/folder/folder.gql\";\nimport { searchRecordSchema } from \"~/record/record.gql\";\n\nimport { AcoContext } from \"~/types\";\n\nconst emptyResolver = () => ({});\n\nconst baseSchema = new GraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type AcoQuery {\n _empty: String\n }\n\n type AcoMutation {\n _empty: String\n }\n\n type SearchQuery {\n _empty: String\n }\n\n type SearchMutation {\n _empty: String\n }\n\n type AcoMeta {\n hasMoreItems: Boolean\n totalCount: Int\n cursor: String\n }\n\n type AcoUser {\n id: ID\n displayName: String\n type: String\n }\n\n type AcoError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type AcoBooleanResponse {\n data: Boolean\n error: AcoError\n }\n\n enum
|
|
1
|
+
{"version":3,"names":["emptyResolver","baseSchema","GraphQLSchemaPlugin","typeDefs","resolvers","Query","aco","search","Mutation","createAcoGraphQL","ContextPlugin","context","plugins","register","folderSchema","searchRecordSchema"],"sources":["createAcoGraphQL.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\n\nimport { folderSchema } from \"~/folder/folder.gql\";\nimport { searchRecordSchema } from \"~/record/record.gql\";\n\nimport { AcoContext } from \"~/types\";\n\nconst emptyResolver = () => ({});\n\nconst baseSchema = new GraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type AcoQuery {\n _empty: String\n }\n\n type AcoMutation {\n _empty: String\n }\n\n type SearchQuery {\n _empty: String\n }\n\n type SearchMutation {\n _empty: String\n }\n\n type AcoMeta {\n hasMoreItems: Boolean\n totalCount: Int\n cursor: String\n }\n\n type AcoUser {\n id: ID\n displayName: String\n type: String\n }\n\n type AcoError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type AcoBooleanResponse {\n data: Boolean\n error: AcoError\n }\n\n enum AcoSortDirection {\n ASC\n DESC\n }\n\n input AcoSort {\n id: AcoSortDirection\n createdOn: AcoSortDirection\n savedOn: AcoSortDirection\n title: AcoSortDirection\n }\n\n extend type Query {\n aco: AcoQuery\n search: SearchQuery\n }\n\n extend type Mutation {\n aco: AcoMutation\n search: SearchMutation\n }\n `,\n resolvers: {\n Query: {\n aco: emptyResolver,\n search: emptyResolver\n },\n Mutation: {\n aco: emptyResolver,\n search: emptyResolver\n }\n }\n});\n\nexport const createAcoGraphQL = () => {\n return new ContextPlugin<AcoContext>(context => {\n context.plugins.register([baseSchema, folderSchema, searchRecordSchema]);\n });\n};\n"],"mappings":";;;;;;AAAA;AACA;AAEA;AACA;AAIA,MAAMA,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC;AAEhC,MAAMC,UAAU,GAAG,IAAIC,mCAAmB,CAAC;EACvCC,QAAQ,EAAE,aAAe;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EACDC,SAAS,EAAE;IACPC,KAAK,EAAE;MACHC,GAAG,EAAEN,aAAa;MAClBO,MAAM,EAAEP;IACZ,CAAC;IACDQ,QAAQ,EAAE;MACNF,GAAG,EAAEN,aAAa;MAClBO,MAAM,EAAEP;IACZ;EACJ;AACJ,CAAC,CAAC;AAEK,MAAMS,gBAAgB,GAAG,MAAM;EAClC,OAAO,IAAIC,kBAAa,CAAaC,OAAO,IAAI;IAC5CA,OAAO,CAACC,OAAO,CAACC,QAAQ,CAAC,CAACZ,UAAU,EAAEa,oBAAY,EAAEC,0BAAkB,CAAC,CAAC;EAC5E,CAAC,CAAC;AACN,CAAC;AAAC"}
|
package/folder/folder.gql.js
CHANGED
package/folder/folder.gql.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["folderSchema","GraphQLSchemaPlugin","typeDefs","resolvers","AcoQuery","getFolder","_","id","context","resolve","aco","folder","get","listFolders","args","entries","meta","list","ListResponse","e","ErrorResponse","AcoMutation","createFolder","data","create","updateFolder","update","deleteFolder","delete"],"sources":["folder.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 folderSchema = new GraphQLSchemaPlugin<AcoContext>({\n typeDefs: /* GraphQL */ `\n type Folder {\n id: ID!\n title: String!\n slug: String!\n type: String!\n parentId: ID\n savedOn: DateTime\n createdOn: DateTime\n createdBy: AcoUser\n }\n\n input FolderCreateInput {\n title: String!\n slug: String!\n type: String!\n parentId: ID\n }\n\n input FolderUpdateInput {\n title: String\n slug: String\n parentId: ID\n }\n\n input FoldersListWhereInput {\n type: String!\n parentId: String\n }\n\n type FolderResponse {\n data: Folder\n error: AcoError\n }\n\n type FoldersListResponse {\n data: [Folder]\n error: AcoError\n }\n\n extend type AcoQuery {\n getFolder(id: ID!): FolderResponse\n listFolders(\n where: FoldersListWhereInput!\n limit: Int\n after: String\n sort:
|
|
1
|
+
{"version":3,"names":["folderSchema","GraphQLSchemaPlugin","typeDefs","resolvers","AcoQuery","getFolder","_","id","context","resolve","aco","folder","get","listFolders","args","entries","meta","list","ListResponse","e","ErrorResponse","AcoMutation","createFolder","data","create","updateFolder","update","deleteFolder","delete"],"sources":["folder.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 folderSchema = new GraphQLSchemaPlugin<AcoContext>({\n typeDefs: /* GraphQL */ `\n type Folder {\n id: ID!\n title: String!\n slug: String!\n type: String!\n parentId: ID\n savedOn: DateTime\n createdOn: DateTime\n createdBy: AcoUser\n }\n\n input FolderCreateInput {\n title: String!\n slug: String!\n type: String!\n parentId: ID\n }\n\n input FolderUpdateInput {\n title: String\n slug: String\n parentId: ID\n }\n\n input FoldersListWhereInput {\n type: String!\n parentId: String\n }\n\n type FolderResponse {\n data: Folder\n error: AcoError\n }\n\n type FoldersListResponse {\n data: [Folder]\n error: AcoError\n }\n\n extend type AcoQuery {\n getFolder(id: ID!): FolderResponse\n listFolders(\n where: FoldersListWhereInput!\n limit: Int\n after: String\n sort: AcoSort\n ): FoldersListResponse\n }\n\n extend type AcoMutation {\n createFolder(data: FolderCreateInput!): FolderResponse\n updateFolder(id: ID!, data: FolderUpdateInput!): FolderResponse\n deleteFolder(id: ID!): AcoBooleanResponse\n }\n `,\n resolvers: {\n AcoQuery: {\n getFolder: async (_, { id }, context) => {\n return resolve(() => context.aco.folder.get(id));\n },\n listFolders: async (_, args: any, context) => {\n try {\n const [entries, meta] = await context.aco.folder.list(args);\n return new ListResponse(entries, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n AcoMutation: {\n createFolder: async (_, { data }, context) => {\n return resolve(() => context.aco.folder.create(data));\n },\n updateFolder: async (_, { id, data }, context) => {\n return resolve(() => context.aco.folder.update(id, data));\n },\n deleteFolder: async (_, { id }, context) => {\n return resolve(() => context.aco.folder.delete(id));\n }\n }\n }\n});\n"],"mappings":";;;;;;AAAA;AACA;AAEA;AAIO,MAAMA,YAAY,GAAG,IAAIC,wCAAmB,CAAa;EAC5DC,QAAQ,EAAE,aAAe;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EACDC,SAAS,EAAE;IACPC,QAAQ,EAAE;MACNC,SAAS,EAAE,OAAOC,CAAC,EAAE;QAAEC;MAAG,CAAC,EAAEC,OAAO,KAAK;QACrC,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,GAAG,CAACC,MAAM,CAACC,GAAG,CAACL,EAAE,CAAC,CAAC;MACpD,CAAC;MACDM,WAAW,EAAE,OAAOP,CAAC,EAAEQ,IAAS,EAAEN,OAAO,KAAK;QAC1C,IAAI;UACA,MAAM,CAACO,OAAO,EAAEC,IAAI,CAAC,GAAG,MAAMR,OAAO,CAACE,GAAG,CAACC,MAAM,CAACM,IAAI,CAACH,IAAI,CAAC;UAC3D,OAAO,IAAII,uBAAY,CAACH,OAAO,EAAEC,IAAI,CAAC;QAC1C,CAAC,CAAC,OAAOG,CAAC,EAAE;UACR,OAAO,IAAIC,wBAAa,CAACD,CAAC,CAAC;QAC/B;MACJ;IACJ,CAAC;IACDE,WAAW,EAAE;MACTC,YAAY,EAAE,OAAOhB,CAAC,EAAE;QAAEiB;MAAK,CAAC,EAAEf,OAAO,KAAK;QAC1C,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,GAAG,CAACC,MAAM,CAACa,MAAM,CAACD,IAAI,CAAC,CAAC;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"}
|
package/folder/folder.model.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
2
|
-
export declare type FolderModelDefinition = Pick<CmsModel, "name" | "modelId" | "layout" | "titleFieldId" | "description" | "fields" | "isPrivate"
|
|
3
|
-
|
|
2
|
+
export declare type FolderModelDefinition = Pick<CmsModel, "name" | "modelId" | "layout" | "titleFieldId" | "description" | "fields" | "isPrivate"> & {
|
|
3
|
+
isPrivate: true;
|
|
4
|
+
};
|
|
5
|
+
export declare const FOLDER_MODEL_ID = "acoFolder";
|
|
4
6
|
export declare const createFolderModelDefinition: () => FolderModelDefinition;
|
package/folder/folder.model.js
CHANGED
|
@@ -63,7 +63,7 @@ const parentIdField = () => (0, _createModelField.createModelField)({
|
|
|
63
63
|
type: "text",
|
|
64
64
|
parent: "folder"
|
|
65
65
|
});
|
|
66
|
-
const FOLDER_MODEL_ID = "
|
|
66
|
+
const FOLDER_MODEL_ID = "acoFolder";
|
|
67
67
|
exports.FOLDER_MODEL_ID = FOLDER_MODEL_ID;
|
|
68
68
|
const createFolderModelDefinition = () => {
|
|
69
69
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["titleField","createModelField","label","type","parent","validation","name","message","settings","value","slugField","preset","regex","flags","typeField","parentIdField","FOLDER_MODEL_ID","createFolderModelDefinition","modelId","titleFieldId","layout","fields","description","isPrivate"],"sources":["folder.model.ts"],"sourcesContent":["import { CmsModel } from \"@webiny/api-headless-cms/types\";\n\nimport { createModelField } from \"~/utils/createModelField\";\n\nexport type FolderModelDefinition = Pick<\n CmsModel,\n \"name\" | \"modelId\" | \"layout\" | \"titleFieldId\" | \"description\" | \"fields\" | \"isPrivate\"\n
|
|
1
|
+
{"version":3,"names":["titleField","createModelField","label","type","parent","validation","name","message","settings","value","slugField","preset","regex","flags","typeField","parentIdField","FOLDER_MODEL_ID","createFolderModelDefinition","modelId","titleFieldId","layout","fields","description","isPrivate"],"sources":["folder.model.ts"],"sourcesContent":["import { CmsModel } from \"@webiny/api-headless-cms/types\";\n\nimport { createModelField } from \"~/utils/createModelField\";\n\nexport type FolderModelDefinition = Pick<\n CmsModel,\n \"name\" | \"modelId\" | \"layout\" | \"titleFieldId\" | \"description\" | \"fields\" | \"isPrivate\"\n> & { isPrivate: true };\n\nconst titleField = () =>\n createModelField({\n label: \"Title\",\n type: \"text\",\n parent: \"folder\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n },\n {\n name: \"minLength\",\n settings: {\n value: \"3\"\n },\n message: \"Value is too short.\"\n }\n ]\n });\n\nconst slugField = () =>\n createModelField({\n label: \"Slug\",\n type: \"text\",\n parent: \"folder\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n },\n {\n name: \"minLength\",\n settings: {\n value: \"3\"\n },\n message: \"Value is too short.\"\n },\n {\n name: \"maxLength\",\n settings: {\n value: \"100\"\n },\n message: \"Value is too long.\"\n },\n {\n name: \"pattern\",\n settings: {\n preset: \"custom\",\n regex: \"^[a-z0-9]+(-[a-z0-9]+)*$\",\n flags: \"g\"\n },\n message: \"Value must consist of only 'a-z', '0-9' and '-'.\"\n }\n ]\n });\n\nconst typeField = () =>\n createModelField({\n label: \"Type\",\n type: \"text\",\n parent: \"folder\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n }\n ]\n });\n\nconst parentIdField = () =>\n createModelField({\n label: \"Parent Id\",\n type: \"text\",\n parent: \"folder\"\n });\n\nexport const FOLDER_MODEL_ID = \"acoFolder\";\n\nexport const createFolderModelDefinition = (): FolderModelDefinition => {\n return {\n name: \"ACO - Folder\",\n modelId: FOLDER_MODEL_ID,\n titleFieldId: \"title\",\n layout: [[\"folder_title\"], [\"folder_slug\"], [\"folder_type\"], [\"folder_parentId\"]],\n fields: [titleField(), slugField(), typeField(), parentIdField()],\n description: \"ACO - Folder content model\",\n isPrivate: true\n };\n};\n"],"mappings":";;;;;;AAEA;AAOA,MAAMA,UAAU,GAAG,MACf,IAAAC,kCAAgB,EAAC;EACbC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,QAAQ;EAChBC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC,EACD;IACID,IAAI,EAAE,WAAW;IACjBE,QAAQ,EAAE;MACNC,KAAK,EAAE;IACX,CAAC;IACDF,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAMG,SAAS,GAAG,MACd,IAAAT,kCAAgB,EAAC;EACbC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,QAAQ;EAChBC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC,EACD;IACID,IAAI,EAAE,WAAW;IACjBE,QAAQ,EAAE;MACNC,KAAK,EAAE;IACX,CAAC;IACDF,OAAO,EAAE;EACb,CAAC,EACD;IACID,IAAI,EAAE,WAAW;IACjBE,QAAQ,EAAE;MACNC,KAAK,EAAE;IACX,CAAC;IACDF,OAAO,EAAE;EACb,CAAC,EACD;IACID,IAAI,EAAE,SAAS;IACfE,QAAQ,EAAE;MACNG,MAAM,EAAE,QAAQ;MAChBC,KAAK,EAAE,0BAA0B;MACjCC,KAAK,EAAE;IACX,CAAC;IACDN,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAMO,SAAS,GAAG,MACd,IAAAb,kCAAgB,EAAC;EACbC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,QAAQ;EAChBC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAMQ,aAAa,GAAG,MAClB,IAAAd,kCAAgB,EAAC;EACbC,KAAK,EAAE,WAAW;EAClBC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE;AACZ,CAAC,CAAC;AAEC,MAAMY,eAAe,GAAG,WAAW;AAAC;AAEpC,MAAMC,2BAA2B,GAAG,MAA6B;EACpE,OAAO;IACHX,IAAI,EAAE,cAAc;IACpBY,OAAO,EAAEF,eAAe;IACxBG,YAAY,EAAE,OAAO;IACrBC,MAAM,EAAE,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC;IACjFC,MAAM,EAAE,CAACrB,UAAU,EAAE,EAAEU,SAAS,EAAE,EAAEI,SAAS,EAAE,EAAEC,aAAa,EAAE,CAAC;IACjEO,WAAW,EAAE,4BAA4B;IACzCC,SAAS,EAAE;EACf,CAAC;AACL,CAAC;AAAC"}
|
package/folder/folder.so.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
2
1
|
import { CreateAcoStorageOperationsParams } from "../createAcoStorageOperations";
|
|
3
|
-
import { AcoFolderStorageOperations
|
|
4
|
-
interface AcoFolderStorageOperations extends BaseAcoFolderStorageOperations {
|
|
5
|
-
getFolderModel(): Promise<CmsModel>;
|
|
6
|
-
}
|
|
2
|
+
import { AcoFolderStorageOperations } from "./folder.types";
|
|
7
3
|
export declare const createFolderOperations: (params: CreateAcoStorageOperationsParams) => AcoFolderStorageOperations;
|
|
8
|
-
export {};
|
package/folder/folder.so.js
CHANGED
|
@@ -9,147 +9,142 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/obje
|
|
|
9
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
10
|
var _folder = require("./folder.model");
|
|
11
11
|
var _createAcoStorageOperations = require("../createAcoStorageOperations");
|
|
12
|
+
var _createListSort = require("../utils/createListSort");
|
|
13
|
+
var _createOperationsWrapper = require("../utils/createOperationsWrapper");
|
|
12
14
|
var _getFieldValues = require("../utils/getFieldValues");
|
|
13
15
|
const createFolderOperations = params => {
|
|
14
16
|
const {
|
|
15
|
-
cms
|
|
16
|
-
security
|
|
17
|
+
cms
|
|
17
18
|
} = params;
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
return model;
|
|
26
|
-
};
|
|
27
|
-
const getFolder = async ({
|
|
19
|
+
const {
|
|
20
|
+
withModel
|
|
21
|
+
} = (0, _createOperationsWrapper.createOperationsWrapper)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
22
|
+
modelName: _folder.FOLDER_MODEL_ID
|
|
23
|
+
}));
|
|
24
|
+
const getFolder = ({
|
|
28
25
|
id,
|
|
29
26
|
slug,
|
|
30
27
|
type,
|
|
31
28
|
parentId
|
|
32
29
|
}) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
return withModel(async model => {
|
|
31
|
+
let entry;
|
|
32
|
+
if (id) {
|
|
33
|
+
entry = await cms.getEntryById(model, id);
|
|
34
|
+
} else if (slug && type) {
|
|
35
|
+
entry = await cms.getEntry(model, {
|
|
36
|
+
where: {
|
|
37
|
+
slug,
|
|
38
|
+
type,
|
|
39
|
+
parentId,
|
|
40
|
+
latest: true
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (!entry) {
|
|
45
|
+
throw new _error.default("Could not load folder.", "GET_FOLDER_ERROR", {
|
|
46
|
+
id,
|
|
41
47
|
slug,
|
|
42
48
|
type,
|
|
43
|
-
parentId
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
if (!entry) {
|
|
49
|
-
throw new _error.default("Could not load folder.", "GET_FOLDER_ERROR", {
|
|
50
|
-
id,
|
|
51
|
-
slug,
|
|
52
|
-
type,
|
|
53
|
-
parentId
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
security.enableAuthorization();
|
|
57
|
-
return (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields);
|
|
49
|
+
parentId
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields);
|
|
53
|
+
});
|
|
58
54
|
};
|
|
59
|
-
const checkExistingFolder =
|
|
55
|
+
const checkExistingFolder = ({
|
|
60
56
|
id,
|
|
61
57
|
params
|
|
62
58
|
}) => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const {
|
|
66
|
-
type,
|
|
67
|
-
slug,
|
|
68
|
-
parentId
|
|
69
|
-
} = params;
|
|
70
|
-
const [existings] = await cms.listLatestEntries(model, {
|
|
71
|
-
where: {
|
|
59
|
+
return withModel(async model => {
|
|
60
|
+
const {
|
|
72
61
|
type,
|
|
73
62
|
slug,
|
|
74
|
-
parentId
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
63
|
+
parentId
|
|
64
|
+
} = params;
|
|
65
|
+
const [existings] = await cms.listLatestEntries(model, {
|
|
66
|
+
where: {
|
|
67
|
+
type,
|
|
68
|
+
slug,
|
|
69
|
+
parentId,
|
|
70
|
+
id_not: id
|
|
71
|
+
},
|
|
72
|
+
limit: 1
|
|
83
73
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
74
|
+
if (existings.length > 0) {
|
|
75
|
+
throw new _error.default(`Folder with slug "${slug}" already exists at this level.`, "FOLDER_ALREADY_EXISTS", {
|
|
76
|
+
id,
|
|
77
|
+
params
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
});
|
|
87
82
|
};
|
|
88
83
|
return {
|
|
89
|
-
getFolderModel,
|
|
90
84
|
getFolder,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
85
|
+
listFolders(params) {
|
|
86
|
+
return withModel(async model => {
|
|
87
|
+
const {
|
|
88
|
+
sort,
|
|
89
|
+
where
|
|
90
|
+
} = params;
|
|
91
|
+
const [entries, meta] = await cms.listLatestEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
92
|
+
sort: (0, _createListSort.createListSort)(sort),
|
|
93
|
+
where: (0, _objectSpread2.default)({}, where || {})
|
|
94
|
+
}));
|
|
95
|
+
return [entries.map(entry => (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields)), meta];
|
|
96
|
+
});
|
|
99
97
|
},
|
|
100
|
-
|
|
98
|
+
createFolder({
|
|
101
99
|
data
|
|
102
100
|
}) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
101
|
+
return withModel(async model => {
|
|
102
|
+
await checkExistingFolder({
|
|
103
|
+
params: {
|
|
104
|
+
type: data.type,
|
|
105
|
+
slug: data.slug,
|
|
106
|
+
parentId: data.parentId
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
const entry = await cms.createEntry(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
|
|
110
|
+
parentId: data.parentId || null
|
|
111
|
+
}));
|
|
112
|
+
return (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields);
|
|
111
113
|
});
|
|
112
|
-
const entry = await cms.createEntry(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
|
|
113
|
-
parentId: data.parentId || null
|
|
114
|
-
}));
|
|
115
|
-
security.enableAuthorization();
|
|
116
|
-
return (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields);
|
|
117
114
|
},
|
|
118
|
-
|
|
115
|
+
updateFolder({
|
|
119
116
|
id,
|
|
120
117
|
data
|
|
121
118
|
}) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
});
|
|
119
|
+
return withModel(async model => {
|
|
120
|
+
const {
|
|
121
|
+
slug,
|
|
122
|
+
parentId
|
|
123
|
+
} = data;
|
|
124
|
+
const original = await getFolder({
|
|
125
|
+
id
|
|
126
|
+
});
|
|
127
|
+
await checkExistingFolder({
|
|
128
|
+
id,
|
|
129
|
+
params: {
|
|
130
|
+
type: original.type,
|
|
131
|
+
slug: slug || original.slug,
|
|
132
|
+
parentId: parentId !== undefined ? parentId : original.parentId // parentId can be `null`
|
|
133
|
+
}
|
|
134
|
+
});
|
|
139
135
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
136
|
+
const input = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, original), data);
|
|
137
|
+
const entry = await cms.updateEntry(model, id, input);
|
|
138
|
+
return (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields);
|
|
139
|
+
});
|
|
144
140
|
},
|
|
145
|
-
|
|
141
|
+
deleteFolder({
|
|
146
142
|
id
|
|
147
143
|
}) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return true;
|
|
144
|
+
return withModel(async model => {
|
|
145
|
+
await cms.deleteEntry(model, id);
|
|
146
|
+
return true;
|
|
147
|
+
});
|
|
153
148
|
}
|
|
154
149
|
};
|
|
155
150
|
};
|
package/folder/folder.so.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createFolderOperations","params","cms","
|
|
1
|
+
{"version":3,"names":["createFolderOperations","params","cms","withModel","createOperationsWrapper","modelName","FOLDER_MODEL_ID","getFolder","id","slug","type","parentId","model","entry","getEntryById","getEntry","where","latest","WebinyError","getFieldValues","baseFields","checkExistingFolder","existings","listLatestEntries","id_not","limit","length","listFolders","sort","entries","meta","createListSort","map","createFolder","data","createEntry","updateFolder","original","undefined","input","updateEntry","deleteFolder","deleteEntry"],"sources":["folder.so.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { FOLDER_MODEL_ID } from \"./folder.model\";\nimport { baseFields, CreateAcoStorageOperationsParams } from \"~/createAcoStorageOperations\";\nimport { createListSort } from \"~/utils/createListSort\";\nimport { createOperationsWrapper } from \"~/utils/createOperationsWrapper\";\nimport { getFieldValues } from \"~/utils/getFieldValues\";\n\nimport { AcoFolderStorageOperations } from \"./folder.types\";\n\ninterface AcoCheckExistingFolderParams {\n params: {\n type: string;\n slug: string;\n parentId?: string | null;\n };\n id?: string;\n}\n\nexport const createFolderOperations = (\n params: CreateAcoStorageOperationsParams\n): AcoFolderStorageOperations => {\n const { cms } = params;\n\n const { withModel } = createOperationsWrapper({\n ...params,\n modelName: FOLDER_MODEL_ID\n });\n\n const getFolder: AcoFolderStorageOperations[\"getFolder\"] = ({ id, slug, type, parentId }) => {\n return withModel(async model => {\n let entry;\n\n if (id) {\n entry = await cms.getEntryById(model, id);\n } else if (slug && type) {\n entry = await cms.getEntry(model, {\n where: { slug, type, parentId, latest: true }\n });\n }\n\n if (!entry) {\n throw new WebinyError(\"Could not load folder.\", \"GET_FOLDER_ERROR\", {\n id,\n slug,\n type,\n parentId\n });\n }\n\n return getFieldValues(entry, baseFields);\n });\n };\n\n const checkExistingFolder = ({ id, params }: AcoCheckExistingFolderParams) => {\n return withModel(async model => {\n const { type, slug, parentId } = params;\n\n const [existings] = await cms.listLatestEntries(model, {\n where: {\n type,\n slug,\n parentId,\n id_not: id\n },\n limit: 1\n });\n\n if (existings.length > 0) {\n throw new WebinyError(\n `Folder with slug \"${slug}\" already exists at this level.`,\n \"FOLDER_ALREADY_EXISTS\",\n {\n id,\n params\n }\n );\n }\n\n return;\n });\n };\n\n return {\n getFolder,\n listFolders(params) {\n return withModel(async model => {\n const { sort, where } = params;\n\n const [entries, meta] = await cms.listLatestEntries(model, {\n ...params,\n sort: createListSort(sort),\n where: {\n ...(where || {})\n }\n });\n\n return [entries.map(entry => getFieldValues(entry, baseFields)), meta];\n });\n },\n createFolder({ data }) {\n return withModel(async model => {\n await checkExistingFolder({\n params: {\n type: data.type,\n slug: data.slug,\n parentId: data.parentId\n }\n });\n\n const entry = await cms.createEntry(model, {\n ...data,\n parentId: data.parentId || null\n });\n\n return getFieldValues(entry, baseFields);\n });\n },\n updateFolder({ id, data }) {\n return withModel(async model => {\n const { slug, parentId } = data;\n\n const original = await getFolder({ id });\n\n await checkExistingFolder({\n id,\n params: {\n type: original.type,\n slug: slug || original.slug,\n parentId: parentId !== undefined ? parentId : original.parentId // parentId can be `null`\n }\n });\n\n const input = {\n ...original,\n ...data\n };\n\n const entry = await cms.updateEntry(model, id, input);\n return getFieldValues(entry, baseFields);\n });\n },\n deleteFolder({ id }) {\n return withModel(async model => {\n await cms.deleteEntry(model, id);\n return true;\n });\n }\n };\n};\n"],"mappings":"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"}
|
package/folder/folder.types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AcoBaseFields, ListMeta } from "../types";
|
|
1
|
+
import { AcoBaseFields, ListMeta, ListSort } from "../types";
|
|
2
2
|
import { Topic } from "@webiny/pubsub/types";
|
|
3
3
|
export interface Folder extends AcoBaseFields {
|
|
4
4
|
title: string;
|
|
@@ -12,7 +12,7 @@ export interface ListFoldersWhere {
|
|
|
12
12
|
}
|
|
13
13
|
export interface ListFoldersParams {
|
|
14
14
|
where: ListFoldersWhere;
|
|
15
|
-
sort?:
|
|
15
|
+
sort?: ListSort;
|
|
16
16
|
limit?: number;
|
|
17
17
|
after?: string | null;
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["folder.types.ts"],"sourcesContent":["import { AcoBaseFields, ListMeta } from \"~/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\n\nexport interface Folder extends AcoBaseFields {\n title: string;\n slug: string;\n type: string;\n parentId?: string | null;\n}\n\nexport interface ListFoldersWhere {\n type: string;\n parentId?: string | null;\n}\n\nexport interface ListFoldersParams {\n where: ListFoldersWhere;\n sort?:
|
|
1
|
+
{"version":3,"names":[],"sources":["folder.types.ts"],"sourcesContent":["import { AcoBaseFields, ListMeta, ListSort } from \"~/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\n\nexport interface Folder extends AcoBaseFields {\n title: string;\n slug: string;\n type: string;\n parentId?: string | null;\n}\n\nexport interface ListFoldersWhere {\n type: string;\n parentId?: string | null;\n}\n\nexport interface ListFoldersParams {\n where: ListFoldersWhere;\n sort?: ListSort;\n limit?: number;\n after?: string | null;\n}\n\nexport type CreateFolderParams = Pick<Folder, \"title\" | \"slug\" | \"type\" | \"parentId\">;\n\nexport interface UpdateFolderParams {\n title?: string;\n slug?: string;\n parentId?: string;\n}\n\nexport interface DeleteFolderParams {\n id: string;\n}\n\nexport interface StorageOperationsGetFolderParams {\n id?: string;\n slug?: string;\n type?: string;\n parentId?: string | null;\n}\n\nexport type StorageOperationsListFoldersParams = ListFoldersParams;\n\nexport interface StorageOperationsCreateFolderParams {\n data: CreateFolderParams;\n}\n\nexport interface StorageOperationsUpdateFolderParams {\n id: string;\n data: UpdateFolderParams;\n}\n\nexport type StorageOperationsDeleteFolderParams = DeleteFolderParams;\n\nexport interface OnFolderBeforeCreateTopicParams {\n input: CreateFolderParams;\n}\n\nexport interface OnFolderAfterCreateTopicParams {\n folder: Folder;\n}\n\nexport interface OnFolderBeforeUpdateTopicParams {\n original: Folder;\n input: Record<string, any>;\n}\n\nexport interface OnFolderAfterUpdateTopicParams {\n original: Folder;\n folder: Folder;\n input: Record<string, any>;\n}\n\nexport interface OnFolderBeforeDeleteTopicParams {\n folder: Folder;\n}\n\nexport interface OnFolderAfterDeleteTopicParams {\n folder: Folder;\n}\n\nexport interface AcoFolderCrud {\n get(id: string): Promise<Folder>;\n list(params: ListFoldersParams): Promise<[Folder[], ListMeta]>;\n create(data: CreateFolderParams): Promise<Folder>;\n update(id: string, data: UpdateFolderParams): Promise<Folder>;\n delete(id: string): Promise<Boolean>;\n onFolderBeforeCreate: Topic<OnFolderBeforeCreateTopicParams>;\n onFolderAfterCreate: Topic<OnFolderAfterCreateTopicParams>;\n onFolderBeforeUpdate: Topic<OnFolderBeforeUpdateTopicParams>;\n onFolderAfterUpdate: Topic<OnFolderAfterUpdateTopicParams>;\n onFolderBeforeDelete: Topic<OnFolderBeforeDeleteTopicParams>;\n onFolderAfterDelete: Topic<OnFolderAfterDeleteTopicParams>;\n}\n\nexport interface AcoFolderStorageOperations {\n getFolder(params: StorageOperationsGetFolderParams): Promise<Folder>;\n listFolders(params: StorageOperationsListFoldersParams): Promise<[Folder[], ListMeta]>;\n createFolder(params: StorageOperationsCreateFolderParams): Promise<Folder>;\n updateFolder(params: StorageOperationsUpdateFolderParams): Promise<Folder>;\n deleteFolder(params: StorageOperationsDeleteFolderParams): Promise<boolean>;\n}\n"],"mappings":""}
|
|
@@ -9,10 +9,10 @@ var _error = _interopRequireDefault(require("@webiny/error"));
|
|
|
9
9
|
const onFolderBeforeDeleteHook = ({
|
|
10
10
|
aco
|
|
11
11
|
}) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
aco.folder.onFolderBeforeDelete.subscribe(async ({
|
|
13
|
+
folder
|
|
14
|
+
}) => {
|
|
15
|
+
try {
|
|
16
16
|
const {
|
|
17
17
|
id,
|
|
18
18
|
type
|
|
@@ -42,12 +42,12 @@ const onFolderBeforeDeleteHook = ({
|
|
|
42
42
|
folder
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
}
|
|
45
|
+
} catch (error) {
|
|
46
|
+
throw _error.default.from(error, {
|
|
47
|
+
message: "Error while executing onFolderBeforeDelete hook",
|
|
48
|
+
code: "ACO_BEFORE_FOLDER_DELETE_HOOK"
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
52
|
};
|
|
53
53
|
exports.onFolderBeforeDeleteHook = onFolderBeforeDeleteHook;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["onFolderBeforeDeleteHook","aco","folder","onFolderBeforeDelete","subscribe","id","type","children","list","where","parentId","limit","records","search","location","folderId","length","WebinyError","error","from","message","code"],"sources":["onFolderBeforeDelete.hook.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { AcoContext } from \"~/types\";\n\nexport const onFolderBeforeDeleteHook = ({ aco }: AcoContext) => {\n
|
|
1
|
+
{"version":3,"names":["onFolderBeforeDeleteHook","aco","folder","onFolderBeforeDelete","subscribe","id","type","children","list","where","parentId","limit","records","search","location","folderId","length","WebinyError","error","from","message","code"],"sources":["onFolderBeforeDelete.hook.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { AcoContext } from \"~/types\";\n\nexport const onFolderBeforeDeleteHook = ({ aco }: AcoContext) => {\n aco.folder.onFolderBeforeDelete.subscribe(async ({ folder }) => {\n try {\n const { id, type } = folder;\n\n // Fetching all child folders\n const [children] = await aco.folder.list({\n where: { type, parentId: id },\n limit: 1\n });\n\n // Fetching all records inside the folder\n const [records] = await aco.search.list({\n where: { type, location: { folderId: id } },\n limit: 1\n });\n\n if (children.length > 0 || records.length > 0) {\n throw new WebinyError(\n \"Error: delete all child folders and entries before proceeding.\",\n \"DELETE_FOLDER_WITH_CHILDREN\",\n {\n folder\n }\n );\n }\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFolderBeforeDelete hook\",\n code: \"ACO_BEFORE_FOLDER_DELETE_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA;AAGO,MAAMA,wBAAwB,GAAG,CAAC;EAAEC;AAAgB,CAAC,KAAK;EAC7DA,GAAG,CAACC,MAAM,CAACC,oBAAoB,CAACC,SAAS,CAAC,OAAO;IAAEF;EAAO,CAAC,KAAK;IAC5D,IAAI;MACA,MAAM;QAAEG,EAAE;QAAEC;MAAK,CAAC,GAAGJ,MAAM;;MAE3B;MACA,MAAM,CAACK,QAAQ,CAAC,GAAG,MAAMN,GAAG,CAACC,MAAM,CAACM,IAAI,CAAC;QACrCC,KAAK,EAAE;UAAEH,IAAI;UAAEI,QAAQ,EAAEL;QAAG,CAAC;QAC7BM,KAAK,EAAE;MACX,CAAC,CAAC;;MAEF;MACA,MAAM,CAACC,OAAO,CAAC,GAAG,MAAMX,GAAG,CAACY,MAAM,CAACL,IAAI,CAAC;QACpCC,KAAK,EAAE;UAAEH,IAAI;UAAEQ,QAAQ,EAAE;YAAEC,QAAQ,EAAEV;UAAG;QAAE,CAAC;QAC3CM,KAAK,EAAE;MACX,CAAC,CAAC;MAEF,IAAIJ,QAAQ,CAACS,MAAM,GAAG,CAAC,IAAIJ,OAAO,CAACI,MAAM,GAAG,CAAC,EAAE;QAC3C,MAAM,IAAIC,cAAW,CACjB,gEAAgE,EAChE,6BAA6B,EAC7B;UACIf;QACJ,CAAC,CACJ;MACL;IACJ,CAAC,CAAC,OAAOgB,KAAK,EAAE;MACZ,MAAMD,cAAW,CAACE,IAAI,CAACD,KAAK,EAAE;QAC1BE,OAAO,EAAE,iDAAiD;QAC1DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-aco",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.df6d94b531",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aco:base"
|
|
@@ -27,31 +27,32 @@
|
|
|
27
27
|
"@babel/preset-env": "^7.19.4",
|
|
28
28
|
"@babel/preset-typescript": "^7.18.6",
|
|
29
29
|
"@babel/runtime": "^7.19.0",
|
|
30
|
-
"@webiny/api-headless-cms-ddb": "^0.0.0-unstable.
|
|
31
|
-
"@webiny/api-i18n-ddb": "^0.0.0-unstable.
|
|
32
|
-
"@webiny/api-security-so-ddb": "^0.0.0-unstable.
|
|
33
|
-
"@webiny/api-tenancy-so-ddb": "^0.0.0-unstable.
|
|
34
|
-
"@webiny/api-wcp": "^0.0.0-unstable.
|
|
35
|
-
"@webiny/cli": "^0.0.0-unstable.
|
|
36
|
-
"@webiny/handler-aws": "^0.0.0-unstable.
|
|
37
|
-
"@webiny/plugins": "^0.0.0-unstable.
|
|
38
|
-
"@webiny/project-utils": "^0.0.0-unstable.
|
|
30
|
+
"@webiny/api-headless-cms-ddb": "^0.0.0-unstable.df6d94b531",
|
|
31
|
+
"@webiny/api-i18n-ddb": "^0.0.0-unstable.df6d94b531",
|
|
32
|
+
"@webiny/api-security-so-ddb": "^0.0.0-unstable.df6d94b531",
|
|
33
|
+
"@webiny/api-tenancy-so-ddb": "^0.0.0-unstable.df6d94b531",
|
|
34
|
+
"@webiny/api-wcp": "^0.0.0-unstable.df6d94b531",
|
|
35
|
+
"@webiny/cli": "^0.0.0-unstable.df6d94b531",
|
|
36
|
+
"@webiny/handler-aws": "^0.0.0-unstable.df6d94b531",
|
|
37
|
+
"@webiny/plugins": "^0.0.0-unstable.df6d94b531",
|
|
38
|
+
"@webiny/project-utils": "^0.0.0-unstable.df6d94b531",
|
|
39
39
|
"rimraf": "^3.0.2",
|
|
40
40
|
"ttypescript": "^1.5.13",
|
|
41
41
|
"typescript": "^4.7.4"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@webiny/api": "0.0.0-unstable.
|
|
45
|
-
"@webiny/api-admin-settings": "0.0.0-unstable.
|
|
46
|
-
"@webiny/api-headless-cms": "0.0.0-unstable.
|
|
47
|
-
"@webiny/api-i18n": "0.0.0-unstable.
|
|
48
|
-
"@webiny/api-security": "0.0.0-unstable.
|
|
49
|
-
"@webiny/api-tenancy": "0.0.0-unstable.
|
|
50
|
-
"@webiny/error": "0.0.0-unstable.
|
|
51
|
-
"@webiny/handler": "0.0.0-unstable.
|
|
52
|
-
"@webiny/handler-graphql": "0.0.0-unstable.
|
|
53
|
-
"@webiny/pubsub": "0.0.0-unstable.
|
|
44
|
+
"@webiny/api": "0.0.0-unstable.df6d94b531",
|
|
45
|
+
"@webiny/api-admin-settings": "0.0.0-unstable.df6d94b531",
|
|
46
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.df6d94b531",
|
|
47
|
+
"@webiny/api-i18n": "0.0.0-unstable.df6d94b531",
|
|
48
|
+
"@webiny/api-security": "0.0.0-unstable.df6d94b531",
|
|
49
|
+
"@webiny/api-tenancy": "0.0.0-unstable.df6d94b531",
|
|
50
|
+
"@webiny/error": "0.0.0-unstable.df6d94b531",
|
|
51
|
+
"@webiny/handler": "0.0.0-unstable.df6d94b531",
|
|
52
|
+
"@webiny/handler-graphql": "0.0.0-unstable.df6d94b531",
|
|
53
|
+
"@webiny/pubsub": "0.0.0-unstable.df6d94b531",
|
|
54
|
+
"@webiny/utils": "0.0.0-unstable.df6d94b531",
|
|
54
55
|
"lodash": "4.17.21"
|
|
55
56
|
},
|
|
56
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "df6d94b531ed0453caef22c785d42be580c9df96"
|
|
57
58
|
}
|
package/record/record.gql.js
CHANGED
|
@@ -11,7 +11,6 @@ const searchRecordSchema = new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
|
|
|
11
11
|
typeDefs: /* GraphQL */`
|
|
12
12
|
type SearchRecord {
|
|
13
13
|
id: ID!
|
|
14
|
-
originalId: ID!
|
|
15
14
|
type: String!
|
|
16
15
|
location: SearchLocationType!
|
|
17
16
|
title: String!
|
|
@@ -31,7 +30,7 @@ const searchRecordSchema = new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
|
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
input SearchRecordCreateInput {
|
|
34
|
-
|
|
33
|
+
id: String!
|
|
35
34
|
type: String!
|
|
36
35
|
title: String!
|
|
37
36
|
content: String
|
|
@@ -69,7 +68,7 @@ const searchRecordSchema = new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
|
|
|
69
68
|
search: String
|
|
70
69
|
limit: Int
|
|
71
70
|
after: String
|
|
72
|
-
sort:
|
|
71
|
+
sort: AcoSort
|
|
73
72
|
): SearchRecordListResponse
|
|
74
73
|
}
|
|
75
74
|
|
package/record/record.gql.js.map
CHANGED
|
@@ -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
|
|
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 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 id: 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: AcoSort\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":";;;;;;AAAA;AACA;AAEA;AAIO,MAAMA,kBAAkB,GAAG,IAAIC,wCAAmB,CAAa;EAClEC,QAAQ,EAAE,aAAe;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EACDC,SAAS,EAAE;IACPC,WAAW,EAAE;MACTC,SAAS,EAAE,OAAOC,CAAC,EAAE;QAAEC;MAAG,CAAC,EAAEC,OAAO,KAAK;QACrC,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,GAAG,CAACC,MAAM,CAACC,GAAG,CAACL,EAAE,CAAC,CAAC;MACpD,CAAC;MACDM,WAAW,EAAE,OAAOP,CAAC,EAAEQ,IAAS,EAAEN,OAAO,KAAK;QAC1C,IAAI;UACA,MAAM,CAACO,OAAO,EAAEC,IAAI,CAAC,GAAG,MAAMR,OAAO,CAACE,GAAG,CAACC,MAAM,CAACM,IAAI,CAACH,IAAI,CAAC;UAC3D,OAAO,IAAII,uBAAY,CAACH,OAAO,EAAEC,IAAI,CAAC;QAC1C,CAAC,CAAC,OAAOG,CAAC,EAAE;UACR,OAAO,IAAIC,wBAAa,CAACD,CAAC,CAAC;QAC/B;MACJ;IACJ,CAAC;IACDE,cAAc,EAAE;MACZC,YAAY,EAAE,OAAOhB,CAAC,EAAE;QAAEiB;MAAK,CAAC,EAAEf,OAAO,KAAK;QAC1C,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,GAAG,CAACC,MAAM,CAACa,MAAM,CAACD,IAAI,CAAC,CAAC;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"}
|
package/record/record.model.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
2
|
-
export declare type SearchRecordModelDefinition = Pick<CmsModel, "name" | "modelId" | "layout" | "titleFieldId" | "description" | "fields" | "isPrivate"
|
|
3
|
-
|
|
2
|
+
export declare type SearchRecordModelDefinition = Pick<CmsModel, "name" | "modelId" | "layout" | "titleFieldId" | "description" | "fields" | "isPrivate"> & {
|
|
3
|
+
isPrivate: true;
|
|
4
|
+
};
|
|
5
|
+
export declare const SEARCH_RECORD_MODEL_ID = "acoSearchRecord";
|
|
4
6
|
export declare const createSearchModelDefinition: () => SearchRecordModelDefinition;
|
package/record/record.model.js
CHANGED
|
@@ -5,18 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.createSearchModelDefinition = exports.SEARCH_RECORD_MODEL_ID = 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",
|
|
@@ -59,15 +47,15 @@ const dataField = () => (0, _createModelField.createModelField)({
|
|
|
59
47
|
type: "wby-aco-json",
|
|
60
48
|
parent: "searchRecord"
|
|
61
49
|
});
|
|
62
|
-
const SEARCH_RECORD_MODEL_ID = "
|
|
50
|
+
const SEARCH_RECORD_MODEL_ID = "acoSearchRecord";
|
|
63
51
|
exports.SEARCH_RECORD_MODEL_ID = SEARCH_RECORD_MODEL_ID;
|
|
64
52
|
const createSearchModelDefinition = () => {
|
|
65
53
|
return {
|
|
66
54
|
name: "ACO - Search Record",
|
|
67
55
|
modelId: SEARCH_RECORD_MODEL_ID,
|
|
68
|
-
titleFieldId: "
|
|
69
|
-
layout: [["
|
|
70
|
-
fields: [
|
|
56
|
+
titleFieldId: "title",
|
|
57
|
+
layout: [["searchRecord_type"], ["searchRecord_title"], ["searchRecord_content"], ["searchRecord_location"], ["searchRecord_data"]],
|
|
58
|
+
fields: [typeField(), titleField(), contentField(), locationField([locationFolderIdField()]), dataField()],
|
|
71
59
|
description: "ACO - Search record model",
|
|
72
60
|
isPrivate: true
|
|
73
61
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["typeField","createModelField","label","type","parent","validation","name","message","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> & { isPrivate: true };\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 = \"acoSearchRecord\";\n\nexport const createSearchModelDefinition = (): SearchRecordModelDefinition => {\n return {\n name: \"ACO - Search Record\",\n modelId: SEARCH_RECORD_MODEL_ID,\n titleFieldId: \"title\",\n layout: [\n [\"searchRecord_type\"],\n [\"searchRecord_title\"],\n [\"searchRecord_content\"],\n [\"searchRecord_location\"],\n [\"searchRecord_data\"]\n ],\n fields: [\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,SAAS,GAAG,MACd,IAAAC,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,MAAMC,UAAU,GAAG,MACf,IAAAP,kCAAgB,EAAC;EACbC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE;AACZ,CAAC,CAAC;AAEN,MAAMK,YAAY,GAAG,MACjB,IAAAR,kCAAgB,EAAC;EACbC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE;AACZ,CAAC,CAAC;AAEN,MAAMM,aAAa,GAAIC,MAAuB,IAC1C,IAAAV,kCAAgB,EAAC;EACbC,KAAK,EAAE,UAAU;EACjBC,IAAI,EAAE,QAAQ;EACdC,MAAM,EAAE,cAAc;EACtBQ,cAAc,EAAE,KAAK;EACrBC,QAAQ,EAAE;IAAEF;EAAO;AACvB,CAAC,CAAC;AAEN,MAAMG,qBAAqB,GAAG,MAC1B,IAAAb,kCAAgB,EAAC;EACbC,KAAK,EAAE,WAAW;EAClBC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,uBAAuB;EAC/BC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAMQ,SAAS,GAAG,MACd,IAAAd,kCAAgB,EAAC;EACbC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAE,cAAc;EACpBC,MAAM,EAAE;AACZ,CAAC,CAAC;AAEC,MAAMY,sBAAsB,GAAG,iBAAiB;AAAC;AAEjD,MAAMC,2BAA2B,GAAG,MAAmC;EAC1E,OAAO;IACHX,IAAI,EAAE,qBAAqB;IAC3BY,OAAO,EAAEF,sBAAsB;IAC/BG,YAAY,EAAE,OAAO;IACrBC,MAAM,EAAE,CACJ,CAAC,mBAAmB,CAAC,EACrB,CAAC,oBAAoB,CAAC,EACtB,CAAC,sBAAsB,CAAC,EACxB,CAAC,uBAAuB,CAAC,EACzB,CAAC,mBAAmB,CAAC,CACxB;IACDT,MAAM,EAAE,CACJX,SAAS,EAAE,EACXQ,UAAU,EAAE,EACZC,YAAY,EAAE,EACdC,aAAa,CAAC,CAACI,qBAAqB,EAAE,CAAC,CAAC,EACxCC,SAAS,EAAE,CACd;IACDM,WAAW,EAAE,2BAA2B;IACxCC,SAAS,EAAE;EACf,CAAC;AACL,CAAC;AAAC"}
|
package/record/record.so.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
2
1
|
import { CreateAcoStorageOperationsParams } from "../createAcoStorageOperations";
|
|
3
|
-
import { AcoSearchRecordStorageOperations
|
|
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 {};
|
package/record/record.so.js
CHANGED
|
@@ -6,94 +6,92 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.createSearchRecordOperations = void 0;
|
|
8
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _valueKeyStorageConverter = require("@webiny/api-headless-cms/utils/converters/valueKeyStorageConverter");
|
|
9
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
11
|
var _record = require("./record.model");
|
|
11
12
|
var _createAcoStorageOperations = require("../createAcoStorageOperations");
|
|
13
|
+
var _createListSort = require("../utils/createListSort");
|
|
14
|
+
var _createOperationsWrapper = require("../utils/createOperationsWrapper");
|
|
12
15
|
var _getFieldValues = require("../utils/getFieldValues");
|
|
13
16
|
const createSearchRecordOperations = params => {
|
|
14
17
|
const {
|
|
15
18
|
cms,
|
|
16
|
-
|
|
19
|
+
getCmsContext
|
|
17
20
|
} = params;
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}) => {
|
|
30
|
-
const model = await getRecordModel();
|
|
31
|
-
security.disableAuthorization();
|
|
21
|
+
const {
|
|
22
|
+
withModel
|
|
23
|
+
} = (0, _createOperationsWrapper.createOperationsWrapper)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
24
|
+
modelName: _record.SEARCH_RECORD_MODEL_ID
|
|
25
|
+
}));
|
|
26
|
+
const getRecord = async (initialModel, id) => {
|
|
27
|
+
const context = getCmsContext();
|
|
28
|
+
const model = (0, _valueKeyStorageConverter.attachCmsModelFieldConverters)({
|
|
29
|
+
model: initialModel,
|
|
30
|
+
plugins: context.plugins
|
|
31
|
+
});
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* The record "id"
|
|
35
|
-
*
|
|
34
|
+
* The record "id" has been passed by the original entry.
|
|
35
|
+
* We need to retrieve it via `cms.storageOperations.entries.getLatestByIds()` method and return the first one.
|
|
36
36
|
*/
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
originalId: id,
|
|
40
|
-
latest: true
|
|
41
|
-
}
|
|
37
|
+
const revisions = await cms.storageOperations.entries.getLatestByIds(model, {
|
|
38
|
+
ids: [id]
|
|
42
39
|
});
|
|
43
|
-
if (
|
|
44
|
-
throw new _error.default("
|
|
40
|
+
if (revisions.length === 0) {
|
|
41
|
+
throw new _error.default("Record not found.", "NOT_FOUND", {
|
|
45
42
|
id
|
|
46
43
|
});
|
|
47
44
|
}
|
|
48
|
-
|
|
49
|
-
return (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields);
|
|
45
|
+
return revisions[0];
|
|
50
46
|
};
|
|
51
47
|
return {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return
|
|
48
|
+
async getRecord({
|
|
49
|
+
id
|
|
50
|
+
}) {
|
|
51
|
+
return withModel(async model => {
|
|
52
|
+
const record = await getRecord(model, id);
|
|
53
|
+
return (0, _getFieldValues.getFieldValues)(record, _createAcoStorageOperations.baseFields, true);
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
listRecords(params) {
|
|
57
|
+
return withModel(async model => {
|
|
58
|
+
const {
|
|
59
|
+
sort,
|
|
60
|
+
where
|
|
61
|
+
} = params;
|
|
62
|
+
const [entries, meta] = await cms.listLatestEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
63
|
+
sort: (0, _createListSort.createListSort)(sort),
|
|
64
|
+
where: (0, _objectSpread2.default)({}, where || {})
|
|
65
|
+
}));
|
|
66
|
+
return [entries.map(entry => (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields, true)), meta];
|
|
67
|
+
});
|
|
62
68
|
},
|
|
63
|
-
|
|
69
|
+
createRecord({
|
|
64
70
|
data
|
|
65
71
|
}) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields);
|
|
72
|
+
return withModel(async model => {
|
|
73
|
+
const entry = await cms.createEntry(model, data);
|
|
74
|
+
return (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields, true);
|
|
75
|
+
});
|
|
71
76
|
},
|
|
72
|
-
|
|
77
|
+
updateRecord({
|
|
73
78
|
id,
|
|
74
79
|
data
|
|
75
80
|
}) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
id
|
|
81
|
+
return withModel(async model => {
|
|
82
|
+
const original = await getRecord(model, id);
|
|
83
|
+
const input = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, original), data);
|
|
84
|
+
const entry = await cms.updateEntry(model, original.id, input);
|
|
85
|
+
return (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields, true);
|
|
80
86
|
});
|
|
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
87
|
},
|
|
86
|
-
|
|
88
|
+
deleteRecord({
|
|
87
89
|
id
|
|
88
90
|
}) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
id
|
|
91
|
+
return withModel(async model => {
|
|
92
|
+
await cms.deleteEntry(model, id);
|
|
93
|
+
return true;
|
|
93
94
|
});
|
|
94
|
-
await cms.deleteEntry(model, entry.id);
|
|
95
|
-
security.enableAuthorization();
|
|
96
|
-
return true;
|
|
97
95
|
}
|
|
98
96
|
};
|
|
99
97
|
};
|
package/record/record.so.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createSearchRecordOperations","params","cms","
|
|
1
|
+
{"version":3,"names":["createSearchRecordOperations","params","cms","getCmsContext","withModel","createOperationsWrapper","modelName","SEARCH_RECORD_MODEL_ID","getRecord","initialModel","id","context","model","attachCmsModelFieldConverters","plugins","revisions","storageOperations","entries","getLatestByIds","ids","length","WebinyError","record","getFieldValues","baseFields","listRecords","sort","where","meta","listLatestEntries","createListSort","map","entry","createRecord","data","createEntry","updateRecord","original","input","updateEntry","deleteRecord","deleteEntry"],"sources":["record.so.ts"],"sourcesContent":["import { attachCmsModelFieldConverters } from \"@webiny/api-headless-cms/utils/converters/valueKeyStorageConverter\";\n\nimport WebinyError from \"@webiny/error\";\n\nimport { SEARCH_RECORD_MODEL_ID } from \"./record.model\";\nimport { baseFields, CreateAcoStorageOperationsParams } from \"~/createAcoStorageOperations\";\nimport { createListSort } from \"~/utils/createListSort\";\nimport { createOperationsWrapper } from \"~/utils/createOperationsWrapper\";\nimport { getFieldValues } from \"~/utils/getFieldValues\";\n\nimport { AcoSearchRecordStorageOperations } from \"./record.types\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\nexport const createSearchRecordOperations = (\n params: CreateAcoStorageOperationsParams\n): AcoSearchRecordStorageOperations => {\n const { cms, getCmsContext } = params;\n\n const { withModel } = createOperationsWrapper({\n ...params,\n modelName: SEARCH_RECORD_MODEL_ID\n });\n\n const getRecord = async (initialModel: CmsModel, id: string) => {\n const context = getCmsContext();\n\n const model = attachCmsModelFieldConverters({\n model: initialModel,\n plugins: context.plugins\n });\n\n /**\n * The record \"id\" has been passed by the original entry.\n * We need to retrieve it via `cms.storageOperations.entries.getLatestByIds()` method and return the first one.\n */\n const revisions = await cms.storageOperations.entries.getLatestByIds(model, {\n ids: [id]\n });\n\n if (revisions.length === 0) {\n throw new WebinyError(\"Record not found.\", \"NOT_FOUND\", {\n id\n });\n }\n\n return revisions[0];\n };\n\n return {\n async getRecord({ id }) {\n return withModel(async model => {\n const record = await getRecord(model, id);\n return getFieldValues(record, baseFields, true);\n });\n },\n listRecords(params) {\n return withModel(async model => {\n const { sort, where } = params;\n\n const [entries, meta] = await cms.listLatestEntries(model, {\n ...params,\n sort: createListSort(sort),\n where: {\n ...(where || {})\n }\n });\n\n return [entries.map(entry => getFieldValues(entry, baseFields, true)), meta];\n });\n },\n createRecord({ data }) {\n return withModel(async model => {\n const entry = await cms.createEntry(model, data);\n\n return getFieldValues(entry, baseFields, true);\n });\n },\n updateRecord({ id, data }) {\n return withModel(async model => {\n const original = await getRecord(model, id);\n\n const input = {\n ...original,\n ...data\n };\n\n const entry = await cms.updateEntry(model, original.id, input);\n\n return getFieldValues(entry, baseFields, true);\n });\n },\n deleteRecord({ id }) {\n return withModel(async model => {\n await cms.deleteEntry(model, id);\n return true;\n });\n }\n };\n};\n"],"mappings":"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"}
|
package/record/record.types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AcoBaseFields, ListMeta } from "../types";
|
|
1
|
+
import { AcoBaseFields, ListMeta, ListSort } from "../types";
|
|
2
2
|
import { Topic } from "@webiny/pubsub/types";
|
|
3
3
|
export declare type GenericSearchData = {
|
|
4
4
|
[key: string]: any;
|
|
@@ -7,7 +7,6 @@ export interface Location {
|
|
|
7
7
|
folderId: string;
|
|
8
8
|
}
|
|
9
9
|
export interface SearchRecord<TData extends GenericSearchData = GenericSearchData> extends AcoBaseFields {
|
|
10
|
-
originalId: string;
|
|
11
10
|
type: string;
|
|
12
11
|
title?: string;
|
|
13
12
|
content?: string;
|
|
@@ -23,11 +22,11 @@ export interface ListSearchRecordsWhere {
|
|
|
23
22
|
export interface ListSearchRecordsParams {
|
|
24
23
|
where?: ListSearchRecordsWhere;
|
|
25
24
|
search?: string;
|
|
26
|
-
sort?:
|
|
25
|
+
sort?: ListSort;
|
|
27
26
|
limit?: number;
|
|
28
27
|
after?: string | null;
|
|
29
28
|
}
|
|
30
|
-
export declare type CreateSearchRecordParams<TData> = Pick<SearchRecord<TData>, "
|
|
29
|
+
export declare type CreateSearchRecordParams<TData> = Pick<SearchRecord<TData>, "id" | "title" | "content" | "type" | "location" | "data">;
|
|
31
30
|
export interface UpdateSearchRecordParams<TData extends GenericSearchData> {
|
|
32
31
|
title?: string;
|
|
33
32
|
content?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["record.types.ts"],"sourcesContent":["import { AcoBaseFields, ListMeta } from \"~/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\n\nexport type GenericSearchData = {\n [key: string]: any;\n};\n\nexport interface Location {\n folderId: string;\n}\n\nexport interface SearchRecord<TData extends GenericSearchData = GenericSearchData>\n extends AcoBaseFields {\n
|
|
1
|
+
{"version":3,"names":[],"sources":["record.types.ts"],"sourcesContent":["import { AcoBaseFields, ListMeta, ListSort } from \"~/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\n\nexport type GenericSearchData = {\n [key: string]: any;\n};\n\nexport interface Location {\n folderId: string;\n}\n\nexport interface SearchRecord<TData extends GenericSearchData = GenericSearchData>\n extends AcoBaseFields {\n type: string;\n title?: string;\n content?: string;\n location?: Location;\n data?: TData;\n}\n\nexport interface ListSearchRecordsWhere {\n type: string;\n location?: {\n folderId: string;\n };\n}\n\nexport interface ListSearchRecordsParams {\n where?: ListSearchRecordsWhere;\n search?: string;\n sort?: ListSort;\n limit?: number;\n after?: string | null;\n}\n\nexport type CreateSearchRecordParams<TData> = Pick<\n SearchRecord<TData>,\n \"id\" | \"title\" | \"content\" | \"type\" | \"location\" | \"data\"\n>;\n\nexport interface UpdateSearchRecordParams<TData extends GenericSearchData> {\n title?: string;\n content?: string;\n location?: Location;\n data?: TData;\n}\n\nexport interface DeleteSearchRecordParams {\n id: string;\n}\n\nexport interface StorageOperationsGetSearchRecordParams {\n id: string;\n}\n\nexport type StorageOperationsListSearchRecordsParams = ListSearchRecordsParams;\n\nexport interface StorageOperationsCreateSearchRecordParams<\n TData extends GenericSearchData = GenericSearchData\n> {\n data: CreateSearchRecordParams<TData>;\n}\nexport interface StorageOperationsUpdateSearchRecordParams<\n TData extends GenericSearchData = GenericSearchData\n> {\n id: string;\n data: UpdateSearchRecordParams<TData>;\n}\nexport type StorageOperationsDeleteSearchRecordParams = DeleteSearchRecordParams;\n\nexport interface OnSearchRecordBeforeCreateTopicParams<\n TData extends GenericSearchData = GenericSearchData\n> {\n input: CreateSearchRecordParams<TData>;\n}\n\nexport interface OnSearchRecordAfterCreateTopicParams<\n TData extends GenericSearchData = GenericSearchData\n> {\n record: SearchRecord<TData>;\n}\n\nexport interface OnSearchRecordBeforeUpdateTopicParams<\n TData extends GenericSearchData = GenericSearchData\n> {\n original: SearchRecord<TData>;\n input: Record<string, any>;\n}\n\nexport interface OnSearchRecordAfterUpdateTopicParams<\n TData extends GenericSearchData = GenericSearchData\n> {\n original: SearchRecord<TData>;\n record: SearchRecord<TData>;\n input: Record<string, any>;\n}\n\nexport interface OnSearchRecordBeforeDeleteTopicParams<\n TData extends GenericSearchData = GenericSearchData\n> {\n record: SearchRecord<TData>;\n}\n\nexport interface OnSearchRecordAfterDeleteTopicParams<\n TData extends GenericSearchData = GenericSearchData\n> {\n record: SearchRecord<TData>;\n}\n\nexport interface AcoSearchRecordCrud {\n get<TData>(id: string): Promise<SearchRecord<TData>>;\n list<TData>(params: ListSearchRecordsParams): Promise<[SearchRecord<TData>[], ListMeta]>;\n create<TData>(data: CreateSearchRecordParams<TData>): Promise<SearchRecord<TData>>;\n update<TData>(id: string, data: UpdateSearchRecordParams<TData>): Promise<SearchRecord<TData>>;\n delete(id: string): Promise<Boolean>;\n onSearchRecordBeforeCreate: Topic<OnSearchRecordBeforeCreateTopicParams>;\n onSearchRecordAfterCreate: Topic<OnSearchRecordAfterCreateTopicParams>;\n onSearchRecordBeforeUpdate: Topic<OnSearchRecordBeforeUpdateTopicParams>;\n onSearchRecordAfterUpdate: Topic<OnSearchRecordAfterUpdateTopicParams>;\n onSearchRecordBeforeDelete: Topic<OnSearchRecordBeforeDeleteTopicParams>;\n onSearchRecordAfterDelete: Topic<OnSearchRecordAfterDeleteTopicParams>;\n}\nexport interface AcoSearchRecordStorageOperations {\n getRecord<TData extends GenericSearchData = GenericSearchData>(\n params: StorageOperationsGetSearchRecordParams\n ): Promise<SearchRecord<TData>>;\n listRecords<TData extends GenericSearchData = GenericSearchData>(\n params: StorageOperationsListSearchRecordsParams\n ): Promise<[SearchRecord<TData>[], ListMeta]>;\n createRecord<TData extends GenericSearchData = GenericSearchData>(\n params: StorageOperationsCreateSearchRecordParams<TData>\n ): Promise<SearchRecord<TData>>;\n updateRecord<TData extends GenericSearchData = GenericSearchData>(\n params: StorageOperationsUpdateSearchRecordParams<TData>\n ): Promise<SearchRecord<TData>>;\n deleteRecord(params: StorageOperationsDeleteSearchRecordParams): Promise<boolean>;\n}\n"],"mappings":""}
|
package/types.d.ts
CHANGED
|
@@ -15,6 +15,11 @@ export interface ListMeta {
|
|
|
15
15
|
totalCount: number;
|
|
16
16
|
hasMoreItems: boolean;
|
|
17
17
|
}
|
|
18
|
+
export declare enum ListSortDirection {
|
|
19
|
+
ASC = 0,
|
|
20
|
+
DESC = 1
|
|
21
|
+
}
|
|
22
|
+
export declare type ListSort = Record<string, ListSortDirection>;
|
|
18
23
|
export interface AcoBaseFields {
|
|
19
24
|
id: string;
|
|
20
25
|
entryId: string;
|
package/types.js
CHANGED
|
@@ -2,4 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
});
|
|
5
|
+
});
|
|
6
|
+
exports.ListSortDirection = void 0;
|
|
7
|
+
let ListSortDirection;
|
|
8
|
+
exports.ListSortDirection = ListSortDirection;
|
|
9
|
+
(function (ListSortDirection) {
|
|
10
|
+
ListSortDirection[ListSortDirection["ASC"] = 0] = "ASC";
|
|
11
|
+
ListSortDirection[ListSortDirection["DESC"] = 1] = "DESC";
|
|
12
|
+
})(ListSortDirection || (exports.ListSortDirection = ListSortDirection = {}));
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { Tenant, TenancyContext } from \"@webiny/api-tenancy/types\";\nimport { Context as BaseContext } from \"@webiny/handler/types\";\nimport { I18NContext, I18NLocale } from \"@webiny/api-i18n/types\";\nimport { SecurityContext, SecurityIdentity } from \"@webiny/api-security/types\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport { AcoSearchRecordCrud, AcoSearchRecordStorageOperations } from \"~/record/record.types\";\nimport { AcoFolderCrud, AcoFolderStorageOperations } from \"~/folder/folder.types\";\n\nexport interface User {\n id: string;\n type: string;\n displayName: string | null;\n}\n\nexport interface ListMeta {\n cursor: string | null;\n totalCount: number;\n hasMoreItems: boolean;\n}\n\nexport interface AcoBaseFields {\n id: string;\n entryId: string;\n createdOn: string;\n createdBy: User;\n savedOn: string;\n}\n\nexport interface AdvancedContentOrganisation {\n folder: AcoFolderCrud;\n search: AcoSearchRecordCrud;\n}\n\nexport interface CreateAcoParams {\n getIdentity: () => SecurityIdentity;\n getLocale: () => I18NLocale;\n getTenant: () => Tenant;\n storageOperations: AcoStorageOperations;\n}\n\nexport type AcoStorageOperations = AcoFolderStorageOperations & AcoSearchRecordStorageOperations;\n\nexport interface AcoContext\n extends BaseContext,\n I18NContext,\n TenancyContext,\n SecurityContext,\n CmsContext {\n aco: AdvancedContentOrganisation;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":["ListSortDirection"],"sources":["types.ts"],"sourcesContent":["import { Tenant, TenancyContext } from \"@webiny/api-tenancy/types\";\nimport { Context as BaseContext } from \"@webiny/handler/types\";\nimport { I18NContext, I18NLocale } from \"@webiny/api-i18n/types\";\nimport { SecurityContext, SecurityIdentity } from \"@webiny/api-security/types\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport { AcoSearchRecordCrud, AcoSearchRecordStorageOperations } from \"~/record/record.types\";\nimport { AcoFolderCrud, AcoFolderStorageOperations } from \"~/folder/folder.types\";\n\nexport interface User {\n id: string;\n type: string;\n displayName: string | null;\n}\n\nexport interface ListMeta {\n cursor: string | null;\n totalCount: number;\n hasMoreItems: boolean;\n}\n\nexport enum ListSortDirection {\n ASC,\n DESC\n}\n\nexport type ListSort = Record<string, ListSortDirection>;\n\nexport interface AcoBaseFields {\n id: string;\n entryId: string;\n createdOn: string;\n createdBy: User;\n savedOn: string;\n}\n\nexport interface AdvancedContentOrganisation {\n folder: AcoFolderCrud;\n search: AcoSearchRecordCrud;\n}\n\nexport interface CreateAcoParams {\n getIdentity: () => SecurityIdentity;\n getLocale: () => I18NLocale;\n getTenant: () => Tenant;\n storageOperations: AcoStorageOperations;\n}\n\nexport type AcoStorageOperations = AcoFolderStorageOperations & AcoSearchRecordStorageOperations;\n\nexport interface AcoContext\n extends BaseContext,\n I18NContext,\n TenancyContext,\n SecurityContext,\n CmsContext {\n aco: AdvancedContentOrganisation;\n}\n"],"mappings":";;;;;;IAoBYA,iBAAiB;AAAA;AAAA,WAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;AAAA,GAAjBA,iBAAiB,iCAAjBA,iBAAiB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createListSort = void 0;
|
|
7
|
+
const createListSort = sort => {
|
|
8
|
+
if (!sort) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
return Object.keys(sort).map(key => `${key}_${sort[key]}`);
|
|
12
|
+
};
|
|
13
|
+
exports.createListSort = createListSort;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createListSort","sort","Object","keys","map","key"],"sources":["createListSort.ts"],"sourcesContent":["import { ListSort } from \"~/types\";\n\nexport const createListSort = (sort?: ListSort): string[] | undefined => {\n if (!sort) {\n return;\n }\n\n return Object.keys(sort).map(key => `${key}_${sort[key]}`);\n};\n"],"mappings":";;;;;;AAEO,MAAMA,cAAc,GAAIC,IAAe,IAA2B;EACrE,IAAI,CAACA,IAAI,EAAE;IACP;EACJ;EAEA,OAAOC,MAAM,CAACC,IAAI,CAACF,IAAI,CAAC,CAACG,GAAG,CAACC,GAAG,IAAK,GAAEA,GAAI,IAAGJ,IAAI,CAACI,GAAG,CAAE,EAAC,CAAC;AAC9D,CAAC;AAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CreateAcoStorageOperationsParams } from "../createAcoStorageOperations";
|
|
2
|
+
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
3
|
+
interface CreateOperationsWrapperParams extends CreateAcoStorageOperationsParams {
|
|
4
|
+
modelName: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const createOperationsWrapper: (params: CreateOperationsWrapperParams) => {
|
|
7
|
+
withModel: <TResult>(cb: (model: CmsModel) => Promise<TResult>) => Promise<TResult>;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createOperationsWrapper = void 0;
|
|
8
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
const createOperationsWrapper = params => {
|
|
10
|
+
const {
|
|
11
|
+
cms,
|
|
12
|
+
security,
|
|
13
|
+
modelName
|
|
14
|
+
} = params;
|
|
15
|
+
const withModel = async cb => {
|
|
16
|
+
security.disableAuthorization();
|
|
17
|
+
const model = await cms.getModel(modelName);
|
|
18
|
+
if (!model) {
|
|
19
|
+
throw new _error.default(`Could not find "${modelName}" model.`, "MODEL_NOT_FOUND_ERROR");
|
|
20
|
+
}
|
|
21
|
+
const result = await cb(model);
|
|
22
|
+
security.enableAuthorization();
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
withModel
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
exports.createOperationsWrapper = createOperationsWrapper;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createOperationsWrapper","params","cms","security","modelName","withModel","cb","disableAuthorization","model","getModel","WebinyError","result","enableAuthorization"],"sources":["createOperationsWrapper.ts"],"sourcesContent":["import { CreateAcoStorageOperationsParams } from \"~/createAcoStorageOperations\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\n\ninterface CreateOperationsWrapperParams extends CreateAcoStorageOperationsParams {\n modelName: string;\n}\n\nexport const createOperationsWrapper = (params: CreateOperationsWrapperParams) => {\n const { cms, security, modelName } = params;\n\n const withModel = async <TResult>(\n cb: (model: CmsModel) => Promise<TResult>\n ): Promise<TResult> => {\n security.disableAuthorization();\n const model = await cms.getModel(modelName);\n\n if (!model) {\n throw new WebinyError(`Could not find \"${modelName}\" model.`, \"MODEL_NOT_FOUND_ERROR\");\n }\n\n const result = await cb(model);\n\n security.enableAuthorization();\n\n return result;\n };\n\n return {\n withModel\n };\n};\n"],"mappings":";;;;;;;AAEA;AAMO,MAAMA,uBAAuB,GAAIC,MAAqC,IAAK;EAC9E,MAAM;IAAEC,GAAG;IAAEC,QAAQ;IAAEC;EAAU,CAAC,GAAGH,MAAM;EAE3C,MAAMI,SAAS,GAAG,MACdC,EAAyC,IACtB;IACnBH,QAAQ,CAACI,oBAAoB,EAAE;IAC/B,MAAMC,KAAK,GAAG,MAAMN,GAAG,CAACO,QAAQ,CAACL,SAAS,CAAC;IAE3C,IAAI,CAACI,KAAK,EAAE;MACR,MAAM,IAAIE,cAAW,CAAE,mBAAkBN,SAAU,UAAS,EAAE,uBAAuB,CAAC;IAC1F;IAEA,MAAMO,MAAM,GAAG,MAAML,EAAE,CAACE,KAAK,CAAC;IAE9BL,QAAQ,CAACS,mBAAmB,EAAE;IAE9B,OAAOD,MAAM;EACjB,CAAC;EAED,OAAO;IACHN;EACJ,CAAC;AACL,CAAC;AAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { CmsEntry } from "@webiny/api-headless-cms/types";
|
|
2
|
-
export declare function getFieldValues(entry: CmsEntry, fields: string[]): any;
|
|
2
|
+
export declare function getFieldValues(entry: CmsEntry, fields: string[], useEntryId?: boolean): any;
|
package/utils/getFieldValues.js
CHANGED
|
@@ -7,6 +7,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.getFieldValues = getFieldValues;
|
|
8
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
9
|
var _pick = _interopRequireDefault(require("lodash/pick"));
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
var _utils = require("@webiny/utils");
|
|
11
|
+
function getFieldValues(entry, fields, useEntryId) {
|
|
12
|
+
// We return the `id` without version in case of `useEntryId` flag is passed.
|
|
13
|
+
const {
|
|
14
|
+
id
|
|
15
|
+
} = (0, _utils.parseIdentifier)(entry.id);
|
|
16
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _pick.default)(entry, fields)), entry.values), useEntryId && {
|
|
17
|
+
id
|
|
18
|
+
});
|
|
12
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getFieldValues","entry","fields","pick","values"],"sources":["getFieldValues.ts"],"sourcesContent":["import pick from \"lodash/pick\";\n\nimport { CmsEntry } from \"@webiny/api-headless-cms/types\";\n\nexport function getFieldValues(entry: CmsEntry, fields: string[]): any {\n return { ...pick(entry, fields), ...entry.values };\n}\n"],"mappings":";;;;;;;;AAAA;
|
|
1
|
+
{"version":3,"names":["getFieldValues","entry","fields","useEntryId","id","parseIdentifier","pick","values"],"sources":["getFieldValues.ts"],"sourcesContent":["import pick from \"lodash/pick\";\n\nimport { CmsEntry } from \"@webiny/api-headless-cms/types\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\nexport function getFieldValues(entry: CmsEntry, fields: string[], useEntryId?: boolean): any {\n // We return the `id` without version in case of `useEntryId` flag is passed.\n const { id } = parseIdentifier(entry.id);\n return { ...pick(entry, fields), ...entry.values, ...(useEntryId && { id }) };\n}\n"],"mappings":";;;;;;;;AAAA;AAGA;AAEO,SAASA,cAAc,CAACC,KAAe,EAAEC,MAAgB,EAAEC,UAAoB,EAAO;EACzF;EACA,MAAM;IAAEC;EAAG,CAAC,GAAG,IAAAC,sBAAe,EAACJ,KAAK,CAACG,EAAE,CAAC;EACxC,+FAAY,IAAAE,aAAI,EAACL,KAAK,EAAEC,MAAM,CAAC,GAAKD,KAAK,CAACM,MAAM,GAAMJ,UAAU,IAAI;IAAEC;EAAG,CAAC;AAC9E"}
|
package/utils/modelFactory.d.ts
CHANGED
|
@@ -9,7 +9,9 @@ interface Params {
|
|
|
9
9
|
*/
|
|
10
10
|
locale?: string;
|
|
11
11
|
tenant?: string;
|
|
12
|
-
modelDefinition: Omit<CmsModel, "locale" | "tenant" | "webinyVersion" | "group"
|
|
12
|
+
modelDefinition: Omit<CmsModel, "locale" | "tenant" | "webinyVersion" | "group" | "singularApiName" | "pluralApiName"> & {
|
|
13
|
+
isPrivate: true;
|
|
14
|
+
};
|
|
13
15
|
}
|
|
14
16
|
export declare const modelFactory: (params: Params) => CmsModelPlugin;
|
|
15
17
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["modelFactory","params","group","locale","tenant","modelDefinition","createCmsModel"],"sources":["modelFactory.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 /**\n * Locale and tenant do not need to be defined.\n * In that case model is not bound to any locale or tenant.\n * You can bind it to locale, tenant, both or none.\n */\n locale?: string;\n tenant?: string;\n modelDefinition: Omit
|
|
1
|
+
{"version":3,"names":["modelFactory","params","group","locale","tenant","modelDefinition","createCmsModel"],"sources":["modelFactory.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 /**\n * Locale and tenant do not need to be defined.\n * In that case model is not bound to any locale or tenant.\n * You can bind it to locale, tenant, both or none.\n */\n locale?: string;\n tenant?: string;\n modelDefinition: Omit<\n CmsModel,\n \"locale\" | \"tenant\" | \"webinyVersion\" | \"group\" | \"singularApiName\" | \"pluralApiName\"\n > & { isPrivate: true };\n}\n\nexport const modelFactory = (params: Params): CmsModelPlugin => {\n const { group, locale, tenant, modelDefinition } = params;\n\n return createCmsModel({\n group,\n locale,\n tenant,\n ...modelDefinition\n });\n};\n"],"mappings":";;;;;;;;AAAA;AAkBO,MAAMA,YAAY,GAAIC,MAAc,IAAqB;EAC5D,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAgB,CAAC,GAAGJ,MAAM;EAEzD,OAAO,IAAAK,8BAAc;IACjBJ,KAAK;IACLC,MAAM;IACNC;EAAM,GACHC,eAAe,EACpB;AACN,CAAC;AAAC"}
|