dyna-record 0.5.0 → 0.5.2
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/src/DynaRecord.d.ts +11 -18
- package/dist/src/DynaRecord.d.ts.map +1 -1
- package/dist/src/Logger.d.ts.map +1 -1
- package/dist/src/Logger.js +0 -1
- 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 -5
- package/dist/src/decorators/Table.d.ts +1 -1
- package/dist/src/decorators/Table.d.ts.map +1 -1
- package/dist/src/decorators/Table.js +2 -4
- package/dist/src/decorators/attributes/BooleanAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/BooleanAttribute.js +7 -9
- package/dist/src/decorators/attributes/DateAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/DateAttribute.js +8 -10
- package/dist/src/decorators/attributes/EnumAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/EnumAttribute.js +7 -9
- package/dist/src/decorators/attributes/ForeignKeyAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/ForeignKeyAttribute.js +9 -11
- package/dist/src/decorators/attributes/NumberAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/NumberAttribute.js +7 -9
- package/dist/src/decorators/attributes/ObjectAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/ObjectAttribute.js +14 -17
- package/dist/src/decorators/attributes/PartitionKeyAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/PartitionKeyAttribute.js +6 -8
- package/dist/src/decorators/attributes/SortKeyAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/SortKeyAttribute.js +6 -8
- package/dist/src/decorators/attributes/StringAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/StringAttribute.js +7 -9
- 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 +1 -1
- package/dist/src/decorators/relationships/BelongsTo.d.ts.map +1 -1
- package/dist/src/decorators/relationships/BelongsTo.js +7 -9
- package/dist/src/decorators/relationships/HasAndBelongsToMany.d.ts.map +1 -1
- package/dist/src/decorators/relationships/HasAndBelongsToMany.js +13 -15
- package/dist/src/decorators/relationships/HasMany.d.ts.map +1 -1
- package/dist/src/decorators/relationships/HasMany.js +15 -17
- package/dist/src/decorators/relationships/HasOne.d.ts.map +1 -1
- package/dist/src/decorators/relationships/HasOne.js +7 -9
- package/dist/src/metadata/EntityMetadata.d.ts +7 -2
- package/dist/src/metadata/EntityMetadata.d.ts.map +1 -1
- package/dist/src/metadata/EntityMetadata.js +17 -2
- package/dist/src/metadata/MetadataStorage.d.ts.map +1 -1
- package/dist/src/metadata/MetadataStorage.js +6 -6
- package/dist/src/metadata/TableMetadata.d.ts.map +1 -1
- package/dist/src/metadata/TableMetadata.js +7 -1
- package/dist/src/metadata/relationship-metadata/BelongsToRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/BelongsToRelationship.js +1 -3
- package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.js +1 -3
- package/dist/src/metadata/relationship-metadata/HasManyRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/HasManyRelationship.js +1 -3
- package/dist/src/metadata/relationship-metadata/HasOneRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/HasOneRelationship.js +1 -3
- package/dist/src/metadata/relationship-metadata/OwnedByRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/OwnedByRelationship.js +1 -3
- package/dist/src/metadata/schemas.d.ts +40 -262
- package/dist/src/metadata/schemas.d.ts.map +1 -1
- package/dist/src/metadata/schemas.js +6 -6
- package/dist/src/metadata/types.d.ts +3 -3
- package/dist/src/metadata/types.d.ts.map +1 -1
- package/dist/src/metadata/utils.js +4 -4
- package/dist/src/operations/Create/Create.js +3 -5
- package/dist/src/operations/Delete/Delete.d.ts.map +1 -1
- package/dist/src/operations/Delete/Delete.js +3 -2
- package/dist/src/operations/FindById/FindById.d.ts.map +1 -1
- package/dist/src/operations/FindById/FindById.js +4 -4
- package/dist/src/operations/Query/Query.d.ts.map +1 -1
- package/dist/src/operations/Query/Query.js +2 -1
- package/dist/src/operations/Update/Update.d.ts.map +1 -1
- package/dist/src/operations/Update/Update.js +17 -15
- package/dist/src/operations/types.d.ts +1 -1
- package/dist/src/operations/types.d.ts.map +1 -1
- package/dist/src/operations/utils/expressionBuilder.js +3 -0
- package/dist/src/operations/utils/flattenObjectForUpdate.d.ts.map +1 -1
- package/dist/src/operations/utils/flattenObjectForUpdate.js +2 -2
- package/dist/src/operations/utils/mergePartialObjectAttributes.d.ts.map +1 -1
- package/dist/src/operations/utils/mergePartialObjectAttributes.js +11 -3
- package/dist/src/operations/utils/utils.d.ts +2 -2
- package/dist/src/operations/utils/utils.d.ts.map +1 -1
- package/dist/src/query-utils/QueryBuilder.d.ts.map +1 -1
- package/dist/src/query-utils/QueryBuilder.js +11 -7
- package/dist/src/query-utils/types.d.ts.map +1 -1
- package/dist/src/relationships/JoinTable.d.ts.map +1 -1
- package/dist/src/relationships/JoinTable.js +4 -3
- package/dist/src/utils.d.ts +4 -4
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +13 -11
- package/package.json +11 -13
|
@@ -32,26 +32,24 @@ const metadata_1 = __importDefault(require("../../metadata"));
|
|
|
32
32
|
*/
|
|
33
33
|
function HasMany(getTarget, props) {
|
|
34
34
|
return (_value, context) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
propertyName: props.foreignKey,
|
|
42
|
-
foreignKey: props.foreignKey,
|
|
43
|
-
target: this.constructor
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
metadata_1.default.addEntityRelationship(this.constructor.name, {
|
|
47
|
-
type: "HasMany",
|
|
48
|
-
propertyName: context.name,
|
|
49
|
-
target,
|
|
35
|
+
context.addInitializer(function () {
|
|
36
|
+
const target = getTarget();
|
|
37
|
+
if (props.uniDirectional === true) {
|
|
38
|
+
metadata_1.default.addEntityRelationship(target.name, {
|
|
39
|
+
type: "OwnedBy",
|
|
40
|
+
propertyName: props.foreignKey,
|
|
50
41
|
foreignKey: props.foreignKey,
|
|
51
|
-
|
|
42
|
+
target: this.constructor
|
|
52
43
|
});
|
|
44
|
+
}
|
|
45
|
+
metadata_1.default.addEntityRelationship(this.constructor.name, {
|
|
46
|
+
type: "HasMany",
|
|
47
|
+
propertyName: context.name,
|
|
48
|
+
target,
|
|
49
|
+
foreignKey: props.foreignKey,
|
|
50
|
+
uniDirectional: props.uniDirectional
|
|
53
51
|
});
|
|
54
|
-
}
|
|
52
|
+
});
|
|
55
53
|
};
|
|
56
54
|
}
|
|
57
55
|
exports.default = HasMany;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasOne.d.ts","sourceRoot":"","sources":["../../../../src/decorators/relationships/HasOne.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAsB,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEvD,UAAU,WAAW,CAAC,CAAC,SAAS,UAAU;IACxC,UAAU,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;CACjD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,iBAAS,MAAM,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,UAAU,EACxD,SAAS,EAAE,MAAM,WAAW,CAAC,CAAC,CAAC,EAC/B,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,YAGX,SAAS,WACR,0BAA0B,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"HasOne.d.ts","sourceRoot":"","sources":["../../../../src/decorators/relationships/HasOne.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAsB,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEvD,UAAU,WAAW,CAAC,CAAC,SAAS,UAAU;IACxC,UAAU,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;CACjD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,iBAAS,MAAM,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,UAAU,EACxD,SAAS,EAAE,MAAM,WAAW,CAAC,CAAC,CAAC,EAC/B,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,YAGX,SAAS,WACR,0BAA0B,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,UAWtD;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -32,16 +32,14 @@ const metadata_1 = __importDefault(require("../../metadata"));
|
|
|
32
32
|
*/
|
|
33
33
|
function HasOne(getTarget, props) {
|
|
34
34
|
return function (_value, context) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
foreignKey: props.foreignKey
|
|
42
|
-
});
|
|
35
|
+
context.addInitializer(function () {
|
|
36
|
+
metadata_1.default.addEntityRelationship(this.constructor.name, {
|
|
37
|
+
type: "HasOne",
|
|
38
|
+
propertyName: context.name,
|
|
39
|
+
target: getTarget(),
|
|
40
|
+
foreignKey: props.foreignKey
|
|
43
41
|
});
|
|
44
|
-
}
|
|
42
|
+
});
|
|
45
43
|
};
|
|
46
44
|
}
|
|
47
45
|
exports.default = HasOne;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BelongsToRelationship, HasRelationships, AttributeMetadata, AttributeMetadataStorage, RelationshipMetadataStorage, RelationshipMetadata, OwnedByRelationship, BelongsToOrOwnedByRelationship, ForeignKeyAttributeMetadata } from ".";
|
|
2
2
|
import type DynaRecord from "../DynaRecord";
|
|
3
3
|
import { type EntityDefinedAttributes } from "../operations";
|
|
4
|
-
type EntityClass = new (...args:
|
|
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.
|
|
7
7
|
*
|
|
@@ -36,7 +36,7 @@ declare class EntityMetadata {
|
|
|
36
36
|
/**
|
|
37
37
|
* Optional attribute of an entity, used with @IdAttribute decorator when an entity has a custom id field
|
|
38
38
|
*/
|
|
39
|
-
idField
|
|
39
|
+
idField?: string;
|
|
40
40
|
constructor(entityClass: EntityClass, tableClassName: string);
|
|
41
41
|
/**
|
|
42
42
|
* Add attribute metadata to an entity
|
|
@@ -58,6 +58,11 @@ declare class EntityMetadata {
|
|
|
58
58
|
* @param attributes
|
|
59
59
|
*/
|
|
60
60
|
parseRawEntityDefinedAttributesPartial(attributes: Partial<EntityDefinedAttributes<DynaRecord>>): Partial<EntityDefinedAttributes<DynaRecord>>;
|
|
61
|
+
/**
|
|
62
|
+
* Filters reserved keys to only include keys present in the given attributes.
|
|
63
|
+
* Zod v4 throws on .omit() with keys not in the schema.
|
|
64
|
+
*/
|
|
65
|
+
private filterReservedKeys;
|
|
61
66
|
/**
|
|
62
67
|
* Build validation errors with the cause
|
|
63
68
|
* @param error
|
|
@@ -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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AC,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"}
|
|
@@ -85,7 +85,8 @@ class EntityMetadata {
|
|
|
85
85
|
parseRawEntityDefinedAttributes(attributes) {
|
|
86
86
|
if (this.#schema === undefined) {
|
|
87
87
|
const tableMeta = _1.default.getTable(this.tableClassName);
|
|
88
|
-
|
|
88
|
+
const omitKeys = this.filterReservedKeys(tableMeta.reservedKeys, this.#zodAttributes);
|
|
89
|
+
this.#schema = zod_1.z.object(this.#zodAttributes).omit(omitKeys);
|
|
89
90
|
}
|
|
90
91
|
try {
|
|
91
92
|
return this.#schema.parse(attributes);
|
|
@@ -104,9 +105,10 @@ class EntityMetadata {
|
|
|
104
105
|
parseRawEntityDefinedAttributesPartial(attributes) {
|
|
105
106
|
if (this.#schemaPartial === undefined) {
|
|
106
107
|
const tableMeta = _1.default.getTable(this.tableClassName);
|
|
108
|
+
const omitKeys = this.filterReservedKeys(tableMeta.reservedKeys, this.#zodPartialAttributes);
|
|
107
109
|
this.#schemaPartial = zod_1.z
|
|
108
110
|
.object(this.#zodPartialAttributes)
|
|
109
|
-
.omit(
|
|
111
|
+
.omit(omitKeys)
|
|
110
112
|
.partial()
|
|
111
113
|
.transform((data) => {
|
|
112
114
|
// Remove undefined values but keep null values
|
|
@@ -126,6 +128,19 @@ class EntityMetadata {
|
|
|
126
128
|
throw this.buildValidationError(error);
|
|
127
129
|
}
|
|
128
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Filters reserved keys to only include keys present in the given attributes.
|
|
133
|
+
* Zod v4 throws on .omit() with keys not in the schema.
|
|
134
|
+
*/
|
|
135
|
+
filterReservedKeys(reservedKeys, attributes) {
|
|
136
|
+
const filtered = {};
|
|
137
|
+
for (const key of Object.keys(reservedKeys)) {
|
|
138
|
+
if (key in attributes) {
|
|
139
|
+
filtered[key] = true;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return filtered;
|
|
143
|
+
}
|
|
129
144
|
/**
|
|
130
145
|
* Build validation errors with the cause
|
|
131
146
|
* @param error
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetadataStorage.d.ts","sourceRoot":"","sources":["../../../src/metadata/MetadataStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,KAAK,EACV,wBAAwB,EAExB,qBAAqB,EAErB,oBAAoB,EAEpB,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB;;;;GAIG;AACH,cAAM,eAAe;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W,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"}
|
|
@@ -122,7 +122,7 @@ class MetadataStorage {
|
|
|
122
122
|
*/
|
|
123
123
|
addEntityRelationship(entityName, options) {
|
|
124
124
|
const entityMetadata = this.#entities[entityName];
|
|
125
|
-
if (
|
|
125
|
+
if (!(options.propertyName in entityMetadata.relationships)) {
|
|
126
126
|
entityMetadata.relationships[options.propertyName] =
|
|
127
127
|
(0, utils_1.createRelationshipInstance)(options);
|
|
128
128
|
}
|
|
@@ -133,8 +133,7 @@ class MetadataStorage {
|
|
|
133
133
|
* @param options
|
|
134
134
|
*/
|
|
135
135
|
addJoinTable(joinTableName, options) {
|
|
136
|
-
|
|
137
|
-
if (metadata === undefined) {
|
|
136
|
+
if (!(joinTableName in this.#joinTables)) {
|
|
138
137
|
const meta = new JoinTableMetadata_1.default(options.entity, options.foreignKey);
|
|
139
138
|
this.#joinTables[joinTableName] = [meta];
|
|
140
139
|
}
|
|
@@ -152,9 +151,10 @@ class MetadataStorage {
|
|
|
152
151
|
addEntityAttribute(entityName, options) {
|
|
153
152
|
const entityMetadata = this.#entities[entityName];
|
|
154
153
|
const { defaultAttributes } = this.#tables[entityMetadata.tableClassName];
|
|
155
|
-
const defaultAttrMeta = defaultAttributes[options.attributeName];
|
|
156
154
|
// The property is a default field assign it, otherwise instantiate new AttributeMetadata
|
|
157
|
-
const meta =
|
|
155
|
+
const meta = options.attributeName in defaultAttributes
|
|
156
|
+
? defaultAttributes[options.attributeName]
|
|
157
|
+
: new AttributeMetadata_1.default(options);
|
|
158
158
|
entityMetadata.addAttribute(meta);
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
@@ -207,7 +207,7 @@ class MetadataStorage {
|
|
|
207
207
|
const protoType = Object.getPrototypeOf(classPrototype);
|
|
208
208
|
if (protoType === null)
|
|
209
209
|
return;
|
|
210
|
-
if (
|
|
210
|
+
if (protoType.constructor.name in this.#tables) {
|
|
211
211
|
return this.#tables[protoType.constructor.name];
|
|
212
212
|
}
|
|
213
213
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableMetadata.d.ts","sourceRoot":"","sources":["../../../src/metadata/TableMetadata.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,GAAG,CAAC;AAEtC,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EAGb,4BAA4B,EAC5B,qBAAqB,EACtB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,KAAK,uBAAuB,EAE7B,MAAM,WAAW,CAAC;AAEnB,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,I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OAAO,CAAC,8BAA8B;IAgCtC;;;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"}
|
|
@@ -130,7 +130,13 @@ class TableMetadata {
|
|
|
130
130
|
*/
|
|
131
131
|
toJSON(entities) {
|
|
132
132
|
return schemas_1.TableMetadataTransform.parse({
|
|
133
|
-
|
|
133
|
+
name: this.name,
|
|
134
|
+
delimiter: this.delimiter,
|
|
135
|
+
defaultAttributes: this.defaultAttributes,
|
|
136
|
+
defaultTableAttributes: this.defaultTableAttributes,
|
|
137
|
+
partitionKeyAttribute: this.partitionKeyAttribute,
|
|
138
|
+
sortKeyAttribute: this.sortKeyAttribute,
|
|
139
|
+
reservedKeys: this.reservedKeys,
|
|
134
140
|
entities
|
|
135
141
|
});
|
|
136
142
|
}
|
|
@@ -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,aAAa,CAAC;AACtD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;;GAQG;AACH,cAAM,qBAAsB,SAAQ,oBAAoB;IACtD,IAAI,
|
|
1
|
+
{"version":3,"file":"BelongsToRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/BelongsToRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;;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"}
|
|
@@ -18,9 +18,7 @@ class BelongsToRelationship extends RelationshipMetadata_1.default {
|
|
|
18
18
|
foreignKey;
|
|
19
19
|
constructor(item) {
|
|
20
20
|
super();
|
|
21
|
-
|
|
22
|
-
Object.assign(this, item);
|
|
23
|
-
}
|
|
21
|
+
Object.assign(this, item);
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
exports.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,wBAAwB,CAAC;AAE1D;;;;;;;GAOG;AACH,cAAM,+BAAgC,SAAQ,oBAAoB;IAChE,IAAI,
|
|
1
|
+
{"version":3,"file":"HasAndBelongsToManyRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;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"}
|
|
@@ -17,9 +17,7 @@ class HasAndBelongsToManyRelationship extends RelationshipMetadata_1.default {
|
|
|
17
17
|
joinTableName;
|
|
18
18
|
constructor(item) {
|
|
19
19
|
super();
|
|
20
|
-
|
|
21
|
-
Object.assign(this, item);
|
|
22
|
-
}
|
|
20
|
+
Object.assign(this, item);
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
23
|
exports.default = HasAndBelongsToManyRelationship;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasManyRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/HasManyRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;;GAQG;AACH,cAAM,mBAAoB,SAAQ,oBAAoB;IACpD,IAAI,
|
|
1
|
+
{"version":3,"file":"HasManyRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/HasManyRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;;GAQG;AACH,cAAM,mBAAoB,SAAQ,oBAAoB;IACpD,IAAI,EAAG,SAAS,CAAU;IAC1B,UAAU,EAAE,kBAAkB,CAAC;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAS;gBAErB,IAAI,EAAE,oBAAoB;CAIvC;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -19,9 +19,7 @@ class HasManyRelationship extends RelationshipMetadata_1.default {
|
|
|
19
19
|
uniDirectional = false;
|
|
20
20
|
constructor(item) {
|
|
21
21
|
super();
|
|
22
|
-
|
|
23
|
-
Object.assign(this, item);
|
|
24
|
-
}
|
|
22
|
+
Object.assign(this, item);
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
25
|
exports.default = HasManyRelationship;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasOneRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/HasOneRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;GAOG;AACH,cAAM,kBAAmB,SAAQ,oBAAoB;IACnD,IAAI,
|
|
1
|
+
{"version":3,"file":"HasOneRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/HasOneRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;GAOG;AACH,cAAM,kBAAmB,SAAQ,oBAAoB;IACnD,IAAI,EAAG,QAAQ,CAAU;IACzB,UAAU,EAAE,kBAAkB,CAAC;gBAEnB,IAAI,EAAE,oBAAoB;CAIvC;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -17,9 +17,7 @@ class HasOneRelationship extends RelationshipMetadata_1.default {
|
|
|
17
17
|
foreignKey;
|
|
18
18
|
constructor(item) {
|
|
19
19
|
super();
|
|
20
|
-
|
|
21
|
-
Object.assign(this, item);
|
|
22
|
-
}
|
|
20
|
+
Object.assign(this, item);
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
23
|
exports.default = HasOneRelationship;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OwnedByRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/OwnedByRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;;GAQG;AACH,cAAM,mBAAoB,SAAQ,oBAAoB;IACpD,IAAI,
|
|
1
|
+
{"version":3,"file":"OwnedByRelationship.d.ts","sourceRoot":"","sources":["../../../../src/metadata/relationship-metadata/OwnedByRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;;GAQG;AACH,cAAM,mBAAoB,SAAQ,oBAAoB;IACpD,IAAI,EAAG,SAAS,CAAU;IAC1B,UAAU,EAAE,kBAAkB,CAAC;gBAEnB,IAAI,EAAE,oBAAoB;CAIvC;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -18,9 +18,7 @@ class OwnedByRelationship extends RelationshipMetadata_1.default {
|
|
|
18
18
|
foreignKey;
|
|
19
19
|
constructor(item) {
|
|
20
20
|
super();
|
|
21
|
-
|
|
22
|
-
Object.assign(this, item);
|
|
23
|
-
}
|
|
21
|
+
Object.assign(this, item);
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
exports.default = OwnedByRelationship;
|