monorise 1.11.0 → 1.13.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.
Files changed (40) hide show
  1. package/dist/base/index.d.ts +4 -4
  2. package/dist/base/index.js.map +1 -1
  3. package/dist/cli/cli.js +6 -0
  4. package/dist/cli/cli.js.map +1 -1
  5. package/dist/core/chunk-W6HUNJ6S.js +79 -0
  6. package/dist/core/chunk-W6HUNJ6S.js.map +1 -0
  7. package/dist/core/index.d.ts +253 -24
  8. package/dist/core/index.js +1304 -182
  9. package/dist/core/index.js.map +1 -1
  10. package/dist/core/service.config-U77V7WIB.js +13 -0
  11. package/dist/core/service.config-U77V7WIB.js.map +1 -0
  12. package/dist/index.d.ts +15 -0
  13. package/dist/proxy/index.d.ts +35 -0
  14. package/dist/proxy/index.js +78 -0
  15. package/dist/proxy/index.js.map +1 -0
  16. package/dist/react/actions/core.action.d.ts.map +1 -1
  17. package/dist/react/actions/websocket.action.d.ts +71 -0
  18. package/dist/react/actions/websocket.action.d.ts.map +1 -0
  19. package/dist/react/chunk-CQQYJW4K.js +444 -0
  20. package/dist/react/chunk-CQQYJW4K.js.map +1 -0
  21. package/dist/react/helpers/transactional.d.ts +32 -1
  22. package/dist/react/helpers/transactional.d.ts.map +1 -1
  23. package/dist/react/index.d.ts +30 -2
  24. package/dist/react/index.d.ts.map +1 -1
  25. package/dist/react/index.js +714 -43
  26. package/dist/react/index.js.map +1 -1
  27. package/dist/react/websocket/WebSocketManager.d.ts +72 -0
  28. package/dist/react/websocket/WebSocketManager.d.ts.map +1 -0
  29. package/dist/react/websocket/index.d.ts +3 -0
  30. package/dist/react/websocket/index.d.ts.map +1 -0
  31. package/dist/react/websocket/optimistic.d.ts +51 -0
  32. package/dist/react/websocket/optimistic.d.ts.map +1 -0
  33. package/dist/react/websocket-34W2HQLH.js +9 -0
  34. package/dist/react/websocket-34W2HQLH.js.map +1 -0
  35. package/dist/sst/components/monorise-core.d.ts +10 -0
  36. package/dist/sst/components/monorise-core.d.ts.map +1 -1
  37. package/dist/sst/components/single-table.d.ts.map +1 -1
  38. package/dist/sst/index.js +86 -14
  39. package/dist/sst/index.js.map +1 -1
  40. package/package.json +11 -1
@@ -0,0 +1,79 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
20
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
+ var __objRest = (source, exclude) => {
22
+ var target = {};
23
+ for (var prop in source)
24
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
25
+ target[prop] = source[prop];
26
+ if (source != null && __getOwnPropSymbols)
27
+ for (var prop of __getOwnPropSymbols(source)) {
28
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
29
+ target[prop] = source[prop];
30
+ }
31
+ return target;
32
+ };
33
+ var __export = (target, all) => {
34
+ for (var name in all)
35
+ __defProp(target, name, { get: all[name], enumerable: true });
36
+ };
37
+ var __async = (__this, __arguments, generator) => {
38
+ return new Promise((resolve, reject) => {
39
+ var fulfilled = (value) => {
40
+ try {
41
+ step(generator.next(value));
42
+ } catch (e) {
43
+ reject(e);
44
+ }
45
+ };
46
+ var rejected = (value) => {
47
+ try {
48
+ step(generator.throw(value));
49
+ } catch (e) {
50
+ reject(e);
51
+ }
52
+ };
53
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
54
+ step((generator = generator.apply(__this, __arguments)).next());
55
+ });
56
+ };
57
+ var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")]) ? it.call(obj) : (obj = obj[__knownSymbol("iterator")](), it = {}, method = (key, fn) => (fn = obj[key]) && (it[key] = (arg) => new Promise((yes, no, done) => (arg = fn.call(obj, arg), done = arg.done, Promise.resolve(arg.value).then((value) => yes({ value, done }), no)))), method("next"), method("return"), it);
58
+
59
+ // constants/table.ts
60
+ var ENTITY_REPLICATION_INDEX = "ENTITY_REPLICATION_INDEX";
61
+ var MUTUAL_REPLICATION_INDEX = "MUTUAL_REPLICATION_INDEX";
62
+
63
+ // configs/service.config.ts
64
+ var CORE_TABLE = process.env.CORE_TABLE || "";
65
+ var CORE_EVENT_BUS = process.env.CORE_EVENT_BUS || "";
66
+
67
+ export {
68
+ __spreadValues,
69
+ __spreadProps,
70
+ __objRest,
71
+ __export,
72
+ __async,
73
+ __forAwait,
74
+ ENTITY_REPLICATION_INDEX,
75
+ MUTUAL_REPLICATION_INDEX,
76
+ CORE_TABLE,
77
+ CORE_EVENT_BUS
78
+ };
79
+ //# sourceMappingURL=chunk-W6HUNJ6S.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../constants/table.ts","../configs/service.config.ts"],"sourcesContent":["export const ENTITY_REPLICATION_INDEX = 'ENTITY_REPLICATION_INDEX';\nexport const MUTUAL_REPLICATION_INDEX = 'MUTUAL_REPLICATION_INDEX';\n","import {\n ENTITY_REPLICATION_INDEX,\n MUTUAL_REPLICATION_INDEX,\n} from '../constants/table';\n\nconst CORE_TABLE = process.env.CORE_TABLE || '';\nconst CORE_EVENT_BUS = process.env.CORE_EVENT_BUS || '';\n\nexport {\n CORE_TABLE,\n CORE_EVENT_BUS,\n ENTITY_REPLICATION_INDEX,\n MUTUAL_REPLICATION_INDEX,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAM,2BAA2B;AACjC,IAAM,2BAA2B;;;ACIxC,IAAM,aAAa,QAAQ,IAAI,cAAc;AAC7C,IAAM,iBAAiB,QAAQ,IAAI,kBAAkB;","names":[]}
@@ -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';
@@ -13,7 +14,7 @@ import { FirehoseClient } from '@aws-sdk/client-firehose';
13
14
  import { LambdaClient } from '@aws-sdk/client-lambda';
14
15
  import { S3Client } from '@aws-sdk/client-s3';
15
16
  import * as hono_aws_lambda from 'hono/aws-lambda';
16
- import { SQSEvent, SQSBatchItemFailure, DynamoDBBatchItemFailure } from 'aws-lambda';
17
+ import { SQSEvent, SQSBatchItemFailure, DynamoDBBatchItemFailure, APIGatewayProxyWebsocketEventV2, APIGatewayProxyResultV2, DynamoDBStreamEvent } from 'aws-lambda';
17
18
  import { _Record } from '@aws-sdk/client-dynamodb-streams';
18
19
 
19
20
  type EventDetail = {
@@ -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>;
@@ -329,6 +363,58 @@ declare class TagRepository extends Repository {
329
363
  }): Promise<void>;
330
364
  }
331
365
 
366
+ interface ConnectionRecord {
367
+ connectionId: string;
368
+ entityType?: string;
369
+ entityId?: string;
370
+ connectedAt?: string;
371
+ expiresAt?: number;
372
+ }
373
+ interface SubscriptionRecord {
374
+ PK: string;
375
+ SK: string;
376
+ connectionId: string;
377
+ subscriptionType: string;
378
+ feedTypes?: string[];
379
+ [key: string]: unknown;
380
+ }
381
+ interface TicketData {
382
+ entityType: string;
383
+ entityId: string;
384
+ feedTypes: string[];
385
+ }
386
+ declare class WebSocketRepository extends Repository {
387
+ private tableName;
388
+ private dynamodbClient;
389
+ private docClient;
390
+ constructor(tableName: string, dynamodbClient: DynamoDB);
391
+ createConnection(connectionId: string, metadata: Record<string, unknown>, expiresAt: number): Promise<void>;
392
+ getConnection(connectionId: string): Promise<ConnectionRecord | undefined>;
393
+ deleteConnection(connectionId: string): Promise<void>;
394
+ createSubscription(subKey: string, connectionId: string, data: Record<string, unknown>): Promise<void>;
395
+ deleteSubscription(subKey: string, connectionId: string): Promise<void>;
396
+ /**
397
+ * Run a query to exhaustion.
398
+ *
399
+ * Every caller below fans a broadcast out to the rows it returns, so a
400
+ * single-page query silently drops recipients past DynamoDB's 1MB limit --
401
+ * and on `$disconnect`, silently leaves their subscription rows behind. The
402
+ * `ConsistentRead` on these queries exists to avoid dropping recipients;
403
+ * stopping at one page drops them the same way, just at a different
404
+ * threshold.
405
+ */
406
+ private queryAllPages;
407
+ querySubscriptionsByKey(subKey: string): Promise<SubscriptionRecord[]>;
408
+ querySubscriptionsByConnectionId(connectionId: string): Promise<SubscriptionRecord[]>;
409
+ createTicket(ticket: string, entityType: string, entityId: string, feedTypes: string[], expiresAt: number): Promise<void>;
410
+ consumeTicket(ticket: string): Promise<TicketData | null>;
411
+ queryMutualConnections(byEntityType: string, byEntityId: string): Promise<{
412
+ entityType: string;
413
+ entityId: string;
414
+ }[]>;
415
+ queryFeedSubscriptions(entityType: string, entityId: string): Promise<SubscriptionRecord[]>;
416
+ }
417
+
332
418
  var __defProp = Object.defineProperty;
333
419
  var __defProps = Object.defineProperties;
334
420
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -373,6 +459,10 @@ var __async = (__this, __arguments, generator) => {
373
459
  });
374
460
  };
375
461
 
462
+ // configs/service.config.ts
463
+ process.env.CORE_TABLE || "";
464
+ process.env.CORE_EVENT_BUS || "";
465
+
376
466
  // errors/standard-error.ts
377
467
  var StandardError$1 = class StandardError extends Error {
378
468
  constructor(errorCode, message, lastError, context) {
@@ -493,10 +583,6 @@ factory.createMiddleware((c, next) => __async(null, null, function* () {
493
583
  return yield next();
494
584
  }));
495
585
 
496
- // configs/service.config.ts
497
- process.env.CORE_TABLE || "";
498
- process.env.CORE_EVENT_BUS || "";
499
-
500
586
  // helpers/event.ts
501
587
  new EventBridgeClient();
502
588
 
@@ -4594,6 +4680,23 @@ declare class UpsertEntityController {
4594
4680
  }, hono_utils_http_status.ContentfulStatusCode, "json">>;
4595
4681
  }
4596
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
+ };
4597
4700
  declare class MutualService {
4598
4701
  private EntityConfig;
4599
4702
  private entityRepository;
@@ -4618,23 +4721,25 @@ declare class MutualService {
4618
4721
  */
4619
4722
  private getMutualFieldConfig;
4620
4723
  private getMutualDataSchema;
4621
- createMutual: <B extends Entity$2, T extends Entity$2, A extends Entity$2>({ byEntityType, byEntityId, entityType, entityId, mutualPayload, accountId, options, }: {
4622
- byEntityType: B;
4623
- byEntityId: string;
4624
- entityType: T;
4625
- entityId: string;
4626
- mutualPayload?: Record<string, unknown>;
4627
- accountId?: string | string[];
4628
- options?: {
4629
- asEntity?: A;
4630
- mutualId?: string;
4631
- skipMutualCreation?: boolean;
4632
- createAndUpdateDatetime?: Date;
4633
- ConditionExpression?: string;
4634
- ExpressionAttributeNames?: Record<string, string>;
4635
- ExpressionAttributeValues?: Record<string, AttributeValue>;
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;
4636
4740
  };
4637
- }) => Promise<{
4741
+ }>;
4742
+ createMutual: <B extends Entity$2, T extends Entity$2, A extends Entity$2>(params: CreateMutualParams<B, T, A>) => Promise<{
4638
4743
  mutual: Mutual<B, T, {
4639
4744
  [x: string]: any;
4640
4745
  }>;
@@ -4650,6 +4755,38 @@ declare class MutualService {
4650
4755
  publishedAt: string;
4651
4756
  };
4652
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
+ }>;
4653
4790
  updateMutual: <B extends Entity$2, T extends Entity$2, M extends Record<string, unknown>>({ byEntityType, byEntityId, entityType, entityId, mutualPayload, accountId, options, }: {
4654
4791
  byEntityType: B;
4655
4792
  byEntityId: string;
@@ -4662,6 +4799,20 @@ declare class MutualService {
4662
4799
  returnUpdatedValue?: boolean;
4663
4800
  };
4664
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
+ }>;
4665
4816
  deleteMutual: ({ byEntityType, byEntityId, entityType, entityId, accountId, }: {
4666
4817
  byEntityType: Entity$2;
4667
4818
  byEntityId: string;
@@ -4750,7 +4901,30 @@ type TransactionDeleteEntity<T extends Entity$2 = Entity$2> = {
4750
4901
  entityType: T;
4751
4902
  entityId: string;
4752
4903
  };
4753
- type TransactionOperation = TransactionCreateEntity | TransactionUpdateEntity | TransactionAdjustEntity | TransactionDeleteEntity;
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;
4754
4928
  type TransactionResultEntry = {
4755
4929
  operation: string;
4756
4930
  entityType: Entity$2;
@@ -4758,6 +4932,11 @@ type TransactionResultEntry = {
4758
4932
  data?: Record<string, unknown>;
4759
4933
  createdAt?: string;
4760
4934
  updatedAt?: string;
4935
+ byEntityType?: Entity$2;
4936
+ byEntityId?: string;
4937
+ mutualId?: string;
4938
+ mutualData?: Record<string, unknown>;
4939
+ mutualUpdatedAt?: string;
4761
4940
  };
4762
4941
  type TransactionResult = {
4763
4942
  results: TransactionResultEntry[];
@@ -4771,9 +4950,15 @@ declare class TransactionService {
4771
4950
  private publishEvent;
4772
4951
  private entityServiceLifeCycle;
4773
4952
  private eventUtils;
4774
- constructor(EntityConfig: Record<Entity$2, ReturnType<typeof createEntityConfig>>, EmailAuthEnabledEntities: Entity$2[], entityRepository: EntityRepository, dynamodbClient: DynamoDB, publishEvent: typeof publishEvent, entityServiceLifeCycle: EntityServiceLifeCycle, eventUtils: EventUtils);
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);
4775
4955
  executeTransaction: (operations: TransactionOperation[], accountId?: string) => Promise<TransactionResult>;
4776
4956
  private processOperation;
4957
+ private processCreateMutual;
4958
+ private processUpdateMutual;
4959
+ private processDeleteMutual;
4960
+ private assertMutualOperation;
4961
+ private requireMutualService;
4777
4962
  private buildCreateItems;
4778
4963
  private buildUpdateItem;
4779
4964
  private buildAdjustItem;
@@ -4788,6 +4973,16 @@ declare class ExecuteTransactionController {
4788
4973
  controller: hono.MiddlewareHandler<any, string, {}, any>;
4789
4974
  }
4790
4975
 
4976
+ declare class CreateTicketController {
4977
+ private container;
4978
+ constructor(container: DependencyContainer);
4979
+ controller: hono.MiddlewareHandler<any, string, {}, Response & hono.TypedResponse<{
4980
+ ticket: string;
4981
+ wsUrl: string;
4982
+ expiresIn: number;
4983
+ }, hono_utils_http_status.ContentfulStatusCode, "json">>;
4984
+ }
4985
+
4791
4986
  declare class DependencyContainer {
4792
4987
  config: {
4793
4988
  EntityConfig: Record<Entity$2, ReturnType<typeof createEntityConfig>>;
@@ -4816,6 +5011,7 @@ declare class DependencyContainer {
4816
5011
  get entityService(): EntityService;
4817
5012
  get mutualService(): MutualService;
4818
5013
  get tagRepository(): TagRepository;
5014
+ get websocketRepository(): WebSocketRepository;
4819
5015
  get getEntityController(): GetEntityController;
4820
5016
  get getEntityByUniqueFieldController(): GetEntityByUniqueFieldValueController;
4821
5017
  get listEntitiesController(): ListEntitiesController;
@@ -4832,6 +5028,7 @@ declare class DependencyContainer {
4832
5028
  get listTagsController(): ListTagsController;
4833
5029
  get transactionService(): TransactionService;
4834
5030
  get executeTransactionController(): ExecuteTransactionController;
5031
+ get createTicketController(): CreateTicketController;
4835
5032
  }
4836
5033
 
4837
5034
  declare const setupCommonRoutes: (container: DependencyContainer) => Hono;
@@ -4985,6 +5182,31 @@ declare const handler: (container: DependencyContainer) => (ev: SQSEvent) => Pro
4985
5182
  batchItemFailures: SQSBatchItemFailure[];
4986
5183
  }>;
4987
5184
 
5185
+ type WebSocketConnectEvent = APIGatewayProxyWebsocketEventV2 & {
5186
+ queryStringParameters?: Record<string, string | undefined>;
5187
+ headers?: Record<string, string | undefined>;
5188
+ };
5189
+ /**
5190
+ * $connect handler
5191
+ * Supports two auth modes:
5192
+ * - ticket: ?ticket=abc123 (issued via /ws/ticket/:entityType/:entityId)
5193
+ * - token: ?token=userId (simplified direct auth)
5194
+ */
5195
+ declare const connect: (container: DependencyContainer) => (event: WebSocketConnectEvent) => Promise<APIGatewayProxyResultV2>;
5196
+ /**
5197
+ * $disconnect handler
5198
+ * Cleans up connection record and all associated subscription records.
5199
+ */
5200
+ declare const disconnect: (container: DependencyContainer) => (event: APIGatewayProxyWebsocketEventV2) => Promise<APIGatewayProxyResultV2>;
5201
+ /**
5202
+ * $default handler - route messages
5203
+ */
5204
+ declare const $default: (container: DependencyContainer) => (event: APIGatewayProxyWebsocketEventV2) => Promise<APIGatewayProxyResultV2>;
5205
+ /**
5206
+ * Broadcast handler - triggered by DynamoDB Streams
5207
+ */
5208
+ declare const broadcast: (container: DependencyContainer) => (event: DynamoDBStreamEvent) => Promise<void>;
5209
+
4988
5210
  declare const transactional: {
4989
5211
  createEntity: <T extends Entity$2>(entityType: T, payload: EntitySchemaMap[T] & {
4990
5212
  entityId?: string;
@@ -4996,6 +5218,9 @@ declare const transactional: {
4996
5218
  $condition?: string;
4997
5219
  }) => TransactionAdjustEntity<T>;
4998
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>;
4999
5224
  };
5000
5225
 
5001
5226
  declare class CoreFactory {
@@ -5009,6 +5234,10 @@ declare class CoreFactory {
5009
5234
  prejoinProcessor: ReturnType<typeof handler$2>;
5010
5235
  tagProcessor: ReturnType<typeof handler>;
5011
5236
  appHandler: ReturnType<typeof appHandler>;
5237
+ wsConnect: ReturnType<typeof connect>;
5238
+ wsDisconnect: ReturnType<typeof disconnect>;
5239
+ wsDefault: ReturnType<typeof $default>;
5240
+ wsBroadcast: ReturnType<typeof broadcast>;
5012
5241
  dependencyContainer: DependencyContainer;
5013
5242
  constructor(config: {
5014
5243
  EntityConfig: Record<Entity$2, ReturnType<typeof createEntityConfig>>;
@@ -5017,4 +5246,4 @@ declare class CoreFactory {
5017
5246
  });
5018
5247
  }
5019
5248
 
5020
- export { DependencyContainer, Entity$1 as Entity, EntityRepository, EntityService, Mutual, MutualRepository, MutualService, PROJECTION_EXPRESSION, StandardError, StandardErrorCode, TagRepository, TransactionService, handler$7 as analyticsBackfillProcessor, handler$6 as analyticsMaterializationProcessor, handler$5 as analyticsModelProcessor, handler$8 as analyticsProcessor, analyticsQueryHandler, handler$4 as analyticsViewProcessor, appHandler, handler$9 as createEntityProcessor, CoreFactory as default, handler$3 as mutualProcessor, handler$2 as prejoinProcessor, handler$1 as replicationProcessor, setupCommonRoutes, startBackfill as startAnalyticsBackfill, handler as tagProcessor, transactional };
5249
+ export { DependencyContainer, Entity$1 as Entity, EntityRepository, EntityService, Mutual, MutualRepository, MutualService, PROJECTION_EXPRESSION, StandardError, StandardErrorCode, TagRepository, TransactionService, WebSocketRepository, handler$7 as analyticsBackfillProcessor, handler$6 as analyticsMaterializationProcessor, handler$5 as analyticsModelProcessor, handler$8 as analyticsProcessor, analyticsQueryHandler, handler$4 as analyticsViewProcessor, appHandler, handler$9 as createEntityProcessor, CoreFactory as default, handler$3 as mutualProcessor, handler$2 as prejoinProcessor, handler$1 as replicationProcessor, setupCommonRoutes, startBackfill as startAnalyticsBackfill, handler as tagProcessor, transactional, broadcast as wsBroadcast, connect as wsConnect, $default as wsDefault, disconnect as wsDisconnect };