@webiny/api-headless-cms-storage 6.6.0-alpha.0 → 6.6.0-alpha.10
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/{dist/cms → cms}/storageHelpers.js +3 -3
- package/cms/storageHelpers.js.map +1 -0
- package/features/FilterRegistriesFeature.d.ts +9 -0
- package/features/FilterRegistriesFeature.js +17 -0
- package/features/FilterRegistriesFeature.js.map +1 -0
- package/features/fieldFilterCreate/DefaultFieldFilterCreateRegistry.d.ts +9 -0
- package/features/fieldFilterCreate/DefaultFieldFilterCreateRegistry.js +26 -0
- package/features/fieldFilterCreate/DefaultFieldFilterCreateRegistry.js.map +1 -0
- package/features/fieldFilterPath/DefaultFieldFilterPathRegistry.d.ts +9 -0
- package/features/fieldFilterPath/DefaultFieldFilterPathRegistry.js +20 -0
- package/features/fieldFilterPath/DefaultFieldFilterPathRegistry.js.map +1 -0
- package/features/fieldFilterValueTransform/DefaultFieldFilterValueTransformRegistry.d.ts +9 -0
- package/features/fieldFilterValueTransform/DefaultFieldFilterValueTransformRegistry.js +17 -0
- package/features/fieldFilterValueTransform/DefaultFieldFilterValueTransformRegistry.js.map +1 -0
- package/features/fieldSorting/DefaultFieldSortingRegistry.d.ts +8 -0
- package/features/fieldSorting/DefaultFieldSortingRegistry.js +11 -0
- package/features/fieldSorting/DefaultFieldSortingRegistry.js.map +1 -0
- package/{dist/filtering → filtering}/fields/createFields.d.ts +2 -0
- package/{dist/filtering → filtering}/fields/createFields.js +2 -2
- package/filtering/fields/createFields.js.map +1 -0
- package/{dist/filtering → filtering}/fields/extractSort.js +1 -1
- package/{dist/filtering → filtering}/fields/extractSort.js.map +1 -1
- package/filtering/fields/systemFields.d.ts +5 -0
- package/{dist/filtering → filtering}/fields/systemFields.js +17 -1
- package/filtering/fields/systemFields.js.map +1 -0
- package/{dist/filtering → filtering}/filter.js +1 -1
- package/{dist/filtering → filtering}/filter.js.map +1 -1
- package/{dist/filtering → filtering}/getValue.js +2 -2
- package/{dist/filtering → filtering}/getValue.js.map +1 -1
- package/{dist/filtering → filtering}/sort.js +1 -1
- package/{dist/filtering → filtering}/sort.js.map +1 -1
- package/{dist/handlers → handlers}/datetimeTransformHandler.js +3 -3
- package/{dist/handlers → handlers}/datetimeTransformHandler.js.map +1 -1
- package/{dist/handlers → handlers}/locationFolderIdPathHandler.js +1 -1
- package/{dist/handlers → handlers}/locationFolderIdPathHandler.js.map +1 -1
- package/package.json +20 -15
- package/{dist/path → path}/locationFolderId.js +1 -1
- package/{dist/path → path}/locationFolderId.js.map +1 -1
- package/{dist/plugins → plugins}/CmsEntryFieldFilterPathPlugin.js +2 -2
- package/{dist/plugins → plugins}/CmsEntryFieldFilterPathPlugin.js.map +1 -1
- package/{dist/transforms → transforms}/datetime.js +3 -3
- package/{dist/transforms → transforms}/datetime.js.map +1 -1
- 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/cms/storageHelpers.js.map +0 -1
- package/dist/features/FilterRegistriesFeature.d.ts +0 -4
- package/dist/features/FilterRegistriesFeature.js +0 -39
- package/dist/features/FilterRegistriesFeature.js.map +0 -1
- package/dist/filtering/fields/createFields.js.map +0 -1
- package/dist/filtering/fields/systemFields.d.ts +0 -2
- package/dist/filtering/fields/systemFields.js.map +0 -1
- 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/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/extractSort.d.ts +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}/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}/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}/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}/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}/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}/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}/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/src/index.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/* Filtering. */
|
|
2
|
-
export { filter } from "./filtering/filter.js";
|
|
3
|
-
export { sort } from "./filtering/sort.js";
|
|
4
|
-
export { createFields } from "./filtering/fields/createFields.js";
|
|
5
|
-
export { createFilterCreatePlugins } from "./filtering/plugins/index.js";
|
|
6
|
-
export { createExpressions } from "./filtering/expressions/createExpressions.js";
|
|
7
|
-
export type { Expression, ExpressionCondition } from "./filtering/expressions/createExpressions.js";
|
|
8
|
-
export { getValue } from "./filtering/getValue.js";
|
|
9
|
-
|
|
10
|
-
/* Plugin base classes. */
|
|
11
|
-
export { CmsEntryFieldFilterPlugin } from "./plugins/CmsEntryFieldFilterPlugin.js";
|
|
12
|
-
export type { CmsEntryFieldFilterPluginCreateResponse } from "./plugins/CmsEntryFieldFilterPlugin.js";
|
|
13
|
-
export {
|
|
14
|
-
CmsEntryFieldSortingPlugin,
|
|
15
|
-
createCmsEntryFieldSortingPlugin
|
|
16
|
-
} from "./plugins/CmsEntryFieldSortingPlugin.js";
|
|
17
|
-
export { CmsEntryFieldFilterPathPlugin } from "./plugins/CmsEntryFieldFilterPathPlugin.js";
|
|
18
|
-
export type { CreatePathCallable } from "./plugins/CmsEntryFieldFilterPathPlugin.js";
|
|
19
|
-
export { CmsFieldFilterValueTransformPlugin } from "./plugins/CmsFieldFilterValueTransformPlugin.js";
|
|
20
|
-
|
|
21
|
-
/* Path + transform plugins. */
|
|
22
|
-
export { createPlainObjectPathPlugin } from "./path/plainObject.js";
|
|
23
|
-
export { createLocationFolderIdPathPlugin } from "./path/locationFolderId.js";
|
|
24
|
-
export { createDatetimeTransformValuePlugin } from "./transforms/datetime.js";
|
|
25
|
-
|
|
26
|
-
/* CMS storage helpers. */
|
|
27
|
-
export {
|
|
28
|
-
createStorageModelAccessor,
|
|
29
|
-
createStorageTransformCallable,
|
|
30
|
-
aggregateUniqueFieldValues
|
|
31
|
-
} from "./cms/storageHelpers.js";
|
|
32
|
-
|
|
33
|
-
/* Types. */
|
|
34
|
-
export type { Field } from "./filtering/fields/types.js";
|
|
35
|
-
export type { FilterItemFromStorage } from "./filtering/fields/types.js";
|
|
36
|
-
|
|
37
|
-
/* DI registries. */
|
|
38
|
-
export {
|
|
39
|
-
FieldFilterPathRegistry,
|
|
40
|
-
type IFieldFilterPathHandler,
|
|
41
|
-
type IFieldFilterPathRegistry
|
|
42
|
-
} from "./features/fieldFilterPath/abstractions.js";
|
|
43
|
-
export {
|
|
44
|
-
FieldFilterValueTransformRegistry,
|
|
45
|
-
type IFieldFilterValueTransformHandler,
|
|
46
|
-
type IFieldFilterValueTransformRegistry
|
|
47
|
-
} from "./features/fieldFilterValueTransform/abstractions.js";
|
|
48
|
-
export {
|
|
49
|
-
FieldFilterCreateRegistry,
|
|
50
|
-
type IFieldFilterCreateHandler,
|
|
51
|
-
type IFieldFilterCreateParams,
|
|
52
|
-
type IFieldFilterCreateRegistry,
|
|
53
|
-
type IFieldFilterCreateResult
|
|
54
|
-
} from "./features/fieldFilterCreate/abstractions.js";
|
|
55
|
-
export {
|
|
56
|
-
FieldSortingRegistry,
|
|
57
|
-
type IFieldSortingCanUseParams,
|
|
58
|
-
type IFieldSortingCreateParams,
|
|
59
|
-
type IFieldSortingHandler,
|
|
60
|
-
type IFieldSortingRegistry,
|
|
61
|
-
type IFieldSortingResult
|
|
62
|
-
} from "./features/fieldSorting/abstractions.js";
|
|
63
|
-
export { FilterRegistriesFeature } from "./features/FilterRegistriesFeature.js";
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/* File is @internal. */
|
|
2
|
-
import WebinyError from "@webiny/error";
|
|
3
|
-
import type { CreatePathCallable } from "../plugins/CmsEntryFieldFilterPathPlugin.js";
|
|
4
|
-
import { CmsEntryFieldFilterPathPlugin } from "../plugins/CmsEntryFieldFilterPathPlugin.js";
|
|
5
|
-
|
|
6
|
-
const createPath: CreatePathCallable = ({ field }) => {
|
|
7
|
-
const { path } = field.settings || {};
|
|
8
|
-
if (!path) {
|
|
9
|
-
throw new WebinyError("Missing path settings value.", "FIELD_SETTINGS_ERROR", {
|
|
10
|
-
field
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
return path;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const createLocationFolderIdPathPlugin = (): CmsEntryFieldFilterPathPlugin => {
|
|
17
|
-
return new CmsEntryFieldFilterPathPlugin({
|
|
18
|
-
fieldType: "text",
|
|
19
|
-
path: createPath,
|
|
20
|
-
canUse: (field, parents) => {
|
|
21
|
-
if (field.fieldId !== "folderId") {
|
|
22
|
-
return false;
|
|
23
|
-
} else if (!parents?.length) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
return parents[0] === "wbyAco_location";
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
};
|
package/src/path/plainObject.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/* File is @internal. */
|
|
2
|
-
import WebinyError from "@webiny/error";
|
|
3
|
-
import type { CreatePathCallable } from "../plugins/CmsEntryFieldFilterPathPlugin.js";
|
|
4
|
-
import { CmsEntryFieldFilterPathPlugin } from "../plugins/CmsEntryFieldFilterPathPlugin.js";
|
|
5
|
-
|
|
6
|
-
const createPath: CreatePathCallable = ({ field }) => {
|
|
7
|
-
const { path } = field.settings || {};
|
|
8
|
-
if (!path) {
|
|
9
|
-
throw new WebinyError("Missing path settings value.", "FIELD_SETTINGS_ERROR", {
|
|
10
|
-
field
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
return path;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const createPlainObjectPathPlugin = (): CmsEntryFieldFilterPathPlugin => {
|
|
17
|
-
return new CmsEntryFieldFilterPathPlugin({
|
|
18
|
-
fieldType: "plainObject",
|
|
19
|
-
path: createPath
|
|
20
|
-
});
|
|
21
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import WebinyError from "@webiny/error";
|
|
2
|
-
import { Plugin } from "@webiny/plugins/Plugin.js";
|
|
3
|
-
import type { CmsModelField } from "@webiny/api-headless-cms/types/index.js";
|
|
4
|
-
|
|
5
|
-
export interface CreatePathCallableParams {
|
|
6
|
-
field: Partial<CmsModelField> & Pick<CmsModelField, "fieldId" | "storageId" | "id">;
|
|
7
|
-
index?: number;
|
|
8
|
-
}
|
|
9
|
-
export interface CreatePathCallable {
|
|
10
|
-
(params: CreatePathCallableParams): string;
|
|
11
|
-
}
|
|
12
|
-
export interface CmsEntryFieldFilterPathPluginParams {
|
|
13
|
-
fieldType: string;
|
|
14
|
-
fieldId?: string[];
|
|
15
|
-
path: string | CreatePathCallable;
|
|
16
|
-
canUse?: (field: Pick<CmsModelField, "fieldId" | "type">, parents?: string[]) => boolean;
|
|
17
|
-
}
|
|
18
|
-
export class CmsEntryFieldFilterPathPlugin extends Plugin {
|
|
19
|
-
public static override readonly type: string = "cms-field-filter-path";
|
|
20
|
-
|
|
21
|
-
private readonly config: CmsEntryFieldFilterPathPluginParams;
|
|
22
|
-
|
|
23
|
-
public get fieldType(): string {
|
|
24
|
-
return this.config.fieldType;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public constructor(config: CmsEntryFieldFilterPathPluginParams) {
|
|
28
|
-
super();
|
|
29
|
-
|
|
30
|
-
this.config = config;
|
|
31
|
-
|
|
32
|
-
/* We expect error here because we know that `this.constructor.type` is defined, but TS does not. */
|
|
33
|
-
// @ts-expect-error
|
|
34
|
-
this.name = `${this.constructor.type}-${this.config.fieldType}`;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public canUse(field: Pick<CmsModelField, "fieldId" | "type">, parents: string[]): boolean {
|
|
38
|
-
if (field.type !== this.config.fieldType) {
|
|
39
|
-
return false;
|
|
40
|
-
} else if (this.config.canUse) {
|
|
41
|
-
return this.config.canUse(field, parents);
|
|
42
|
-
}
|
|
43
|
-
const fieldId = this.config.fieldId;
|
|
44
|
-
if (!fieldId || Array.isArray(fieldId) === false || fieldId.length === 0) {
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
return fieldId.includes(field.fieldId);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public createPath(params: CreatePathCallableParams): string {
|
|
51
|
-
if (typeof this.config.path === "function") {
|
|
52
|
-
return this.config.path(params);
|
|
53
|
-
} else if (typeof this.config.path === "string") {
|
|
54
|
-
return this.config.path;
|
|
55
|
-
}
|
|
56
|
-
throw new WebinyError(`Missing path in "${this.name}" plugin.`);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
import type { Field } from "~/filtering/fields/types.js";
|
|
3
|
-
import type { ICmsFieldFilterValueTransformPlugin } from "./CmsFieldFilterValueTransformPlugin.js";
|
|
4
|
-
import { ValueFilterRegistry } from "@webiny/db-utils";
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
* This plugin is used to create the filter.
|
|
8
|
-
* Internally we have default one + the one for the reference field - because it is actually an object when filtering.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
interface CmsEntryFieldFilterPluginParams<T = any> {
|
|
12
|
-
fieldType: string;
|
|
13
|
-
create: (
|
|
14
|
-
params: CmsEntryFieldFilterPluginCreateParams<T>
|
|
15
|
-
) => null | CmsEntryFieldFilterPluginCreateResponse | CmsEntryFieldFilterPluginCreateResponse[];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface CmsEntryFieldFilterPluginCreateParams<T = any> {
|
|
19
|
-
key: string;
|
|
20
|
-
value: T;
|
|
21
|
-
field: Field;
|
|
22
|
-
fields: Record<string, Field>;
|
|
23
|
-
operation: string;
|
|
24
|
-
valueFilterRegistry: ValueFilterRegistry.Interface;
|
|
25
|
-
transformValuePlugins: Record<string, ICmsFieldFilterValueTransformPlugin>;
|
|
26
|
-
getFilterCreatePlugin: (type: string) => CmsEntryFieldFilterPlugin;
|
|
27
|
-
negate: boolean;
|
|
28
|
-
compareValue: any;
|
|
29
|
-
transformValue: <I = any, O = any>(value: I) => O;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface CmsEntryFieldFilterPluginCreateResponse {
|
|
33
|
-
field: Field;
|
|
34
|
-
path: string;
|
|
35
|
-
fieldPathId: string;
|
|
36
|
-
filter: ValueFilterRegistry.Filter;
|
|
37
|
-
negate: boolean;
|
|
38
|
-
compareValue: any;
|
|
39
|
-
transformValue: <I = any, O = any>(value: I) => O;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export class CmsEntryFieldFilterPlugin<T = any> extends Plugin {
|
|
43
|
-
public static override readonly type: string = "cms.dynamodb.entry.field.filter";
|
|
44
|
-
public static readonly ALL: string = "*";
|
|
45
|
-
|
|
46
|
-
private readonly config: CmsEntryFieldFilterPluginParams<T>;
|
|
47
|
-
|
|
48
|
-
public readonly fieldType: string;
|
|
49
|
-
|
|
50
|
-
public constructor(config: CmsEntryFieldFilterPluginParams<T>) {
|
|
51
|
-
super();
|
|
52
|
-
this.config = config;
|
|
53
|
-
this.fieldType = this.config.fieldType;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public create(params: CmsEntryFieldFilterPluginCreateParams<T>) {
|
|
57
|
-
return this.config.create(params);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
import type { Field } from "~/filtering/fields/types.js";
|
|
3
|
-
import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
4
|
-
|
|
5
|
-
interface CmsEntryFieldSortingPluginCanUseParams {
|
|
6
|
-
model: CmsModel;
|
|
7
|
-
field?: Field;
|
|
8
|
-
fieldId: string;
|
|
9
|
-
order: "ASC" | "DESC";
|
|
10
|
-
/*
|
|
11
|
-
* Combination of fieldId and sortBy.
|
|
12
|
-
*
|
|
13
|
-
* example: id_ASC or createdBy_DESC
|
|
14
|
-
*/
|
|
15
|
-
sortBy: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface CmsEntryFieldSortingPluginCreateSortParams {
|
|
19
|
-
model: CmsModel;
|
|
20
|
-
fieldId: string;
|
|
21
|
-
order: "ASC" | "DESC";
|
|
22
|
-
sortBy: string;
|
|
23
|
-
fields: Record<string, Field>;
|
|
24
|
-
field?: Field;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface CmsEntryFieldSortingPluginCreateSortResult {
|
|
28
|
-
valuePath: string;
|
|
29
|
-
reverse: boolean;
|
|
30
|
-
fieldId: string;
|
|
31
|
-
field: Field;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
interface CmsEntryFieldSortingPluginConfig {
|
|
35
|
-
createSort: (
|
|
36
|
-
params: CmsEntryFieldSortingPluginCreateSortParams
|
|
37
|
-
) => CmsEntryFieldSortingPluginCreateSortResult;
|
|
38
|
-
canUse: (params: CmsEntryFieldSortingPluginCanUseParams) => boolean;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export class CmsEntryFieldSortingPlugin extends Plugin {
|
|
42
|
-
public static override readonly type: string = "cms.entry.field.sorting";
|
|
43
|
-
private readonly config: CmsEntryFieldSortingPluginConfig;
|
|
44
|
-
|
|
45
|
-
public constructor(config: CmsEntryFieldSortingPluginConfig) {
|
|
46
|
-
super();
|
|
47
|
-
this.config = config;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public canUse(params: CmsEntryFieldSortingPluginCanUseParams): boolean {
|
|
51
|
-
return this.config.canUse(params);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
public createSort(
|
|
55
|
-
params: CmsEntryFieldSortingPluginCreateSortParams
|
|
56
|
-
): CmsEntryFieldSortingPluginCreateSortResult {
|
|
57
|
-
return this.config.createSort(params);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export const createCmsEntryFieldSortingPlugin = (config: CmsEntryFieldSortingPluginConfig) => {
|
|
62
|
-
return new CmsEntryFieldSortingPlugin(config);
|
|
63
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
import type { CmsModelField } from "@webiny/api-headless-cms/types/index.js";
|
|
3
|
-
import type { Plugin as IPlugin } from "@webiny/plugins/types.js";
|
|
4
|
-
|
|
5
|
-
export interface CmsFieldFilterValueTransformParams {
|
|
6
|
-
/* A field which value we are transforming. */
|
|
7
|
-
field: Partial<CmsModelField> &
|
|
8
|
-
Pick<CmsModelField, "id" | "storageId" | "fieldId" | "settings">;
|
|
9
|
-
value: any;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface ICmsFieldFilterValueTransformPlugin extends IPlugin {
|
|
13
|
-
/* A plugin type. */
|
|
14
|
-
type: "cms-field-filter-value-transform";
|
|
15
|
-
/* A field type this plugin is for. */
|
|
16
|
-
fieldType: string;
|
|
17
|
-
/* Transform method which expect field definition and value to transform. */
|
|
18
|
-
transform: (params: CmsFieldFilterValueTransformParams) => any;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
type CmsFieldFilterValueTransformPluginParams = Omit<ICmsFieldFilterValueTransformPlugin, "type">;
|
|
22
|
-
|
|
23
|
-
export class CmsFieldFilterValueTransformPlugin
|
|
24
|
-
extends Plugin
|
|
25
|
-
implements Omit<ICmsFieldFilterValueTransformPlugin, "type">
|
|
26
|
-
{
|
|
27
|
-
public static override type = "cms-field-filter-value-transform";
|
|
28
|
-
|
|
29
|
-
private readonly config: CmsFieldFilterValueTransformPluginParams;
|
|
30
|
-
|
|
31
|
-
public get fieldType(): string {
|
|
32
|
-
return this.config.fieldType;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public get transform(): CmsFieldFilterValueTransformPluginParams["transform"] {
|
|
36
|
-
return this.config.transform;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
public constructor(config: CmsFieldFilterValueTransformPluginParams) {
|
|
40
|
-
super();
|
|
41
|
-
this.config = config;
|
|
42
|
-
}
|
|
43
|
-
}
|
package/src/plugins/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { CmsEntryFieldFilterPathPlugin } from "./CmsEntryFieldFilterPathPlugin.js";
|
|
2
|
-
export type { CreatePathCallable } from "./CmsEntryFieldFilterPathPlugin.js";
|
|
3
|
-
export {
|
|
4
|
-
CmsEntryFieldSortingPlugin,
|
|
5
|
-
createCmsEntryFieldSortingPlugin
|
|
6
|
-
} from "./CmsEntryFieldSortingPlugin.js";
|
|
7
|
-
export { CmsEntryFieldFilterPlugin } from "./CmsEntryFieldFilterPlugin.js";
|
|
8
|
-
export type { CmsEntryFieldFilterPluginCreateResponse } from "./CmsEntryFieldFilterPlugin.js";
|
|
9
|
-
export { CmsFieldFilterValueTransformPlugin } from "./CmsFieldFilterValueTransformPlugin.js";
|
|
10
|
-
export type { ICmsFieldFilterValueTransformPlugin } from "./CmsFieldFilterValueTransformPlugin.js";
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/* File is @internal. */
|
|
2
|
-
import { parseISO } from "date-fns";
|
|
3
|
-
import {
|
|
4
|
-
CmsFieldFilterValueTransformPlugin,
|
|
5
|
-
CmsFieldFilterValueTransformParams
|
|
6
|
-
} from "../plugins/CmsFieldFilterValueTransformPlugin.js";
|
|
7
|
-
|
|
8
|
-
const transformTime = (value: any): number => {
|
|
9
|
-
if (value === undefined || value === null) {
|
|
10
|
-
throw new Error(`Time value is null or undefined.`);
|
|
11
|
-
} else if (typeof value === "boolean" || value === "" || Array.isArray(value)) {
|
|
12
|
-
throw new Error("Field value must be a string because field is defined as time.");
|
|
13
|
-
}
|
|
14
|
-
const converted = Number(`${value}`);
|
|
15
|
-
if (typeof value === "number" || isNaN(converted) === false) {
|
|
16
|
-
return Number(value);
|
|
17
|
-
} else if (typeof value !== "string") {
|
|
18
|
-
throw new Error("Field value must be a string because field is defined as time.");
|
|
19
|
-
}
|
|
20
|
-
/* This is for the time format, eg. 12:36:25 or 12:36:25.881. */
|
|
21
|
-
const [time, milliseconds = 0] = value.split(".");
|
|
22
|
-
const values = time.split(":").map(Number);
|
|
23
|
-
if (values.length < 2) {
|
|
24
|
-
throw new Error("Time must contain at least hours and minutes.");
|
|
25
|
-
}
|
|
26
|
-
const [hours, minutes, seconds = 0] = values;
|
|
27
|
-
return (hours * 60 * 60 + minutes * 60 + seconds) * 1000 + Number(milliseconds);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const transformDateTime = (value: any): number | null => {
|
|
31
|
-
if (value === null || value === undefined) {
|
|
32
|
-
return null;
|
|
33
|
-
} else if (typeof value === "string") {
|
|
34
|
-
const parsedDateTime = parseISO(value).getTime();
|
|
35
|
-
if (isNaN(parsedDateTime) === false) {
|
|
36
|
-
return parsedDateTime;
|
|
37
|
-
}
|
|
38
|
-
} else if (value instanceof Date || typeof (value as unknown as Date)?.getTime === "function") {
|
|
39
|
-
/* In this case we assume this is a date object, and we just get the time. */
|
|
40
|
-
return value.getTime();
|
|
41
|
-
}
|
|
42
|
-
/* No point in throwing an error here, as this would cause the entire transformation to fail. Instead, we just log a warning and return null. */
|
|
43
|
-
console.warn("Could not parse given dateTime value.", "PARSE_DATE_ERROR", {
|
|
44
|
-
value
|
|
45
|
-
});
|
|
46
|
-
return null;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const createDatetimeTransformValuePlugin = (): CmsFieldFilterValueTransformPlugin => {
|
|
50
|
-
return new CmsFieldFilterValueTransformPlugin({
|
|
51
|
-
name: "cms-field-value-filter-transform-datetime",
|
|
52
|
-
fieldType: "datetime",
|
|
53
|
-
/* Always transform into the milliseconds. */
|
|
54
|
-
transform: ({ field, value }: CmsFieldFilterValueTransformParams) => {
|
|
55
|
-
const { type } = field.settings || {};
|
|
56
|
-
if (type === "time") {
|
|
57
|
-
return transformTime(value);
|
|
58
|
-
}
|
|
59
|
-
return transformDateTime(value);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
};
|
package/tsconfig.build.json
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.build.json",
|
|
3
|
-
"include": ["src"],
|
|
4
|
-
"references": [
|
|
5
|
-
{ "path": "../api/tsconfig.build.json" },
|
|
6
|
-
{ "path": "../api-headless-cms/tsconfig.build.json" },
|
|
7
|
-
{ "path": "../db-utils/tsconfig.build.json" },
|
|
8
|
-
{ "path": "../error/tsconfig.build.json" },
|
|
9
|
-
{ "path": "../feature/tsconfig.build.json" },
|
|
10
|
-
{ "path": "../plugins/tsconfig.build.json" }
|
|
11
|
-
],
|
|
12
|
-
"compilerOptions": {
|
|
13
|
-
"rootDir": "./src",
|
|
14
|
-
"outDir": "./dist",
|
|
15
|
-
"declarationDir": "./dist",
|
|
16
|
-
"paths": {
|
|
17
|
-
"~/*": ["./src/*"],
|
|
18
|
-
"~tests/*": ["./__tests__/*"],
|
|
19
|
-
"@webiny/api/*": ["../api/src/*"],
|
|
20
|
-
"@webiny/api": ["../api/src"],
|
|
21
|
-
"@webiny/api-headless-cms/*": ["../api-headless-cms/src/*"],
|
|
22
|
-
"@webiny/api-headless-cms": ["../api-headless-cms/src"],
|
|
23
|
-
"@webiny/db-utils/*": ["../db-utils/src/*"],
|
|
24
|
-
"@webiny/db-utils": ["../db-utils/src"],
|
|
25
|
-
"@webiny/error/*": ["../error/src/*"],
|
|
26
|
-
"@webiny/error": ["../error/src"],
|
|
27
|
-
"@webiny/feature/*": ["../feature/src/*"],
|
|
28
|
-
"@webiny/feature": ["../feature/src"],
|
|
29
|
-
"@webiny/plugins/*": ["../plugins/src/*"],
|
|
30
|
-
"@webiny/plugins": ["../plugins/src"]
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.json",
|
|
3
|
-
"include": ["src", "__tests__"],
|
|
4
|
-
"references": [
|
|
5
|
-
{ "path": "../api" },
|
|
6
|
-
{ "path": "../api-headless-cms" },
|
|
7
|
-
{ "path": "../db-utils" },
|
|
8
|
-
{ "path": "../error" },
|
|
9
|
-
{ "path": "../feature" },
|
|
10
|
-
{ "path": "../plugins" }
|
|
11
|
-
],
|
|
12
|
-
"compilerOptions": {
|
|
13
|
-
"rootDirs": ["./src", "./__tests__"],
|
|
14
|
-
"outDir": "./dist",
|
|
15
|
-
"declarationDir": "./dist",
|
|
16
|
-
"paths": {
|
|
17
|
-
"~/*": ["./src/*"],
|
|
18
|
-
"~tests/*": ["./__tests__/*"],
|
|
19
|
-
"@webiny/api/*": ["../api/src/*"],
|
|
20
|
-
"@webiny/api": ["../api/src"],
|
|
21
|
-
"@webiny/api-headless-cms/*": ["../api-headless-cms/src/*"],
|
|
22
|
-
"@webiny/api-headless-cms": ["../api-headless-cms/src"],
|
|
23
|
-
"@webiny/db-utils/*": ["../db-utils/src/*"],
|
|
24
|
-
"@webiny/db-utils": ["../db-utils/src"],
|
|
25
|
-
"@webiny/error/*": ["../error/src/*"],
|
|
26
|
-
"@webiny/error": ["../error/src"],
|
|
27
|
-
"@webiny/feature/*": ["../feature/src/*"],
|
|
28
|
-
"@webiny/feature": ["../feature/src"],
|
|
29
|
-
"@webiny/plugins/*": ["../plugins/src/*"],
|
|
30
|
-
"@webiny/plugins": ["../plugins/src"]
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
package/vitest.config.ts
DELETED
package/webiny.config.js
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{dist/features → features}/fieldFilterValueTransform/FieldFilterValueTransformRegistry.d.ts
RENAMED
|
File without changes
|
/package/{dist/features → features}/fieldFilterValueTransform/FieldFilterValueTransformRegistry.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|