@webiny/api-headless-cms-ddb 6.1.0 → 6.2.0
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/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/index.js +1 -3
- package/dynamoDb/index.js.map +1 -1
- package/index.d.ts +1 -2
- package/index.js +36 -31
- package/index.js.map +1 -1
- package/operations/entry/filtering/createExpressions.d.ts +6 -5
- package/operations/entry/filtering/createExpressions.js +5 -8
- package/operations/entry/filtering/createExpressions.js.map +1 -1
- package/operations/entry/filtering/filter.d.ts +5 -4
- package/operations/entry/filtering/filter.js +11 -8
- package/operations/entry/filtering/filter.js.map +1 -1
- package/operations/entry/filtering/fullTextSearch.d.ts +2 -2
- package/operations/entry/filtering/fullTextSearch.js +2 -2
- package/operations/entry/filtering/fullTextSearch.js.map +1 -1
- package/operations/entry/filtering/plugins/defaultFilterCreate.js +4 -4
- package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/objectFilterCreate.js +2 -2
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/refFilterCreate.js +4 -4
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +7 -2
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -1
- package/operations/entry/filtering/types.d.ts +1 -1
- package/operations/entry/filtering/types.js.map +1 -1
- package/operations/entry/index.d.ts +2 -0
- package/operations/entry/index.js +12 -14
- package/operations/entry/index.js.map +1 -1
- package/operations/group/index.d.ts +2 -3
- package/operations/group/index.js +6 -9
- package/operations/group/index.js.map +1 -1
- package/package.json +17 -14
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +3 -3
- package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
- package/types.d.ts +5 -3
- package/types.js.map +1 -1
- package/dynamoDb/storage/longText.d.ts +0 -10
- package/dynamoDb/storage/longText.js +0 -86
- package/dynamoDb/storage/longText.js.map +0 -1
- package/dynamoDb/storage/richText.d.ts +0 -2
- package/dynamoDb/storage/richText.js +0 -52
- package/dynamoDb/storage/richText.js.map +0 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { CmsGroupStorageOperations } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
-
import type { PluginsContainer } from "@webiny/plugins";
|
|
1
|
+
import type { CmsContext, CmsGroupStorageOperations } from "@webiny/api-headless-cms/types/index.js";
|
|
3
2
|
import type { IGroupEntity } from "../../definitions/types.js";
|
|
4
3
|
interface CreateGroupsStorageOperationsParams {
|
|
5
4
|
entity: IGroupEntity;
|
|
6
|
-
|
|
5
|
+
container: CmsContext["container"];
|
|
7
6
|
}
|
|
8
7
|
export declare const createGroupsStorageOperations: (params: CreateGroupsStorageOperationsParams) => CmsGroupStorageOperations;
|
|
9
8
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import WebinyError from "@webiny/error";
|
|
2
|
-
import {
|
|
2
|
+
import { sortItems } from "@webiny/db-dynamodb";
|
|
3
|
+
import { FilterUtil } from "@webiny/db-dynamodb/feature/FilterUtil/index.js";
|
|
3
4
|
const createPartitionKey = params => {
|
|
4
5
|
const {
|
|
5
6
|
tenant
|
|
@@ -25,12 +26,9 @@ const createType = () => {
|
|
|
25
26
|
export const createGroupsStorageOperations = params => {
|
|
26
27
|
const {
|
|
27
28
|
entity,
|
|
28
|
-
|
|
29
|
+
container
|
|
29
30
|
} = params;
|
|
30
|
-
const
|
|
31
|
-
if (filteringPlugins.length === 0) {
|
|
32
|
-
throw new WebinyError("DynamoDB filtering plugins not loaded.", "MISSING_DYNAMODB_FILTERING_PLUGINS");
|
|
33
|
-
}
|
|
31
|
+
const filterUtil = container.resolve(FilterUtil);
|
|
34
32
|
const create = async params => {
|
|
35
33
|
const {
|
|
36
34
|
group
|
|
@@ -119,11 +117,10 @@ export const createGroupsStorageOperations = params => {
|
|
|
119
117
|
where
|
|
120
118
|
});
|
|
121
119
|
}
|
|
122
|
-
const filteredItems =
|
|
120
|
+
const filteredItems = filterUtil.filter({
|
|
123
121
|
items: records,
|
|
124
122
|
where,
|
|
125
|
-
fields: []
|
|
126
|
-
plugins
|
|
123
|
+
fields: []
|
|
127
124
|
});
|
|
128
125
|
if (!sort || sort.length === 0) {
|
|
129
126
|
return filteredItems;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WebinyError","
|
|
1
|
+
{"version":3,"names":["WebinyError","sortItems","FilterUtil","createPartitionKey","params","tenant","createSortKeys","id","createKeys","PK","SK","GSI_TENANT","createType","createGroupsStorageOperations","entity","container","filterUtil","resolve","create","group","keys","put","data","TYPE","ex","message","code","error","update","deleteGroup","delete","get","result","list","sort","where","records","ddbRecords","queryAll","partitionKey","options","gte","map","item","filteredItems","filter","items","fields","length"],"sources":["index.ts"],"sourcesContent":["import type {\n CmsContext,\n CmsGroup,\n CmsGroupStorageOperations,\n CmsGroupStorageOperationsCreateParams,\n CmsGroupStorageOperationsDeleteParams,\n CmsGroupStorageOperationsGetParams,\n CmsGroupStorageOperationsListParams,\n CmsGroupStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { sortItems } from \"@webiny/db-dynamodb\";\nimport type { IGroupEntity } from \"~/definitions/types.js\";\nimport { FilterUtil } from \"@webiny/db-dynamodb/feature/FilterUtil/index.js\";\n\ninterface PartitionKeyParams {\n tenant: string;\n}\nconst createPartitionKey = (params: PartitionKeyParams): string => {\n const { tenant } = params;\n return `T#${tenant}#CMS#CMG`;\n};\n\ninterface SortKeyParams {\n id: string;\n}\nconst createSortKeys = (params: SortKeyParams): string => {\n const { id } = params;\n return id;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n GSI_TENANT: string;\n}\nconst createKeys = (params: PartitionKeyParams & SortKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKeys(params),\n GSI_TENANT: params.tenant\n };\n};\n\nconst createType = (): string => {\n return \"cms.group\";\n};\n\ninterface CreateGroupsStorageOperationsParams {\n entity: IGroupEntity;\n container: CmsContext[\"container\"];\n}\nexport const createGroupsStorageOperations = (\n params: CreateGroupsStorageOperationsParams\n): CmsGroupStorageOperations => {\n const { entity, container } = params;\n const filterUtil = container.resolve(FilterUtil);\n\n const create = async (params: CmsGroupStorageOperationsCreateParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await entity.put({\n data: group,\n TYPE: createType(),\n ...keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create group.\",\n ex.code || \"CREATE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const update = async (params: CmsGroupStorageOperationsUpdateParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await entity.put({\n data: group,\n TYPE: createType(),\n ...keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update group.\",\n ex.code || \"UPDATE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const deleteGroup = async (params: CmsGroupStorageOperationsDeleteParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await entity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete group.\",\n ex.code || \"DELETE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const get = async (params: CmsGroupStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const result = await entity.get(keys);\n\n return result?.data || null;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get group.\",\n ex.code || \"GET_GROUP_ERROR\",\n {\n error: ex,\n ...params,\n keys\n }\n );\n }\n };\n const list = async (params: CmsGroupStorageOperationsListParams) => {\n const { sort, where } = params;\n\n let records: CmsGroup[] = [];\n try {\n const ddbRecords = await entity.queryAll({\n partitionKey: createPartitionKey(where),\n options: {\n gte: \" \"\n }\n });\n records = ddbRecords.map(item => item.data);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list groups.\",\n ex.code || \"LIST_GROUP_ERROR\",\n {\n error: ex,\n ...params,\n sort,\n where\n }\n );\n }\n\n const filteredItems = filterUtil.filter({\n items: records,\n where,\n fields: []\n });\n if (!sort || sort.length === 0) {\n return filteredItems;\n }\n\n return sortItems({\n items: filteredItems,\n sort\n });\n };\n\n return {\n create,\n update,\n delete: deleteGroup,\n get,\n list\n };\n};\n"],"mappings":"AAUA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,SAAS,QAAQ,qBAAqB;AAE/C,SAASC,UAAU,QAAQ,iDAAiD;AAK5E,MAAMC,kBAAkB,GAAIC,MAA0B,IAAa;EAC/D,MAAM;IAAEC;EAAO,CAAC,GAAGD,MAAM;EACzB,OAAO,KAAKC,MAAM,UAAU;AAChC,CAAC;AAKD,MAAMC,cAAc,GAAIF,MAAqB,IAAa;EACtD,MAAM;IAAEG;EAAG,CAAC,GAAGH,MAAM;EACrB,OAAOG,EAAE;AACb,CAAC;AAOD,MAAMC,UAAU,GAAIJ,MAA0C,IAAW;EACrE,OAAO;IACHK,EAAE,EAAEN,kBAAkB,CAACC,MAAM,CAAC;IAC9BM,EAAE,EAAEJ,cAAc,CAACF,MAAM,CAAC;IAC1BO,UAAU,EAAEP,MAAM,CAACC;EACvB,CAAC;AACL,CAAC;AAED,MAAMO,UAAU,GAAGA,CAAA,KAAc;EAC7B,OAAO,WAAW;AACtB,CAAC;AAMD,OAAO,MAAMC,6BAA6B,GACtCT,MAA2C,IACf;EAC5B,MAAM;IAAEU,MAAM;IAAEC;EAAU,CAAC,GAAGX,MAAM;EACpC,MAAMY,UAAU,GAAGD,SAAS,CAACE,OAAO,CAACf,UAAU,CAAC;EAEhD,MAAMgB,MAAM,GAAG,MAAOd,MAA6C,IAAK;IACpE,MAAM;MAAEe;IAAM,CAAC,GAAGf,MAAM;IACxB,MAAMgB,IAAI,GAAGZ,UAAU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a,GAAG5B,UAAU,CAAC6B,MAAM,CAAC;MACpCC,KAAK,EAAEV,OAAO;MACdD,KAAK;MACLY,MAAM,EAAE;IACZ,CAAC,CAAC;IACF,IAAI,CAACb,IAAI,IAAIA,IAAI,CAACc,MAAM,KAAK,CAAC,EAAE;MAC5B,OAAOJ,aAAa;IACxB;IAEA,OAAO3C,SAAS,CAAC;MACb6C,KAAK,EAAEF,aAAa;MACpBV;IACJ,CAAC,CAAC;EACN,CAAC;EAED,OAAO;IACHhB,MAAM;IACNU,MAAM;IACNE,MAAM,EAAED,WAAW;IACnBE,GAAG;IACHE;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-ddb",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -23,31 +23,34 @@
|
|
|
23
23
|
],
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@webiny/api": "6.
|
|
27
|
-
"@webiny/api-headless-cms": "6.
|
|
28
|
-
"@webiny/aws-sdk": "6.
|
|
29
|
-
"@webiny/db-dynamodb": "6.
|
|
30
|
-
"@webiny/error": "6.
|
|
31
|
-
"@webiny/
|
|
32
|
-
"@webiny/
|
|
26
|
+
"@webiny/api": "6.2.0",
|
|
27
|
+
"@webiny/api-headless-cms": "6.2.0",
|
|
28
|
+
"@webiny/aws-sdk": "6.2.0",
|
|
29
|
+
"@webiny/db-dynamodb": "6.2.0",
|
|
30
|
+
"@webiny/error": "6.2.0",
|
|
31
|
+
"@webiny/feature": "6.2.0",
|
|
32
|
+
"@webiny/handler": "6.2.0",
|
|
33
|
+
"@webiny/handler-db": "6.2.0",
|
|
34
|
+
"@webiny/utils": "6.2.0",
|
|
33
35
|
"dataloader": "2.2.3",
|
|
34
36
|
"dot-object": "2.1.5",
|
|
35
37
|
"dot-prop": "10.1.0",
|
|
36
|
-
"lodash": "4.
|
|
38
|
+
"lodash": "4.18.1"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
41
|
"@types/dot-object": "2.1.6",
|
|
40
42
|
"@types/jsonpack": "1.1.6",
|
|
41
|
-
"@webiny/build-tools": "6.
|
|
42
|
-
"@webiny/
|
|
43
|
-
"@webiny/
|
|
43
|
+
"@webiny/build-tools": "6.2.0",
|
|
44
|
+
"@webiny/di": "0.2.3",
|
|
45
|
+
"@webiny/plugins": "6.2.0",
|
|
46
|
+
"@webiny/project-utils": "6.2.0",
|
|
44
47
|
"jest-dynalite": "3.6.1",
|
|
45
48
|
"typescript": "5.9.3",
|
|
46
|
-
"vitest": "4.1.
|
|
49
|
+
"vitest": "4.1.4"
|
|
47
50
|
},
|
|
48
51
|
"publishConfig": {
|
|
49
52
|
"access": "public",
|
|
50
53
|
"directory": "dist"
|
|
51
54
|
},
|
|
52
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "3d3148358b6febbc857371930871743bec3b3939"
|
|
53
56
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
import type { ValueFilterPlugin } from "@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin.js";
|
|
3
2
|
import type { Field } from "../operations/entry/filtering/types.js";
|
|
4
3
|
import type { CmsFieldFilterValueTransformPlugin } from "../types.js";
|
|
4
|
+
import { ValueFilterRegistry } from "@webiny/db-dynamodb/feature/ValueFilter/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* This plugin is used to create the filter.
|
|
7
7
|
* Internally we have default one + the one for the reference field - because it is actually an object when filtering.
|
|
@@ -16,7 +16,7 @@ interface CmsEntryFieldFilterPluginCreateParams<T = any> {
|
|
|
16
16
|
field: Field;
|
|
17
17
|
fields: Record<string, Field>;
|
|
18
18
|
operation: string;
|
|
19
|
-
|
|
19
|
+
valueFilterRegistry: ValueFilterRegistry.Interface;
|
|
20
20
|
transformValuePlugins: Record<string, CmsFieldFilterValueTransformPlugin>;
|
|
21
21
|
getFilterCreatePlugin: (type: string) => CmsEntryFieldFilterPlugin;
|
|
22
22
|
negate: boolean;
|
|
@@ -27,7 +27,7 @@ export interface CmsEntryFieldFilterPluginCreateResponse {
|
|
|
27
27
|
field: Field;
|
|
28
28
|
path: string;
|
|
29
29
|
fieldPathId: string;
|
|
30
|
-
|
|
30
|
+
filter: ValueFilterRegistry.Filter;
|
|
31
31
|
negate: boolean;
|
|
32
32
|
compareValue: any;
|
|
33
33
|
transformValue: <I = any, O = any>(value: I) => O;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Plugin","CmsEntryFieldFilterPlugin","type","ALL","constructor","config","fieldType","create","params"],"sources":["CmsEntryFieldFilterPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type {
|
|
1
|
+
{"version":3,"names":["Plugin","CmsEntryFieldFilterPlugin","type","ALL","constructor","config","fieldType","create","params"],"sources":["CmsEntryFieldFilterPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Field } from \"~/operations/entry/filtering/types.js\";\nimport type { CmsFieldFilterValueTransformPlugin } from \"~/types.js\";\nimport { ValueFilterRegistry } from \"@webiny/db-dynamodb/feature/ValueFilter/index.js\";\n\n/**\n * This plugin is used to create the filter.\n * Internally we have default one + the one for the reference field - because it is actually an object when filtering.\n */\n\ninterface CmsEntryFieldFilterPluginParams<T = any> {\n fieldType: string;\n create: (\n params: CmsEntryFieldFilterPluginCreateParams<T>\n ) => null | CmsEntryFieldFilterPluginCreateResponse | CmsEntryFieldFilterPluginCreateResponse[];\n}\n\ninterface CmsEntryFieldFilterPluginCreateParams<T = any> {\n key: string;\n value: T;\n field: Field;\n fields: Record<string, Field>;\n operation: string;\n valueFilterRegistry: ValueFilterRegistry.Interface;\n transformValuePlugins: Record<string, CmsFieldFilterValueTransformPlugin>;\n getFilterCreatePlugin: (type: string) => CmsEntryFieldFilterPlugin;\n negate: boolean;\n compareValue: any;\n transformValue: <I = any, O = any>(value: I) => O;\n}\n\nexport interface CmsEntryFieldFilterPluginCreateResponse {\n field: Field;\n path: string;\n fieldPathId: string;\n filter: ValueFilterRegistry.Filter;\n negate: boolean;\n compareValue: any;\n transformValue: <I = any, O = any>(value: I) => O;\n}\n\nexport class CmsEntryFieldFilterPlugin<T = any> extends Plugin {\n public static override readonly type: string = \"cms.dynamodb.entry.field.filter\";\n public static readonly ALL: string = \"*\";\n\n private readonly config: CmsEntryFieldFilterPluginParams<T>;\n\n public readonly fieldType: string;\n\n public constructor(config: CmsEntryFieldFilterPluginParams<T>) {\n super();\n this.config = config;\n this.fieldType = this.config.fieldType;\n }\n\n public create(params: CmsEntryFieldFilterPluginCreateParams<T>) {\n return this.config.create(params);\n }\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAiB;;AAKxC;AACA;AACA;AACA;;AAiCA,OAAO,MAAMC,yBAAyB,SAAkBD,MAAM,CAAC;EAC3D,OAAgCE,IAAI,GAAW,iCAAiC;EAChF,OAAuBC,GAAG,GAAW,GAAG;EAMjCC,WAAWA,CAACC,MAA0C,EAAE;IAC3D,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,SAAS,GAAG,IAAI,CAACD,MAAM,CAACC,SAAS;EAC1C;EAEOC,MAAMA,CAACC,MAAgD,EAAE;IAC5D,OAAO,IAAI,CAACH,MAAM,CAACE,MAAM,CAACC,MAAM,CAAC;EACrC;AACJ","ignoreList":[]}
|
package/types.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { CmsEntryStorageOperations as BaseCmsEntryStorageOperations, CmsModel, CmsModelField, HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations } from "@webiny/api-headless-cms/types/index.js";
|
|
1
|
+
import { type Plugin, PluginsContainer } from "@webiny/plugins/types.js";
|
|
2
|
+
import type { CmsContext, CmsEntryStorageOperations as BaseCmsEntryStorageOperations, CmsModel, CmsModelField, HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations } from "@webiny/api-headless-cms/types/index.js";
|
|
3
3
|
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
4
4
|
import type { IEntryEntity, IGroupEntity, IModelEntity } from "./definitions/types.js";
|
|
5
5
|
import type { ITable } from "@webiny/db-dynamodb";
|
|
6
|
+
export type { CmsContext };
|
|
6
7
|
export type { IGroupEntity, IModelEntity, IEntryEntity };
|
|
7
8
|
interface CmsFieldFilterValueTransformParams {
|
|
8
9
|
/**
|
|
@@ -33,7 +34,8 @@ export declare enum ENTITIES {
|
|
|
33
34
|
export interface StorageOperationsFactoryParams {
|
|
34
35
|
documentClient: DynamoDBDocument;
|
|
35
36
|
table?: string;
|
|
36
|
-
plugins
|
|
37
|
+
plugins: PluginsContainer;
|
|
38
|
+
container: CmsContext["container"];
|
|
37
39
|
}
|
|
38
40
|
export interface IHeadlessCmsStorageOperationsGetEntitiesResult {
|
|
39
41
|
groups: IGroupEntity;
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ENTITIES"],"sources":["types.ts"],"sourcesContent":["import type
|
|
1
|
+
{"version":3,"names":["ENTITIES"],"sources":["types.ts"],"sourcesContent":["import { type Plugin, PluginsContainer } from \"@webiny/plugins/types.js\";\nimport type {\n CmsContext,\n CmsEntryStorageOperations as BaseCmsEntryStorageOperations,\n CmsModel,\n CmsModelField,\n HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { IEntryEntity, IGroupEntity, IModelEntity } from \"~/definitions/types.js\";\nimport type { ITable } from \"@webiny/db-dynamodb\";\n\nexport type { CmsContext };\n\nexport type { IGroupEntity, IModelEntity, IEntryEntity };\n\ninterface CmsFieldFilterValueTransformParams {\n /**\n * A field which value we are transforming.\n */\n field: Partial<CmsModelField> &\n Pick<CmsModelField, \"id\" | \"storageId\" | \"fieldId\" | \"settings\">;\n value: any;\n}\n\nexport interface CmsFieldFilterValueTransformPlugin extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-field-filter-value-transform\";\n /**\n * A field type this plugin is for.\n */\n fieldType: string;\n /**\n * Transform method which expect field definition and value to transform.\n */\n transform: (params: CmsFieldFilterValueTransformParams) => any;\n}\n\nexport enum ENTITIES {\n GROUPS = \"CmsGroups\",\n MODELS = \"CmsModels\",\n ENTRIES = \"CmsEntries\"\n}\n\nexport interface StorageOperationsFactoryParams {\n documentClient: DynamoDBDocument;\n table?: string;\n plugins: PluginsContainer;\n container: CmsContext[\"container\"];\n}\n\nexport interface IHeadlessCmsStorageOperationsGetEntitiesResult {\n groups: IGroupEntity;\n models: IModelEntity;\n entries: IEntryEntity;\n}\n\nexport interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {\n getTable: () => ITable;\n getEntities: () => IHeadlessCmsStorageOperationsGetEntitiesResult;\n}\n\nexport interface StorageOperationsFactory {\n (params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;\n}\n\nexport interface CmsEntryStorageOperations extends BaseCmsEntryStorageOperations {\n dataLoaders: IDataLoadersHandler;\n}\n\nexport interface DataLoadersHandlerInterfaceClearAllParams {\n model: Pick<CmsModel, \"tenant\">;\n}\nexport interface IDataLoadersHandler {\n clearAll: (params?: DataLoadersHandlerInterfaceClearAllParams) => void;\n}\n"],"mappings":"AAwCA,WAAYA,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA","ignoreList":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File is @internal
|
|
3
|
-
*/
|
|
4
|
-
import { StorageTransformPlugin } from "@webiny/api-headless-cms";
|
|
5
|
-
export interface StorageValue {
|
|
6
|
-
compression: string;
|
|
7
|
-
value: string;
|
|
8
|
-
isArray?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare const createLongTextStorageTransformPlugin: () => StorageTransformPlugin<string | string[], StorageValue, import("@webiny/api-headless-cms/types").CmsModelField>;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File is @internal
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import WebinyError from "@webiny/error";
|
|
6
|
-
import { compress as gzip, decompress as ungzip } from "@webiny/utils/compression/gzip.js";
|
|
7
|
-
import { StorageTransformPlugin } from "@webiny/api-headless-cms";
|
|
8
|
-
const GZIP = "gzip";
|
|
9
|
-
const TO_STORAGE_ENCODING = "base64";
|
|
10
|
-
const FROM_STORAGE_ENCODING = "utf8";
|
|
11
|
-
const convertToBuffer = value => {
|
|
12
|
-
if (typeof value === "string") {
|
|
13
|
-
return Buffer.from(value, TO_STORAGE_ENCODING);
|
|
14
|
-
}
|
|
15
|
-
return value;
|
|
16
|
-
};
|
|
17
|
-
export const createLongTextStorageTransformPlugin = () => {
|
|
18
|
-
return new StorageTransformPlugin({
|
|
19
|
-
name: "headless-cms.storage-transform.long-text.default",
|
|
20
|
-
fieldType: "long-text",
|
|
21
|
-
fromStorage: async ({
|
|
22
|
-
field,
|
|
23
|
-
value: storageValue
|
|
24
|
-
}) => {
|
|
25
|
-
const typeOf = typeof storageValue;
|
|
26
|
-
if (!storageValue || typeOf === "string" || typeOf === "number" || Array.isArray(storageValue) === true) {
|
|
27
|
-
return storageValue;
|
|
28
|
-
} else if (typeOf !== "object") {
|
|
29
|
-
throw new WebinyError(`LongText value received in "fromStorage" function is not an object in field "${field.storageId}" - ${field.fieldId}.`);
|
|
30
|
-
}
|
|
31
|
-
const {
|
|
32
|
-
compression,
|
|
33
|
-
value,
|
|
34
|
-
isArray
|
|
35
|
-
} = storageValue;
|
|
36
|
-
/**
|
|
37
|
-
* Check if possibly undefined, null, empty...
|
|
38
|
-
*/
|
|
39
|
-
if (!compression) {
|
|
40
|
-
throw new WebinyError(`Missing compression in "fromStorage" function in field "${field.storageId}" - ${field.fieldId}.": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
|
|
41
|
-
value: storageValue
|
|
42
|
-
});
|
|
43
|
-
} else if (compression !== GZIP) {
|
|
44
|
-
throw new WebinyError(`This plugin cannot transform something not compressed with "GZIP".`, "WRONG_COMPRESSION", {
|
|
45
|
-
compression
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
try {
|
|
49
|
-
const buf = await ungzip(convertToBuffer(value));
|
|
50
|
-
const result = buf.toString(FROM_STORAGE_ENCODING);
|
|
51
|
-
if (!isArray) {
|
|
52
|
-
return result;
|
|
53
|
-
}
|
|
54
|
-
return JSON.parse(result);
|
|
55
|
-
} catch (ex) {
|
|
56
|
-
console.log("Error while transforming long-text.");
|
|
57
|
-
console.log(ex.message);
|
|
58
|
-
return "";
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
toStorage: async ({
|
|
62
|
-
value: initialValue
|
|
63
|
-
}) => {
|
|
64
|
-
/**
|
|
65
|
-
* There is a possibility that we are trying to compress already compressed value.
|
|
66
|
-
*/
|
|
67
|
-
if (initialValue && initialValue.hasOwnProperty("compression") === true) {
|
|
68
|
-
return initialValue;
|
|
69
|
-
}
|
|
70
|
-
const isArray = Array.isArray(initialValue);
|
|
71
|
-
const value = isArray ? JSON.stringify(initialValue) : initialValue;
|
|
72
|
-
const compressedValue = await gzip(value);
|
|
73
|
-
const result = {
|
|
74
|
-
compression: GZIP,
|
|
75
|
-
value: compressedValue.toString(TO_STORAGE_ENCODING)
|
|
76
|
-
};
|
|
77
|
-
if (!isArray) {
|
|
78
|
-
return result;
|
|
79
|
-
}
|
|
80
|
-
result.isArray = isArray;
|
|
81
|
-
return result;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
//# sourceMappingURL=longText.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["WebinyError","compress","gzip","decompress","ungzip","StorageTransformPlugin","GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","createLongTextStorageTransformPlugin","name","fieldType","fromStorage","field","storageValue","typeOf","Array","isArray","storageId","fieldId","compression","JSON","stringify","buf","result","toString","parse","ex","console","log","message","toStorage","initialValue","hasOwnProperty","compressedValue"],"sources":["longText.ts"],"sourcesContent":["/**\n * File is @internal\n */\n\nimport WebinyError from \"@webiny/error\";\nimport { compress as gzip, decompress as ungzip } from \"@webiny/utils/compression/gzip.js\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\n\nconst GZIP = \"gzip\";\nconst TO_STORAGE_ENCODING = \"base64\";\nconst FROM_STORAGE_ENCODING = \"utf8\";\n\nconst convertToBuffer = (value: string | Buffer): Buffer => {\n if (typeof value === \"string\") {\n return Buffer.from(value, TO_STORAGE_ENCODING);\n }\n return value;\n};\n\nexport interface StorageValue {\n compression: string;\n value: string;\n isArray?: boolean;\n}\n\nexport const createLongTextStorageTransformPlugin = () => {\n return new StorageTransformPlugin<string | string[], StorageValue>({\n name: \"headless-cms.storage-transform.long-text.default\",\n fieldType: \"long-text\",\n fromStorage: async ({ field, value: storageValue }) => {\n const typeOf = typeof storageValue;\n if (\n !storageValue ||\n typeOf === \"string\" ||\n typeOf === \"number\" ||\n Array.isArray(storageValue) === true\n ) {\n return storageValue as unknown as string | string[];\n } else if (typeOf !== \"object\") {\n throw new WebinyError(\n `LongText value received in \"fromStorage\" function is not an object in field \"${field.storageId}\" - ${field.fieldId}.`\n );\n }\n const { compression, value, isArray } = storageValue;\n /**\n * Check if possibly undefined, null, empty...\n */\n if (!compression) {\n throw new WebinyError(\n `Missing compression in \"fromStorage\" function in field \"${\n field.storageId\n }\" - ${field.fieldId}.\": ${JSON.stringify(storageValue)}.`,\n \"MISSING_COMPRESSION\",\n {\n value: storageValue\n }\n );\n } else if (compression !== GZIP) {\n throw new WebinyError(\n `This plugin cannot transform something not compressed with \"GZIP\".`,\n \"WRONG_COMPRESSION\",\n {\n compression\n }\n );\n }\n try {\n const buf = await ungzip(convertToBuffer(value));\n const result = buf.toString(FROM_STORAGE_ENCODING);\n if (!isArray) {\n return result;\n }\n return JSON.parse(result);\n } catch (ex) {\n console.log(\"Error while transforming long-text.\");\n console.log(ex.message);\n return \"\";\n }\n },\n toStorage: async ({ value: initialValue }) => {\n /**\n * There is a possibility that we are trying to compress already compressed value.\n */\n if (initialValue && initialValue.hasOwnProperty(\"compression\") === true) {\n return initialValue as unknown as StorageValue;\n }\n const isArray = Array.isArray(initialValue);\n const value = isArray ? JSON.stringify(initialValue) : initialValue;\n const compressedValue = await gzip(value);\n\n const result: StorageValue = {\n compression: GZIP,\n value: compressedValue.toString(TO_STORAGE_ENCODING)\n };\n if (!isArray) {\n return result;\n }\n result.isArray = isArray;\n return result;\n }\n });\n};\n"],"mappings":"AAAA;AACA;AACA;;AAEA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,QAAQ,IAAIC,IAAI,EAAEC,UAAU,IAAIC,MAAM,QAAQ,mCAAmC;AAC1F,SAASC,sBAAsB,QAAQ,0BAA0B;AAEjE,MAAMC,IAAI,GAAG,MAAM;AACnB,MAAMC,mBAAmB,GAAG,QAAQ;AACpC,MAAMC,qBAAqB,GAAG,MAAM;AAEpC,MAAMC,eAAe,GAAIC,KAAsB,IAAa;EACxD,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOC,MAAM,CAACC,IAAI,CAACF,KAAK,EAAEH,mBAAmB,CAAC;EAClD;EACA,OAAOG,KAAK;AAChB,CAAC;AAQD,OAAO,MAAMG,oCAAoC,GAAGA,CAAA,KAAM;EACtD,OAAO,IAAIR,sBAAsB,CAAkC;IAC/DS,IAAI,EAAE,kDAAkD;IAC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AqC,CAAC;QAClDD,OAAO,CAACC,GAAG,CAACF,EAAE,CAACG,OAAO,CAAC;QACvB,OAAO,EAAE;MACb;IACJ,CAAC;IACDC,SAAS,EAAE,MAAAA,CAAO;MAAEzB,KAAK,EAAE0B;IAAa,CAAC,KAAK;MAC1C;AACZ;AACA;MACY,IAAIA,YAAY,IAAIA,YAAY,CAACC,cAAc,CAAC,aAAa,CAAC,KAAK,IAAI,EAAE;QACrE,OAAOD,YAAY;MACvB;MACA,MAAMf,OAAO,GAAGD,KAAK,CAACC,OAAO,CAACe,YAAY,CAAC;MAC3C,MAAM1B,KAAK,GAAGW,OAAO,GAAGI,IAAI,CAACC,SAAS,CAACU,YAAY,CAAC,GAAGA,YAAY;MACnE,MAAME,eAAe,GAAG,MAAMpC,IAAI,CAACQ,KAAK,CAAC;MAEzC,MAAMkB,MAAoB,GAAG;QACzBJ,WAAW,EAAElB,IAAI;QACjBI,KAAK,EAAE4B,eAAe,CAACT,QAAQ,CAACtB,mBAAmB;MACvD,CAAC;MACD,IAAI,CAACc,OAAO,EAAE;QACV,OAAOO,MAAM;MACjB;MACAA,MAAM,CAACP,OAAO,GAAGA,OAAO;MACxB,OAAOO,MAAM;IACjB;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File is @internal
|
|
3
|
-
*/
|
|
4
|
-
import WebinyError from "@webiny/error";
|
|
5
|
-
import { StorageTransformPlugin } from "@webiny/api-headless-cms";
|
|
6
|
-
import { CompressorPlugin } from "@webiny/api";
|
|
7
|
-
export const createRichTextStorageTransformPlugin = () => {
|
|
8
|
-
return new StorageTransformPlugin({
|
|
9
|
-
name: "headless-cms.storage-transform.rich-text.default",
|
|
10
|
-
fieldType: "rich-text",
|
|
11
|
-
fromStorage: async ({
|
|
12
|
-
field,
|
|
13
|
-
value: storageValue,
|
|
14
|
-
plugins
|
|
15
|
-
}) => {
|
|
16
|
-
if (!storageValue) {
|
|
17
|
-
return storageValue;
|
|
18
|
-
} else if (typeof storageValue !== "object") {
|
|
19
|
-
throw new WebinyError(`RichText value received in "fromStorage" function is not an object in field "${field.storageId}" - ${field.fieldId}.`);
|
|
20
|
-
}
|
|
21
|
-
let compressor;
|
|
22
|
-
try {
|
|
23
|
-
compressor = plugins.oneByType(CompressorPlugin.type);
|
|
24
|
-
} catch {
|
|
25
|
-
return storageValue;
|
|
26
|
-
}
|
|
27
|
-
try {
|
|
28
|
-
return await compressor.getCompressor().decompress(storageValue);
|
|
29
|
-
} catch {
|
|
30
|
-
return storageValue;
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
toStorage: async ({
|
|
34
|
-
value,
|
|
35
|
-
plugins
|
|
36
|
-
}) => {
|
|
37
|
-
let compressor;
|
|
38
|
-
try {
|
|
39
|
-
compressor = plugins.oneByType(CompressorPlugin.type);
|
|
40
|
-
} catch {
|
|
41
|
-
return value;
|
|
42
|
-
}
|
|
43
|
-
try {
|
|
44
|
-
return await compressor.getCompressor().compress(value);
|
|
45
|
-
} catch {
|
|
46
|
-
return value;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
//# sourceMappingURL=richText.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["WebinyError","StorageTransformPlugin","CompressorPlugin","createRichTextStorageTransformPlugin","name","fieldType","fromStorage","field","value","storageValue","plugins","storageId","fieldId","compressor","oneByType","type","getCompressor","decompress","toStorage","compress"],"sources":["richText.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { CompressorPlugin } from \"@webiny/api\";\n\nexport const createRichTextStorageTransformPlugin = () => {\n return new StorageTransformPlugin({\n name: \"headless-cms.storage-transform.rich-text.default\",\n fieldType: \"rich-text\",\n fromStorage: async ({ field, value: storageValue, plugins }) => {\n if (!storageValue) {\n return storageValue;\n } else if (typeof storageValue !== \"object\") {\n throw new WebinyError(\n `RichText value received in \"fromStorage\" function is not an object in field \"${field.storageId}\" - ${field.fieldId}.`\n );\n }\n\n let compressor: CompressorPlugin;\n\n try {\n compressor = plugins.oneByType<CompressorPlugin>(CompressorPlugin.type);\n } catch {\n return storageValue;\n }\n\n try {\n return await compressor.getCompressor().decompress(storageValue);\n } catch {\n return storageValue;\n }\n },\n toStorage: async ({ value, plugins }) => {\n let compressor: CompressorPlugin;\n\n try {\n compressor = plugins.oneByType<CompressorPlugin>(CompressorPlugin.type);\n } catch {\n return value;\n }\n try {\n return await compressor.getCompressor().compress(value);\n } catch {\n return value;\n }\n }\n });\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,sBAAsB,QAAQ,0BAA0B;AACjE,SAASC,gBAAgB,QAAQ,aAAa;AAE9C,OAAO,MAAMC,oCAAoC,GAAGA,CAAA,KAAM;EACtD,OAAO,IAAIF,sBAAsB,CAAC;IAC9BG,IAAI,EAAE,kDAAkD;IACxDC,SAAS,EAAE,WAAW;IACtBC,WAAW,EAAE,MAAAA,CAAO;MAAEC,KAAK;MAAEC,KAAK,EAAEC,YAAY;MAAEC;IAAQ,CAAC,KAAK;MAC5D,IAAI,CAACD,YAAY,EAAE;QACf,OAAOA,YAAY;MACvB,CAAC,MAAM,IAAI,OAAOA,YAAY,KAAK,QAAQ,EAAE;QACzC,MAAM,IAAIT,WAAW,CACjB,gFAAgFO,KAAK,CAACI,SAAS,OAAOJ,KAAK,CAACK,OAAO,GACvH,CAAC;MACL;MAEA,IAAIC,UAA4B;MAEhC,IAAI;QACAA,UAAU,GAAGH,OAAO,CAACI,SAAS,CAAmBZ,gBAAgB,CAACa,IAAI,CAAC;MAC3E,CAAC,CAAC,MAAM;QACJ,OAAON,YAAY;MACvB;MAEA,IAAI;QACA,OAAO,MAAMI,UAAU,CAACG,aAAa,CAAC,CAAC,CA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