@webiny/api-aco 0.0.0-unstable.d7f521b032 → 0.0.0-unstable.de38392959
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/apps/AcoApp.d.ts +21 -0
- package/apps/AcoApp.js +143 -0
- package/apps/AcoApp.js.map +1 -0
- package/apps/AcoApps.d.ts +10 -0
- package/apps/AcoApps.js +75 -0
- package/apps/AcoApps.js.map +1 -0
- package/apps/app.gql.d.ts +3 -0
- package/apps/app.gql.js +60 -0
- package/apps/app.gql.js.map +1 -0
- package/apps/index.d.ts +2 -0
- package/apps/index.js +29 -0
- package/apps/index.js.map +1 -0
- package/createAcoContext.d.ts +5 -1
- package/createAcoContext.js +159 -28
- package/createAcoContext.js.map +1 -1
- package/createAcoGraphQL.d.ts +2 -2
- package/createAcoGraphQL.js +49 -15
- package/createAcoGraphQL.js.map +1 -1
- package/createAcoHooks.js +9 -3
- package/createAcoHooks.js.map +1 -1
- package/createAcoModels.js +6 -44
- package/createAcoModels.js.map +1 -1
- package/createAcoStorageOperations.d.ts +0 -1
- package/createAcoStorageOperations.js +10 -7
- package/createAcoStorageOperations.js.map +1 -1
- package/filter/filter.crud.d.ts +3 -0
- package/filter/filter.crud.js +94 -0
- package/filter/filter.crud.js.map +1 -0
- package/filter/filter.gql.d.ts +3 -0
- package/filter/filter.gql.js +153 -0
- package/filter/filter.gql.js.map +1 -0
- package/filter/filter.model.d.ts +2 -0
- package/filter/filter.model.js +125 -0
- package/filter/filter.model.js.map +1 -0
- package/filter/filter.so.d.ts +3 -0
- package/filter/filter.so.js +98 -0
- package/filter/filter.so.js.map +1 -0
- package/filter/filter.types.d.ts +95 -0
- package/filter/filter.types.js +14 -0
- package/filter/filter.types.js.map +1 -0
- package/folder/folder.crud.d.ts +8 -1
- package/folder/folder.crud.js +201 -4
- package/folder/folder.crud.js.map +1 -1
- package/folder/folder.gql.js +99 -7
- package/folder/folder.gql.js.map +1 -1
- package/folder/folder.model.d.ts +2 -4
- package/folder/folder.model.js +56 -31
- package/folder/folder.model.js.map +1 -1
- package/folder/folder.so.d.ts +1 -6
- package/folder/folder.so.js +127 -112
- package/folder/folder.so.js.map +1 -1
- package/folder/folder.types.d.ts +36 -4
- package/folder/folder.types.js +3 -1
- package/folder/folder.types.js.map +1 -1
- package/folder/onFolderBeforeDeleteAco.hook.d.ts +2 -0
- package/folder/onFolderBeforeDeleteAco.hook.js +67 -0
- package/folder/onFolderBeforeDeleteAco.hook.js.map +1 -0
- package/folder/onFolderBeforeDeleteFm.hook.d.ts +2 -0
- package/folder/onFolderBeforeDeleteFm.hook.js +49 -0
- package/folder/onFolderBeforeDeleteFm.hook.js.map +1 -0
- package/folder/onFolderBeforeDeleteHcms.hook.d.ts +2 -0
- package/folder/onFolderBeforeDeleteHcms.hook.js +56 -0
- package/folder/onFolderBeforeDeleteHcms.hook.js.map +1 -0
- package/index.d.ts +9 -1
- package/index.js +57 -6
- package/index.js.map +1 -1
- package/package.json +38 -31
- package/plugins/AcoAppModifierPlugin.d.ts +43 -0
- package/plugins/AcoAppModifierPlugin.js +58 -0
- package/plugins/AcoAppModifierPlugin.js.map +1 -0
- package/plugins/AcoAppRegisterPlugin.d.ts +8 -0
- package/plugins/AcoAppRegisterPlugin.js +21 -0
- package/plugins/AcoAppRegisterPlugin.js.map +1 -0
- package/plugins/index.d.ts +2 -0
- package/plugins/index.js +29 -0
- package/plugins/index.js.map +1 -0
- package/record/graphql/createAppResolvers.d.ts +14 -0
- package/record/graphql/createAppResolvers.js +115 -0
- package/record/graphql/createAppResolvers.js.map +1 -0
- package/record/graphql/createAppSchema.d.ts +9 -0
- package/record/graphql/createAppSchema.js +147 -0
- package/record/graphql/createAppSchema.js.map +1 -0
- package/record/record.crud.js +49 -13
- package/record/record.crud.js.map +1 -1
- package/record/record.gql.d.ts +8 -3
- package/record/record.gql.js +38 -113
- package/record/record.gql.js.map +1 -1
- package/record/record.model.d.ts +8 -4
- package/record/record.model.js +44 -33
- package/record/record.model.js.map +1 -1
- package/record/record.so.d.ts +1 -6
- package/record/record.so.js +126 -64
- package/record/record.so.js.map +1 -1
- package/record/record.types.d.ts +69 -17
- package/record/record.types.js +3 -1
- package/record/record.types.js.map +1 -1
- package/types.d.ts +78 -8
- package/types.js +56 -1
- package/types.js.map +1 -1
- package/utils/FolderLevelPermissions.d.ts +71 -0
- package/utils/FolderLevelPermissions.js +353 -0
- package/utils/FolderLevelPermissions.js.map +1 -0
- package/utils/acoRecordId.d.ts +6 -0
- package/utils/acoRecordId.js +35 -0
- package/utils/acoRecordId.js.map +1 -0
- package/utils/createListSort.d.ts +2 -0
- package/utils/createListSort.js +15 -0
- package/utils/createListSort.js.map +1 -0
- package/utils/createModelField.d.ts +0 -1
- package/utils/createModelField.js +5 -5
- package/utils/createModelField.js.map +1 -1
- package/utils/createOperationsWrapper.d.ts +9 -0
- package/utils/createOperationsWrapper.js +31 -0
- package/utils/createOperationsWrapper.js.map +1 -0
- package/utils/decorators/CmsEntriesCrudDecorators.d.ts +11 -0
- package/utils/decorators/CmsEntriesCrudDecorators.js +190 -0
- package/utils/decorators/CmsEntriesCrudDecorators.js.map +1 -0
- package/utils/decorators/constants.d.ts +1 -0
- package/utils/decorators/constants.js +10 -0
- package/utils/decorators/constants.js.map +1 -0
- package/utils/decorators/createFolderType.d.ts +2 -0
- package/utils/decorators/createFolderType.js +18 -0
- package/utils/decorators/createFolderType.js.map +1 -0
- package/utils/decorators/filterEntriesByFolderFactory.d.ts +6 -0
- package/utils/decorators/filterEntriesByFolderFactory.js +37 -0
- package/utils/decorators/filterEntriesByFolderFactory.js.map +1 -0
- package/utils/decorators/isPageModel.d.ts +5 -0
- package/utils/decorators/isPageModel.js +20 -0
- package/utils/decorators/isPageModel.js.map +1 -0
- package/utils/decorators/where.d.ts +15 -0
- package/utils/decorators/where.js +60 -0
- package/utils/decorators/where.js.map +1 -0
- package/utils/ensureAuthentication.d.ts +2 -0
- package/utils/ensureAuthentication.js +16 -0
- package/utils/ensureAuthentication.js.map +1 -0
- package/utils/getFolderAndItsAncestors.d.ts +7 -0
- package/utils/getFolderAndItsAncestors.js +53 -0
- package/utils/getFolderAndItsAncestors.js.map +1 -0
- package/utils/isInstallationPending.js +3 -1
- package/utils/isInstallationPending.js.map +1 -1
- package/utils/modelFactory.d.ts +2 -4
- package/utils/modelFactory.js +7 -8
- package/utils/modelFactory.js.map +1 -1
- package/utils/pickEntryFieldValues.d.ts +3 -0
- package/utils/pickEntryFieldValues.js +31 -0
- package/utils/pickEntryFieldValues.js.map +1 -0
- package/utils/resolve.d.ts +3 -2
- package/utils/resolve.js +13 -2
- package/utils/resolve.js.map +1 -1
- package/context/folders.d.ts +0 -2
- package/context/folders.js +0 -261
- package/context/folders.js.map +0 -1
- package/context/index.d.ts +0 -2
- package/context/index.js +0 -22
- package/context/index.js.map +0 -1
- package/context/links.d.ts +0 -2
- package/context/links.js +0 -270
- package/context/links.js.map +0 -1
- package/createAcoCrud.d.ts +0 -2
- package/createAcoCrud.js +0 -17
- package/createAcoCrud.js.map +0 -1
- package/createAcoFields.d.ts +0 -2
- package/createAcoFields.js +0 -40
- package/createAcoFields.js.map +0 -1
- package/folder/onFolderBeforeDelete.hook.d.ts +0 -2
- package/folder/onFolderBeforeDelete.hook.js +0 -53
- package/folder/onFolderBeforeDelete.hook.js.map +0 -1
- package/graphql/base.gql.d.ts +0 -3
- package/graphql/base.gql.js +0 -63
- package/graphql/base.gql.js.map +0 -1
- package/graphql/folders.gql.d.ts +0 -3
- package/graphql/folders.gql.js +0 -126
- package/graphql/folders.gql.js.map +0 -1
- package/graphql/index.d.ts +0 -1
- package/graphql/index.js +0 -15
- package/graphql/index.js.map +0 -1
- package/graphql/links.gql.d.ts +0 -3
- package/graphql/links.gql.js +0 -123
- package/graphql/links.gql.js.map +0 -1
- package/subscriptions/afterFolderDelete.d.ts +0 -3
- package/subscriptions/afterFolderDelete.js +0 -62
- package/subscriptions/afterFolderDelete.js.map +0 -1
- package/subscriptions/index.d.ts +0 -3
- package/subscriptions/index.js +0 -14
- package/subscriptions/index.js.map +0 -1
- package/utils/fieldResolver.d.ts +0 -16
- package/utils/fieldResolver.js +0 -44
- package/utils/fieldResolver.js.map +0 -1
- package/utils/getFieldValues.d.ts +0 -2
- package/utils/getFieldValues.js +0 -12
- package/utils/getFieldValues.js.map +0 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createAppSchema = void 0;
|
|
7
|
+
var _renderFields = require("@webiny/api-headless-cms/utils/renderFields");
|
|
8
|
+
var _renderInputFields = require("@webiny/api-headless-cms/utils/renderInputFields");
|
|
9
|
+
var _renderListFilterFields = require("@webiny/api-headless-cms/utils/renderListFilterFields");
|
|
10
|
+
var _renderSortEnum = require("@webiny/api-headless-cms/utils/renderSortEnum");
|
|
11
|
+
const removeFieldRequiredValidation = field => {
|
|
12
|
+
if (field.validation) {
|
|
13
|
+
field.validation = field.validation.filter(validation => validation.name !== "required");
|
|
14
|
+
}
|
|
15
|
+
if (field.listValidation) {
|
|
16
|
+
field.listValidation = field.listValidation.filter(v => v.name !== "required");
|
|
17
|
+
}
|
|
18
|
+
return field;
|
|
19
|
+
};
|
|
20
|
+
const createUpdateFields = fields => {
|
|
21
|
+
return fields.reduce((collection, field) => {
|
|
22
|
+
if (["type"].includes(field.fieldId)) {
|
|
23
|
+
return collection;
|
|
24
|
+
} else if (field.fieldId === "tags") {
|
|
25
|
+
collection.push(field);
|
|
26
|
+
return collection;
|
|
27
|
+
}
|
|
28
|
+
collection.push(removeFieldRequiredValidation({
|
|
29
|
+
...field
|
|
30
|
+
}));
|
|
31
|
+
return collection;
|
|
32
|
+
}, []);
|
|
33
|
+
};
|
|
34
|
+
const createAppSchema = params => {
|
|
35
|
+
const {
|
|
36
|
+
app,
|
|
37
|
+
models,
|
|
38
|
+
plugins: fieldTypePlugins
|
|
39
|
+
} = params;
|
|
40
|
+
const {
|
|
41
|
+
model
|
|
42
|
+
} = app;
|
|
43
|
+
const {
|
|
44
|
+
singularApiName: apiName,
|
|
45
|
+
fields
|
|
46
|
+
} = model;
|
|
47
|
+
const fieldTypes = (0, _renderFields.renderFields)({
|
|
48
|
+
models,
|
|
49
|
+
model,
|
|
50
|
+
fields,
|
|
51
|
+
type: "manage",
|
|
52
|
+
fieldTypePlugins
|
|
53
|
+
});
|
|
54
|
+
const inputCreateFields = (0, _renderInputFields.renderInputFields)({
|
|
55
|
+
models,
|
|
56
|
+
model,
|
|
57
|
+
fields,
|
|
58
|
+
fieldTypePlugins
|
|
59
|
+
});
|
|
60
|
+
const inputUpdateFields = (0, _renderInputFields.renderInputFields)({
|
|
61
|
+
models,
|
|
62
|
+
model,
|
|
63
|
+
fields: createUpdateFields(fields),
|
|
64
|
+
fieldTypePlugins
|
|
65
|
+
});
|
|
66
|
+
const listFilterFieldsRender = (0, _renderListFilterFields.renderListFilterFields)({
|
|
67
|
+
model,
|
|
68
|
+
fields: model.fields,
|
|
69
|
+
type: "manage",
|
|
70
|
+
fieldTypePlugins
|
|
71
|
+
});
|
|
72
|
+
const sortEnumRender = (0, _renderSortEnum.renderSortEnum)({
|
|
73
|
+
model,
|
|
74
|
+
fields: model.fields,
|
|
75
|
+
fieldTypePlugins
|
|
76
|
+
});
|
|
77
|
+
return (/* GraphQL */`
|
|
78
|
+
${fieldTypes.map(f => f.typeDefs).join("\n")}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
type ${apiName} {
|
|
82
|
+
id: ID!
|
|
83
|
+
createdOn: DateTime!
|
|
84
|
+
modifiedOn: DateTime
|
|
85
|
+
savedOn: DateTime!
|
|
86
|
+
createdBy: AcoUser!
|
|
87
|
+
modifiedBy: AcoUser
|
|
88
|
+
savedBy: AcoUser!
|
|
89
|
+
${fieldTypes.map(f => f.fields).join("\n")}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
${inputCreateFields.map(f => f.typeDefs).join("\n")}
|
|
93
|
+
|
|
94
|
+
input ${apiName}CreateInput {
|
|
95
|
+
id: ID
|
|
96
|
+
${inputCreateFields.map(f => f.fields).join("\n")}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
input ${apiName}UpdateInput {
|
|
100
|
+
${inputUpdateFields.map(f => f.fields).join("\n")}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
type ${apiName}Response {
|
|
104
|
+
data: ${apiName}
|
|
105
|
+
error: AcoError
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
input ${apiName}ListWhereInput {
|
|
109
|
+
${listFilterFieldsRender}
|
|
110
|
+
AND: [${apiName}ListWhereInput!]
|
|
111
|
+
OR: [${apiName}ListWhereInput!]
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
type ${apiName}ListResponse {
|
|
115
|
+
data: [${apiName}!]
|
|
116
|
+
error: AcoError
|
|
117
|
+
meta: AcoMeta
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
enum ${apiName}ListSorter {
|
|
121
|
+
${sortEnumRender}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
extend type SearchQuery {
|
|
125
|
+
get${apiName}(id: ID!): ${apiName}Response!
|
|
126
|
+
list${apiName}(
|
|
127
|
+
where: ${apiName}ListWhereInput
|
|
128
|
+
search: String
|
|
129
|
+
limit: Int
|
|
130
|
+
after: String
|
|
131
|
+
sort: [${apiName}ListSorter!]
|
|
132
|
+
): ${apiName}ListResponse!
|
|
133
|
+
list${apiName}Tags(where: AcoSearchRecordTagListWhereInput): AcoSearchRecordTagListResponse!
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
extend type SearchMutation {
|
|
137
|
+
create${apiName}(data: ${apiName}CreateInput!): ${apiName}Response!
|
|
138
|
+
update${apiName}(id: ID!, data: ${apiName}UpdateInput!): ${apiName}Response!
|
|
139
|
+
move${apiName}(id: ID!, folderId: ID!): AcoSearchRecordMoveResponse!
|
|
140
|
+
delete${apiName}(id: ID!): AcoBooleanResponse!
|
|
141
|
+
}
|
|
142
|
+
`
|
|
143
|
+
);
|
|
144
|
+
};
|
|
145
|
+
exports.createAppSchema = createAppSchema;
|
|
146
|
+
|
|
147
|
+
//# sourceMappingURL=createAppSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_renderFields","require","_renderInputFields","_renderListFilterFields","_renderSortEnum","removeFieldRequiredValidation","field","validation","filter","name","listValidation","v","createUpdateFields","fields","reduce","collection","includes","fieldId","push","createAppSchema","params","app","models","plugins","fieldTypePlugins","model","singularApiName","apiName","fieldTypes","renderFields","type","inputCreateFields","renderInputFields","inputUpdateFields","listFilterFieldsRender","renderListFilterFields","sortEnumRender","renderSortEnum","map","f","typeDefs","join","exports"],"sources":["createAppSchema.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport { renderFields } from \"@webiny/api-headless-cms/utils/renderFields\";\nimport { renderInputFields } from \"@webiny/api-headless-cms/utils/renderInputFields\";\nimport { IAcoApp } from \"~/types\";\nimport { renderListFilterFields } from \"@webiny/api-headless-cms/utils/renderListFilterFields\";\nimport { renderSortEnum } from \"@webiny/api-headless-cms/utils/renderSortEnum\";\n\ninterface Params {\n app: IAcoApp;\n models: CmsModel[];\n plugins: CmsFieldTypePlugins;\n}\n\nconst removeFieldRequiredValidation = (field: CmsModelField) => {\n if (field.validation) {\n field.validation = field.validation.filter(validation => validation.name !== \"required\");\n }\n if (field.listValidation) {\n field.listValidation = field.listValidation.filter(v => v.name !== \"required\");\n }\n return field;\n};\n\nconst createUpdateFields = (fields: CmsModelField[]): CmsModelField[] => {\n return fields.reduce<CmsModelField[]>((collection, field) => {\n if ([\"type\"].includes(field.fieldId)) {\n return collection;\n } else if (field.fieldId === \"tags\") {\n collection.push(field);\n return collection;\n }\n collection.push(removeFieldRequiredValidation({ ...field }));\n return collection;\n }, []);\n};\n\nexport const createAppSchema = (params: Params): string => {\n const { app, models, plugins: fieldTypePlugins } = params;\n const { model } = app;\n const { singularApiName: apiName, fields } = model;\n\n const fieldTypes = renderFields({\n models,\n model,\n fields,\n type: \"manage\",\n fieldTypePlugins\n });\n const inputCreateFields = renderInputFields({\n models,\n model,\n fields,\n fieldTypePlugins\n });\n const inputUpdateFields = renderInputFields({\n models,\n model,\n fields: createUpdateFields(fields),\n fieldTypePlugins\n });\n const listFilterFieldsRender = renderListFilterFields({\n model,\n fields: model.fields,\n type: \"manage\",\n fieldTypePlugins\n });\n\n const sortEnumRender = renderSortEnum({\n model,\n fields: model.fields,\n fieldTypePlugins\n });\n\n return /* GraphQL */ `\n ${fieldTypes.map(f => f.typeDefs).join(\"\\n\")}\n\n\n type ${apiName} {\n id: ID!\n createdOn: DateTime!\n modifiedOn: DateTime\n savedOn: DateTime!\n createdBy: AcoUser!\n modifiedBy: AcoUser\n savedBy: AcoUser!\n ${fieldTypes.map(f => f.fields).join(\"\\n\")}\n }\n\n ${inputCreateFields.map(f => f.typeDefs).join(\"\\n\")}\n\n input ${apiName}CreateInput {\n id: ID\n ${inputCreateFields.map(f => f.fields).join(\"\\n\")}\n }\n\n input ${apiName}UpdateInput {\n ${inputUpdateFields.map(f => f.fields).join(\"\\n\")}\n }\n\n type ${apiName}Response {\n data: ${apiName}\n error: AcoError\n }\n\n input ${apiName}ListWhereInput {\n ${listFilterFieldsRender}\n AND: [${apiName}ListWhereInput!]\n OR: [${apiName}ListWhereInput!]\n }\n\n type ${apiName}ListResponse {\n data: [${apiName}!]\n error: AcoError\n meta: AcoMeta\n }\n\n enum ${apiName}ListSorter {\n ${sortEnumRender}\n }\n\n extend type SearchQuery {\n get${apiName}(id: ID!): ${apiName}Response!\n list${apiName}(\n where: ${apiName}ListWhereInput\n search: String\n limit: Int\n after: String\n sort: [${apiName}ListSorter!]\n ): ${apiName}ListResponse!\n list${apiName}Tags(where: AcoSearchRecordTagListWhereInput): AcoSearchRecordTagListResponse!\n }\n\n extend type SearchMutation {\n create${apiName}(data: ${apiName}CreateInput!): ${apiName}Response!\n update${apiName}(id: ID!, data: ${apiName}UpdateInput!): ${apiName}Response!\n move${apiName}(id: ID!, folderId: ID!): AcoSearchRecordMoveResponse!\n delete${apiName}(id: ID!): AcoBooleanResponse!\n }\n `;\n};\n"],"mappings":";;;;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AAEA,IAAAE,uBAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAQA,MAAMI,6BAA6B,GAAIC,KAAoB,IAAK;EAC5D,IAAIA,KAAK,CAACC,UAAU,EAAE;IAClBD,KAAK,CAACC,UAAU,GAAGD,KAAK,CAACC,UAAU,CAACC,MAAM,CAACD,UAAU,IAAIA,UAAU,CAACE,IAAI,KAAK,UAAU,CAAC;EAC5F;EACA,IAAIH,KAAK,CAACI,cAAc,EAAE;IACtBJ,KAAK,CAACI,cAAc,GAAGJ,KAAK,CAACI,cAAc,CAACF,MAAM,CAACG,CAAC,IAAIA,CAAC,CAACF,IAAI,KAAK,UAAU,CAAC;EAClF;EACA,OAAOH,KAAK;AAChB,CAAC;AAED,MAAMM,kBAAkB,GAAIC,MAAuB,IAAsB;EACrE,OAAOA,MAAM,CAACC,MAAM,CAAkB,CAACC,UAAU,EAAET,KAAK,KAAK;IACzD,IAAI,CAAC,MAAM,CAAC,CAACU,QAAQ,CAACV,KAAK,CAACW,OAAO,CAAC,EAAE;MAClC,OAAOF,UAAU;IACrB,CAAC,MAAM,IAAIT,KAAK,CAACW,OAAO,KAAK,MAAM,EAAE;MACjCF,UAAU,CAACG,IAAI,CAACZ,KAAK,CAAC;MACtB,OAAOS,UAAU;IACrB;IACAA,UAAU,CAACG,IAAI,CAACb,6BAA6B,CAAC;MAAE,GAAGC;IAAM,CAAC,CAAC,CAAC;IAC5D,OAAOS,UAAU;EACrB,CAAC,EAAE,EAAE,CAAC;AACV,CA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V,iBAAiB,CAACO,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,QAAQ,CAAC,CAACC,IAAI,CAAC,IAAI,CAAE;AAC5D;AACA,gBAAgBd,OAAQ;AACxB;AACA,cAAcI,iBAAiB,CAACO,GAAG,CAACC,CAAC,IAAIA,CAAC,CAAC1B,MAAM,CAAC,CAAC4B,IAAI,CAAC,IAAI,CAAE;AAC9D;AACA;AACA,gBAAgBd,OAAQ;AACxB,cAAcM,iBAAiB,CAACK,GAAG,CAACC,CAAC,IAAIA,CAAC,CAAC1B,MAAM,CAAC,CAAC4B,IAAI,CAAC,IAAI,CAAE;AAC9D;AACA;AACA,eAAed,OAAQ;AACvB,oBAAoBA,OAAQ;AAC5B;AACA;AACA;AACA,gBAAgBA,OAAQ;AACxB,cAAcO,sBAAuB;AACrC,oBAAoBP,OAAQ;AAC5B,mBAAmBA,OAAQ;AAC3B;AACA;AACA,eAAeA,OAAQ;AACvB,qBAAqBA,OAAQ;AAC7B;AACA;AACA;AACA;AACA,eAAeA,OAAQ;AACvB,cAAcS,cAAe;AAC7B;AACA;AACA;AACA,iBAAiBT,OAAQ,cAAaA,OAAQ;AAC9C,kBAAkBA,OAAQ;AAC1B,yBAAyBA,OAAQ;AACjC;AACA;AACA;AACA,yBAAyBA,OAAQ;AACjC,iBAAiBA,OAAQ;AACzB,kBAAkBA,OAAQ;AAC1B;AACA;AACA;AACA,oBAAoBA,OAAQ,UAASA,OAAQ,kBAAiBA,OAAQ;AACtE,oBAAoBA,OAAQ,mBAAkBA,OAAQ,kBAAiBA,OAAQ;AAC/E,kBAAkBA,OAAQ;AAC1B,oBAAoBA,OAAQ;AAC5B;AACA;EAAK;AACL,CAAC;AAACe,OAAA,CAAAvB,eAAA,GAAAA,eAAA"}
|
package/record/record.crud.js
CHANGED
|
@@ -14,6 +14,9 @@ const createSearchRecordCrudMethods = ({
|
|
|
14
14
|
// update
|
|
15
15
|
const onSearchRecordBeforeUpdate = (0, _pubsub.createTopic)("aco.onSearchRecordBeforeUpdate");
|
|
16
16
|
const onSearchRecordAfterUpdate = (0, _pubsub.createTopic)("aco.onSearchRecordAfterUpdate");
|
|
17
|
+
// move
|
|
18
|
+
const onSearchRecordBeforeMove = (0, _pubsub.createTopic)("aco.onSearchRecordBeforeMove");
|
|
19
|
+
const onSearchRecordAfterMove = (0, _pubsub.createTopic)("aco.onSearchRecordAfterMove");
|
|
17
20
|
// delete
|
|
18
21
|
const onSearchRecordBeforeDelete = (0, _pubsub.createTopic)("aco.onSearchRecordBeforeDelete");
|
|
19
22
|
const onSearchRecordAfterDelete = (0, _pubsub.createTopic)("aco.onSearchRecordAfterDelete");
|
|
@@ -25,44 +28,50 @@ const createSearchRecordCrudMethods = ({
|
|
|
25
28
|
onSearchRecordAfterCreate,
|
|
26
29
|
onSearchRecordBeforeUpdate,
|
|
27
30
|
onSearchRecordAfterUpdate,
|
|
31
|
+
onSearchRecordBeforeMove,
|
|
32
|
+
onSearchRecordAfterMove,
|
|
28
33
|
onSearchRecordBeforeDelete,
|
|
29
34
|
onSearchRecordAfterDelete,
|
|
30
|
-
async get(id) {
|
|
31
|
-
return storageOperations.getRecord({
|
|
35
|
+
async get(model, id) {
|
|
36
|
+
return storageOperations.getRecord(model, {
|
|
32
37
|
id
|
|
33
38
|
});
|
|
34
39
|
},
|
|
35
|
-
async list(params) {
|
|
36
|
-
return storageOperations.listRecords(params);
|
|
40
|
+
async list(model, params) {
|
|
41
|
+
return storageOperations.listRecords(model, params);
|
|
37
42
|
},
|
|
38
|
-
async create(data) {
|
|
43
|
+
async create(model, data) {
|
|
39
44
|
await onSearchRecordBeforeCreate.publish({
|
|
45
|
+
model,
|
|
40
46
|
input: data
|
|
41
47
|
});
|
|
42
|
-
const record = await storageOperations.createRecord({
|
|
48
|
+
const record = await storageOperations.createRecord(model, {
|
|
43
49
|
data
|
|
44
50
|
});
|
|
45
51
|
await onSearchRecordAfterCreate.publish({
|
|
52
|
+
model,
|
|
46
53
|
record
|
|
47
54
|
});
|
|
48
55
|
return record;
|
|
49
56
|
},
|
|
50
|
-
async update(id, data) {
|
|
51
|
-
const original = await storageOperations.getRecord({
|
|
57
|
+
async update(model, id, data) {
|
|
58
|
+
const original = await storageOperations.getRecord(model, {
|
|
52
59
|
id
|
|
53
60
|
});
|
|
54
61
|
await onSearchRecordBeforeUpdate.publish({
|
|
62
|
+
model,
|
|
55
63
|
original,
|
|
56
64
|
input: {
|
|
57
65
|
id,
|
|
58
66
|
data
|
|
59
67
|
}
|
|
60
68
|
});
|
|
61
|
-
const record = await storageOperations.updateRecord({
|
|
69
|
+
const record = await storageOperations.updateRecord(model, {
|
|
62
70
|
id,
|
|
63
71
|
data
|
|
64
72
|
});
|
|
65
73
|
await onSearchRecordAfterUpdate.publish({
|
|
74
|
+
model,
|
|
66
75
|
original,
|
|
67
76
|
input: {
|
|
68
77
|
id,
|
|
@@ -72,21 +81,48 @@ const createSearchRecordCrudMethods = ({
|
|
|
72
81
|
});
|
|
73
82
|
return record;
|
|
74
83
|
},
|
|
75
|
-
async
|
|
76
|
-
const
|
|
84
|
+
async move(model, id, folderId) {
|
|
85
|
+
const original = await storageOperations.getRecord(model, {
|
|
86
|
+
id
|
|
87
|
+
});
|
|
88
|
+
await onSearchRecordBeforeMove.publish({
|
|
89
|
+
model,
|
|
90
|
+
original,
|
|
91
|
+
folderId
|
|
92
|
+
});
|
|
93
|
+
const result = await storageOperations.moveRecord(model, {
|
|
94
|
+
id,
|
|
95
|
+
folderId
|
|
96
|
+
});
|
|
97
|
+
await onSearchRecordAfterMove.publish({
|
|
98
|
+
model,
|
|
99
|
+
original,
|
|
100
|
+
folderId
|
|
101
|
+
});
|
|
102
|
+
return result;
|
|
103
|
+
},
|
|
104
|
+
async delete(model, id) {
|
|
105
|
+
const record = await storageOperations.getRecord(model, {
|
|
77
106
|
id
|
|
78
107
|
});
|
|
79
108
|
await onSearchRecordBeforeDelete.publish({
|
|
109
|
+
model,
|
|
80
110
|
record
|
|
81
111
|
});
|
|
82
|
-
await storageOperations.deleteRecord({
|
|
112
|
+
await storageOperations.deleteRecord(model, {
|
|
83
113
|
id
|
|
84
114
|
});
|
|
85
115
|
await onSearchRecordAfterDelete.publish({
|
|
116
|
+
model,
|
|
86
117
|
record
|
|
87
118
|
});
|
|
88
119
|
return true;
|
|
120
|
+
},
|
|
121
|
+
async listTags(model, params) {
|
|
122
|
+
return storageOperations.listTags(model, params);
|
|
89
123
|
}
|
|
90
124
|
};
|
|
91
125
|
};
|
|
92
|
-
exports.createSearchRecordCrudMethods = createSearchRecordCrudMethods;
|
|
126
|
+
exports.createSearchRecordCrudMethods = createSearchRecordCrudMethods;
|
|
127
|
+
|
|
128
|
+
//# sourceMappingURL=record.crud.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createSearchRecordCrudMethods","storageOperations","onSearchRecordBeforeCreate","createTopic","onSearchRecordAfterCreate","onSearchRecordBeforeUpdate","onSearchRecordAfterUpdate","onSearchRecordBeforeDelete","onSearchRecordAfterDelete","get","id","getRecord","list","params","listRecords","create","data","publish","input","record","createRecord","update","original","updateRecord","delete","deleteRecord"],"sources":["record.crud.ts"],"sourcesContent":["import { createTopic } from \"@webiny/pubsub\";\
|
|
1
|
+
{"version":3,"names":["_pubsub","require","createSearchRecordCrudMethods","storageOperations","onSearchRecordBeforeCreate","createTopic","onSearchRecordAfterCreate","onSearchRecordBeforeUpdate","onSearchRecordAfterUpdate","onSearchRecordBeforeMove","onSearchRecordAfterMove","onSearchRecordBeforeDelete","onSearchRecordAfterDelete","get","model","id","getRecord","list","params","listRecords","create","data","publish","input","record","createRecord","update","original","updateRecord","move","folderId","result","moveRecord","delete","deleteRecord","listTags","exports"],"sources":["record.crud.ts"],"sourcesContent":["import { createTopic } from \"@webiny/pubsub\";\nimport {\n CreateAcoParams,\n OnSearchRecordAfterMoveTopicParams,\n OnSearchRecordBeforeMoveTopicParams\n} from \"~/types\";\nimport {\n AcoSearchRecordCrud,\n OnSearchRecordAfterCreateTopicParams,\n OnSearchRecordAfterDeleteTopicParams,\n OnSearchRecordAfterUpdateTopicParams,\n OnSearchRecordBeforeCreateTopicParams,\n OnSearchRecordBeforeDeleteTopicParams,\n OnSearchRecordBeforeUpdateTopicParams\n} from \"./record.types\";\n\nexport const createSearchRecordCrudMethods = ({\n storageOperations\n}: CreateAcoParams): AcoSearchRecordCrud => {\n // create\n const onSearchRecordBeforeCreate = createTopic<OnSearchRecordBeforeCreateTopicParams>(\n \"aco.onSearchRecordBeforeCreate\"\n );\n const onSearchRecordAfterCreate = createTopic<OnSearchRecordAfterCreateTopicParams>(\n \"aco.onSearchRecordAfterCreate\"\n );\n // update\n const onSearchRecordBeforeUpdate = createTopic<OnSearchRecordBeforeUpdateTopicParams>(\n \"aco.onSearchRecordBeforeUpdate\"\n );\n const onSearchRecordAfterUpdate = createTopic<OnSearchRecordAfterUpdateTopicParams>(\n \"aco.onSearchRecordAfterUpdate\"\n );\n // move\n const onSearchRecordBeforeMove = createTopic<OnSearchRecordBeforeMoveTopicParams>(\n \"aco.onSearchRecordBeforeMove\"\n );\n const onSearchRecordAfterMove = createTopic<OnSearchRecordAfterMoveTopicParams>(\n \"aco.onSearchRecordAfterMove\"\n );\n // delete\n const onSearchRecordBeforeDelete = createTopic<OnSearchRecordBeforeDeleteTopicParams>(\n \"aco.onSearchRecordBeforeDelete\"\n );\n const onSearchRecordAfterDelete = createTopic<OnSearchRecordAfterDeleteTopicParams>(\n \"aco.onSearchRecordAfterDelete\"\n );\n\n return {\n /**\n * Lifecycle events\n */\n onSearchRecordBeforeCreate,\n onSearchRecordAfterCreate,\n onSearchRecordBeforeUpdate,\n onSearchRecordAfterUpdate,\n onSearchRecordBeforeMove,\n onSearchRecordAfterMove,\n onSearchRecordBeforeDelete,\n onSearchRecordAfterDelete,\n async get(model, id) {\n return storageOperations.getRecord(model, { id });\n },\n async list(model, params) {\n return storageOperations.listRecords(model, params);\n },\n async create(model, data) {\n await onSearchRecordBeforeCreate.publish({ model, input: data });\n const record = await storageOperations.createRecord(model, { data });\n await onSearchRecordAfterCreate.publish({ model, record });\n return record;\n },\n async update(model, id, data) {\n const original = await storageOperations.getRecord(model, { id });\n await onSearchRecordBeforeUpdate.publish({ model, original, input: { id, data } });\n const record = await storageOperations.updateRecord(model, { id, data });\n await onSearchRecordAfterUpdate.publish({\n model,\n original,\n input: { id, data },\n record\n });\n return record;\n },\n async move(model, id, folderId) {\n const original = await storageOperations.getRecord(model, { id });\n await onSearchRecordBeforeMove.publish({ model, original, folderId });\n const result = await storageOperations.moveRecord(model, {\n id,\n folderId\n });\n await onSearchRecordAfterMove.publish({\n model,\n original,\n folderId\n });\n return result;\n },\n async delete(model, id: string) {\n const record = await storageOperations.getRecord(model, { id });\n await onSearchRecordBeforeDelete.publish({ model, record });\n await storageOperations.deleteRecord(model, { id });\n await onSearchRecordAfterDelete.publish({ model, record });\n return true;\n },\n async listTags(model, params) {\n return storageOperations.listTags(model, params);\n }\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAgBO,MAAMC,6BAA6B,GAAGA,CAAC;EAC1CC;AACa,CAAC,KAA0B;EACxC;EACA,MAAMC,0BAA0B,GAAG,IAAAC,mBAAW,EAC1C,gCACJ,CAAC;EACD,MAAMC,yBAAyB,GAAG,IAAAD,mBAAW,EACzC,+BACJ,CAAC;EACD;EACA,MAAME,0BAA0B,GAAG,IAAAF,mBAAW,EAC1C,gCACJ,CAAC;EACD,MAAMG,yBAAyB,GAAG,IAAAH,mBAAW,EACzC,+BACJ,CAAC;EACD;EACA,MAAMI,wBAAwB,GAAG,IAAAJ,mBAAW,EACxC,8BACJ,CAAC;EACD,MAAMK,uBAAuB,GAAG,IAAAL,mBAAW,EACvC,6BACJ,CAAC;EACD;EACA,MAAMM,0BAA0B,GAAG,IAAAN,mBAAW,EAC1C,gCACJ,CAAC;EACD,MAAMO,yBAAyB,GAAG,IAAAP,mBAAW,EACzC,+BACJ,CAAC;EAED,OAAO;IACH;AACR;AACA;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,3 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { AcoContext, IAcoApp } from "../types";
|
|
2
|
+
import { GraphQLSchemaPlugin } from "@webiny/handler-graphql";
|
|
3
|
+
interface Params {
|
|
4
|
+
context: AcoContext;
|
|
5
|
+
app: IAcoApp;
|
|
6
|
+
}
|
|
7
|
+
export declare const createSchema: (params: Params) => Promise<GraphQLSchemaPlugin<import("@webiny/api/types").Context>>;
|
|
8
|
+
export {};
|
package/record/record.gql.js
CHANGED
|
@@ -3,116 +3,41 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
content: String
|
|
45
|
-
location: SearchLocationInput
|
|
46
|
-
data: JSON
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
input SearchRecordListWhereInput {
|
|
50
|
-
type: String!
|
|
51
|
-
location: SearchLocationInput
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
type SearchRecordResponse {
|
|
55
|
-
data: SearchRecord
|
|
56
|
-
error: AcoError
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
type SearchRecordListResponse {
|
|
60
|
-
data: [SearchRecord]
|
|
61
|
-
error: AcoError
|
|
62
|
-
meta: AcoMeta
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
extend type SearchQuery {
|
|
66
|
-
getRecord(id: ID!): SearchRecordResponse
|
|
67
|
-
listRecords(
|
|
68
|
-
where: SearchRecordListWhereInput
|
|
69
|
-
search: String
|
|
70
|
-
limit: Int
|
|
71
|
-
after: String
|
|
72
|
-
sort: [AcoListSort]
|
|
73
|
-
): SearchRecordListResponse
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
extend type SearchMutation {
|
|
77
|
-
createRecord(data: SearchRecordCreateInput!): SearchRecordResponse
|
|
78
|
-
updateRecord(id: ID!, data: SearchRecordUpdateInput!): SearchRecordResponse
|
|
79
|
-
deleteRecord(id: ID!): AcoBooleanResponse
|
|
80
|
-
}
|
|
81
|
-
`,
|
|
82
|
-
resolvers: {
|
|
83
|
-
SearchQuery: {
|
|
84
|
-
getRecord: async (_, {
|
|
85
|
-
id
|
|
86
|
-
}, context) => {
|
|
87
|
-
return (0, _resolve.resolve)(() => context.aco.search.get(id));
|
|
88
|
-
},
|
|
89
|
-
listRecords: async (_, args, context) => {
|
|
90
|
-
try {
|
|
91
|
-
const [entries, meta] = await context.aco.search.list(args);
|
|
92
|
-
return new _responses.ListResponse(entries, meta);
|
|
93
|
-
} catch (e) {
|
|
94
|
-
return new _responses.ErrorResponse(e);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
SearchMutation: {
|
|
99
|
-
createRecord: async (_, {
|
|
100
|
-
data
|
|
101
|
-
}, context) => {
|
|
102
|
-
return (0, _resolve.resolve)(() => context.aco.search.create(data));
|
|
103
|
-
},
|
|
104
|
-
updateRecord: async (_, {
|
|
105
|
-
id,
|
|
106
|
-
data
|
|
107
|
-
}, context) => {
|
|
108
|
-
return (0, _resolve.resolve)(() => context.aco.search.update(id, data));
|
|
109
|
-
},
|
|
110
|
-
deleteRecord: async (_, {
|
|
111
|
-
id
|
|
112
|
-
}, context) => {
|
|
113
|
-
return (0, _resolve.resolve)(() => context.aco.search.delete(id));
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
exports.searchRecordSchema = searchRecordSchema;
|
|
6
|
+
exports.createSchema = void 0;
|
|
7
|
+
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
8
|
+
var _createAppSchema = require("./graphql/createAppSchema");
|
|
9
|
+
var _createAppResolvers = require("./graphql/createAppResolvers");
|
|
10
|
+
const createSchema = async params => {
|
|
11
|
+
const {
|
|
12
|
+
context,
|
|
13
|
+
app
|
|
14
|
+
} = params;
|
|
15
|
+
const plugins = context.plugins.byType("cms-model-field-to-graphql").reduce((fields, plugin) => {
|
|
16
|
+
fields[plugin.fieldType] = plugin;
|
|
17
|
+
return fields;
|
|
18
|
+
}, {});
|
|
19
|
+
const models = await context.security.withoutAuthorization(async () => {
|
|
20
|
+
return (await context.cms.listModels()).filter(model => {
|
|
21
|
+
return !model.isPrivate;
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
return context.benchmark.measure(`aco.schema.generate.${app.name}`, async () => {
|
|
25
|
+
const plugin = new _handlerGraphql.GraphQLSchemaPlugin({
|
|
26
|
+
typeDefs: (0, _createAppSchema.createAppSchema)({
|
|
27
|
+
models,
|
|
28
|
+
app,
|
|
29
|
+
plugins
|
|
30
|
+
}),
|
|
31
|
+
resolvers: (0, _createAppResolvers.createAppResolvers)({
|
|
32
|
+
models,
|
|
33
|
+
app,
|
|
34
|
+
plugins
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
plugin.name = `aco.graphql.appSchema.searchRecord.${app.name}`;
|
|
38
|
+
return plugin;
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
exports.createSchema = createSchema;
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=record.gql.js.map
|
package/record/record.gql.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_handlerGraphql","require","_createAppSchema","_createAppResolvers","createSchema","params","context","app","plugins","byType","reduce","fields","plugin","fieldType","models","security","withoutAuthorization","cms","listModels","filter","model","isPrivate","benchmark","measure","name","GraphQLSchemaPlugin","typeDefs","createAppSchema","resolvers","createAppResolvers","exports"],"sources":["record.gql.ts"],"sourcesContent":["import { AcoContext, IAcoApp } from \"~/types\";\nimport { CmsFieldTypePlugins, CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { createAppSchema } from \"./graphql/createAppSchema\";\nimport { createAppResolvers } from \"./graphql/createAppResolvers\";\n\ninterface Params {\n context: AcoContext;\n app: IAcoApp;\n}\n\nexport const createSchema = async (params: Params) => {\n const { context, app } = params;\n const plugins = context.plugins\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce<CmsFieldTypePlugins>((fields, plugin) => {\n fields[plugin.fieldType] = plugin;\n return fields;\n }, {});\n const models = await context.security.withoutAuthorization(async () => {\n return (await context.cms.listModels()).filter(model => {\n return !model.isPrivate;\n });\n });\n\n return context.benchmark.measure(`aco.schema.generate.${app.name}`, async () => {\n const plugin = new GraphQLSchemaPlugin({\n typeDefs: createAppSchema({\n models,\n app,\n plugins\n }),\n resolvers: createAppResolvers({\n models,\n app,\n plugins\n })\n });\n plugin.name = `aco.graphql.appSchema.searchRecord.${app.name}`;\n return plugin;\n });\n};\n"],"mappings":";;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AAOO,MAAMG,YAAY,GAAG,MAAOC,MAAc,IAAK;EAClD,MAAM;IAAEC,OAAO;IAAEC;EAAI,CAAC,GAAGF,MAAM;EAC/B,MAAMG,OAAO,GAAGF,OAAO,CAACE,OAAO,CAC1BC,MAAM,CAA+B,4BAA4B,CAAC,CAClEC,MAAM,CAAsB,CAACC,MAAM,EAAEC,MAAM,KAAK;IAC7CD,MAAM,CAACC,MAAM,CAACC,SAAS,CAAC,GAAGD,MAAM;IACjC,OAAOD,MAAM;EACjB,CAAC,EAAE,CAAC,CAAC,CAAC;EACV,MAAMG,MAAM,GAAG,MAAMR,OAAO,CAACS,QAAQ,CAACC,oBAAoB,CAAC,YAAY;IACnE,OAAO,CAAC,MAAMV,OAAO,CAACW,GAAG,CAACC,UAAU,CAAC,CAAC,EAAEC,MAAM,CAACC,KAAK,IAAI;MACpD,OAAO,CAACA,KAAK,CAACC,SAAS;IAC3B,CAAC,CAAC;EACN,CAAC,CAAC;EAEF,OAAOf,OAAO,CAACgB,SAAS,CAACC,OAAO,CAAE,uBAAsBhB,GAAG,CAACiB,IAAK,EAAC,EAAE,YAAY;IAC5E,MAAMZ,MAAM,GAAG,IAAIa,mCAAmB,CAAC;MACnCC,QAAQ,EAAE,IAAAC,gCAAe,EAAC;QACtBb,MAAM;QACNP,GAAG;QACHC;MACJ,CAAC,CAAC;MACFoB,SAAS,EAAE,IAAAC,sCAAkB,EAAC;QAC1Bf,MAAM;QACNP,GAAG;QACHC;MACJ,CAAC;IACL,CAAC,CAAC;IACFI,MAAM,CAACY,IAAI,GAAI,sCAAqCjB,GAAG,CAACiB,IAAK,EAAC;IAC9D,OAAOZ,MAAM;EACjB,CAAC,CAAC;AACN,CAAC;AAACkB,OAAA,CAAA1B,YAAA,GAAAA,YAAA"}
|
package/record/record.model.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { CmsModelField } from "@webiny/api-headless-cms/types";
|
|
2
|
+
export declare const SEARCH_RECORD_MODEL_ID = "acoSearchRecord";
|
|
3
|
+
interface CreateSearchModelDefinitionParams {
|
|
4
|
+
fields?: CmsModelField[];
|
|
5
|
+
}
|
|
6
|
+
export declare const DEFAULT_FIELDS: string[];
|
|
7
|
+
export declare const createSearchModelDefinition: (params?: CreateSearchModelDefinitionParams) => import("@webiny/api-headless-cms").CmsPrivateModelFull;
|
|
8
|
+
export {};
|
package/record/record.model.js
CHANGED
|
@@ -3,24 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.createSearchModelDefinition = exports.SEARCH_RECORD_MODEL_ID = void 0;
|
|
6
|
+
exports.createSearchModelDefinition = exports.SEARCH_RECORD_MODEL_ID = exports.DEFAULT_FIELDS = void 0;
|
|
7
7
|
var _createModelField = require("../utils/createModelField");
|
|
8
|
-
|
|
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
|
-
});
|
|
8
|
+
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
20
9
|
const typeField = () => (0, _createModelField.createModelField)({
|
|
21
10
|
label: "Type",
|
|
22
11
|
type: "text",
|
|
23
|
-
parent: "searchRecord",
|
|
24
12
|
validation: [{
|
|
25
13
|
name: "required",
|
|
26
14
|
message: "Value is required."
|
|
@@ -29,18 +17,23 @@ const typeField = () => (0, _createModelField.createModelField)({
|
|
|
29
17
|
const titleField = () => (0, _createModelField.createModelField)({
|
|
30
18
|
label: "Title",
|
|
31
19
|
type: "text",
|
|
32
|
-
|
|
20
|
+
validation: [{
|
|
21
|
+
name: "required",
|
|
22
|
+
message: "Value is required."
|
|
23
|
+
}]
|
|
33
24
|
});
|
|
34
25
|
const contentField = () => (0, _createModelField.createModelField)({
|
|
35
26
|
label: "Content",
|
|
36
|
-
type: "text"
|
|
37
|
-
parent: "searchRecord"
|
|
27
|
+
type: "text"
|
|
38
28
|
});
|
|
39
29
|
const locationField = fields => (0, _createModelField.createModelField)({
|
|
40
30
|
label: "Location",
|
|
41
31
|
type: "object",
|
|
42
|
-
parent: "searchRecord",
|
|
43
32
|
multipleValues: false,
|
|
33
|
+
validation: [{
|
|
34
|
+
name: "required",
|
|
35
|
+
message: "The location field must be populated."
|
|
36
|
+
}],
|
|
44
37
|
settings: {
|
|
45
38
|
fields
|
|
46
39
|
}
|
|
@@ -48,28 +41,46 @@ const locationField = fields => (0, _createModelField.createModelField)({
|
|
|
48
41
|
const locationFolderIdField = () => (0, _createModelField.createModelField)({
|
|
49
42
|
label: "Folder Id",
|
|
50
43
|
type: "text",
|
|
51
|
-
parent: "searchRecord Location",
|
|
52
44
|
validation: [{
|
|
53
45
|
name: "required",
|
|
54
46
|
message: "Value is required."
|
|
55
47
|
}]
|
|
56
48
|
});
|
|
57
|
-
const dataField =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
49
|
+
const dataField = fields => {
|
|
50
|
+
return (0, _createModelField.createModelField)({
|
|
51
|
+
label: "Data",
|
|
52
|
+
type: "object",
|
|
53
|
+
multipleValues: false,
|
|
54
|
+
validation: [{
|
|
55
|
+
name: "required",
|
|
56
|
+
message: "The data field must be populated."
|
|
57
|
+
}],
|
|
58
|
+
settings: {
|
|
59
|
+
fields
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
const tagsField = () => (0, _createModelField.createModelField)({
|
|
64
|
+
label: "Tags",
|
|
65
|
+
type: "text",
|
|
66
|
+
multipleValues: true,
|
|
67
|
+
validation: [{
|
|
68
|
+
name: "required",
|
|
69
|
+
message: "The tags field must be populated."
|
|
70
|
+
}]
|
|
61
71
|
});
|
|
62
|
-
const SEARCH_RECORD_MODEL_ID = "
|
|
72
|
+
const SEARCH_RECORD_MODEL_ID = "acoSearchRecord";
|
|
63
73
|
exports.SEARCH_RECORD_MODEL_ID = SEARCH_RECORD_MODEL_ID;
|
|
64
|
-
const
|
|
65
|
-
|
|
74
|
+
const DEFAULT_FIELDS = ["type", "title", "content", "location", "data", "tags"];
|
|
75
|
+
exports.DEFAULT_FIELDS = DEFAULT_FIELDS;
|
|
76
|
+
const createSearchModelDefinition = params => {
|
|
77
|
+
return (0, _apiHeadlessCms.createPrivateModelDefinition)({
|
|
66
78
|
name: "ACO - Search Record",
|
|
67
79
|
modelId: SEARCH_RECORD_MODEL_ID,
|
|
68
|
-
titleFieldId: "
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
description: "ACO - Search record model",
|
|
72
|
-
isPrivate: true
|
|
73
|
-
};
|
|
80
|
+
titleFieldId: "title",
|
|
81
|
+
fields: [typeField(), titleField(), contentField(), locationField([locationFolderIdField()]), dataField(params?.fields), tagsField()]
|
|
82
|
+
});
|
|
74
83
|
};
|
|
75
|
-
exports.createSearchModelDefinition = createSearchModelDefinition;
|
|
84
|
+
exports.createSearchModelDefinition = createSearchModelDefinition;
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=record.model.js.map
|