@webiny/api-headless-cms-ddb-es 0.0.0-unstable.e53eceafb5 → 0.0.0-unstable.eb196ccd2f
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/elasticsearch/search/index.js +2 -1
- package/elasticsearch/search/index.js.map +1 -1
- package/elasticsearch/search/searchableJson.d.ts +2 -0
- package/elasticsearch/search/searchableJson.js +60 -0
- package/elasticsearch/search/searchableJson.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.js +1 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/path.d.ts +1 -0
- package/operations/entry/elasticsearch/filtering/path.js +4 -2
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
- package/operations/entry/elasticsearch/sort.js +4 -2
- package/operations/entry/elasticsearch/sort.js.map +1 -1
- package/package.json +23 -23
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +1 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -1
- package/values/NoValueContainer.d.ts +5 -0
- package/values/NoValueContainer.js +20 -0
- package/values/NoValueContainer.js.map +1 -0
|
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _timeSearch = require("./timeSearch");
|
|
8
8
|
var _refSearch = require("./refSearch");
|
|
9
|
-
var
|
|
9
|
+
var _searchableJson = require("./searchableJson.js");
|
|
10
|
+
var _default = () => [(0, _timeSearch.createTimeSearchPlugin)(), (0, _refSearch.createRefSearchPlugin)(), (0, _searchableJson.createSearchableJsonSearchPlugin)()];
|
|
10
11
|
exports.default = _default;
|
|
11
12
|
|
|
12
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_timeSearch","require","_refSearch","_default","createTimeSearchPlugin","createRefSearchPlugin","exports","default"],"sources":["index.ts"],"sourcesContent":["import { createTimeSearchPlugin } from \"./timeSearch\";\nimport { createRefSearchPlugin } from \"./refSearch\";\nimport type { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from \"~/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin\";\n\nexport default (): CmsEntryElasticsearchQueryBuilderValueSearchPlugin[] => [\n createTimeSearchPlugin(),\n createRefSearchPlugin()\n];\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;
|
|
1
|
+
{"version":3,"names":["_timeSearch","require","_refSearch","_searchableJson","_default","createTimeSearchPlugin","createRefSearchPlugin","createSearchableJsonSearchPlugin","exports","default"],"sources":["index.ts"],"sourcesContent":["import { createTimeSearchPlugin } from \"./timeSearch\";\nimport { createRefSearchPlugin } from \"./refSearch\";\nimport { createSearchableJsonSearchPlugin } from \"./searchableJson.js\";\nimport type { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from \"~/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin\";\n\nexport default (): CmsEntryElasticsearchQueryBuilderValueSearchPlugin[] => [\n createTimeSearchPlugin(),\n createRefSearchPlugin(),\n createSearchableJsonSearchPlugin()\n];\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAAuE,IAAAG,QAAA,GAGxDA,CAAA,KAA4D,CACvE,IAAAC,kCAAsB,EAAC,CAAC,EACxB,IAAAC,gCAAqB,EAAC,CAAC,EACvB,IAAAC,gDAAgC,EAAC,CAAC,CACrC;AAAAC,OAAA,CAAAC,OAAA,GAAAL,QAAA","ignoreList":[]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createSearchableJsonSearchPlugin = void 0;
|
|
7
|
+
var _CmsEntryElasticsearchQueryBuilderValueSearchPlugin = require("../../plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin");
|
|
8
|
+
var _error = require("@webiny/error");
|
|
9
|
+
var _NoValueContainer = require("../../values/NoValueContainer.js");
|
|
10
|
+
const getKey = params => {
|
|
11
|
+
const {
|
|
12
|
+
field,
|
|
13
|
+
value
|
|
14
|
+
} = params;
|
|
15
|
+
const keys = Object.keys(value);
|
|
16
|
+
if (keys.length === 0) {
|
|
17
|
+
throw new _error.WebinyError(`Searchable JSON field "${field.fieldId}" cannot be empty.`, "EMPTY_SEARCHABLE_JSON_FIELD", {
|
|
18
|
+
field,
|
|
19
|
+
value
|
|
20
|
+
});
|
|
21
|
+
} else if (keys.length > 1) {
|
|
22
|
+
throw new _error.WebinyError(`Searchable JSON field "${field.fieldId}" can only have one key.`, "MULTIPLE_KEYS_IN_SEARCHABLE_JSON_FIELD", {
|
|
23
|
+
field,
|
|
24
|
+
value,
|
|
25
|
+
keys
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return keys[0];
|
|
29
|
+
};
|
|
30
|
+
const createSearchableJsonSearchPlugin = () => {
|
|
31
|
+
return new _CmsEntryElasticsearchQueryBuilderValueSearchPlugin.CmsEntryElasticsearchQueryBuilderValueSearchPlugin({
|
|
32
|
+
fieldType: "searchable-json",
|
|
33
|
+
transform: params => {
|
|
34
|
+
const {
|
|
35
|
+
value
|
|
36
|
+
} = params;
|
|
37
|
+
if (_NoValueContainer.NoValueContainer.is(value)) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const key = getKey(params);
|
|
41
|
+
return value[key] || null;
|
|
42
|
+
},
|
|
43
|
+
path: params => {
|
|
44
|
+
const {
|
|
45
|
+
field
|
|
46
|
+
} = params;
|
|
47
|
+
if (_NoValueContainer.NoValueContainer.is(params.originalValue)) {
|
|
48
|
+
return `${field.storageId}.unknown`;
|
|
49
|
+
}
|
|
50
|
+
const key = getKey({
|
|
51
|
+
field,
|
|
52
|
+
value: params.originalValue
|
|
53
|
+
});
|
|
54
|
+
return `${field.storageId}.${key}`;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
exports.createSearchableJsonSearchPlugin = createSearchableJsonSearchPlugin;
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=searchableJson.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_CmsEntryElasticsearchQueryBuilderValueSearchPlugin","require","_error","_NoValueContainer","getKey","params","field","value","keys","Object","length","WebinyError","fieldId","createSearchableJsonSearchPlugin","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","fieldType","transform","NoValueContainer","is","key","path","originalValue","storageId","exports"],"sources":["searchableJson.ts"],"sourcesContent":["import { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from \"~/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin\";\nimport { WebinyError } from \"@webiny/error\";\nimport type { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { NoValueContainer } from \"~/values/NoValueContainer.js\";\n\ninterface IGetKeyParams {\n field: CmsModelField;\n value: {\n [key: string]: any;\n };\n}\n\nconst getKey = (params: IGetKeyParams): string => {\n const { field, value } = params;\n const keys = Object.keys(value);\n if (keys.length === 0) {\n throw new WebinyError(\n `Searchable JSON field \"${field.fieldId}\" cannot be empty.`,\n \"EMPTY_SEARCHABLE_JSON_FIELD\",\n {\n field,\n value\n }\n );\n } else if (keys.length > 1) {\n throw new WebinyError(\n `Searchable JSON field \"${field.fieldId}\" can only have one key.`,\n \"MULTIPLE_KEYS_IN_SEARCHABLE_JSON_FIELD\",\n {\n field,\n value,\n keys\n }\n );\n }\n return keys[0];\n};\n\nexport const createSearchableJsonSearchPlugin =\n (): CmsEntryElasticsearchQueryBuilderValueSearchPlugin => {\n return new CmsEntryElasticsearchQueryBuilderValueSearchPlugin({\n fieldType: \"searchable-json\",\n transform: params => {\n const { value } = params;\n\n if (NoValueContainer.is(value)) {\n return null;\n }\n\n const key = getKey(params);\n return value[key] || null;\n },\n path: params => {\n const { field } = params;\n\n if (NoValueContainer.is(params.originalValue)) {\n return `${field.storageId}.unknown`;\n }\n\n const key = getKey({\n field,\n value: params.originalValue\n });\n\n return `${field.storageId}.${key}`;\n }\n });\n };\n"],"mappings":";;;;;;AAAA,IAAAA,mDAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,iBAAA,GAAAF,OAAA;AASA,MAAMG,MAAM,GAAIC,MAAqB,IAAa;EAC9C,MAAM;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAC/B,MAAMG,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACD,KAAK,CAAC;EAC/B,IAAIC,IAAI,CAACE,MAAM,KAAK,CAAC,EAAE;IACnB,MAAM,IAAIC,kBAAW,CACjB,0BAA0BL,KAAK,CAACM,OAAO,oBAAoB,EAC3D,6BAA6B,EAC7B;MACIN,KAAK;MACLC;IACJ,CACJ,CAAC;EACL,CAAC,MAAM,IAAIC,IAAI,CAACE,MAAM,GAAG,CAAC,EAAE;IACxB,MAAM,IAAIC,kBAAW,CACjB,0BAA0BL,KAAK,CAACM,OAAO,0BAA0B,EACjE,wCAAwC,EACxC;MACIN,KAAK;MACLC,KAAK;MACLC;IACJ,CACJ,CAAC;EACL;EACA,OAAOA,IAAI,CAAC,CAAC,CAAC;AAClB,CAAC;AAEM,MAAMK,gCAAgC,GACzCA,CAAA,KAA0D;EACtD,OAAO,IAAIC,sGAAkD,CAAC;IAC1DC,SAAS,EAAE,iBAAiB;IAC5BC,SAAS,EAAEX,MAAM,IAAI;MACjB,MAAM;QAAEE;MAAM,CAAC,GAAGF,MAAM;MAExB,IAAIY,kCAAgB,CAACC,EAAE,CAACX,KAAK,CAAC,EAAE;QAC5B,OAAO,IAAI;MACf;MAEA,MAAMY,GAAG,GAAGf,MAAM,CAACC,MAAM,CAAC;MAC1B,OAAOE,KAAK,CAACY,GAAG,CAAC,IAAI,IAAI;IAC7B,CAAC;IACDC,IAAI,EAAEf,MAAM,IAAI;MACZ,MAAM;QAAEC;MAAM,CAAC,GAAGD,MAAM;MAExB,IAAIY,kCAAgB,CAACC,EAAE,CAACb,MAAM,CAACgB,aAAa,CAAC,EAAE;QAC3C,OAAO,GAAGf,KAAK,CAACgB,SAAS,UAAU;MACvC;MAEA,MAAMH,GAAG,GAAGf,MAAM,CAAC;QACfE,KAAK;QACLC,KAAK,EAAEF,MAAM,CAACgB;MAClB,CAAC,CAAC;MAEF,OAAO,GAAGf,KAAK,CAACgB,SAAS,IAAIH,GAAG,EAAE;IACtC;EACJ,CAAC,CAAC;AACN,CAAC;AAACI,OAAA,CAAAV,gCAAA,GAAAA,gCAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_transformValueForSearch","_keyword","_path","createApplyFiltering","operatorPlugins","searchPlugins","createFieldPath","createFieldPathFactory","plugins","params","key","value","initialValue","query","operator","field","plugin","WebinyError","transformValueForSearch","keyword","hasKeyword","basePath","path","apply","name","fieldId","exports"],"sources":["applyFiltering.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { transformValueForSearch } from \"~/operations/entry/elasticsearch/transformValueForSearch\";\nimport { hasKeyword } from \"~/operations/entry/elasticsearch/keyword\";\nimport type {\n ElasticsearchQueryBuilderOperatorPlugins,\n ElasticsearchQuerySearchValuePlugins\n} from \"~/operations/entry/elasticsearch/types\";\nimport { createFieldPathFactory } from \"~/operations/entry/elasticsearch/filtering/path\";\nimport type { ApplyFilteringCb } from \"~/plugins/CmsEntryFilterPlugin\";\n\ninterface CreateParams {\n operatorPlugins: ElasticsearchQueryBuilderOperatorPlugins;\n searchPlugins: ElasticsearchQuerySearchValuePlugins;\n}\n\nexport const createApplyFiltering = ({\n operatorPlugins,\n searchPlugins\n}: CreateParams): ApplyFilteringCb => {\n const createFieldPath = createFieldPathFactory({\n plugins: searchPlugins\n });\n\n return params => {\n const { key, value: initialValue, query, operator, field } = params;\n\n const plugin = operatorPlugins[operator];\n if (!plugin) {\n throw new WebinyError(\n `Elasticsearch operator \"${operator}\" plugin missing.`,\n \"PLUGIN_MISSING\",\n {\n operator\n }\n );\n }\n\n const value = transformValueForSearch({\n plugins: searchPlugins,\n field: field.field,\n value: initialValue\n });\n\n const keyword = hasKeyword(field);\n\n const { basePath, path } = createFieldPath({\n field,\n value,\n key,\n keyword\n });\n\n plugin.apply(query, {\n name: field.field.fieldId,\n basePath,\n path,\n value,\n keyword\n });\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,wBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AAQO,MAAMI,oBAAoB,GAAGA,CAAC;EACjCC,eAAe;EACfC;AACU,CAAC,KAAuB;EAClC,MAAMC,eAAe,GAAG,IAAAC,4BAAsB,EAAC;IAC3CC,OAAO,EAAEH;EACb,CAAC,CAAC;EAEF,OAAOI,MAAM,IAAI;IACb,MAAM;MAAEC,GAAG;MAAEC,KAAK,EAAEC,YAAY;MAAEC,KAAK;MAAEC,QAAQ;MAAEC;IAAM,CAAC,GAAGN,MAAM;IAEnE,MAAMO,MAAM,GAAGZ,eAAe,CAACU,QAAQ,CAAC;IACxC,IAAI,CAACE,MAAM,EAAE;MACT,MAAM,IAAIC,cAAW,CACjB,2BAA2BH,QAAQ,mBAAmB,EACtD,gBAAgB,EAChB;QACIA;MACJ,CACJ,CAAC;IACL;IAEA,MAAMH,KAAK,GAAG,IAAAO,gDAAuB,EAAC;MAClCV,OAAO,EAAEH,aAAa;MACtBU,KAAK,EAAEA,KAAK,CAACA,KAAK;MAClBJ,KAAK,EAAEC;IACX,CAAC,CAAC;IAEF,MAAMO,OAAO,GAAG,IAAAC,mBAAU,EAACL,KAAK,CAAC;IAEjC,MAAM;MAAEM,QAAQ;MAAEC;IAAK,CAAC,GAAGhB,eAAe,CAAC;MACvCS,KAAK;MACLJ,KAAK;
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_transformValueForSearch","_keyword","_path","createApplyFiltering","operatorPlugins","searchPlugins","createFieldPath","createFieldPathFactory","plugins","params","key","value","initialValue","query","operator","field","plugin","WebinyError","transformValueForSearch","keyword","hasKeyword","basePath","path","originalValue","apply","name","fieldId","exports"],"sources":["applyFiltering.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { transformValueForSearch } from \"~/operations/entry/elasticsearch/transformValueForSearch\";\nimport { hasKeyword } from \"~/operations/entry/elasticsearch/keyword\";\nimport type {\n ElasticsearchQueryBuilderOperatorPlugins,\n ElasticsearchQuerySearchValuePlugins\n} from \"~/operations/entry/elasticsearch/types\";\nimport { createFieldPathFactory } from \"~/operations/entry/elasticsearch/filtering/path\";\nimport type { ApplyFilteringCb } from \"~/plugins/CmsEntryFilterPlugin\";\n\ninterface CreateParams {\n operatorPlugins: ElasticsearchQueryBuilderOperatorPlugins;\n searchPlugins: ElasticsearchQuerySearchValuePlugins;\n}\n\nexport const createApplyFiltering = ({\n operatorPlugins,\n searchPlugins\n}: CreateParams): ApplyFilteringCb => {\n const createFieldPath = createFieldPathFactory({\n plugins: searchPlugins\n });\n\n return params => {\n const { key, value: initialValue, query, operator, field } = params;\n\n const plugin = operatorPlugins[operator];\n if (!plugin) {\n throw new WebinyError(\n `Elasticsearch operator \"${operator}\" plugin missing.`,\n \"PLUGIN_MISSING\",\n {\n operator\n }\n );\n }\n\n const value = transformValueForSearch({\n plugins: searchPlugins,\n field: field.field,\n value: initialValue\n });\n\n const keyword = hasKeyword(field);\n\n const { basePath, path } = createFieldPath({\n field,\n value,\n originalValue: initialValue,\n key,\n keyword\n });\n\n plugin.apply(query, {\n name: field.field.fieldId,\n basePath,\n path,\n value,\n keyword\n });\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,wBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AAQO,MAAMI,oBAAoB,GAAGA,CAAC;EACjCC,eAAe;EACfC;AACU,CAAC,KAAuB;EAClC,MAAMC,eAAe,GAAG,IAAAC,4BAAsB,EAAC;IAC3CC,OAAO,EAAEH;EACb,CAAC,CAAC;EAEF,OAAOI,MAAM,IAAI;IACb,MAAM;MAAEC,GAAG;MAAEC,KAAK,EAAEC,YAAY;MAAEC,KAAK;MAAEC,QAAQ;MAAEC;IAAM,CAAC,GAAGN,MAAM;IAEnE,MAAMO,MAAM,GAAGZ,eAAe,CAACU,QAAQ,CAAC;IACxC,IAAI,CAACE,MAAM,EAAE;MACT,MAAM,IAAIC,cAAW,CACjB,2BAA2BH,QAAQ,mBAAmB,EACtD,gBAAgB,EAChB;QACIA;MACJ,CACJ,CAAC;IACL;IAEA,MAAMH,KAAK,GAAG,IAAAO,gDAAuB,EAAC;MAClCV,OAAO,EAAEH,aAAa;MACtBU,KAAK,EAAEA,KAAK,CAACA,KAAK;MAClBJ,KAAK,EAAEC;IACX,CAAC,CAAC;IAEF,MAAMO,OAAO,GAAG,IAAAC,mBAAU,EAACL,KAAK,CAAC;IAEjC,MAAM;MAAEM,QAAQ;MAAEC;IAAK,CAAC,GAAGhB,eAAe,CAAC;MACvCS,KAAK;MACLJ,KAAK;MACLY,aAAa,EAAEX,YAAY;MAC3BF,GAAG;MACHS;IACJ,CAAC,CAAC;IAEFH,MAAM,CAACQ,KAAK,CAACX,KAAK,EAAE;MAChBY,IAAI,EAAEV,KAAK,CAACA,KAAK,CAACW,OAAO;MACzBL,QAAQ;MACRC,IAAI;MACJX,KAAK;MACLQ;IACJ,CAAC,CAAC;EACN,CAAC;AACL,CAAC;AAACQ,OAAA,CAAAxB,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -12,7 +12,8 @@ const createFieldPathFactory = ({
|
|
|
12
12
|
field,
|
|
13
13
|
key,
|
|
14
14
|
value,
|
|
15
|
-
keyword
|
|
15
|
+
keyword,
|
|
16
|
+
originalValue
|
|
16
17
|
} = params;
|
|
17
18
|
const plugin = plugins[field.type];
|
|
18
19
|
let fieldPath = null;
|
|
@@ -20,7 +21,8 @@ const createFieldPathFactory = ({
|
|
|
20
21
|
fieldPath = plugin.createPath({
|
|
21
22
|
field: field.field,
|
|
22
23
|
value,
|
|
23
|
-
key
|
|
24
|
+
key,
|
|
25
|
+
originalValue
|
|
24
26
|
});
|
|
25
27
|
}
|
|
26
28
|
if (!fieldPath) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createFieldPathFactory","plugins","params","field","key","value","keyword","plugin","type","fieldPath","createPath","storageId","path","result","systemField","push","parents","map","p","basePath","join","concat","exports"],"sources":["path.ts"],"sourcesContent":["import type {\n ElasticsearchQuerySearchValuePlugins,\n ModelField\n} from \"~/operations/entry/elasticsearch/types\";\n\ninterface FieldPathFactoryParams {\n plugins: ElasticsearchQuerySearchValuePlugins;\n}\ninterface FieldPathParams {\n field: ModelField;\n key: string;\n value: any;\n keyword: boolean;\n}\n\nexport const createFieldPathFactory = ({ plugins }: FieldPathFactoryParams) => {\n return (params: FieldPathParams) => {\n const { field, key, value, keyword } = params;\n const plugin = plugins[field.type];\n\n let fieldPath: string | null = null;\n if (plugin) {\n fieldPath = plugin.createPath({ field: field.field, value, key });\n }\n if (!fieldPath) {\n fieldPath = field.field.storageId;\n if (field.path) {\n fieldPath = typeof field.path === \"function\" ? field.path(value) : field.path;\n }\n }\n\n const result: string[] = [];\n if (!field.systemField) {\n result.push(\"values\");\n }\n result.push(...field.parents.map(p => p.storageId));\n result.push(fieldPath);\n\n return {\n basePath: result.join(\".\"),\n path: result.concat(keyword ? [\"keyword\"] : []).join(\".\")\n };\n };\n};\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"names":["createFieldPathFactory","plugins","params","field","key","value","keyword","originalValue","plugin","type","fieldPath","createPath","storageId","path","result","systemField","push","parents","map","p","basePath","join","concat","exports"],"sources":["path.ts"],"sourcesContent":["import type {\n ElasticsearchQuerySearchValuePlugins,\n ModelField\n} from \"~/operations/entry/elasticsearch/types\";\n\ninterface FieldPathFactoryParams {\n plugins: ElasticsearchQuerySearchValuePlugins;\n}\ninterface FieldPathParams {\n field: ModelField;\n key: string;\n value: any;\n originalValue: any;\n keyword: boolean;\n}\n\nexport const createFieldPathFactory = ({ plugins }: FieldPathFactoryParams) => {\n return (params: FieldPathParams) => {\n const { field, key, value, keyword, originalValue } = params;\n const plugin = plugins[field.type];\n\n let fieldPath: string | null = null;\n if (plugin) {\n fieldPath = plugin.createPath({ field: field.field, value, key, originalValue });\n }\n if (!fieldPath) {\n fieldPath = field.field.storageId;\n if (field.path) {\n fieldPath = typeof field.path === \"function\" ? field.path(value) : field.path;\n }\n }\n\n const result: string[] = [];\n if (!field.systemField) {\n result.push(\"values\");\n }\n result.push(...field.parents.map(p => p.storageId));\n result.push(fieldPath);\n\n return {\n basePath: result.join(\".\"),\n path: result.concat(keyword ? [\"keyword\"] : []).join(\".\")\n };\n };\n};\n"],"mappings":";;;;;;AAgBO,MAAMA,sBAAsB,GAAGA,CAAC;EAAEC;AAAgC,CAAC,KAAK;EAC3E,OAAQC,MAAuB,IAAK;IAChC,MAAM;MAAEC,KAAK;MAAEC,GAAG;MAAEC,KAAK;MAAEC,OAAO;MAAEC;IAAc,CAAC,GAAGL,MAAM;IAC5D,MAAMM,MAAM,GAAGP,OAAO,CAACE,KAAK,CAACM,IAAI,CAAC;IAElC,IAAIC,SAAwB,GAAG,IAAI;IACnC,IAAIF,MAAM,EAAE;MACRE,SAAS,GAAGF,MAAM,CAACG,UAAU,CAAC;QAAER,KAAK,EAAEA,KAAK,CAACA,KAAK;QAAEE,KAAK;QAAED,GAAG;QAAEG;MAAc,CAAC,CAAC;IACpF;IACA,IAAI,CAACG,SAAS,EAAE;MACZA,SAAS,GAAGP,KAAK,CAACA,KAAK,CAACS,SAAS;MACjC,IAAIT,KAAK,CAACU,IAAI,EAAE;QACZH,SAAS,GAAG,OAAOP,KAAK,CAACU,IAAI,KAAK,UAAU,GAAGV,KAAK,CAACU,IAAI,CAACR,KAAK,CAAC,GAAGF,KAAK,CAACU,IAAI;MACjF;IACJ;IAEA,MAAMC,MAAgB,GAAG,EAAE;IAC3B,IAAI,CAACX,KAAK,CAACY,WAAW,EAAE;MACpBD,MAAM,CAACE,IAAI,CAAC,QAAQ,CAAC;IACzB;IACAF,MAAM,CAACE,IAAI,CAAC,GAAGb,KAAK,CAACc,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACP,SAAS,CAAC,CAAC;IACnDE,MAAM,CAACE,IAAI,CAACN,SAAS,CAAC;IAEtB,OAAO;MACHU,QAAQ,EAAEN,MAAM,CAACO,IAAI,CAAC,GAAG,CAAC;MAC1BR,IAAI,EAAEC,MAAM,CAACQ,MAAM,CAAChB,OAAO,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,CAACe,IAAI,CAAC,GAAG;IAC5D,CAAC;EACL,CAAC;AACL,CAAC;AAACE,OAAA,CAAAvB,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -8,6 +8,7 @@ var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
|
8
8
|
var _keyword = require("./keyword");
|
|
9
9
|
var _search = require("./plugins/search");
|
|
10
10
|
var _path = require("./filtering/path");
|
|
11
|
+
var _NoValueContainer = require("../../../values/NoValueContainer.js");
|
|
11
12
|
const createElasticsearchSort = params => {
|
|
12
13
|
const {
|
|
13
14
|
sort,
|
|
@@ -45,8 +46,9 @@ const createElasticsearchSort = params => {
|
|
|
45
46
|
} = createFieldPath({
|
|
46
47
|
key: storageId,
|
|
47
48
|
field,
|
|
48
|
-
value:
|
|
49
|
-
keyword: false
|
|
49
|
+
value: _NoValueContainer.NoValueContainer.create(),
|
|
50
|
+
keyword: false,
|
|
51
|
+
originalValue: _NoValueContainer.NoValueContainer.create()
|
|
50
52
|
});
|
|
51
53
|
/**
|
|
52
54
|
* Plugins must be stored with fieldId as key because it is later used to find the sorting plugin.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_apiElasticsearch","require","_keyword","_search","_path","createElasticsearchSort","params","sort","modelFields","plugins","length","order","searchPlugins","createSearchPluginList","createFieldPath","createFieldPathFactory","fieldIdToStorageIdIdMap","sortPlugins","Object","values","reduce","field","parents","fieldId","storageId","path","key","value","keyword","ElasticsearchFieldPlugin","unmappedType","hasKeyword","sortable","searchable","ALL","transformedSort","map","matched","match","filter","Boolean","createSort","fieldPlugins","exports"],"sources":["sort.ts"],"sourcesContent":["import type { Sort as esSort } from \"@webiny/api-elasticsearch/types\";\nimport { createSort, ElasticsearchFieldPlugin } from \"@webiny/api-elasticsearch\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { CmsEntryListSort, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport type { ModelFields } from \"./types\";\nimport { hasKeyword } from \"~/operations/entry/elasticsearch/keyword\";\nimport { createSearchPluginList } from \"~/operations/entry/elasticsearch/plugins/search\";\nimport { createFieldPathFactory } from \"~/operations/entry/elasticsearch/filtering/path\";\n\ninterface Params {\n plugins: PluginsContainer;\n sort?: CmsEntryListSort;\n modelFields: ModelFields;\n model: CmsModel;\n}\nexport const createElasticsearchSort = (params: Params): esSort => {\n const { sort, modelFields, plugins } = params;\n\n if (!sort || sort.length === 0) {\n return [\n {\n [\"id.keyword\"]: {\n order: \"asc\"\n }\n }\n ];\n }\n\n const searchPlugins = createSearchPluginList({\n plugins\n });\n\n const createFieldPath = createFieldPathFactory({\n plugins: searchPlugins\n });\n\n const fieldIdToStorageIdIdMap: Record<string, string> = {};\n\n const sortPlugins = Object.values(modelFields).reduce<Record<string, ElasticsearchFieldPlugin>>(\n (plugins, field) => {\n /**\n * We do not support sorting by nested fields.\n */\n if (field.parents.length > 0) {\n return plugins;\n }\n const { fieldId, storageId } = field.field;\n\n fieldIdToStorageIdIdMap[fieldId] = fieldId;\n\n const { path } = createFieldPath({\n key: storageId,\n field,\n value:
|
|
1
|
+
{"version":3,"names":["_apiElasticsearch","require","_keyword","_search","_path","_NoValueContainer","createElasticsearchSort","params","sort","modelFields","plugins","length","order","searchPlugins","createSearchPluginList","createFieldPath","createFieldPathFactory","fieldIdToStorageIdIdMap","sortPlugins","Object","values","reduce","field","parents","fieldId","storageId","path","key","value","NoValueContainer","create","keyword","originalValue","ElasticsearchFieldPlugin","unmappedType","hasKeyword","sortable","searchable","ALL","transformedSort","map","matched","match","filter","Boolean","createSort","fieldPlugins","exports"],"sources":["sort.ts"],"sourcesContent":["import type { Sort as esSort } from \"@webiny/api-elasticsearch/types\";\nimport { createSort, ElasticsearchFieldPlugin } from \"@webiny/api-elasticsearch\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { CmsEntryListSort, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport type { ModelFields } from \"./types\";\nimport { hasKeyword } from \"~/operations/entry/elasticsearch/keyword\";\nimport { createSearchPluginList } from \"~/operations/entry/elasticsearch/plugins/search\";\nimport { createFieldPathFactory } from \"~/operations/entry/elasticsearch/filtering/path\";\nimport { NoValueContainer } from \"~/values/NoValueContainer.js\";\n\ninterface Params {\n plugins: PluginsContainer;\n sort?: CmsEntryListSort;\n modelFields: ModelFields;\n model: CmsModel;\n}\nexport const createElasticsearchSort = (params: Params): esSort => {\n const { sort, modelFields, plugins } = params;\n\n if (!sort || sort.length === 0) {\n return [\n {\n [\"id.keyword\"]: {\n order: \"asc\"\n }\n }\n ];\n }\n\n const searchPlugins = createSearchPluginList({\n plugins\n });\n\n const createFieldPath = createFieldPathFactory({\n plugins: searchPlugins\n });\n\n const fieldIdToStorageIdIdMap: Record<string, string> = {};\n\n const sortPlugins = Object.values(modelFields).reduce<Record<string, ElasticsearchFieldPlugin>>(\n (plugins, field) => {\n /**\n * We do not support sorting by nested fields.\n */\n if (field.parents.length > 0) {\n return plugins;\n }\n const { fieldId, storageId } = field.field;\n\n fieldIdToStorageIdIdMap[fieldId] = fieldId;\n\n const { path } = createFieldPath({\n key: storageId,\n field,\n value: NoValueContainer.create(),\n keyword: false,\n originalValue: NoValueContainer.create()\n });\n /**\n * Plugins must be stored with fieldId as key because it is later used to find the sorting plugin.\n */\n plugins[fieldId] = new ElasticsearchFieldPlugin({\n unmappedType: field.unmappedType,\n keyword: hasKeyword(field),\n sortable: field.sortable,\n searchable: field.searchable,\n field: fieldId,\n path\n });\n return plugins;\n },\n {\n [\"*\"]: new ElasticsearchFieldPlugin({\n field: ElasticsearchFieldPlugin.ALL,\n keyword: false\n })\n }\n );\n\n const transformedSort = sort\n .map(value => {\n const matched = value.match(/^([a-zA-Z-0-9_]+)_(ASC|DESC)$/);\n if (!matched) {\n return null;\n }\n const [, fieldId, order] = matched;\n if (fieldIdToStorageIdIdMap[fieldId]) {\n return `${fieldIdToStorageIdIdMap[fieldId]}_${order}`;\n }\n\n return value;\n })\n .filter(Boolean) as string[];\n return createSort({\n fieldPlugins: sortPlugins,\n sort: transformedSort\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AAIA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAQO,MAAMK,uBAAuB,GAAIC,MAAc,IAAa;EAC/D,MAAM;IAAEC,IAAI;IAAEC,WAAW;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAE7C,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACG,MAAM,KAAK,CAAC,EAAE;IAC5B,OAAO,CACH;MACI,CAAC,YAAY,GAAG;QACZC,KAAK,EAAE;MACX;IACJ,CAAC,CACJ;EACL;EAEA,MAAMC,aAAa,GAAG,IAAAC,8BAAsB,EAAC;IACzCJ;EACJ,CAAC,CAAC;EAEF,MAAMK,eAAe,GAAG,IAAAC,4BAAsB,EAAC;IAC3CN,OAAO,EAAEG;EACb,CAAC,CAAC;EAEF,MAAMI,uBAA+C,GAAG,CAAC,CAAC;EAE1D,MAAMC,WAAW,GAAGC,MAAM,CAACC,MAAM,CAACX,WAAW,CAAC,CAACY,MAAM,CACjD,CAACX,OAAO,EAAEY,KAAK,KAAK;IAChB;AACZ;AACA;IACY,IAAIA,KAAK,CAACC,OAAO,CAACZ,MAAM,GAAG,CAAC,EAAE;MAC1B,OAAOD,OAAO;IAClB;IACA,MAAM;MAAEc,OAAO;MAAEC;IAAU,CAAC,GAAGH,KAAK,CAACA,KAAK;IAE1CL,uBAAuB,CAACO,OAAO,CAAC,GAAGA,OAAO;IAE1C,MAAM;MAAEE;IAAK,CAAC,GAAGX,eAAe,CAAC;MAC7BY,GAAG,EAAEF,SAAS;MACdH,KAAK;MACLM,KAAK,EAAEC,kCAAgB,CAACC,MAAM,CAAC,CAAC;MAChCC,OAAO,EAAE,KAAK;MACdC,aAAa,EAAEH,kCAAgB,CAACC,MAAM,CAAC;IAC3C,CAAC,CAAC;IACF;AACZ;AACA;IACYpB,OAAO,CAACc,OAAO,CAAC,GAAG,IAAIS,0CAAwB,CAAC;MAC5CC,YAAY,EAAEZ,KAAK,CAACY,YAAY;MAChCH,OAAO,EAAE,IAAAI,mBAAU,EAACb,KAAK,CAAC;MAC1Bc,QAAQ,EAAEd,KAAK,CAACc,QAAQ;MACxBC,UAAU,EAAEf,KAAK,CAACe,UAAU;MAC5Bf,KAAK,EAAEE,OAAO;MACdE;IACJ,CAAC,CAAC;IACF,OAAOhB,OAAO;EAClB,CAAC,EACD;IACI,CAAC,GAAG,GAAG,IAAIuB,0CAAwB,CAAC;MAChCX,KAAK,EAAEW,0CAAwB,CAACK,GAAG;MACnCP,OAAO,EAAE;IACb,CAAC;EACL,CACJ,CAAC;EAED,MAAMQ,eAAe,GAAG/B,IAAI,CACvBgC,GAAG,CAACZ,KAAK,IAAI;IACV,MAAMa,OAAO,GAAGb,KAAK,CAACc,KAAK,CAAC,+BAA+B,CAAC;IAC5D,IAAI,CAACD,OAAO,EAAE;MACV,OAAO,IAAI;IACf;IACA,MAAM,GAAGjB,OAAO,EAAEZ,KAAK,CAAC,GAAG6B,OAAO;IAClC,IAAIxB,uBAAuB,CAACO,OAAO,CAAC,EAAE;MAClC,OAAO,GAAGP,uBAAuB,CAACO,OAAO,CAAC,IAAIZ,KAAK,EAAE;IACzD;IAEA,OAAOgB,KAAK;EAChB,CAAC,CAAC,CACDe,MAAM,CAACC,OAAO,CAAa;EAChC,OAAO,IAAAC,4BAAU,EAAC;IACdC,YAAY,EAAE5B,WAAW;IACzBV,IAAI,EAAE+B;EACV,CAAC,CAAC;AACN,CAAC;AAACQ,OAAA,CAAAzC,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-ddb-es",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.eb196ccd2f",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-headless-cms",
|
|
@@ -26,33 +26,33 @@
|
|
|
26
26
|
],
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@webiny/api": "0.0.0-unstable.
|
|
30
|
-
"@webiny/api-elasticsearch": "0.0.0-unstable.
|
|
31
|
-
"@webiny/api-elasticsearch-tasks": "0.0.0-unstable.
|
|
32
|
-
"@webiny/api-headless-cms": "0.0.0-unstable.
|
|
33
|
-
"@webiny/aws-sdk": "0.0.0-unstable.
|
|
34
|
-
"@webiny/db-dynamodb": "0.0.0-unstable.
|
|
35
|
-
"@webiny/error": "0.0.0-unstable.
|
|
36
|
-
"@webiny/handler-db": "0.0.0-unstable.
|
|
37
|
-
"@webiny/plugins": "0.0.0-unstable.
|
|
38
|
-
"@webiny/utils": "0.0.0-unstable.
|
|
29
|
+
"@webiny/api": "0.0.0-unstable.eb196ccd2f",
|
|
30
|
+
"@webiny/api-elasticsearch": "0.0.0-unstable.eb196ccd2f",
|
|
31
|
+
"@webiny/api-elasticsearch-tasks": "0.0.0-unstable.eb196ccd2f",
|
|
32
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.eb196ccd2f",
|
|
33
|
+
"@webiny/aws-sdk": "0.0.0-unstable.eb196ccd2f",
|
|
34
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.eb196ccd2f",
|
|
35
|
+
"@webiny/error": "0.0.0-unstable.eb196ccd2f",
|
|
36
|
+
"@webiny/handler-db": "0.0.0-unstable.eb196ccd2f",
|
|
37
|
+
"@webiny/plugins": "0.0.0-unstable.eb196ccd2f",
|
|
38
|
+
"@webiny/utils": "0.0.0-unstable.eb196ccd2f",
|
|
39
39
|
"dataloader": "2.2.3",
|
|
40
40
|
"lodash": "4.17.21"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@elastic/elasticsearch": "7.12.0",
|
|
44
44
|
"@types/jsonpack": "1.1.6",
|
|
45
|
-
"@webiny/api-dynamodb-to-elasticsearch": "0.0.0-unstable.
|
|
46
|
-
"@webiny/api-i18n": "0.0.0-unstable.
|
|
47
|
-
"@webiny/api-log": "0.0.0-unstable.
|
|
48
|
-
"@webiny/api-security": "0.0.0-unstable.
|
|
49
|
-
"@webiny/api-tenancy": "0.0.0-unstable.
|
|
50
|
-
"@webiny/api-wcp": "0.0.0-unstable.
|
|
51
|
-
"@webiny/handler": "0.0.0-unstable.
|
|
52
|
-
"@webiny/handler-aws": "0.0.0-unstable.
|
|
53
|
-
"@webiny/handler-graphql": "0.0.0-unstable.
|
|
54
|
-
"@webiny/project-utils": "0.0.0-unstable.
|
|
55
|
-
"@webiny/tasks": "0.0.0-unstable.
|
|
45
|
+
"@webiny/api-dynamodb-to-elasticsearch": "0.0.0-unstable.eb196ccd2f",
|
|
46
|
+
"@webiny/api-i18n": "0.0.0-unstable.eb196ccd2f",
|
|
47
|
+
"@webiny/api-log": "0.0.0-unstable.eb196ccd2f",
|
|
48
|
+
"@webiny/api-security": "0.0.0-unstable.eb196ccd2f",
|
|
49
|
+
"@webiny/api-tenancy": "0.0.0-unstable.eb196ccd2f",
|
|
50
|
+
"@webiny/api-wcp": "0.0.0-unstable.eb196ccd2f",
|
|
51
|
+
"@webiny/handler": "0.0.0-unstable.eb196ccd2f",
|
|
52
|
+
"@webiny/handler-aws": "0.0.0-unstable.eb196ccd2f",
|
|
53
|
+
"@webiny/handler-graphql": "0.0.0-unstable.eb196ccd2f",
|
|
54
|
+
"@webiny/project-utils": "0.0.0-unstable.eb196ccd2f",
|
|
55
|
+
"@webiny/tasks": "0.0.0-unstable.eb196ccd2f",
|
|
56
56
|
"jest": "29.7.0",
|
|
57
57
|
"jest-dynalite": "3.6.1",
|
|
58
58
|
"prettier": "2.8.8",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"build": "node ../cli/bin.js run build",
|
|
68
68
|
"watch": "node ../cli/bin.js run watch"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "eb196ccd2f32296e10f7add6dd7220d4e3abece4"
|
|
71
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_Plugin","require","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","Plugin","type","fieldType","config","constructor","params","name","transform","createPath","path","exports","createCmsEntryElasticsearchQueryBuilderValueSearchPlugin"],"sources":["CmsEntryElasticsearchQueryBuilderValueSearchPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport type { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nexport interface CreatePathCallableParams<T = any> {\n field: CmsModelField;\n key: string;\n value: T;\n}\n\nexport interface CreatePathCallable<T = any> {\n (params: CreatePathCallableParams<T>): string;\n}\n\nexport interface TransformCallableParams<T = any> {\n field: CmsModelField;\n value: T;\n}\nexport interface TransformCallable<T = any> {\n (params: TransformCallableParams<T>): string;\n}\n\nexport interface CmsEntryElasticsearchQueryBuilderValueSearchPluginParams {\n fieldType: string;\n path?: string | CreatePathCallable;\n transform: TransformCallable;\n}\nexport class CmsEntryElasticsearchQueryBuilderValueSearchPlugin extends Plugin {\n public static override readonly type: string = \"cms-elastic-search-query-builder-value-search\";\n\n private readonly config: CmsEntryElasticsearchQueryBuilderValueSearchPluginParams;\n\n public get fieldType(): string {\n return this.config.fieldType;\n }\n\n public constructor(params: CmsEntryElasticsearchQueryBuilderValueSearchPluginParams) {\n super();\n\n this.config = params;\n /**\n * There is a type on the constructor, TS just doesn't see it.\n */\n // @ts-expect-error\n this.name = `${this.constructor.type}-${this.config.fieldType}`;\n }\n\n public transform(params: TransformCallableParams): any {\n return this.config.transform(params);\n }\n\n public createPath(params: CreatePathCallableParams): string | null {\n if (typeof this.config.path === \"function\") {\n return this.config.path(params);\n } else if (typeof this.config.path === \"string\") {\n return this.config.path;\n }\n return null;\n }\n}\n\nexport const createCmsEntryElasticsearchQueryBuilderValueSearchPlugin = (\n params: CmsEntryElasticsearchQueryBuilderValueSearchPluginParams\n) => {\n return new CmsEntryElasticsearchQueryBuilderValueSearchPlugin(params);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;
|
|
1
|
+
{"version":3,"names":["_Plugin","require","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","Plugin","type","fieldType","config","constructor","params","name","transform","createPath","path","exports","createCmsEntryElasticsearchQueryBuilderValueSearchPlugin"],"sources":["CmsEntryElasticsearchQueryBuilderValueSearchPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport type { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nexport interface CreatePathCallableParams<T = any> {\n field: CmsModelField;\n key: string;\n value: T;\n originalValue: any;\n}\n\nexport interface CreatePathCallable<T = any> {\n (params: CreatePathCallableParams<T>): string;\n}\n\nexport interface TransformCallableParams<T = any> {\n field: CmsModelField;\n value: T;\n}\nexport interface TransformCallable<T = any> {\n (params: TransformCallableParams<T>): string;\n}\n\nexport interface CmsEntryElasticsearchQueryBuilderValueSearchPluginParams {\n fieldType: string;\n path?: string | CreatePathCallable;\n transform: TransformCallable;\n}\nexport class CmsEntryElasticsearchQueryBuilderValueSearchPlugin extends Plugin {\n public static override readonly type: string = \"cms-elastic-search-query-builder-value-search\";\n\n private readonly config: CmsEntryElasticsearchQueryBuilderValueSearchPluginParams;\n\n public get fieldType(): string {\n return this.config.fieldType;\n }\n\n public constructor(params: CmsEntryElasticsearchQueryBuilderValueSearchPluginParams) {\n super();\n\n this.config = params;\n /**\n * There is a type on the constructor, TS just doesn't see it.\n */\n // @ts-expect-error\n this.name = `${this.constructor.type}-${this.config.fieldType}`;\n }\n\n public transform(params: TransformCallableParams): any {\n return this.config.transform(params);\n }\n\n public createPath(params: CreatePathCallableParams): string | null {\n if (typeof this.config.path === \"function\") {\n return this.config.path(params);\n } else if (typeof this.config.path === \"string\") {\n return this.config.path;\n }\n return null;\n }\n}\n\nexport const createCmsEntryElasticsearchQueryBuilderValueSearchPlugin = (\n params: CmsEntryElasticsearchQueryBuilderValueSearchPluginParams\n) => {\n return new CmsEntryElasticsearchQueryBuilderValueSearchPlugin(params);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AA2BO,MAAMC,kDAAkD,SAASC,cAAM,CAAC;EAC3E,OAAgCC,IAAI,GAAW,+CAA+C;EAI9F,IAAWC,SAASA,CAAA,EAAW;IAC3B,OAAO,IAAI,CAACC,MAAM,CAACD,SAAS;EAChC;EAEOE,WAAWA,CAACC,MAAgE,EAAE;IACjF,KAAK,CAAC,CAAC;IAEP,IAAI,CAACF,MAAM,GAAGE,MAAM;IACpB;AACR;AACA;IACQ;IACA,IAAI,CAACC,IAAI,GAAG,GAAG,IAAI,CAACF,WAAW,CAACH,IAAI,IAAI,IAAI,CAACE,MAAM,CAACD,SAAS,EAAE;EACnE;EAEOK,SAASA,CAACF,MAA+B,EAAO;IACnD,OAAO,IAAI,CAACF,MAAM,CAACI,SAAS,CAACF,MAAM,CAAC;EACxC;EAEOG,UAAUA,CAACH,MAAgC,EAAiB;IAC/D,IAAI,OAAO,IAAI,CAACF,MAAM,CAACM,IAAI,KAAK,UAAU,EAAE;MACxC,OAAO,IAAI,CAACN,MAAM,CAACM,IAAI,CAACJ,MAAM,CAAC;IACnC,CAAC,MAAM,IAAI,OAAO,IAAI,CAACF,MAAM,CAACM,IAAI,KAAK,QAAQ,EAAE;MAC7C,OAAO,IAAI,CAACN,MAAM,CAACM,IAAI;IAC3B;IACA,OAAO,IAAI;EACf;AACJ;AAACC,OAAA,CAAAX,kDAAA,GAAAA,kDAAA;AAEM,MAAMY,wDAAwD,GACjEN,MAAgE,IAC/D;EACD,OAAO,IAAIN,kDAAkD,CAACM,MAAM,CAAC;AACzE,CAAC;AAACK,OAAA,CAAAC,wDAAA,GAAAA,wDAAA","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NoValueContainer = void 0;
|
|
7
|
+
class NoValueContainer {
|
|
8
|
+
constructor() {
|
|
9
|
+
//
|
|
10
|
+
}
|
|
11
|
+
static create() {
|
|
12
|
+
return new NoValueContainer();
|
|
13
|
+
}
|
|
14
|
+
static is(value) {
|
|
15
|
+
return value instanceof NoValueContainer;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.NoValueContainer = NoValueContainer;
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=NoValueContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NoValueContainer","constructor","create","is","value","exports"],"sources":["NoValueContainer.ts"],"sourcesContent":["export class NoValueContainer {\n private constructor() {\n //\n }\n\n public static create(): NoValueContainer {\n return new NoValueContainer();\n }\n\n public static is(value: unknown): boolean {\n return value instanceof NoValueContainer;\n }\n}\n"],"mappings":";;;;;;AAAO,MAAMA,gBAAgB,CAAC;EAClBC,WAAWA,CAAA,EAAG;IAClB;EAAA;EAGJ,OAAcC,MAAMA,CAAA,EAAqB;IACrC,OAAO,IAAIF,gBAAgB,CAAC,CAAC;EACjC;EAEA,OAAcG,EAAEA,CAACC,KAAc,EAAW;IACtC,OAAOA,KAAK,YAAYJ,gBAAgB;EAC5C;AACJ;AAACK,OAAA,CAAAL,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|