@webiny/db-dynamodb 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7be00a75a9
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/DynamoDbDriver.d.ts +18 -32
- package/DynamoDbDriver.js +215 -261
- package/DynamoDbDriver.js.map +1 -1
- package/README.md +6 -62
- package/exports/api/db.d.ts +2 -0
- package/exports/api/db.js +2 -0
- package/feature/FilterUtil/FilterUtil.d.ts +11 -0
- package/feature/FilterUtil/FilterUtil.js +26 -0
- package/feature/FilterUtil/FilterUtil.js.map +1 -0
- package/feature/FilterUtil/abstractions/FilterUtil.d.ts +17 -0
- package/feature/FilterUtil/abstractions/FilterUtil.js +5 -0
- package/feature/FilterUtil/abstractions/FilterUtil.js.map +1 -0
- package/feature/FilterUtil/createFilters.d.ts +22 -0
- package/feature/FilterUtil/createFilters.js +92 -0
- package/feature/FilterUtil/createFilters.js.map +1 -0
- package/feature/FilterUtil/extractWhereArgs.d.ts +7 -0
- package/feature/FilterUtil/extractWhereArgs.js +20 -0
- package/feature/FilterUtil/extractWhereArgs.js.map +1 -0
- package/feature/FilterUtil/feature.d.ts +4 -0
- package/feature/FilterUtil/feature.js +11 -0
- package/feature/FilterUtil/feature.js.map +1 -0
- package/feature/FilterUtil/index.d.ts +2 -0
- package/feature/FilterUtil/index.js +2 -0
- package/feature/ValueFilter/ValueFilterRegistry.d.ts +12 -0
- package/feature/ValueFilter/ValueFilterRegistry.js +27 -0
- package/feature/ValueFilter/ValueFilterRegistry.js.map +1 -0
- package/feature/ValueFilter/abstractions/ValueFilter.d.ts +22 -0
- package/feature/ValueFilter/abstractions/ValueFilter.js +5 -0
- package/feature/ValueFilter/abstractions/ValueFilter.js.map +1 -0
- package/feature/ValueFilter/abstractions/ValueFilterRegistry.d.ts +10 -0
- package/feature/ValueFilter/abstractions/ValueFilterRegistry.js +5 -0
- package/feature/ValueFilter/abstractions/ValueFilterRegistry.js.map +1 -0
- package/feature/ValueFilter/feature.d.ts +4 -0
- package/feature/ValueFilter/feature.js +33 -0
- package/feature/ValueFilter/feature.js.map +1 -0
- package/feature/ValueFilter/filters/AndInFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/AndInFilter.js +28 -0
- package/feature/ValueFilter/filters/AndInFilter.js.map +1 -0
- package/feature/ValueFilter/filters/BetweenFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/BetweenFilter.js +31 -0
- package/feature/ValueFilter/filters/BetweenFilter.js.map +1 -0
- package/feature/ValueFilter/filters/ContainsFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/ContainsFilter.js +42 -0
- package/feature/ValueFilter/filters/ContainsFilter.js.map +1 -0
- package/feature/ValueFilter/filters/EqFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/EqFilter.js +24 -0
- package/feature/ValueFilter/filters/EqFilter.js.map +1 -0
- package/feature/ValueFilter/filters/FuzzyFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/FuzzyFilter.js +37 -0
- package/feature/ValueFilter/filters/FuzzyFilter.js.map +1 -0
- package/feature/ValueFilter/filters/GtFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/GtFilter.js +22 -0
- package/feature/ValueFilter/filters/GtFilter.js.map +1 -0
- package/feature/ValueFilter/filters/GteFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/GteFilter.js +22 -0
- package/feature/ValueFilter/filters/GteFilter.js.map +1 -0
- package/feature/ValueFilter/filters/InFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/InFilter.js +28 -0
- package/feature/ValueFilter/filters/InFilter.js.map +1 -0
- package/feature/ValueFilter/filters/LtFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/LtFilter.js +22 -0
- package/feature/ValueFilter/filters/LtFilter.js.map +1 -0
- package/feature/ValueFilter/filters/LteFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/LteFilter.js +22 -0
- package/feature/ValueFilter/filters/LteFilter.js.map +1 -0
- package/feature/ValueFilter/filters/StartsWithFilter.d.ts +11 -0
- package/feature/ValueFilter/filters/StartsWithFilter.js +29 -0
- package/feature/ValueFilter/filters/StartsWithFilter.js.map +1 -0
- package/feature/ValueFilter/index.d.ts +3 -0
- package/feature/ValueFilter/index.js +3 -0
- package/index.d.ts +5 -1
- package/index.js +12 -14
- package/index.js.map +1 -1
- package/package.json +32 -30
- package/plugins/definitions/DateTimeTransformPlugin.d.ts +2 -1
- package/plugins/definitions/DateTimeTransformPlugin.js +21 -50
- package/plugins/definitions/DateTimeTransformPlugin.js.map +1 -1
- package/plugins/definitions/FieldPlugin.d.ts +2 -2
- package/plugins/definitions/FieldPlugin.js +36 -68
- package/plugins/definitions/FieldPlugin.js.map +1 -1
- package/plugins/definitions/TimeTransformPlugin.d.ts +2 -1
- package/plugins/definitions/TimeTransformPlugin.js +29 -56
- package/plugins/definitions/TimeTransformPlugin.js.map +1 -1
- package/plugins/definitions/ValueTransformPlugin.d.ts +2 -7
- package/plugins/definitions/ValueTransformPlugin.js +20 -46
- package/plugins/definitions/ValueTransformPlugin.js.map +1 -1
- package/plugins/definitions/assignFields.js +15 -34
- package/plugins/definitions/assignFields.js.map +1 -1
- package/plugins/index.d.ts +5 -2
- package/plugins/index.js +5 -19
- package/store/entity.d.ts +6 -0
- package/store/entity.js +8 -0
- package/store/entity.js.map +1 -0
- package/store/keys.d.ts +6 -0
- package/store/keys.js +9 -0
- package/store/keys.js.map +1 -0
- package/store/types.d.ts +6 -0
- package/store/types.js +0 -0
- package/toolbox.d.ts +60 -0
- package/toolbox.js +1 -0
- package/types.d.ts +10 -23
- package/types.js +0 -5
- package/utils/batch/batchRead.d.ts +15 -0
- package/utils/batch/batchRead.js +45 -0
- package/utils/batch/batchRead.js.map +1 -0
- package/utils/batch/batchWrite.d.ts +13 -0
- package/utils/batch/batchWrite.js +39 -0
- package/utils/batch/batchWrite.js.map +1 -0
- package/utils/batch/index.d.ts +3 -0
- package/utils/batch/index.js +3 -0
- package/utils/batch/types.d.ts +30 -0
- package/utils/batch/types.js +0 -0
- package/utils/cleanup.d.ts +3 -3
- package/utils/cleanup.js +36 -41
- package/utils/cleanup.js.map +1 -1
- package/utils/count.d.ts +2 -0
- package/utils/count.js +11 -0
- package/utils/count.js.map +1 -0
- package/utils/createEntity.d.ts +36 -0
- package/utils/createEntity.js +82 -0
- package/utils/createEntity.js.map +1 -0
- package/utils/createTable.d.ts +11 -0
- package/utils/createTable.js +29 -0
- package/utils/createTable.js.map +1 -0
- package/utils/cursor.js +8 -23
- package/utils/cursor.js.map +1 -1
- package/utils/delete.d.ts +10 -0
- package/utils/delete.js +9 -0
- package/utils/delete.js.map +1 -0
- package/utils/entity/Entity.d.ts +28 -0
- package/utils/entity/Entity.js +95 -0
- package/utils/entity/Entity.js.map +1 -0
- package/utils/entity/EntityReadBatch.d.ts +18 -0
- package/utils/entity/EntityReadBatch.js +31 -0
- package/utils/entity/EntityReadBatch.js.map +1 -0
- package/utils/entity/EntityReadBatchBuilder.d.ts +10 -0
- package/utils/entity/EntityReadBatchBuilder.js +18 -0
- package/utils/entity/EntityReadBatchBuilder.js.map +1 -0
- package/utils/entity/EntityWriteBatch.d.ts +23 -0
- package/utils/entity/EntityWriteBatch.js +44 -0
- package/utils/entity/EntityWriteBatch.js.map +1 -0
- package/utils/entity/EntityWriteBatchBuilder.d.ts +11 -0
- package/utils/entity/EntityWriteBatchBuilder.js +19 -0
- package/utils/entity/EntityWriteBatchBuilder.js.map +1 -0
- package/utils/entity/getEntity.d.ts +4 -0
- package/utils/entity/getEntity.js +11 -0
- package/utils/entity/getEntity.js.map +1 -0
- package/utils/entity/index.d.ts +7 -0
- package/utils/entity/index.js +7 -0
- package/utils/entity/types.d.ts +75 -0
- package/utils/entity/types.js +0 -0
- package/utils/get.d.ts +8 -6
- package/utils/get.js +15 -28
- package/utils/get.js.map +1 -1
- package/utils/index.d.ts +13 -0
- package/utils/index.js +13 -0
- package/utils/put.d.ts +12 -0
- package/utils/put.js +10 -0
- package/utils/put.js.map +1 -0
- package/utils/query.d.ts +20 -14
- package/utils/query.js +84 -108
- package/utils/query.js.map +1 -1
- package/utils/scan.d.ts +38 -0
- package/utils/scan.js +56 -0
- package/utils/scan.js.map +1 -0
- package/utils/sort.d.ts +1 -1
- package/utils/sort.js +38 -84
- package/utils/sort.js.map +1 -1
- package/utils/table/Table.d.ts +10 -0
- package/utils/table/Table.js +28 -0
- package/utils/table/Table.js.map +1 -0
- package/utils/table/TableReadBatch.d.ts +19 -0
- package/utils/table/TableReadBatch.js +46 -0
- package/utils/table/TableReadBatch.js.map +1 -0
- package/utils/table/TableWriteBatch.d.ts +21 -0
- package/utils/table/TableWriteBatch.js +52 -0
- package/utils/table/TableWriteBatch.js.map +1 -0
- package/utils/table/index.d.ts +4 -0
- package/utils/table/index.js +4 -0
- package/utils/table/types.d.ts +39 -0
- package/utils/table/types.js +0 -0
- package/BatchProcess.d.ts +0 -47
- package/BatchProcess.js +0 -198
- package/BatchProcess.js.map +0 -1
- package/QueryGenerator.d.ts +0 -21
- package/QueryGenerator.js +0 -78
- package/QueryGenerator.js.map +0 -1
- package/operators/comparison/beginsWith.d.ts +0 -3
- package/operators/comparison/beginsWith.js +0 -24
- package/operators/comparison/beginsWith.js.map +0 -1
- package/operators/comparison/between.d.ts +0 -3
- package/operators/comparison/between.js +0 -30
- package/operators/comparison/between.js.map +0 -1
- package/operators/comparison/eq.d.ts +0 -3
- package/operators/comparison/eq.js +0 -34
- package/operators/comparison/eq.js.map +0 -1
- package/operators/comparison/gt.d.ts +0 -3
- package/operators/comparison/gt.js +0 -24
- package/operators/comparison/gt.js.map +0 -1
- package/operators/comparison/gte.d.ts +0 -3
- package/operators/comparison/gte.js +0 -24
- package/operators/comparison/gte.js.map +0 -1
- package/operators/comparison/lt.d.ts +0 -3
- package/operators/comparison/lt.js +0 -24
- package/operators/comparison/lt.js.map +0 -1
- package/operators/comparison/lte.d.ts +0 -3
- package/operators/comparison/lte.js +0 -24
- package/operators/comparison/lte.js.map +0 -1
- package/operators/index.d.ts +0 -12
- package/operators/index.js +0 -39
- package/operators/index.js.map +0 -1
- package/operators/logical/and.d.ts +0 -3
- package/operators/logical/and.js +0 -63
- package/operators/logical/and.js.map +0 -1
- package/operators/logical/or.d.ts +0 -3
- package/operators/logical/or.js +0 -63
- package/operators/logical/or.js.map +0 -1
- package/plugins/definitions/AttributePlugin.d.ts +0 -20
- package/plugins/definitions/AttributePlugin.js +0 -61
- package/plugins/definitions/AttributePlugin.js.map +0 -1
- package/plugins/definitions/FieldPathPlugin.d.ts +0 -22
- package/plugins/definitions/FieldPathPlugin.js +0 -46
- package/plugins/definitions/FieldPathPlugin.js.map +0 -1
- package/plugins/definitions/NumberTransformPlugin.d.ts +0 -4
- package/plugins/definitions/NumberTransformPlugin.js +0 -45
- package/plugins/definitions/NumberTransformPlugin.js.map +0 -1
- package/plugins/definitions/ValueFilterPlugin.d.ts +0 -20
- package/plugins/definitions/ValueFilterPlugin.js +0 -49
- package/plugins/definitions/ValueFilterPlugin.js.map +0 -1
- package/plugins/filters/andIn.d.ts +0 -3
- package/plugins/filters/andIn.js +0 -35
- package/plugins/filters/andIn.js.map +0 -1
- package/plugins/filters/between.d.ts +0 -3
- package/plugins/filters/between.js +0 -36
- package/plugins/filters/between.js.map +0 -1
- package/plugins/filters/contains.d.ts +0 -3
- package/plugins/filters/contains.js +0 -32
- package/plugins/filters/contains.js.map +0 -1
- package/plugins/filters/eq.d.ts +0 -3
- package/plugins/filters/eq.js +0 -33
- package/plugins/filters/eq.js.map +0 -1
- package/plugins/filters/fuzzy.d.ts +0 -3
- package/plugins/filters/fuzzy.js +0 -30
- package/plugins/filters/fuzzy.js.map +0 -1
- package/plugins/filters/gt.d.ts +0 -3
- package/plugins/filters/gt.js +0 -20
- package/plugins/filters/gt.js.map +0 -1
- package/plugins/filters/gte.d.ts +0 -3
- package/plugins/filters/gte.js +0 -20
- package/plugins/filters/gte.js.map +0 -1
- package/plugins/filters/in.d.ts +0 -3
- package/plugins/filters/in.js +0 -35
- package/plugins/filters/in.js.map +0 -1
- package/plugins/filters/index.d.ts +0 -2
- package/plugins/filters/index.js +0 -34
- package/plugins/filters/index.js.map +0 -1
- package/plugins/filters/lt.d.ts +0 -3
- package/plugins/filters/lt.js +0 -20
- package/plugins/filters/lt.js.map +0 -1
- package/plugins/filters/lte.d.ts +0 -3
- package/plugins/filters/lte.js +0 -20
- package/plugins/filters/lte.js.map +0 -1
- package/plugins/filters/startsWith.d.ts +0 -3
- package/plugins/filters/startsWith.js +0 -33
- package/plugins/filters/startsWith.js.map +0 -1
- package/plugins/index.js.map +0 -1
- package/statements/createKeyConditionExpressionArgs.d.ts +0 -15
- package/statements/createKeyConditionExpressionArgs.js +0 -52
- package/statements/createKeyConditionExpressionArgs.js.map +0 -1
- package/statements/processStatement.d.ts +0 -3
- package/statements/processStatement.js +0 -42
- package/statements/processStatement.js.map +0 -1
- package/types.js.map +0 -1
- package/utils/attributes.d.ts +0 -10
- package/utils/attributes.js +0 -31
- package/utils/attributes.js.map +0 -1
- package/utils/batchRead.d.ts +0 -15
- package/utils/batchRead.js +0 -89
- package/utils/batchRead.js.map +0 -1
- package/utils/batchWrite.d.ts +0 -17
- package/utils/batchWrite.js +0 -30
- package/utils/batchWrite.js.map +0 -1
- package/utils/filter.d.ts +0 -12
- package/utils/filter.js +0 -213
- package/utils/filter.js.map +0 -1
- package/utils/listResponse.d.ts +0 -13
- package/utils/listResponse.js +0 -33
- package/utils/listResponse.js.map +0 -1
- package/utils/table.d.ts +0 -7
- package/utils/table.js +0 -27
- package/utils/table.js.map +0 -1
|
@@ -1,54 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
-
|
|
16
|
-
var _dateFns = require("date-fns");
|
|
17
|
-
|
|
18
|
-
const transformDateTime = params => {
|
|
19
|
-
const {
|
|
20
|
-
value
|
|
21
|
-
} = params;
|
|
22
|
-
|
|
23
|
-
if (value === null) {
|
|
1
|
+
import { ValueTransformPlugin } from "./ValueTransformPlugin.js";
|
|
2
|
+
import { parseISO } from "date-fns";
|
|
3
|
+
const transformDateTime = (params)=>{
|
|
4
|
+
const { value } = params;
|
|
5
|
+
if (null == value) return null;
|
|
6
|
+
if ("string" == typeof value) {
|
|
7
|
+
const parsedDateTime = parseISO(value).getTime();
|
|
8
|
+
if (false === isNaN(parsedDateTime)) return parsedDateTime;
|
|
9
|
+
} else if (value instanceof Date || "function" == typeof value?.getTime) return value.getTime();
|
|
10
|
+
console.warn("Could not parse given dateTime value.", "PARSE_DATE_ERROR", {
|
|
11
|
+
value
|
|
12
|
+
});
|
|
24
13
|
return null;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (value && typeof value.getTime === "function") {
|
|
28
|
-
/**
|
|
29
|
-
* In this case we assume this is a date object and we just get the time.
|
|
30
|
-
*/
|
|
31
|
-
return value.getTime();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const parsedDateTime = (0, _dateFns.parseISO)(value).getTime();
|
|
35
|
-
|
|
36
|
-
if (isNaN(parsedDateTime) === false) {
|
|
37
|
-
return parsedDateTime;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
throw new _error.default("Could not parse given dateTime value.", "PARSE_DATE_ERROR", {
|
|
41
|
-
value
|
|
42
|
-
});
|
|
43
14
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
15
|
+
class DateTimeTransformPlugin extends ValueTransformPlugin {
|
|
16
|
+
constructor(params){
|
|
17
|
+
super({
|
|
18
|
+
transform: transformDateTime,
|
|
19
|
+
...params
|
|
20
|
+
});
|
|
21
|
+
}
|
|
52
22
|
}
|
|
23
|
+
export { DateTimeTransformPlugin };
|
|
53
24
|
|
|
54
|
-
|
|
25
|
+
//# sourceMappingURL=DateTimeTransformPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/definitions/DateTimeTransformPlugin.js","sources":["../../../src/plugins/definitions/DateTimeTransformPlugin.ts"],"sourcesContent":["import type {\n ValueTransformPluginParams,\n ValueTransformPluginParamsTransformParams\n} from \"./ValueTransformPlugin.js\";\nimport { ValueTransformPlugin } from \"./ValueTransformPlugin.js\";\nimport { parseISO } from \"date-fns\";\n\nconst transformDateTime = (params: ValueTransformPluginParamsTransformParams): number | null => {\n const { value } = params;\n if (value === null || value === undefined) {\n return null;\n } else if (typeof value === \"string\") {\n const parsedDateTime = parseISO(value).getTime();\n if (isNaN(parsedDateTime) === false) {\n return parsedDateTime;\n }\n } else if (value instanceof Date || typeof (value as unknown as Date)?.getTime === \"function\") {\n /**\n * In this case we assume this is a date object, and we just get the time.\n */\n return value.getTime();\n }\n /**\n * 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.\n */\n console.warn(\"Could not parse given dateTime value.\", \"PARSE_DATE_ERROR\", {\n value\n });\n return null;\n};\n\nexport class DateTimeTransformPlugin extends ValueTransformPlugin {\n public constructor(params: Omit<ValueTransformPluginParams, \"transform\">) {\n super({\n transform: transformDateTime,\n ...params\n });\n }\n}\n"],"names":["transformDateTime","params","value","parsedDateTime","parseISO","isNaN","Date","console","DateTimeTransformPlugin","ValueTransformPlugin"],"mappings":";;AAOA,MAAMA,oBAAoB,CAACC;IACvB,MAAM,EAAEC,KAAK,EAAE,GAAGD;IAClB,IAAIC,QAAAA,OACA,OAAO;IACJ,IAAI,AAAiB,YAAjB,OAAOA,OAAoB;QAClC,MAAMC,iBAAiBC,SAASF,OAAO,OAAO;QAC9C,IAAIG,AAA0B,UAA1BA,MAAMF,iBACN,OAAOA;IAEf,OAAO,IAAID,iBAAiBI,QAAQ,AAA+C,cAA/C,OAAQJ,OAA2B,SAInE,OAAOA,MAAM,OAAO;IAKxBK,QAAQ,IAAI,CAAC,yCAAyC,oBAAoB;QACtEL;IACJ;IACA,OAAO;AACX;AAEO,MAAMM,gCAAgCC;IACzC,YAAmBR,MAAqD,CAAE;QACtE,KAAK,CAAC;YACF,WAAWD;YACX,GAAGC,MAAM;QACb;IACJ;AACJ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
import { DynamoDBTypes } from "
|
|
3
|
-
export
|
|
2
|
+
import type { DynamoDBTypes } from "../../toolbox.js";
|
|
3
|
+
export type FieldType = DynamoDBTypes & "date" & any;
|
|
4
4
|
export interface TransformValueCb {
|
|
5
5
|
(value: any): any;
|
|
6
6
|
}
|
|
@@ -1,73 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _plugins = require("@webiny/plugins");
|
|
13
|
-
|
|
14
|
-
class FieldPlugin extends _plugins.Plugin {
|
|
15
|
-
constructor(params) {
|
|
16
|
-
super();
|
|
17
|
-
(0, _defineProperty2.default)(this, "path", void 0);
|
|
18
|
-
(0, _defineProperty2.default)(this, "field", void 0);
|
|
19
|
-
(0, _defineProperty2.default)(this, "fieldType", void 0);
|
|
20
|
-
(0, _defineProperty2.default)(this, "dynamoDbType", void 0);
|
|
21
|
-
(0, _defineProperty2.default)(this, "sortable", void 0);
|
|
22
|
-
(0, _defineProperty2.default)(this, "_transformValue", void 0);
|
|
23
|
-
this.fieldType = params.type || "string";
|
|
24
|
-
this.dynamoDbType = params.type === "date" ? "string" : params.type;
|
|
25
|
-
this.field = params.field;
|
|
26
|
-
this.path = params.path;
|
|
27
|
-
this.sortable = params.sortable === undefined ? true : params.sortable;
|
|
28
|
-
this._transformValue = params.transformValue;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
getPath() {
|
|
32
|
-
return this.path || this.field;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
getType() {
|
|
36
|
-
return this.fieldType;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
getField() {
|
|
40
|
-
return this.field;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
getDynamoDbType() {
|
|
44
|
-
return this.dynamoDbType;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
transformValue(value) {
|
|
48
|
-
if (this._transformValue) {
|
|
49
|
-
return this.transformValue(value);
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
class FieldPlugin extends Plugin {
|
|
3
|
+
constructor(params){
|
|
4
|
+
super();
|
|
5
|
+
this.fieldType = params.type || "string";
|
|
6
|
+
this.dynamoDbType = "date" === params.type ? "string" : params.type;
|
|
7
|
+
this.field = params.field;
|
|
8
|
+
this.path = params.path;
|
|
9
|
+
this.sortable = void 0 === params.sortable ? true : params.sortable;
|
|
10
|
+
this._transformValue = params.transformValue;
|
|
50
11
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
12
|
+
getPath() {
|
|
13
|
+
return this.path || this.field;
|
|
14
|
+
}
|
|
15
|
+
getType() {
|
|
16
|
+
return this.fieldType;
|
|
17
|
+
}
|
|
18
|
+
getField() {
|
|
19
|
+
return this.field;
|
|
20
|
+
}
|
|
21
|
+
getDynamoDbType() {
|
|
22
|
+
return this.dynamoDbType;
|
|
23
|
+
}
|
|
24
|
+
transformValue(value) {
|
|
25
|
+
if (this._transformValue) return this.transformValue(value);
|
|
26
|
+
switch(this.fieldType){
|
|
27
|
+
case "number":
|
|
28
|
+
return Number(value);
|
|
29
|
+
case "date":
|
|
30
|
+
if (!value) return null;
|
|
31
|
+
return new Date(value);
|
|
59
32
|
}
|
|
60
|
-
|
|
61
|
-
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
isSortable() {
|
|
36
|
+
return this.sortable;
|
|
62
37
|
}
|
|
63
|
-
|
|
64
|
-
return value;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
isSortable() {
|
|
68
|
-
return this.sortable;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
38
|
}
|
|
39
|
+
export { FieldPlugin };
|
|
72
40
|
|
|
73
|
-
|
|
41
|
+
//# sourceMappingURL=FieldPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/definitions/FieldPlugin.js","sources":["../../../src/plugins/definitions/FieldPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { DynamoDBTypes } from \"~/toolbox.js\";\n\nexport type FieldType = DynamoDBTypes & \"date\" & any;\n\nexport interface TransformValueCb {\n (value: any): any;\n}\n\nexport interface FieldPluginParams {\n /**\n * Default is string.\n */\n type?: FieldType;\n field: string;\n path?: string;\n /**\n * Default is true.\n */\n sortable?: boolean;\n\n transformValue?: TransformValueCb;\n}\n\nexport abstract class FieldPlugin extends Plugin {\n private readonly path?: string;\n private readonly field: string;\n private readonly fieldType: FieldType;\n private readonly dynamoDbType: DynamoDBTypes;\n private readonly sortable: boolean;\n private readonly _transformValue: TransformValueCb | undefined;\n\n public constructor(params: FieldPluginParams) {\n super();\n this.fieldType = params.type || \"string\";\n this.dynamoDbType = params.type === \"date\" ? \"string\" : params.type;\n this.field = params.field;\n this.path = params.path;\n this.sortable = params.sortable === undefined ? true : params.sortable;\n this._transformValue = params.transformValue;\n }\n\n public getPath(): string {\n return this.path || this.field;\n }\n\n public getType(): FieldType {\n return this.fieldType;\n }\n\n public getField(): string {\n return this.field;\n }\n\n public getDynamoDbType(): string {\n return this.dynamoDbType;\n }\n\n public transformValue(value: any): any {\n if (this._transformValue) {\n return this.transformValue(value);\n }\n switch (this.fieldType) {\n case \"number\":\n return Number(value);\n case \"date\":\n if (!value) {\n return null;\n }\n return new Date(value);\n }\n return value;\n }\n\n public isSortable(): boolean {\n return this.sortable;\n }\n}\n"],"names":["FieldPlugin","Plugin","params","undefined","value","Number","Date"],"mappings":";AAwBO,MAAeA,oBAAoBC;IAQtC,YAAmBC,MAAyB,CAAE;QAC1C,KAAK;QACL,IAAI,CAAC,SAAS,GAAGA,OAAO,IAAI,IAAI;QAChC,IAAI,CAAC,YAAY,GAAGA,AAAgB,WAAhBA,OAAO,IAAI,GAAc,WAAWA,OAAO,IAAI;QACnE,IAAI,CAAC,KAAK,GAAGA,OAAO,KAAK;QACzB,IAAI,CAAC,IAAI,GAAGA,OAAO,IAAI;QACvB,IAAI,CAAC,QAAQ,GAAGA,AAAoBC,WAApBD,OAAO,QAAQ,GAAiB,OAAOA,OAAO,QAAQ;QACtE,IAAI,CAAC,eAAe,GAAGA,OAAO,cAAc;IAChD;IAEO,UAAkB;QACrB,OAAO,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK;IAClC;IAEO,UAAqB;QACxB,OAAO,IAAI,CAAC,SAAS;IACzB;IAEO,WAAmB;QACtB,OAAO,IAAI,CAAC,KAAK;IACrB;IAEO,kBAA0B;QAC7B,OAAO,IAAI,CAAC,YAAY;IAC5B;IAEO,eAAeE,KAAU,EAAO;QACnC,IAAI,IAAI,CAAC,eAAe,EACpB,OAAO,IAAI,CAAC,cAAc,CAACA;QAE/B,OAAQ,IAAI,CAAC,SAAS;YAClB,KAAK;gBACD,OAAOC,OAAOD;YAClB,KAAK;gBACD,IAAI,CAACA,OACD,OAAO;gBAEX,OAAO,IAAIE,KAAKF;QACxB;QACA,OAAOA;IACX;IAEO,aAAsB;QACzB,OAAO,IAAI,CAAC,QAAQ;IACxB;AACJ"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ValueTransformPluginParams } from "./ValueTransformPlugin.js";
|
|
2
|
+
import { ValueTransformPlugin } from "./ValueTransformPlugin.js";
|
|
2
3
|
export declare class TimeTransformPlugin extends ValueTransformPlugin {
|
|
3
4
|
constructor(params: Omit<ValueTransformPluginParams, "transform">);
|
|
4
5
|
}
|
|
@@ -1,61 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
});
|
|
8
|
-
exports.TimeTransformPlugin = void 0;
|
|
9
|
-
|
|
10
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
|
-
var _ValueTransformPlugin = require("./ValueTransformPlugin");
|
|
13
|
-
|
|
14
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
-
|
|
16
|
-
var _isNumber = _interopRequireDefault(require("is-number"));
|
|
17
|
-
|
|
18
|
-
const transformTime = params => {
|
|
19
|
-
const {
|
|
20
|
-
value
|
|
21
|
-
} = params;
|
|
22
|
-
const typeOf = typeof value;
|
|
23
|
-
/**
|
|
24
|
-
* Due to some internal JS stuff, we must check for a number like this.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
if (typeOf === "number" || (0, _isNumber.default)(value) === true) {
|
|
28
|
-
return Number(value);
|
|
29
|
-
} else if (typeOf !== "string") {
|
|
30
|
-
throw new _error.default("Field value must be a string because field is defined as time.", "TIME_PARSE_ERROR", {
|
|
31
|
-
value
|
|
1
|
+
import { ValueTransformPlugin } from "./ValueTransformPlugin.js";
|
|
2
|
+
import error from "@webiny/error";
|
|
3
|
+
const transformTime = (params)=>{
|
|
4
|
+
const { value } = params;
|
|
5
|
+
if (null == value) throw new error("Time value is null or undefined.", "TIME_PARSE_ERROR", {
|
|
6
|
+
value
|
|
32
7
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
* This is for the time format, eg. 12:36:25 or 12:36:25.881
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const [time, milliseconds = 0] = value.split(".");
|
|
40
|
-
const values = time.split(":").map(Number);
|
|
41
|
-
|
|
42
|
-
if (values.length < 2) {
|
|
43
|
-
throw new _error.default("Time must contain at least hours and minutes.", "TIME_PARSE_ERROR", {
|
|
44
|
-
value
|
|
8
|
+
if ("boolean" == typeof value || "" === value || Array.isArray(value)) throw new error("Field value must be a string because field is defined as time.", "TIME_PARSE_ERROR", {
|
|
9
|
+
value
|
|
45
10
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
11
|
+
const converted = Number(`${value}`);
|
|
12
|
+
if ("number" == typeof value || false === isNaN(converted)) return Number(value);
|
|
13
|
+
if ("string" != typeof value) throw new error("Field value must be a string because field is defined as time.", "TIME_PARSE_ERROR", {
|
|
14
|
+
value
|
|
15
|
+
});
|
|
16
|
+
const [time, milliseconds = 0] = value.split(".");
|
|
17
|
+
const values = time.split(":").map(Number);
|
|
18
|
+
if (values.length < 2) throw new error("Time must contain at least hours and minutes.", "TIME_PARSE_ERROR", {
|
|
19
|
+
value
|
|
20
|
+
});
|
|
21
|
+
const [hours, minutes, seconds = 0] = values;
|
|
22
|
+
return (60 * hours * 60 + 60 * minutes + seconds) * 1000 + Number(milliseconds);
|
|
50
23
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
24
|
+
class TimeTransformPlugin extends ValueTransformPlugin {
|
|
25
|
+
constructor(params){
|
|
26
|
+
super({
|
|
27
|
+
transform: transformTime,
|
|
28
|
+
...params
|
|
29
|
+
});
|
|
30
|
+
}
|
|
59
31
|
}
|
|
32
|
+
export { TimeTransformPlugin };
|
|
60
33
|
|
|
61
|
-
|
|
34
|
+
//# sourceMappingURL=TimeTransformPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/definitions/TimeTransformPlugin.js","sources":["../../../src/plugins/definitions/TimeTransformPlugin.ts"],"sourcesContent":["import type {\n ValueTransformPluginParams,\n ValueTransformPluginParamsTransformParams\n} from \"./ValueTransformPlugin.js\";\nimport { ValueTransformPlugin } from \"./ValueTransformPlugin.js\";\nimport WebinyError from \"@webiny/error\";\n\nconst transformTime = (params: ValueTransformPluginParamsTransformParams): number => {\n const { value } = params;\n if (value === undefined || value === null) {\n throw new WebinyError(`Time value is null or undefined.`, \"TIME_PARSE_ERROR\", {\n value\n });\n } else if (typeof value === \"boolean\" || value === \"\" || Array.isArray(value)) {\n throw new WebinyError(\n \"Field value must be a string because field is defined as time.\",\n \"TIME_PARSE_ERROR\",\n {\n value\n }\n );\n }\n const converted = Number(`${value}`);\n if (typeof value === \"number\" || isNaN(converted) === false) {\n return Number(value);\n } else if (typeof value !== \"string\") {\n throw new WebinyError(\n \"Field value must be a string because field is defined as time.\",\n \"TIME_PARSE_ERROR\",\n {\n value\n }\n );\n }\n /**\n * This is for the time format, eg. 12:36:25 or 12:36:25.881\n */\n const [time, milliseconds = 0] = value.split(\".\");\n const values = time.split(\":\").map(Number);\n if (values.length < 2) {\n throw new WebinyError(\"Time must contain at least hours and minutes.\", \"TIME_PARSE_ERROR\", {\n value\n });\n }\n const [hours, minutes, seconds = 0] = values;\n return (hours * 60 * 60 + minutes * 60 + seconds) * 1000 + Number(milliseconds);\n};\n\nexport class TimeTransformPlugin extends ValueTransformPlugin {\n public constructor(params: Omit<ValueTransformPluginParams, \"transform\">) {\n super({\n transform: transformTime,\n ...params\n });\n }\n}\n"],"names":["transformTime","params","value","WebinyError","Array","converted","Number","isNaN","time","milliseconds","values","hours","minutes","seconds","TimeTransformPlugin","ValueTransformPlugin"],"mappings":";;AAOA,MAAMA,gBAAgB,CAACC;IACnB,MAAM,EAAEC,KAAK,EAAE,GAAGD;IAClB,IAAIC,QAAAA,OACA,MAAM,IAAIC,MAAY,oCAAoC,oBAAoB;QAC1ED;IACJ;IACG,IAAI,AAAiB,aAAjB,OAAOA,SAAuBA,AAAU,OAAVA,SAAgBE,MAAM,OAAO,CAACF,QACnE,MAAM,IAAIC,MACN,kEACA,oBACA;QACID;IACJ;IAGR,MAAMG,YAAYC,OAAO,GAAGJ,OAAO;IACnC,IAAI,AAAiB,YAAjB,OAAOA,SAAsBK,AAAqB,UAArBA,MAAMF,YACnC,OAAOC,OAAOJ;IACX,IAAI,AAAiB,YAAjB,OAAOA,OACd,MAAM,IAAIC,MACN,kEACA,oBACA;QACID;IACJ;IAMR,MAAM,CAACM,MAAMC,eAAe,CAAC,CAAC,GAAGP,MAAM,KAAK,CAAC;IAC7C,MAAMQ,SAASF,KAAK,KAAK,CAAC,KAAK,GAAG,CAACF;IACnC,IAAII,OAAO,MAAM,GAAG,GAChB,MAAM,IAAIP,MAAY,iDAAiD,oBAAoB;QACvFD;IACJ;IAEJ,MAAM,CAACS,OAAOC,SAASC,UAAU,CAAC,CAAC,GAAGH;IACtC,OAAQC,AAAAA,CAAAA,AAAQ,KAARA,QAAa,KAAKC,AAAU,KAAVA,UAAeC,OAAM,IAAK,OAAOP,OAAOG;AACtE;AAEO,MAAMK,4BAA4BC;IACrC,YAAmBd,MAAqD,CAAE;QACtE,KAAK,CAAC;YACF,WAAWD;YACX,GAAGC,MAAM;QACb;IACJ;AACJ"}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins";
|
|
2
2
|
export interface ValueTransformPluginParamsTransformParams {
|
|
3
|
-
value:
|
|
3
|
+
value: Date | string | null | undefined;
|
|
4
4
|
}
|
|
5
5
|
export interface ValueTransformPluginParamsTransform {
|
|
6
6
|
(params: ValueTransformPluginParamsTransformParams): any;
|
|
7
7
|
}
|
|
8
|
-
export interface CanTransform {
|
|
9
|
-
(field: string): boolean;
|
|
10
|
-
}
|
|
11
8
|
export interface ValueTransformPluginParams {
|
|
12
9
|
fields: string[];
|
|
13
10
|
transform: ValueTransformPluginParamsTransform;
|
|
14
|
-
canTransform?: CanTransform;
|
|
15
11
|
}
|
|
16
|
-
export declare class ValueTransformPlugin extends Plugin {
|
|
12
|
+
export declare abstract class ValueTransformPlugin extends Plugin {
|
|
17
13
|
static readonly type: string;
|
|
18
14
|
private readonly _params;
|
|
19
15
|
constructor(params: ValueTransformPluginParams);
|
|
20
|
-
canTransform(field: string): boolean;
|
|
21
16
|
transform(params: ValueTransformPluginParamsTransformParams): any;
|
|
22
17
|
}
|
|
@@ -1,50 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
});
|
|
8
|
-
exports.ValueTransformPlugin = void 0;
|
|
9
|
-
|
|
10
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
|
|
14
|
-
var _plugins = require("@webiny/plugins");
|
|
15
|
-
|
|
16
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
17
|
-
|
|
18
|
-
var _assignFields = require("./assignFields");
|
|
19
|
-
|
|
20
|
-
class ValueTransformPlugin extends _plugins.Plugin {
|
|
21
|
-
constructor(params) {
|
|
22
|
-
super();
|
|
23
|
-
(0, _defineProperty2.default)(this, "_params", void 0);
|
|
24
|
-
this._params = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
25
|
-
fields: (0, _assignFields.assignFields)(params.fields)
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
canTransform(field) {
|
|
30
|
-
if (!this._params.canTransform) {
|
|
31
|
-
return this._params.fields.includes(field);
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import error from "@webiny/error";
|
|
3
|
+
import { assignFields } from "./assignFields.js";
|
|
4
|
+
class ValueTransformPlugin extends Plugin {
|
|
5
|
+
static{
|
|
6
|
+
this.type = "dynamodb.value.transform";
|
|
32
7
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
8
|
+
constructor(params){
|
|
9
|
+
super();
|
|
10
|
+
this._params = {
|
|
11
|
+
...params,
|
|
12
|
+
fields: assignFields(params.fields)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
transform(params) {
|
|
16
|
+
if (!this._params.transform) throw new error('Missing "transform" in the plugin.', "TRANSFORM_ERROR", {
|
|
17
|
+
fields: this._params.fields
|
|
18
|
+
});
|
|
19
|
+
return this._params.transform(params);
|
|
42
20
|
}
|
|
43
|
-
|
|
44
|
-
return this._params.transform(params);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
21
|
}
|
|
22
|
+
export { ValueTransformPlugin };
|
|
48
23
|
|
|
49
|
-
|
|
50
|
-
(0, _defineProperty2.default)(ValueTransformPlugin, "type", "dynamodb.value.transform");
|
|
24
|
+
//# sourceMappingURL=ValueTransformPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/definitions/ValueTransformPlugin.js","sources":["../../../src/plugins/definitions/ValueTransformPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\nimport { assignFields } from \"./assignFields.js\";\n\nexport interface ValueTransformPluginParamsTransformParams {\n value: Date | string | null | undefined;\n}\nexport interface ValueTransformPluginParamsTransform {\n (params: ValueTransformPluginParamsTransformParams): any;\n}\nexport interface ValueTransformPluginParams {\n fields: string[];\n transform: ValueTransformPluginParamsTransform;\n}\n\nexport abstract class ValueTransformPlugin extends Plugin {\n public static override readonly type: string = \"dynamodb.value.transform\";\n\n private readonly _params: ValueTransformPluginParams;\n\n public constructor(params: ValueTransformPluginParams) {\n super();\n this._params = {\n ...params,\n fields: assignFields(params.fields)\n };\n }\n\n public transform(params: ValueTransformPluginParamsTransformParams): any {\n if (!this._params.transform) {\n throw new WebinyError(`Missing \"transform\" in the plugin.`, \"TRANSFORM_ERROR\", {\n fields: this._params.fields\n });\n }\n return this._params.transform(params);\n }\n}\n"],"names":["ValueTransformPlugin","Plugin","params","assignFields","WebinyError"],"mappings":";;;AAeO,MAAeA,6BAA6BC;;aACf,IAAI,GAAW;;IAI/C,YAAmBC,MAAkC,CAAE;QACnD,KAAK;QACL,IAAI,CAAC,OAAO,GAAG;YACX,GAAGA,MAAM;YACT,QAAQC,aAAaD,OAAO,MAAM;QACtC;IACJ;IAEO,UAAUA,MAAiD,EAAO;QACrE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EACvB,MAAM,IAAIE,MAAY,sCAAsC,mBAAmB;YAC3E,QAAQ,IAAI,CAAC,OAAO,CAAC,MAAM;QAC/B;QAEJ,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAACF;IAClC;AACJ"}
|
|
@@ -1,37 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const input = Array.isArray(rawInput) ? rawInput : [rawInput];
|
|
14
|
-
|
|
15
|
-
if (input.length === 0) {
|
|
16
|
-
throw new _error.default("Could not assign fields because there are none.", "ASSIGN_FIELDS_ERROR");
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const fields = [];
|
|
20
|
-
|
|
21
|
-
for (const field of input) {
|
|
22
|
-
/**
|
|
23
|
-
* Need to make sure that no field is empty.
|
|
24
|
-
*/
|
|
25
|
-
if (!field) {
|
|
26
|
-
throw new _error.default("Passed empty field value into the plugin.", "EMPTY_FIELD_VALUE", {
|
|
27
|
-
fields: input
|
|
28
|
-
});
|
|
1
|
+
import error from "@webiny/error";
|
|
2
|
+
const assignFields = (rawInput)=>{
|
|
3
|
+
const input = Array.isArray(rawInput) ? rawInput : [
|
|
4
|
+
rawInput
|
|
5
|
+
];
|
|
6
|
+
if (0 === input.length) throw new error("Could not assign fields because there are none.", "ASSIGN_FIELDS_ERROR");
|
|
7
|
+
const fields = [];
|
|
8
|
+
for (const field of input){
|
|
9
|
+
if (!field) throw new error("Passed empty field value into the plugin.", "EMPTY_FIELD_VALUE", {
|
|
10
|
+
fields: input
|
|
11
|
+
});
|
|
12
|
+
fields.push(field);
|
|
29
13
|
}
|
|
30
|
-
|
|
31
|
-
fields.push(field);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return fields;
|
|
14
|
+
return fields;
|
|
35
15
|
};
|
|
16
|
+
export { assignFields };
|
|
36
17
|
|
|
37
|
-
|
|
18
|
+
//# sourceMappingURL=assignFields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/definitions/assignFields.js","sources":["../../../src/plugins/definitions/assignFields.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nexport const assignFields = (rawInput: string | string[]): string[] => {\n const input = Array.isArray(rawInput) ? rawInput : [rawInput];\n if (input.length === 0) {\n throw new WebinyError(\n \"Could not assign fields because there are none.\",\n \"ASSIGN_FIELDS_ERROR\"\n );\n }\n const fields: string[] = [];\n for (const field of input) {\n /**\n * Need to make sure that no field is empty.\n */\n if (!field) {\n throw new WebinyError(\n \"Passed empty field value into the plugin.\",\n \"EMPTY_FIELD_VALUE\",\n {\n fields: input\n }\n );\n }\n fields.push(field);\n }\n return fields;\n};\n"],"names":["assignFields","rawInput","input","Array","WebinyError","fields","field"],"mappings":";AAEO,MAAMA,eAAe,CAACC;IACzB,MAAMC,QAAQC,MAAM,OAAO,CAACF,YAAYA,WAAW;QAACA;KAAS;IAC7D,IAAIC,AAAiB,MAAjBA,MAAM,MAAM,EACZ,MAAM,IAAIE,MACN,mDACA;IAGR,MAAMC,SAAmB,EAAE;IAC3B,KAAK,MAAMC,SAASJ,MAAO;QAIvB,IAAI,CAACI,OACD,MAAM,IAAIF,MACN,6CACA,qBACA;YACI,QAAQF;QACZ;QAGRG,OAAO,IAAI,CAACC;IAChB;IACA,OAAOD;AACX"}
|
package/plugins/index.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
export * from "./definitions/assignFields.js";
|
|
2
|
+
export * from "./definitions/DateTimeTransformPlugin.js";
|
|
3
|
+
export * from "./definitions/FieldPlugin.js";
|
|
4
|
+
export * from "./definitions/TimeTransformPlugin.js";
|
|
5
|
+
export * from "./definitions/ValueTransformPlugin.js";
|
package/plugins/index.js
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _filters = _interopRequireDefault(require("./filters"));
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* List everything that needs to be loaded by default.
|
|
14
|
-
*/
|
|
15
|
-
var _default = () => {
|
|
16
|
-
return [(0, _filters.default)()];
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
exports.default = _default;
|
|
1
|
+
export * from "./definitions/assignFields.js";
|
|
2
|
+
export * from "./definitions/DateTimeTransformPlugin.js";
|
|
3
|
+
export * from "./definitions/FieldPlugin.js";
|
|
4
|
+
export * from "./definitions/TimeTransformPlugin.js";
|
|
5
|
+
export * from "./definitions/ValueTransformPlugin.js";
|
package/store/entity.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store/entity.js","sources":["../../src/store/entity.ts"],"sourcesContent":["import type { ITable } from \"~/utils/index.js\";\nimport { createGlobalEntity as baseCreateGlobalEntity } from \"~/utils/index.js\";\nimport type { IStoreEntity, IStoreEntityValue } from \"~/store/types.js\";\n\nexport interface ICreateEntityParams {\n table: ITable;\n}\n\nexport const createEntity = ({ table }: ICreateEntityParams): IStoreEntity => {\n return baseCreateGlobalEntity<IStoreEntityValue>({\n table: table.table,\n name: \"WebinyKeyValue\"\n });\n};\n"],"names":["createEntity","table","baseCreateGlobalEntity"],"mappings":";AAQO,MAAMA,eAAe,CAAC,EAAEC,KAAK,EAAuB,GAChDC,mBAA0C;QAC7C,OAAOD,MAAM,KAAK;QAClB,MAAM;IACV"}
|
package/store/keys.d.ts
ADDED
package/store/keys.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const createPartitionKey = ()=>"W#internal";
|
|
2
|
+
const createSortKey = ({ key })=>{
|
|
3
|
+
if ("symbol" == typeof key) return key.toString();
|
|
4
|
+
return String(key);
|
|
5
|
+
};
|
|
6
|
+
const createType = ()=>"internal";
|
|
7
|
+
export { createPartitionKey, createSortKey, createType };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store/keys.js","sources":["../../src/store/keys.ts"],"sourcesContent":["export interface IParams {\n key: string | number | symbol;\n}\n\nexport const createPartitionKey = () => {\n return `W#internal`;\n};\n\nexport const createSortKey = ({ key }: IParams) => {\n if (typeof key === \"symbol\") {\n return key.toString();\n }\n return String(key);\n};\n\nexport const createType = () => {\n return \"internal\";\n};\n"],"names":["createPartitionKey","createSortKey","key","String","createType"],"mappings":"AAIO,MAAMA,qBAAqB,IACvB;AAGJ,MAAMC,gBAAgB,CAAC,EAAEC,GAAG,EAAW;IAC1C,IAAI,AAAe,YAAf,OAAOA,KACP,OAAOA,IAAI,QAAQ;IAEvB,OAAOC,OAAOD;AAClB;AAEO,MAAME,aAAa,IACf"}
|
package/store/types.d.ts
ADDED
package/store/types.js
ADDED
|
File without changes
|