@itzworking/single-table 0.0.162 → 0.0.197
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-cjs/dynamodb/dynamodb.js +17 -0
- package/{dist → dist-cjs}/errors/decorators-error.js +1 -1
- package/{dist → dist-cjs}/errors/generate-update-expression-error.js +1 -1
- package/{dist → dist-cjs}/errors/index-decorator-error.js +1 -1
- package/{dist → dist-cjs}/errors/key-composition-error.js +1 -1
- package/{dist → dist-cjs}/errors/single-table-error.js +1 -1
- package/{dist → dist-cjs}/errors/single-table-item-format-error.js +1 -1
- package/dist-cjs/single-table-item/single-table-item.js +261 -0
- package/dist-cjs/single-table-item/utils/validate-entity-annotations.js +20 -0
- package/{dist → dist-cjs}/single-table-repository/single-table-repository.js +0 -22
- package/dist-es/decorators/editable/editable.js +4 -0
- package/dist-es/decorators/editable/index.js +2 -0
- package/dist-es/decorators/editable/is-editable.js +4 -0
- package/dist-es/decorators/editable/symbol.js +1 -0
- package/dist-es/decorators/entity/entity.js +6 -0
- package/dist-es/decorators/entity/get-entity-name.js +4 -0
- package/dist-es/decorators/entity/index.js +2 -0
- package/dist-es/decorators/entity/symbol.js +1 -0
- package/dist-es/decorators/gsis/get-pk-composition.js +4 -0
- package/dist-es/decorators/gsis/get-sk-composition.js +4 -0
- package/dist-es/decorators/gsis/gsis.js +15 -0
- package/dist-es/decorators/gsis/index.js +3 -0
- package/dist-es/decorators/gsis/symbols.js +8 -0
- package/dist-es/decorators/gsis/types.js +1 -0
- package/dist-es/decorators/index.js +4 -0
- package/dist-es/dynamodb/delete-dynamodb-item.js +24 -0
- package/dist-es/dynamodb/dynamodb.js +14 -0
- package/dist-es/dynamodb/get-dynamodb-item.js +24 -0
- package/dist-es/dynamodb/index.js +7 -0
- package/dist-es/dynamodb/put-dynamodb-item.js +28 -0
- package/dist-es/dynamodb/query-all-dynamodb.js +19 -0
- package/dist-es/dynamodb/query-dynamodb.js +28 -0
- package/dist-es/dynamodb/update-dynamodb-item.js +24 -0
- package/dist-es/errors/decorators-error.js +10 -0
- package/dist-es/errors/generate-update-expression-error.js +10 -0
- package/dist-es/errors/index-decorator-error.js +10 -0
- package/dist-es/errors/index.js +5 -0
- package/dist-es/errors/key-composition-error.js +10 -0
- package/dist-es/errors/single-table-error.js +10 -0
- package/dist-es/errors/single-table-item-format-error.js +10 -0
- package/dist-es/index.js +6 -0
- package/dist-es/single-table-item/index.js +1 -0
- package/dist-es/single-table-item/single-table-item.js +257 -0
- package/dist-es/single-table-item/utils/capitalize-first-letter.js +3 -0
- package/dist-es/single-table-item/utils/handle-composite-primary-key.js +33 -0
- package/dist-es/single-table-item/utils/index.js +3 -0
- package/dist-es/single-table-item/utils/validate-entity-annotations.js +16 -0
- package/dist-es/single-table-repository/index.js +2 -0
- package/dist-es/single-table-repository/single-table-repository.js +189 -0
- package/dist-es/single-table-repository/types.js +1 -0
- package/dist-es/types.js +1 -0
- package/{dist → dist-types}/decorators/editable/editable.d.ts +0 -1
- package/{dist → dist-types}/decorators/editable/index.d.ts +0 -1
- package/{dist → dist-types}/decorators/editable/is-editable.d.ts +0 -1
- package/{dist → dist-types}/decorators/editable/symbol.d.ts +0 -1
- package/{dist → dist-types}/decorators/entity/entity.d.ts +0 -1
- package/{dist → dist-types}/decorators/entity/get-entity-name.d.ts +0 -1
- package/{dist → dist-types}/decorators/entity/index.d.ts +0 -1
- package/{dist → dist-types}/decorators/entity/symbol.d.ts +0 -1
- package/{dist → dist-types}/decorators/gsis/get-pk-composition.d.ts +0 -1
- package/{dist → dist-types}/decorators/gsis/get-sk-composition.d.ts +0 -1
- package/{dist → dist-types}/decorators/gsis/gsis.d.ts +0 -1
- package/{dist → dist-types}/decorators/gsis/index.d.ts +0 -1
- package/{dist → dist-types}/decorators/gsis/symbols.d.ts +0 -1
- package/{dist → dist-types}/decorators/gsis/types.d.ts +0 -1
- package/{dist → dist-types}/decorators/index.d.ts +0 -1
- package/{dist → dist-types}/dynamodb/delete-dynamodb-item.d.ts +0 -1
- package/{dist → dist-types}/dynamodb/dynamodb.d.ts +0 -1
- package/{dist → dist-types}/dynamodb/get-dynamodb-item.d.ts +0 -1
- package/{dist → dist-types}/dynamodb/index.d.ts +0 -1
- package/{dist → dist-types}/dynamodb/put-dynamodb-item.d.ts +0 -1
- package/{dist → dist-types}/dynamodb/query-all-dynamodb.d.ts +0 -1
- package/{dist → dist-types}/dynamodb/query-dynamodb.d.ts +0 -1
- package/{dist → dist-types}/dynamodb/update-dynamodb-item.d.ts +0 -1
- package/{dist → dist-types}/errors/decorators-error.d.ts +0 -1
- package/{dist → dist-types}/errors/generate-update-expression-error.d.ts +0 -1
- package/{dist → dist-types}/errors/index-decorator-error.d.ts +0 -1
- package/{dist → dist-types}/errors/index.d.ts +0 -1
- package/{dist → dist-types}/errors/key-composition-error.d.ts +0 -1
- package/{dist → dist-types}/errors/single-table-error.d.ts +0 -1
- package/{dist → dist-types}/errors/single-table-item-format-error.d.ts +0 -1
- package/{dist → dist-types}/index.d.ts +0 -1
- package/{dist → dist-types}/single-table-item/index.d.ts +0 -1
- package/{dist → dist-types}/single-table-item/single-table-item.d.ts +0 -1
- package/{dist → dist-types}/single-table-item/utils/capitalize-first-letter.d.ts +0 -1
- package/{dist → dist-types}/single-table-item/utils/handle-composite-primary-key.d.ts +0 -1
- package/{dist → dist-types}/single-table-item/utils/index.d.ts +0 -1
- package/{dist → dist-types}/single-table-item/utils/validate-entity-annotations.d.ts +0 -1
- package/{dist → dist-types}/single-table-repository/index.d.ts +0 -1
- package/{dist → dist-types}/single-table-repository/single-table-repository.d.ts +0 -1
- package/{dist → dist-types}/single-table-repository/types.d.ts +0 -1
- package/{dist → dist-types}/types.d.ts +0 -1
- package/package.json +26 -26
- package/dist/decorators/editable/editable.d.ts.map +0 -1
- package/dist/decorators/editable/index.d.ts.map +0 -1
- package/dist/decorators/editable/is-editable.d.ts.map +0 -1
- package/dist/decorators/editable/symbol.d.ts.map +0 -1
- package/dist/decorators/entity/entity.d.ts.map +0 -1
- package/dist/decorators/entity/get-entity-name.d.ts.map +0 -1
- package/dist/decorators/entity/index.d.ts.map +0 -1
- package/dist/decorators/entity/symbol.d.ts.map +0 -1
- package/dist/decorators/gsis/get-pk-composition.d.ts.map +0 -1
- package/dist/decorators/gsis/get-sk-composition.d.ts.map +0 -1
- package/dist/decorators/gsis/gsis.d.ts.map +0 -1
- package/dist/decorators/gsis/index.d.ts.map +0 -1
- package/dist/decorators/gsis/symbols.d.ts.map +0 -1
- package/dist/decorators/gsis/types.d.ts.map +0 -1
- package/dist/decorators/index.d.ts.map +0 -1
- package/dist/dynamodb/delete-dynamodb-item.d.ts.map +0 -1
- package/dist/dynamodb/dynamodb.d.ts.map +0 -1
- package/dist/dynamodb/dynamodb.js +0 -24
- package/dist/dynamodb/get-dynamodb-item.d.ts.map +0 -1
- package/dist/dynamodb/index.d.ts.map +0 -1
- package/dist/dynamodb/put-dynamodb-item.d.ts.map +0 -1
- package/dist/dynamodb/query-all-dynamodb.d.ts.map +0 -1
- package/dist/dynamodb/query-dynamodb.d.ts.map +0 -1
- package/dist/dynamodb/update-dynamodb-item.d.ts.map +0 -1
- package/dist/errors/decorators-error.d.ts.map +0 -1
- package/dist/errors/generate-update-expression-error.d.ts.map +0 -1
- package/dist/errors/index-decorator-error.d.ts.map +0 -1
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/key-composition-error.d.ts.map +0 -1
- package/dist/errors/single-table-error.d.ts.map +0 -1
- package/dist/errors/single-table-item-format-error.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/single-table-item/index.d.ts.map +0 -1
- package/dist/single-table-item/single-table-item.d.ts.map +0 -1
- package/dist/single-table-item/single-table-item.js +0 -281
- package/dist/single-table-item/utils/capitalize-first-letter.d.ts.map +0 -1
- package/dist/single-table-item/utils/handle-composite-primary-key.d.ts.map +0 -1
- package/dist/single-table-item/utils/index.d.ts.map +0 -1
- package/dist/single-table-item/utils/validate-entity-annotations.d.ts.map +0 -1
- package/dist/single-table-item/utils/validate-entity-annotations.js +0 -38
- package/dist/single-table-repository/index.d.ts.map +0 -1
- package/dist/single-table-repository/single-table-repository.d.ts.map +0 -1
- package/dist/single-table-repository/types.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- /package/{dist → dist-cjs}/decorators/editable/editable.js +0 -0
- /package/{dist → dist-cjs}/decorators/editable/index.js +0 -0
- /package/{dist → dist-cjs}/decorators/editable/is-editable.js +0 -0
- /package/{dist → dist-cjs}/decorators/editable/symbol.js +0 -0
- /package/{dist → dist-cjs}/decorators/entity/entity.js +0 -0
- /package/{dist → dist-cjs}/decorators/entity/get-entity-name.js +0 -0
- /package/{dist → dist-cjs}/decorators/entity/index.js +0 -0
- /package/{dist → dist-cjs}/decorators/entity/symbol.js +0 -0
- /package/{dist → dist-cjs}/decorators/gsis/get-pk-composition.js +0 -0
- /package/{dist → dist-cjs}/decorators/gsis/get-sk-composition.js +0 -0
- /package/{dist → dist-cjs}/decorators/gsis/gsis.js +0 -0
- /package/{dist → dist-cjs}/decorators/gsis/index.js +0 -0
- /package/{dist → dist-cjs}/decorators/gsis/symbols.js +0 -0
- /package/{dist → dist-cjs}/decorators/gsis/types.js +0 -0
- /package/{dist → dist-cjs}/decorators/index.js +0 -0
- /package/{dist → dist-cjs}/dynamodb/delete-dynamodb-item.js +0 -0
- /package/{dist → dist-cjs}/dynamodb/get-dynamodb-item.js +0 -0
- /package/{dist → dist-cjs}/dynamodb/index.js +0 -0
- /package/{dist → dist-cjs}/dynamodb/put-dynamodb-item.js +0 -0
- /package/{dist → dist-cjs}/dynamodb/query-all-dynamodb.js +0 -0
- /package/{dist → dist-cjs}/dynamodb/query-dynamodb.js +0 -0
- /package/{dist → dist-cjs}/dynamodb/update-dynamodb-item.js +0 -0
- /package/{dist → dist-cjs}/errors/index.js +0 -0
- /package/{dist → dist-cjs}/index.js +0 -0
- /package/{dist → dist-cjs}/single-table-item/index.js +0 -0
- /package/{dist → dist-cjs}/single-table-item/utils/capitalize-first-letter.js +0 -0
- /package/{dist → dist-cjs}/single-table-item/utils/handle-composite-primary-key.js +0 -0
- /package/{dist → dist-cjs}/single-table-item/utils/index.js +0 -0
- /package/{dist → dist-cjs}/single-table-repository/index.js +0 -0
- /package/{dist → dist-cjs}/single-table-repository/types.js +0 -0
- /package/{dist → dist-cjs}/types.js +0 -0
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SingleTableItem = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const uuid_1 = require("uuid");
|
|
6
|
-
const decorators_1 = require("../decorators");
|
|
7
|
-
const utils_1 = require("./utils");
|
|
8
|
-
const errors_1 = require("../errors");
|
|
9
|
-
const decorated_class_1 = require("@itzworking/decorated-class");
|
|
10
|
-
let SingleTableItem = (() => {
|
|
11
|
-
let _classSuper = decorated_class_1.DecoratedClass;
|
|
12
|
-
let _id_decorators;
|
|
13
|
-
let _id_initializers = [];
|
|
14
|
-
let _id_extraInitializers = [];
|
|
15
|
-
let _createdAt_decorators;
|
|
16
|
-
let _createdAt_initializers = [];
|
|
17
|
-
let _createdAt_extraInitializers = [];
|
|
18
|
-
let _updatedAt_decorators;
|
|
19
|
-
let _updatedAt_initializers = [];
|
|
20
|
-
let _updatedAt_extraInitializers = [];
|
|
21
|
-
let _createdBy_decorators;
|
|
22
|
-
let _createdBy_initializers = [];
|
|
23
|
-
let _createdBy_extraInitializers = [];
|
|
24
|
-
let _updatedBy_decorators;
|
|
25
|
-
let _updatedBy_initializers = [];
|
|
26
|
-
let _updatedBy_extraInitializers = [];
|
|
27
|
-
let _deletedBy_decorators;
|
|
28
|
-
let _deletedBy_initializers = [];
|
|
29
|
-
let _deletedBy_extraInitializers = [];
|
|
30
|
-
let _deletedAt_decorators;
|
|
31
|
-
let _deletedAt_initializers = [];
|
|
32
|
-
let _deletedAt_extraInitializers = [];
|
|
33
|
-
return class SingleTableItem extends _classSuper {
|
|
34
|
-
static {
|
|
35
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
36
|
-
_id_decorators = [(0, decorated_class_1.Attribute)(decorated_class_1.AttributeType.String)];
|
|
37
|
-
_createdAt_decorators = [(0, decorated_class_1.Attribute)(decorated_class_1.AttributeType.Date)];
|
|
38
|
-
_updatedAt_decorators = [decorators_1.Editable, (0, decorated_class_1.Attribute)(decorated_class_1.AttributeType.Date)];
|
|
39
|
-
_createdBy_decorators = [(0, decorated_class_1.Attribute)(decorated_class_1.AttributeType.String)];
|
|
40
|
-
_updatedBy_decorators = [decorators_1.Editable, (0, decorated_class_1.Attribute)(decorated_class_1.AttributeType.String)];
|
|
41
|
-
_deletedBy_decorators = [(0, decorated_class_1.Attribute)(decorated_class_1.AttributeType.String)];
|
|
42
|
-
_deletedAt_decorators = [(0, decorated_class_1.Attribute)(decorated_class_1.AttributeType.Date)];
|
|
43
|
-
tslib_1.__esDecorate(null, null, _id_decorators, { kind: "field", name: "id", static: false, private: false, access: { has: obj => "id" in obj, get: obj => obj.id, set: (obj, value) => { obj.id = value; } }, metadata: _metadata }, _id_initializers, _id_extraInitializers);
|
|
44
|
-
tslib_1.__esDecorate(null, null, _createdAt_decorators, { kind: "field", name: "createdAt", static: false, private: false, access: { has: obj => "createdAt" in obj, get: obj => obj.createdAt, set: (obj, value) => { obj.createdAt = value; } }, metadata: _metadata }, _createdAt_initializers, _createdAt_extraInitializers);
|
|
45
|
-
tslib_1.__esDecorate(null, null, _updatedAt_decorators, { kind: "field", name: "updatedAt", static: false, private: false, access: { has: obj => "updatedAt" in obj, get: obj => obj.updatedAt, set: (obj, value) => { obj.updatedAt = value; } }, metadata: _metadata }, _updatedAt_initializers, _updatedAt_extraInitializers);
|
|
46
|
-
tslib_1.__esDecorate(null, null, _createdBy_decorators, { kind: "field", name: "createdBy", static: false, private: false, access: { has: obj => "createdBy" in obj, get: obj => obj.createdBy, set: (obj, value) => { obj.createdBy = value; } }, metadata: _metadata }, _createdBy_initializers, _createdBy_extraInitializers);
|
|
47
|
-
tslib_1.__esDecorate(null, null, _updatedBy_decorators, { kind: "field", name: "updatedBy", static: false, private: false, access: { has: obj => "updatedBy" in obj, get: obj => obj.updatedBy, set: (obj, value) => { obj.updatedBy = value; } }, metadata: _metadata }, _updatedBy_initializers, _updatedBy_extraInitializers);
|
|
48
|
-
tslib_1.__esDecorate(null, null, _deletedBy_decorators, { kind: "field", name: "deletedBy", static: false, private: false, access: { has: obj => "deletedBy" in obj, get: obj => obj.deletedBy, set: (obj, value) => { obj.deletedBy = value; } }, metadata: _metadata }, _deletedBy_initializers, _deletedBy_extraInitializers);
|
|
49
|
-
tslib_1.__esDecorate(null, null, _deletedAt_decorators, { kind: "field", name: "deletedAt", static: false, private: false, access: { has: obj => "deletedAt" in obj, get: obj => obj.deletedAt, set: (obj, value) => { obj.deletedAt = value; } }, metadata: _metadata }, _deletedAt_initializers, _deletedAt_extraInitializers);
|
|
50
|
-
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
51
|
-
}
|
|
52
|
-
id = tslib_1.__runInitializers(this, _id_initializers, void 0);
|
|
53
|
-
createdAt = (tslib_1.__runInitializers(this, _id_extraInitializers), tslib_1.__runInitializers(this, _createdAt_initializers, void 0));
|
|
54
|
-
updatedAt = (tslib_1.__runInitializers(this, _createdAt_extraInitializers), tslib_1.__runInitializers(this, _updatedAt_initializers, void 0));
|
|
55
|
-
createdBy = (tslib_1.__runInitializers(this, _updatedAt_extraInitializers), tslib_1.__runInitializers(this, _createdBy_initializers, void 0));
|
|
56
|
-
updatedBy = (tslib_1.__runInitializers(this, _createdBy_extraInitializers), tslib_1.__runInitializers(this, _updatedBy_initializers, void 0));
|
|
57
|
-
deletedBy = (tslib_1.__runInitializers(this, _updatedBy_extraInitializers), tslib_1.__runInitializers(this, _deletedBy_initializers, void 0));
|
|
58
|
-
deletedAt = (tslib_1.__runInitializers(this, _deletedBy_extraInitializers), tslib_1.__runInitializers(this, _deletedAt_initializers, void 0));
|
|
59
|
-
constructor(props = {}) {
|
|
60
|
-
super(props);
|
|
61
|
-
tslib_1.__runInitializers(this, _deletedAt_extraInitializers);
|
|
62
|
-
(0, utils_1.validateEntityAnnotations)(this);
|
|
63
|
-
if (!props?.id) {
|
|
64
|
-
this.generateId();
|
|
65
|
-
}
|
|
66
|
-
if (!props?.createdAt) {
|
|
67
|
-
this.createdAt = new Date();
|
|
68
|
-
}
|
|
69
|
-
if (!props?.updatedAt) {
|
|
70
|
-
this.updatedAt = new Date();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
generateId() {
|
|
74
|
-
this.id = (0, uuid_1.v4)();
|
|
75
|
-
return this.id;
|
|
76
|
-
}
|
|
77
|
-
type() {
|
|
78
|
-
return (0, decorators_1.getEntityName)(this);
|
|
79
|
-
}
|
|
80
|
-
pk() {
|
|
81
|
-
const keys = (0, decorators_1.getPKComposition)(this);
|
|
82
|
-
if (!keys?.length) {
|
|
83
|
-
throw new errors_1.IndexDecoratorError(`@Entity("${this.type()}") @Index: PK is not defined`);
|
|
84
|
-
}
|
|
85
|
-
return (0, utils_1.handleCompositePrimaryKey)(this, keys);
|
|
86
|
-
}
|
|
87
|
-
sk() {
|
|
88
|
-
const keys = (0, decorators_1.getSKComposition)(this);
|
|
89
|
-
if (!keys?.length) {
|
|
90
|
-
throw new errors_1.IndexDecoratorError(`@Entity("${this.type()}") @Index: SK is not defined`);
|
|
91
|
-
}
|
|
92
|
-
return (0, utils_1.handleCompositePrimaryKey)(this, keys);
|
|
93
|
-
}
|
|
94
|
-
key() {
|
|
95
|
-
return {
|
|
96
|
-
PK: this.pk(),
|
|
97
|
-
SK: this.sk(),
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
gsi1pk() {
|
|
101
|
-
return (0, utils_1.handleCompositePrimaryKey)(this, (0, decorators_1.getPKComposition)(this, "GSI1"));
|
|
102
|
-
}
|
|
103
|
-
gsi1sk() {
|
|
104
|
-
return (0, utils_1.handleCompositePrimaryKey)(this, (0, decorators_1.getSKComposition)(this, "GSI1"));
|
|
105
|
-
}
|
|
106
|
-
gsi2pk() {
|
|
107
|
-
return (0, utils_1.handleCompositePrimaryKey)(this, (0, decorators_1.getPKComposition)(this, "GSI2"));
|
|
108
|
-
}
|
|
109
|
-
gsi2sk() {
|
|
110
|
-
return (0, utils_1.handleCompositePrimaryKey)(this, (0, decorators_1.getSKComposition)(this, "GSI2"));
|
|
111
|
-
}
|
|
112
|
-
gsi3pk() {
|
|
113
|
-
return (0, utils_1.handleCompositePrimaryKey)(this, (0, decorators_1.getPKComposition)(this, "GSI3"));
|
|
114
|
-
}
|
|
115
|
-
gsi3sk() {
|
|
116
|
-
return (0, utils_1.handleCompositePrimaryKey)(this, (0, decorators_1.getSKComposition)(this, "GSI3"));
|
|
117
|
-
}
|
|
118
|
-
gsi4pk() {
|
|
119
|
-
return (0, utils_1.handleCompositePrimaryKey)(this, (0, decorators_1.getPKComposition)(this, "GSI4"));
|
|
120
|
-
}
|
|
121
|
-
gsi4sk() {
|
|
122
|
-
return (0, utils_1.handleCompositePrimaryKey)(this, (0, decorators_1.getSKComposition)(this, "GSI4"));
|
|
123
|
-
}
|
|
124
|
-
gsi5pk() {
|
|
125
|
-
return (0, utils_1.handleCompositePrimaryKey)(this, (0, decorators_1.getPKComposition)(this, "GSI5"));
|
|
126
|
-
}
|
|
127
|
-
gsi5sk() {
|
|
128
|
-
return (0, utils_1.handleCompositePrimaryKey)(this, (0, decorators_1.getSKComposition)(this, "GSI5"));
|
|
129
|
-
}
|
|
130
|
-
generateUpdateExpression(attributes = []) {
|
|
131
|
-
const attributesToUpdate = [];
|
|
132
|
-
const entityAttributes = (0, decorated_class_1.listAttributes)(this);
|
|
133
|
-
if (attributes?.length) {
|
|
134
|
-
for (const attribute of attributes) {
|
|
135
|
-
if (entityAttributes.find((ef) => ef.attributeName === attribute)) {
|
|
136
|
-
attributesToUpdate.push(attribute);
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
throw new errors_1.GenerateUpdateExpressionError(`@Entity("${this.type()}"): ${attribute} is not an @Attribute`);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
for (const attribute of entityAttributes) {
|
|
145
|
-
if (!(0, decorators_1.isEditable)(this, attribute.attributeName)) {
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
attributesToUpdate.push(attribute.attributeName);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
if (attributesToUpdate.length === 0) {
|
|
152
|
-
throw new errors_1.GenerateUpdateExpressionError(`@Entity("${this.type()}"): attributesToUpdate is empty; attributes = ${attributes}`);
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
const indexComposition = {
|
|
156
|
-
PK: (0, decorators_1.getPKComposition)(this),
|
|
157
|
-
SK: (0, decorators_1.getSKComposition)(this),
|
|
158
|
-
};
|
|
159
|
-
const indexPkSkAttributes = [
|
|
160
|
-
...(indexComposition.PK || []),
|
|
161
|
-
...(indexComposition.SK || []),
|
|
162
|
-
];
|
|
163
|
-
const notAllowedAttributes = indexPkSkAttributes.filter((attribute) => attributesToUpdate.includes(attribute));
|
|
164
|
-
if (notAllowedAttributes.length > 0) {
|
|
165
|
-
throw new errors_1.GenerateUpdateExpressionError(`@Entity("${this.type()}"): cannot update @Index notAllowedAttributes = ${notAllowedAttributes}`);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
const attributeValues = {};
|
|
169
|
-
const attributeNames = {};
|
|
170
|
-
const namesAndValues = [];
|
|
171
|
-
const attributesToRemove = [];
|
|
172
|
-
const gsis = {
|
|
173
|
-
GSI1: {
|
|
174
|
-
PK: (0, decorators_1.getPKComposition)(this, "GSI1"),
|
|
175
|
-
SK: (0, decorators_1.getSKComposition)(this, "GSI1"),
|
|
176
|
-
},
|
|
177
|
-
GSI2: {
|
|
178
|
-
PK: (0, decorators_1.getPKComposition)(this, "GSI2"),
|
|
179
|
-
SK: (0, decorators_1.getSKComposition)(this, "GSI2"),
|
|
180
|
-
},
|
|
181
|
-
GSI3: {
|
|
182
|
-
PK: (0, decorators_1.getPKComposition)(this, "GSI3"),
|
|
183
|
-
SK: (0, decorators_1.getSKComposition)(this, "GSI3"),
|
|
184
|
-
},
|
|
185
|
-
GSI4: {
|
|
186
|
-
PK: (0, decorators_1.getPKComposition)(this, "GSI4"),
|
|
187
|
-
SK: (0, decorators_1.getSKComposition)(this, "GSI4"),
|
|
188
|
-
},
|
|
189
|
-
GSI5: {
|
|
190
|
-
PK: (0, decorators_1.getPKComposition)(this, "GSI5"),
|
|
191
|
-
SK: (0, decorators_1.getSKComposition)(this, "GSI5"),
|
|
192
|
-
},
|
|
193
|
-
};
|
|
194
|
-
for (const [gsiKey, gsiComposition] of Object.entries(gsis)) {
|
|
195
|
-
for (const [gsiAttributeKey, gsiAttributeComposition] of Object.entries(gsiComposition)) {
|
|
196
|
-
if (gsiAttributeComposition?.some((key) => attributesToUpdate.includes(key))) {
|
|
197
|
-
attributeNames[`#key${gsiKey}${gsiAttributeKey}`] = `${gsiKey}${gsiAttributeKey}`;
|
|
198
|
-
attributeValues[`:value${gsiKey}${gsiAttributeKey}`] = this[`${gsiKey}${gsiAttributeKey}`.toLowerCase()]();
|
|
199
|
-
namesAndValues.push(`#key${gsiKey}${gsiAttributeKey} = :value${gsiKey}${gsiAttributeKey}`);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
for (const key of attributesToUpdate) {
|
|
204
|
-
const keyToUse = (0, utils_1.capitalizeFirstLetter)(key);
|
|
205
|
-
const value = this[key];
|
|
206
|
-
attributeNames[`#key${keyToUse}`] = key;
|
|
207
|
-
if (value === undefined) {
|
|
208
|
-
attributesToRemove.push(`#key${keyToUse}`);
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
attributeValues[`:value${keyToUse}`] =
|
|
212
|
-
value instanceof Date ? value.toISOString() : value;
|
|
213
|
-
namesAndValues.push(`#key${keyToUse} = :value${keyToUse}`);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
return {
|
|
217
|
-
UpdateExpression: ((namesAndValues.length ? `SET ${namesAndValues.join(", ")} ` : "") +
|
|
218
|
-
(attributesToRemove.length
|
|
219
|
-
? `REMOVE ${attributesToRemove.join(", ")}`
|
|
220
|
-
: "")).trim(),
|
|
221
|
-
ExpressionAttributeNames: attributeNames,
|
|
222
|
-
ExpressionAttributeValues: attributeValues,
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
toSingleTableItem() {
|
|
226
|
-
const result = {
|
|
227
|
-
type: this.type(),
|
|
228
|
-
...this.key(),
|
|
229
|
-
};
|
|
230
|
-
if (this.gsi1pk() && this.gsi1sk()) {
|
|
231
|
-
result.GSI1PK = this.gsi1pk();
|
|
232
|
-
result.GSI1SK = this.gsi1sk();
|
|
233
|
-
}
|
|
234
|
-
if (this.gsi2pk() && this.gsi2sk()) {
|
|
235
|
-
result.GSI2PK = this.gsi2pk();
|
|
236
|
-
result.GSI2SK = this.gsi2sk();
|
|
237
|
-
}
|
|
238
|
-
if (this.gsi3pk() && this.gsi3sk()) {
|
|
239
|
-
result.GSI3PK = this.gsi3pk();
|
|
240
|
-
result.GSI3SK = this.gsi3sk();
|
|
241
|
-
}
|
|
242
|
-
if (this.gsi4pk() && this.gsi4sk()) {
|
|
243
|
-
result.GSI4PK = this.gsi4pk();
|
|
244
|
-
result.GSI4SK = this.gsi4sk();
|
|
245
|
-
}
|
|
246
|
-
if (this.gsi5pk() && this.gsi5sk()) {
|
|
247
|
-
result.GSI5PK = this.gsi5pk();
|
|
248
|
-
result.GSI5SK = this.gsi5sk();
|
|
249
|
-
}
|
|
250
|
-
const attributes = (0, decorated_class_1.listAttributes)(this);
|
|
251
|
-
const reservedKeys = [
|
|
252
|
-
"type",
|
|
253
|
-
"PK",
|
|
254
|
-
"SK",
|
|
255
|
-
"GSI1PK",
|
|
256
|
-
"GSI1SK",
|
|
257
|
-
"GSI2PK",
|
|
258
|
-
"GSI2SK",
|
|
259
|
-
"GSI3PK",
|
|
260
|
-
"GSI3SK",
|
|
261
|
-
"GSI4PK",
|
|
262
|
-
"GSI4SK",
|
|
263
|
-
"GSI5PK",
|
|
264
|
-
"GSI5SK",
|
|
265
|
-
];
|
|
266
|
-
const reservedKeysInUse = reservedKeys.filter((reservedKey) => attributes.find((f) => f.attributeName === reservedKey));
|
|
267
|
-
if (reservedKeysInUse.length > 0) {
|
|
268
|
-
throw new errors_1.SingleTableItemFormatError(`@Entity("${this.type()}"): cannot use reserved keys in attributes = ${reservedKeysInUse}`);
|
|
269
|
-
}
|
|
270
|
-
for (const attribute of attributes) {
|
|
271
|
-
const value = this[attribute.attributeName];
|
|
272
|
-
if (value !== undefined) {
|
|
273
|
-
result[attribute.attributeName] =
|
|
274
|
-
value instanceof Date ? value.toISOString() : value;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
return result;
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
})();
|
|
281
|
-
exports.SingleTableItem = SingleTableItem;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"capitalize-first-letter.d.ts","sourceRoot":"","sources":["../../../src/single-table-item/utils/capitalize-first-letter.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,MAAO,MAAM,WAE9C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handle-composite-primary-key.d.ts","sourceRoot":"","sources":["../../../src/single-table-item/utils/handle-composite-primary-key.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,yBAAyB,WAC5B,GAAG,SACJ,MAAM,EAAE,KACd,MA4BF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/single-table-item/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate-entity-annotations.d.ts","sourceRoot":"","sources":["../../../src/single-table-item/utils/validate-entity-annotations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,eAAO,MAAM,yBAAyB,GAAI,CAAC,SAAS,eAAe,UACzD,CAAC,SAiCV,CAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateEntityAnnotations = void 0;
|
|
4
|
-
const errors_1 = require("../../errors");
|
|
5
|
-
const validateEntityAnnotations = (entity) => {
|
|
6
|
-
const errors = [];
|
|
7
|
-
if (!entity.type()) {
|
|
8
|
-
errors.push("missing @Entity annotation on SingleTableItem class");
|
|
9
|
-
}
|
|
10
|
-
try {
|
|
11
|
-
entity.key();
|
|
12
|
-
}
|
|
13
|
-
catch (e) {
|
|
14
|
-
errors.push("missing @Index annotation on SingleTableItem class");
|
|
15
|
-
}
|
|
16
|
-
// const gsis = {
|
|
17
|
-
// GSI1: getGSI1Composition(this),
|
|
18
|
-
// GSI2: getGSI2Composition(this),
|
|
19
|
-
// GSI3: getGSI3Composition(this),
|
|
20
|
-
// GSI4: getGSI4Composition(this),
|
|
21
|
-
// GSI5: getGSI5Composition(this),
|
|
22
|
-
// };
|
|
23
|
-
// for (const [gsi, gsiComposition] of Object.entries(gsis)) {
|
|
24
|
-
// if (!gsiComposition.PK && !gsiComposition.SK) {
|
|
25
|
-
// continue;
|
|
26
|
-
// }
|
|
27
|
-
// if (!gsiComposition.PK?.length) {
|
|
28
|
-
// errors.push(`@Entity("${this.type()}"): @${gsi} requires a PK with a length > 0`);
|
|
29
|
-
// }
|
|
30
|
-
// if (!gsiComposition.SK?.length) {
|
|
31
|
-
// errors.push(`@Entity("${this.type()}"): @${gsi} requires a SK with a length > 0`);
|
|
32
|
-
// }
|
|
33
|
-
// }
|
|
34
|
-
if (errors.length) {
|
|
35
|
-
throw new errors_1.DecoratorsError(errors.join(","));
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
exports.validateEntityAnnotations = validateEntityAnnotations;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/single-table-repository/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"single-table-repository.d.ts","sourceRoot":"","sources":["../../src/single-table-repository/single-table-repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,iBAAiB,EAEjB,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,+BAA+B,EAC/B,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAWjB,8BAAsB,qBAAqB,CAAC,CAAC,SAAS,eAAe;IACnE,QAAQ,CAAC,SAAS,SACuD;IAEzE,SAAS,IAAI,MAAM;IAQb,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,CAAC;IAoC1D,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAepD,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAwB7D,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB7D,KAAK,CACT,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC;QAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,CAAC;IAO5D,wBAAwB,CAAC,CAAC,SAAS,eAAe,EACtD,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC;QAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,CAAC;CAwHnE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/single-table-repository/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,UAAU,CAAC,EAAE,CAAC,MAAM,qBAAqB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAChD,KAAK,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IACnD,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,KAAK,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACpC;AAED,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC;AAE1D,MAAM,WAAW,+BAAgC,SAAQ,iBAAiB;IACxE,aAAa,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;CACzC"}
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,GACb,YAAY,GACZ,IAAI,GACJ,IAAI,GACJ,KAAK,GACL,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,0BAA0B,GAC1B,mBAAmB,CAAC;AAExB,MAAM,MAAM,qBAAqB,CAAC,CAAC,IAAI;KACpC,GAAG,IAAI,MAAM,CAAC,IAAI,GAAG,SAAS,YAAY,GAAG,KAAK,GAAG,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC;CACnE,CAAC"}
|
|
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
|