@webiny/api-headless-cms-storage 6.6.0-alpha.0 → 6.6.0-alpha.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/package.json +20 -15
- package/__tests__/filtering/getValue.test.ts +0 -58
- package/__tests__/filtering/mocks/entry.noModel.ts +0 -110
- package/__tests__/path/plainObject.test.ts +0 -32
- package/__tests__/transforms/datetime.test.ts +0 -71
- package/dist/package.json +0 -30
- package/src/cms/storageHelpers.ts +0 -92
- package/src/features/FilterRegistriesFeature.ts +0 -40
- package/src/features/fieldFilterCreate/FieldFilterCreateRegistry.ts +0 -25
- package/src/features/fieldFilterCreate/abstractions.ts +0 -51
- package/src/features/fieldFilterPath/FieldFilterPathRegistry.ts +0 -13
- package/src/features/fieldFilterPath/abstractions.ts +0 -22
- package/src/features/fieldFilterValueTransform/FieldFilterValueTransformRegistry.ts +0 -15
- package/src/features/fieldFilterValueTransform/abstractions.ts +0 -21
- package/src/features/fieldSorting/FieldSortingRegistry.ts +0 -20
- package/src/features/fieldSorting/abstractions.ts +0 -49
- package/src/filtering/expressions/createExpressions.ts +0 -170
- package/src/filtering/fields/createFields.ts +0 -124
- package/src/filtering/fields/extractSort.ts +0 -97
- package/src/filtering/fields/systemFields.ts +0 -165
- package/src/filtering/fields/types.ts +0 -46
- package/src/filtering/filter.ts +0 -166
- package/src/filtering/fullTextSearch.ts +0 -40
- package/src/filtering/getValue.ts +0 -64
- package/src/filtering/mapPlugins.ts +0 -30
- package/src/filtering/plugins/defaultFilterCreate.ts +0 -36
- package/src/filtering/plugins/index.ts +0 -13
- package/src/filtering/plugins/objectFilterCreate.ts +0 -100
- package/src/filtering/plugins/refFilterCreate.ts +0 -83
- package/src/filtering/plugins/searchableJsonFilterCreate.ts +0 -78
- package/src/filtering/sort.ts +0 -79
- package/src/filtering/transform.ts +0 -11
- package/src/filtering/values.ts +0 -24
- package/src/filtering/where.ts +0 -24
- package/src/handlers/datetimeTransformHandler.ts +0 -52
- package/src/handlers/defaultFilterCreateHandler.ts +0 -31
- package/src/handlers/locationFolderIdPathHandler.ts +0 -24
- package/src/handlers/objectFilterCreateHandler.ts +0 -86
- package/src/handlers/plainObjectPathHandler.ts +0 -17
- package/src/handlers/refFilterCreateHandler.ts +0 -65
- package/src/handlers/searchableJsonFilterCreateHandler.ts +0 -61
- package/src/index.ts +0 -63
- package/src/path/locationFolderId.ts +0 -29
- package/src/path/plainObject.ts +0 -21
- package/src/plugins/CmsEntryFieldFilterPathPlugin.ts +0 -58
- package/src/plugins/CmsEntryFieldFilterPlugin.ts +0 -59
- package/src/plugins/CmsEntryFieldSortingPlugin.ts +0 -63
- package/src/plugins/CmsFieldFilterValueTransformPlugin.ts +0 -43
- package/src/plugins/index.ts +0 -10
- package/src/transforms/datetime.ts +0 -62
- package/tsconfig.build.json +0 -33
- package/tsconfig.json +0 -33
- package/vitest.config.ts +0 -5
- package/webiny.config.js +0 -8
- /package/{dist/LICENSE → LICENSE} +0 -0
- /package/{dist/README.md → README.md} +0 -0
- /package/{dist/cms → cms}/storageHelpers.d.ts +0 -0
- /package/{dist/cms → cms}/storageHelpers.js +0 -0
- /package/{dist/cms → cms}/storageHelpers.js.map +0 -0
- /package/{dist/features → features}/FilterRegistriesFeature.d.ts +0 -0
- /package/{dist/features → features}/FilterRegistriesFeature.js +0 -0
- /package/{dist/features → features}/FilterRegistriesFeature.js.map +0 -0
- /package/{dist/features → features}/fieldFilterCreate/FieldFilterCreateRegistry.d.ts +0 -0
- /package/{dist/features → features}/fieldFilterCreate/FieldFilterCreateRegistry.js +0 -0
- /package/{dist/features → features}/fieldFilterCreate/FieldFilterCreateRegistry.js.map +0 -0
- /package/{dist/features → features}/fieldFilterCreate/abstractions.d.ts +0 -0
- /package/{dist/features → features}/fieldFilterCreate/abstractions.js +0 -0
- /package/{dist/features → features}/fieldFilterCreate/abstractions.js.map +0 -0
- /package/{dist/features → features}/fieldFilterPath/FieldFilterPathRegistry.d.ts +0 -0
- /package/{dist/features → features}/fieldFilterPath/FieldFilterPathRegistry.js +0 -0
- /package/{dist/features → features}/fieldFilterPath/FieldFilterPathRegistry.js.map +0 -0
- /package/{dist/features → features}/fieldFilterPath/abstractions.d.ts +0 -0
- /package/{dist/features → features}/fieldFilterPath/abstractions.js +0 -0
- /package/{dist/features → features}/fieldFilterPath/abstractions.js.map +0 -0
- /package/{dist/features → features}/fieldFilterValueTransform/FieldFilterValueTransformRegistry.d.ts +0 -0
- /package/{dist/features → features}/fieldFilterValueTransform/FieldFilterValueTransformRegistry.js +0 -0
- /package/{dist/features → features}/fieldFilterValueTransform/FieldFilterValueTransformRegistry.js.map +0 -0
- /package/{dist/features → features}/fieldFilterValueTransform/abstractions.d.ts +0 -0
- /package/{dist/features → features}/fieldFilterValueTransform/abstractions.js +0 -0
- /package/{dist/features → features}/fieldFilterValueTransform/abstractions.js.map +0 -0
- /package/{dist/features → features}/fieldSorting/FieldSortingRegistry.d.ts +0 -0
- /package/{dist/features → features}/fieldSorting/FieldSortingRegistry.js +0 -0
- /package/{dist/features → features}/fieldSorting/FieldSortingRegistry.js.map +0 -0
- /package/{dist/features → features}/fieldSorting/abstractions.d.ts +0 -0
- /package/{dist/features → features}/fieldSorting/abstractions.js +0 -0
- /package/{dist/features → features}/fieldSorting/abstractions.js.map +0 -0
- /package/{dist/filtering → filtering}/expressions/createExpressions.d.ts +0 -0
- /package/{dist/filtering → filtering}/expressions/createExpressions.js +0 -0
- /package/{dist/filtering → filtering}/expressions/createExpressions.js.map +0 -0
- /package/{dist/filtering → filtering}/fields/createFields.d.ts +0 -0
- /package/{dist/filtering → filtering}/fields/createFields.js +0 -0
- /package/{dist/filtering → filtering}/fields/createFields.js.map +0 -0
- /package/{dist/filtering → filtering}/fields/extractSort.d.ts +0 -0
- /package/{dist/filtering → filtering}/fields/extractSort.js +0 -0
- /package/{dist/filtering → filtering}/fields/extractSort.js.map +0 -0
- /package/{dist/filtering → filtering}/fields/systemFields.d.ts +0 -0
- /package/{dist/filtering → filtering}/fields/systemFields.js +0 -0
- /package/{dist/filtering → filtering}/fields/systemFields.js.map +0 -0
- /package/{dist/filtering → filtering}/fields/types.d.ts +0 -0
- /package/{dist/filtering → filtering}/fields/types.js +0 -0
- /package/{dist/filtering → filtering}/filter.d.ts +0 -0
- /package/{dist/filtering → filtering}/filter.js +0 -0
- /package/{dist/filtering → filtering}/filter.js.map +0 -0
- /package/{dist/filtering → filtering}/fullTextSearch.d.ts +0 -0
- /package/{dist/filtering → filtering}/fullTextSearch.js +0 -0
- /package/{dist/filtering → filtering}/fullTextSearch.js.map +0 -0
- /package/{dist/filtering → filtering}/getValue.d.ts +0 -0
- /package/{dist/filtering → filtering}/getValue.js +0 -0
- /package/{dist/filtering → filtering}/getValue.js.map +0 -0
- /package/{dist/filtering → filtering}/mapPlugins.d.ts +0 -0
- /package/{dist/filtering → filtering}/mapPlugins.js +0 -0
- /package/{dist/filtering → filtering}/mapPlugins.js.map +0 -0
- /package/{dist/filtering → filtering}/plugins/defaultFilterCreate.d.ts +0 -0
- /package/{dist/filtering → filtering}/plugins/defaultFilterCreate.js +0 -0
- /package/{dist/filtering → filtering}/plugins/defaultFilterCreate.js.map +0 -0
- /package/{dist/filtering → filtering}/plugins/index.d.ts +0 -0
- /package/{dist/filtering → filtering}/plugins/index.js +0 -0
- /package/{dist/filtering → filtering}/plugins/index.js.map +0 -0
- /package/{dist/filtering → filtering}/plugins/objectFilterCreate.d.ts +0 -0
- /package/{dist/filtering → filtering}/plugins/objectFilterCreate.js +0 -0
- /package/{dist/filtering → filtering}/plugins/objectFilterCreate.js.map +0 -0
- /package/{dist/filtering → filtering}/plugins/refFilterCreate.d.ts +0 -0
- /package/{dist/filtering → filtering}/plugins/refFilterCreate.js +0 -0
- /package/{dist/filtering → filtering}/plugins/refFilterCreate.js.map +0 -0
- /package/{dist/filtering → filtering}/plugins/searchableJsonFilterCreate.d.ts +0 -0
- /package/{dist/filtering → filtering}/plugins/searchableJsonFilterCreate.js +0 -0
- /package/{dist/filtering → filtering}/plugins/searchableJsonFilterCreate.js.map +0 -0
- /package/{dist/filtering → filtering}/sort.d.ts +0 -0
- /package/{dist/filtering → filtering}/sort.js +0 -0
- /package/{dist/filtering → filtering}/sort.js.map +0 -0
- /package/{dist/filtering → filtering}/transform.d.ts +0 -0
- /package/{dist/filtering → filtering}/transform.js +0 -0
- /package/{dist/filtering → filtering}/transform.js.map +0 -0
- /package/{dist/filtering → filtering}/values.d.ts +0 -0
- /package/{dist/filtering → filtering}/values.js +0 -0
- /package/{dist/filtering → filtering}/values.js.map +0 -0
- /package/{dist/filtering → filtering}/where.d.ts +0 -0
- /package/{dist/filtering → filtering}/where.js +0 -0
- /package/{dist/filtering → filtering}/where.js.map +0 -0
- /package/{dist/handlers → handlers}/datetimeTransformHandler.d.ts +0 -0
- /package/{dist/handlers → handlers}/datetimeTransformHandler.js +0 -0
- /package/{dist/handlers → handlers}/datetimeTransformHandler.js.map +0 -0
- /package/{dist/handlers → handlers}/defaultFilterCreateHandler.d.ts +0 -0
- /package/{dist/handlers → handlers}/defaultFilterCreateHandler.js +0 -0
- /package/{dist/handlers → handlers}/defaultFilterCreateHandler.js.map +0 -0
- /package/{dist/handlers → handlers}/locationFolderIdPathHandler.d.ts +0 -0
- /package/{dist/handlers → handlers}/locationFolderIdPathHandler.js +0 -0
- /package/{dist/handlers → handlers}/locationFolderIdPathHandler.js.map +0 -0
- /package/{dist/handlers → handlers}/objectFilterCreateHandler.d.ts +0 -0
- /package/{dist/handlers → handlers}/objectFilterCreateHandler.js +0 -0
- /package/{dist/handlers → handlers}/objectFilterCreateHandler.js.map +0 -0
- /package/{dist/handlers → handlers}/plainObjectPathHandler.d.ts +0 -0
- /package/{dist/handlers → handlers}/plainObjectPathHandler.js +0 -0
- /package/{dist/handlers → handlers}/plainObjectPathHandler.js.map +0 -0
- /package/{dist/handlers → handlers}/refFilterCreateHandler.d.ts +0 -0
- /package/{dist/handlers → handlers}/refFilterCreateHandler.js +0 -0
- /package/{dist/handlers → handlers}/refFilterCreateHandler.js.map +0 -0
- /package/{dist/handlers → handlers}/searchableJsonFilterCreateHandler.d.ts +0 -0
- /package/{dist/handlers → handlers}/searchableJsonFilterCreateHandler.js +0 -0
- /package/{dist/handlers → handlers}/searchableJsonFilterCreateHandler.js.map +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/index.js → index.js} +0 -0
- /package/{dist/path → path}/locationFolderId.d.ts +0 -0
- /package/{dist/path → path}/locationFolderId.js +0 -0
- /package/{dist/path → path}/locationFolderId.js.map +0 -0
- /package/{dist/path → path}/plainObject.d.ts +0 -0
- /package/{dist/path → path}/plainObject.js +0 -0
- /package/{dist/path → path}/plainObject.js.map +0 -0
- /package/{dist/plugins → plugins}/CmsEntryFieldFilterPathPlugin.d.ts +0 -0
- /package/{dist/plugins → plugins}/CmsEntryFieldFilterPathPlugin.js +0 -0
- /package/{dist/plugins → plugins}/CmsEntryFieldFilterPathPlugin.js.map +0 -0
- /package/{dist/plugins → plugins}/CmsEntryFieldFilterPlugin.d.ts +0 -0
- /package/{dist/plugins → plugins}/CmsEntryFieldFilterPlugin.js +0 -0
- /package/{dist/plugins → plugins}/CmsEntryFieldFilterPlugin.js.map +0 -0
- /package/{dist/plugins → plugins}/CmsEntryFieldSortingPlugin.d.ts +0 -0
- /package/{dist/plugins → plugins}/CmsEntryFieldSortingPlugin.js +0 -0
- /package/{dist/plugins → plugins}/CmsEntryFieldSortingPlugin.js.map +0 -0
- /package/{dist/plugins → plugins}/CmsFieldFilterValueTransformPlugin.d.ts +0 -0
- /package/{dist/plugins → plugins}/CmsFieldFilterValueTransformPlugin.js +0 -0
- /package/{dist/plugins → plugins}/CmsFieldFilterValueTransformPlugin.js.map +0 -0
- /package/{dist/plugins → plugins}/index.d.ts +0 -0
- /package/{dist/plugins → plugins}/index.js +0 -0
- /package/{dist/transforms → transforms}/datetime.d.ts +0 -0
- /package/{dist/transforms → transforms}/datetime.js +0 -0
- /package/{dist/transforms → transforms}/datetime.js.map +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-storage",
|
|
3
|
-
"version": "6.6.0-alpha.
|
|
3
|
+
"version": "6.6.0-alpha.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -10,21 +10,26 @@
|
|
|
10
10
|
"directory": "packages/api-headless-cms-storage"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@webiny/api": "6.6.0-alpha.
|
|
14
|
-
"@webiny/api-headless-cms": "6.6.0-alpha.
|
|
15
|
-
"@webiny/db-utils": "6.6.0-alpha.
|
|
16
|
-
"@webiny/di": "
|
|
17
|
-
"@webiny/error": "6.6.0-alpha.
|
|
18
|
-
"@webiny/feature": "6.6.0-alpha.
|
|
19
|
-
"@webiny/plugins": "6.6.0-alpha.
|
|
20
|
-
"date-fns": "
|
|
21
|
-
"dot-prop": "
|
|
22
|
-
"lodash": "
|
|
13
|
+
"@webiny/api": "6.6.0-alpha.1",
|
|
14
|
+
"@webiny/api-headless-cms": "6.6.0-alpha.1",
|
|
15
|
+
"@webiny/db-utils": "6.6.0-alpha.1",
|
|
16
|
+
"@webiny/di": "1.1.0",
|
|
17
|
+
"@webiny/error": "6.6.0-alpha.1",
|
|
18
|
+
"@webiny/feature": "6.6.0-alpha.1",
|
|
19
|
+
"@webiny/plugins": "6.6.0-alpha.1",
|
|
20
|
+
"date-fns": "4.4.0",
|
|
21
|
+
"dot-prop": "10.2.0",
|
|
22
|
+
"lodash": "4.18.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@webiny/build-tools": "6.6.0-alpha.
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
|
|
25
|
+
"@webiny/build-tools": "6.6.0-alpha.1",
|
|
26
|
+
"typescript": "7.0.2",
|
|
27
|
+
"vitest": "4.1.11"
|
|
28
|
+
},
|
|
29
|
+
"webiny": {
|
|
30
|
+
"publishFrom": "dist"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
29
34
|
}
|
|
30
35
|
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { getValue } from "~/filtering/getValue";
|
|
3
|
-
import { createEntry } from "./mocks/entry.noModel";
|
|
4
|
-
|
|
5
|
-
describe("value via object-path", () => {
|
|
6
|
-
it("should find values complex object / array structure", async () => {
|
|
7
|
-
const title = getValue(createEntry(), "values.title");
|
|
8
|
-
expect(title).toEqual(createEntry().values.title);
|
|
9
|
-
|
|
10
|
-
const options = getValue(createEntry(), "values.options");
|
|
11
|
-
expect(options).toEqual(createEntry().values.options);
|
|
12
|
-
|
|
13
|
-
const variantTitle = getValue(createEntry(), "values.variant.title");
|
|
14
|
-
expect(variantTitle).toEqual(createEntry().values.variant.title);
|
|
15
|
-
|
|
16
|
-
const variantSpecificationsKey = getValue(
|
|
17
|
-
createEntry(),
|
|
18
|
-
"values.variant.specifications.key"
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
expect(variantSpecificationsKey).toEqual([
|
|
22
|
-
"Specification #1",
|
|
23
|
-
"Specification #2",
|
|
24
|
-
"Specification #3"
|
|
25
|
-
]);
|
|
26
|
-
|
|
27
|
-
const variantSpecificationsInfoImages = getValue(
|
|
28
|
-
createEntry(),
|
|
29
|
-
"values.variant.specifications.info.images"
|
|
30
|
-
);
|
|
31
|
-
expect(variantSpecificationsInfoImages).toEqual([
|
|
32
|
-
{ files: ["image1.jpg", "image2.jpg", "image3.jpg", "image4.jpg"] },
|
|
33
|
-
{ files: ["image31.jpg", "image32.jpg", "image33.jpg", "image34.jpg"] }
|
|
34
|
-
]);
|
|
35
|
-
|
|
36
|
-
const variantSpecificationsInfoImagesFiles = getValue(
|
|
37
|
-
createEntry(),
|
|
38
|
-
"values.variant.specifications.info.images.files"
|
|
39
|
-
);
|
|
40
|
-
expect(variantSpecificationsInfoImagesFiles).toEqual([
|
|
41
|
-
"image1.jpg",
|
|
42
|
-
"image2.jpg",
|
|
43
|
-
"image3.jpg",
|
|
44
|
-
"image4.jpg",
|
|
45
|
-
"image31.jpg",
|
|
46
|
-
"image32.jpg",
|
|
47
|
-
"image33.jpg",
|
|
48
|
-
"image34.jpg"
|
|
49
|
-
]);
|
|
50
|
-
|
|
51
|
-
const variantSpecificationsInfoTagsKey = getValue(
|
|
52
|
-
createEntry(),
|
|
53
|
-
"values.variant.specifications.info.tags.key"
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
expect(variantSpecificationsInfoTagsKey).toEqual(["size", "weight", "price"]);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import type { CmsEntry } from "@webiny/api-headless-cms/types";
|
|
2
|
-
|
|
3
|
-
interface ValuesOption {
|
|
4
|
-
title: string;
|
|
5
|
-
value: number;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
interface ValuesVariantSpecification {
|
|
9
|
-
key: string;
|
|
10
|
-
value: string | number;
|
|
11
|
-
info?: {
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
interface ValuesVariant {
|
|
16
|
-
title: string;
|
|
17
|
-
specifications: ValuesVariantSpecification[];
|
|
18
|
-
}
|
|
19
|
-
interface Values {
|
|
20
|
-
title: string;
|
|
21
|
-
options: ValuesOption[];
|
|
22
|
-
variant: ValuesVariant;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
type Result = Pick<CmsEntry<Values>, "id" | "createdBy" | "createdOn" | "values">;
|
|
26
|
-
|
|
27
|
-
const createCreatedOn = (index: number) => {
|
|
28
|
-
const d = new Date();
|
|
29
|
-
d.setTime(d.getTime() + index * 1000 * 86400);
|
|
30
|
-
|
|
31
|
-
return d.toISOString();
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const createEntry = (index = 0): Result => {
|
|
35
|
-
return {
|
|
36
|
-
id: `${index + 100000}#0001`,
|
|
37
|
-
createdOn: createCreatedOn(index),
|
|
38
|
-
createdBy: {
|
|
39
|
-
id: "userId",
|
|
40
|
-
type: "admin",
|
|
41
|
-
displayName: "Admin"
|
|
42
|
-
},
|
|
43
|
-
values: {
|
|
44
|
-
title: `Title #${String(index).padStart(5, "t")}`,
|
|
45
|
-
options: Array.from({ length: 100 }).map((_, optionIndex) => {
|
|
46
|
-
return {
|
|
47
|
-
title: `Option #${index + optionIndex + 1}`,
|
|
48
|
-
value: index + optionIndex + 1
|
|
49
|
-
};
|
|
50
|
-
}),
|
|
51
|
-
variant: {
|
|
52
|
-
title: `Variant title ${String(index).padStart(5, "a")}`,
|
|
53
|
-
specifications: [
|
|
54
|
-
{
|
|
55
|
-
key: `Specification #${index === 0 ? 1 : index}`,
|
|
56
|
-
value: `${index + 100}`,
|
|
57
|
-
info: {
|
|
58
|
-
images: {
|
|
59
|
-
files: ["image1.jpg", "image2.jpg", "image3.jpg", "image4.jpg"]
|
|
60
|
-
},
|
|
61
|
-
tags: [
|
|
62
|
-
{
|
|
63
|
-
key: "size",
|
|
64
|
-
value: 55
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
key: "weight",
|
|
68
|
-
value: 105
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
key: "price",
|
|
72
|
-
value: 999
|
|
73
|
-
}
|
|
74
|
-
]
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
key: "Specification #2",
|
|
79
|
-
value: "2"
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
key: "Specification #3",
|
|
83
|
-
value: "3",
|
|
84
|
-
info: {
|
|
85
|
-
images: {
|
|
86
|
-
files: ["image31.jpg", "image32.jpg", "image33.jpg", "image34.jpg"]
|
|
87
|
-
},
|
|
88
|
-
tags: [
|
|
89
|
-
{
|
|
90
|
-
key: "size",
|
|
91
|
-
value: 355
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
key: "price",
|
|
95
|
-
value: 3999
|
|
96
|
-
}
|
|
97
|
-
]
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
]
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export const createEntries = (amount: number) => {
|
|
107
|
-
return [...Array(amount)].map((_, index) => {
|
|
108
|
-
return createEntry(index);
|
|
109
|
-
});
|
|
110
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { CmsModelField } from "@webiny/api-headless-cms/types";
|
|
3
|
-
import { createPlainObjectPathPlugin } from "~/path/plainObject";
|
|
4
|
-
|
|
5
|
-
describe("dynamodb path plain object", () => {
|
|
6
|
-
it("should get the plain object path", () => {
|
|
7
|
-
const plugin = createPlainObjectPathPlugin();
|
|
8
|
-
|
|
9
|
-
const result = plugin.createPath({
|
|
10
|
-
field: {
|
|
11
|
-
storageId: "authors",
|
|
12
|
-
settings: {
|
|
13
|
-
path: "createdBy.id"
|
|
14
|
-
}
|
|
15
|
-
} as unknown as CmsModelField
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
expect(result).toEqual("createdBy.id");
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("should throw an error when no path in the settings", () => {
|
|
22
|
-
const plugin = createPlainObjectPathPlugin();
|
|
23
|
-
|
|
24
|
-
expect(() => {
|
|
25
|
-
plugin.createPath({
|
|
26
|
-
field: {
|
|
27
|
-
settings: {}
|
|
28
|
-
} as unknown as CmsModelField
|
|
29
|
-
});
|
|
30
|
-
}).toThrow("Missing path settings value.");
|
|
31
|
-
});
|
|
32
|
-
});
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { createDatetimeTransformValuePlugin } from "~/transforms/datetime";
|
|
3
|
-
import { CmsModelField } from "@webiny/api-headless-cms/types";
|
|
4
|
-
|
|
5
|
-
const createField = (fieldType: string): CmsModelField => {
|
|
6
|
-
return {
|
|
7
|
-
id: "storageId",
|
|
8
|
-
storageId: "storageId",
|
|
9
|
-
type: "datetime",
|
|
10
|
-
settings: {
|
|
11
|
-
type: fieldType
|
|
12
|
-
}
|
|
13
|
-
} as unknown as CmsModelField;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
describe("dynamodb transform datetime", () => {
|
|
17
|
-
const correctValues: [string | Date, string, number][] = [
|
|
18
|
-
[new Date("Thu, 13 May 2021 12:32:33.892 GMT"), "date", 1620909153892],
|
|
19
|
-
[new Date("2021-05-13T12:32:33.892Z"), "date", 1620909153892],
|
|
20
|
-
["2021-05-13T12:32:33.892Z", "date", 1620909153892],
|
|
21
|
-
["13:57:22", "time", 50242000],
|
|
22
|
-
["13:57", "time", 50220000],
|
|
23
|
-
["13:57.481", "time", 50220481],
|
|
24
|
-
["13:57:22.581", "time", 50242581]
|
|
25
|
-
];
|
|
26
|
-
it.each(correctValues)(
|
|
27
|
-
"should transform date or time into the milliseconds - %s",
|
|
28
|
-
(value: Date | string, fieldType: string, expected: number) => {
|
|
29
|
-
const plugin = createDatetimeTransformValuePlugin();
|
|
30
|
-
|
|
31
|
-
const result = plugin.transform({
|
|
32
|
-
field: createField(fieldType),
|
|
33
|
-
value
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
expect(result).toEqual(expected);
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
const incorrectTimeValues: [any][] = [
|
|
41
|
-
[{}],
|
|
42
|
-
[[]],
|
|
43
|
-
[""],
|
|
44
|
-
[
|
|
45
|
-
function () {
|
|
46
|
-
return 1;
|
|
47
|
-
}
|
|
48
|
-
],
|
|
49
|
-
[true]
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
it.each(incorrectTimeValues)(
|
|
53
|
-
"should throw an error when trying to transform time field but value is not a string or a number",
|
|
54
|
-
value => {
|
|
55
|
-
expect.assertions(1);
|
|
56
|
-
const plugin = createDatetimeTransformValuePlugin();
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
const result = plugin.transform({
|
|
60
|
-
field: createField("time"),
|
|
61
|
-
value
|
|
62
|
-
});
|
|
63
|
-
expect(result).toEqual("SHOULD NOT HAPPEN");
|
|
64
|
-
} catch (ex) {
|
|
65
|
-
expect(ex.message).toEqual(
|
|
66
|
-
"Field value must be a string because field is defined as time."
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
|
-
});
|
package/dist/package.json
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@webiny/api-headless-cms-storage",
|
|
3
|
-
"version": "0.0.0",
|
|
4
|
-
"main": "dist/index.js",
|
|
5
|
-
"types": "dist/index.d.ts",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "https://github.com/webiny/webiny-js.git",
|
|
10
|
-
"directory": "packages/api-headless-cms-storage"
|
|
11
|
-
},
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"@webiny/api": "0.0.0",
|
|
14
|
-
"@webiny/api-headless-cms": "0.0.0",
|
|
15
|
-
"@webiny/db-utils": "0.0.0",
|
|
16
|
-
"@webiny/di": "1.0.2",
|
|
17
|
-
"@webiny/error": "0.0.0",
|
|
18
|
-
"@webiny/feature": "0.0.0",
|
|
19
|
-
"@webiny/plugins": "0.0.0",
|
|
20
|
-
"date-fns": "4.4.0",
|
|
21
|
-
"dot-prop": "10.2.0",
|
|
22
|
-
"lodash": "4.18.1"
|
|
23
|
-
},
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"@webiny/build-tools": "0.0.0",
|
|
26
|
-
"@webiny/project-utils": "0.0.0",
|
|
27
|
-
"typescript": "7.0.2",
|
|
28
|
-
"vitest": "4.1.10"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
CmsEntry,
|
|
3
|
-
CmsEntryUniqueValue,
|
|
4
|
-
CmsEntryValues,
|
|
5
|
-
CmsModel,
|
|
6
|
-
CmsModelField,
|
|
7
|
-
StorageOperationsCmsModel
|
|
8
|
-
} from "@webiny/api-headless-cms/types/index.js";
|
|
9
|
-
import type { Container } from "@webiny/di";
|
|
10
|
-
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
11
|
-
import { getBaseFieldType } from "@webiny/api-headless-cms/utils/getBaseFieldType.js";
|
|
12
|
-
import type { StorageTransformRegistry } from "@webiny/api-headless-cms/exports/api/cms/storage.js";
|
|
13
|
-
import type { FilterItemFromStorage } from "../filtering/fields/types.js";
|
|
14
|
-
|
|
15
|
-
/* Creates a lazy-cached getter for the storage representation of a CMS model. */
|
|
16
|
-
export const createStorageModelAccessor = (container: Container) => {
|
|
17
|
-
let cached: CmsStorageModelProvider.Interface | undefined;
|
|
18
|
-
|
|
19
|
-
const getProvider = () => {
|
|
20
|
-
if (!cached) {
|
|
21
|
-
cached = container.resolve(CmsStorageModelProvider);
|
|
22
|
-
}
|
|
23
|
-
return cached;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const getModel = <T extends CmsEntryValues = CmsEntryValues>(
|
|
27
|
-
model: CmsModel
|
|
28
|
-
): StorageOperationsCmsModel<T> => {
|
|
29
|
-
return getProvider().getModel<T>(model);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
return { getModel };
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/* Creates a fromStorage transform callable for a given model. */
|
|
36
|
-
export const createStorageTransformCallable = (
|
|
37
|
-
storageTransformRegistry: StorageTransformRegistry.Interface,
|
|
38
|
-
model: StorageOperationsCmsModel
|
|
39
|
-
): FilterItemFromStorage => {
|
|
40
|
-
return async (field: CmsModelField, value: unknown) => {
|
|
41
|
-
const fieldType = getBaseFieldType(field);
|
|
42
|
-
const storageTransform = storageTransformRegistry.get(fieldType);
|
|
43
|
-
|
|
44
|
-
if (!storageTransform) {
|
|
45
|
-
return value;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const result = await storageTransform.fromStorage({
|
|
49
|
-
model,
|
|
50
|
-
field,
|
|
51
|
-
value,
|
|
52
|
-
getStorageTransform(ft: string) {
|
|
53
|
-
return storageTransformRegistry.get(ft) || storageTransformRegistry.get("*")!;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
return result;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/* Aggregates unique values for a given field across a list of CMS entries. */
|
|
62
|
-
export const aggregateUniqueFieldValues = <T extends CmsEntryValues = CmsEntryValues>(
|
|
63
|
-
items: CmsEntry<T>[],
|
|
64
|
-
fieldId: string
|
|
65
|
-
): CmsEntryUniqueValue[] => {
|
|
66
|
-
const result: Record<string, CmsEntryUniqueValue> = {};
|
|
67
|
-
|
|
68
|
-
for (const item of items) {
|
|
69
|
-
const fieldValue = item.values[fieldId] as string[] | string | undefined;
|
|
70
|
-
|
|
71
|
-
if (fieldValue == null) {
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
|
|
76
|
-
|
|
77
|
-
if (values.length === 0) {
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
for (const value of values) {
|
|
82
|
-
result[value] = {
|
|
83
|
-
value,
|
|
84
|
-
count: (result[value]?.count || 0) + 1
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return Object.values(result)
|
|
90
|
-
.sort((a, b) => (a.value > b.value ? 1 : b.value > a.value ? -1 : 0))
|
|
91
|
-
.sort((a, b) => b.count - a.count);
|
|
92
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { createFeature } from "@webiny/feature/api/index.js";
|
|
2
|
-
import { FieldFilterPathRegistry } from "./fieldFilterPath/abstractions.js";
|
|
3
|
-
import { FieldFilterValueTransformRegistry } from "./fieldFilterValueTransform/abstractions.js";
|
|
4
|
-
import { FieldFilterCreateRegistry } from "./fieldFilterCreate/abstractions.js";
|
|
5
|
-
import { FieldSortingRegistry } from "./fieldSorting/abstractions.js";
|
|
6
|
-
import { FieldFilterPathRegistryImpl } from "./fieldFilterPath/FieldFilterPathRegistry.js";
|
|
7
|
-
import { FieldFilterValueTransformRegistryImpl } from "./fieldFilterValueTransform/FieldFilterValueTransformRegistry.js";
|
|
8
|
-
import { FieldFilterCreateRegistryImpl } from "./fieldFilterCreate/FieldFilterCreateRegistry.js";
|
|
9
|
-
import { FieldSortingRegistryImpl } from "./fieldSorting/FieldSortingRegistry.js";
|
|
10
|
-
import { createPlainObjectPathHandler } from "../handlers/plainObjectPathHandler.js";
|
|
11
|
-
import { createLocationFolderIdPathHandler } from "../handlers/locationFolderIdPathHandler.js";
|
|
12
|
-
import { createDatetimeTransformHandler } from "../handlers/datetimeTransformHandler.js";
|
|
13
|
-
import { createDefaultFilterCreateHandler } from "../handlers/defaultFilterCreateHandler.js";
|
|
14
|
-
import { createRefFilterCreateHandler } from "../handlers/refFilterCreateHandler.js";
|
|
15
|
-
import { createObjectFilterCreateHandler } from "../handlers/objectFilterCreateHandler.js";
|
|
16
|
-
import { createSearchableJsonFilterCreateHandler } from "../handlers/searchableJsonFilterCreateHandler.js";
|
|
17
|
-
|
|
18
|
-
export const FilterRegistriesFeature = createFeature({
|
|
19
|
-
name: "cms.storage.filterRegistries",
|
|
20
|
-
register: container => {
|
|
21
|
-
const pathRegistry = new FieldFilterPathRegistryImpl();
|
|
22
|
-
pathRegistry.register("plainObject", createPlainObjectPathHandler());
|
|
23
|
-
pathRegistry.register("text", createLocationFolderIdPathHandler());
|
|
24
|
-
container.registerInstance(FieldFilterPathRegistry, pathRegistry);
|
|
25
|
-
|
|
26
|
-
const transformRegistry = new FieldFilterValueTransformRegistryImpl();
|
|
27
|
-
transformRegistry.register("datetime", createDatetimeTransformHandler());
|
|
28
|
-
container.registerInstance(FieldFilterValueTransformRegistry, transformRegistry);
|
|
29
|
-
|
|
30
|
-
const filterCreateRegistry = new FieldFilterCreateRegistryImpl();
|
|
31
|
-
filterCreateRegistry.register("*", createDefaultFilterCreateHandler());
|
|
32
|
-
filterCreateRegistry.register("ref", createRefFilterCreateHandler());
|
|
33
|
-
filterCreateRegistry.register("object", createObjectFilterCreateHandler());
|
|
34
|
-
filterCreateRegistry.register("searchable-json", createSearchableJsonFilterCreateHandler());
|
|
35
|
-
container.registerInstance(FieldFilterCreateRegistry, filterCreateRegistry);
|
|
36
|
-
|
|
37
|
-
const sortingRegistry = new FieldSortingRegistryImpl();
|
|
38
|
-
container.registerInstance(FieldSortingRegistry, sortingRegistry);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import WebinyError from "@webiny/error";
|
|
2
|
-
import type { FieldFilterCreateRegistry } from "./abstractions.js";
|
|
3
|
-
|
|
4
|
-
export class FieldFilterCreateRegistryImpl implements FieldFilterCreateRegistry.Interface {
|
|
5
|
-
private readonly handlers = new Map<string, FieldFilterCreateRegistry.Handler>();
|
|
6
|
-
|
|
7
|
-
public register(fieldType: string, handler: FieldFilterCreateRegistry.Handler): void {
|
|
8
|
-
this.handlers.set(fieldType, handler);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
public get(fieldType: string): FieldFilterCreateRegistry.Handler | undefined {
|
|
12
|
-
return this.handlers.get(fieldType);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
public getDefault(): FieldFilterCreateRegistry.Handler {
|
|
16
|
-
const handler = this.handlers.get("*");
|
|
17
|
-
if (!handler) {
|
|
18
|
-
throw new WebinyError(
|
|
19
|
-
"No default filter create handler registered.",
|
|
20
|
-
"MISSING_DEFAULT_HANDLER"
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
return handler;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Abstraction } from "@webiny/di";
|
|
2
|
-
import type { Field } from "../../filtering/fields/types.js";
|
|
3
|
-
import type { ValueFilterRegistry } from "@webiny/db-utils";
|
|
4
|
-
import type { FieldFilterValueTransformRegistry } from "../fieldFilterValueTransform/abstractions.js";
|
|
5
|
-
|
|
6
|
-
export interface IFieldFilterCreateResult {
|
|
7
|
-
field: Field;
|
|
8
|
-
path: string;
|
|
9
|
-
fieldPathId: string;
|
|
10
|
-
filter: ValueFilterRegistry.Filter;
|
|
11
|
-
negate: boolean;
|
|
12
|
-
compareValue: any;
|
|
13
|
-
transformValue: <I = any, O = any>(value: I) => O;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface IFieldFilterCreateParams<T = any> {
|
|
17
|
-
key: string;
|
|
18
|
-
value: T;
|
|
19
|
-
field: Field;
|
|
20
|
-
fields: Record<string, Field>;
|
|
21
|
-
operation: string;
|
|
22
|
-
valueFilterRegistry: ValueFilterRegistry.Interface;
|
|
23
|
-
transformRegistry: FieldFilterValueTransformRegistry.Interface;
|
|
24
|
-
getHandler: (fieldType: string) => IFieldFilterCreateHandler;
|
|
25
|
-
negate: boolean;
|
|
26
|
-
compareValue: any;
|
|
27
|
-
transformValue: <I = any, O = any>(value: I) => O;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface IFieldFilterCreateHandler {
|
|
31
|
-
create(
|
|
32
|
-
params: IFieldFilterCreateParams
|
|
33
|
-
): null | IFieldFilterCreateResult | IFieldFilterCreateResult[];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface IFieldFilterCreateRegistry {
|
|
37
|
-
register(fieldType: string, handler: IFieldFilterCreateHandler): void;
|
|
38
|
-
get(fieldType: string): IFieldFilterCreateHandler | undefined;
|
|
39
|
-
getDefault(): IFieldFilterCreateHandler;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export const FieldFilterCreateRegistry = new Abstraction<IFieldFilterCreateRegistry>(
|
|
43
|
-
"Cms/Storage/FieldFilterCreateRegistry"
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
export namespace FieldFilterCreateRegistry {
|
|
47
|
-
export type Interface = IFieldFilterCreateRegistry;
|
|
48
|
-
export type Handler = IFieldFilterCreateHandler;
|
|
49
|
-
export type Params = IFieldFilterCreateParams;
|
|
50
|
-
export type Result = IFieldFilterCreateResult;
|
|
51
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { FieldFilterPathRegistry } from "./abstractions.js";
|
|
2
|
-
|
|
3
|
-
export class FieldFilterPathRegistryImpl implements FieldFilterPathRegistry.Interface {
|
|
4
|
-
private readonly handlers = new Map<string, FieldFilterPathRegistry.Handler>();
|
|
5
|
-
|
|
6
|
-
public register(fieldType: string, handler: FieldFilterPathRegistry.Handler): void {
|
|
7
|
-
this.handlers.set(fieldType, handler);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
public get(fieldType: string): FieldFilterPathRegistry.Handler | undefined {
|
|
11
|
-
return this.handlers.get(fieldType);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Abstraction } from "@webiny/di";
|
|
2
|
-
import type { CmsModelField } from "@webiny/api-headless-cms/types/index.js";
|
|
3
|
-
import type { CreatePathCallableParams } from "../../plugins/CmsEntryFieldFilterPathPlugin.js";
|
|
4
|
-
|
|
5
|
-
export interface IFieldFilterPathHandler {
|
|
6
|
-
canUse(field: Pick<CmsModelField, "fieldId" | "type">, parents: string[]): boolean;
|
|
7
|
-
createPath(params: CreatePathCallableParams): string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface IFieldFilterPathRegistry {
|
|
11
|
-
register(fieldType: string, handler: IFieldFilterPathHandler): void;
|
|
12
|
-
get(fieldType: string): IFieldFilterPathHandler | undefined;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const FieldFilterPathRegistry = new Abstraction<IFieldFilterPathRegistry>(
|
|
16
|
-
"Cms/Storage/FieldFilterPathRegistry"
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
export namespace FieldFilterPathRegistry {
|
|
20
|
-
export type Interface = IFieldFilterPathRegistry;
|
|
21
|
-
export type Handler = IFieldFilterPathHandler;
|
|
22
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { FieldFilterValueTransformRegistry } from "./abstractions.js";
|
|
2
|
-
|
|
3
|
-
export class FieldFilterValueTransformRegistryImpl
|
|
4
|
-
implements FieldFilterValueTransformRegistry.Interface
|
|
5
|
-
{
|
|
6
|
-
private readonly handlers = new Map<string, FieldFilterValueTransformRegistry.Handler>();
|
|
7
|
-
|
|
8
|
-
public register(fieldType: string, handler: FieldFilterValueTransformRegistry.Handler): void {
|
|
9
|
-
this.handlers.set(fieldType, handler);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
public get(fieldType: string): FieldFilterValueTransformRegistry.Handler | undefined {
|
|
13
|
-
return this.handlers.get(fieldType);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Abstraction } from "@webiny/di";
|
|
2
|
-
import type { CmsFieldFilterValueTransformParams } from "../../plugins/CmsFieldFilterValueTransformPlugin.js";
|
|
3
|
-
|
|
4
|
-
export interface IFieldFilterValueTransformHandler {
|
|
5
|
-
transform(params: CmsFieldFilterValueTransformParams): any;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface IFieldFilterValueTransformRegistry {
|
|
9
|
-
register(fieldType: string, handler: IFieldFilterValueTransformHandler): void;
|
|
10
|
-
get(fieldType: string): IFieldFilterValueTransformHandler | undefined;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const FieldFilterValueTransformRegistry =
|
|
14
|
-
new Abstraction<IFieldFilterValueTransformRegistry>(
|
|
15
|
-
"Cms/Storage/FieldFilterValueTransformRegistry"
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
export namespace FieldFilterValueTransformRegistry {
|
|
19
|
-
export type Interface = IFieldFilterValueTransformRegistry;
|
|
20
|
-
export type Handler = IFieldFilterValueTransformHandler;
|
|
21
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { FieldSortingRegistry } from "./abstractions.js";
|
|
2
|
-
|
|
3
|
-
export class FieldSortingRegistryImpl implements FieldSortingRegistry.Interface {
|
|
4
|
-
private readonly handlers: FieldSortingRegistry.Handler[] = [];
|
|
5
|
-
|
|
6
|
-
public register(handler: FieldSortingRegistry.Handler): void {
|
|
7
|
-
this.handlers.push(handler);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
public find(
|
|
11
|
-
params: FieldSortingRegistry.CanUseParams
|
|
12
|
-
): FieldSortingRegistry.Handler | undefined {
|
|
13
|
-
for (let i = this.handlers.length - 1; i >= 0; i--) {
|
|
14
|
-
if (this.handlers[i].canUse(params)) {
|
|
15
|
-
return this.handlers[i];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
}
|