@monorise/base 4.6.0 → 4.7.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 CHANGED
@@ -15,7 +15,7 @@ import { z } from 'zod';
15
15
  declare function resolveEffectiveMutualSchema<M extends z.AnyZodObject | undefined>(mutualSchema: M, createMutualSchema?: z.AnyZodObject): M extends z.AnyZodObject ? z.AnyZodObject : z.AnyZodObject | undefined;
16
16
  declare const createEntityConfig: <T extends Entity, B extends z.ZodRawShape, C extends z.ZodRawShape, M extends z.ZodRawShape, CO extends z.ZodObject<C> | undefined = undefined, MO extends z.ZodObject<M> | undefined = undefined, CMO extends z.AnyZodObject | undefined = undefined>(config: MonoriseEntityConfig<T, B, C, M, CO, MO, CMO>) => {
17
17
  effectiveMutualSchema: z.AnyZodObject | (MO extends z.AnyZodObject ? z.AnyZodObject : z.AnyZodObject | undefined) | undefined;
18
- finalSchema: (CO extends z.AnyZodObject ? MO extends z.AnyZodObject ? z.ZodObject<MO["shape"] & CO["shape"], z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<MO["shape"] & CO["shape"]>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<MO["shape"] & CO["shape"]> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never> : CO : MO extends z.AnyZodObject ? z.ZodObject<MO["shape"] & B, z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<MO["shape"] & B>, any> extends infer T_3 ? { [k_2 in keyof T_3]: T_3[k_2]; } : never, z.baseObjectInputType<MO["shape"] & B> extends infer T_4 ? { [k_3 in keyof T_4]: T_4[k_3]; } : never> : z.ZodObject<B, z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B>, any> extends infer T_5 ? { [k_4 in keyof T_5]: T_5[k_4]; } : never, z.baseObjectInputType<B> extends infer T_6 ? { [k_5 in keyof T_6]: T_6[k_5]; } : never>) | z.ZodEffects<CO extends z.AnyZodObject ? MO extends z.AnyZodObject ? z.ZodObject<MO["shape"] & CO["shape"], z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<MO["shape"] & CO["shape"]>, any> extends infer T_7 ? { [k in keyof T_7]: T_7[k]; } : never, z.baseObjectInputType<MO["shape"] & CO["shape"]> extends infer T_8 ? { [k_1 in keyof T_8]: T_8[k_1]; } : never> : CO : MO extends z.AnyZodObject ? z.ZodObject<MO["shape"] & B, z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<MO["shape"] & B>, any> extends infer T_9 ? { [k_2 in keyof T_9]: T_9[k_2]; } : never, z.baseObjectInputType<MO["shape"] & B> extends infer T_10 ? { [k_3 in keyof T_10]: T_10[k_3]; } : never> : z.ZodObject<B, z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B>, any> extends infer T_11 ? { [k_4 in keyof T_11]: T_11[k_4]; } : never, z.baseObjectInputType<B> extends infer T_12 ? { [k_5 in keyof T_12]: T_12[k_5]; } : never>, z.output<CO extends z.AnyZodObject ? MO extends z.AnyZodObject ? z.ZodObject<MO["shape"] & CO["shape"], z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<MO["shape"] & CO["shape"]>, any> extends infer T_13 ? { [k in keyof T_13]: T_13[k]; } : never, z.baseObjectInputType<MO["shape"] & CO["shape"]> extends infer T_14 ? { [k_1 in keyof T_14]: T_14[k_1]; } : never> : CO : MO extends z.AnyZodObject ? z.ZodObject<MO["shape"] & B, z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<MO["shape"] & B>, any> extends infer T_15 ? { [k_2 in keyof T_15]: T_15[k_2]; } : never, z.baseObjectInputType<MO["shape"] & B> extends infer T_16 ? { [k_3 in keyof T_16]: T_16[k_3]; } : never> : z.ZodObject<B, z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B>, any> extends infer T_17 ? { [k_4 in keyof T_17]: T_17[k_4]; } : never, z.baseObjectInputType<B> extends infer T_18 ? { [k_5 in keyof T_18]: T_18[k_5]; } : never>>, z.input<CO extends z.AnyZodObject ? MO extends z.AnyZodObject ? z.ZodObject<MO["shape"] & CO["shape"], z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<MO["shape"] & CO["shape"]>, any> extends infer T_19 ? { [k in keyof T_19]: T_19[k]; } : never, z.baseObjectInputType<MO["shape"] & CO["shape"]> extends infer T_20 ? { [k_1 in keyof T_20]: T_20[k_1]; } : never> : CO : MO extends z.AnyZodObject ? z.ZodObject<MO["shape"] & B, z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<MO["shape"] & B>, any> extends infer T_21 ? { [k_2 in keyof T_21]: T_21[k_2]; } : never, z.baseObjectInputType<MO["shape"] & B> extends infer T_22 ? { [k_3 in keyof T_22]: T_22[k_3]; } : never> : z.ZodObject<B, z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B>, any> extends infer T_23 ? { [k_4 in keyof T_23]: T_23[k_4]; } : never, z.baseObjectInputType<B> extends infer T_24 ? { [k_5 in keyof T_24]: T_24[k_5]; } : never>>>;
18
+ finalSchema: (CO extends z.AnyZodObject ? MO extends z.AnyZodObject ? z.ZodObject<B & CO["shape"] & MO["shape"], z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B & CO["shape"] & MO["shape"]>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<B & CO["shape"] & MO["shape"]> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never> : z.ZodObject<B & CO["shape"], z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B & CO["shape"]>, any> extends infer T_3 ? { [k_2 in keyof T_3]: T_3[k_2]; } : never, z.baseObjectInputType<B & CO["shape"]> extends infer T_4 ? { [k_3 in keyof T_4]: T_4[k_3]; } : never> : MO extends z.AnyZodObject ? z.ZodObject<B & MO["shape"], z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B & MO["shape"]>, any> extends infer T_5 ? { [k_4 in keyof T_5]: T_5[k_4]; } : never, z.baseObjectInputType<B & MO["shape"]> extends infer T_6 ? { [k_5 in keyof T_6]: T_6[k_5]; } : never> : z.ZodObject<B, z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B>, any> extends infer T_7 ? { [k_6 in keyof T_7]: T_7[k_6]; } : never, z.baseObjectInputType<B> extends infer T_8 ? { [k_7 in keyof T_8]: T_8[k_7]; } : never>) | z.ZodEffects<CO extends z.AnyZodObject ? MO extends z.AnyZodObject ? z.ZodObject<B & CO["shape"] & MO["shape"], z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B & CO["shape"] & MO["shape"]>, any> extends infer T_9 ? { [k in keyof T_9]: T_9[k]; } : never, z.baseObjectInputType<B & CO["shape"] & MO["shape"]> extends infer T_10 ? { [k_1 in keyof T_10]: T_10[k_1]; } : never> : z.ZodObject<B & CO["shape"], z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B & CO["shape"]>, any> extends infer T_11 ? { [k_2 in keyof T_11]: T_11[k_2]; } : never, z.baseObjectInputType<B & CO["shape"]> extends infer T_12 ? { [k_3 in keyof T_12]: T_12[k_3]; } : never> : MO extends z.AnyZodObject ? z.ZodObject<B & MO["shape"], z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B & MO["shape"]>, any> extends infer T_13 ? { [k_4 in keyof T_13]: T_13[k_4]; } : never, z.baseObjectInputType<B & MO["shape"]> extends infer T_14 ? { [k_5 in keyof T_14]: T_14[k_5]; } : never> : z.ZodObject<B, z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B>, any> extends infer T_15 ? { [k_6 in keyof T_15]: T_15[k_6]; } : never, z.baseObjectInputType<B> extends infer T_16 ? { [k_7 in keyof T_16]: T_16[k_7]; } : never>, z.output<CO extends z.AnyZodObject ? MO extends z.AnyZodObject ? z.ZodObject<B & CO["shape"] & MO["shape"], z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B & CO["shape"] & MO["shape"]>, any> extends infer T_17 ? { [k in keyof T_17]: T_17[k]; } : never, z.baseObjectInputType<B & CO["shape"] & MO["shape"]> extends infer T_18 ? { [k_1 in keyof T_18]: T_18[k_1]; } : never> : z.ZodObject<B & CO["shape"], z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B & CO["shape"]>, any> extends infer T_19 ? { [k_2 in keyof T_19]: T_19[k_2]; } : never, z.baseObjectInputType<B & CO["shape"]> extends infer T_20 ? { [k_3 in keyof T_20]: T_20[k_3]; } : never> : MO extends z.AnyZodObject ? z.ZodObject<B & MO["shape"], z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B & MO["shape"]>, any> extends infer T_21 ? { [k_4 in keyof T_21]: T_21[k_4]; } : never, z.baseObjectInputType<B & MO["shape"]> extends infer T_22 ? { [k_5 in keyof T_22]: T_22[k_5]; } : never> : z.ZodObject<B, z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B>, any> extends infer T_23 ? { [k_6 in keyof T_23]: T_23[k_6]; } : never, z.baseObjectInputType<B> extends infer T_24 ? { [k_7 in keyof T_24]: T_24[k_7]; } : never>>, z.input<CO extends z.AnyZodObject ? MO extends z.AnyZodObject ? z.ZodObject<B & CO["shape"] & MO["shape"], z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B & CO["shape"] & MO["shape"]>, any> extends infer T_25 ? { [k in keyof T_25]: T_25[k]; } : never, z.baseObjectInputType<B & CO["shape"] & MO["shape"]> extends infer T_26 ? { [k_1 in keyof T_26]: T_26[k_1]; } : never> : z.ZodObject<B & CO["shape"], z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B & CO["shape"]>, any> extends infer T_27 ? { [k_2 in keyof T_27]: T_27[k_2]; } : never, z.baseObjectInputType<B & CO["shape"]> extends infer T_28 ? { [k_3 in keyof T_28]: T_28[k_3]; } : never> : MO extends z.AnyZodObject ? z.ZodObject<B & MO["shape"], z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B & MO["shape"]>, any> extends infer T_29 ? { [k_4 in keyof T_29]: T_29[k_4]; } : never, z.baseObjectInputType<B & MO["shape"]> extends infer T_30 ? { [k_5 in keyof T_30]: T_30[k_5]; } : never> : z.ZodObject<B, z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B>, any> extends infer T_31 ? { [k_6 in keyof T_31]: T_31[k_6]; } : never, z.baseObjectInputType<B> extends infer T_32 ? { [k_7 in keyof T_32]: T_32[k_7]; } : never>>>;
19
19
  name: string | T;
20
20
  displayName: string;
21
21
  authMethod?: {
@@ -23,7 +23,7 @@ declare const createEntityConfig: <T extends Entity, B extends z.ZodRawShape, C
23
23
  tokenExpiresIn: number;
24
24
  };
25
25
  };
26
- baseSchema: z.ZodObject<B, z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B>, any> extends infer T_25 ? { [k_4 in keyof T_25]: T_25[k_4]; } : never, z.baseObjectInputType<B> extends infer T_26 ? { [k_5 in keyof T_26]: T_26[k_5]; } : never>;
26
+ baseSchema: z.ZodObject<B, z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B>, any> extends infer T_33 ? { [k_6 in keyof T_33]: T_33[k_6]; } : never, z.baseObjectInputType<B> extends infer T_34 ? { [k_7 in keyof T_34]: T_34[k_7]; } : never>;
27
27
  createSchema?: CO | undefined;
28
28
  searchableFields?: (keyof B)[] | undefined;
29
29
  uniqueFields?: (keyof B)[] | undefined;
@@ -83,10 +83,10 @@ declare const createEntityConfig: <T extends Entity, B extends z.ZodRawShape, C
83
83
  };
84
84
  } | undefined;
85
85
  adjustmentConditions?: {
86
- [conditionName: string]: undefined | ((data: Partial<z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B>, any> extends infer T_27 ? { [k_4 in keyof T_27]: T_27[k_4]; } : never>, adjustments: Record<string, number>) => undefined);
86
+ [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>, adjustments: Record<string, number>) => undefined);
87
87
  } | undefined;
88
88
  updateConditions?: {
89
- [conditionName: string]: undefined | ((data: Partial<z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B>, any> extends infer T_27 ? { [k_4 in keyof T_27]: T_27[k_4]; } : never>) => undefined);
89
+ [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);
90
90
  } | undefined;
91
91
  allowLegacyWhere?: boolean;
92
92
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../types/monorise.type.ts","../utils/index.ts"],"sourcesContent":["import type { z } from 'zod';\nimport type { createEntityConfig } from '../utils';\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 */\n/**\n * @description The shape `createMutualConfig(...)` is CALLED with — looser than the resolved\n * `MutualConfig` it returns. `mutualDataSchema` is optional here (and mutually exclusive with\n * `asEntity`) because `createMutualConfig` resolves it before returning: every OTHER consumer in\n * this codebase (`mutualFields[key].mutual`, `MutualService`, the processors) reads the resolved\n * `MutualConfig` type below, where `mutualDataSchema` stays REQUIRED — the same \"loose input,\n * strict resolved output\" split `createEntityConfig`/`MonoriseEntityConfig` already use for\n * `finalSchema`/`effectiveMutualSchema`. Import this type only if you're writing something that\n * itself calls `createMutualConfig`; every other call site should keep using `MutualConfig`.\n */\nexport interface MutualConfigInput<MD extends z.ZodRawShape = z.ZodRawShape> {\n /**\n * Stable analytics dataset name. When provided, it must be lower-kebab-case;\n * the generator validates this so unnamed mutuals remain backwards compatible.\n */\n name?: string;\n entities: [Entity, Entity];\n /** Required unless `asEntity` is set — see `asEntity`'s own doc comment. */\n mutualDataSchema?: z.ZodObject<MD>;\n\n /**\n * @description (Optional) Materialize this mutual relationship as a real,\n * independently-queryable `Entity` whenever it's created — whether imperatively via\n * `MutualService.createMutual` or automatically via a declarative `mutualFields` entry that\n * references this config — by passing the `createEntityConfig(...)` return value for the\n * entity type it should materialize as.\n *\n * When set, in addition to the mutual edge, a real `Entity` is created:\n * `entityType = asEntity.name`, `entityId = <the mutual's own generated ulid>`,\n * `data = <the mutual's own parsed mutualData>`. This lets the relationship be looked up via\n * monorise's `tags` mechanism (an indexed GSI lookup) instead of scanning and filtering every\n * edge in application code, and lets the synthetic entity carry its own `mutualFields`.\n *\n * `mutualDataSchema` must be OMITTED when `asEntity` is set: it's derived automatically from\n * `asEntity.finalSchema` (that entity's own `baseSchema` + `createSchema` +\n * `effectiveMutualSchema`, merged — the same schema this codebase already validates every\n * normal `createEntity` payload against). Chosen over a narrower `baseSchema`/`createSchema`\n * derivation because `MutualService.createMutual`'s `asEntity` path fires\n * `afterCreateEntityHook` on the synthetic entity — the same hook that wires up an entity's\n * OWN further `mutualFields` — so anything narrower than `finalSchema` would silently break\n * that wiring for any `asEntity`-targeted entity that itself declares further relationships.\n * Providing both `asEntity` and `mutualDataSchema` is a build-time AND runtime error.\n *\n * The synthetic entity is always created SYNCHRONOUSLY, in the same DynamoDB transaction as\n * the mutual write, with its `afterCreateEntityHook` (tags/mutualFields wiring) firing\n * immediately after the commit. There is no asynchronous mode: the entity either exists the\n * moment the mutual does, or neither is written. That costs a `TransactWriteItems` (2x WCU\n * versus a plain write) but leaves no window in which the mutual exists and its projection\n * does not.\n *\n * An explicit `options.asEntity` passed directly at an imperative `createMutual(...)` call\n * site always overrides this config-level value — see `resolveAsEntity` in `@monorise/core`'s\n * `mutual.service`.\n *\n * @example\n * ```ts\n * const enrollmentMutual = createMutualConfig({\n * entities: [Entity.STUDENT, Entity.COURSE],\n * asEntity: enrollmentEntityConfig, // the createEntityConfig(...) result for Entity.ENROLLMENT\n * });\n * ```\n */\n asEntity?: ReturnType<typeof createEntityConfig>;\n}\n\n/**\n * @description The resolved shape `createMutualConfig(...)` RETURNS, and what every other\n * consumer in this codebase (`mutualFields[key].mutual`, `MutualService`, the mutual processor)\n * actually references. Unlike `MutualConfigInput`, `mutualDataSchema` is REQUIRED here — by the\n * time a `MutualConfig` object exists, `createMutualConfig` has already derived it from\n * `asEntity.finalSchema` when needed, so every existing `.mutualDataSchema` read across this\n * codebase keeps its original, always-defined guarantee regardless of whether the mutual uses\n * `asEntity` or not.\n */\nexport interface MutualConfig<MD extends z.ZodRawShape = z.ZodRawShape>\n extends Omit<MutualConfigInput<MD>, 'mutualDataSchema'> {\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 CMO extends z.AnyZodObject | 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 * Used to validate mutual fields on create, and — derived to a partial — on update. You do NOT need to author this `.partial()`: the SDK partials it for the update path, so an update that doesn't touch every mutual relationship stays valid regardless of how this is declared.\n */\n mutualSchema: MO;\n\n /**\n * @description (Optional) Stricter schema applied ONLY when the entity is created — falls back to `mutualSchema` if not provided, so existing configs are unaffected. When provided, its shape is merged over `mutualSchema` for create; fields only `mutualSchema` declares (and `createMutualSchema` doesn't mention) are still validated and wired, not dropped.\n *\n * Use this when a mutual relationship must always be wired at creation time (e.g. every Competition must have an owning Organisation from the start). It does not affect updates either way — the update path derives a partial from `mutualSchema` itself, so a required-at-create relationship never has to be resent on an unrelated patch.\n *\n * Without this, a create silently succeeds even if a required mutual link is omitted from the payload — the entity is created but never gets wired to the relationship, with no error anywhere.\n *\n * Note: this only strengthens the *runtime* validation on create — `EntitySchemaMap` (the type callers see back from a read, generated from `finalSchema`) stays `MO`-shaped regardless, since mutual fields are never stored and a read can never actually return one. Don't expect a `createMutualSchema`-required field to show up as required in generated read types.\n *\n * The same-named `PUT /entity/:type/:id` upsert endpoint applies this schema only when the entity doesn't already exist — the same call is strict or lenient purely depending on whether that ID was already there.\n *\n * @example\n * ```ts\n * const mutualSchema = z.object({ organisationIds: z.string().array() }).partial();\n * const createMutualSchema = z.object({ organisationIds: z.string().array() }); // required on create\n * ```\n */\n createMutualSchema?: CMO;\n // Deliberately typed via its own `CMO` generic rather than `MO` — the\n // whole point is that it's allowed to be a DIFFERENT (stricter) shape\n // than `mutualSchema`, e.g. built via `mutualSchema.required({ field:\n // true })`, which is a structurally different ZodObject type, not `MO`\n // itself. Only the runtime merge (`resolveEffectiveMutualSchema` /\n // `effectiveMutualSchema`, see `packages/base/utils`) combines `MO` and\n // `CMO` — `finalSchema`'s TYPE deliberately stays `MO`-based; see the\n // note above and `makeSchema`'s own comment for why.\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: {\n entityId: string;\n entityType: string;\n data: Record<string, any>;\n createdAt: string;\n updatedAt: string;\n }) => {\n group?: string;\n sortValue?: string;\n }[];\n }[];\n\n /**\n * @description (Optional) Configure a DynamoDB TTL for this entity. When set, `expiresAt`\n * is computed via `processor` on create, and recomputed on every update/upsert. Once past,\n * DynamoDB automatically deletes the item (and its derived index rows, since they all carry\n * the same `expiresAt`).\n *\n * `processor` returning `undefined` means \"no TTL\" for that record. On updates, an `undefined`\n * result leaves any existing `expiresAt` untouched rather than clearing it.\n *\n * @example\n * ```ts\n * // fixed 30-day TTL from creation/each update\n * ttl: {\n * processor: () => Math.floor(Date.now() / 1000) + 30 * 24 * 60 * 60,\n * }\n * ```\n *\n * @example\n * ```ts\n * // data-driven TTL, eg. expire when a subscription ends\n * ttl: {\n * processor: (entity) => {\n * return entity.data.subscriptionEndsAt\n * ? new Date(entity.data.subscriptionEndsAt)\n * : undefined;\n * },\n * }\n * ```\n */\n ttl?: {\n /**\n * @description Returns the expiry as epoch seconds (absolute) or a `Date`.\n * Return `undefined` for no expiry.\n */\n processor: (entity: {\n entityId: string;\n entityType: string;\n data: Record<string, any>;\n createdAt: string;\n updatedAt: string;\n }) => number | Date | undefined;\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>\n ? K\n : never]: K;\n } extends never\n ? string\n : keyof {\n [K in keyof B as B[K] extends\n | z.ZodNumber\n | z.ZodOptional<z.ZodNumber>\n ? K\n : 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>\n ? K\n : never]: K;\n } extends never\n ? string\n : keyof {\n [K in keyof B as B[K] extends\n | z.ZodNumber\n | z.ZodOptional<z.ZodNumber>\n ? K\n : 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 /**\n * @description (Optional) Opt in to accepting legacy raw `$where` on updateEntity.\n * Disabled by default: raw DynamoDB condition operators must never be\n * client-facing — an authenticated client could otherwise probe field\n * existence or guess values via the 200-vs-409 response status.\n *\n * Only enable this if you trust the caller (e.g. server-to-server) or have\n * your own validation in front of it. Prefer `updateConditions` instead.\n *\n * @default false\n */\n allowLegacyWhere?: boolean;\n}\n","import { z } from 'zod';\nimport type {\n Entity,\n MonoriseEntityConfig,\n MutualConfig,\n MutualConfigInput,\n} from '../types/monorise.type';\n\n/**\n * @description Merges `mutualSchema` and `createMutualSchema` into the schema\n * actually used to validate a create payload. A plain `createMutualSchema ||\n * mutualSchema` fallback would DROP any mutual field that's declared on\n * `mutualSchema` but omitted from `createMutualSchema` (e.g. a\n * `createMutualSchema` authored to cover only the newly-required field,\n * without repeating every other optional mutual field) — `.parse()` strips\n * unknown keys, so that field's wiring would silently never fire even when\n * the caller supplied it. Merging shapes (with `createMutualSchema`'s keys\n * taking precedence on overlap, since it's the stricter one) keeps every\n * mutual field in play while still enforcing the create-only requirement.\n */\nfunction resolveEffectiveMutualSchema<M extends z.AnyZodObject | undefined>(\n mutualSchema: M,\n createMutualSchema?: z.AnyZodObject,\n): M extends z.AnyZodObject ? z.AnyZodObject : z.AnyZodObject | undefined {\n if (!createMutualSchema) return mutualSchema as any;\n if (!mutualSchema) return createMutualSchema as any;\n\n return mutualSchema.merge(createMutualSchema) as any;\n}\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 CMO extends z.AnyZodObject | undefined = undefined,\n>(\n config: MonoriseEntityConfig<T, B, C, M, CO, MO, CMO>,\n effectiveMutualSchema: z.AnyZodObject | undefined,\n) {\n const { baseSchema, createSchema, effect } = config;\n\n // Deliberately NOT `MO & CMO`-typed: finalSchema.parse() runs against\n // effectiveMutualSchema's real runtime shape (below), but EntitySchemaMap\n // — the type callers see back from a *read* — is generated from this\n // same FinalSchemaType (packages/cli/commands/utils/generate.ts). Mutual\n // fields are never stored, so a required createMutualSchema field must\n // stay optional here; only the create-path runtime validation is allowed\n // to be strict.\n type FinalSchemaType = CO extends z.AnyZodObject\n ? MO extends z.AnyZodObject\n ? z.ZodObject<MO['shape'] & CO['shape']>\n : CO\n : MO extends z.AnyZodObject\n ? z.ZodObject<MO['shape'] & B>\n : z.ZodObject<B>;\n\n const finalSchema = z.object({\n ...baseSchema.shape,\n ...createSchema?.shape,\n ...effectiveMutualSchema?.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 CMO extends z.AnyZodObject | undefined = undefined,\n>(\n config: MonoriseEntityConfig<T, B, C, M, CO, MO, CMO>,\n) => {\n // Computed once here (config-definition time, not per-request/per-item)\n // and reused by every create-path call site (afterCreateEntityHook,\n // TransactionService.collectCreateEvents, UpsertEntityController) instead\n // of each rebuilding the same merged ZodObject from scratch.\n const { mutualSchema, createMutualSchema } = config.mutual || {};\n const effectiveMutualSchema = resolveEffectiveMutualSchema(\n mutualSchema,\n createMutualSchema,\n );\n\n return {\n ...config,\n // Derived output, not an input on MonoriseEntityConfig — there's\n // nowhere to declare this on the config type itself. Read by name\n // across packages/core (EntityServiceLifeCycle, TransactionService,\n // UpsertEntityController); don't hand-set it on a config object built\n // outside this factory (e.g. a test fixture) — build through\n // createEntityConfig instead, or it silently falls out of sync with\n // mutual.mutualSchema/createMutualSchema.\n effectiveMutualSchema,\n finalSchema: makeSchema(config, effectiveMutualSchema),\n };\n};\n\nconst createMutualConfig = <MD extends z.ZodRawShape>(\n config: MutualConfigInput<MD>,\n): MutualConfig<MD> => {\n // Catches a specific footgun before it falls through to the generic\n // \"one of mutualDataSchema or asEntity is required\" error below: a config\n // module that does `asEntity: importedEntityConfig` where\n // `importedEntityConfig` comes from a circular import (e.g. student.ts\n // imports enrollmentEntityConfig, which itself lives in a module that\n // imports student.ts) evaluates to `undefined` at this point, not a\n // missing key — `'asEntity' in config` is true, `config.asEntity` is not.\n // The generic error below would say \"one of ... is required\", which sends\n // people looking for a typo instead of an import cycle.\n if ('asEntity' in config && config.asEntity === undefined) {\n throw new Error(\n \"createMutualConfig: 'asEntity' is undefined — likely a circular import between entity config files (the imported entity config module hasn't finished initializing yet). Restructure the imports to break the cycle.\",\n );\n }\n\n if (config.asEntity && config.mutualDataSchema) {\n throw new Error(\n \"createMutualConfig: 'asEntity' and 'mutualDataSchema' are mutually exclusive. \" +\n \"When 'asEntity' is set, mutualDataSchema is derived automatically from \" +\n \"asEntity.finalSchema — remove the explicit mutualDataSchema (or drop 'asEntity' \" +\n 'if this mutual should keep its own independently-authored schema).',\n );\n }\n\n if (!config.asEntity && !config.mutualDataSchema) {\n throw new Error(\n \"createMutualConfig: one of 'mutualDataSchema' or 'asEntity' is required.\",\n );\n }\n\n // Unchanged identity behavior when `asEntity` isn't set — existing configs are unaffected.\n // `mutualDataSchema` is guaranteed present here (checked above), so this cast just tells\n // TypeScript what the runtime guard already established.\n if (!config.asEntity) return config as MutualConfig<MD>;\n\n // `finalSchema` (not baseSchema/createSchema alone) on purpose: the declarative mutual\n // processor's `afterCreateEntityHook` call needs the full schema to correctly wire the\n // synthetic entity's own further `mutualFields` too (see mutual-processor.ts).\n //\n // This does NOT mean finalSchema-shaped data is what gets PERSISTED as this mutual's\n // `mutualData` or the synthetic entity's `data` — both `MutualService.createMutual` and\n // `mutual-processor.ts` re-derive a narrower `asEntity.createSchema ?? asEntity.baseSchema`\n // parse for anything actually written to storage, specifically so the target entity's own\n // mutual-field keys (e.g. `courseIds`, if the target entity itself declares `mutualFields`)\n // never get baked into stored data — the same \"mutual fields are never stored\" invariant\n // `makeSchema` already documents for ordinary entities. `mutualDataSchema` staying as\n // `finalSchema` is what makes the fuller shape available to whichever call site needs it for\n // hook-wiring purposes, without that fuller shape leaking into what's actually persisted.\n return {\n ...config,\n mutualDataSchema: config.asEntity.finalSchema as unknown as z.ZodObject<MD>,\n };\n};\n\nexport { createEntityConfig, createMutualConfig, resolveEffectiveMutualSchema };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAIO,IAAK,SAAL,kBAAKA,YAAL;AAAK,SAAAA;AAAA,GAAA;;;ACJZ,SAAS,SAAS;AAoBlB,SAAS,6BACP,cACA,oBACwE;AACxE,MAAI,CAAC,mBAAoB,QAAO;AAChC,MAAI,CAAC,aAAc,QAAO;AAE1B,SAAO,aAAa,MAAM,kBAAkB;AAC9C;AAEA,SAAS,WASP,QACA,uBACA;AACA,QAAM,EAAE,YAAY,cAAc,OAAO,IAAI;AAiB7C,QAAM,cAAc,EAAE,OAAO,iDACxB,WAAW,QACX,6CAAc,QACd,+DAAuB,MAC3B;AAED,MAAI,QAAQ;AACV,WAAO,OAAO,WAAW;AAAA,EAC3B;AAEA,SAAO;AACT;AAEA,IAAM,qBAAqB,CASzB,WACG;AAKH,QAAM,EAAE,cAAc,mBAAmB,IAAI,OAAO,UAAU,CAAC;AAC/D,QAAM,wBAAwB;AAAA,IAC5B;AAAA,IACA;AAAA,EACF;AAEA,SAAO,iCACF,SADE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASL;AAAA,IACA,aAAa,WAAW,QAAQ,qBAAqB;AAAA,EACvD;AACF;AAEA,IAAM,qBAAqB,CACzB,WACqB;AAUrB,MAAI,cAAc,UAAU,OAAO,aAAa,QAAW;AACzD,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,MAAI,OAAO,YAAY,OAAO,kBAAkB;AAC9C,UAAM,IAAI;AAAA,MACR;AAAA,IAIF;AAAA,EACF;AAEA,MAAI,CAAC,OAAO,YAAY,CAAC,OAAO,kBAAkB;AAChD,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAKA,MAAI,CAAC,OAAO,SAAU,QAAO;AAe7B,SAAO,iCACF,SADE;AAAA,IAEL,kBAAkB,OAAO,SAAS;AAAA,EACpC;AACF;","names":["Entity"]}
1
+ {"version":3,"sources":["../types/monorise.type.ts","../utils/index.ts"],"sourcesContent":["import type { z } from 'zod';\nimport type { createEntityConfig } from '../utils';\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 */\n/**\n * @description The shape `createMutualConfig(...)` is CALLED with — looser than the resolved\n * `MutualConfig` it returns. `mutualDataSchema` is optional here (and mutually exclusive with\n * `asEntity`) because `createMutualConfig` resolves it before returning: every OTHER consumer in\n * this codebase (`mutualFields[key].mutual`, `MutualService`, the processors) reads the resolved\n * `MutualConfig` type below, where `mutualDataSchema` stays REQUIRED — the same \"loose input,\n * strict resolved output\" split `createEntityConfig`/`MonoriseEntityConfig` already use for\n * `finalSchema`/`effectiveMutualSchema`. Import this type only if you're writing something that\n * itself calls `createMutualConfig`; every other call site should keep using `MutualConfig`.\n */\nexport interface MutualConfigInput<MD extends z.ZodRawShape = z.ZodRawShape> {\n /**\n * Stable analytics dataset name. When provided, it must be lower-kebab-case;\n * the generator validates this so unnamed mutuals remain backwards compatible.\n */\n name?: string;\n entities: [Entity, Entity];\n /** Required unless `asEntity` is set — see `asEntity`'s own doc comment. */\n mutualDataSchema?: z.ZodObject<MD>;\n\n /**\n * @description (Optional) Materialize this mutual relationship as a real,\n * independently-queryable `Entity` whenever it's created — whether imperatively via\n * `MutualService.createMutual` or automatically via a declarative `mutualFields` entry that\n * references this config — by passing the `createEntityConfig(...)` return value for the\n * entity type it should materialize as.\n *\n * When set, in addition to the mutual edge, a real `Entity` is created:\n * `entityType = asEntity.name`, `entityId = <the mutual's own generated ulid>`,\n * `data = <the mutual's own parsed mutualData>`. This lets the relationship be looked up via\n * monorise's `tags` mechanism (an indexed GSI lookup) instead of scanning and filtering every\n * edge in application code, and lets the synthetic entity carry its own `mutualFields`.\n *\n * `mutualDataSchema` must be OMITTED when `asEntity` is set: it's derived automatically from\n * `asEntity.finalSchema` (that entity's own `baseSchema` + `createSchema` +\n * `effectiveMutualSchema`, merged — the same schema this codebase already validates every\n * normal `createEntity` payload against). Chosen over a narrower `baseSchema`/`createSchema`\n * derivation because `MutualService.createMutual`'s `asEntity` path fires\n * `afterCreateEntityHook` on the synthetic entity — the same hook that wires up an entity's\n * OWN further `mutualFields` — so anything narrower than `finalSchema` would silently break\n * that wiring for any `asEntity`-targeted entity that itself declares further relationships.\n * Providing both `asEntity` and `mutualDataSchema` is a build-time AND runtime error.\n *\n * The synthetic entity is always created SYNCHRONOUSLY, in the same DynamoDB transaction as\n * the mutual write, with its `afterCreateEntityHook` (tags/mutualFields wiring) firing\n * immediately after the commit. There is no asynchronous mode: the entity either exists the\n * moment the mutual does, or neither is written. That costs a `TransactWriteItems` (2x WCU\n * versus a plain write) but leaves no window in which the mutual exists and its projection\n * does not.\n *\n * An explicit `options.asEntity` passed directly at an imperative `createMutual(...)` call\n * site always overrides this config-level value — see `resolveAsEntity` in `@monorise/core`'s\n * `mutual.service`.\n *\n * @example\n * ```ts\n * const enrollmentMutual = createMutualConfig({\n * entities: [Entity.STUDENT, Entity.COURSE],\n * asEntity: enrollmentEntityConfig, // the createEntityConfig(...) result for Entity.ENROLLMENT\n * });\n * ```\n */\n asEntity?: ReturnType<typeof createEntityConfig>;\n}\n\n/**\n * @description The resolved shape `createMutualConfig(...)` RETURNS, and what every other\n * consumer in this codebase (`mutualFields[key].mutual`, `MutualService`, the mutual processor)\n * actually references. Unlike `MutualConfigInput`, `mutualDataSchema` is REQUIRED here — by the\n * time a `MutualConfig` object exists, `createMutualConfig` has already derived it from\n * `asEntity.finalSchema` when needed, so every existing `.mutualDataSchema` read across this\n * codebase keeps its original, always-defined guarantee regardless of whether the mutual uses\n * `asEntity` or not.\n */\nexport interface MutualConfig<MD extends z.ZodRawShape = z.ZodRawShape>\n extends Omit<MutualConfigInput<MD>, 'mutualDataSchema'> {\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 CMO extends z.AnyZodObject | 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 * Used to validate mutual fields on create, and — derived to a partial — on update. You do NOT need to author this `.partial()`: the SDK partials it for the update path, so an update that doesn't touch every mutual relationship stays valid regardless of how this is declared.\n */\n mutualSchema: MO;\n\n /**\n * @description (Optional) Stricter schema applied ONLY when the entity is created — falls back to `mutualSchema` if not provided, so existing configs are unaffected. When provided, its shape is merged over `mutualSchema` for create; fields only `mutualSchema` declares (and `createMutualSchema` doesn't mention) are still validated and wired, not dropped.\n *\n * Use this when a mutual relationship must always be wired at creation time (e.g. every Competition must have an owning Organisation from the start). It does not affect updates either way — the update path derives a partial from `mutualSchema` itself, so a required-at-create relationship never has to be resent on an unrelated patch.\n *\n * Without this, a create silently succeeds even if a required mutual link is omitted from the payload — the entity is created but never gets wired to the relationship, with no error anywhere.\n *\n * Note: this only strengthens the *runtime* validation on create — `EntitySchemaMap` (the type callers see back from a read, generated from `finalSchema`) stays `MO`-shaped regardless, since mutual fields are never stored and a read can never actually return one. Don't expect a `createMutualSchema`-required field to show up as required in generated read types.\n *\n * The same-named `PUT /entity/:type/:id` upsert endpoint applies this schema only when the entity doesn't already exist — the same call is strict or lenient purely depending on whether that ID was already there.\n *\n * @example\n * ```ts\n * const mutualSchema = z.object({ organisationIds: z.string().array() }).partial();\n * const createMutualSchema = z.object({ organisationIds: z.string().array() }); // required on create\n * ```\n */\n createMutualSchema?: CMO;\n // Deliberately typed via its own `CMO` generic rather than `MO` — the\n // whole point is that it's allowed to be a DIFFERENT (stricter) shape\n // than `mutualSchema`, e.g. built via `mutualSchema.required({ field:\n // true })`, which is a structurally different ZodObject type, not `MO`\n // itself. Only the runtime merge (`resolveEffectiveMutualSchema` /\n // `effectiveMutualSchema`, see `packages/base/utils`) combines `MO` and\n // `CMO` — `finalSchema`'s TYPE deliberately stays `MO`-based; see the\n // note above and `makeSchema`'s own comment for why.\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: {\n entityId: string;\n entityType: string;\n data: Record<string, any>;\n createdAt: string;\n updatedAt: string;\n }) => {\n group?: string;\n sortValue?: string;\n }[];\n }[];\n\n /**\n * @description (Optional) Configure a DynamoDB TTL for this entity. When set, `expiresAt`\n * is computed via `processor` on create, and recomputed on every update/upsert. Once past,\n * DynamoDB automatically deletes the item (and its derived index rows, since they all carry\n * the same `expiresAt`).\n *\n * `processor` returning `undefined` means \"no TTL\" for that record. On updates, an `undefined`\n * result leaves any existing `expiresAt` untouched rather than clearing it.\n *\n * @example\n * ```ts\n * // fixed 30-day TTL from creation/each update\n * ttl: {\n * processor: () => Math.floor(Date.now() / 1000) + 30 * 24 * 60 * 60,\n * }\n * ```\n *\n * @example\n * ```ts\n * // data-driven TTL, eg. expire when a subscription ends\n * ttl: {\n * processor: (entity) => {\n * return entity.data.subscriptionEndsAt\n * ? new Date(entity.data.subscriptionEndsAt)\n * : undefined;\n * },\n * }\n * ```\n */\n ttl?: {\n /**\n * @description Returns the expiry as epoch seconds (absolute) or a `Date`.\n * Return `undefined` for no expiry.\n */\n processor: (entity: {\n entityId: string;\n entityType: string;\n data: Record<string, any>;\n createdAt: string;\n updatedAt: string;\n }) => number | Date | undefined;\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>\n ? K\n : never]: K;\n } extends never\n ? string\n : keyof {\n [K in keyof B as B[K] extends\n | z.ZodNumber\n | z.ZodOptional<z.ZodNumber>\n ? K\n : 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>\n ? K\n : never]: K;\n } extends never\n ? string\n : keyof {\n [K in keyof B as B[K] extends\n | z.ZodNumber\n | z.ZodOptional<z.ZodNumber>\n ? K\n : 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 /**\n * @description (Optional) Opt in to accepting legacy raw `$where` on updateEntity.\n * Disabled by default: raw DynamoDB condition operators must never be\n * client-facing — an authenticated client could otherwise probe field\n * existence or guess values via the 200-vs-409 response status.\n *\n * Only enable this if you trust the caller (e.g. server-to-server) or have\n * your own validation in front of it. Prefer `updateConditions` instead.\n *\n * @default false\n */\n allowLegacyWhere?: boolean;\n}\n","import { z } from 'zod';\nimport type {\n Entity,\n MonoriseEntityConfig,\n MutualConfig,\n MutualConfigInput,\n} from '../types/monorise.type';\n\n/**\n * @description Merges `mutualSchema` and `createMutualSchema` into the schema\n * actually used to validate a create payload. A plain `createMutualSchema ||\n * mutualSchema` fallback would DROP any mutual field that's declared on\n * `mutualSchema` but omitted from `createMutualSchema` (e.g. a\n * `createMutualSchema` authored to cover only the newly-required field,\n * without repeating every other optional mutual field) — `.parse()` strips\n * unknown keys, so that field's wiring would silently never fire even when\n * the caller supplied it. Merging shapes (with `createMutualSchema`'s keys\n * taking precedence on overlap, since it's the stricter one) keeps every\n * mutual field in play while still enforcing the create-only requirement.\n */\nfunction resolveEffectiveMutualSchema<M extends z.AnyZodObject | undefined>(\n mutualSchema: M,\n createMutualSchema?: z.AnyZodObject,\n): M extends z.AnyZodObject ? z.AnyZodObject : z.AnyZodObject | undefined {\n if (!createMutualSchema) return mutualSchema as any;\n if (!mutualSchema) return createMutualSchema as any;\n\n return mutualSchema.merge(createMutualSchema) as any;\n}\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 CMO extends z.AnyZodObject | undefined = undefined,\n>(\n config: MonoriseEntityConfig<T, B, C, M, CO, MO, CMO>,\n effectiveMutualSchema: z.AnyZodObject | undefined,\n) {\n const { baseSchema, createSchema, effect } = config;\n\n // Deliberately NOT `MO & CMO`-typed: finalSchema.parse() runs against\n // effectiveMutualSchema's real runtime shape (below), but EntitySchemaMap\n // — the type callers see back from a *read* — is generated from this\n // same FinalSchemaType (packages/cli/commands/utils/generate.ts). Mutual\n // fields are never stored, so a required createMutualSchema field must\n // stay optional here; only the create-path runtime validation is allowed\n // to be strict.\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 ...effectiveMutualSchema?.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 CMO extends z.AnyZodObject | undefined = undefined,\n>(\n config: MonoriseEntityConfig<T, B, C, M, CO, MO, CMO>,\n) => {\n // Computed once here (config-definition time, not per-request/per-item)\n // and reused by every create-path call site (afterCreateEntityHook,\n // TransactionService.collectCreateEvents, UpsertEntityController) instead\n // of each rebuilding the same merged ZodObject from scratch.\n const { mutualSchema, createMutualSchema } = config.mutual || {};\n const effectiveMutualSchema = resolveEffectiveMutualSchema(\n mutualSchema,\n createMutualSchema,\n );\n\n return {\n ...config,\n // Derived output, not an input on MonoriseEntityConfig — there's\n // nowhere to declare this on the config type itself. Read by name\n // across packages/core (EntityServiceLifeCycle, TransactionService,\n // UpsertEntityController); don't hand-set it on a config object built\n // outside this factory (e.g. a test fixture) — build through\n // createEntityConfig instead, or it silently falls out of sync with\n // mutual.mutualSchema/createMutualSchema.\n effectiveMutualSchema,\n finalSchema: makeSchema(config, effectiveMutualSchema),\n };\n};\n\nconst createMutualConfig = <MD extends z.ZodRawShape>(\n config: MutualConfigInput<MD>,\n): MutualConfig<MD> => {\n // Catches a specific footgun before it falls through to the generic\n // \"one of mutualDataSchema or asEntity is required\" error below: a config\n // module that does `asEntity: importedEntityConfig` where\n // `importedEntityConfig` comes from a circular import (e.g. student.ts\n // imports enrollmentEntityConfig, which itself lives in a module that\n // imports student.ts) evaluates to `undefined` at this point, not a\n // missing key — `'asEntity' in config` is true, `config.asEntity` is not.\n // The generic error below would say \"one of ... is required\", which sends\n // people looking for a typo instead of an import cycle.\n if ('asEntity' in config && config.asEntity === undefined) {\n throw new Error(\n \"createMutualConfig: 'asEntity' is undefined — likely a circular import between entity config files (the imported entity config module hasn't finished initializing yet). Restructure the imports to break the cycle.\",\n );\n }\n\n if (config.asEntity && config.mutualDataSchema) {\n throw new Error(\n \"createMutualConfig: 'asEntity' and 'mutualDataSchema' are mutually exclusive. \" +\n \"When 'asEntity' is set, mutualDataSchema is derived automatically from \" +\n \"asEntity.finalSchema — remove the explicit mutualDataSchema (or drop 'asEntity' \" +\n 'if this mutual should keep its own independently-authored schema).',\n );\n }\n\n if (!config.asEntity && !config.mutualDataSchema) {\n throw new Error(\n \"createMutualConfig: one of 'mutualDataSchema' or 'asEntity' is required.\",\n );\n }\n\n // Unchanged identity behavior when `asEntity` isn't set — existing configs are unaffected.\n // `mutualDataSchema` is guaranteed present here (checked above), so this cast just tells\n // TypeScript what the runtime guard already established.\n if (!config.asEntity) return config as MutualConfig<MD>;\n\n // `finalSchema` (not baseSchema/createSchema alone) on purpose: the declarative mutual\n // processor's `afterCreateEntityHook` call needs the full schema to correctly wire the\n // synthetic entity's own further `mutualFields` too (see mutual-processor.ts).\n //\n // This does NOT mean finalSchema-shaped data is what gets PERSISTED as this mutual's\n // `mutualData` or the synthetic entity's `data` — both `MutualService.createMutual` and\n // `mutual-processor.ts` re-derive a narrower `asEntity.createSchema ?? asEntity.baseSchema`\n // parse for anything actually written to storage, specifically so the target entity's own\n // mutual-field keys (e.g. `courseIds`, if the target entity itself declares `mutualFields`)\n // never get baked into stored data — the same \"mutual fields are never stored\" invariant\n // `makeSchema` already documents for ordinary entities. `mutualDataSchema` staying as\n // `finalSchema` is what makes the fuller shape available to whichever call site needs it for\n // hook-wiring purposes, without that fuller shape leaking into what's actually persisted.\n return {\n ...config,\n mutualDataSchema: config.asEntity.finalSchema as unknown as z.ZodObject<MD>,\n };\n};\n\nexport { createEntityConfig, createMutualConfig, resolveEffectiveMutualSchema };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAIO,IAAK,SAAL,kBAAKA,YAAL;AAAK,SAAAA;AAAA,GAAA;;;ACJZ,SAAS,SAAS;AAoBlB,SAAS,6BACP,cACA,oBACwE;AACxE,MAAI,CAAC,mBAAoB,QAAO;AAChC,MAAI,CAAC,aAAc,QAAO;AAE1B,SAAO,aAAa,MAAM,kBAAkB;AAC9C;AAEA,SAAS,WASP,QACA,uBACA;AACA,QAAM,EAAE,YAAY,cAAc,OAAO,IAAI;AAiB7C,QAAM,cAAc,EAAE,OAAO,iDACxB,WAAW,QACX,6CAAc,QACd,+DAAuB,MAC3B;AAED,MAAI,QAAQ;AACV,WAAO,OAAO,WAAW;AAAA,EAC3B;AAEA,SAAO;AACT;AAEA,IAAM,qBAAqB,CASzB,WACG;AAKH,QAAM,EAAE,cAAc,mBAAmB,IAAI,OAAO,UAAU,CAAC;AAC/D,QAAM,wBAAwB;AAAA,IAC5B;AAAA,IACA;AAAA,EACF;AAEA,SAAO,iCACF,SADE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASL;AAAA,IACA,aAAa,WAAW,QAAQ,qBAAqB;AAAA,EACvD;AACF;AAEA,IAAM,qBAAqB,CACzB,WACqB;AAUrB,MAAI,cAAc,UAAU,OAAO,aAAa,QAAW;AACzD,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,MAAI,OAAO,YAAY,OAAO,kBAAkB;AAC9C,UAAM,IAAI;AAAA,MACR;AAAA,IAIF;AAAA,EACF;AAEA,MAAI,CAAC,OAAO,YAAY,CAAC,OAAO,kBAAkB;AAChD,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAKA,MAAI,CAAC,OAAO,SAAU,QAAO;AAe7B,SAAO,iCACF,SADE;AAAA,IAEL,kBAAkB,OAAO,SAAS;AAAA,EACpC;AACF;","names":["Entity"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monorise/base",
3
- "version": "4.6.0",
3
+ "version": "4.7.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/monorist/monorise.git",