dyna-record 0.3.1 → 0.3.3
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
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type FindByIdOptions, type FindByIdIncludesRes, type EntityKeyConditions, type QueryResults, Create, type CreateOptions, type UpdateOptions, type EntityAttributesInstance, type IncludedAssociations, type IndexKeyConditions, type OptionsWithoutIndex, type OptionsWithIndex } from "./operations";
|
|
2
|
-
import type { EntityClass, Optional } from "./types";
|
|
2
|
+
import type { DynamoTableItem, EntityClass, Optional } from "./types";
|
|
3
3
|
interface DynaRecordBase {
|
|
4
4
|
id: string;
|
|
5
5
|
type: string;
|
|
@@ -249,6 +249,14 @@ declare abstract class DynaRecord implements DynaRecordBase {
|
|
|
249
249
|
* ```
|
|
250
250
|
*/
|
|
251
251
|
static partitionKeyValue(id: string): string;
|
|
252
|
+
/**
|
|
253
|
+
* Takes a table item and serializes it to an entity instance
|
|
254
|
+
*/
|
|
255
|
+
static tableItemToEntity<T extends DynaRecord>(this: new () => T, tableItem: DynamoTableItem): T;
|
|
256
|
+
/**
|
|
257
|
+
* Get the partition key for an entity
|
|
258
|
+
* @returns The partition key of the entity
|
|
259
|
+
*/
|
|
252
260
|
partitionKeyValue(): string;
|
|
253
261
|
}
|
|
254
262
|
export default DynaRecord;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynaRecord.d.ts","sourceRoot":"","sources":["../../src/DynaRecord.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EAExB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,MAAM,EACN,KAAK,aAAa,EAElB,KAAK,aAAa,EAGlB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EAEtB,MAA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;;;;;;;;;OAmBG;WACiB,MAAM,CAAC,CAAC,SAAS,UAAU,EAC7C,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EACpB,EAAE,EAAE,MAAM,EACV,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,GAC3B,OAAO,CAAC,IAAI,CAAC;IAKhB;;;;;;;;;;;;;OAaG;IACU,MAAM,CAAC,CAAC,SAAS,IAAI,EAChC,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,GAC3B,OAAO,CAAC,CAAC,CAAC;IAkBb;;;;;;;;;;OAUG;WACiB,MAAM,CAAC,CAAC,SAAS,UAAU,EAC7C,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EACpB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC;IAKhB;;;;;;;;;OASG;WACW,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAKnD;;OAEG;WACW,iBAAiB,CAAC,CAAC,SAAS,UAAU,EAClD,IAAI,EAAE,UAAU,CAAC,EACjB,SAAS,EAAE,eAAe,GACzB,CAAC;IAWJ;;;OAGG;IACI,iBAAiB,IAAI,MAAM;CAGnC;AAED,eAAe,UAAU,CAAC"}
|
package/dist/src/DynaRecord.js
CHANGED
|
@@ -235,6 +235,21 @@ let DynaRecord = (() => {
|
|
|
235
235
|
const { delimiter } = metadata_1.default.getEntityTable(this.name);
|
|
236
236
|
return `${this.name}${delimiter}${id}`;
|
|
237
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Takes a table item and serializes it to an entity instance
|
|
240
|
+
*/
|
|
241
|
+
static tableItemToEntity(tableItem) {
|
|
242
|
+
const tableMeta = metadata_1.default.getEntityTable(this.name);
|
|
243
|
+
const typeAlias = tableMeta.defaultAttributes.type.alias;
|
|
244
|
+
if (tableItem[typeAlias] !== this.name) {
|
|
245
|
+
throw new Error("Unable to convert dynamo item to entity. Invalid type");
|
|
246
|
+
}
|
|
247
|
+
return (0, utils_1.tableItemToEntity)(this, tableItem);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Get the partition key for an entity
|
|
251
|
+
* @returns The partition key of the entity
|
|
252
|
+
*/
|
|
238
253
|
partitionKeyValue() {
|
|
239
254
|
return this.constructor.partitionKeyValue(this.id);
|
|
240
255
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -4,5 +4,4 @@ export * from "./relationships";
|
|
|
4
4
|
export * from "./dynamo-utils/errors";
|
|
5
5
|
export type { EntityAttributesOnly, EntityAttributesInstance as EntityInstance, FindByIdIncludesRes } from "./operations";
|
|
6
6
|
export type { PartitionKey, SortKey, ForeignKey, NullableForeignKey } from "./types";
|
|
7
|
-
export { tableItemToEntity } from "./utils";
|
|
8
7
|
//# 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,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AAEtC,YAAY,EACV,oBAAoB,EACpB,wBAAwB,IAAI,cAAc,EAC1C,mBAAmB,EACpB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,YAAY,EACZ,OAAO,EACP,UAAU,EACV,kBAAkB,EACnB,MAAM,SAAS,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AAEtC,YAAY,EACV,oBAAoB,EACpB,wBAAwB,IAAI,cAAc,EAC1C,mBAAmB,EACpB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,YAAY,EACZ,OAAO,EACP,UAAU,EACV,kBAAkB,EACnB,MAAM,SAAS,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -14,10 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.tableItemToEntity = void 0;
|
|
18
17
|
__exportStar(require("./decorators"), exports);
|
|
19
18
|
__exportStar(require("./errors"), exports);
|
|
20
19
|
__exportStar(require("./relationships"), exports);
|
|
21
20
|
__exportStar(require("./dynamo-utils/errors"), exports);
|
|
22
|
-
var utils_1 = require("./utils");
|
|
23
|
-
Object.defineProperty(exports, "tableItemToEntity", { enumerable: true, get: function () { return utils_1.tableItemToEntity; } });
|