monorise 1.1.0-dev.0 → 1.1.0-dev.10

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 (88) hide show
  1. package/dist/base/index.d.ts +79 -1
  2. package/dist/base/index.js +51 -1
  3. package/dist/base/index.js.map +1 -1
  4. package/dist/cli/cli.js +2 -2
  5. package/dist/core/index.d.ts +12 -56
  6. package/dist/core/index.js +249 -59
  7. package/dist/core/index.js.map +1 -1
  8. package/dist/react/actions/core.action.d.ts.map +1 -1
  9. package/dist/react/{chunk-EQ3PKQ2S.js → chunk-BIXAYYE4.js} +35 -5
  10. package/dist/react/{chunk-EQ3PKQ2S.js.map → chunk-BIXAYYE4.js.map} +1 -1
  11. package/dist/react/index.d.ts +1 -1
  12. package/dist/react/index.d.ts.map +1 -1
  13. package/dist/react/index.js +251 -10389
  14. package/dist/react/index.js.map +1 -1
  15. package/dist/react/lib/entity.d.ts +1 -1
  16. package/dist/react/lib/entity.d.ts.map +1 -1
  17. package/dist/react/websocket-7MZ3ENOC.js +9 -0
  18. package/dist/sst/components/monorise-core.d.ts +2 -0
  19. package/dist/sst/components/monorise-core.d.ts.map +1 -1
  20. package/dist/sst/components/single-table.d.ts +6 -0
  21. package/dist/sst/components/single-table.d.ts.map +1 -1
  22. package/dist/sst/index.js +8 -7
  23. package/dist/sst/index.js.map +1 -1
  24. package/package.json +9 -2
  25. package/dist/react/chunk-4D22OCZG.js +0 -65
  26. package/dist/react/chunk-4D22OCZG.js.map +0 -1
  27. package/dist/react/chunk-4N3P4ONH.js +0 -588
  28. package/dist/react/chunk-4N3P4ONH.js.map +0 -1
  29. package/dist/react/chunk-4Y4KWGJD.js +0 -182
  30. package/dist/react/chunk-4Y4KWGJD.js.map +0 -1
  31. package/dist/react/chunk-757E5UYA.js +0 -893
  32. package/dist/react/chunk-757E5UYA.js.map +0 -1
  33. package/dist/react/chunk-A5TI2FW3.js +0 -13
  34. package/dist/react/chunk-A5TI2FW3.js.map +0 -1
  35. package/dist/react/chunk-B3XDGUFO.js +0 -489
  36. package/dist/react/chunk-B3XDGUFO.js.map +0 -1
  37. package/dist/react/chunk-BPBCUO2Z.js +0 -248
  38. package/dist/react/chunk-BPBCUO2Z.js.map +0 -1
  39. package/dist/react/chunk-CQBOIXWK.js +0 -142
  40. package/dist/react/chunk-DRH2BB7I.js +0 -383
  41. package/dist/react/chunk-DRH2BB7I.js.map +0 -1
  42. package/dist/react/chunk-H64MMAL7.js +0 -245
  43. package/dist/react/chunk-H64MMAL7.js.map +0 -1
  44. package/dist/react/chunk-KJX5LOMN.js +0 -43
  45. package/dist/react/chunk-KJX5LOMN.js.map +0 -1
  46. package/dist/react/chunk-MO35V2Y7.js +0 -172
  47. package/dist/react/chunk-MO35V2Y7.js.map +0 -1
  48. package/dist/react/chunk-UC3E72G7.js +0 -73
  49. package/dist/react/chunk-UC3E72G7.js.map +0 -1
  50. package/dist/react/chunk-UHMKB3OR.js +0 -5568
  51. package/dist/react/chunk-UHMKB3OR.js.map +0 -1
  52. package/dist/react/chunk-UQPQBWEQ.js +0 -54
  53. package/dist/react/chunk-UQPQBWEQ.js.map +0 -1
  54. package/dist/react/chunk-XCDCVRJR.js +0 -43
  55. package/dist/react/chunk-XCDCVRJR.js.map +0 -1
  56. package/dist/react/chunk-XOYAZDIH.js +0 -47
  57. package/dist/react/chunk-XOYAZDIH.js.map +0 -1
  58. package/dist/react/chunk-YNFQEPO5.js +0 -29
  59. package/dist/react/chunk-YNFQEPO5.js.map +0 -1
  60. package/dist/react/dist-es-35AO47NO.js +0 -90
  61. package/dist/react/dist-es-35AO47NO.js.map +0 -1
  62. package/dist/react/dist-es-5GDBXNKQ.js +0 -333
  63. package/dist/react/dist-es-5GDBXNKQ.js.map +0 -1
  64. package/dist/react/dist-es-B3JDGWY6.js +0 -71
  65. package/dist/react/dist-es-B3JDGWY6.js.map +0 -1
  66. package/dist/react/dist-es-IWIE5JLA.js +0 -169
  67. package/dist/react/dist-es-IWIE5JLA.js.map +0 -1
  68. package/dist/react/dist-es-NRIS3TYJ.js +0 -494
  69. package/dist/react/dist-es-NRIS3TYJ.js.map +0 -1
  70. package/dist/react/dist-es-VCXAEYYN.js +0 -22
  71. package/dist/react/dist-es-VCXAEYYN.js.map +0 -1
  72. package/dist/react/dist-es-VU33JFTZ.js +0 -379
  73. package/dist/react/dist-es-VU33JFTZ.js.map +0 -1
  74. package/dist/react/event-streams-OSOTOTTP.js +0 -277
  75. package/dist/react/event-streams-OSOTOTTP.js.map +0 -1
  76. package/dist/react/loadSso-ME7MKAM3.js +0 -556
  77. package/dist/react/loadSso-ME7MKAM3.js.map +0 -1
  78. package/dist/react/service.config-ZJEZ6EKA-FC2TR3GH.js +0 -14
  79. package/dist/react/service.config-ZJEZ6EKA-FC2TR3GH.js.map +0 -1
  80. package/dist/react/signin-LOXYIE5I.js +0 -653
  81. package/dist/react/signin-LOXYIE5I.js.map +0 -1
  82. package/dist/react/sso-oidc-X63KRRLO.js +0 -786
  83. package/dist/react/sso-oidc-X63KRRLO.js.map +0 -1
  84. package/dist/react/sts-OXBEY7HY.js +0 -3948
  85. package/dist/react/sts-OXBEY7HY.js.map +0 -1
  86. package/dist/react/websocket-QHA7SQXG.js +0 -10
  87. package/dist/react/websocket-QHA7SQXG.js.map +0 -1
  88. /package/dist/react/{chunk-CQBOIXWK.js.map → websocket-7MZ3ENOC.js.map} +0 -0
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { Entity as Entity$1, EntitySchemaMap as EntitySchemaMap$1 } from './index';
2
3
 
3
4
  type WhereOperator = {
4
5
  $eq: string | number | boolean;
@@ -29,6 +30,25 @@ declare enum Entity {
29
30
  interface EntitySchemaMap {
30
31
  [key: string]: Record<string, any>;
31
32
  }
33
+ /**
34
+ * @description Configuration for a mutual relationship between two entities.
35
+ * Defines the schema for mutualData validation. Define once, reference from both entity configs.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * const enrollmentMutual = createMutualConfig({
40
+ * entities: [Entity.STUDENT, Entity.COURSE],
41
+ * mutualDataSchema: z.object({
42
+ * role: z.enum(['student', 'auditor']),
43
+ * enrolledAt: z.string().datetime(),
44
+ * }),
45
+ * });
46
+ * ```
47
+ */
48
+ interface MutualConfig<MD extends z.ZodRawShape = z.ZodRawShape> {
49
+ entities: [Entity, Entity];
50
+ mutualDataSchema: z.ZodObject<MD>;
51
+ }
32
52
  type DraftEntity<T extends Entity = Entity> = T extends keyof EntitySchemaMap ? EntitySchemaMap[T] : never;
33
53
  type NumericFields<T> = {
34
54
  [K in keyof T as T[K] extends number ? K : never]?: number;
@@ -133,6 +153,11 @@ interface MonoriseEntityConfig<T extends Entity = Entity, B extends z.ZodRawShap
133
153
  * @returns the final state of `mutualData` to be stored in the mutual record. Must be an object.
134
154
  */
135
155
  mutualDataProcessor?: (mutualIds: string[], currentMutual: any, customContext?: Record<string, any>) => Record<string, any>;
156
+ /**
157
+ * @description (Optional) Reference to a mutual config created by `createMutualConfig`.
158
+ * Provides mutualData schema validation for create/update operations on this mutual relationship.
159
+ */
160
+ mutual?: MutualConfig;
136
161
  };
137
162
  };
138
163
  /**
@@ -353,6 +378,7 @@ declare const createEntityConfig: <T extends Entity, B extends z.ZodRawShape, C
353
378
  entityType: Entity;
354
379
  toMutualIds?: (context: any) => string[];
355
380
  mutualDataProcessor?: (mutualIds: string[], currentMutual: any, customContext?: Record<string, any>) => Record<string, any>;
381
+ mutual?: MutualConfig;
356
382
  };
357
383
  };
358
384
  prejoins?: {
@@ -394,5 +420,57 @@ declare const createEntityConfig: <T extends Entity, B extends z.ZodRawShape, C
394
420
  [conditionName: string]: undefined | ((data: Partial<z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B>, any> extends infer T_35 ? { [k_6 in keyof T_35]: T_35[k_6]; } : never>) => undefined);
395
421
  } | undefined;
396
422
  };
423
+ declare const createMutualConfig: <MD extends z.ZodRawShape>(config: MutualConfig<MD>) => MutualConfig<MD>;
424
+
425
+ type TransactionCreateEntity<T extends Entity$1 = Entity$1> = {
426
+ operation: 'createEntity';
427
+ entityType: T;
428
+ entityId?: string;
429
+ payload: EntitySchemaMap$1[T];
430
+ };
431
+ type TransactionUpdateEntity<T extends Entity$1 = Entity$1> = {
432
+ operation: 'updateEntity';
433
+ entityType: T;
434
+ entityId: string;
435
+ payload: Partial<EntitySchemaMap$1[T]>;
436
+ accountId?: string;
437
+ condition?: string;
438
+ };
439
+ type TransactionAdjustEntity<T extends Entity$1 = Entity$1> = {
440
+ operation: 'adjustEntity';
441
+ entityType: T;
442
+ entityId: string;
443
+ adjustments: Record<string, number>;
444
+ accountId?: string;
445
+ condition?: string;
446
+ };
447
+ type TransactionDeleteEntity<T extends Entity$1 = Entity$1> = {
448
+ operation: 'deleteEntity';
449
+ entityType: T;
450
+ entityId: string;
451
+ };
452
+ type TransactionOperation = TransactionCreateEntity | TransactionUpdateEntity | TransactionAdjustEntity | TransactionDeleteEntity;
453
+ type TransactionResultEntry = {
454
+ operation: string;
455
+ entityType: Entity$1;
456
+ entityId: string;
457
+ data?: Record<string, unknown>;
458
+ };
459
+ type TransactionResult = {
460
+ results: TransactionResultEntry[];
461
+ };
462
+
463
+ declare const transactional: {
464
+ createEntity: <T extends Entity$1>(entityType: T, payload: EntitySchemaMap$1[T] & {
465
+ entityId?: string;
466
+ }) => TransactionCreateEntity<T>;
467
+ updateEntity: <T extends Entity$1>(entityType: T, entityId: string, payload: Partial<EntitySchemaMap$1[T]> & {
468
+ $condition?: string;
469
+ }) => TransactionUpdateEntity<T>;
470
+ adjustEntity: <T extends Entity$1>(entityType: T, entityId: string, adjustments: Record<string, number> & {
471
+ $condition?: string;
472
+ }) => TransactionAdjustEntity<T>;
473
+ deleteEntity: <T extends Entity$1>(entityType: T, entityId: string) => TransactionDeleteEntity<T>;
474
+ };
397
475
 
398
- export { type AdjustmentCondition, type AdjustmentConditionFn, type CreatedEntity, type DraftEntity, Entity, type EntitySchemaMap, type MonoriseEntityConfig, type NumericFields, type UpdateCondition, type UpdateConditionFn, type WhereClause, type WhereConditions, type WhereOperator, createEntityConfig };
476
+ export { type AdjustmentCondition, type AdjustmentConditionFn, type CreatedEntity, type DraftEntity, Entity, type EntitySchemaMap, type MonoriseEntityConfig, type MutualConfig, type NumericFields, type TransactionAdjustEntity, type TransactionCreateEntity, type TransactionDeleteEntity, type TransactionOperation, type TransactionResult, type TransactionResultEntry, type TransactionUpdateEntity, type UpdateCondition, type UpdateConditionFn, type WhereClause, type WhereConditions, type WhereOperator, createEntityConfig, createMutualConfig, transactional };
@@ -17,6 +17,18 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
20
32
 
21
33
  // types/monorise.type.ts
22
34
  var Entity = /* @__PURE__ */ ((Entity2) => {
@@ -37,8 +49,46 @@ function makeSchema(config) {
37
49
  var createEntityConfig = (config) => __spreadProps(__spreadValues({}, config), {
38
50
  finalSchema: makeSchema(config)
39
51
  });
52
+ var createMutualConfig = (config) => config;
53
+
54
+ // transactional.ts
55
+ var transactional = {
56
+ createEntity: (entityType, payload) => {
57
+ const _a = payload, { entityId } = _a, rest = __objRest(_a, ["entityId"]);
58
+ return __spreadValues({
59
+ operation: "createEntity",
60
+ entityType,
61
+ payload: rest
62
+ }, entityId && { entityId });
63
+ },
64
+ updateEntity: (entityType, entityId, payload) => {
65
+ const _a = payload, { $condition } = _a, rest = __objRest(_a, ["$condition"]);
66
+ return __spreadValues({
67
+ operation: "updateEntity",
68
+ entityType,
69
+ entityId,
70
+ payload: rest
71
+ }, $condition && { condition: $condition });
72
+ },
73
+ adjustEntity: (entityType, entityId, adjustments) => {
74
+ const _a = adjustments, { $condition } = _a, rest = __objRest(_a, ["$condition"]);
75
+ return __spreadValues({
76
+ operation: "adjustEntity",
77
+ entityType,
78
+ entityId,
79
+ adjustments: rest
80
+ }, $condition && { condition: $condition });
81
+ },
82
+ deleteEntity: (entityType, entityId) => ({
83
+ operation: "deleteEntity",
84
+ entityType,
85
+ entityId
86
+ })
87
+ };
40
88
  export {
41
89
  Entity,
42
- createEntityConfig
90
+ createEntityConfig,
91
+ createMutualConfig,
92
+ transactional
43
93
  };
44
94
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../types/monorise.type.ts","../utils/index.ts"],"sourcesContent":["import type { z } from 'zod';\nimport type { WhereConditions } from './conditions.type';\n\nexport enum Entity {}\n\nexport interface EntitySchemaMap {\n [key: string]: Record<string, any>;\n}\n\nexport type DraftEntity<T extends Entity = Entity> =\n T extends keyof EntitySchemaMap ? EntitySchemaMap[T] : never;\n\nexport type NumericFields<T> = {\n [K in keyof T as T[K] extends number ? K : never]?: number;\n};\n\nexport type CreatedEntity<T extends Entity = Entity> = {\n entityId: string;\n entityType: string;\n data: T extends keyof EntitySchemaMap ? EntitySchemaMap[T] : never;\n createdAt: string;\n updatedAt: string;\n};\n\n/**\n * @description Configuration for a monorise entity, a shared configuration that is used across frontend and backend.\n * This can be served as a single source of truth for the entity configuration.\n * It is used to define the schema, and mutual relationships between this entity and other entities.\n *\n * @example\n * ```ts\n * const baseSchema = z.object({\n * title: z.string(),\n * }).partial();\n *\n * const createSchema = baseSchema.extend({\n * title: z.string(),\n * })\n *\n * const config = createEntityConfig({\n * name: 'learner',\n * displayName: 'Learner',\n * baseSchema,\n * createSchema,\n * });\n * ```\n */\nexport interface MonoriseEntityConfig<\n T extends Entity = Entity,\n B extends z.ZodRawShape = z.ZodRawShape,\n C extends z.ZodRawShape = z.ZodRawShape,\n M extends z.ZodRawShape = z.ZodRawShape,\n CO extends z.ZodObject<C> | undefined = undefined,\n MO extends z.ZodObject<M> | undefined = undefined,\n> {\n /**\n * @description Name of the entity. Must be in **lower-kebab-case** and **unique** across all entities\n *\n * @example `learner`, `learning-activity`\n */\n name: string | T;\n\n /**\n * @description Display name of the entity. It is not required to be unique\n */\n displayName: string;\n\n /**\n * @description (DEPRECATED) Use `uniqueFields` instead, Monorise should not handle auth mechanism\n * @description (Optional) Specify the authentication method to be used for the entity\n */\n authMethod?: {\n /**\n * @description Authentication method using email\n *\n * Note: The email used for authentication is unique per entity.\n * For example, if `johndoe@mail.com` is used for `learner` entity,\n * it can be reused again on `admin` entity. However, the same email\n * address cannot be repeated for the same entity.\n */\n email: {\n /**\n * @description Number of milliseconds before the token expires\n */\n tokenExpiresIn: number;\n };\n };\n\n /**\n * @description Base schema for the entity\n */\n baseSchema: z.ZodObject<B>;\n\n /**\n * @description Minimal schema required to create an entity\n */\n createSchema?: CO;\n searchableFields?: (keyof B)[];\n uniqueFields?: (keyof B)[];\n\n /**\n * @description Define mutual relationship of this entity with other entities\n */\n mutual?: {\n /**\n * @description Subscribes to update events from specified entities in the array.\n * These events will be used to run prejoin processor.\n */\n subscribes?: { entityType: Entity }[];\n /**\n * @description Virtual schema for mutual relationship. The schema is only used for validation purpose, but these fields are not stored in the database\n */\n mutualSchema: MO;\n\n /**\n * @description Keys of `mutualFields` are fields defined in `mutualSchema`.\n * Each field is a mutual relationship between this entity and another entity.\n */\n mutualFields: {\n [key: string]: {\n entityType: Entity;\n toMutualIds?: (context: any) => string[];\n /**\n * @description (Optional) Custom function to process `mutualData`. If not provided, `mutualData` will be empty.\n *\n * @returns the final state of `mutualData` to be stored in the mutual record. Must be an object.\n */\n mutualDataProcessor?: (\n mutualIds: string[],\n currentMutual: any,\n customContext?: Record<string, any>,\n ) => Record<string, any>;\n };\n };\n\n /**\n * @description (Optional) Better known as tree processor\n * This is used to prejoin entities that are not directly related as mutual.\n * For example, if `learner` entity is related to `course` entity, and `course` entity is related to `module` entity,\n * prejoins can be used to join `learner` and `module` entities.\n * With this, the `learner` entity can access the `module` entity without having to go through the `course` entity,\n * hence reducing the number of queries.\n *\n * DynamoDB best practices: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-general-normalization.html\n *\n */\n prejoins?: {\n mutualField: string;\n targetEntityType: Entity;\n entityPaths: {\n skipCache?: boolean;\n entityType: Entity;\n processor?: (items: any[], context: Record<string, any>) => any;\n }[];\n }[];\n };\n /**\n * Use this function to perform side effects on the final schema for example refine/superRefine the schema\n *\n * @param schema The final schema of the entity (the combination of `baseSchema`/`createSchema` and `mutualSchema` if specified)\n * @returns void\n *\n * @example\n * ```ts\n * effect: (schema) => {\n * schema.refine(\n * // refinement logic here\n * )\n * }\n */\n effect?: (\n schema: z.ZodObject<z.ZodRawShape>,\n ) => z.ZodEffects<z.ZodObject<z.ZodRawShape>>;\n\n /**\n * @description (Optional) Use tags to create additional access patterns for the entity.\n * Time complexity for retrieving tagged entities is O(1).\n *\n * The following configuration will create a tag named `region` for the `organization` entity grouped by `region`.\n * You would then be able to retrieve all organizations in a specific region by:\n * GET `/core/tag/organization/region?group={region_name}`\n *\n * @example\n *\n * ```ts\n * {\n * name: 'organization',\n * tags: [\n * {\n * name: 'region',\n * processor: (entity) => {\n * return [\n * {\n * group: entity.data.region\n * }\n * ]\n * },\n * }\n * ]\n * }\n * ```\n *\n * @description\n *\n * The following configuration will create a tag named `dob` for the `user` entity sorted by `dob`.\n * You would then be able to retrieve all users sorted by `dob` by:\n * GET `/core/tag/user/dob?start=2000-01-01&end=2020-12-31`\n *\n * @example\n * ```ts\n * {\n * name: 'user',\n * tags: [\n * {\n * name: 'dob',\n * processor: (entity) => {\n * return [\n * {\n * sortValue: entity.data.dob\n * }\n * ]\n * },\n * }\n * ]\n * }\n * ```\n */\n tags?: {\n name: string;\n processor: (entity: { entityId: string; entityType: string; data: Record<string, any>; createdAt: string; updatedAt: string }) => {\n group?: string;\n sortValue?: string;\n }[];\n }[];\n\n /**\n * @description (Optional) Constraints for `adjustEntity` operations.\n * When adjusting numeric fields, these constraints are enforced at the database level.\n * If an adjustment would violate a constraint, the operation is rejected.\n *\n * @deprecated Use `conditions` instead. Will be removed in a future version.\n *\n * @example\n * ```ts\n * {\n * adjustmentConstraints: {\n * // Static: same for all entities of this type\n * balance: { min: 0 },\n * credits: { min: 0, max: 10000 },\n *\n * // Dynamic: reads constraint value from entity's own data\n * balance: { minField: 'minBalance' },\n * credits: { min: 0, maxField: 'creditLimit' },\n * }\n * }\n * ```\n */\n adjustmentConstraints?: {\n [fieldName: string]: {\n /** Static minimum value */\n min?: number;\n /** Static maximum value */\n max?: number;\n /** Field name on the entity whose value is used as the minimum (must be a numeric field) */\n minField?: keyof {\n [K in keyof B as B[K] extends z.ZodNumber | z.ZodOptional<z.ZodNumber> ? K : never]: K;\n } extends never ? string : keyof {\n [K in keyof B as B[K] extends z.ZodNumber | z.ZodOptional<z.ZodNumber> ? K : never]: K;\n };\n /** Field name on the entity whose value is used as the maximum (must be a numeric field) */\n maxField?: keyof {\n [K in keyof B as B[K] extends z.ZodNumber | z.ZodOptional<z.ZodNumber> ? K : never]: K;\n } extends never ? string : keyof {\n [K in keyof B as B[K] extends z.ZodNumber | z.ZodOptional<z.ZodNumber> ? K : never]: K;\n };\n };\n };\n\n /**\n * @description Named conditions for adjustEntity operations.\n * Each condition is either a static `WhereConditions` object or a function\n * `(data, adjustments) => WhereConditions` that receives the entity's current data\n * and the adjustment deltas.\n *\n * When defined, `$condition` is **required** in the adjustEntity request body.\n * The client sends a condition name (string), the server resolves it to a\n * DynamoDB ConditionExpression.\n *\n * @example\n * ```ts\n * {\n * adjustmentConditions: {\n * withdraw: (data, adjustments) => ({\n * balance: { $gte: (data.minBalance ?? 0) + Math.abs(adjustments?.balance ?? 0) },\n * }),\n * deposit: (data, adjustments) => ({\n * balance: { $lte: 1000000 - (adjustments.balance ?? 0) },\n * }),\n * }\n * }\n * ```\n */\n adjustmentConditions?: {\n [conditionName: string]:\n | WhereConditions\n | ((\n data: Partial<z.infer<z.ZodObject<B>>>,\n adjustments: Record<string, number>,\n ) => WhereConditions);\n };\n\n /**\n * @description Named conditions for updateEntity operations.\n * Each condition is either a static `WhereConditions` object or a function\n * `(data) => WhereConditions` that receives the entity's current data.\n *\n * `$condition` is always **optional** for updateEntity.\n * The client sends a condition name (string), the server resolves it to a\n * DynamoDB ConditionExpression. Replaces raw `$where` (deprecated).\n *\n * @example\n * ```ts\n * {\n * updateConditions: {\n * publish: { status: { $eq: 'draft' } },\n * archive: (data) => ({ status: { $ne: 'archived' } }),\n * }\n * }\n * ```\n */\n updateConditions?: {\n [conditionName: string]:\n | WhereConditions\n | ((data: Partial<z.infer<z.ZodObject<B>>>) => WhereConditions);\n };\n}\n","import type { Entity, MonoriseEntityConfig } from '../types/monorise.type';\nimport { z } from 'zod';\n\nfunction makeSchema<\n T extends Entity,\n B extends z.ZodRawShape,\n C extends z.ZodRawShape,\n M extends z.ZodRawShape,\n CO extends z.ZodObject<C> | undefined = undefined,\n MO extends z.ZodObject<M> | undefined = undefined,\n>(config: MonoriseEntityConfig<T, B, C, M, CO, MO>) {\n const { baseSchema, createSchema, mutual, effect } = config;\n const { mutualSchema } = mutual || {};\n\n type FinalSchemaType = CO extends z.AnyZodObject\n ? MO extends z.AnyZodObject\n ? z.ZodObject<B & CO['shape'] & MO['shape']>\n : z.ZodObject<B & CO['shape']>\n : MO extends z.AnyZodObject\n ? z.ZodObject<B & MO['shape']>\n : z.ZodObject<B>;\n\n const finalSchema = z.object({\n ...baseSchema.shape,\n ...createSchema?.shape,\n ...mutualSchema?.shape,\n }) as FinalSchemaType;\n\n if (effect) {\n return effect(finalSchema) as z.ZodEffects<FinalSchemaType>;\n }\n\n return finalSchema;\n}\n\nconst createEntityConfig = <\n T extends Entity,\n B extends z.ZodRawShape,\n C extends z.ZodRawShape,\n M extends z.ZodRawShape,\n CO extends z.ZodObject<C> | undefined = undefined,\n MO extends z.ZodObject<M> | undefined = undefined,\n>(\n config: MonoriseEntityConfig<T, B, C, M, CO, MO>,\n) => ({\n ...config,\n finalSchema: makeSchema(config),\n});\n\nexport { createEntityConfig };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGO,IAAK,SAAL,kBAAKA,YAAL;AAAK,SAAAA;AAAA,GAAA;;;ACFZ,SAAS,SAAS;AAElB,SAAS,WAOP,QAAkD;AAClD,QAAM,EAAE,YAAY,cAAc,QAAQ,OAAO,IAAI;AACrD,QAAM,EAAE,aAAa,IAAI,UAAU,CAAC;AAUpC,QAAM,cAAc,EAAE,OAAO,iDACxB,WAAW,QACX,6CAAc,QACd,6CAAc,MAClB;AAED,MAAI,QAAQ;AACV,WAAO,OAAO,WAAW;AAAA,EAC3B;AAEA,SAAO;AACT;AAEA,IAAM,qBAAqB,CAQzB,WACI,iCACD,SADC;AAAA,EAEJ,aAAa,WAAW,MAAM;AAChC;","names":["Entity"]}
1
+ {"version":3,"sources":["../types/monorise.type.ts","../utils/index.ts","../transactional.ts"],"sourcesContent":["import type { z } from 'zod';\nimport type { WhereConditions } from './conditions.type';\n\nexport enum Entity {}\n\nexport interface EntitySchemaMap {\n [key: string]: Record<string, any>;\n}\n\n/**\n * @description Configuration for a mutual relationship between two entities.\n * Defines the schema for mutualData validation. Define once, reference from both entity configs.\n *\n * @example\n * ```ts\n * const enrollmentMutual = createMutualConfig({\n * entities: [Entity.STUDENT, Entity.COURSE],\n * mutualDataSchema: z.object({\n * role: z.enum(['student', 'auditor']),\n * enrolledAt: z.string().datetime(),\n * }),\n * });\n * ```\n */\nexport interface MutualConfig<\n MD extends z.ZodRawShape = z.ZodRawShape,\n> {\n entities: [Entity, Entity];\n mutualDataSchema: z.ZodObject<MD>;\n}\n\nexport type DraftEntity<T extends Entity = Entity> =\n T extends keyof EntitySchemaMap ? EntitySchemaMap[T] : never;\n\nexport type NumericFields<T> = {\n [K in keyof T as T[K] extends number ? K : never]?: number;\n};\n\nexport type CreatedEntity<T extends Entity = Entity> = {\n entityId: string;\n entityType: string;\n data: T extends keyof EntitySchemaMap ? EntitySchemaMap[T] : never;\n createdAt: string;\n updatedAt: string;\n};\n\n/**\n * @description Configuration for a monorise entity, a shared configuration that is used across frontend and backend.\n * This can be served as a single source of truth for the entity configuration.\n * It is used to define the schema, and mutual relationships between this entity and other entities.\n *\n * @example\n * ```ts\n * const baseSchema = z.object({\n * title: z.string(),\n * }).partial();\n *\n * const createSchema = baseSchema.extend({\n * title: z.string(),\n * })\n *\n * const config = createEntityConfig({\n * name: 'learner',\n * displayName: 'Learner',\n * baseSchema,\n * createSchema,\n * });\n * ```\n */\nexport interface MonoriseEntityConfig<\n T extends Entity = Entity,\n B extends z.ZodRawShape = z.ZodRawShape,\n C extends z.ZodRawShape = z.ZodRawShape,\n M extends z.ZodRawShape = z.ZodRawShape,\n CO extends z.ZodObject<C> | undefined = undefined,\n MO extends z.ZodObject<M> | undefined = undefined,\n> {\n /**\n * @description Name of the entity. Must be in **lower-kebab-case** and **unique** across all entities\n *\n * @example `learner`, `learning-activity`\n */\n name: string | T;\n\n /**\n * @description Display name of the entity. It is not required to be unique\n */\n displayName: string;\n\n /**\n * @description (DEPRECATED) Use `uniqueFields` instead, Monorise should not handle auth mechanism\n * @description (Optional) Specify the authentication method to be used for the entity\n */\n authMethod?: {\n /**\n * @description Authentication method using email\n *\n * Note: The email used for authentication is unique per entity.\n * For example, if `johndoe@mail.com` is used for `learner` entity,\n * it can be reused again on `admin` entity. However, the same email\n * address cannot be repeated for the same entity.\n */\n email: {\n /**\n * @description Number of milliseconds before the token expires\n */\n tokenExpiresIn: number;\n };\n };\n\n /**\n * @description Base schema for the entity\n */\n baseSchema: z.ZodObject<B>;\n\n /**\n * @description Minimal schema required to create an entity\n */\n createSchema?: CO;\n searchableFields?: (keyof B)[];\n uniqueFields?: (keyof B)[];\n\n /**\n * @description Define mutual relationship of this entity with other entities\n */\n mutual?: {\n /**\n * @description Subscribes to update events from specified entities in the array.\n * These events will be used to run prejoin processor.\n */\n subscribes?: { entityType: Entity }[];\n /**\n * @description Virtual schema for mutual relationship. The schema is only used for validation purpose, but these fields are not stored in the database\n */\n mutualSchema: MO;\n\n /**\n * @description Keys of `mutualFields` are fields defined in `mutualSchema`.\n * Each field is a mutual relationship between this entity and another entity.\n */\n mutualFields: {\n [key: string]: {\n entityType: Entity;\n toMutualIds?: (context: any) => string[];\n /**\n * @description (Optional) Custom function to process `mutualData`. If not provided, `mutualData` will be empty.\n *\n * @returns the final state of `mutualData` to be stored in the mutual record. Must be an object.\n */\n mutualDataProcessor?: (\n mutualIds: string[],\n currentMutual: any,\n customContext?: Record<string, any>,\n ) => Record<string, any>;\n /**\n * @description (Optional) Reference to a mutual config created by `createMutualConfig`.\n * Provides mutualData schema validation for create/update operations on this mutual relationship.\n */\n mutual?: MutualConfig;\n };\n };\n\n /**\n * @description (Optional) Better known as tree processor\n * This is used to prejoin entities that are not directly related as mutual.\n * For example, if `learner` entity is related to `course` entity, and `course` entity is related to `module` entity,\n * prejoins can be used to join `learner` and `module` entities.\n * With this, the `learner` entity can access the `module` entity without having to go through the `course` entity,\n * hence reducing the number of queries.\n *\n * DynamoDB best practices: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-general-normalization.html\n *\n */\n prejoins?: {\n mutualField: string;\n targetEntityType: Entity;\n entityPaths: {\n skipCache?: boolean;\n entityType: Entity;\n processor?: (items: any[], context: Record<string, any>) => any;\n }[];\n }[];\n };\n /**\n * Use this function to perform side effects on the final schema for example refine/superRefine the schema\n *\n * @param schema The final schema of the entity (the combination of `baseSchema`/`createSchema` and `mutualSchema` if specified)\n * @returns void\n *\n * @example\n * ```ts\n * effect: (schema) => {\n * schema.refine(\n * // refinement logic here\n * )\n * }\n */\n effect?: (\n schema: z.ZodObject<z.ZodRawShape>,\n ) => z.ZodEffects<z.ZodObject<z.ZodRawShape>>;\n\n /**\n * @description (Optional) Use tags to create additional access patterns for the entity.\n * Time complexity for retrieving tagged entities is O(1).\n *\n * The following configuration will create a tag named `region` for the `organization` entity grouped by `region`.\n * You would then be able to retrieve all organizations in a specific region by:\n * GET `/core/tag/organization/region?group={region_name}`\n *\n * @example\n *\n * ```ts\n * {\n * name: 'organization',\n * tags: [\n * {\n * name: 'region',\n * processor: (entity) => {\n * return [\n * {\n * group: entity.data.region\n * }\n * ]\n * },\n * }\n * ]\n * }\n * ```\n *\n * @description\n *\n * The following configuration will create a tag named `dob` for the `user` entity sorted by `dob`.\n * You would then be able to retrieve all users sorted by `dob` by:\n * GET `/core/tag/user/dob?start=2000-01-01&end=2020-12-31`\n *\n * @example\n * ```ts\n * {\n * name: 'user',\n * tags: [\n * {\n * name: 'dob',\n * processor: (entity) => {\n * return [\n * {\n * sortValue: entity.data.dob\n * }\n * ]\n * },\n * }\n * ]\n * }\n * ```\n */\n tags?: {\n name: string;\n processor: (entity: { entityId: string; entityType: string; data: Record<string, any>; createdAt: string; updatedAt: string }) => {\n group?: string;\n sortValue?: string;\n }[];\n }[];\n\n /**\n * @description (Optional) Constraints for `adjustEntity` operations.\n * When adjusting numeric fields, these constraints are enforced at the database level.\n * If an adjustment would violate a constraint, the operation is rejected.\n *\n * @deprecated Use `conditions` instead. Will be removed in a future version.\n *\n * @example\n * ```ts\n * {\n * adjustmentConstraints: {\n * // Static: same for all entities of this type\n * balance: { min: 0 },\n * credits: { min: 0, max: 10000 },\n *\n * // Dynamic: reads constraint value from entity's own data\n * balance: { minField: 'minBalance' },\n * credits: { min: 0, maxField: 'creditLimit' },\n * }\n * }\n * ```\n */\n adjustmentConstraints?: {\n [fieldName: string]: {\n /** Static minimum value */\n min?: number;\n /** Static maximum value */\n max?: number;\n /** Field name on the entity whose value is used as the minimum (must be a numeric field) */\n minField?: keyof {\n [K in keyof B as B[K] extends z.ZodNumber | z.ZodOptional<z.ZodNumber> ? K : never]: K;\n } extends never ? string : keyof {\n [K in keyof B as B[K] extends z.ZodNumber | z.ZodOptional<z.ZodNumber> ? K : never]: K;\n };\n /** Field name on the entity whose value is used as the maximum (must be a numeric field) */\n maxField?: keyof {\n [K in keyof B as B[K] extends z.ZodNumber | z.ZodOptional<z.ZodNumber> ? K : never]: K;\n } extends never ? string : keyof {\n [K in keyof B as B[K] extends z.ZodNumber | z.ZodOptional<z.ZodNumber> ? K : never]: K;\n };\n };\n };\n\n /**\n * @description Named conditions for adjustEntity operations.\n * Each condition is either a static `WhereConditions` object or a function\n * `(data, adjustments) => WhereConditions` that receives the entity's current data\n * and the adjustment deltas.\n *\n * When defined, `$condition` is **required** in the adjustEntity request body.\n * The client sends a condition name (string), the server resolves it to a\n * DynamoDB ConditionExpression.\n *\n * @example\n * ```ts\n * {\n * adjustmentConditions: {\n * withdraw: (data, adjustments) => ({\n * balance: { $gte: (data.minBalance ?? 0) + Math.abs(adjustments?.balance ?? 0) },\n * }),\n * deposit: (data, adjustments) => ({\n * balance: { $lte: 1000000 - (adjustments.balance ?? 0) },\n * }),\n * }\n * }\n * ```\n */\n adjustmentConditions?: {\n [conditionName: string]:\n | WhereConditions\n | ((\n data: Partial<z.infer<z.ZodObject<B>>>,\n adjustments: Record<string, number>,\n ) => WhereConditions);\n };\n\n /**\n * @description Named conditions for updateEntity operations.\n * Each condition is either a static `WhereConditions` object or a function\n * `(data) => WhereConditions` that receives the entity's current data.\n *\n * `$condition` is always **optional** for updateEntity.\n * The client sends a condition name (string), the server resolves it to a\n * DynamoDB ConditionExpression. Replaces raw `$where` (deprecated).\n *\n * @example\n * ```ts\n * {\n * updateConditions: {\n * publish: { status: { $eq: 'draft' } },\n * archive: (data) => ({ status: { $ne: 'archived' } }),\n * }\n * }\n * ```\n */\n updateConditions?: {\n [conditionName: string]:\n | WhereConditions\n | ((data: Partial<z.infer<z.ZodObject<B>>>) => WhereConditions);\n };\n}\n","import type { Entity, MonoriseEntityConfig, MutualConfig } from '../types/monorise.type';\nimport { z } from 'zod';\n\nfunction makeSchema<\n T extends Entity,\n B extends z.ZodRawShape,\n C extends z.ZodRawShape,\n M extends z.ZodRawShape,\n CO extends z.ZodObject<C> | undefined = undefined,\n MO extends z.ZodObject<M> | undefined = undefined,\n>(config: MonoriseEntityConfig<T, B, C, M, CO, MO>) {\n const { baseSchema, createSchema, mutual, effect } = config;\n const { mutualSchema } = mutual || {};\n\n type FinalSchemaType = CO extends z.AnyZodObject\n ? MO extends z.AnyZodObject\n ? z.ZodObject<B & CO['shape'] & MO['shape']>\n : z.ZodObject<B & CO['shape']>\n : MO extends z.AnyZodObject\n ? z.ZodObject<B & MO['shape']>\n : z.ZodObject<B>;\n\n const finalSchema = z.object({\n ...baseSchema.shape,\n ...createSchema?.shape,\n ...mutualSchema?.shape,\n }) as FinalSchemaType;\n\n if (effect) {\n return effect(finalSchema) as z.ZodEffects<FinalSchemaType>;\n }\n\n return finalSchema;\n}\n\nconst createEntityConfig = <\n T extends Entity,\n B extends z.ZodRawShape,\n C extends z.ZodRawShape,\n M extends z.ZodRawShape,\n CO extends z.ZodObject<C> | undefined = undefined,\n MO extends z.ZodObject<M> | undefined = undefined,\n>(\n config: MonoriseEntityConfig<T, B, C, M, CO, MO>,\n) => ({\n ...config,\n finalSchema: makeSchema(config),\n});\n\nconst createMutualConfig = <MD extends z.ZodRawShape>(\n config: MutualConfig<MD>,\n) => config;\n\nexport { createEntityConfig, createMutualConfig };\n","import type { Entity as EntityType, EntitySchemaMap } from '@monorise/base';\nimport type {\n TransactionAdjustEntity,\n TransactionCreateEntity,\n TransactionDeleteEntity,\n TransactionOperation,\n TransactionUpdateEntity,\n} from './types/transaction.type';\n\nexport const transactional = {\n createEntity: <T extends EntityType>(\n entityType: T,\n payload: EntitySchemaMap[T] & { entityId?: string },\n ): TransactionCreateEntity<T> => {\n const { entityId, ...rest } = payload as EntitySchemaMap[T] & {\n entityId?: string;\n };\n return {\n operation: 'createEntity',\n entityType,\n payload: rest as EntitySchemaMap[T],\n ...(entityId && { entityId }),\n };\n },\n\n updateEntity: <T extends EntityType>(\n entityType: T,\n entityId: string,\n payload: Partial<EntitySchemaMap[T]> & { $condition?: string },\n ): TransactionUpdateEntity<T> => {\n const { $condition, ...rest } = payload as Partial<EntitySchemaMap[T]> & {\n $condition?: string;\n };\n return {\n operation: 'updateEntity',\n entityType,\n entityId,\n payload: rest as Partial<EntitySchemaMap[T]>,\n ...($condition && { condition: $condition }),\n };\n },\n\n adjustEntity: <T extends EntityType>(\n entityType: T,\n entityId: string,\n adjustments: Record<string, number> & { $condition?: string },\n ): TransactionAdjustEntity<T> => {\n const { $condition, ...rest } = adjustments;\n return {\n operation: 'adjustEntity',\n entityType,\n entityId,\n adjustments: rest,\n ...($condition && { condition: $condition }),\n };\n },\n\n deleteEntity: <T extends EntityType>(\n entityType: T,\n entityId: string,\n ): TransactionDeleteEntity<T> => ({\n operation: 'deleteEntity',\n entityType,\n entityId,\n }),\n};\n\nexport type { TransactionOperation };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAK,SAAL,kBAAKA,YAAL;AAAK,SAAAA;AAAA,GAAA;;;ACFZ,SAAS,SAAS;AAElB,SAAS,WAOP,QAAkD;AAClD,QAAM,EAAE,YAAY,cAAc,QAAQ,OAAO,IAAI;AACrD,QAAM,EAAE,aAAa,IAAI,UAAU,CAAC;AAUpC,QAAM,cAAc,EAAE,OAAO,iDACxB,WAAW,QACX,6CAAc,QACd,6CAAc,MAClB;AAED,MAAI,QAAQ;AACV,WAAO,OAAO,WAAW;AAAA,EAC3B;AAEA,SAAO;AACT;AAEA,IAAM,qBAAqB,CAQzB,WACI,iCACD,SADC;AAAA,EAEJ,aAAa,WAAW,MAAM;AAChC;AAEA,IAAM,qBAAqB,CACzB,WACG;;;AC1CE,IAAM,gBAAgB;AAAA,EAC3B,cAAc,CACZ,YACA,YAC+B;AAC/B,UAA8B,cAAtB,WAdZ,IAckC,IAAT,iBAAS,IAAT,CAAb;AAGR,WAAO;AAAA,MACL,WAAW;AAAA,MACX;AAAA,MACA,SAAS;AAAA,OACL,YAAY,EAAE,SAAS;AAAA,EAE/B;AAAA,EAEA,cAAc,CACZ,YACA,UACA,YAC+B;AAC/B,UAAgC,cAAxB,aA9BZ,IA8BoC,IAAT,iBAAS,IAAT,CAAf;AAGR,WAAO;AAAA,MACL,WAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA,SAAS;AAAA,OACL,cAAc,EAAE,WAAW,WAAW;AAAA,EAE9C;AAAA,EAEA,cAAc,CACZ,YACA,UACA,gBAC+B;AAC/B,UAAgC,kBAAxB,aA/CZ,IA+CoC,IAAT,iBAAS,IAAT,CAAf;AACR,WAAO;AAAA,MACL,WAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA,aAAa;AAAA,OACT,cAAc,EAAE,WAAW,WAAW;AAAA,EAE9C;AAAA,EAEA,cAAc,CACZ,YACA,cACgC;AAAA,IAChC,WAAW;AAAA,IACX;AAAA,IACA;AAAA,EACF;AACF;","names":["Entity"]}
package/dist/cli/cli.js CHANGED
@@ -97,7 +97,7 @@ declare module '${moduleName}' {
97
97
  ${schemaMapEntries.join("\n ")}
98
98
  }
99
99
  }`;
100
- const moduleAugmentations = usesCombinedPackage ? augmentationBlock("monorise/base") : augmentationBlock("@monorise/base");
100
+ const moduleAugmentations = usesCombinedPackage ? augmentationBlock("monorise/base") : augmentationBlock("../base/index.js");
101
101
  const configOutputContent = `
102
102
  import type { z } from 'zod';
103
103
  ${imports.join("\n")}
@@ -188,7 +188,7 @@ async function generateHandleFile(monoriseConfig, projectRoot, monoriseOutputDir
188
188
  appHandlerPayload = "{ routes }";
189
189
  }
190
190
  const usesCombinedPackage = detectCombinedPackage(projectRoot);
191
- const coreImportPath = usesCombinedPackage ? "monorise/core" : "@monorise/core";
191
+ const coreImportPath = usesCombinedPackage ? "monorise/core" : "../core/index.js";
192
192
  const combinedContent = `
193
193
  import CoreFactory from '${coreImportPath}';
194
194
  import config from './config';
@@ -1,4 +1,5 @@
1
- import { Entity as Entity$2, EntitySchemaMap, createEntityConfig, WhereConditions } from '../base/index';
1
+ import { Entity as Entity$2, EntitySchemaMap, createEntityConfig, WhereConditions, TransactionOperation, TransactionResult } from '../base/index';
2
+ export { transactional } from '../base/index';
2
3
  import * as hono from 'hono';
3
4
  import { Hono } from 'hono';
4
5
  import { DynamoDB, TransactWriteItemsInput, AttributeValue, TransactWriteItem, UpdateItemCommandInput } from '@aws-sdk/client-dynamodb';
@@ -4608,12 +4609,14 @@ declare class UpsertEntityController {
4608
4609
  }
4609
4610
 
4610
4611
  declare class MutualService {
4612
+ private EntityConfig;
4611
4613
  private entityRepository;
4612
4614
  private mutualRepository;
4613
4615
  private publishEvent;
4614
4616
  private ddbUtils;
4615
4617
  private entityServiceLifeCycle;
4616
- constructor(entityRepository: EntityRepository, mutualRepository: MutualRepository, publishEvent: typeof publishEvent, ddbUtils: DbUtils, entityServiceLifeCycle: EntityServiceLifeCycle);
4618
+ constructor(EntityConfig: Record<Entity$2, ReturnType<typeof createEntityConfig>>, entityRepository: EntityRepository, mutualRepository: MutualRepository, publishEvent: typeof publishEvent, ddbUtils: DbUtils, entityServiceLifeCycle: EntityServiceLifeCycle);
4619
+ private getMutualDataSchema;
4617
4620
  createMutual: <B extends Entity$2, T extends Entity$2, A extends Entity$2>({ byEntityType, byEntityId, entityType, entityId, mutualPayload, accountId, options, }: {
4618
4621
  byEntityType: B;
4619
4622
  byEntityId: string;
@@ -4632,13 +4635,17 @@ declare class MutualService {
4632
4635
  ExpressionAttributeValues?: Record<string, AttributeValue>;
4633
4636
  };
4634
4637
  }) => Promise<{
4635
- mutual: Mutual<B, T, Record<string, any>>;
4638
+ mutual: Mutual<B, T, {
4639
+ [x: string]: any;
4640
+ }>;
4636
4641
  eventPayload: {
4637
4642
  byEntityType: B;
4638
4643
  byEntityId: string;
4639
4644
  entityType: T;
4640
4645
  entityId: string;
4641
- parsedMutualPayload: Record<string, any>;
4646
+ parsedMutualPayload: {
4647
+ [x: string]: any;
4648
+ };
4642
4649
  accountId: string | string[] | undefined;
4643
4650
  publishedAt: string;
4644
4651
  };
@@ -4718,44 +4725,6 @@ declare class ListTagsController {
4718
4725
  }, hono_utils_http_status.ContentfulStatusCode, "json">>;
4719
4726
  }
4720
4727
 
4721
- type TransactionCreateEntity<T extends Entity$2 = Entity$2> = {
4722
- operation: 'createEntity';
4723
- entityType: T;
4724
- entityId?: string;
4725
- payload: EntitySchemaMap[T];
4726
- };
4727
- type TransactionUpdateEntity<T extends Entity$2 = Entity$2> = {
4728
- operation: 'updateEntity';
4729
- entityType: T;
4730
- entityId: string;
4731
- payload: Partial<EntitySchemaMap[T]>;
4732
- accountId?: string;
4733
- condition?: string;
4734
- };
4735
- type TransactionAdjustEntity<T extends Entity$2 = Entity$2> = {
4736
- operation: 'adjustEntity';
4737
- entityType: T;
4738
- entityId: string;
4739
- adjustments: Record<string, number>;
4740
- accountId?: string;
4741
- condition?: string;
4742
- };
4743
- type TransactionDeleteEntity<T extends Entity$2 = Entity$2> = {
4744
- operation: 'deleteEntity';
4745
- entityType: T;
4746
- entityId: string;
4747
- };
4748
- type TransactionOperation = TransactionCreateEntity | TransactionUpdateEntity | TransactionAdjustEntity | TransactionDeleteEntity;
4749
- type TransactionResultEntry = {
4750
- operation: string;
4751
- entityType: Entity$2;
4752
- entityId: string;
4753
- data?: Record<string, unknown>;
4754
- };
4755
- type TransactionResult = {
4756
- results: TransactionResultEntry[];
4757
- };
4758
-
4759
4728
  declare class TransactionService {
4760
4729
  private EntityConfig;
4761
4730
  private EmailAuthEnabledEntities;
@@ -4937,19 +4906,6 @@ declare const $default: (container: DependencyContainer) => (event: APIGatewayPr
4937
4906
  */
4938
4907
  declare const broadcast: (container: DependencyContainer) => (event: DynamoDBStreamEvent) => Promise<void>;
4939
4908
 
4940
- declare const transactional: {
4941
- createEntity: <T extends Entity$2>(entityType: T, payload: EntitySchemaMap[T] & {
4942
- entityId?: string;
4943
- }) => TransactionCreateEntity<T>;
4944
- updateEntity: <T extends Entity$2>(entityType: T, entityId: string, payload: Partial<EntitySchemaMap[T]> & {
4945
- $condition?: string;
4946
- }) => TransactionUpdateEntity<T>;
4947
- adjustEntity: <T extends Entity$2>(entityType: T, entityId: string, adjustments: Record<string, number> & {
4948
- $condition?: string;
4949
- }) => TransactionAdjustEntity<T>;
4950
- deleteEntity: <T extends Entity$2>(entityType: T, entityId: string) => TransactionDeleteEntity<T>;
4951
- };
4952
-
4953
4909
  declare class CoreFactory {
4954
4910
  private config;
4955
4911
  setupCommonRoutes: ReturnType<typeof setupCommonRoutes>;
@@ -4971,4 +4927,4 @@ declare class CoreFactory {
4971
4927
  });
4972
4928
  }
4973
4929
 
4974
- export { DependencyContainer, Entity$1 as Entity, EntityRepository, EntityService, Mutual, MutualRepository, MutualService, PROJECTION_EXPRESSION, StandardError, StandardErrorCode, TagRepository, TransactionService, WebSocketRepository, appHandler, handler$4 as createEntityProcessor, CoreFactory as default, handler$3 as mutualProcessor, handler$2 as prejoinProcessor, handler$1 as replicationProcessor, setupCommonRoutes, handler as tagProcessor, transactional, broadcast as wsBroadcast, connect as wsConnect, $default as wsDefault, disconnect as wsDisconnect };
4930
+ export { DependencyContainer, Entity$1 as Entity, EntityRepository, EntityService, Mutual, MutualRepository, MutualService, PROJECTION_EXPRESSION, StandardError, StandardErrorCode, TagRepository, TransactionService, WebSocketRepository, appHandler, handler$4 as createEntityProcessor, CoreFactory as default, handler$3 as mutualProcessor, handler$2 as prejoinProcessor, handler$1 as replicationProcessor, setupCommonRoutes, handler as tagProcessor, broadcast as wsBroadcast, connect as wsConnect, $default as wsDefault, disconnect as wsDisconnect };