monorise 0.0.2 → 0.0.3

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.
@@ -199,7 +199,13 @@ interface MonoriseEntityConfig<T extends Entity = Entity, B extends z.ZodRawShap
199
199
  */
200
200
  tags?: {
201
201
  name: string;
202
- processor: (entity: CreatedEntity<T>) => {
202
+ processor: (entity: {
203
+ entityId: string;
204
+ entityType: string;
205
+ data: Record<string, any>;
206
+ createdAt: string;
207
+ updatedAt: string;
208
+ }) => {
203
209
  group?: string;
204
210
  sortValue?: string;
205
211
  }[];
@@ -207,7 +213,7 @@ interface MonoriseEntityConfig<T extends Entity = Entity, B extends z.ZodRawShap
207
213
  }
208
214
 
209
215
  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>(config: MonoriseEntityConfig<T, B, C, M, CO, MO>) => {
210
- 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]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<MO["shape"] & CO["shape"]>, any>[k]; } : never, z.baseObjectInputType<MO["shape"] & CO["shape"]> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<MO["shape"] & CO["shape"]>[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]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<MO["shape"] & B>, any>[k_2]; } : never, z.baseObjectInputType<MO["shape"] & B> extends infer T_4 ? { [k_3 in keyof T_4]: z.baseObjectInputType<MO["shape"] & B>[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]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B>, any>[k_4]; } : never, z.baseObjectInputType<B> extends infer T_6 ? { [k_5 in keyof T_6]: z.baseObjectInputType<B>[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]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<MO["shape"] & CO["shape"]>, any>[k]; } : never, z.baseObjectInputType<MO["shape"] & CO["shape"]> extends infer T_8 ? { [k_1 in keyof T_8]: z.baseObjectInputType<MO["shape"] & CO["shape"]>[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]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<MO["shape"] & B>, any>[k_2]; } : never, z.baseObjectInputType<MO["shape"] & B> extends infer T_10 ? { [k_3 in keyof T_10]: z.baseObjectInputType<MO["shape"] & B>[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]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B>, any>[k_4]; } : never, z.baseObjectInputType<B> extends infer T_12 ? { [k_5 in keyof T_12]: z.baseObjectInputType<B>[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]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<MO["shape"] & CO["shape"]>, any>[k]; } : never, z.baseObjectInputType<MO["shape"] & CO["shape"]> extends infer T_14 ? { [k_1 in keyof T_14]: z.baseObjectInputType<MO["shape"] & CO["shape"]>[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]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<MO["shape"] & B>, any>[k_2]; } : never, z.baseObjectInputType<MO["shape"] & B> extends infer T_16 ? { [k_3 in keyof T_16]: z.baseObjectInputType<MO["shape"] & B>[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]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B>, any>[k_4]; } : never, z.baseObjectInputType<B> extends infer T_18 ? { [k_5 in keyof T_18]: z.baseObjectInputType<B>[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]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<MO["shape"] & CO["shape"]>, any>[k]; } : never, z.baseObjectInputType<MO["shape"] & CO["shape"]> extends infer T_20 ? { [k_1 in keyof T_20]: z.baseObjectInputType<MO["shape"] & CO["shape"]>[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]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<MO["shape"] & B>, any>[k_2]; } : never, z.baseObjectInputType<MO["shape"] & B> extends infer T_22 ? { [k_3 in keyof T_22]: z.baseObjectInputType<MO["shape"] & B>[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]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B>, any>[k_4]; } : never, z.baseObjectInputType<B> extends infer T_24 ? { [k_5 in keyof T_24]: z.baseObjectInputType<B>[k_5]; } : never>>>;
216
+ 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>>>;
211
217
  name: string | T;
212
218
  displayName: string;
213
219
  authMethod?: {
@@ -215,7 +221,7 @@ declare const createEntityConfig: <T extends Entity, B extends z.ZodRawShape, C
215
221
  tokenExpiresIn: number;
216
222
  };
217
223
  };
218
- 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]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<B>, any>[k_4]; } : never, z.baseObjectInputType<B> extends infer T_26 ? { [k_5 in keyof T_26]: z.baseObjectInputType<B>[k_5]; } : never>;
224
+ 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>;
219
225
  createSchema?: CO | undefined;
220
226
  searchableFields?: (keyof B)[] | undefined;
221
227
  uniqueFields?: (keyof B)[] | undefined;
@@ -244,11 +250,17 @@ declare const createEntityConfig: <T extends Entity, B extends z.ZodRawShape, C
244
250
  effect?: (schema: z.ZodObject<z.ZodRawShape>) => z.ZodEffects<z.ZodObject<z.ZodRawShape>>;
245
251
  tags?: {
246
252
  name: string;
247
- processor: (entity: undefined<T>) => {
253
+ processor: (entity: {
254
+ entityId: string;
255
+ entityType: string;
256
+ data: Record<string, any>;
257
+ createdAt: string;
258
+ updatedAt: string;
259
+ }) => {
248
260
  group?: string;
249
261
  sortValue?: string;
250
262
  }[];
251
- }[] | undefined;
252
- }
263
+ }[];
264
+ };
253
265
 
254
266
  export { type CreatedEntity, type DraftEntity, Entity, type EntitySchemaMap, type MonoriseEntityConfig, createEntityConfig };
@@ -1 +1 @@
1
- {"version":3,"sources":["../types/monorise.type.ts","../utils/index.ts"],"sourcesContent":["import type { z } from 'zod';\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 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: CreatedEntity<T>) => {\n group?: string;\n sortValue?: string;\n }[];\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<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 ...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":";;;;;;;;;;;;;;;;;;;;;AAEO,IAAK,SAAL,kBAAKA,YAAL;AAAK,SAAAA;AAAA,GAAA;;;ACDZ,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"],"sourcesContent":["import type { z } from 'zod';\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 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","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<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 ...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":";;;;;;;;;;;;;;;;;;;;;AAEO,IAAK,SAAL,kBAAKA,YAAL;AAAK,SAAAA;AAAA,GAAA;;;ACDZ,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"]}
package/dist/cli/cli.js CHANGED
@@ -12,7 +12,7 @@ function kebabToCamel(str) {
12
12
  function kebabToPascal(kebab) {
13
13
  return kebab.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
14
14
  }
15
- async function generateConfigFile(configDir, monoriseOutputDir) {
15
+ async function generateConfigFile(configDir, monoriseOutputDir, projectRoot) {
16
16
  const configOutputPath = path.join(monoriseOutputDir, "config.ts");
17
17
  const initialConfigContent = `
18
18
  export enum Entity {}
@@ -66,6 +66,8 @@ export enum Entity {}
66
66
  entityWithEmailAuthEntries.push(`Entity.${enumKey}`);
67
67
  }
68
68
  }
69
+ const usesCombinedPackage = fs.existsSync(path.join(projectRoot, "node_modules", "monorise"));
70
+ const baseModuleName = usesCombinedPackage ? "monorise/base" : "@monorise/base";
69
71
  const configOutputContent = `
70
72
  import type { z } from 'zod';
71
73
  ${imports.join("\n")}
@@ -110,7 +112,7 @@ const config = {
110
112
 
111
113
  export default config;
112
114
 
113
- declare module '@monorise/base' {
115
+ declare module '${baseModuleName}' {
114
116
  export enum Entity {
115
117
  ${enumEntries.join(",\n ")}
116
118
  }
@@ -166,8 +168,10 @@ async function generateHandleFile(monoriseConfig, projectRoot, monoriseOutputDir
166
168
  routesImportLine = `import routes from '${relativePathToRoutes}';`;
167
169
  appHandlerPayload = "{ routes }";
168
170
  }
171
+ const usesCombinedPackage = fs.existsSync(path.join(projectRoot, "node_modules", "monorise"));
172
+ const coreImportPath = usesCombinedPackage ? "monorise/core" : "@monorise/core";
169
173
  const combinedContent = `
170
- import CoreFactory from 'monorise/core';
174
+ import CoreFactory from '${coreImportPath}';
171
175
  import config from './config';
172
176
  ${routesImportLine ? `${routesImportLine}
173
177
  ` : ""}const coreFactory = new CoreFactory(config);
@@ -202,7 +206,7 @@ async function generateFiles(rootPath) {
202
206
  const configDir = path.resolve(projectRoot, monoriseConfig.configDir);
203
207
  const monoriseOutputDir = path.join(projectRoot, ".monorise");
204
208
  fs.mkdirSync(monoriseOutputDir, { recursive: true });
205
- await generateConfigFile(configDir, monoriseOutputDir);
209
+ await generateConfigFile(configDir, monoriseOutputDir, projectRoot);
206
210
  await generateHandleFile(monoriseConfig, projectRoot, monoriseOutputDir);
207
211
  return configDir;
208
212
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport 'tsx';\nimport 'tsconfig-paths/register.js';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport chokidar from 'chokidar';\n\nfunction kebabToCamel(str: string): string {\n return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n}\n\nfunction kebabToPascal(kebab: string): string {\n return kebab\n .split('-')\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join('');\n}\n\nasync function generateConfigFile(\n configDir: string,\n monoriseOutputDir: string,\n): Promise<string> {\n const configOutputPath = path.join(monoriseOutputDir, 'config.ts');\n const initialConfigContent = `\nexport enum Entity {}\n`;\n fs.writeFileSync(configOutputPath, initialConfigContent);\n\n const files = fs\n .readdirSync(configDir)\n .filter((file) => file.endsWith('.ts') && file !== 'index.ts');\n\n const names = new Set<string>();\n const nameRegex = /^[a-z]+(-[a-z]+)*$/;\n const imports: string[] = [];\n\n const enumEntries: string[] = [];\n const typeEntries: string[] = [];\n const schemaMapEntries: string[] = [];\n const configEntries: string[] = [];\n const schemaEntries: string[] = [];\n const allowedEntityEntries: string[] = [];\n const entityWithEmailAuthEntries: string[] = [];\n\n const relativePathToConfigDir = path.relative(monoriseOutputDir, configDir);\n const importPathPrefix = relativePathToConfigDir\n ? `${relativePathToConfigDir}/`\n : './';\n\n for (const file of files) {\n const fullPath = path.join(configDir, file);\n const module = await import(fullPath);\n const config = module.default;\n\n if (!nameRegex.test(config.name)) {\n throw new Error(\n `Invalid name format: ${config.name} in ${file}. Must be kebab-case.`,\n );\n }\n\n if (names.has(config.name)) {\n throw new Error(`Duplicate name found: ${config.name} in ${file}`);\n }\n names.add(config.name);\n\n const fileName = file.replace(/\\.ts$/, '');\n const variableName = kebabToCamel(fileName);\n imports.push(\n `import ${variableName} from '${importPathPrefix}${fileName}';`,\n );\n\n const enumKey = config.name.toUpperCase().replace(/-/g, '_');\n enumEntries.push(`${enumKey} = '${config.name}'`);\n typeEntries.push(\n `export type ${kebabToPascal(config.name)}Type = z.infer<(typeof ${variableName})['finalSchema']>;`,\n );\n schemaMapEntries.push(\n `[Entity.${enumKey}]: ${kebabToPascal(config.name)}Type;`,\n );\n\n configEntries.push(`[Entity.${enumKey}]: ${kebabToCamel(config.name)},`);\n schemaEntries.push(\n `[Entity.${enumKey}]: ${kebabToCamel(config.name)}.finalSchema,`,\n );\n\n allowedEntityEntries.push(`Entity.${enumKey}`);\n\n if (config.authMethod?.email) {\n entityWithEmailAuthEntries.push(`Entity.${enumKey}`);\n }\n }\n\n const configOutputContent = `\nimport type { z } from 'zod';\n${imports.join('\\n')}\n\nexport enum Entity {\n ${enumEntries.join(',\\n ')}\n}\n\n${typeEntries.join('\\n')}\n\nexport interface EntitySchemaMap {\n ${schemaMapEntries.join('\\n ')}\n}\n\nconst EntityConfig = {\n ${configEntries.join('\\n ')}\n};\n\nconst FormSchema = {\n ${schemaEntries.join('\\n ')}\n};\n\nconst AllowedEntityTypes = [\n ${allowedEntityEntries.join(',\\n ')}\n];\n\nconst EmailAuthEnabledEntities: Entity[] = [${entityWithEmailAuthEntries.join(', ')}];\n\nexport {\n EntityConfig,\n FormSchema,\n AllowedEntityTypes,\n EmailAuthEnabledEntities,\n};\n\nconst config = {\n EntityConfig,\n FormSchema,\n AllowedEntityTypes,\n EmailAuthEnabledEntities,\n};\n\nexport default config;\n\ndeclare module '@monorise/base' {\n export enum Entity {\n ${enumEntries.join(',\\n ')}\n }\n\n ${typeEntries.join('\\n ')}\n\n export interface EntitySchemaMap {\n ${schemaMapEntries.join('\\n ')}\n }\n}\n`;\n\n fs.writeFileSync(configOutputPath, configOutputContent);\n console.log('Successfully generated config.ts!');\n return configOutputPath;\n}\n\nasync function generateHandleFile(\n monoriseConfig: { customRoutes?: string; configDir: string },\n projectRoot: string,\n monoriseOutputDir: string,\n): Promise<string> {\n const handleOutputPath = path.join(monoriseOutputDir, 'handle.ts');\n const customRoutesPath = monoriseConfig.customRoutes;\n\n let routesImportLine = '';\n let appHandlerPayload = '{}'; // Default to an empty object for appHandler if no custom routes\n\n if (customRoutesPath) {\n const absoluteCustomRoutesPath = path.resolve(\n projectRoot,\n customRoutesPath,\n );\n\n if (\n !fs.existsSync(absoluteCustomRoutesPath) &&\n !fs.existsSync(`${absoluteCustomRoutesPath}.ts`) &&\n !fs.existsSync(`${absoluteCustomRoutesPath}.js`)\n ) {\n throw new Error(\n `Custom routes file not found: '${absoluteCustomRoutesPath}'. Please ensure 'customRoutes' in monorise.config.ts points to a valid file.`,\n );\n }\n\n let routesModule;\n try {\n routesModule = await import(absoluteCustomRoutesPath);\n } catch (e: any) {\n throw new Error(\n `Failed to load custom routes file at '${absoluteCustomRoutesPath}'. Ensure it's a valid JavaScript/TypeScript module. Error: ${e.message}`,\n );\n }\n\n const routesExport = routesModule.default;\n\n if (\n !routesExport ||\n routesExport === null ||\n (typeof routesExport === 'object' &&\n !(\n 'get' in routesExport &&\n 'post' in routesExport &&\n 'use' in routesExport\n ))\n ) {\n throw new Error(\n `Custom routes file at '${absoluteCustomRoutesPath}' must default export an instance of Hono (or an object with .get, .post, .use methods). Or a function that consume the dependency container provided by route handler.`,\n );\n }\n\n let relativePathToRoutes = path.relative(\n monoriseOutputDir,\n absoluteCustomRoutesPath,\n );\n relativePathToRoutes = relativePathToRoutes.replace(\n /\\.(ts|js|mjs|cjs)$/,\n '',\n );\n\n // If custom routes are provided, include the import statement and pass 'routes' to appHandler\n routesImportLine = `import routes from '${relativePathToRoutes}';`;\n appHandlerPayload = '{ routes }';\n }\n // If customRoutesPath is not provided, routesImportLine remains empty and appHandlerPayload remains `{}`\n\n const combinedContent = `\nimport CoreFactory from 'monorise/core';\nimport config from './config';\n${routesImportLine ? `${routesImportLine}\\n` : ''}const coreFactory = new CoreFactory(config);\n\nexport const replicationHandler = coreFactory.replicationProcessor;\nexport const mutualHandler = coreFactory.mutualProcessor;\nexport const tagHandler = coreFactory.tagProcessor;\nexport const treeHandler = coreFactory.prejoinProcessor;\nexport const appHandler = coreFactory.appHandler(${appHandlerPayload});\n`;\n fs.writeFileSync(handleOutputPath, combinedContent);\n console.log('Successfully generated handle.ts!');\n\n return handleOutputPath;\n}\n\nasync function generateFiles(rootPath?: string): Promise<string> {\n const baseDir = rootPath ? path.resolve(rootPath) : process.cwd();\n const configFilePathTS = path.join(baseDir, 'monorise.config.ts');\n const configFilePathJS = path.join(baseDir, 'monorise.config.js');\n\n let configFilePath: string;\n if (fs.existsSync(configFilePathTS)) {\n configFilePath = configFilePathTS;\n } else if (fs.existsSync(configFilePathJS)) {\n configFilePath = configFilePathJS;\n } else {\n throw new Error(\n 'Neither monorise.config.ts nor monorise.config.js found in the root of the project.',\n );\n }\n\n const projectRoot = path.dirname(configFilePath);\n const monoriseConfigModule = await import(configFilePath);\n const monoriseConfig = monoriseConfigModule.default;\n\n const configDir = path.resolve(projectRoot, monoriseConfig.configDir);\n const monoriseOutputDir = path.join(projectRoot, '.monorise');\n\n fs.mkdirSync(monoriseOutputDir, { recursive: true });\n\n await generateConfigFile(configDir, monoriseOutputDir);\n await generateHandleFile(monoriseConfig, projectRoot, monoriseOutputDir);\n\n return configDir;\n}\n\nconst MONORISE_LOGO = `\n\n\n\n ░░░░░░░\n ░░▒▒▒░░░░░░▒▒▒░\n ░▒▒░ ░▒▒░\n ░▒▒░ ░▒▒░\n ░▒░ ░▒▒░\n ░▒▒░ ▒▒▒░\n ░▒░░░▒░ ░▒░░▒▒░\n ░▒▒░ ░▒▒▒░ ░▒▒░ ░▒░░\n ░▒▒ ░▒▒░ ░▒▒░ ░▒░ ░▒░ ░▒░\n ░▒▒░ ░▒░ ░▒░░▒▒░░░ ░░▒▒░░▒░ ░▒▒ ░▒░\n ░░▒░ ░▒░ ░▒░ ░▒▒░░▒▒▒▒▒▒░░▒░ ░▒░░ ░▒░ ░▒░\n ░▒░ ░░▒░ ░▒░ ░░░ ░▒░ ░░ ░▒░ ░▒░ ░▒░░ ░░▒░\n ░▒░ ░▒░ ░▒░ ░▒ ░░ ░▒░ ░▒░ ░▒░ ░▒░ ░░░░\n ░░░ ░░░░ ░░░ ░░ ▒░ ░░░ ░░░ ░░░ ░░░ ░░░░\n ░░░ ░░░░ ░░░ ░░░ ░░░ ░░ ░░░ ░░░ ░░░ ░░░░\n ░░░ ░░░ ░░░ ░░░ ░░ ░░ ░░░ ░░░ ░░░ ░░░\n ░░░ ░░░░ ░░░ ░░░ ░░ ░░░ ░░ ░░░ ░░░ ░░░\n ░░ ░░░ ░░░ ░░░ ░░░ ░░ ░░░ ░░░ ░░░ ░░░\n ░░ ░░ ░░ ░░ ░░ ░░░ ░░░ ░░░ ░░░░ ░░░\n ░░░ ░░ ░░░ ░░░ ░░░\n ░░░░░▒░░░░░░░░░▒░░░░░░░░░ ░ ░░ ░░░ ░░░ ░░\n ░░░ ░░░░░░░░░ ░░░ ░░░\n ░░░ ░░░░░░ ░░ ░░░░░▒░░░░░░▒░░░░\n ░░░░░░░░░░░░░░░░░ ░░░░░ ░░░░░░░░ ░░\n ░░░░░░░ ░░░░░░░░░░░░░░ ░░░░ ░░░░░ ░▒░\n ░░░ ░░░░░░░ ░░░░░░ ░░░░░░░░\n ░░░░░░░░░░░░ ░░░░░░ ░░░░ ░░░░░░░░░░░░░\n ░▒▒░░░░░░░░░░░▒▒░░ ░░▒▒▒░░ ░▒▒░░ ░░░░\n ░▒░ ░░▒▒░ ░▒░ ░▒▒░ ░░▒░\n ░▒░ ░░░░▒▒▒▒▒▒▒▒▒▒░░ ░▒░ ▒▒░ ░░▒▒▒░\n ░▒▒▒▒▒░░░ ░░░▒▒▒▒▒░ ▒▒░ ░▒▒▒▒▒▒░\n ░▒▒░ ░▒▒▒▒ ▒▒▒ ▒▒▒\n ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░ ░▒▒▒▒▒░ ░▒▒\n ▒▒▒ ░░▒▒▒▒▒▒░ ▒▒▒ ░▒▒\n ▒▒▒ ░▒▒▒▒ ░▒▒▒░\n ▒▓▓▓▒▒▒▓▓▒▒▒░ ▒▒▒░░▒▒░\n ▒▓░ ░▒▒▓▓▒░ ▒▓▓░\n ░▒▓░ ░▒▓▒░▒▓▒\n ░▒▓▒░ ░▒▓▓▒\n ░▒▒▓▓▓▓▓▓▒▒░\n\n\n\n`;\n\nasync function runInitCommand(rootPath?: string) {\n const projectRoot = rootPath ? path.resolve(rootPath) : process.cwd();\n console.log(MONORISE_LOGO);\n console.log(`Initializing Monorise project in ${projectRoot}...`);\n\n // 1. Create monorise.config.ts\n const monoriseConfigTsPath = path.join(projectRoot, 'monorise.config.ts');\n const monoriseConfigContent = `\nconst config = {\n configDir: './monorise/entities',\n // custom route file should export default an Hono object.\n // customRoutes: './path/to/custom/routes.ts'\n};\n\nexport default config;\n`;\n if (!fs.existsSync(monoriseConfigTsPath)) {\n fs.writeFileSync(monoriseConfigTsPath, monoriseConfigContent.trimStart());\n console.log(`Created ${path.relative(projectRoot, monoriseConfigTsPath)}`);\n } else {\n console.log(\n `${path.relative(projectRoot, monoriseConfigTsPath)} already exists. Skipping.`,\n );\n }\n\n // 2. Create ./monorise/entities/user.ts\n const monoriseEntitiesDir = path.join(projectRoot, 'monorise', 'entities');\n fs.mkdirSync(monoriseEntitiesDir, { recursive: true });\n\n const userEntityTsPath = path.join(monoriseEntitiesDir, 'user.ts');\n const userEntityContent = `\nimport { createEntityConfig } from 'monorise/base';\nimport { z } from 'zod';\n\nconst baseSchema = z\n .object({\n displayName: z\n .string()\n .min(1, 'Please provide a name for this user account'),\n firstName: z.string().min(1, 'Please provide first name'),\n lastName: z.string().min(1, 'Please provide last name'),\n jobTitle: z.string(),\n })\n .partial();\n\nconst config = createEntityConfig({\n name: 'user',\n baseSchema,\n});\n\nexport default config;\n`;\n if (!fs.existsSync(userEntityTsPath)) {\n fs.writeFileSync(userEntityTsPath, userEntityContent.trimStart());\n console.log(`Created ${path.relative(projectRoot, userEntityTsPath)}`);\n } else {\n console.log(\n `${path.relative(projectRoot, userEntityTsPath)} already exists. Skipping.`,\n );\n }\n\n // 3. Update package.json\n const packageJsonPath = path.join(projectRoot, 'package.json');\n if (fs.existsSync(packageJsonPath)) {\n try {\n const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf8');\n const packageJson = JSON.parse(packageJsonContent);\n\n if (packageJson.type !== 'module') {\n packageJson.type = 'module';\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));\n console.log(\n `Updated 'type' to 'module' in ${path.relative(projectRoot, packageJsonPath)}`,\n );\n } else {\n console.log(\n `'type: \"module\"' already set in ${path.relative(projectRoot, packageJsonPath)}. Skipping.`,\n );\n }\n } catch (error) {\n console.error(\n `Error reading or parsing ${path.relative(projectRoot, packageJsonPath)}:`,\n error,\n );\n }\n } else {\n console.warn(\n `Warning: ${path.relative(projectRoot, packageJsonPath)} not found. Cannot update 'type'.`,\n );\n }\n\n // 4. Add tsconfig path alias for .monorise directory\n const tsconfigPath = path.join(projectRoot, 'tsconfig.json');\n if (fs.existsSync(tsconfigPath)) {\n try {\n const tsconfigContent = fs.readFileSync(tsconfigPath, 'utf8');\n const tsconfig = JSON.parse(tsconfigContent);\n\n if (!tsconfig.compilerOptions) {\n tsconfig.compilerOptions = {};\n }\n if (!tsconfig.compilerOptions.paths) {\n tsconfig.compilerOptions.paths = {};\n }\n\n const pathKey = '#/monorise/*';\n const pathValue = ['./.monorise/*'];\n\n if (!tsconfig.compilerOptions.paths[pathKey]) {\n tsconfig.compilerOptions.paths[pathKey] = pathValue;\n fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2));\n console.log(\n `Added '${pathKey}' path alias in ${path.relative(projectRoot, tsconfigPath)}`,\n );\n } else {\n console.log(\n `'${pathKey}' path alias already set in ${path.relative(projectRoot, tsconfigPath)}. Skipping.`,\n );\n }\n } catch (error) {\n console.error(\n `Error updating ${path.relative(projectRoot, tsconfigPath)}:`,\n error,\n );\n }\n } else {\n console.warn(\n `Warning: ${path.relative(projectRoot, tsconfigPath)} not found. Cannot add path alias.`,\n );\n }\n\n console.log('Monorise initialization complete!');\n}\n\nasync function runDevCommand(configDir: string, rootPath?: string) {\n console.log(MONORISE_LOGO);\n console.log(`Watching for changes in ${configDir}...`);\n const watcher = chokidar.watch(configDir, {\n ignored: (watchedPath: string) => {\n const fileName = path.basename(watchedPath);\n return (\n fileName === 'index.ts' || // Old name, still ignore in case it exists\n fileName === 'config.ts' || // Generated config file\n fileName === 'processors.ts' || // Generated processors file\n fileName === 'app.ts' || // Generated app file\n fileName.startsWith('.') ||\n watchedPath.endsWith('.js') ||\n watchedPath.endsWith('.jsx') ||\n watchedPath.endsWith('.d.ts')\n );\n },\n persistent: true,\n ignoreInitial: true,\n });\n\n watcher.on('add', async (filePath) => {\n console.log(`File ${filePath} has been added. Regenerating...`);\n try {\n await generateFiles(rootPath);\n } catch (err) {\n console.error('Regeneration failed:', err);\n }\n });\n\n watcher.on('change', async (filePath) => {\n console.log(`File ${filePath} has been changed. Regenerating...`);\n try {\n await generateFiles(rootPath);\n } catch (err) {\n console.error('Regeneration failed:', err);\n }\n });\n\n watcher.on('unlink', async (filePath) => {\n console.log(`File ${filePath} has been removed. Regenerating...`);\n try {\n await generateFiles(rootPath);\n } catch (err) {\n console.error('Regeneration failed:', err);\n }\n });\n\n process.on('SIGINT', () => {\n console.log('Monorise dev terminated. Closing watcher and sst dev...');\n watcher.close();\n process.exit(0);\n });\n process.on('SIGTERM', () => {\n console.log('Monorise dev terminated. Closing watcher and sst dev...');\n watcher.close();\n process.exit(0);\n });\n}\n\nasync function runBuildCommand(rootPath?: string) {\n console.log('Starting sst build...');\n await generateFiles(rootPath);\n}\n\nasync function main() {\n const args = process.argv.slice(2);\n const command = args[0];\n\n let rootPath: string | undefined;\n const rootFlagIndex = args.indexOf('--config-root');\n if (rootFlagIndex > -1 && args[rootFlagIndex + 1]) {\n rootPath = args[rootFlagIndex + 1];\n }\n\n try {\n if (command === 'dev') {\n const configDir = await generateFiles(rootPath);\n await runDevCommand(configDir, rootPath);\n } else if (command === 'build') {\n await runBuildCommand(rootPath);\n } else if (command === 'init') {\n await runInitCommand(rootPath);\n } else {\n console.error(\n 'Unknown command. Usage: monorise [dev|build|init] [--config-root <path>]',\n );\n process.exit(1);\n }\n } catch (err) {\n console.error('Monorise process failed:', err);\n process.exit(1);\n }\n}\n\nmain().catch((err) => {\n console.error('Monorise encountered an unhandled error:', err);\n process.exit(1);\n});\n"],"mappings":";;;AAEA,OAAO;AACP,OAAO;AACP,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,cAAc;AAErB,SAAS,aAAa,KAAqB;AACzC,SAAO,IAAI,QAAQ,aAAa,CAAC,GAAG,WAAW,OAAO,YAAY,CAAC;AACrE;AAEA,SAAS,cAAc,OAAuB;AAC5C,SAAO,MACJ,MAAM,GAAG,EACT,IAAI,CAAC,SAAS,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,CAAC,EAC1D,KAAK,EAAE;AACZ;AAEA,eAAe,mBACb,WACA,mBACiB;AACjB,QAAM,mBAAmB,KAAK,KAAK,mBAAmB,WAAW;AACjE,QAAM,uBAAuB;AAAA;AAAA;AAG7B,KAAG,cAAc,kBAAkB,oBAAoB;AAEvD,QAAM,QAAQ,GACX,YAAY,SAAS,EACrB,OAAO,CAAC,SAAS,KAAK,SAAS,KAAK,KAAK,SAAS,UAAU;AAE/D,QAAM,QAAQ,oBAAI,IAAY;AAC9B,QAAM,YAAY;AAClB,QAAM,UAAoB,CAAC;AAE3B,QAAM,cAAwB,CAAC;AAC/B,QAAM,cAAwB,CAAC;AAC/B,QAAM,mBAA6B,CAAC;AACpC,QAAM,gBAA0B,CAAC;AACjC,QAAM,gBAA0B,CAAC;AACjC,QAAM,uBAAiC,CAAC;AACxC,QAAM,6BAAuC,CAAC;AAE9C,QAAM,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AAO;AACrB,YAAM,YAAY,MAAM,cAAc,QAAQ;AAC9C,YAAM,cAAc,WAAW,QAAQ;AAAA,IACzC,WAAW,YAAY,SAAS;AAC9B,YAAM,gBAAgB,QAAQ;AAAA,IAChC,WAAW,YAAY,QAAQ;AAC7B,YAAM,eAAe,QAAQ;AAAA,IAC/B,OAAO;AACL,cAAQ;AAAA,QACN;AAAA,MACF;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,SAAS,KAAK;AACZ,YAAQ,MAAM,4BAA4B,GAAG;AAC7C,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,UAAQ,MAAM,4CAA4C,GAAG;AAC7D,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
1
+ {"version":3,"sources":["../cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport 'tsx';\nimport 'tsconfig-paths/register.js';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport chokidar from 'chokidar';\n\nfunction kebabToCamel(str: string): string {\n return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n}\n\nfunction kebabToPascal(kebab: string): string {\n return kebab\n .split('-')\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join('');\n}\n\nasync function generateConfigFile(\n configDir: string,\n monoriseOutputDir: string,\n projectRoot: string,\n): Promise<string> {\n const configOutputPath = path.join(monoriseOutputDir, 'config.ts');\n const initialConfigContent = `\nexport enum Entity {}\n`;\n fs.writeFileSync(configOutputPath, initialConfigContent);\n\n const files = fs\n .readdirSync(configDir)\n .filter((file) => file.endsWith('.ts') && file !== 'index.ts');\n\n const names = new Set<string>();\n const nameRegex = /^[a-z]+(-[a-z]+)*$/;\n const imports: string[] = [];\n\n const enumEntries: string[] = [];\n const typeEntries: string[] = [];\n const schemaMapEntries: string[] = [];\n const configEntries: string[] = [];\n const schemaEntries: string[] = [];\n const allowedEntityEntries: string[] = [];\n const entityWithEmailAuthEntries: string[] = [];\n\n const relativePathToConfigDir = path.relative(monoriseOutputDir, configDir);\n const importPathPrefix = relativePathToConfigDir\n ? `${relativePathToConfigDir}/`\n : './';\n\n for (const file of files) {\n const fullPath = path.join(configDir, file);\n const module = await import(fullPath);\n const config = module.default;\n\n if (!nameRegex.test(config.name)) {\n throw new Error(\n `Invalid name format: ${config.name} in ${file}. Must be kebab-case.`,\n );\n }\n\n if (names.has(config.name)) {\n throw new Error(`Duplicate name found: ${config.name} in ${file}`);\n }\n names.add(config.name);\n\n const fileName = file.replace(/\\.ts$/, '');\n const variableName = kebabToCamel(fileName);\n imports.push(\n `import ${variableName} from '${importPathPrefix}${fileName}';`,\n );\n\n const enumKey = config.name.toUpperCase().replace(/-/g, '_');\n enumEntries.push(`${enumKey} = '${config.name}'`);\n typeEntries.push(\n `export type ${kebabToPascal(config.name)}Type = z.infer<(typeof ${variableName})['finalSchema']>;`,\n );\n schemaMapEntries.push(\n `[Entity.${enumKey}]: ${kebabToPascal(config.name)}Type;`,\n );\n\n configEntries.push(`[Entity.${enumKey}]: ${kebabToCamel(config.name)},`);\n schemaEntries.push(\n `[Entity.${enumKey}]: ${kebabToCamel(config.name)}.finalSchema,`,\n );\n\n allowedEntityEntries.push(`Entity.${enumKey}`);\n\n if (config.authMethod?.email) {\n entityWithEmailAuthEntries.push(`Entity.${enumKey}`);\n }\n }\n\n // Detect whether the consumer uses the combined 'monorise' package or scoped '@monorise/*' packages\n const usesCombinedPackage = fs.existsSync(path.join(projectRoot, 'node_modules', 'monorise'));\n const baseModuleName = usesCombinedPackage ? 'monorise/base' : '@monorise/base';\n\n const configOutputContent = `\nimport type { z } from 'zod';\n${imports.join('\\n')}\n\nexport enum Entity {\n ${enumEntries.join(',\\n ')}\n}\n\n${typeEntries.join('\\n')}\n\nexport interface EntitySchemaMap {\n ${schemaMapEntries.join('\\n ')}\n}\n\nconst EntityConfig = {\n ${configEntries.join('\\n ')}\n};\n\nconst FormSchema = {\n ${schemaEntries.join('\\n ')}\n};\n\nconst AllowedEntityTypes = [\n ${allowedEntityEntries.join(',\\n ')}\n];\n\nconst EmailAuthEnabledEntities: Entity[] = [${entityWithEmailAuthEntries.join(', ')}];\n\nexport {\n EntityConfig,\n FormSchema,\n AllowedEntityTypes,\n EmailAuthEnabledEntities,\n};\n\nconst config = {\n EntityConfig,\n FormSchema,\n AllowedEntityTypes,\n EmailAuthEnabledEntities,\n};\n\nexport default config;\n\ndeclare module '${baseModuleName}' {\n export enum Entity {\n ${enumEntries.join(',\\n ')}\n }\n\n ${typeEntries.join('\\n ')}\n\n export interface EntitySchemaMap {\n ${schemaMapEntries.join('\\n ')}\n }\n}\n`;\n\n fs.writeFileSync(configOutputPath, configOutputContent);\n console.log('Successfully generated config.ts!');\n return configOutputPath;\n}\n\nasync function generateHandleFile(\n monoriseConfig: { customRoutes?: string; configDir: string },\n projectRoot: string,\n monoriseOutputDir: string,\n): Promise<string> {\n const handleOutputPath = path.join(monoriseOutputDir, 'handle.ts');\n const customRoutesPath = monoriseConfig.customRoutes;\n\n let routesImportLine = '';\n let appHandlerPayload = '{}'; // Default to an empty object for appHandler if no custom routes\n\n if (customRoutesPath) {\n const absoluteCustomRoutesPath = path.resolve(\n projectRoot,\n customRoutesPath,\n );\n\n if (\n !fs.existsSync(absoluteCustomRoutesPath) &&\n !fs.existsSync(`${absoluteCustomRoutesPath}.ts`) &&\n !fs.existsSync(`${absoluteCustomRoutesPath}.js`)\n ) {\n throw new Error(\n `Custom routes file not found: '${absoluteCustomRoutesPath}'. Please ensure 'customRoutes' in monorise.config.ts points to a valid file.`,\n );\n }\n\n let routesModule;\n try {\n routesModule = await import(absoluteCustomRoutesPath);\n } catch (e: any) {\n throw new Error(\n `Failed to load custom routes file at '${absoluteCustomRoutesPath}'. Ensure it's a valid JavaScript/TypeScript module. Error: ${e.message}`,\n );\n }\n\n const routesExport = routesModule.default;\n\n if (\n !routesExport ||\n routesExport === null ||\n (typeof routesExport === 'object' &&\n !(\n 'get' in routesExport &&\n 'post' in routesExport &&\n 'use' in routesExport\n ))\n ) {\n throw new Error(\n `Custom routes file at '${absoluteCustomRoutesPath}' must default export an instance of Hono (or an object with .get, .post, .use methods). Or a function that consume the dependency container provided by route handler.`,\n );\n }\n\n let relativePathToRoutes = path.relative(\n monoriseOutputDir,\n absoluteCustomRoutesPath,\n );\n relativePathToRoutes = relativePathToRoutes.replace(\n /\\.(ts|js|mjs|cjs)$/,\n '',\n );\n\n // If custom routes are provided, include the import statement and pass 'routes' to appHandler\n routesImportLine = `import routes from '${relativePathToRoutes}';`;\n appHandlerPayload = '{ routes }';\n }\n // If customRoutesPath is not provided, routesImportLine remains empty and appHandlerPayload remains `{}`\n\n // Detect whether the consumer uses the combined 'monorise' package or scoped '@monorise/*' packages\n const usesCombinedPackage = fs.existsSync(path.join(projectRoot, 'node_modules', 'monorise'));\n const coreImportPath = usesCombinedPackage ? 'monorise/core' : '@monorise/core';\n\n const combinedContent = `\nimport CoreFactory from '${coreImportPath}';\nimport config from './config';\n${routesImportLine ? `${routesImportLine}\\n` : ''}const coreFactory = new CoreFactory(config);\n\nexport const replicationHandler = coreFactory.replicationProcessor;\nexport const mutualHandler = coreFactory.mutualProcessor;\nexport const tagHandler = coreFactory.tagProcessor;\nexport const treeHandler = coreFactory.prejoinProcessor;\nexport const appHandler = coreFactory.appHandler(${appHandlerPayload});\n`;\n fs.writeFileSync(handleOutputPath, combinedContent);\n console.log('Successfully generated handle.ts!');\n\n return handleOutputPath;\n}\n\nasync function generateFiles(rootPath?: string): Promise<string> {\n const baseDir = rootPath ? path.resolve(rootPath) : process.cwd();\n const configFilePathTS = path.join(baseDir, 'monorise.config.ts');\n const configFilePathJS = path.join(baseDir, 'monorise.config.js');\n\n let configFilePath: string;\n if (fs.existsSync(configFilePathTS)) {\n configFilePath = configFilePathTS;\n } else if (fs.existsSync(configFilePathJS)) {\n configFilePath = configFilePathJS;\n } else {\n throw new Error(\n 'Neither monorise.config.ts nor monorise.config.js found in the root of the project.',\n );\n }\n\n const projectRoot = path.dirname(configFilePath);\n const monoriseConfigModule = await import(configFilePath);\n const monoriseConfig = monoriseConfigModule.default;\n\n const configDir = path.resolve(projectRoot, monoriseConfig.configDir);\n const monoriseOutputDir = path.join(projectRoot, '.monorise');\n\n fs.mkdirSync(monoriseOutputDir, { recursive: true });\n\n await generateConfigFile(configDir, monoriseOutputDir, projectRoot);\n await generateHandleFile(monoriseConfig, projectRoot, monoriseOutputDir);\n\n return configDir;\n}\n\nconst MONORISE_LOGO = `\n\n\n\n ░░░░░░░\n ░░▒▒▒░░░░░░▒▒▒░\n ░▒▒░ ░▒▒░\n ░▒▒░ ░▒▒░\n ░▒░ ░▒▒░\n ░▒▒░ ▒▒▒░\n ░▒░░░▒░ ░▒░░▒▒░\n ░▒▒░ ░▒▒▒░ ░▒▒░ ░▒░░\n ░▒▒ ░▒▒░ ░▒▒░ ░▒░ ░▒░ ░▒░\n ░▒▒░ ░▒░ ░▒░░▒▒░░░ ░░▒▒░░▒░ ░▒▒ ░▒░\n ░░▒░ ░▒░ ░▒░ ░▒▒░░▒▒▒▒▒▒░░▒░ ░▒░░ ░▒░ ░▒░\n ░▒░ ░░▒░ ░▒░ ░░░ ░▒░ ░░ ░▒░ ░▒░ ░▒░░ ░░▒░\n ░▒░ ░▒░ ░▒░ ░▒ ░░ ░▒░ ░▒░ ░▒░ ░▒░ ░░░░\n ░░░ ░░░░ ░░░ ░░ ▒░ ░░░ ░░░ ░░░ ░░░ ░░░░\n ░░░ ░░░░ ░░░ ░░░ ░░░ ░░ ░░░ ░░░ ░░░ ░░░░\n ░░░ ░░░ ░░░ ░░░ ░░ ░░ ░░░ ░░░ ░░░ ░░░\n ░░░ ░░░░ ░░░ ░░░ ░░ ░░░ ░░ ░░░ ░░░ ░░░\n ░░ ░░░ ░░░ ░░░ ░░░ ░░ ░░░ ░░░ ░░░ ░░░\n ░░ ░░ ░░ ░░ ░░ ░░░ ░░░ ░░░ ░░░░ ░░░\n ░░░ ░░ ░░░ ░░░ ░░░\n ░░░░░▒░░░░░░░░░▒░░░░░░░░░ ░ ░░ ░░░ ░░░ ░░\n ░░░ ░░░░░░░░░ ░░░ ░░░\n ░░░ ░░░░░░ ░░ ░░░░░▒░░░░░░▒░░░░\n ░░░░░░░░░░░░░░░░░ ░░░░░ ░░░░░░░░ ░░\n ░░░░░░░ ░░░░░░░░░░░░░░ ░░░░ ░░░░░ ░▒░\n ░░░ ░░░░░░░ ░░░░░░ ░░░░░░░░\n ░░░░░░░░░░░░ ░░░░░░ ░░░░ ░░░░░░░░░░░░░\n ░▒▒░░░░░░░░░░░▒▒░░ ░░▒▒▒░░ ░▒▒░░ ░░░░\n ░▒░ ░░▒▒░ ░▒░ ░▒▒░ ░░▒░\n ░▒░ ░░░░▒▒▒▒▒▒▒▒▒▒░░ ░▒░ ▒▒░ ░░▒▒▒░\n ░▒▒▒▒▒░░░ ░░░▒▒▒▒▒░ ▒▒░ ░▒▒▒▒▒▒░\n ░▒▒░ ░▒▒▒▒ ▒▒▒ ▒▒▒\n ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░ ░▒▒▒▒▒░ ░▒▒\n ▒▒▒ ░░▒▒▒▒▒▒░ ▒▒▒ ░▒▒\n ▒▒▒ ░▒▒▒▒ ░▒▒▒░\n ▒▓▓▓▒▒▒▓▓▒▒▒░ ▒▒▒░░▒▒░\n ▒▓░ ░▒▒▓▓▒░ ▒▓▓░\n ░▒▓░ ░▒▓▒░▒▓▒\n ░▒▓▒░ ░▒▓▓▒\n ░▒▒▓▓▓▓▓▓▒▒░\n\n\n\n`;\n\nasync function runInitCommand(rootPath?: string) {\n const projectRoot = rootPath ? path.resolve(rootPath) : process.cwd();\n console.log(MONORISE_LOGO);\n console.log(`Initializing Monorise project in ${projectRoot}...`);\n\n // 1. Create monorise.config.ts\n const monoriseConfigTsPath = path.join(projectRoot, 'monorise.config.ts');\n const monoriseConfigContent = `\nconst config = {\n configDir: './monorise/entities',\n // custom route file should export default an Hono object.\n // customRoutes: './path/to/custom/routes.ts'\n};\n\nexport default config;\n`;\n if (!fs.existsSync(monoriseConfigTsPath)) {\n fs.writeFileSync(monoriseConfigTsPath, monoriseConfigContent.trimStart());\n console.log(`Created ${path.relative(projectRoot, monoriseConfigTsPath)}`);\n } else {\n console.log(\n `${path.relative(projectRoot, monoriseConfigTsPath)} already exists. Skipping.`,\n );\n }\n\n // 2. Create ./monorise/entities/user.ts\n const monoriseEntitiesDir = path.join(projectRoot, 'monorise', 'entities');\n fs.mkdirSync(monoriseEntitiesDir, { recursive: true });\n\n const userEntityTsPath = path.join(monoriseEntitiesDir, 'user.ts');\n const userEntityContent = `\nimport { createEntityConfig } from 'monorise/base';\nimport { z } from 'zod';\n\nconst baseSchema = z\n .object({\n displayName: z\n .string()\n .min(1, 'Please provide a name for this user account'),\n firstName: z.string().min(1, 'Please provide first name'),\n lastName: z.string().min(1, 'Please provide last name'),\n jobTitle: z.string(),\n })\n .partial();\n\nconst config = createEntityConfig({\n name: 'user',\n baseSchema,\n});\n\nexport default config;\n`;\n if (!fs.existsSync(userEntityTsPath)) {\n fs.writeFileSync(userEntityTsPath, userEntityContent.trimStart());\n console.log(`Created ${path.relative(projectRoot, userEntityTsPath)}`);\n } else {\n console.log(\n `${path.relative(projectRoot, userEntityTsPath)} already exists. Skipping.`,\n );\n }\n\n // 3. Update package.json\n const packageJsonPath = path.join(projectRoot, 'package.json');\n if (fs.existsSync(packageJsonPath)) {\n try {\n const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf8');\n const packageJson = JSON.parse(packageJsonContent);\n\n if (packageJson.type !== 'module') {\n packageJson.type = 'module';\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));\n console.log(\n `Updated 'type' to 'module' in ${path.relative(projectRoot, packageJsonPath)}`,\n );\n } else {\n console.log(\n `'type: \"module\"' already set in ${path.relative(projectRoot, packageJsonPath)}. Skipping.`,\n );\n }\n } catch (error) {\n console.error(\n `Error reading or parsing ${path.relative(projectRoot, packageJsonPath)}:`,\n error,\n );\n }\n } else {\n console.warn(\n `Warning: ${path.relative(projectRoot, packageJsonPath)} not found. Cannot update 'type'.`,\n );\n }\n\n // 4. Add tsconfig path alias for .monorise directory\n const tsconfigPath = path.join(projectRoot, 'tsconfig.json');\n if (fs.existsSync(tsconfigPath)) {\n try {\n const tsconfigContent = fs.readFileSync(tsconfigPath, 'utf8');\n const tsconfig = JSON.parse(tsconfigContent);\n\n if (!tsconfig.compilerOptions) {\n tsconfig.compilerOptions = {};\n }\n if (!tsconfig.compilerOptions.paths) {\n tsconfig.compilerOptions.paths = {};\n }\n\n const pathKey = '#/monorise/*';\n const pathValue = ['./.monorise/*'];\n\n if (!tsconfig.compilerOptions.paths[pathKey]) {\n tsconfig.compilerOptions.paths[pathKey] = pathValue;\n fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2));\n console.log(\n `Added '${pathKey}' path alias in ${path.relative(projectRoot, tsconfigPath)}`,\n );\n } else {\n console.log(\n `'${pathKey}' path alias already set in ${path.relative(projectRoot, tsconfigPath)}. Skipping.`,\n );\n }\n } catch (error) {\n console.error(\n `Error updating ${path.relative(projectRoot, tsconfigPath)}:`,\n error,\n );\n }\n } else {\n console.warn(\n `Warning: ${path.relative(projectRoot, tsconfigPath)} not found. Cannot add path alias.`,\n );\n }\n\n console.log('Monorise initialization complete!');\n}\n\nasync function runDevCommand(configDir: string, rootPath?: string) {\n console.log(MONORISE_LOGO);\n console.log(`Watching for changes in ${configDir}...`);\n const watcher = chokidar.watch(configDir, {\n ignored: (watchedPath: string) => {\n const fileName = path.basename(watchedPath);\n return (\n fileName === 'index.ts' || // Old name, still ignore in case it exists\n fileName === 'config.ts' || // Generated config file\n fileName === 'processors.ts' || // Generated processors file\n fileName === 'app.ts' || // Generated app file\n fileName.startsWith('.') ||\n watchedPath.endsWith('.js') ||\n watchedPath.endsWith('.jsx') ||\n watchedPath.endsWith('.d.ts')\n );\n },\n persistent: true,\n ignoreInitial: true,\n });\n\n watcher.on('add', async (filePath) => {\n console.log(`File ${filePath} has been added. Regenerating...`);\n try {\n await generateFiles(rootPath);\n } catch (err) {\n console.error('Regeneration failed:', err);\n }\n });\n\n watcher.on('change', async (filePath) => {\n console.log(`File ${filePath} has been changed. Regenerating...`);\n try {\n await generateFiles(rootPath);\n } catch (err) {\n console.error('Regeneration failed:', err);\n }\n });\n\n watcher.on('unlink', async (filePath) => {\n console.log(`File ${filePath} has been removed. Regenerating...`);\n try {\n await generateFiles(rootPath);\n } catch (err) {\n console.error('Regeneration failed:', err);\n }\n });\n\n process.on('SIGINT', () => {\n console.log('Monorise dev terminated. Closing watcher and sst dev...');\n watcher.close();\n process.exit(0);\n });\n process.on('SIGTERM', () => {\n console.log('Monorise dev terminated. Closing watcher and sst dev...');\n watcher.close();\n process.exit(0);\n });\n}\n\nasync function runBuildCommand(rootPath?: string) {\n console.log('Starting sst build...');\n await generateFiles(rootPath);\n}\n\nasync function main() {\n const args = process.argv.slice(2);\n const command = args[0];\n\n let rootPath: string | undefined;\n const rootFlagIndex = args.indexOf('--config-root');\n if (rootFlagIndex > -1 && args[rootFlagIndex + 1]) {\n rootPath = args[rootFlagIndex + 1];\n }\n\n try {\n if (command === 'dev') {\n const configDir = await generateFiles(rootPath);\n await runDevCommand(configDir, rootPath);\n } else if (command === 'build') {\n await runBuildCommand(rootPath);\n } else if (command === 'init') {\n await runInitCommand(rootPath);\n } else {\n console.error(\n 'Unknown command. Usage: monorise [dev|build|init] [--config-root <path>]',\n );\n process.exit(1);\n }\n } catch (err) {\n console.error('Monorise process failed:', err);\n process.exit(1);\n }\n}\n\nmain().catch((err) => {\n console.error('Monorise encountered an unhandled error:', err);\n process.exit(1);\n});\n"],"mappings":";;;AAEA,OAAO;AACP,OAAO;AACP,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,cAAc;AAErB,SAAS,aAAa,KAAqB;AACzC,SAAO,IAAI,QAAQ,aAAa,CAAC,GAAG,WAAW,OAAO,YAAY,CAAC;AACr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,EACF,SAAS,KAAK;AACZ,YAAQ,MAAM,4BAA4B,GAAG;AAC7C,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,UAAQ,MAAM,4CAA4C,GAAG;AAC7D,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
@@ -1,4 +1,4 @@
1
- import { Entity as Entity$2, EntitySchemaMap, createEntityConfig } from '@monorise/base';
1
+ import { Entity as Entity$2, EntitySchemaMap, createEntityConfig } from '../base/index';
2
2
  import * as hono from 'hono';
3
3
  import { Hono } from 'hono';
4
4
  import { DynamoDB, TransactWriteItemsInput, AttributeValue, TransactWriteItem, UpdateItemCommandInput } from '@aws-sdk/client-dynamodb';
@@ -465,7 +465,7 @@ new EventBridgeClient();
465
465
  // middlewares/general-error-handler.ts
466
466
  createFactory();
467
467
 
468
- // ../../node_modules/zod/dist/esm/v3/external.js
468
+ // ../../node_modules/zod/v3/external.js
469
469
  var external_exports = {};
470
470
  __export(external_exports, {
471
471
  BRAND: () => BRAND,
@@ -577,7 +577,7 @@ __export(external_exports, {
577
577
  void: () => voidType
578
578
  });
579
579
 
580
- // ../../node_modules/zod/dist/esm/v3/helpers/util.js
580
+ // ../../node_modules/zod/v3/helpers/util.js
581
581
  var util;
582
582
  (function(util2) {
583
583
  util2.assertEqual = (_) => {
@@ -707,7 +707,7 @@ var getParsedType = (data) => {
707
707
  }
708
708
  };
709
709
 
710
- // ../../node_modules/zod/dist/esm/v3/ZodError.js
710
+ // ../../node_modules/zod/v3/ZodError.js
711
711
  var ZodIssueCode = util.arrayToEnum([
712
712
  "invalid_type",
713
713
  "invalid_literal",
@@ -807,8 +807,9 @@ var ZodError = class _ZodError extends Error {
807
807
  const formErrors = [];
808
808
  for (const sub of this.issues) {
809
809
  if (sub.path.length > 0) {
810
- fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
811
- fieldErrors[sub.path[0]].push(mapper(sub));
810
+ const firstEl = sub.path[0];
811
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
812
+ fieldErrors[firstEl].push(mapper(sub));
812
813
  } else {
813
814
  formErrors.push(mapper(sub));
814
815
  }
@@ -824,7 +825,7 @@ ZodError.create = (issues) => {
824
825
  return error;
825
826
  };
826
827
 
827
- // ../../node_modules/zod/dist/esm/v3/locales/en.js
828
+ // ../../node_modules/zod/v3/locales/en.js
828
829
  var errorMap = (issue, _ctx) => {
829
830
  let message;
830
831
  switch (issue.code) {
@@ -886,6 +887,8 @@ var errorMap = (issue, _ctx) => {
886
887
  message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
887
888
  else if (issue.type === "number")
888
889
  message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
890
+ else if (issue.type === "bigint")
891
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
889
892
  else if (issue.type === "date")
890
893
  message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
891
894
  else
@@ -925,7 +928,7 @@ var errorMap = (issue, _ctx) => {
925
928
  };
926
929
  var en_default = errorMap;
927
930
 
928
- // ../../node_modules/zod/dist/esm/v3/errors.js
931
+ // ../../node_modules/zod/v3/errors.js
929
932
  var overrideErrorMap = en_default;
930
933
  function setErrorMap(map) {
931
934
  overrideErrorMap = map;
@@ -934,7 +937,7 @@ function getErrorMap() {
934
937
  return overrideErrorMap;
935
938
  }
936
939
 
937
- // ../../node_modules/zod/dist/esm/v3/helpers/parseUtil.js
940
+ // ../../node_modules/zod/v3/helpers/parseUtil.js
938
941
  var makeIssue = (params) => {
939
942
  const { data, path, errorMaps, issueData } = params;
940
943
  const fullPath = [...path, ...issueData.path || []];
@@ -1043,14 +1046,14 @@ var isDirty = (x) => x.status === "dirty";
1043
1046
  var isValid = (x) => x.status === "valid";
1044
1047
  var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
1045
1048
 
1046
- // ../../node_modules/zod/dist/esm/v3/helpers/errorUtil.js
1049
+ // ../../node_modules/zod/v3/helpers/errorUtil.js
1047
1050
  var errorUtil;
1048
1051
  (function(errorUtil2) {
1049
1052
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
1050
1053
  errorUtil2.toString = (message) => typeof message === "string" ? message : message == null ? void 0 : message.message;
1051
1054
  })(errorUtil || (errorUtil = {}));
1052
1055
 
1053
- // ../../node_modules/zod/dist/esm/v3/types.js
1056
+ // ../../node_modules/zod/v3/types.js
1054
1057
  var ParseInputLazyPath = class {
1055
1058
  constructor(parent, value, path, key) {
1056
1059
  this._cachedPath = [];
@@ -1450,6 +1453,8 @@ function isValidJWT(jwt, alg) {
1450
1453
  return false;
1451
1454
  try {
1452
1455
  const [header] = jwt.split(".");
1456
+ if (!header)
1457
+ return false;
1453
1458
  const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
1454
1459
  const decoded = JSON.parse(atob(base64));
1455
1460
  if (typeof decoded !== "object" || decoded === null)
@@ -2975,7 +2975,7 @@ var GetEntityController = class {
2975
2975
  // controllers/entity/list-entities.controller.ts
2976
2976
  import { createMiddleware as createMiddleware7 } from "hono/factory";
2977
2977
 
2978
- // ../../node_modules/zod/dist/esm/v3/external.js
2978
+ // ../../node_modules/zod/v3/external.js
2979
2979
  var external_exports = {};
2980
2980
  __export(external_exports, {
2981
2981
  BRAND: () => BRAND,
@@ -3087,7 +3087,7 @@ __export(external_exports, {
3087
3087
  void: () => voidType
3088
3088
  });
3089
3089
 
3090
- // ../../node_modules/zod/dist/esm/v3/helpers/util.js
3090
+ // ../../node_modules/zod/v3/helpers/util.js
3091
3091
  var util;
3092
3092
  (function(util2) {
3093
3093
  util2.assertEqual = (_) => {
@@ -3217,7 +3217,7 @@ var getParsedType = (data) => {
3217
3217
  }
3218
3218
  };
3219
3219
 
3220
- // ../../node_modules/zod/dist/esm/v3/ZodError.js
3220
+ // ../../node_modules/zod/v3/ZodError.js
3221
3221
  var ZodIssueCode = util.arrayToEnum([
3222
3222
  "invalid_type",
3223
3223
  "invalid_literal",
@@ -3317,8 +3317,9 @@ var ZodError = class _ZodError extends Error {
3317
3317
  const formErrors = [];
3318
3318
  for (const sub of this.issues) {
3319
3319
  if (sub.path.length > 0) {
3320
- fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
3321
- fieldErrors[sub.path[0]].push(mapper(sub));
3320
+ const firstEl = sub.path[0];
3321
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
3322
+ fieldErrors[firstEl].push(mapper(sub));
3322
3323
  } else {
3323
3324
  formErrors.push(mapper(sub));
3324
3325
  }
@@ -3334,7 +3335,7 @@ ZodError.create = (issues) => {
3334
3335
  return error;
3335
3336
  };
3336
3337
 
3337
- // ../../node_modules/zod/dist/esm/v3/locales/en.js
3338
+ // ../../node_modules/zod/v3/locales/en.js
3338
3339
  var errorMap = (issue, _ctx) => {
3339
3340
  let message;
3340
3341
  switch (issue.code) {
@@ -3396,6 +3397,8 @@ var errorMap = (issue, _ctx) => {
3396
3397
  message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
3397
3398
  else if (issue.type === "number")
3398
3399
  message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
3400
+ else if (issue.type === "bigint")
3401
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
3399
3402
  else if (issue.type === "date")
3400
3403
  message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
3401
3404
  else
@@ -3435,7 +3438,7 @@ var errorMap = (issue, _ctx) => {
3435
3438
  };
3436
3439
  var en_default = errorMap;
3437
3440
 
3438
- // ../../node_modules/zod/dist/esm/v3/errors.js
3441
+ // ../../node_modules/zod/v3/errors.js
3439
3442
  var overrideErrorMap = en_default;
3440
3443
  function setErrorMap(map) {
3441
3444
  overrideErrorMap = map;
@@ -3444,7 +3447,7 @@ function getErrorMap() {
3444
3447
  return overrideErrorMap;
3445
3448
  }
3446
3449
 
3447
- // ../../node_modules/zod/dist/esm/v3/helpers/parseUtil.js
3450
+ // ../../node_modules/zod/v3/helpers/parseUtil.js
3448
3451
  var makeIssue = (params) => {
3449
3452
  const { data, path, errorMaps, issueData } = params;
3450
3453
  const fullPath = [...path, ...issueData.path || []];
@@ -3553,14 +3556,14 @@ var isDirty = (x) => x.status === "dirty";
3553
3556
  var isValid = (x) => x.status === "valid";
3554
3557
  var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
3555
3558
 
3556
- // ../../node_modules/zod/dist/esm/v3/helpers/errorUtil.js
3559
+ // ../../node_modules/zod/v3/helpers/errorUtil.js
3557
3560
  var errorUtil;
3558
3561
  (function(errorUtil2) {
3559
3562
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
3560
3563
  errorUtil2.toString = (message) => typeof message === "string" ? message : message == null ? void 0 : message.message;
3561
3564
  })(errorUtil || (errorUtil = {}));
3562
3565
 
3563
- // ../../node_modules/zod/dist/esm/v3/types.js
3566
+ // ../../node_modules/zod/v3/types.js
3564
3567
  var ParseInputLazyPath = class {
3565
3568
  constructor(parent, value, path, key) {
3566
3569
  this._cachedPath = [];
@@ -3960,6 +3963,8 @@ function isValidJWT(jwt, alg) {
3960
3963
  return false;
3961
3964
  try {
3962
3965
  const [header] = jwt.split(".");
3966
+ if (!header)
3967
+ return false;
3963
3968
  const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
3964
3969
  const decoded = JSON.parse(atob(base64));
3965
3970
  if (typeof decoded !== "object" || decoded === null)