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/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from "./decorators";
|
|
2
|
-
export * from "./errors";
|
|
3
|
-
export * from "./relationships";
|
|
4
|
-
export * from "./dynamo-utils/errors";
|
|
5
|
-
export type { EntityAttributesOnly, EntityAttributesInstance as EntityInstance, FindByIdIncludesRes, TypedFilterParams, TypedSortKeyCondition, SKScopedFilterParams, InferQueryResults, PartitionEntityNames } from "./operations";
|
|
6
|
-
export type { PartitionKey, SortKey, ForeignKey, NullableForeignKey } from "./types";
|
|
7
|
-
export type { AttributeKind } from "./metadata/types";
|
|
8
|
-
export type { SerializedTableMetadata } from "./metadata/schemas";
|
|
1
|
+
export * from "./decorators/index.js";
|
|
2
|
+
export * from "./errors.js";
|
|
3
|
+
export * from "./relationships/index.js";
|
|
4
|
+
export * from "./dynamo-utils/errors.js";
|
|
5
|
+
export type { EntityAttributesOnly, EntityAttributesInstance as EntityInstance, FindByIdIncludesRes, TypedFilterParams, TypedSortKeyCondition, SKScopedFilterParams, InferQueryResults, PartitionEntityNames } from "./operations/index.js";
|
|
6
|
+
export type { PartitionKey, SortKey, ForeignKey, NullableForeignKey } from "./types.js";
|
|
7
|
+
export type { AttributeKind } from "./metadata/types.js";
|
|
8
|
+
export type { SerializedTableMetadata } from "./metadata/schemas.js";
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AAEzC,YAAY,EACV,oBAAoB,EACpB,wBAAwB,IAAI,cAAc,EAC1C,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,YAAY,EACZ,OAAO,EACP,UAAU,EACV,kBAAkB,EACnB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,YAAY,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./decorators"), exports);
|
|
18
|
-
__exportStar(require("./errors"), exports);
|
|
19
|
-
__exportStar(require("./relationships"), exports);
|
|
20
|
-
__exportStar(require("./dynamo-utils/errors"), exports);
|
|
1
|
+
export * from "./decorators/index.js";
|
|
2
|
+
export * from "./errors.js";
|
|
3
|
+
export * from "./relationships/index.js";
|
|
4
|
+
export * from "./dynamo-utils/errors.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type ZodType } from "zod";
|
|
2
|
-
import type DynaRecord from "../DynaRecord";
|
|
3
|
-
import type { AttributeKind, AttributeMetadataOptions, Serializers } from "./types";
|
|
4
|
-
import type { EntityClass } from "../types";
|
|
5
|
-
import type { ObjectSchema } from "../decorators/attributes/types";
|
|
2
|
+
import type DynaRecord from "../DynaRecord.js";
|
|
3
|
+
import type { AttributeKind, AttributeMetadataOptions, Serializers } from "./types.js";
|
|
4
|
+
import type { EntityClass } from "../types.js";
|
|
5
|
+
import type { ObjectSchema } from "../decorators/attributes/types.js";
|
|
6
6
|
/**
|
|
7
7
|
* Represents the metadata for an attribute of an entity, including its name, alias (if any), nullability, and serialization strategies.
|
|
8
8
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttributeMetadata.d.ts","sourceRoot":"","sources":["../../../src/metadata/AttributeMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,KAAK,UAAU,MAAM,
|
|
1
|
+
{"version":3,"file":"AttributeMetadata.d.ts","sourceRoot":"","sources":["../../../src/metadata/AttributeMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,EACxB,WAAW,EACZ,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEtE;;;;;;;;;;;;;GAaG;AACH,cAAM,iBAAiB;IACrB,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,KAAK,EAAE,MAAM,CAAC;IAC9B,SAAgB,IAAI,EAAE,aAAa,CAAC;IACpC,SAAgB,QAAQ,EAAE,OAAO,CAAC;IAClC,SAAgB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1C,SAAgB,IAAI,EAAE,OAAO,CAAC;IAC9B,SAAgB,gBAAgB,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAC3D,SAAgB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5C,SAAgB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtC,SAAgB,UAAU,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;gBAEhD,OAAO,EAAE,wBAAwB;CAiB9C;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
/**
|
|
4
2
|
* Represents the metadata for an attribute of an entity, including its name, alias (if any), nullability, and serialization strategies.
|
|
5
3
|
*
|
|
@@ -44,4 +42,4 @@ class AttributeMetadata {
|
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
44
|
}
|
|
47
|
-
|
|
45
|
+
export default AttributeMetadata;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { BelongsToRelationship, HasRelationships, AttributeMetadata, AttributeMetadataStorage, RelationshipMetadataStorage, RelationshipMetadata, OwnedByRelationship, BelongsToOrOwnedByRelationship, ForeignKeyAttributeMetadata } from ".";
|
|
2
|
-
import type DynaRecord from "../DynaRecord";
|
|
3
|
-
import { type EntityDefinedAttributes } from "../operations";
|
|
1
|
+
import type { BelongsToRelationship, HasRelationships, AttributeMetadata, AttributeMetadataStorage, RelationshipMetadataStorage, RelationshipMetadata, OwnedByRelationship, BelongsToOrOwnedByRelationship, ForeignKeyAttributeMetadata } from "./index.js";
|
|
2
|
+
import type DynaRecord from "../DynaRecord.js";
|
|
3
|
+
import { type EntityDefinedAttributes } from "../operations/index.js";
|
|
4
4
|
type EntityClass = new (...args: unknown[]) => DynaRecord;
|
|
5
5
|
/**
|
|
6
6
|
* Represents metadata for an entity within the ORM system, encapsulating information about the entity's attributes, relationships, and its associated database table.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityMetadata.d.ts","sourceRoot":"","sources":["../../../src/metadata/EntityMetadata.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACxB,2BAA2B,EAC3B,oBAAoB,EACpB,mBAAmB,EACnB,8BAA8B,EAC9B,2BAA2B,EAC5B,MAAM,
|
|
1
|
+
{"version":3,"file":"EntityMetadata.d.ts","sourceRoot":"","sources":["../../../src/metadata/EntityMetadata.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACxB,2BAA2B,EAC3B,oBAAoB,EACpB,mBAAmB,EACnB,8BAA8B,EAC9B,2BAA2B,EAC5B,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAYtE,KAAK,WAAW,GAAG,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,UAAU,CAAC;AAE1D;;;;;;;;;;;GAWG;AACH,cAAM,cAAc;;IAClB;;OAEG;IACH,SAAgB,cAAc,EAAE,MAAM,CAAC;IACvC;;OAEG;IACH,SAAgB,UAAU,EAAE,wBAAwB,CAAC;IACrD;;OAEG;IACH,SAAgB,eAAe,EAAE,wBAAwB,CAAC;IAE1D;;OAEG;IACH,SAAgB,aAAa,EAAE,2BAA2B,CAAC;IAE3D,SAAgB,WAAW,EAAE,WAAW,CAAC;IAEzC;;OAEG;IACI,OAAO,CAAC,EAAE,MAAM,CAAC;gBAuBZ,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM;IAS5D;;;OAGG;IACI,YAAY,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IAStD;;;;;OAKG;IACI,+BAA+B,CACpC,UAAU,EAAE,uBAAuB,CAAC,UAAU,CAAC,GAC9C,uBAAuB,CAAC,UAAU,CAAC;IAmBtC;;;;;;OAMG;IACI,sCAAsC,CAC3C,UAAU,EAAE,OAAO,CAAC,uBAAuB,CAAC,UAAU,CAAC,CAAC,GACvD,OAAO,CAAC,uBAAuB,CAAC,UAAU,CAAC,CAAC;IAgC/C;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAa1B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAM5B;;OAEG;IACH,IAAW,gBAAgB,IAAI,oBAAoB,EAAE,CAEpD;IAED;;OAEG;IACH,IAAW,sBAAsB,IAAI,qBAAqB,EAAE,CAI3D;IAED;;OAEG;IACH,IAAW,oBAAoB,IAAI,mBAAmB,EAAE,CAIvD;IAED;;OAEG;IACH,IAAW,+BAA+B,IAAI,8BAA8B,EAAE,CAE7E;IAED;;OAEG;IACH,IAAW,gBAAgB,IAAI,gBAAgB,CAO9C;IAED;;;OAGG;IACH,IAAW,oBAAoB,IAAI,2BAA2B,EAAE,CAE/D;IAED;;;OAGG;IACH,IAAW,8BAA8B,IAAI,2BAA2B,EAAE,CAUzE;CACF;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const zod_1 = require("zod");
|
|
7
|
-
const errors_1 = require("../errors");
|
|
8
|
-
const _1 = __importDefault(require("."));
|
|
9
|
-
const utils_1 = require("./utils");
|
|
1
|
+
import { z, ZodError } from "zod";
|
|
2
|
+
import { ValidationError } from "../errors.js";
|
|
3
|
+
import Metadata from "./index.js";
|
|
4
|
+
import { isBelongsToRelationship, isHasAndBelongsToManyRelationship, isHasManyRelationship, isHasOneRelationship, isOwnedByRelationship, isRelationshipMetadataWithForeignKey, isForeignKeyAttributeMetadata } from "./utils.js";
|
|
10
5
|
/**
|
|
11
6
|
* Represents metadata for an entity within the ORM system, encapsulating information about the entity's attributes, relationships, and its associated database table.
|
|
12
7
|
*
|
|
@@ -84,9 +79,9 @@ class EntityMetadata {
|
|
|
84
79
|
*/
|
|
85
80
|
parseRawEntityDefinedAttributes(attributes) {
|
|
86
81
|
if (this.#schema === undefined) {
|
|
87
|
-
const tableMeta =
|
|
82
|
+
const tableMeta = Metadata.getTable(this.tableClassName);
|
|
88
83
|
const omitKeys = this.filterReservedKeys(tableMeta.reservedKeys, this.#zodAttributes);
|
|
89
|
-
this.#schema =
|
|
84
|
+
this.#schema = z.object(this.#zodAttributes).omit(omitKeys);
|
|
90
85
|
}
|
|
91
86
|
try {
|
|
92
87
|
return this.#schema.parse(attributes);
|
|
@@ -104,9 +99,9 @@ class EntityMetadata {
|
|
|
104
99
|
*/
|
|
105
100
|
parseRawEntityDefinedAttributesPartial(attributes) {
|
|
106
101
|
if (this.#schemaPartial === undefined) {
|
|
107
|
-
const tableMeta =
|
|
102
|
+
const tableMeta = Metadata.getTable(this.tableClassName);
|
|
108
103
|
const omitKeys = this.filterReservedKeys(tableMeta.reservedKeys, this.#zodPartialAttributes);
|
|
109
|
-
this.#schemaPartial =
|
|
104
|
+
this.#schemaPartial = z
|
|
110
105
|
.object(this.#zodPartialAttributes)
|
|
111
106
|
.omit(omitKeys)
|
|
112
107
|
.partial()
|
|
@@ -146,8 +141,8 @@ class EntityMetadata {
|
|
|
146
141
|
* @param error
|
|
147
142
|
*/
|
|
148
143
|
buildValidationError(error) {
|
|
149
|
-
const errorOptions = error instanceof
|
|
150
|
-
return new
|
|
144
|
+
const errorOptions = error instanceof ZodError ? { cause: error.issues } : undefined;
|
|
145
|
+
return new ValidationError("Validation errors", errorOptions);
|
|
151
146
|
}
|
|
152
147
|
/**
|
|
153
148
|
* Returns all relationship metadata for the entity
|
|
@@ -159,13 +154,13 @@ class EntityMetadata {
|
|
|
159
154
|
* Returns the BelongsToRelationship (bidirectional to parent) metadata for the entity
|
|
160
155
|
*/
|
|
161
156
|
get belongsToRelationships() {
|
|
162
|
-
return Object.values(this.relationships).filter(rel =>
|
|
157
|
+
return Object.values(this.relationships).filter(rel => isBelongsToRelationship(rel));
|
|
163
158
|
}
|
|
164
159
|
/**
|
|
165
160
|
* Returns the OwnedByRelationship (unidirectional to parent) relationship metadata for an entity
|
|
166
161
|
*/
|
|
167
162
|
get ownedByRelationships() {
|
|
168
|
-
return Object.values(this.relationships).filter(relMeta =>
|
|
163
|
+
return Object.values(this.relationships).filter(relMeta => isOwnedByRelationship(relMeta));
|
|
169
164
|
}
|
|
170
165
|
/**
|
|
171
166
|
* Returns the BelongsToRelationship and OwnedByRelationship metadata objects for an entity
|
|
@@ -177,16 +172,16 @@ class EntityMetadata {
|
|
|
177
172
|
* Returns the "Has" relationship metadata for the entity (EX: "HasMany")
|
|
178
173
|
*/
|
|
179
174
|
get hasRelationships() {
|
|
180
|
-
return Object.values(this.relationships).filter(relMeta =>
|
|
181
|
-
|
|
182
|
-
|
|
175
|
+
return Object.values(this.relationships).filter(relMeta => isHasOneRelationship(relMeta) ||
|
|
176
|
+
isHasManyRelationship(relMeta) ||
|
|
177
|
+
isHasAndBelongsToManyRelationship(relMeta));
|
|
183
178
|
}
|
|
184
179
|
/**
|
|
185
180
|
* Returns attribute metadata for attributes that reference a foreign entity via {@link ForeignKeyAttribute}.
|
|
186
181
|
* The returned metadata guarantees a non-null {@link ForeignKeyAttributeMetadata.foreignKeyTarget}.
|
|
187
182
|
*/
|
|
188
183
|
get foreignKeyAttributes() {
|
|
189
|
-
return Object.values(this.attributes).filter(
|
|
184
|
+
return Object.values(this.attributes).filter(isForeignKeyAttributeMetadata);
|
|
190
185
|
}
|
|
191
186
|
/**
|
|
192
187
|
* Returns foreign key attributes that are not linked through a relationship decorator.
|
|
@@ -194,9 +189,9 @@ class EntityMetadata {
|
|
|
194
189
|
*/
|
|
195
190
|
get standaloneForeignKeyAttributes() {
|
|
196
191
|
const associatedForeignKeys = new Set(Object.values(this.relationships)
|
|
197
|
-
.filter(
|
|
192
|
+
.filter(isRelationshipMetadataWithForeignKey)
|
|
198
193
|
.map(rel => rel.foreignKey.toString()));
|
|
199
194
|
return this.foreignKeyAttributes.filter(attr => !associatedForeignKeys.has(attr.name));
|
|
200
195
|
}
|
|
201
196
|
}
|
|
202
|
-
|
|
197
|
+
export default EntityMetadata;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type DynaRecord from "../DynaRecord";
|
|
2
|
-
import type { JoinTable } from "../relationships";
|
|
3
|
-
import type { EntityClass } from "../types";
|
|
1
|
+
import type DynaRecord from "../DynaRecord.js";
|
|
2
|
+
import type { JoinTable } from "../relationships/index.js";
|
|
3
|
+
import type { EntityClass } from "../types.js";
|
|
4
4
|
type Entity = EntityClass<DynaRecord>;
|
|
5
5
|
type ForeignKey = keyof JoinTable<DynaRecord, DynaRecord>;
|
|
6
6
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JoinTableMetadata.d.ts","sourceRoot":"","sources":["../../../src/metadata/JoinTableMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,
|
|
1
|
+
{"version":3,"file":"JoinTableMetadata.d.ts","sourceRoot":"","sources":["../../../src/metadata/JoinTableMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,KAAK,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;AACtC,KAAK,UAAU,GAAG,MAAM,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAE1D;;;;;;;;;;GAUG;AAEH,cAAM,iBAAiB;IACrB,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,UAAU,EAAE,UAAU,CAAC;gBAE3B,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU;CAInD;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
/**
|
|
4
2
|
* Represents the metadata for a join table used in many-to-many relationships within the ORM system. This metadata includes the entity class and the foreign key used in the join table.
|
|
5
3
|
*
|
|
@@ -19,4 +17,4 @@ class JoinTableMetadata {
|
|
|
19
17
|
this.foreignKey = foreignKey;
|
|
20
18
|
}
|
|
21
19
|
}
|
|
22
|
-
|
|
20
|
+
export default JoinTableMetadata;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type DynaRecord from "../DynaRecord";
|
|
2
|
-
import type { MakeOptional } from "../types";
|
|
3
|
-
import TableMetadata from "./TableMetadata";
|
|
4
|
-
import EntityMetadata from "./EntityMetadata";
|
|
5
|
-
import JoinTableMetadata from "./JoinTableMetadata";
|
|
6
|
-
import type { RelationshipMetadata } from "./relationship-metadata";
|
|
7
|
-
import type { AttributeMetadataStorage, EntityMetadataStorage, TableMetadataOptions, AttributeMetadataOptions } from "./types";
|
|
1
|
+
import type DynaRecord from "../DynaRecord.js";
|
|
2
|
+
import type { MakeOptional } from "../types.js";
|
|
3
|
+
import TableMetadata from "./TableMetadata.js";
|
|
4
|
+
import EntityMetadata from "./EntityMetadata.js";
|
|
5
|
+
import JoinTableMetadata from "./JoinTableMetadata.js";
|
|
6
|
+
import type { RelationshipMetadata } from "./relationship-metadata/index.js";
|
|
7
|
+
import type { AttributeMetadataStorage, EntityMetadataStorage, TableMetadataOptions, AttributeMetadataOptions } from "./types.js";
|
|
8
8
|
/**
|
|
9
9
|
* Central storage for managing and accessing all metadata related to entities, attributes, relationships, and tables within the ORM.
|
|
10
10
|
* It provides methods for retrieving and adding metadata for entities and their corresponding tables, handling relationships
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetadataStorage.d.ts","sourceRoot":"","sources":["../../../src/metadata/MetadataStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,
|
|
1
|
+
{"version":3,"file":"MetadataStorage.d.ts","sourceRoot":"","sources":["../../../src/metadata/MetadataStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AAEvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,KAAK,EACV,wBAAwB,EAExB,qBAAqB,EAErB,oBAAoB,EAEpB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAEpB;;;;GAIG;AACH,cAAM,eAAe;;IAOnB;;;;OAIG;IACI,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc;IAKpD;;;;OAIG;IACI,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa;IAKjD;;;;OAIG;IACI,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa;IAMxD;;;;OAIG;IACI,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,iBAAiB,EAAE;IAK/D;;;;OAIG;IACI,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,qBAAqB;IAWzE;;;OAGG;IACI,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,wBAAwB;IAYxE;;;;OAIG;IACI,wBAAwB,CAC7B,UAAU,EAAE,MAAM,GACjB,wBAAwB;IAY3B;;;;OAIG;IACI,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,IAAI;IAI5E;;;;OAIG;IACI,SAAS,CACd,WAAW,EAAE,cAAc,CAAC,aAAa,CAAC,EAC1C,cAAc,EAAE,MAAM,GACrB,IAAI;IAOP;;;;OAIG;IACI,qBAAqB,CAC1B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,GAC5B,IAAI;IAQP;;;;OAIG;IACI,YAAY,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAW5E;;;;OAIG;IACI,kBAAkB,CACvB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,YAAY,CAAC,wBAAwB,EAAE,OAAO,CAAC,GACvD,IAAI;IAYP;;;;OAIG;IACI,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAKpE;;;;OAIG;IACI,wBAAwB,CAC7B,WAAW,EAAE,UAAU,EACvB,OAAO,EAAE,UAAU,CAAC,aAAa,CAAC,0BAA0B,CAAC,CAAC,CAAC,MAAM,CAAC,GACrE,IAAI;IAQP;;;;OAIG;IACI,mBAAmB,CACxB,WAAW,EAAE,UAAU,EACvB,OAAO,EAAE,UAAU,CAAC,aAAa,CAAC,0BAA0B,CAAC,CAAC,CAAC,MAAM,CAAC,GACrE,IAAI;IAQP;;OAEG;IACH,OAAO,CAAC,IAAI;IAUZ;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;CAe/B;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const TableMetadata_1 = __importDefault(require("./TableMetadata"));
|
|
7
|
-
const EntityMetadata_1 = __importDefault(require("./EntityMetadata"));
|
|
8
|
-
const AttributeMetadata_1 = __importDefault(require("./AttributeMetadata"));
|
|
9
|
-
const JoinTableMetadata_1 = __importDefault(require("./JoinTableMetadata"));
|
|
10
|
-
const utils_1 = require("./relationship-metadata/utils");
|
|
1
|
+
import TableMetadata from "./TableMetadata.js";
|
|
2
|
+
import EntityMetadata from "./EntityMetadata.js";
|
|
3
|
+
import AttributeMetadata from "./AttributeMetadata.js";
|
|
4
|
+
import JoinTableMetadata from "./JoinTableMetadata.js";
|
|
5
|
+
import { createRelationshipInstance } from "./relationship-metadata/utils.js";
|
|
11
6
|
/**
|
|
12
7
|
* Central storage for managing and accessing all metadata related to entities, attributes, relationships, and tables within the ORM.
|
|
13
8
|
* It provides methods for retrieving and adding metadata for entities and their corresponding tables, handling relationships
|
|
@@ -105,7 +100,7 @@ class MetadataStorage {
|
|
|
105
100
|
* @param options
|
|
106
101
|
*/
|
|
107
102
|
addTable(tableClassName, options) {
|
|
108
|
-
this.#tables[tableClassName] = new
|
|
103
|
+
this.#tables[tableClassName] = new TableMetadata(options);
|
|
109
104
|
}
|
|
110
105
|
/**
|
|
111
106
|
* Add an entity to metadata storage
|
|
@@ -113,7 +108,7 @@ class MetadataStorage {
|
|
|
113
108
|
* @param tableName
|
|
114
109
|
*/
|
|
115
110
|
addEntity(entityClass, tableClassName) {
|
|
116
|
-
this.#entities[entityClass.name] = new
|
|
111
|
+
this.#entities[entityClass.name] = new EntityMetadata(entityClass, tableClassName);
|
|
117
112
|
}
|
|
118
113
|
/**
|
|
119
114
|
* Adds a relationship to an Entity's metadata storage
|
|
@@ -124,7 +119,7 @@ class MetadataStorage {
|
|
|
124
119
|
const entityMetadata = this.#entities[entityName];
|
|
125
120
|
if (!(options.propertyName in entityMetadata.relationships)) {
|
|
126
121
|
entityMetadata.relationships[options.propertyName] =
|
|
127
|
-
|
|
122
|
+
createRelationshipInstance(options);
|
|
128
123
|
}
|
|
129
124
|
}
|
|
130
125
|
/**
|
|
@@ -134,12 +129,12 @@ class MetadataStorage {
|
|
|
134
129
|
*/
|
|
135
130
|
addJoinTable(joinTableName, options) {
|
|
136
131
|
if (!(joinTableName in this.#joinTables)) {
|
|
137
|
-
const meta = new
|
|
132
|
+
const meta = new JoinTableMetadata(options.entity, options.foreignKey);
|
|
138
133
|
this.#joinTables[joinTableName] = [meta];
|
|
139
134
|
}
|
|
140
135
|
else if (this.#joinTables[joinTableName].length === 1) {
|
|
141
136
|
// There can only be two tables in a join table
|
|
142
|
-
const meta = new
|
|
137
|
+
const meta = new JoinTableMetadata(options.entity, options.foreignKey);
|
|
143
138
|
this.#joinTables[joinTableName].push(meta);
|
|
144
139
|
}
|
|
145
140
|
}
|
|
@@ -154,7 +149,7 @@ class MetadataStorage {
|
|
|
154
149
|
// The property is a default field assign it, otherwise instantiate new AttributeMetadata
|
|
155
150
|
const meta = options.attributeName in defaultAttributes
|
|
156
151
|
? defaultAttributes[options.attributeName]
|
|
157
|
-
: new
|
|
152
|
+
: new AttributeMetadata(options);
|
|
158
153
|
entityMetadata.addAttribute(meta);
|
|
159
154
|
}
|
|
160
155
|
/**
|
|
@@ -215,4 +210,4 @@ class MetadataStorage {
|
|
|
215
210
|
}
|
|
216
211
|
}
|
|
217
212
|
}
|
|
218
|
-
|
|
213
|
+
export default MetadataStorage;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AttributeMetadata } from ".";
|
|
2
|
-
import type { TableMetadataOptions, DefaultFields, KeysAttributeMetadataOptions, EntityMetadataStorage } from "./types";
|
|
3
|
-
import { type SerializedTableMetadata } from "./schemas";
|
|
1
|
+
import { AttributeMetadata } from "./index.js";
|
|
2
|
+
import type { TableMetadataOptions, DefaultFields, KeysAttributeMetadataOptions, EntityMetadataStorage } from "./types.js";
|
|
3
|
+
import { type SerializedTableMetadata } from "./schemas.js";
|
|
4
4
|
export declare const defaultTableKeys: {
|
|
5
5
|
readonly partitionKey: "PK";
|
|
6
6
|
readonly sortKey: "SK";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableMetadata.d.ts","sourceRoot":"","sources":["../../../src/metadata/TableMetadata.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"TableMetadata.d.ts","sourceRoot":"","sources":["../../../src/metadata/TableMetadata.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,KAAK,EAEV,oBAAoB,EACpB,aAAa,EAGb,4BAA4B,EAC5B,qBAAqB,EACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,uBAAuB,EAE7B,MAAM,cAAc,CAAC;AAEtB,eAAO,MAAM,gBAAgB;;;CAAiD,CAAC;AAE/E;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CACrC,aAAa,EACb;IAAE,KAAK,EAAE,aAAa,CAAA;CAAE,CAMhB,CAAC;AAEX;;;;;;;;;;;;;GAaG;AACH,cAAM,aAAa;IACjB,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,iBAAiB,EAAE,MAAM,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;IAC5E,SAAgB,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACnE,qBAAqB,EAAE,iBAAiB,CAAC;IACzC,gBAAgB,EAAE,iBAAiB,CAAC;IAE3C;;;;;;;;;;;;;;;;OAgBG;IACI,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;gBAE9B,OAAO,EAAE,oBAAoB;IA8BzC;;;;OAIG;IACH,OAAO,CAAC,8BAA8B;IAkCtC;;;OAGG;IACI,wBAAwB,CAAC,OAAO,EAAE,4BAA4B,GAAG,IAAI;IAO5E;;;OAGG;IACI,mBAAmB,CAAC,OAAO,EAAE,4BAA4B,GAAG,IAAI;IAOvE;;;;;OAKG;IACI,MAAM,CAAC,QAAQ,EAAE,qBAAqB,GAAG,uBAAuB;CAYxE;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const decorators_1 = require("../decorators");
|
|
7
|
-
const schemas_1 = require("./schemas");
|
|
8
|
-
exports.defaultTableKeys = { partitionKey: "PK", sortKey: "SK" };
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AttributeMetadata } from "./index.js";
|
|
3
|
+
import { dateSerializer } from "../decorators/index.js";
|
|
4
|
+
import { TableMetadataTransform } from "./schemas.js";
|
|
5
|
+
export const defaultTableKeys = { partitionKey: "PK", sortKey: "SK" };
|
|
9
6
|
/**
|
|
10
7
|
* Default fields with default table alias. Can be overwritten through {@link TableMetadataOptions} defaultFields
|
|
11
8
|
*/
|
|
12
|
-
|
|
9
|
+
export const tableDefaultFields = {
|
|
13
10
|
id: { alias: "id" },
|
|
14
11
|
type: { alias: "type" },
|
|
15
12
|
createdAt: { alias: "createdAt" },
|
|
@@ -63,17 +60,17 @@ class TableMetadata {
|
|
|
63
60
|
// Placeholders, these are set later
|
|
64
61
|
this.partitionKeyAttribute = {
|
|
65
62
|
name: "",
|
|
66
|
-
alias:
|
|
63
|
+
alias: defaultTableKeys.partitionKey,
|
|
67
64
|
kind: "string",
|
|
68
65
|
nullable: false,
|
|
69
|
-
type:
|
|
66
|
+
type: z.string()
|
|
70
67
|
};
|
|
71
68
|
this.sortKeyAttribute = {
|
|
72
69
|
name: "",
|
|
73
|
-
alias:
|
|
70
|
+
alias: defaultTableKeys.sortKey,
|
|
74
71
|
kind: "string",
|
|
75
72
|
nullable: false,
|
|
76
|
-
type:
|
|
73
|
+
type: z.string()
|
|
77
74
|
};
|
|
78
75
|
const defaultAttrNames = Object.keys(this.defaultAttributes);
|
|
79
76
|
// Set the default keys as reserved keys, the user defined primary and sort key are set later
|
|
@@ -85,7 +82,7 @@ class TableMetadata {
|
|
|
85
82
|
* @returns
|
|
86
83
|
*/
|
|
87
84
|
buildDefaultAttributesMetadata(options) {
|
|
88
|
-
const defaultAttrsMeta = Object.entries(
|
|
85
|
+
const defaultAttrsMeta = Object.entries(tableDefaultFields);
|
|
89
86
|
const customDefaults = options.defaultFields ?? {};
|
|
90
87
|
const dateFields = ["createdAt", "updatedAt"];
|
|
91
88
|
return defaultAttrsMeta.reduce((acc, [entityKey, tableKeyAlias]) => {
|
|
@@ -98,8 +95,8 @@ class TableMetadata {
|
|
|
98
95
|
alias,
|
|
99
96
|
kind,
|
|
100
97
|
nullable: false,
|
|
101
|
-
serializers: isDateField ?
|
|
102
|
-
type: isDateField ?
|
|
98
|
+
serializers: isDateField ? dateSerializer : undefined,
|
|
99
|
+
type: isDateField ? z.date() : z.string()
|
|
103
100
|
};
|
|
104
101
|
acc.entityDefaults[entityKey] = meta;
|
|
105
102
|
acc.tableDefaults[alias] = meta;
|
|
@@ -112,7 +109,7 @@ class TableMetadata {
|
|
|
112
109
|
*/
|
|
113
110
|
addPartitionKeyAttribute(options) {
|
|
114
111
|
const opts = { ...options, nullable: false };
|
|
115
|
-
this.partitionKeyAttribute = new
|
|
112
|
+
this.partitionKeyAttribute = new AttributeMetadata(opts);
|
|
116
113
|
// Set the user defined primary key as reserved key so that its managed by dyna-record
|
|
117
114
|
this.reservedKeys[options.attributeName] = true;
|
|
118
115
|
}
|
|
@@ -122,7 +119,7 @@ class TableMetadata {
|
|
|
122
119
|
*/
|
|
123
120
|
addSortKeyAttribute(options) {
|
|
124
121
|
const opts = { ...options, nullable: false };
|
|
125
|
-
this.sortKeyAttribute = new
|
|
122
|
+
this.sortKeyAttribute = new AttributeMetadata(opts);
|
|
126
123
|
// Set the user defined primary key as reserved key so that its managed by dyna-record
|
|
127
124
|
this.reservedKeys[options.attributeName] = true;
|
|
128
125
|
}
|
|
@@ -133,7 +130,7 @@ class TableMetadata {
|
|
|
133
130
|
* @returns A plain object representation of the metadata
|
|
134
131
|
*/
|
|
135
132
|
toJSON(entities) {
|
|
136
|
-
return
|
|
133
|
+
return TableMetadataTransform.parse({
|
|
137
134
|
name: this.name,
|
|
138
135
|
delimiter: this.delimiter,
|
|
139
136
|
defaultAttributes: this.defaultAttributes,
|
|
@@ -145,4 +142,4 @@ class TableMetadata {
|
|
|
145
142
|
});
|
|
146
143
|
}
|
|
147
144
|
}
|
|
148
|
-
|
|
145
|
+
export default TableMetadata;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import TableMetadata from "./TableMetadata";
|
|
2
|
-
import EntityMetadata from "./EntityMetadata";
|
|
3
|
-
import AttributeMetadata from "./AttributeMetadata";
|
|
4
|
-
import MetadataStorage from "./MetadataStorage";
|
|
5
|
-
import JoinTableMetadata from "./JoinTableMetadata";
|
|
1
|
+
import TableMetadata from "./TableMetadata.js";
|
|
2
|
+
import EntityMetadata from "./EntityMetadata.js";
|
|
3
|
+
import AttributeMetadata from "./AttributeMetadata.js";
|
|
4
|
+
import MetadataStorage from "./MetadataStorage.js";
|
|
5
|
+
import JoinTableMetadata from "./JoinTableMetadata.js";
|
|
6
6
|
declare const _default: MetadataStorage;
|
|
7
7
|
export default _default;
|
|
8
8
|
export { TableMetadata, EntityMetadata, AttributeMetadata, JoinTableMetadata };
|
|
9
|
-
export * from "./MetadataStorage";
|
|
10
|
-
export * from "./TableMetadata";
|
|
11
|
-
export * from "./relationship-metadata";
|
|
12
|
-
export * from "./types";
|
|
9
|
+
export * from "./MetadataStorage.js";
|
|
10
|
+
export * from "./TableMetadata.js";
|
|
11
|
+
export * from "./relationship-metadata/index.js";
|
|
12
|
+
export * from "./types.js";
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/metadata/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/metadata/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,cAAc,MAAM,qBAAqB,CAAC;AACjD,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AACvD,OAAO,eAAe,MAAM,sBAAsB,CAAC;AACnD,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;;AAEvD,wBAAqC;AACrC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,CAAC;AAE/E,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kCAAkC,CAAC;AACjD,cAAc,YAAY,CAAC"}
|
|
@@ -1,34 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.JoinTableMetadata = exports.AttributeMetadata = exports.EntityMetadata = exports.TableMetadata = void 0;
|
|
21
|
-
const TableMetadata_1 = __importDefault(require("./TableMetadata"));
|
|
22
|
-
exports.TableMetadata = TableMetadata_1.default;
|
|
23
|
-
const EntityMetadata_1 = __importDefault(require("./EntityMetadata"));
|
|
24
|
-
exports.EntityMetadata = EntityMetadata_1.default;
|
|
25
|
-
const AttributeMetadata_1 = __importDefault(require("./AttributeMetadata"));
|
|
26
|
-
exports.AttributeMetadata = AttributeMetadata_1.default;
|
|
27
|
-
const MetadataStorage_1 = __importDefault(require("./MetadataStorage"));
|
|
28
|
-
const JoinTableMetadata_1 = __importDefault(require("./JoinTableMetadata"));
|
|
29
|
-
exports.JoinTableMetadata = JoinTableMetadata_1.default;
|
|
30
|
-
exports.default = new MetadataStorage_1.default();
|
|
31
|
-
__exportStar(require("./MetadataStorage"), exports);
|
|
32
|
-
__exportStar(require("./TableMetadata"), exports);
|
|
33
|
-
__exportStar(require("./relationship-metadata"), exports);
|
|
34
|
-
__exportStar(require("./types"), exports);
|
|
1
|
+
import TableMetadata from "./TableMetadata.js";
|
|
2
|
+
import EntityMetadata from "./EntityMetadata.js";
|
|
3
|
+
import AttributeMetadata from "./AttributeMetadata.js";
|
|
4
|
+
import MetadataStorage from "./MetadataStorage.js";
|
|
5
|
+
import JoinTableMetadata from "./JoinTableMetadata.js";
|
|
6
|
+
export default new MetadataStorage();
|
|
7
|
+
export { TableMetadata, EntityMetadata, AttributeMetadata, JoinTableMetadata };
|
|
8
|
+
export * from "./MetadataStorage.js";
|
|
9
|
+
export * from "./TableMetadata.js";
|
|
10
|
+
export * from "./relationship-metadata/index.js";
|
|
11
|
+
export * from "./types.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ForeignKeyProperty } from "../../types";
|
|
2
|
-
import RelationshipMetadata from "./RelationshipMetadata";
|
|
1
|
+
import type { ForeignKeyProperty } from "../../types.js";
|
|
2
|
+
import RelationshipMetadata from "./RelationshipMetadata.js";
|
|
3
3
|
/**
|
|
4
4
|
* Represents a "Belongs To" relationship metadata within the ORM system. These are bidirectional relationships to the parent.
|
|
5
5
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BelongsToRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/BelongsToRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"BelongsToRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/BelongsToRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAE7D;;;;;;;;GAQG;AACH,cAAM,qBAAsB,SAAQ,oBAAoB;IACtD,IAAI,EAAG,WAAW,CAAU;IAC5B,UAAU,EAAE,kBAAkB,CAAC;gBAEnB,IAAI,EAAE,oBAAoB;CAIvC;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -1,9 +1,4 @@
|
|
|
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
|
-
const RelationshipMetadata_1 = __importDefault(require("./RelationshipMetadata"));
|
|
1
|
+
import RelationshipMetadata from "./RelationshipMetadata.js";
|
|
7
2
|
/**
|
|
8
3
|
* Represents a "Belongs To" relationship metadata within the ORM system. These are bidirectional relationships to the parent.
|
|
9
4
|
*
|
|
@@ -13,7 +8,7 @@ const RelationshipMetadata_1 = __importDefault(require("./RelationshipMetadata")
|
|
|
13
8
|
*
|
|
14
9
|
* @param {RelationshipMetadata} item - The initial relationship metadata to be copied into this "Belongs To" relationship instance. This allows for easy creation and setup of relationship metadata based on existing configurations.
|
|
15
10
|
*/
|
|
16
|
-
class BelongsToRelationship extends
|
|
11
|
+
class BelongsToRelationship extends RelationshipMetadata {
|
|
17
12
|
type = "BelongsTo";
|
|
18
13
|
foreignKey;
|
|
19
14
|
constructor(item) {
|
|
@@ -21,4 +16,4 @@ class BelongsToRelationship extends RelationshipMetadata_1.default {
|
|
|
21
16
|
Object.assign(this, item);
|
|
22
17
|
}
|
|
23
18
|
}
|
|
24
|
-
|
|
19
|
+
export default BelongsToRelationship;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasAndBelongsToManyRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,
|
|
1
|
+
{"version":3,"file":"HasAndBelongsToManyRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAE7D;;;;;;;GAOG;AACH,cAAM,+BAAgC,SAAQ,oBAAoB;IAChE,IAAI,EAAG,qBAAqB,CAAU;IACtC,aAAa,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,oBAAoB;CAIvC;AAED,eAAe,+BAA+B,CAAC"}
|
|
@@ -1,9 +1,4 @@
|
|
|
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
|
-
const RelationshipMetadata_1 = __importDefault(require("./RelationshipMetadata"));
|
|
1
|
+
import RelationshipMetadata from "./RelationshipMetadata.js";
|
|
7
2
|
/**
|
|
8
3
|
* Represents the metadata for a "HasAndBelongsToMany" relationship metadata within the ORM system.
|
|
9
4
|
*
|
|
@@ -12,7 +7,7 @@ const RelationshipMetadata_1 = __importDefault(require("./RelationshipMetadata")
|
|
|
12
7
|
*
|
|
13
8
|
* @param {RelationshipMetadata} item - An instance of `RelationshipMetadata` containing the initial settings for the relationship. This can include properties like `joinTableName`, which are specific to many-to-many relationships.
|
|
14
9
|
*/
|
|
15
|
-
class HasAndBelongsToManyRelationship extends
|
|
10
|
+
class HasAndBelongsToManyRelationship extends RelationshipMetadata {
|
|
16
11
|
type = "HasAndBelongsToMany";
|
|
17
12
|
joinTableName;
|
|
18
13
|
constructor(item) {
|
|
@@ -20,4 +15,4 @@ class HasAndBelongsToManyRelationship extends RelationshipMetadata_1.default {
|
|
|
20
15
|
Object.assign(this, item);
|
|
21
16
|
}
|
|
22
17
|
}
|
|
23
|
-
|
|
18
|
+
export default HasAndBelongsToManyRelationship;
|