monorise 1.12.0 → 1.13.1
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/core/index.d.ts +154 -18
- package/dist/core/index.js +510 -114
- package/dist/core/index.js.map +1 -1
- package/dist/react/actions/core.action.d.ts.map +1 -1
- package/dist/react/helpers/transactional.d.ts +33 -2
- package/dist/react/helpers/transactional.d.ts.map +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +121 -13
- package/dist/react/index.js.map +1 -1
- package/dist/react/services/core.service.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/core/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Entity as Entity$2, EntitySchemaMap, createEntityConfig, WhereConditions } from '../base/index';
|
|
2
2
|
import * as hono from 'hono';
|
|
3
3
|
import { Hono } from 'hono';
|
|
4
|
+
import * as _aws_sdk_client_dynamodb from '@aws-sdk/client-dynamodb';
|
|
4
5
|
import { DynamoDB, TransactWriteItemsInput, AttributeValue, TransactWriteItem, UpdateItemCommandInput, DynamoDBClient } from '@aws-sdk/client-dynamodb';
|
|
5
6
|
import * as hono_utils_http_status from 'hono/utils/http-status';
|
|
6
7
|
import * as hono_utils_types from 'hono/utils/types';
|
|
@@ -228,6 +229,25 @@ declare class MutualRepository extends Repository {
|
|
|
228
229
|
ExpressionAttributeValues?: Record<string, AttributeValue>;
|
|
229
230
|
createAndUpdateDatetime?: Date;
|
|
230
231
|
}): Promise<Mutual<B, T, M>>;
|
|
232
|
+
/**
|
|
233
|
+
* @description Resolves the live mutual and builds the TransactWriteItems that update its
|
|
234
|
+
* `mutualData` on all three records, without writing them. `updateMutual` writes them on their
|
|
235
|
+
* own; `TransactionService` folds them into a larger transaction. Throws `MUTUAL_IS_UNDEFINED`
|
|
236
|
+
* when there is no live mutual for the pair.
|
|
237
|
+
*/
|
|
238
|
+
prepareUpdateMutual<B extends Entity$2, T extends Entity$2, M extends Record<string, unknown>>(byEntityType: B, byEntityId: string, entityType: T, entityId: string, toUpdate: {
|
|
239
|
+
mutualData: Record<string, unknown>;
|
|
240
|
+
mutualUpdatedAt?: string;
|
|
241
|
+
updatedAt?: string;
|
|
242
|
+
}, opts?: {
|
|
243
|
+
ConditionExpression?: string;
|
|
244
|
+
ExpressionAttributeNames?: Record<string, string>;
|
|
245
|
+
ExpressionAttributeValues?: Record<string, AttributeValue>;
|
|
246
|
+
maxObjectUpdateLevel?: number;
|
|
247
|
+
}): Promise<{
|
|
248
|
+
mutual: Mutual<B, T, M>;
|
|
249
|
+
TransactItems: TransactWriteItem[];
|
|
250
|
+
}>;
|
|
231
251
|
updateMutual<B extends Entity$2, T extends Entity$2, M extends Record<string, unknown>>(byEntityType: B, byEntityId: string, entityType: T, entityId: string, toUpdate: {
|
|
232
252
|
mutualData: Record<string, unknown>;
|
|
233
253
|
mutualUpdatedAt?: string;
|
|
@@ -239,6 +259,20 @@ declare class MutualRepository extends Repository {
|
|
|
239
259
|
returnUpdatedValue?: boolean;
|
|
240
260
|
maxObjectUpdateLevel?: number;
|
|
241
261
|
}): Promise<Mutual<B, T, M> | undefined>;
|
|
262
|
+
/**
|
|
263
|
+
* @description Resolves the live mutual and builds the TransactWriteItems that soft-delete it
|
|
264
|
+
* (all three records get a 10-minute `expiresAt`), without writing them. `deleteMutual` writes
|
|
265
|
+
* them on their own; `TransactionService` folds them into a larger transaction. Throws
|
|
266
|
+
* `MUTUAL_IS_UNDEFINED` when there is no live mutual for the pair.
|
|
267
|
+
*/
|
|
268
|
+
prepareDeleteMutual<B extends Entity$2, T extends Entity$2, M extends Record<string, unknown>>(byEntityType: B, byEntityId: string, entityType: T, entityId: string, opts?: {
|
|
269
|
+
ConditionExpression?: string;
|
|
270
|
+
ExpressionAttributeNames?: Record<string, string>;
|
|
271
|
+
ExpressionAttributeValues?: Record<string, AttributeValue>;
|
|
272
|
+
}): Promise<{
|
|
273
|
+
mutual: Mutual<B, T, M>;
|
|
274
|
+
TransactItems: TransactWriteItem[];
|
|
275
|
+
}>;
|
|
242
276
|
deleteMutual<B extends Entity$2, T extends Entity$2, M extends Record<string, unknown>>(byEntityType: B, byEntityId: string, entityType: T, entityId: string, opts?: {
|
|
243
277
|
ConditionExpression?: string;
|
|
244
278
|
ExpressionAttributeNames?: Record<string, string>;
|
|
@@ -4646,6 +4680,23 @@ declare class UpsertEntityController {
|
|
|
4646
4680
|
}, hono_utils_http_status.ContentfulStatusCode, "json">>;
|
|
4647
4681
|
}
|
|
4648
4682
|
|
|
4683
|
+
type CreateMutualParams<B extends Entity$2, T extends Entity$2, A extends Entity$2> = {
|
|
4684
|
+
byEntityType: B;
|
|
4685
|
+
byEntityId: string;
|
|
4686
|
+
entityType: T;
|
|
4687
|
+
entityId: string;
|
|
4688
|
+
mutualPayload?: Record<string, unknown>;
|
|
4689
|
+
accountId?: string | string[];
|
|
4690
|
+
options?: {
|
|
4691
|
+
asEntity?: A;
|
|
4692
|
+
mutualId?: string;
|
|
4693
|
+
skipMutualCreation?: boolean;
|
|
4694
|
+
createAndUpdateDatetime?: Date;
|
|
4695
|
+
ConditionExpression?: string;
|
|
4696
|
+
ExpressionAttributeNames?: Record<string, string>;
|
|
4697
|
+
ExpressionAttributeValues?: Record<string, AttributeValue>;
|
|
4698
|
+
};
|
|
4699
|
+
};
|
|
4649
4700
|
declare class MutualService {
|
|
4650
4701
|
private EntityConfig;
|
|
4651
4702
|
private entityRepository;
|
|
@@ -4670,23 +4721,25 @@ declare class MutualService {
|
|
|
4670
4721
|
*/
|
|
4671
4722
|
private getMutualFieldConfig;
|
|
4672
4723
|
private getMutualDataSchema;
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4724
|
+
/**
|
|
4725
|
+
* @description Everything `createMutual` does before it writes: validates the payload, reads
|
|
4726
|
+
* both entities, checks no live mutual exists, and builds the TransactWriteItems (plus the
|
|
4727
|
+
* `asEntity` projection's items, when there is one). Nothing is written. `createMutual` commits
|
|
4728
|
+
* the items on their own; `TransactionService` folds them into a larger transaction. Either
|
|
4729
|
+
* caller then runs `afterCreateEntityHook` for `entity` (when set) and publishes MUTUAL_CREATED
|
|
4730
|
+
* once the write has committed.
|
|
4731
|
+
*/
|
|
4732
|
+
prepareCreateMutual: <B extends Entity$2, T extends Entity$2, A extends Entity$2>({ byEntityType, byEntityId, entityType, entityId, mutualPayload, options, }: CreateMutualParams<B, T, A>) => Promise<{
|
|
4733
|
+
mutual: Mutual<B, T, {
|
|
4734
|
+
[x: string]: any;
|
|
4735
|
+
}>;
|
|
4736
|
+
entity: Entity$1<A> | undefined;
|
|
4737
|
+
transactItems: _aws_sdk_client_dynamodb.TransactWriteItem[];
|
|
4738
|
+
parsedMutualPayload: {
|
|
4739
|
+
[x: string]: any;
|
|
4688
4740
|
};
|
|
4689
|
-
}
|
|
4741
|
+
}>;
|
|
4742
|
+
createMutual: <B extends Entity$2, T extends Entity$2, A extends Entity$2>(params: CreateMutualParams<B, T, A>) => Promise<{
|
|
4690
4743
|
mutual: Mutual<B, T, {
|
|
4691
4744
|
[x: string]: any;
|
|
4692
4745
|
}>;
|
|
@@ -4702,6 +4755,38 @@ declare class MutualService {
|
|
|
4702
4755
|
publishedAt: string;
|
|
4703
4756
|
};
|
|
4704
4757
|
}>;
|
|
4758
|
+
private getMutualUpdateSchema;
|
|
4759
|
+
/**
|
|
4760
|
+
* @description Reads the live mutual for a pair, with its stored `data` and `mutualData` —
|
|
4761
|
+
* the same read `updateMutual` returns with `returnUpdatedValue`. Throws `MUTUAL_IS_UNDEFINED`
|
|
4762
|
+
* when there is none.
|
|
4763
|
+
*/
|
|
4764
|
+
getMutual: ({ byEntityType, byEntityId, entityType, entityId, }: {
|
|
4765
|
+
byEntityType: Entity$2;
|
|
4766
|
+
byEntityId: string;
|
|
4767
|
+
entityType: Entity$2;
|
|
4768
|
+
entityId: string;
|
|
4769
|
+
}) => Promise<Mutual<Entity$2, Entity$2, Record<string, unknown>>>;
|
|
4770
|
+
/**
|
|
4771
|
+
* @description Everything `updateMutual` does before it writes: validates the patch with the
|
|
4772
|
+
* same schema, resolves the live mutual and builds the TransactWriteItems. Nothing is written —
|
|
4773
|
+
* for `TransactionService`, which publishes the same MUTUAL_UPDATED event once its transaction
|
|
4774
|
+
* commits. Throws `MUTUAL_NOT_FOUND` when there is no live mutual for the pair.
|
|
4775
|
+
*/
|
|
4776
|
+
prepareUpdateMutual: ({ byEntityType, byEntityId, entityType, entityId, mutualPayload, options, }: {
|
|
4777
|
+
byEntityType: Entity$2;
|
|
4778
|
+
byEntityId: string;
|
|
4779
|
+
entityType: Entity$2;
|
|
4780
|
+
entityId: string;
|
|
4781
|
+
mutualPayload: Record<string, unknown>;
|
|
4782
|
+
options?: {
|
|
4783
|
+
maxObjectUpdateLevel?: number;
|
|
4784
|
+
};
|
|
4785
|
+
}) => Promise<{
|
|
4786
|
+
mutual: Mutual<Entity$2, Entity$2, Record<string, unknown>>;
|
|
4787
|
+
TransactItems: _aws_sdk_client_dynamodb.TransactWriteItem[];
|
|
4788
|
+
parsedMutualPayload: Record<string, unknown>;
|
|
4789
|
+
}>;
|
|
4705
4790
|
updateMutual: <B extends Entity$2, T extends Entity$2, M extends Record<string, unknown>>({ byEntityType, byEntityId, entityType, entityId, mutualPayload, accountId, options, }: {
|
|
4706
4791
|
byEntityType: B;
|
|
4707
4792
|
byEntityId: string;
|
|
@@ -4714,6 +4799,20 @@ declare class MutualService {
|
|
|
4714
4799
|
returnUpdatedValue?: boolean;
|
|
4715
4800
|
};
|
|
4716
4801
|
}) => Promise<Mutual<B, T, Record<string, unknown>> | undefined>;
|
|
4802
|
+
/**
|
|
4803
|
+
* @description Resolves the live mutual and builds the TransactWriteItems that delete it,
|
|
4804
|
+
* without writing — for `TransactionService`. Throws `MUTUAL_NOT_FOUND` (same as
|
|
4805
|
+
* `deleteMutual`) when there is no live mutual for the pair.
|
|
4806
|
+
*/
|
|
4807
|
+
prepareDeleteMutual: ({ byEntityType, byEntityId, entityType, entityId, }: {
|
|
4808
|
+
byEntityType: Entity$2;
|
|
4809
|
+
byEntityId: string;
|
|
4810
|
+
entityType: Entity$2;
|
|
4811
|
+
entityId: string;
|
|
4812
|
+
}) => Promise<{
|
|
4813
|
+
mutual: Mutual<Entity$2, Entity$2, Record<string, unknown>>;
|
|
4814
|
+
TransactItems: _aws_sdk_client_dynamodb.TransactWriteItem[];
|
|
4815
|
+
}>;
|
|
4717
4816
|
deleteMutual: ({ byEntityType, byEntityId, entityType, entityId, accountId, }: {
|
|
4718
4817
|
byEntityType: Entity$2;
|
|
4719
4818
|
byEntityId: string;
|
|
@@ -4802,7 +4901,30 @@ type TransactionDeleteEntity<T extends Entity$2 = Entity$2> = {
|
|
|
4802
4901
|
entityType: T;
|
|
4803
4902
|
entityId: string;
|
|
4804
4903
|
};
|
|
4805
|
-
type
|
|
4904
|
+
type TransactionCreateMutual<B extends Entity$2 = Entity$2, T extends Entity$2 = Entity$2> = {
|
|
4905
|
+
operation: 'createMutual';
|
|
4906
|
+
byEntityType: B;
|
|
4907
|
+
byEntityId: string;
|
|
4908
|
+
entityType: T;
|
|
4909
|
+
entityId: string;
|
|
4910
|
+
payload?: Record<string, unknown>;
|
|
4911
|
+
};
|
|
4912
|
+
type TransactionUpdateMutual<B extends Entity$2 = Entity$2, T extends Entity$2 = Entity$2> = {
|
|
4913
|
+
operation: 'updateMutual';
|
|
4914
|
+
byEntityType: B;
|
|
4915
|
+
byEntityId: string;
|
|
4916
|
+
entityType: T;
|
|
4917
|
+
entityId: string;
|
|
4918
|
+
payload: Record<string, unknown>;
|
|
4919
|
+
};
|
|
4920
|
+
type TransactionDeleteMutual<B extends Entity$2 = Entity$2, T extends Entity$2 = Entity$2> = {
|
|
4921
|
+
operation: 'deleteMutual';
|
|
4922
|
+
byEntityType: B;
|
|
4923
|
+
byEntityId: string;
|
|
4924
|
+
entityType: T;
|
|
4925
|
+
entityId: string;
|
|
4926
|
+
};
|
|
4927
|
+
type TransactionOperation = TransactionCreateEntity | TransactionUpdateEntity | TransactionAdjustEntity | TransactionDeleteEntity | TransactionCreateMutual | TransactionUpdateMutual | TransactionDeleteMutual;
|
|
4806
4928
|
type TransactionResultEntry = {
|
|
4807
4929
|
operation: string;
|
|
4808
4930
|
entityType: Entity$2;
|
|
@@ -4810,6 +4932,11 @@ type TransactionResultEntry = {
|
|
|
4810
4932
|
data?: Record<string, unknown>;
|
|
4811
4933
|
createdAt?: string;
|
|
4812
4934
|
updatedAt?: string;
|
|
4935
|
+
byEntityType?: Entity$2;
|
|
4936
|
+
byEntityId?: string;
|
|
4937
|
+
mutualId?: string;
|
|
4938
|
+
mutualData?: Record<string, unknown>;
|
|
4939
|
+
mutualUpdatedAt?: string;
|
|
4813
4940
|
};
|
|
4814
4941
|
type TransactionResult = {
|
|
4815
4942
|
results: TransactionResultEntry[];
|
|
@@ -4823,9 +4950,15 @@ declare class TransactionService {
|
|
|
4823
4950
|
private publishEvent;
|
|
4824
4951
|
private entityServiceLifeCycle;
|
|
4825
4952
|
private eventUtils;
|
|
4826
|
-
|
|
4953
|
+
private mutualService?;
|
|
4954
|
+
constructor(EntityConfig: Record<Entity$2, ReturnType<typeof createEntityConfig>>, EmailAuthEnabledEntities: Entity$2[], entityRepository: EntityRepository, dynamodbClient: DynamoDB, publishEvent: typeof publishEvent, entityServiceLifeCycle: EntityServiceLifeCycle, eventUtils: EventUtils, mutualService?: MutualService | undefined);
|
|
4827
4955
|
executeTransaction: (operations: TransactionOperation[], accountId?: string) => Promise<TransactionResult>;
|
|
4828
4956
|
private processOperation;
|
|
4957
|
+
private processCreateMutual;
|
|
4958
|
+
private processUpdateMutual;
|
|
4959
|
+
private processDeleteMutual;
|
|
4960
|
+
private assertMutualOperation;
|
|
4961
|
+
private requireMutualService;
|
|
4829
4962
|
private buildCreateItems;
|
|
4830
4963
|
private buildUpdateItem;
|
|
4831
4964
|
private buildAdjustItem;
|
|
@@ -5085,6 +5218,9 @@ declare const transactional: {
|
|
|
5085
5218
|
$condition?: string;
|
|
5086
5219
|
}) => TransactionAdjustEntity<T>;
|
|
5087
5220
|
deleteEntity: <T extends Entity$2>(entityType: T, entityId: string) => TransactionDeleteEntity<T>;
|
|
5221
|
+
createMutual: <B extends Entity$2, T extends Entity$2>(byEntityType: B, entityType: T, byEntityId: string, entityId: string, payload?: Record<string, unknown>) => TransactionCreateMutual<B, T>;
|
|
5222
|
+
updateMutual: <B extends Entity$2, T extends Entity$2>(byEntityType: B, entityType: T, byEntityId: string, entityId: string, payload: Record<string, unknown>) => TransactionUpdateMutual<B, T>;
|
|
5223
|
+
deleteMutual: <B extends Entity$2, T extends Entity$2>(byEntityType: B, entityType: T, byEntityId: string, entityId: string) => TransactionDeleteMutual<B, T>;
|
|
5088
5224
|
};
|
|
5089
5225
|
|
|
5090
5226
|
declare class CoreFactory {
|