@webiny/api-aco 0.0.0-unstable.d65ec29d44 → 0.0.0-unstable.da99e0b846
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/README.md +6 -6
- package/createAcoGraphQL.js +10 -9
- package/createAcoGraphQL.js.map +1 -1
- package/createAcoModels.js +0 -2
- package/createAcoModels.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 +3 -3
- package/folder/folder.model.js +3 -7
- 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/index.d.ts +1 -1
- package/index.js +3 -3
- package/index.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 +3 -3
- package/record/record.model.js +7 -25
- package/record/record.model.js.map +1 -1
- package/record/record.so.d.ts +1 -6
- package/record/record.so.js +51 -61
- 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 +9 -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/createModelField.d.ts +0 -1
- package/utils/createModelField.js +2 -4
- package/utils/createModelField.js.map +1 -1
- 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 -3
- package/utils/modelFactory.js +4 -2
- package/utils/modelFactory.js.map +1 -1
|
@@ -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/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const createAco: () => (import("@webiny/api").ContextPlugin<import("./types").AcoContext> | import("@webiny/api-headless-cms/types").CmsModelFieldToGraphQLPlugin<import("@webiny/api-headless-cms/types").CmsModelField>[] | import("@webiny/api").ContextPlugin<import("@webiny/api-admin-settings/types").AdminSettingsContext>)[];
|
package/index.js
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.createAco = void 0;
|
|
7
7
|
var _apiAdminSettings = require("@webiny/api-admin-settings");
|
|
8
8
|
var _createAcoContext = require("./createAcoContext");
|
|
9
9
|
var _createAcoFields = require("./createAcoFields");
|
|
10
10
|
var _createAcoGraphQL = require("./createAcoGraphQL");
|
|
11
|
-
const
|
|
11
|
+
const createAco = () => {
|
|
12
12
|
return [...(0, _apiAdminSettings.createAdminSettingsContext)(), (0, _createAcoContext.createAcoContext)(), (0, _createAcoFields.createAcoFields)(), (0, _createAcoGraphQL.createAcoGraphQL)()];
|
|
13
13
|
};
|
|
14
|
-
exports.
|
|
14
|
+
exports.createAco = createAco;
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createAco","createAdminSettingsContext","createAcoContext","createAcoFields","createAcoGraphQL"],"sources":["index.ts"],"sourcesContent":["import { createAdminSettingsContext } from \"@webiny/api-admin-settings\";\n\nimport { createAcoContext } from \"~/createAcoContext\";\nimport { createAcoFields } from \"~/createAcoFields\";\nimport { createAcoGraphQL } from \"~/createAcoGraphQL\";\n\nexport const createAco = () => {\n return [\n ...createAdminSettingsContext(),\n createAcoContext(),\n createAcoFields(),\n createAcoGraphQL()\n ];\n};\n"],"mappings":";;;;;;AAAA;AAEA;AACA;AACA;AAEO,MAAMA,SAAS,GAAG,MAAM;EAC3B,OAAO,CACH,GAAG,IAAAC,4CAA0B,GAAE,EAC/B,IAAAC,kCAAgB,GAAE,EAClB,IAAAC,gCAAe,GAAE,EACjB,IAAAC,kCAAgB,GAAE,CACrB;AACL,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.da99e0b846",
|
|
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.da99e0b846",
|
|
31
|
+
"@webiny/api-i18n-ddb": "^0.0.0-unstable.da99e0b846",
|
|
32
|
+
"@webiny/api-security-so-ddb": "^0.0.0-unstable.da99e0b846",
|
|
33
|
+
"@webiny/api-tenancy-so-ddb": "^0.0.0-unstable.da99e0b846",
|
|
34
|
+
"@webiny/api-wcp": "^0.0.0-unstable.da99e0b846",
|
|
35
|
+
"@webiny/cli": "^0.0.0-unstable.da99e0b846",
|
|
36
|
+
"@webiny/handler-aws": "^0.0.0-unstable.da99e0b846",
|
|
37
|
+
"@webiny/plugins": "^0.0.0-unstable.da99e0b846",
|
|
38
|
+
"@webiny/project-utils": "^0.0.0-unstable.da99e0b846",
|
|
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.da99e0b846",
|
|
45
|
+
"@webiny/api-admin-settings": "0.0.0-unstable.da99e0b846",
|
|
46
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.da99e0b846",
|
|
47
|
+
"@webiny/api-i18n": "0.0.0-unstable.da99e0b846",
|
|
48
|
+
"@webiny/api-security": "0.0.0-unstable.da99e0b846",
|
|
49
|
+
"@webiny/api-tenancy": "0.0.0-unstable.da99e0b846",
|
|
50
|
+
"@webiny/error": "0.0.0-unstable.da99e0b846",
|
|
51
|
+
"@webiny/handler": "0.0.0-unstable.da99e0b846",
|
|
52
|
+
"@webiny/handler-graphql": "0.0.0-unstable.da99e0b846",
|
|
53
|
+
"@webiny/pubsub": "0.0.0-unstable.da99e0b846",
|
|
54
|
+
"@webiny/utils": "0.0.0-unstable.da99e0b846",
|
|
54
55
|
"lodash": "4.17.21"
|
|
55
56
|
},
|
|
56
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "da99e0b8461741d3ae57fdb9d4b2fc7646c1d754"
|
|
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,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare type SearchRecordModelDefinition =
|
|
3
|
-
export declare const SEARCH_RECORD_MODEL_ID = "
|
|
1
|
+
import { CmsPrivateModelFull } from "@webiny/api-headless-cms";
|
|
2
|
+
export declare type SearchRecordModelDefinition = Omit<CmsPrivateModelFull, "noValidate" | "group">;
|
|
3
|
+
export declare const SEARCH_RECORD_MODEL_ID = "acoSearchRecord";
|
|
4
4
|
export declare const createSearchModelDefinition: () => SearchRecordModelDefinition;
|
package/record/record.model.js
CHANGED
|
@@ -5,22 +5,9 @@ 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",
|
|
23
|
-
parent: "searchRecord",
|
|
24
11
|
validation: [{
|
|
25
12
|
name: "required",
|
|
26
13
|
message: "Value is required."
|
|
@@ -28,18 +15,15 @@ const typeField = () => (0, _createModelField.createModelField)({
|
|
|
28
15
|
});
|
|
29
16
|
const titleField = () => (0, _createModelField.createModelField)({
|
|
30
17
|
label: "Title",
|
|
31
|
-
type: "text"
|
|
32
|
-
parent: "searchRecord"
|
|
18
|
+
type: "text"
|
|
33
19
|
});
|
|
34
20
|
const contentField = () => (0, _createModelField.createModelField)({
|
|
35
21
|
label: "Content",
|
|
36
|
-
type: "text"
|
|
37
|
-
parent: "searchRecord"
|
|
22
|
+
type: "text"
|
|
38
23
|
});
|
|
39
24
|
const locationField = fields => (0, _createModelField.createModelField)({
|
|
40
25
|
label: "Location",
|
|
41
26
|
type: "object",
|
|
42
|
-
parent: "searchRecord",
|
|
43
27
|
multipleValues: false,
|
|
44
28
|
settings: {
|
|
45
29
|
fields
|
|
@@ -48,7 +32,6 @@ const locationField = fields => (0, _createModelField.createModelField)({
|
|
|
48
32
|
const locationFolderIdField = () => (0, _createModelField.createModelField)({
|
|
49
33
|
label: "Folder Id",
|
|
50
34
|
type: "text",
|
|
51
|
-
parent: "searchRecord Location",
|
|
52
35
|
validation: [{
|
|
53
36
|
name: "required",
|
|
54
37
|
message: "Value is required."
|
|
@@ -56,18 +39,17 @@ const locationFolderIdField = () => (0, _createModelField.createModelField)({
|
|
|
56
39
|
});
|
|
57
40
|
const dataField = () => (0, _createModelField.createModelField)({
|
|
58
41
|
label: "Data",
|
|
59
|
-
type: "wby-aco-json"
|
|
60
|
-
parent: "searchRecord"
|
|
42
|
+
type: "wby-aco-json"
|
|
61
43
|
});
|
|
62
|
-
const SEARCH_RECORD_MODEL_ID = "
|
|
44
|
+
const SEARCH_RECORD_MODEL_ID = "acoSearchRecord";
|
|
63
45
|
exports.SEARCH_RECORD_MODEL_ID = SEARCH_RECORD_MODEL_ID;
|
|
64
46
|
const createSearchModelDefinition = () => {
|
|
65
47
|
return {
|
|
66
48
|
name: "ACO - Search Record",
|
|
67
49
|
modelId: SEARCH_RECORD_MODEL_ID,
|
|
68
|
-
titleFieldId: "
|
|
69
|
-
layout: [["
|
|
70
|
-
fields: [
|
|
50
|
+
titleFieldId: "title",
|
|
51
|
+
layout: [["type"], ["title"], ["content"], ["location"], ["data"]],
|
|
52
|
+
fields: [typeField(), titleField(), contentField(), locationField([locationFolderIdField()]), dataField()],
|
|
71
53
|
description: "ACO - Search record model",
|
|
72
54
|
isPrivate: true
|
|
73
55
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["typeField","createModelField","label","type","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 { 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 });\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 settings: { fields }\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 = () =>\n createModelField({\n label: \"Data\",\n type: \"wby-aco-json\"\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: [[\"type\"], [\"title\"], [\"content\"], [\"location\"], [\"data\"]],\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":";;;;;;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;AACV,CAAC,CAAC;AAEN,MAAMK,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;EACrBC,QAAQ,EAAE;IAAEF;EAAO;AACvB,CAAC,CAAC;AAEN,MAAMG,qBAAqB,GAAG,MAC1B,IAAAZ,kCAAgB,EAAC;EACbC,KAAK,EAAE,WAAW;EAClBC,IAAI,EAAE,MAAM;EACZC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAMQ,SAAS,GAAG,MACd,IAAAb,kCAAgB,EAAC;EACbC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAE;AACV,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,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IAClET,MAAM,EAAE,CACJV,SAAS,EAAE,EACXO,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
|
@@ -9,91 +9,81 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/obje
|
|
|
9
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
10
|
var _record = require("./record.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 createSearchRecordOperations = 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 getRecord = async ({
|
|
28
|
-
id
|
|
29
|
-
}) => {
|
|
30
|
-
const model = await getRecordModel();
|
|
31
|
-
security.disableAuthorization();
|
|
32
|
-
|
|
19
|
+
const {
|
|
20
|
+
withModel
|
|
21
|
+
} = (0, _createOperationsWrapper.createOperationsWrapper)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
22
|
+
modelName: _record.SEARCH_RECORD_MODEL_ID
|
|
23
|
+
}));
|
|
24
|
+
const getRecord = async (model, id) => {
|
|
33
25
|
/**
|
|
34
|
-
* The record "id"
|
|
35
|
-
*
|
|
26
|
+
* The record "id" has been passed by the original entry.
|
|
27
|
+
* We need to retrieve it via `cms.storageOperations.entries.getLatestByIds()` method and return the first one.
|
|
36
28
|
*/
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
originalId: id,
|
|
40
|
-
latest: true
|
|
41
|
-
}
|
|
29
|
+
const revisions = await cms.storageOperations.entries.getLatestByIds(model, {
|
|
30
|
+
ids: [id]
|
|
42
31
|
});
|
|
43
|
-
if (
|
|
44
|
-
throw new _error.default("
|
|
32
|
+
if (revisions.length === 0) {
|
|
33
|
+
throw new _error.default("Record not found.", "NOT_FOUND", {
|
|
45
34
|
id
|
|
46
35
|
});
|
|
47
36
|
}
|
|
48
|
-
|
|
49
|
-
return (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields);
|
|
37
|
+
return revisions[0];
|
|
50
38
|
};
|
|
51
39
|
return {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return
|
|
40
|
+
async getRecord({
|
|
41
|
+
id
|
|
42
|
+
}) {
|
|
43
|
+
return withModel(async model => {
|
|
44
|
+
const record = await getRecord(model, id);
|
|
45
|
+
return (0, _getFieldValues.getFieldValues)(record, _createAcoStorageOperations.baseFields, true);
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
listRecords(params) {
|
|
49
|
+
return withModel(async model => {
|
|
50
|
+
const {
|
|
51
|
+
sort,
|
|
52
|
+
where
|
|
53
|
+
} = params;
|
|
54
|
+
const [entries, meta] = await cms.listLatestEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
55
|
+
sort: (0, _createListSort.createListSort)(sort),
|
|
56
|
+
where: (0, _objectSpread2.default)({}, where || {})
|
|
57
|
+
}));
|
|
58
|
+
return [entries.map(entry => (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields, true)), meta];
|
|
59
|
+
});
|
|
62
60
|
},
|
|
63
|
-
|
|
61
|
+
createRecord({
|
|
64
62
|
data
|
|
65
63
|
}) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields);
|
|
64
|
+
return withModel(async model => {
|
|
65
|
+
const entry = await cms.createEntry(model, data);
|
|
66
|
+
return (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields, true);
|
|
67
|
+
});
|
|
71
68
|
},
|
|
72
|
-
|
|
69
|
+
updateRecord({
|
|
73
70
|
id,
|
|
74
71
|
data
|
|
75
72
|
}) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
id
|
|
73
|
+
return withModel(async model => {
|
|
74
|
+
const original = await getRecord(model, id);
|
|
75
|
+
const input = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, original), data);
|
|
76
|
+
const entry = await cms.updateEntry(model, original.id, input);
|
|
77
|
+
return (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields, true);
|
|
80
78
|
});
|
|
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
79
|
},
|
|
86
|
-
|
|
80
|
+
deleteRecord({
|
|
87
81
|
id
|
|
88
82
|
}) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
id
|
|
83
|
+
return withModel(async model => {
|
|
84
|
+
await cms.deleteEntry(model, id);
|
|
85
|
+
return true;
|
|
93
86
|
});
|
|
94
|
-
await cms.deleteEntry(model, entry.id);
|
|
95
|
-
security.enableAuthorization();
|
|
96
|
-
return true;
|
|
97
87
|
}
|
|
98
88
|
};
|
|
99
89
|
};
|
package/record/record.so.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createSearchRecordOperations","params","cms","
|
|
1
|
+
{"version":3,"names":["createSearchRecordOperations","params","cms","withModel","createOperationsWrapper","modelName","SEARCH_RECORD_MODEL_ID","getRecord","model","id","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 WebinyError from \"@webiny/error\";\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\";\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 } = params;\n\n const { withModel } = createOperationsWrapper({\n ...params,\n modelName: SEARCH_RECORD_MODEL_ID\n });\n\n const getRecord = async (model: CmsModel, id: string) => {\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;
|
|
@@ -36,3 +41,7 @@ export declare type AcoStorageOperations = AcoFolderStorageOperations & AcoSearc
|
|
|
36
41
|
export interface AcoContext extends BaseContext, I18NContext, TenancyContext, SecurityContext, CmsContext {
|
|
37
42
|
aco: AdvancedContentOrganisation;
|
|
38
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Use AcoContext instead
|
|
46
|
+
*/
|
|
47
|
+
export declare type ACOContext = AcoContext;
|
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\n/**\n * @deprecated Use AcoContext instead\n */\nexport type ACOContext = AcoContext;\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"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CmsModelField } from "@webiny/api-headless-cms/types";
|
|
2
2
|
export interface CreateModelFieldParams extends Omit<CmsModelField, "id" | "storageId" | "fieldId"> {
|
|
3
3
|
fieldId?: string;
|
|
4
|
-
parent: string;
|
|
5
4
|
}
|
|
6
5
|
export declare const createModelField: (params: CreateModelFieldParams) => CmsModelField;
|