@webiny/api-headless-cms 5.35.2 → 5.36.0-beta.1
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/crud/contentEntry.crud.d.ts +4 -4
- package/crud/contentEntry.crud.js +73 -14
- package/crud/contentEntry.crud.js.map +1 -1
- package/crud/contentModel/validation.d.ts +87 -87
- package/crud/contentModelGroup/validation.d.ts +4 -4
- package/crud/contentModelGroup.crud.js +1 -7
- package/crud/contentModelGroup.crud.js.map +1 -1
- package/graphql/index.d.ts +1 -1
- package/graphql/schema/createFieldResolvers.d.ts +1 -1
- package/graphql/schema/createFieldResolvers.js +4 -11
- package/graphql/schema/createFieldResolvers.js.map +1 -1
- package/graphql/schema/createFieldTypePluginRecords.d.ts +3 -0
- package/graphql/schema/createFieldTypePluginRecords.js +13 -0
- package/graphql/schema/createFieldTypePluginRecords.js.map +1 -0
- package/graphql/schema/createManageSDL.js +30 -24
- package/graphql/schema/createManageSDL.js.map +1 -1
- package/graphql/schema/createReadSDL.js +22 -19
- package/graphql/schema/createReadSDL.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.d.ts +4 -0
- package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js +18 -0
- package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js.map +1 -0
- package/graphql/schema/schemaPlugins.js +2 -4
- package/graphql/schema/schemaPlugins.js.map +1 -1
- package/graphqlFields/object.js.map +1 -1
- package/index.d.ts +1 -1
- package/package.json +22 -23
- package/types.d.ts +27 -22
- package/types.js +4 -0
- package/types.js.map +1 -1
- package/utils/converters/valueKeyStorageConverter.js +5 -2
- package/utils/converters/valueKeyStorageConverter.js.map +1 -1
- package/utils/getBaseFieldType.d.ts +1 -3
- package/utils/getBaseFieldType.js.map +1 -1
- package/utils/getEntryDescription.d.ts +1 -1
- package/utils/getEntryDescription.js.map +1 -1
- package/utils/getEntryImage.d.ts +1 -1
- package/utils/getEntryImage.js.map +1 -1
- package/utils/getEntryTitle.d.ts +1 -1
- package/utils/getEntryTitle.js.map +1 -1
- package/utils/renderFields.d.ts +2 -1
- package/utils/renderFields.js +2 -1
- package/utils/renderFields.js.map +1 -1
- package/utils/renderGetFilterFields.d.ts +2 -2
- package/utils/renderGetFilterFields.js +7 -20
- package/utils/renderGetFilterFields.js.map +1 -1
- package/utils/renderInputFields.d.ts +2 -1
- package/utils/renderInputFields.js +14 -6
- package/utils/renderInputFields.js.map +1 -1
- package/utils/renderListFilterFields.d.ts +2 -1
- package/utils/renderListFilterFields.js +9 -20
- package/utils/renderListFilterFields.js.map +1 -1
- package/utils/renderSortEnum.d.ts +2 -1
- package/utils/renderSortEnum.js +2 -1
- package/utils/renderSortEnum.js.map +1 -1
|
@@ -5,41 +5,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.renderGetFilterFields = void 0;
|
|
7
7
|
var _getBaseFieldType = require("./getBaseFieldType");
|
|
8
|
-
const getCreateFilters = (plugins, fieldType) => {
|
|
9
|
-
if (!plugins[fieldType] || !plugins[fieldType].read.createGetFilters) {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
return plugins[fieldType].read.createGetFilters;
|
|
13
|
-
};
|
|
14
8
|
const renderGetFilterFields = ({
|
|
15
|
-
|
|
9
|
+
fields,
|
|
16
10
|
fieldTypePlugins
|
|
17
11
|
}) => {
|
|
18
|
-
const
|
|
12
|
+
const filters = ["id: ID", "entryId: String"];
|
|
13
|
+
for (const field of fields) {
|
|
14
|
+
var _plugin$read;
|
|
19
15
|
// Every time a client updates content model's fields, we check the type of each field. If a field plugin
|
|
20
16
|
// for a particular "field.type" doesn't exist on the backend yet, we throw an error. But still, we also
|
|
21
17
|
// want to be careful when accessing the field plugin here too. It is still possible to have a content model
|
|
22
18
|
// that contains a field, for which we don't have a plugin registered on the backend. For example, user
|
|
23
19
|
// could've just removed the plugin from the backend.
|
|
24
20
|
const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
return fieldTypePlugins[baseType].isSearchable;
|
|
29
|
-
}).map(f => f.fieldId);
|
|
30
|
-
const filters = ["id: ID", "entryId: String"];
|
|
31
|
-
for (const fieldId of fieldIdList) {
|
|
32
|
-
const field = model.fields.find(item => item.fieldId === fieldId);
|
|
33
|
-
if (!field) {
|
|
21
|
+
const plugin = fieldTypePlugins[baseType];
|
|
22
|
+
if (!(plugin !== null && plugin !== void 0 && plugin.isSearchable)) {
|
|
34
23
|
continue;
|
|
35
24
|
}
|
|
36
|
-
const
|
|
37
|
-
const createGetFilters = getCreateFilters(fieldTypePlugins, baseType);
|
|
25
|
+
const createGetFilters = (_plugin$read = plugin.read) === null || _plugin$read === void 0 ? void 0 : _plugin$read.createGetFilters;
|
|
38
26
|
if (typeof createGetFilters !== "function") {
|
|
39
27
|
continue;
|
|
40
28
|
}
|
|
41
29
|
filters.push(createGetFilters({
|
|
42
|
-
model,
|
|
43
30
|
field
|
|
44
31
|
}));
|
|
45
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["renderGetFilterFields","fields","fieldTypePlugins","filters","field","baseType","getBaseFieldType","plugin","isSearchable","createGetFilters","read","push","filter","Boolean","join"],"sources":["renderGetFilterFields.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderGetFilterFieldsParams {\n fields: CmsModelField[];\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface RenderGetFilterFields {\n (params: RenderGetFilterFieldsParams): string;\n}\n\nexport const renderGetFilterFields: RenderGetFilterFields = ({ fields, fieldTypePlugins }) => {\n const filters: string[] = [\"id: ID\", \"entryId: String\"];\n\n for (const field of fields) {\n // Every time a client updates content model's fields, we check the type of each field. If a field plugin\n // for a particular \"field.type\" doesn't exist on the backend yet, we throw an error. But still, we also\n // want to be careful when accessing the field plugin here too. It is still possible to have a content model\n // that contains a field, for which we don't have a plugin registered on the backend. For example, user\n // could've just removed the plugin from the backend.\n const baseType = getBaseFieldType(field);\n const plugin = fieldTypePlugins[baseType];\n if (!plugin?.isSearchable) {\n continue;\n }\n const createGetFilters = plugin.read?.createGetFilters;\n if (typeof createGetFilters !== \"function\") {\n continue;\n }\n filters.push(createGetFilters({ field }));\n }\n\n return filters.filter(Boolean).join(\"\\n\");\n};\n"],"mappings":";;;;;;AACA;AAUO,MAAMA,qBAA4C,GAAG,CAAC;EAAEC,MAAM;EAAEC;AAAiB,CAAC,KAAK;EAC1F,MAAMC,OAAiB,GAAG,CAAC,QAAQ,EAAE,iBAAiB,CAAC;EAEvD,KAAK,MAAMC,KAAK,IAAIH,MAAM,EAAE;IAAA;IACxB;IACA;IACA;IACA;IACA;IACA,MAAMI,QAAQ,GAAG,IAAAC,kCAAgB,EAACF,KAAK,CAAC;IACxC,MAAMG,MAAM,GAAGL,gBAAgB,CAACG,QAAQ,CAAC;IACzC,IAAI,EAACE,MAAM,aAANA,MAAM,eAANA,MAAM,CAAEC,YAAY,GAAE;MACvB;IACJ;IACA,MAAMC,gBAAgB,mBAAGF,MAAM,CAACG,IAAI,iDAAX,aAAaD,gBAAgB;IACtD,IAAI,OAAOA,gBAAgB,KAAK,UAAU,EAAE;MACxC;IACJ;IACAN,OAAO,CAACQ,IAAI,CAACF,gBAAgB,CAAC;MAAEL;IAAM,CAAC,CAAC,CAAC;EAC7C;EAEA,OAAOD,OAAO,CAACS,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AAC7C,CAAC;AAAC"}
|
|
@@ -2,9 +2,10 @@ import { CmsFieldTypePlugins, CmsModel, CmsModelField, CmsModelFieldDefinition }
|
|
|
2
2
|
interface RenderInputFieldsParams {
|
|
3
3
|
models: CmsModel[];
|
|
4
4
|
model: CmsModel;
|
|
5
|
+
fields: CmsModelField[];
|
|
5
6
|
fieldTypePlugins: CmsFieldTypePlugins;
|
|
6
7
|
}
|
|
7
|
-
interface RenderInputFieldParams extends RenderInputFieldsParams {
|
|
8
|
+
interface RenderInputFieldParams extends Omit<RenderInputFieldsParams, "fields"> {
|
|
8
9
|
field: CmsModelField;
|
|
9
10
|
}
|
|
10
11
|
interface RenderInputFields {
|
|
@@ -8,14 +8,22 @@ var _getBaseFieldType = require("./getBaseFieldType");
|
|
|
8
8
|
const renderInputFields = ({
|
|
9
9
|
models,
|
|
10
10
|
model,
|
|
11
|
+
fields,
|
|
11
12
|
fieldTypePlugins
|
|
12
13
|
}) => {
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
return fields.reduce((result, field) => {
|
|
15
|
+
const input = renderInputField({
|
|
16
|
+
models,
|
|
17
|
+
model,
|
|
18
|
+
field,
|
|
19
|
+
fieldTypePlugins
|
|
20
|
+
});
|
|
21
|
+
if (!input) {
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
result.push(input);
|
|
25
|
+
return result;
|
|
26
|
+
}, []);
|
|
19
27
|
};
|
|
20
28
|
exports.renderInputFields = renderInputFields;
|
|
21
29
|
const renderInputField = ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["renderInputFields","models","model","fieldTypePlugins","
|
|
1
|
+
{"version":3,"names":["renderInputFields","models","model","fields","fieldTypePlugins","reduce","result","field","input","renderInputField","push","plugin","getBaseFieldType","def","manage","createInputField"],"sources":["renderInputFields.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModel, CmsModelField, CmsModelFieldDefinition } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderInputFieldsParams {\n models: CmsModel[];\n model: CmsModel;\n fields: CmsModelField[];\n fieldTypePlugins: CmsFieldTypePlugins;\n}\n\ninterface RenderInputFieldParams extends Omit<RenderInputFieldsParams, \"fields\"> {\n field: CmsModelField;\n}\n\ninterface RenderInputFields {\n (params: RenderInputFieldsParams): CmsModelFieldDefinition[];\n}\n\nexport const renderInputFields: RenderInputFields = ({\n models,\n model,\n fields,\n fieldTypePlugins\n}): CmsModelFieldDefinition[] => {\n return fields.reduce<CmsModelFieldDefinition[]>((result, field) => {\n const input = renderInputField({ models, model, field, fieldTypePlugins });\n if (!input) {\n return result;\n }\n result.push(input);\n return result;\n }, []);\n};\n\nexport const renderInputField = ({\n models,\n model,\n field,\n fieldTypePlugins\n}: RenderInputFieldParams): CmsModelFieldDefinition | null => {\n // Every time a client updates content model's fields, we check the type of each field. If a field plugin\n // for a particular \"field.type\" doesn't exist on the backend yet, we throw an error. But still, we also\n // want to be careful when accessing the field plugin here too. It is still possible to have a content model\n // that contains a field, for which we don't have a plugin registered on the backend. For example, user\n // could've just removed the plugin from the backend.\n const plugin = fieldTypePlugins[getBaseFieldType(field)];\n\n if (!plugin) {\n // Let's not render the field if it does not exist in the field plugins.\n return null;\n }\n\n const def = plugin.manage.createInputField({\n models,\n model,\n field,\n fieldTypePlugins\n });\n if (typeof def === \"string\") {\n return {\n fields: def\n };\n }\n\n return def;\n};\n"],"mappings":";;;;;;AACA;AAiBO,MAAMA,iBAAoC,GAAG,CAAC;EACjDC,MAAM;EACNC,KAAK;EACLC,MAAM;EACNC;AACJ,CAAC,KAAgC;EAC7B,OAAOD,MAAM,CAACE,MAAM,CAA4B,CAACC,MAAM,EAAEC,KAAK,KAAK;IAC/D,MAAMC,KAAK,GAAGC,gBAAgB,CAAC;MAAER,MAAM;MAAEC,KAAK;MAAEK,KAAK;MAAEH;IAAiB,CAAC,CAAC;IAC1E,IAAI,CAACI,KAAK,EAAE;MACR,OAAOF,MAAM;IACjB;IACAA,MAAM,CAACI,IAAI,CAACF,KAAK,CAAC;IAClB,OAAOF,MAAM;EACjB,CAAC,EAAE,EAAE,CAAC;AACV,CAAC;AAAC;AAEK,MAAMG,gBAAgB,GAAG,CAAC;EAC7BR,MAAM;EACNC,KAAK;EACLK,KAAK;EACLH;AACoB,CAAC,KAAqC;EAC1D;EACA;EACA;EACA;EACA;EACA,MAAMO,MAAM,GAAGP,gBAAgB,CAAC,IAAAQ,kCAAgB,EAACL,KAAK,CAAC,CAAC;EAExD,IAAI,CAACI,MAAM,EAAE;IACT;IACA,OAAO,IAAI;EACf;EAEA,MAAME,GAAG,GAAGF,MAAM,CAACG,MAAM,CAACC,gBAAgB,CAAC;IACvCd,MAAM;IACNC,KAAK;IACLK,KAAK;IACLH;EACJ,CAAC,CAAC;EACF,IAAI,OAAOS,GAAG,KAAK,QAAQ,EAAE;IACzB,OAAO;MACHV,MAAM,EAAEU;IACZ,CAAC;EACL;EAEA,OAAOA,GAAG;AACd,CAAC;AAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ApiEndpoint, CmsFieldTypePlugins, CmsModel } from "../types";
|
|
1
|
+
import { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelField } from "../types";
|
|
2
2
|
interface RenderListFilterFieldsParams {
|
|
3
3
|
model: CmsModel;
|
|
4
|
+
fields: CmsModelField[];
|
|
4
5
|
type: ApiEndpoint;
|
|
5
6
|
fieldTypePlugins: CmsFieldTypePlugins;
|
|
6
7
|
}
|
|
@@ -5,49 +5,38 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.renderListFilterFields = void 0;
|
|
7
7
|
var _getBaseFieldType = require("./getBaseFieldType");
|
|
8
|
-
/**
|
|
9
|
-
* We cast as read type, because input and output of read and manage are same. This way we ease things.
|
|
10
|
-
* Internal stuff so it should be ok.
|
|
11
|
-
* TODO note that if changing read/manage types, change this as well.
|
|
12
|
-
*/
|
|
13
|
-
const getCreateListFilters = (plugins, fieldType, type) => {
|
|
14
|
-
if (!plugins[fieldType]) {
|
|
15
|
-
return null;
|
|
16
|
-
} else if (!plugins[fieldType][type]) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
return plugins[fieldType][type].createListFilters;
|
|
20
|
-
};
|
|
21
8
|
const renderListFilterFields = params => {
|
|
22
9
|
const {
|
|
23
10
|
model,
|
|
11
|
+
fields,
|
|
24
12
|
type,
|
|
25
13
|
fieldTypePlugins
|
|
26
14
|
} = params;
|
|
27
|
-
const
|
|
15
|
+
const result = [["id: ID", "id_not: ID", "id_in: [ID!]", "id_not_in: [ID!]", "entryId: String", "entryId_not: String", "entryId_in: [String!]", "entryId_not_in: [String!]", "createdOn: DateTime", "createdOn_gt: DateTime", "createdOn_gte: DateTime", "createdOn_lt: DateTime", "createdOn_lte: DateTime", "createdOn_between: [DateTime!]", "createdOn_not_between: [DateTime!]", "savedOn: DateTime", "savedOn_gt: DateTime", "savedOn_gte: DateTime", "savedOn_lt: DateTime", "savedOn_lte: DateTime", "savedOn_between: [DateTime!]", "savedOn_not_between: [DateTime!]", "createdBy: String", "createdBy_not: String", "createdBy_in: [String!]", "createdBy_not_in: [String!]", "ownedBy: String", "ownedBy_not: String", "ownedBy_in: [String!]", "ownedBy_not_in: [String!]"].join("\n")];
|
|
28
16
|
/**
|
|
29
17
|
* We can find different statuses only in the manage API endpoint.
|
|
30
18
|
*/
|
|
31
19
|
if (type === "manage") {
|
|
32
|
-
|
|
20
|
+
result.push("status: String", "status_not: String", "status_in: [String!]", "status_not_in: [String!]");
|
|
33
21
|
}
|
|
34
|
-
for (const field of
|
|
22
|
+
for (const field of fields) {
|
|
23
|
+
var _fieldTypePlugins$bas, _fieldTypePlugins$bas2;
|
|
35
24
|
// Every time a client updates content model's fields, we check the type of each field. If a field plugin
|
|
36
25
|
// for a particular "field.type" doesn't exist on the backend yet, we throw an error. But still, we also
|
|
37
26
|
// want to be careful when accessing the field plugin here too. It is still possible to have a content model
|
|
38
27
|
// that contains a field, for which we don't have a plugin registered on the backend. For example, user
|
|
39
28
|
// could've just removed the plugin from the backend.
|
|
40
|
-
|
|
41
|
-
const createListFilters =
|
|
29
|
+
const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
|
|
30
|
+
const createListFilters = (_fieldTypePlugins$bas = fieldTypePlugins[baseType]) === null || _fieldTypePlugins$bas === void 0 ? void 0 : (_fieldTypePlugins$bas2 = _fieldTypePlugins$bas[type]) === null || _fieldTypePlugins$bas2 === void 0 ? void 0 : _fieldTypePlugins$bas2.createListFilters;
|
|
42
31
|
if (typeof createListFilters !== "function") {
|
|
43
32
|
continue;
|
|
44
33
|
}
|
|
45
|
-
|
|
34
|
+
result.push(createListFilters({
|
|
46
35
|
model,
|
|
47
36
|
field,
|
|
48
37
|
plugins: fieldTypePlugins
|
|
49
38
|
}));
|
|
50
39
|
}
|
|
51
|
-
return
|
|
40
|
+
return result.filter(Boolean).join("\n");
|
|
52
41
|
};
|
|
53
42
|
exports.renderListFilterFields = renderListFilterFields;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["renderListFilterFields","params","model","fields","type","fieldTypePlugins","result","join","push","field","baseType","getBaseFieldType","createListFilters","plugins","filter","Boolean"],"sources":["renderListFilterFields.ts"],"sourcesContent":["import {\n ApiEndpoint,\n CmsFieldTypePlugins,\n CmsModel,\n CmsModelField,\n CmsModelFieldToGraphQLPlugin\n} from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderListFilterFieldsParams {\n model: CmsModel;\n fields: CmsModelField[];\n type: ApiEndpoint;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface RenderListFilterFields {\n (params: RenderListFilterFieldsParams): string;\n}\n\ntype CreateListFiltersType =\n | CmsModelFieldToGraphQLPlugin[\"read\"][\"createListFilters\"]\n | CmsModelFieldToGraphQLPlugin[\"manage\"][\"createListFilters\"];\n\nexport const renderListFilterFields: RenderListFilterFields = (params): string => {\n const { model, fields, type, fieldTypePlugins } = params;\n const result: string[] = [\n [\n \"id: ID\",\n \"id_not: ID\",\n \"id_in: [ID!]\",\n \"id_not_in: [ID!]\",\n \"entryId: String\",\n \"entryId_not: String\",\n \"entryId_in: [String!]\",\n \"entryId_not_in: [String!]\",\n \"createdOn: DateTime\",\n \"createdOn_gt: DateTime\",\n \"createdOn_gte: DateTime\",\n \"createdOn_lt: DateTime\",\n \"createdOn_lte: DateTime\",\n \"createdOn_between: [DateTime!]\",\n \"createdOn_not_between: [DateTime!]\",\n \"savedOn: DateTime\",\n \"savedOn_gt: DateTime\",\n \"savedOn_gte: DateTime\",\n \"savedOn_lt: DateTime\",\n \"savedOn_lte: DateTime\",\n \"savedOn_between: [DateTime!]\",\n \"savedOn_not_between: [DateTime!]\",\n \"createdBy: String\",\n \"createdBy_not: String\",\n \"createdBy_in: [String!]\",\n \"createdBy_not_in: [String!]\",\n \"ownedBy: String\",\n \"ownedBy_not: String\",\n \"ownedBy_in: [String!]\",\n \"ownedBy_not_in: [String!]\"\n ].join(\"\\n\")\n ];\n /**\n * We can find different statuses only in the manage API endpoint.\n */\n if (type === \"manage\") {\n result.push(\n \"status: String\",\n \"status_not: String\",\n \"status_in: [String!]\",\n \"status_not_in: [String!]\"\n );\n }\n\n for (const field of fields) {\n // Every time a client updates content model's fields, we check the type of each field. If a field plugin\n // for a particular \"field.type\" doesn't exist on the backend yet, we throw an error. But still, we also\n // want to be careful when accessing the field plugin here too. It is still possible to have a content model\n // that contains a field, for which we don't have a plugin registered on the backend. For example, user\n // could've just removed the plugin from the backend.\n const baseType = getBaseFieldType(field);\n const createListFilters: CreateListFiltersType | undefined =\n fieldTypePlugins[baseType]?.[type]?.createListFilters;\n if (typeof createListFilters !== \"function\") {\n continue;\n }\n result.push(createListFilters({ model, field, plugins: fieldTypePlugins }));\n }\n\n return result.filter(Boolean).join(\"\\n\");\n};\n"],"mappings":";;;;;;AAOA;AAgBO,MAAMA,sBAA8C,GAAIC,MAAM,IAAa;EAC9E,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC,IAAI;IAAEC;EAAiB,CAAC,GAAGJ,MAAM;EACxD,MAAMK,MAAgB,GAAG,CACrB,CACI,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,2BAA2B,EAC3B,qBAAqB,EACrB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAChC,oCAAoC,EACpC,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,EAC9B,kCAAkC,EAClC,mBAAmB,EACnB,uBAAuB,EACvB,yBAAyB,EACzB,6BAA6B,EAC7B,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,2BAA2B,CAC9B,CAACC,IAAI,CAAC,IAAI,CAAC,CACf;EACD;AACJ;AACA;EACI,IAAIH,IAAI,KAAK,QAAQ,EAAE;IACnBE,MAAM,CAACE,IAAI,CACP,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,CAC7B;EACL;EAEA,KAAK,MAAMC,KAAK,IAAIN,MAAM,EAAE;IAAA;IACxB;IACA;IACA;IACA;IACA;IACA,MAAMO,QAAQ,GAAG,IAAAC,kCAAgB,EAACF,KAAK,CAAC;IACxC,MAAMG,iBAAoD,4BACtDP,gBAAgB,CAACK,QAAQ,CAAC,oFAA1B,sBAA6BN,IAAI,CAAC,2DAAlC,uBAAoCQ,iBAAiB;IACzD,IAAI,OAAOA,iBAAiB,KAAK,UAAU,EAAE;MACzC;IACJ;IACAN,MAAM,CAACE,IAAI,CAACI,iBAAiB,CAAC;MAAEV,KAAK;MAAEO,KAAK;MAAEI,OAAO,EAAER;IAAiB,CAAC,CAAC,CAAC;EAC/E;EAEA,OAAOC,MAAM,CAACQ,MAAM,CAACC,OAAO,CAAC,CAACR,IAAI,CAAC,IAAI,CAAC;AAC5C,CAAC;AAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { CmsFieldTypePlugins, CmsModel } from "../types";
|
|
1
|
+
import { CmsFieldTypePlugins, CmsModel, CmsModelField } from "../types";
|
|
2
2
|
import { CmsGraphQLSchemaSorterPlugin } from "../plugins/CmsGraphQLSchemaSorterPlugin";
|
|
3
3
|
interface RenderSortEnumParams {
|
|
4
4
|
model: CmsModel;
|
|
5
|
+
fields: CmsModelField[];
|
|
5
6
|
fieldTypePlugins: CmsFieldTypePlugins;
|
|
6
7
|
sorterPlugins: CmsGraphQLSchemaSorterPlugin[];
|
|
7
8
|
}
|
package/utils/renderSortEnum.js
CHANGED
|
@@ -7,11 +7,12 @@ exports.renderSortEnum = void 0;
|
|
|
7
7
|
var _getBaseFieldType = require("./getBaseFieldType");
|
|
8
8
|
const renderSortEnum = ({
|
|
9
9
|
model,
|
|
10
|
+
fields,
|
|
10
11
|
fieldTypePlugins,
|
|
11
12
|
sorterPlugins
|
|
12
13
|
}) => {
|
|
13
14
|
let sorters = [`id_ASC`, `id_DESC`, "savedOn_ASC", "savedOn_DESC", "createdOn_ASC", "createdOn_DESC"];
|
|
14
|
-
for (const field of
|
|
15
|
+
for (const field of fields) {
|
|
15
16
|
const plugin = fieldTypePlugins[(0, _getBaseFieldType.getBaseFieldType)(field)];
|
|
16
17
|
if (!plugin) {
|
|
17
18
|
continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["renderSortEnum","model","fieldTypePlugins","sorterPlugins","sorters","field","
|
|
1
|
+
{"version":3,"names":["renderSortEnum","model","fields","fieldTypePlugins","sorterPlugins","sorters","field","plugin","getBaseFieldType","createSorters","result","isSortable","push","fieldId","reduce","createSorter","join"],"sources":["renderSortEnum.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModel, CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\nimport { CmsGraphQLSchemaSorterPlugin } from \"~/plugins/CmsGraphQLSchemaSorterPlugin\";\n\ninterface RenderSortEnumParams {\n model: CmsModel;\n fields: CmsModelField[];\n fieldTypePlugins: CmsFieldTypePlugins;\n sorterPlugins: CmsGraphQLSchemaSorterPlugin[];\n}\ninterface RenderSortEnum {\n (params: RenderSortEnumParams): string;\n}\n\nexport const renderSortEnum: RenderSortEnum = ({\n model,\n fields,\n fieldTypePlugins,\n sorterPlugins\n}): string => {\n let sorters: string[] = [\n `id_ASC`,\n `id_DESC`,\n \"savedOn_ASC\",\n \"savedOn_DESC\",\n \"createdOn_ASC\",\n \"createdOn_DESC\"\n ];\n\n for (const field of fields) {\n const plugin = fieldTypePlugins[getBaseFieldType(field)];\n if (!plugin) {\n continue;\n } else if (plugin.createSorters) {\n const result = plugin.createSorters({\n model,\n field,\n sorters\n });\n if (result) {\n sorters = result;\n continue;\n }\n }\n if (!plugin.isSortable) {\n continue;\n }\n sorters.push(`${field.fieldId}_ASC`);\n sorters.push(`${field.fieldId}_DESC`);\n }\n\n return sorterPlugins\n .reduce((result, plugin) => {\n return plugin.createSorter({\n model,\n sorters: result\n });\n }, sorters)\n .join(\"\\n\");\n};\n"],"mappings":";;;;;;AACA;AAaO,MAAMA,cAA8B,GAAG,CAAC;EAC3CC,KAAK;EACLC,MAAM;EACNC,gBAAgB;EAChBC;AACJ,CAAC,KAAa;EACV,IAAIC,OAAiB,GAAG,CACnB,QAAO,EACP,SAAQ,EACT,aAAa,EACb,cAAc,EACd,eAAe,EACf,gBAAgB,CACnB;EAED,KAAK,MAAMC,KAAK,IAAIJ,MAAM,EAAE;IACxB,MAAMK,MAAM,GAAGJ,gBAAgB,CAAC,IAAAK,kCAAgB,EAACF,KAAK,CAAC,CAAC;IACxD,IAAI,CAACC,MAAM,EAAE;MACT;IACJ,CAAC,MAAM,IAAIA,MAAM,CAACE,aAAa,EAAE;MAC7B,MAAMC,MAAM,GAAGH,MAAM,CAACE,aAAa,CAAC;QAChCR,KAAK;QACLK,KAAK;QACLD;MACJ,CAAC,CAAC;MACF,IAAIK,MAAM,EAAE;QACRL,OAAO,GAAGK,MAAM;QAChB;MACJ;IACJ;IACA,IAAI,CAACH,MAAM,CAACI,UAAU,EAAE;MACpB;IACJ;IACAN,OAAO,CAACO,IAAI,CAAE,GAAEN,KAAK,CAACO,OAAQ,MAAK,CAAC;IACpCR,OAAO,CAACO,IAAI,CAAE,GAAEN,KAAK,CAACO,OAAQ,OAAM,CAAC;EACzC;EAEA,OAAOT,aAAa,CACfU,MAAM,CAAC,CAACJ,MAAM,EAAEH,MAAM,KAAK;IACxB,OAAOA,MAAM,CAACQ,YAAY,CAAC;MACvBd,KAAK;MACLI,OAAO,EAAEK;IACb,CAAC,CAAC;EACN,CAAC,EAAEL,OAAO,CAAC,CACVW,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC;AAAC"}
|