@monorise/core 4.0.0 → 4.2.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/dist/index.d.ts +31 -9
- package/dist/index.js +339 -68
- package/dist/index.js.map +1 -1
- package/package.json +7 -2
package/dist/index.d.ts
CHANGED
|
@@ -74,8 +74,9 @@ declare class Entity$1<T extends Entity$2> extends Item$1 {
|
|
|
74
74
|
data: Partial<EntitySchemaMap[T]>;
|
|
75
75
|
private _createdAt?;
|
|
76
76
|
private _updatedAt?;
|
|
77
|
+
private _expiresAt?;
|
|
77
78
|
fullId: string;
|
|
78
|
-
constructor(entityType: T, entityId?: string | undefined, data?: Partial<EntitySchemaMap[T]>, _createdAt?: Date | undefined, _updatedAt?: Date | undefined);
|
|
79
|
+
constructor(entityType: T, entityId?: string | undefined, data?: Partial<EntitySchemaMap[T]>, _createdAt?: Date | undefined, _updatedAt?: Date | undefined, _expiresAt?: Date | undefined);
|
|
79
80
|
static fromItem<T extends Entity$2>(item?: Record<string, AttributeValue>): Entity$1<T>;
|
|
80
81
|
get pk(): string;
|
|
81
82
|
get sk(): string;
|
|
@@ -83,6 +84,7 @@ declare class Entity$1<T extends Entity$2> extends Item$1 {
|
|
|
83
84
|
get emailKeys(): Record<string, AttributeValue>;
|
|
84
85
|
get createdAt(): string | undefined;
|
|
85
86
|
get updatedAt(): string | undefined;
|
|
87
|
+
get expiresAt(): number | undefined;
|
|
86
88
|
toItem(): Record<string, AttributeValue>;
|
|
87
89
|
toJSON(): Record<string, unknown>;
|
|
88
90
|
}
|
|
@@ -92,6 +94,13 @@ declare class EntityRepository extends Repository {
|
|
|
92
94
|
private readonly dynamodbClient;
|
|
93
95
|
private readonly EmailAuthEnabledEntities;
|
|
94
96
|
constructor(EntityConfig: Record<Entity$2, ReturnType<typeof createEntityConfig>>, TABLE_NAME: string, dynamodbClient: DynamoDB, EmailAuthEnabledEntities: Entity$2[]);
|
|
97
|
+
/**
|
|
98
|
+
* Computes the `expiresAt` Date for an entity via its `ttl.processor` config, if any.
|
|
99
|
+
* When `mergeWithExisting` is true, the processor receives the previous entity's data
|
|
100
|
+
* merged with `incomingData` (falls back to `incomingData` alone if no previous entity
|
|
101
|
+
* exists yet, eg. an upsert-as-create).
|
|
102
|
+
*/
|
|
103
|
+
private computeExpiresAt;
|
|
95
104
|
listEntities<T extends Entity$2>({ entityType, limit, // if this is not set, it will return all items
|
|
96
105
|
between, options, }: {
|
|
97
106
|
entityType: T;
|
|
@@ -123,7 +132,7 @@ declare class EntityRepository extends Repository {
|
|
|
123
132
|
mutualId?: string;
|
|
124
133
|
}): Promise<Entity$1<T>>;
|
|
125
134
|
upsertEntity<T extends Entity$2>(entityType: T, entityId: string, payload: Partial<EntitySchemaMap[T]>): Promise<Entity$1<T>>;
|
|
126
|
-
updateEntityTransactItems<T extends Entity$2>(entity: Entity$1<T>, updateParams: UpdateItemCommandInput, previousUniqueFieldValues: Record<string, string>, previousEntity: Entity$1<T
|
|
135
|
+
updateEntityTransactItems<T extends Entity$2>(entity: Entity$1<T>, updateParams: UpdateItemCommandInput, previousUniqueFieldValues: Record<string, string>, previousEntity: Entity$1<T>, expiresAt?: Date): TransactWriteItem[];
|
|
127
136
|
updateEntity<T extends Entity$2>(entityType: T, entityId: string, toUpdate: {
|
|
128
137
|
data: Partial<EntitySchemaMap[T]>;
|
|
129
138
|
updatedAt?: string;
|
|
@@ -182,7 +191,7 @@ declare class Mutual<B extends Entity$2, T extends Entity$2, M extends Record<st
|
|
|
182
191
|
get createdAt(): string | undefined;
|
|
183
192
|
get updatedAt(): string | undefined;
|
|
184
193
|
get mutualUpdatedAt(): string | undefined;
|
|
185
|
-
get expiresAt():
|
|
194
|
+
get expiresAt(): number | undefined;
|
|
186
195
|
toItem(): Record<string, AttributeValue>;
|
|
187
196
|
toReversedItem(): Record<string, AttributeValue>;
|
|
188
197
|
toJSON(): Record<string, unknown>;
|
|
@@ -393,13 +402,14 @@ var Item = class {
|
|
|
393
402
|
|
|
394
403
|
// data/Entity.ts
|
|
395
404
|
var Entity = class _Entity extends Item {
|
|
396
|
-
constructor(entityType, entityId, data = {}, _createdAt, _updatedAt) {
|
|
405
|
+
constructor(entityType, entityId, data = {}, _createdAt, _updatedAt, _expiresAt) {
|
|
397
406
|
super();
|
|
398
407
|
this.entityType = entityType;
|
|
399
408
|
this.entityId = entityId;
|
|
400
409
|
this.data = data;
|
|
401
410
|
this._createdAt = _createdAt;
|
|
402
411
|
this._updatedAt = _updatedAt;
|
|
412
|
+
this._expiresAt = _expiresAt;
|
|
403
413
|
this.fullId = this.pk;
|
|
404
414
|
}
|
|
405
415
|
static fromItem(item) {
|
|
@@ -414,7 +424,9 @@ var Entity = class _Entity extends Item {
|
|
|
414
424
|
parsedItem.entityId,
|
|
415
425
|
parsedItem.data,
|
|
416
426
|
parsedItem.createdAt ? new Date(parsedItem.createdAt) : void 0,
|
|
417
|
-
parsedItem.updatedAt ? new Date(parsedItem.updatedAt) : void 0
|
|
427
|
+
parsedItem.updatedAt ? new Date(parsedItem.updatedAt) : void 0,
|
|
428
|
+
// expiresAt is stored as epoch seconds (DynamoDB TTL requires type N)
|
|
429
|
+
parsedItem.expiresAt ? new Date(parsedItem.expiresAt * 1e3) : void 0
|
|
418
430
|
);
|
|
419
431
|
}
|
|
420
432
|
get pk() {
|
|
@@ -444,6 +456,9 @@ var Entity = class _Entity extends Item {
|
|
|
444
456
|
var _a;
|
|
445
457
|
return (_a = this._updatedAt) == null ? void 0 : _a.toISOString();
|
|
446
458
|
}
|
|
459
|
+
get expiresAt() {
|
|
460
|
+
return this._expiresAt ? Math.floor(this._expiresAt.getTime() / 1e3) : void 0;
|
|
461
|
+
}
|
|
447
462
|
toItem() {
|
|
448
463
|
return __spreadValues(__spreadValues({}, marshall(this.toJSON(), { removeUndefinedValues: true })), this.keys());
|
|
449
464
|
}
|
|
@@ -453,7 +468,8 @@ var Entity = class _Entity extends Item {
|
|
|
453
468
|
entityId: this.entityId,
|
|
454
469
|
data: this.data,
|
|
455
470
|
createdAt: this.createdAt,
|
|
456
|
-
updatedAt: this.updatedAt
|
|
471
|
+
updatedAt: this.updatedAt,
|
|
472
|
+
expiresAt: this.expiresAt
|
|
457
473
|
};
|
|
458
474
|
}
|
|
459
475
|
};
|
|
@@ -4583,12 +4599,14 @@ declare class UpsertEntityController {
|
|
|
4583
4599
|
}
|
|
4584
4600
|
|
|
4585
4601
|
declare class MutualService {
|
|
4602
|
+
private EntityConfig;
|
|
4586
4603
|
private entityRepository;
|
|
4587
4604
|
private mutualRepository;
|
|
4588
4605
|
private publishEvent;
|
|
4589
4606
|
private ddbUtils;
|
|
4590
4607
|
private entityServiceLifeCycle;
|
|
4591
|
-
constructor(entityRepository: EntityRepository, mutualRepository: MutualRepository, publishEvent: typeof publishEvent, ddbUtils: DbUtils, entityServiceLifeCycle: EntityServiceLifeCycle);
|
|
4608
|
+
constructor(EntityConfig: Record<Entity$2, ReturnType<typeof createEntityConfig>>, entityRepository: EntityRepository, mutualRepository: MutualRepository, publishEvent: typeof publishEvent, ddbUtils: DbUtils, entityServiceLifeCycle: EntityServiceLifeCycle);
|
|
4609
|
+
private getMutualDataSchema;
|
|
4592
4610
|
createMutual: <B extends Entity$2, T extends Entity$2, A extends Entity$2>({ byEntityType, byEntityId, entityType, entityId, mutualPayload, accountId, options, }: {
|
|
4593
4611
|
byEntityType: B;
|
|
4594
4612
|
byEntityId: string;
|
|
@@ -4607,13 +4625,17 @@ declare class MutualService {
|
|
|
4607
4625
|
ExpressionAttributeValues?: Record<string, AttributeValue>;
|
|
4608
4626
|
};
|
|
4609
4627
|
}) => Promise<{
|
|
4610
|
-
mutual: Mutual<B, T,
|
|
4628
|
+
mutual: Mutual<B, T, {
|
|
4629
|
+
[x: string]: any;
|
|
4630
|
+
}>;
|
|
4611
4631
|
eventPayload: {
|
|
4612
4632
|
byEntityType: B;
|
|
4613
4633
|
byEntityId: string;
|
|
4614
4634
|
entityType: T;
|
|
4615
4635
|
entityId: string;
|
|
4616
|
-
parsedMutualPayload:
|
|
4636
|
+
parsedMutualPayload: {
|
|
4637
|
+
[x: string]: any;
|
|
4638
|
+
};
|
|
4617
4639
|
accountId: string | string[] | undefined;
|
|
4618
4640
|
publishedAt: string;
|
|
4619
4641
|
};
|