dyna-record 0.6.7 → 0.7.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/README.md +23 -7
- package/dist/index.d.ts +12 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -22
- package/dist/src/DynaRecord.d.ts +3 -3
- package/dist/src/DynaRecord.d.ts.map +1 -1
- package/dist/src/DynaRecord.js +24 -59
- package/dist/src/Logger.js +1 -3
- package/dist/src/decorators/Entity.d.ts +1 -1
- package/dist/src/decorators/Entity.d.ts.map +1 -1
- package/dist/src/decorators/Entity.js +3 -8
- package/dist/src/decorators/Table.d.ts +2 -2
- package/dist/src/decorators/Table.d.ts.map +1 -1
- package/dist/src/decorators/Table.js +3 -8
- package/dist/src/decorators/attributes/BooleanAttribute.d.ts +2 -2
- package/dist/src/decorators/attributes/BooleanAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/BooleanAttribute.js +5 -10
- package/dist/src/decorators/attributes/DateAttribute.d.ts +2 -2
- package/dist/src/decorators/attributes/DateAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/DateAttribute.js +7 -12
- package/dist/src/decorators/attributes/EnumAttribute.d.ts +2 -2
- package/dist/src/decorators/attributes/EnumAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/EnumAttribute.js +5 -10
- package/dist/src/decorators/attributes/ForeignKeyAttribute.d.ts +3 -3
- package/dist/src/decorators/attributes/ForeignKeyAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/ForeignKeyAttribute.js +5 -10
- package/dist/src/decorators/attributes/IdAttribute.d.ts +1 -1
- package/dist/src/decorators/attributes/IdAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/IdAttribute.js +3 -8
- package/dist/src/decorators/attributes/NumberAttribute.d.ts +2 -2
- package/dist/src/decorators/attributes/NumberAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/NumberAttribute.js +5 -10
- package/dist/src/decorators/attributes/ObjectAttribute.d.ts +3 -3
- package/dist/src/decorators/attributes/ObjectAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/ObjectAttribute.js +16 -21
- package/dist/src/decorators/attributes/PartitionKeyAttribute.d.ts +3 -3
- package/dist/src/decorators/attributes/PartitionKeyAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/PartitionKeyAttribute.js +5 -10
- package/dist/src/decorators/attributes/SortKeyAttribute.d.ts +3 -3
- package/dist/src/decorators/attributes/SortKeyAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/SortKeyAttribute.js +5 -10
- package/dist/src/decorators/attributes/StringAttribute.d.ts +2 -2
- package/dist/src/decorators/attributes/StringAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/StringAttribute.js +5 -10
- package/dist/src/decorators/attributes/index.d.ts +13 -13
- package/dist/src/decorators/attributes/index.d.ts.map +1 -1
- package/dist/src/decorators/attributes/index.js +11 -41
- package/dist/src/decorators/attributes/serializers.d.ts +2 -2
- package/dist/src/decorators/attributes/serializers.d.ts.map +1 -1
- package/dist/src/decorators/attributes/serializers.js +5 -12
- package/dist/src/decorators/attributes/types.js +1 -2
- package/dist/src/decorators/index.d.ts +5 -5
- package/dist/src/decorators/index.d.ts.map +1 -1
- package/dist/src/decorators/index.js +5 -27
- package/dist/src/decorators/relationships/BelongsTo.d.ts +4 -4
- package/dist/src/decorators/relationships/BelongsTo.d.ts.map +1 -1
- package/dist/src/decorators/relationships/BelongsTo.js +3 -8
- package/dist/src/decorators/relationships/HasAndBelongsToMany.d.ts +3 -3
- package/dist/src/decorators/relationships/HasAndBelongsToMany.d.ts.map +1 -1
- package/dist/src/decorators/relationships/HasAndBelongsToMany.js +4 -9
- package/dist/src/decorators/relationships/HasMany.d.ts +3 -3
- package/dist/src/decorators/relationships/HasMany.d.ts.map +1 -1
- package/dist/src/decorators/relationships/HasMany.js +4 -9
- package/dist/src/decorators/relationships/HasOne.d.ts +3 -3
- package/dist/src/decorators/relationships/HasOne.d.ts.map +1 -1
- package/dist/src/decorators/relationships/HasOne.js +3 -8
- package/dist/src/decorators/relationships/index.d.ts +5 -5
- package/dist/src/decorators/relationships/index.d.ts.map +1 -1
- package/dist/src/decorators/relationships/index.js +5 -29
- package/dist/src/decorators/relationships/types.d.ts +3 -3
- package/dist/src/decorators/relationships/types.d.ts.map +1 -1
- package/dist/src/decorators/relationships/types.js +1 -2
- package/dist/src/decorators/types.d.ts +3 -3
- package/dist/src/decorators/types.d.ts.map +1 -1
- package/dist/src/decorators/types.js +1 -2
- package/dist/src/dynamo-utils/DynamoClient.d.ts +1 -1
- package/dist/src/dynamo-utils/DynamoClient.d.ts.map +1 -1
- package/dist/src/dynamo-utils/DynamoClient.js +13 -18
- package/dist/src/dynamo-utils/TransactGetBuilder.d.ts +1 -1
- package/dist/src/dynamo-utils/TransactGetBuilder.d.ts.map +1 -1
- package/dist/src/dynamo-utils/TransactGetBuilder.js +5 -10
- package/dist/src/dynamo-utils/TransactWriteBuilder.d.ts +1 -1
- package/dist/src/dynamo-utils/TransactWriteBuilder.d.ts.map +1 -1
- package/dist/src/dynamo-utils/TransactWriteBuilder.js +11 -16
- package/dist/src/dynamo-utils/errors.js +2 -7
- package/dist/src/dynamo-utils/index.d.ts +7 -7
- package/dist/src/dynamo-utils/index.d.ts.map +1 -1
- package/dist/src/dynamo-utils/index.js +7 -30
- package/dist/src/dynamo-utils/types.js +1 -2
- package/dist/src/errors.js +3 -9
- package/dist/src/id.d.ts +12 -0
- package/dist/src/id.d.ts.map +1 -0
- package/dist/src/id.js +11 -0
- package/dist/src/index.d.ts +8 -8
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -20
- package/dist/src/metadata/AttributeMetadata.d.ts +4 -4
- package/dist/src/metadata/AttributeMetadata.d.ts.map +1 -1
- package/dist/src/metadata/AttributeMetadata.js +1 -3
- package/dist/src/metadata/EntityMetadata.d.ts +3 -3
- package/dist/src/metadata/EntityMetadata.d.ts.map +1 -1
- package/dist/src/metadata/EntityMetadata.js +18 -23
- package/dist/src/metadata/JoinTableMetadata.d.ts +3 -3
- package/dist/src/metadata/JoinTableMetadata.d.ts.map +1 -1
- package/dist/src/metadata/JoinTableMetadata.js +1 -3
- package/dist/src/metadata/MetadataStorage.d.ts +7 -7
- package/dist/src/metadata/MetadataStorage.d.ts.map +1 -1
- package/dist/src/metadata/MetadataStorage.js +12 -17
- package/dist/src/metadata/TableMetadata.d.ts +3 -3
- package/dist/src/metadata/TableMetadata.d.ts.map +1 -1
- package/dist/src/metadata/TableMetadata.js +17 -20
- package/dist/src/metadata/index.d.ts +9 -9
- package/dist/src/metadata/index.d.ts.map +1 -1
- package/dist/src/metadata/index.js +11 -34
- package/dist/src/metadata/relationship-metadata/BelongsToRelationship.d.ts +2 -2
- package/dist/src/metadata/relationship-metadata/BelongsToRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/BelongsToRelationship.js +3 -8
- package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.d.ts +1 -1
- package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.js +3 -8
- package/dist/src/metadata/relationship-metadata/HasManyRelationship.d.ts +2 -2
- package/dist/src/metadata/relationship-metadata/HasManyRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/HasManyRelationship.js +3 -8
- package/dist/src/metadata/relationship-metadata/HasOneRelationship.d.ts +2 -2
- package/dist/src/metadata/relationship-metadata/HasOneRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/HasOneRelationship.js +3 -8
- package/dist/src/metadata/relationship-metadata/OwnedByRelationship.d.ts +2 -2
- package/dist/src/metadata/relationship-metadata/OwnedByRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/OwnedByRelationship.js +3 -8
- package/dist/src/metadata/relationship-metadata/RelationshipMetadata.d.ts +2 -2
- package/dist/src/metadata/relationship-metadata/RelationshipMetadata.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/RelationshipMetadata.js +1 -3
- package/dist/src/metadata/relationship-metadata/index.d.ts +6 -6
- package/dist/src/metadata/relationship-metadata/index.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/index.js +7 -31
- package/dist/src/metadata/relationship-metadata/types.d.ts +5 -5
- package/dist/src/metadata/relationship-metadata/types.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/types.js +1 -2
- package/dist/src/metadata/relationship-metadata/utils.d.ts +1 -1
- package/dist/src/metadata/relationship-metadata/utils.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/utils.js +11 -18
- package/dist/src/metadata/schemas.d.ts +3 -3
- package/dist/src/metadata/schemas.d.ts.map +1 -1
- package/dist/src/metadata/schemas.js +34 -37
- package/dist/src/metadata/types.d.ts +4 -4
- package/dist/src/metadata/types.d.ts.map +1 -1
- package/dist/src/metadata/types.js +1 -2
- package/dist/src/metadata/utils.d.ts +5 -5
- package/dist/src/metadata/utils.d.ts.map +1 -1
- package/dist/src/metadata/utils.js +14 -29
- package/dist/src/operations/Create/Create.d.ts +5 -5
- package/dist/src/operations/Create/Create.d.ts.map +1 -1
- package/dist/src/operations/Create/Create.js +18 -23
- package/dist/src/operations/Create/index.d.ts +2 -2
- package/dist/src/operations/Create/index.d.ts.map +1 -1
- package/dist/src/operations/Create/index.js +2 -23
- package/dist/src/operations/Create/types.d.ts +2 -2
- package/dist/src/operations/Create/types.d.ts.map +1 -1
- package/dist/src/operations/Create/types.js +1 -2
- package/dist/src/operations/Delete/Delete.d.ts +3 -3
- package/dist/src/operations/Delete/Delete.d.ts.map +1 -1
- package/dist/src/operations/Delete/Delete.js +28 -33
- package/dist/src/operations/Delete/index.d.ts +1 -1
- package/dist/src/operations/Delete/index.d.ts.map +1 -1
- package/dist/src/operations/Delete/index.js +1 -8
- package/dist/src/operations/Delete/types.js +1 -2
- package/dist/src/operations/FindById/FindById.d.ts +4 -4
- package/dist/src/operations/FindById/FindById.d.ts.map +1 -1
- package/dist/src/operations/FindById/FindById.js +17 -22
- package/dist/src/operations/FindById/index.d.ts +2 -2
- package/dist/src/operations/FindById/index.d.ts.map +1 -1
- package/dist/src/operations/FindById/index.js +2 -23
- package/dist/src/operations/FindById/types.d.ts +3 -3
- package/dist/src/operations/FindById/types.d.ts.map +1 -1
- package/dist/src/operations/FindById/types.js +1 -2
- package/dist/src/operations/OperationBase.d.ts +3 -3
- package/dist/src/operations/OperationBase.d.ts.map +1 -1
- package/dist/src/operations/OperationBase.js +4 -9
- package/dist/src/operations/Query/Query.d.ts +4 -4
- package/dist/src/operations/Query/Query.d.ts.map +1 -1
- package/dist/src/operations/Query/Query.js +15 -20
- package/dist/src/operations/Query/index.d.ts +2 -2
- package/dist/src/operations/Query/index.d.ts.map +1 -1
- package/dist/src/operations/Query/index.js +2 -23
- package/dist/src/operations/Query/types.d.ts +4 -4
- package/dist/src/operations/Query/types.d.ts.map +1 -1
- package/dist/src/operations/Query/types.js +1 -2
- package/dist/src/operations/Update/Update.d.ts +5 -5
- package/dist/src/operations/Update/Update.d.ts.map +1 -1
- package/dist/src/operations/Update/Update.js +37 -42
- package/dist/src/operations/Update/UpdateDryRun.d.ts +2 -2
- package/dist/src/operations/Update/UpdateDryRun.d.ts.map +1 -1
- package/dist/src/operations/Update/UpdateDryRun.js +3 -8
- package/dist/src/operations/Update/index.d.ts +3 -3
- package/dist/src/operations/Update/index.d.ts.map +1 -1
- package/dist/src/operations/Update/index.js +3 -25
- package/dist/src/operations/Update/types.d.ts +2 -2
- package/dist/src/operations/Update/types.d.ts.map +1 -1
- package/dist/src/operations/Update/types.js +1 -2
- package/dist/src/operations/index.d.ts +6 -6
- package/dist/src/operations/index.d.ts.map +1 -1
- package/dist/src/operations/index.js +6 -22
- package/dist/src/operations/types.d.ts +3 -3
- package/dist/src/operations/types.d.ts.map +1 -1
- package/dist/src/operations/types.js +1 -2
- package/dist/src/operations/utils/expressionBuilder.d.ts +2 -2
- package/dist/src/operations/utils/expressionBuilder.d.ts.map +1 -1
- package/dist/src/operations/utils/expressionBuilder.js +1 -5
- package/dist/src/operations/utils/flattenObjectForUpdate.d.ts +2 -2
- package/dist/src/operations/utils/flattenObjectForUpdate.d.ts.map +1 -1
- package/dist/src/operations/utils/flattenObjectForUpdate.js +3 -6
- package/dist/src/operations/utils/index.d.ts +5 -5
- package/dist/src/operations/utils/index.d.ts.map +1 -1
- package/dist/src/operations/utils/index.js +5 -21
- package/dist/src/operations/utils/mergePartialObjectAttributes.d.ts +1 -1
- package/dist/src/operations/utils/mergePartialObjectAttributes.d.ts.map +1 -1
- package/dist/src/operations/utils/mergePartialObjectAttributes.js +1 -4
- package/dist/src/operations/utils/types.js +1 -2
- package/dist/src/operations/utils/utils.d.ts +4 -4
- package/dist/src/operations/utils/utils.d.ts.map +1 -1
- package/dist/src/operations/utils/utils.js +13 -23
- package/dist/src/query-utils/Filters.d.ts +2 -2
- package/dist/src/query-utils/Filters.d.ts.map +1 -1
- package/dist/src/query-utils/Filters.js +1 -4
- package/dist/src/query-utils/QueryBuilder.d.ts +1 -1
- package/dist/src/query-utils/QueryBuilder.d.ts.map +1 -1
- package/dist/src/query-utils/QueryBuilder.js +8 -13
- package/dist/src/query-utils/index.d.ts +2 -2
- package/dist/src/query-utils/index.d.ts.map +1 -1
- package/dist/src/query-utils/index.js +2 -23
- package/dist/src/query-utils/types.js +1 -2
- package/dist/src/relationships/JoinTable.d.ts +2 -2
- package/dist/src/relationships/JoinTable.d.ts.map +1 -1
- package/dist/src/relationships/JoinTable.js +14 -19
- package/dist/src/relationships/index.d.ts +1 -1
- package/dist/src/relationships/index.d.ts.map +1 -1
- package/dist/src/relationships/index.js +1 -8
- package/dist/src/types.d.ts +2 -2
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +1 -2
- package/dist/src/utils.d.ts +3 -3
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +16 -31
- package/package.json +28 -24
package/dist/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE5D,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAElE;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAC5B,aAAa,UAAU,UAAU,EACjC,YAAY,OAAO,CAAC,UAAU,CAAC,KAC9B,eAoBF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,UAAU,EACpD,aAAa,UAAU,CAAC,EACxB,WAAW,eAAe,KACzB,CAsBF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,UAAU,EACjD,aAAa,UAAU,CAAC,EACxB,YAAY,oBAAoB,CAAC,CAAC,CAAC,KAClC,CAUF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,UAAU,EAClB,KAAK,MAAM,KACV,GAAG,IAAI,MAAM,UAEf,CAAC;AAEF;;;;;GAKG;AAEH,eAAO,MAAM,aAAa,GAAI,CAAC,EAC7B,QAAQ,OAAO,CAAC,UAAU,CAAC,EAC3B,KAAK,WAAW,KACf,GAAG,IAAI,MAAM,CAEf,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,MAAM,MAAM,KAAG,CAAC,EAAE,EAI3D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAElD,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,SAAS,oBAAoB,CAAC,UAAU,CAAC,EACzE,QAAQ,OAAO,EACf,KAAK,MAAM,OAAO,EAClB,OAAO,OAAO,KACb,IAEF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,OAAO,KAAG,GAAG,IAAI,QAAQ,CAAC,MAAM,CAErE,CAAC"}
|
package/dist/src/utils.js
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isNullableString = exports.safeAssign = exports.isString = exports.chunkArray = exports.isKeyOfObject = exports.isKeyOfEntity = exports.createInstance = exports.tableItemToEntity = exports.entityToTableItem = void 0;
|
|
7
|
-
const metadata_1 = __importDefault(require("./metadata"));
|
|
1
|
+
import Metadata from "./metadata/index.js";
|
|
8
2
|
/**
|
|
9
3
|
* Convert an entity to its aliased table item fields to for dynamo interactions
|
|
10
4
|
* @param entityClassName
|
|
11
5
|
* @param entityData
|
|
12
6
|
* @returns
|
|
13
7
|
*/
|
|
14
|
-
const entityToTableItem = (EntityClass, entityData) => {
|
|
15
|
-
const attributesMeta =
|
|
8
|
+
export const entityToTableItem = (EntityClass, entityData) => {
|
|
9
|
+
const attributesMeta = Metadata.getEntityAttributes(EntityClass.name);
|
|
16
10
|
return Object.entries(entityData).reduce((acc, [key, rawVal]) => {
|
|
17
11
|
if (key in attributesMeta) {
|
|
18
12
|
const attrMeta = attributesMeta[key];
|
|
@@ -27,52 +21,48 @@ const entityToTableItem = (EntityClass, entityData) => {
|
|
|
27
21
|
return acc;
|
|
28
22
|
}, {});
|
|
29
23
|
};
|
|
30
|
-
exports.entityToTableItem = entityToTableItem;
|
|
31
24
|
/**
|
|
32
25
|
* Serialize a table item to its associated Entity class, using the class attribute property names
|
|
33
26
|
* @param EntityClass
|
|
34
27
|
* @param tableItem
|
|
35
28
|
* @returns
|
|
36
29
|
*/
|
|
37
|
-
const tableItemToEntity = (EntityClass, tableItem) => {
|
|
38
|
-
const tableAttributes =
|
|
30
|
+
export const tableItemToEntity = (EntityClass, tableItem) => {
|
|
31
|
+
const tableAttributes = Metadata.getEntityTableAttributes(EntityClass.name);
|
|
39
32
|
const entity = new EntityClass();
|
|
40
33
|
Object.keys(tableItem).forEach(attrName => {
|
|
41
34
|
if (attrName in tableAttributes) {
|
|
42
35
|
const attrMeta = tableAttributes[attrName];
|
|
43
36
|
const { name: entityKey, serializers } = attrMeta;
|
|
44
|
-
if (
|
|
37
|
+
if (isKeyOfEntity(entity, entityKey)) {
|
|
45
38
|
const rawVal = tableItem[attrName];
|
|
46
39
|
const val = serializers?.toEntityAttribute === undefined
|
|
47
40
|
? rawVal
|
|
48
41
|
: serializers.toEntityAttribute(rawVal);
|
|
49
|
-
|
|
42
|
+
safeAssign(entity, entityKey, val);
|
|
50
43
|
}
|
|
51
44
|
}
|
|
52
45
|
});
|
|
53
46
|
return entity;
|
|
54
47
|
};
|
|
55
|
-
exports.tableItemToEntity = tableItemToEntity;
|
|
56
48
|
/**
|
|
57
49
|
* Create an instance of a dyna record class
|
|
58
50
|
*/
|
|
59
|
-
const createInstance = (EntityClass, attributes) => {
|
|
51
|
+
export const createInstance = (EntityClass, attributes) => {
|
|
60
52
|
const entity = new EntityClass();
|
|
61
53
|
Object.entries(attributes).forEach(([attrName, val]) => {
|
|
62
|
-
if (
|
|
63
|
-
|
|
54
|
+
if (isKeyOfEntity(entity, attrName)) {
|
|
55
|
+
safeAssign(entity, attrName, val);
|
|
64
56
|
}
|
|
65
57
|
});
|
|
66
58
|
return entity;
|
|
67
59
|
};
|
|
68
|
-
exports.createInstance = createInstance;
|
|
69
60
|
/**
|
|
70
61
|
* Type guard to check if the key is defined on the entity
|
|
71
62
|
*/
|
|
72
|
-
const isKeyOfEntity = (entity, key) => {
|
|
63
|
+
export const isKeyOfEntity = (entity, key) => {
|
|
73
64
|
return key in entity;
|
|
74
65
|
};
|
|
75
|
-
exports.isKeyOfEntity = isKeyOfEntity;
|
|
76
66
|
/**
|
|
77
67
|
* Type guard to check if the key is a defined property on the entity
|
|
78
68
|
* @param entity
|
|
@@ -80,30 +70,27 @@ exports.isKeyOfEntity = isKeyOfEntity;
|
|
|
80
70
|
* @returns
|
|
81
71
|
*/
|
|
82
72
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- Generic T needed for narrowing key to keyof T at call sites
|
|
83
|
-
const isKeyOfObject = (entity, key) => {
|
|
73
|
+
export const isKeyOfObject = (entity, key) => {
|
|
84
74
|
return key in entity;
|
|
85
75
|
};
|
|
86
|
-
exports.isKeyOfObject = isKeyOfObject;
|
|
87
76
|
/**
|
|
88
77
|
* Break an array into chunks
|
|
89
78
|
* @param array
|
|
90
79
|
* @param size
|
|
91
80
|
* @returns Array split into chunks of given size
|
|
92
81
|
*/
|
|
93
|
-
const chunkArray = (array, size) => {
|
|
82
|
+
export const chunkArray = (array, size) => {
|
|
94
83
|
return Array.from({ length: Math.ceil(array.length / size) }, (_, index) => array.slice(index * size, (index + 1) * size));
|
|
95
84
|
};
|
|
96
|
-
exports.chunkArray = chunkArray;
|
|
97
85
|
/**
|
|
98
86
|
* Checks if the given value is a string.
|
|
99
87
|
*
|
|
100
88
|
* @param value - The value to check. This can be any type as the function is meant to validate if it's a string.
|
|
101
89
|
* @returns `true` if `value` is a string; otherwise, `false`.
|
|
102
90
|
*/
|
|
103
|
-
const isString = (value) => {
|
|
91
|
+
export const isString = (value) => {
|
|
104
92
|
return typeof value === "string";
|
|
105
93
|
};
|
|
106
|
-
exports.isString = isString;
|
|
107
94
|
/**
|
|
108
95
|
* Safely assigns a value to a property of an object.
|
|
109
96
|
* It's useful for dynamically assigning properties to objects where the property names might be known but the types could vary.
|
|
@@ -122,16 +109,14 @@ exports.isString = isString;
|
|
|
122
109
|
* let entity = { id: "123" };
|
|
123
110
|
* safeAssign(entity, "name", "Jane Doe");
|
|
124
111
|
*/
|
|
125
|
-
const safeAssign = (object, key, value) => {
|
|
112
|
+
export const safeAssign = (object, key, value) => {
|
|
126
113
|
object[key] = value;
|
|
127
114
|
};
|
|
128
|
-
exports.safeAssign = safeAssign;
|
|
129
115
|
/**
|
|
130
116
|
* Type guard to check if a string is a Nullable<string>
|
|
131
117
|
* @param val
|
|
132
118
|
* @returns
|
|
133
119
|
*/
|
|
134
|
-
const isNullableString = (val) => {
|
|
120
|
+
export const isNullableString = (val) => {
|
|
135
121
|
return typeof val === "string" || val === null;
|
|
136
122
|
};
|
|
137
|
-
exports.isNullableString = isNullableString;
|
package/package.json
CHANGED
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dyna-record",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Typescript Data Modeler and ORM for Dynamo",
|
|
5
|
-
"
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
7
15
|
"scripts": {
|
|
8
16
|
"build": "tsc",
|
|
9
|
-
"watch": "tsc
|
|
17
|
+
"watch": "tsc --watch",
|
|
10
18
|
"typecheck": "tsc --noEmit && tsc -p tsconfig.dev.json --noEmit",
|
|
11
19
|
"typecheck:tests": "tsc -p tsconfig.dev.json --noEmit",
|
|
12
|
-
"test": "tsc -p tsconfig.dev.json --noEmit &&
|
|
13
|
-
"test:watch": "
|
|
20
|
+
"test": "tsc -p tsconfig.dev.json --noEmit && vitest run",
|
|
21
|
+
"test:watch": "vitest",
|
|
14
22
|
"eslint": "npx eslint .",
|
|
15
23
|
"eslint:fix": "npx eslint . --fix",
|
|
16
24
|
"prettier": "npx prettier . --write",
|
|
17
|
-
"docs": "npx typedoc"
|
|
25
|
+
"docs": "npx typedoc",
|
|
26
|
+
"prepublishOnly": "npm run build && npx publint"
|
|
18
27
|
},
|
|
19
28
|
"repository": {
|
|
20
29
|
"type": "git",
|
|
@@ -30,32 +39,27 @@
|
|
|
30
39
|
"@aws-sdk/client-dynamodb": "^3.502.0",
|
|
31
40
|
"@aws-sdk/lib-dynamodb": "^3.502.0",
|
|
32
41
|
"@aws-sdk/util-dynamodb": "^3.509.0",
|
|
33
|
-
"uuid": "^9.0.1",
|
|
34
42
|
"zod": "^4.3.6"
|
|
35
43
|
},
|
|
36
44
|
"devDependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"
|
|
42
|
-
"@types/uuid": "^9.0.8",
|
|
43
|
-
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
44
|
-
"eslint": "^9.39.3",
|
|
45
|
+
"@eslint/js": "^10.0.1",
|
|
46
|
+
"@types/node": "^22.19.19",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^8.60.0",
|
|
48
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
49
|
+
"eslint": "^10.4.0",
|
|
45
50
|
"eslint-config-prettier": "^10.1.8",
|
|
46
51
|
"globals": "^16.5.0",
|
|
47
|
-
"jest": "^29.7.0",
|
|
48
52
|
"prettier": "^3.2.5",
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"typedoc": "^
|
|
52
|
-
"
|
|
53
|
-
"typescript": "^
|
|
54
|
-
"
|
|
53
|
+
"publint": "^0.3.21",
|
|
54
|
+
"typedoc": "^0.28.19",
|
|
55
|
+
"typedoc-plugin-missing-exports": "^4.1.3",
|
|
56
|
+
"typescript": "^6.0.3",
|
|
57
|
+
"typescript-eslint": "^8.60.0",
|
|
58
|
+
"vitest": "^3.2.4"
|
|
55
59
|
},
|
|
56
60
|
"engines": {
|
|
57
61
|
"npm": ">=10.0.0",
|
|
58
|
-
"node": ">=
|
|
62
|
+
"node": ">=22.12.0"
|
|
59
63
|
},
|
|
60
64
|
"files": [
|
|
61
65
|
"dist/**/*"
|