@pattern-stack/codegen 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +9 -4
  2. package/dist/src/cli/index.js +136 -128
  3. package/dist/src/cli/index.js.map +1 -1
  4. package/dist/src/index.d.ts +16 -0
  5. package/dist/src/index.js +25 -0
  6. package/dist/src/index.js.map +1 -1
  7. package/package.json +10 -1
  8. package/templates/entity/new/backend/application/commands/create.ejs.t +38 -1
  9. package/templates/entity/new/backend/application/commands/delete.ejs.t +41 -1
  10. package/templates/entity/new/backend/application/commands/update.ejs.t +42 -1
  11. package/templates/entity/new/backend/database/repository.ejs.t +33 -3
  12. package/templates/entity/new/backend/domain/repository-interface.ejs.t +6 -3
  13. package/templates/entity/new/backend/modules/core/module.ejs.t +6 -0
  14. package/templates/entity/new/backend/presentation/controller.ejs.t +32 -10
  15. package/templates/entity/new/clean-lite-ps/controller.ejs.t +72 -11
  16. package/templates/entity/new/clean-lite-ps/entity.ejs.t +16 -2
  17. package/templates/entity/new/clean-lite-ps/index.ejs.t +1 -1
  18. package/templates/entity/new/clean-lite-ps/module.ejs.t +45 -2
  19. package/templates/entity/new/clean-lite-ps/prompt-extension.js +459 -98
  20. package/templates/entity/new/clean-lite-ps/repository.ejs.t +57 -4
  21. package/templates/entity/new/clean-lite-ps/search-controller.ejs.t +50 -0
  22. package/templates/entity/new/clean-lite-ps/service.ejs.t +98 -1
  23. package/templates/entity/new/clean-lite-ps/use-cases/create.ejs.t +150 -0
  24. package/templates/entity/new/clean-lite-ps/use-cases/delete.ejs.t +70 -0
  25. package/templates/entity/new/clean-lite-ps/use-cases/find-by-id-with-fields.ejs.t +19 -0
  26. package/templates/entity/new/clean-lite-ps/use-cases/find-by-id.ejs.t +7 -3
  27. package/templates/entity/new/clean-lite-ps/use-cases/list-with-fields.ejs.t +17 -0
  28. package/templates/entity/new/clean-lite-ps/use-cases/search.ejs.t +63 -0
  29. package/templates/entity/new/clean-lite-ps/use-cases/update.ejs.t +153 -0
  30. package/templates/entity/new/prompt.js +284 -41
  31. package/templates/relationship/new/entity.ejs.t +2 -2
  32. package/templates/relationship/new/prompt.js +3 -7
  33. package/templates/relationship/new/service.ejs.t +1 -1
  34. package/templates/subsystem/bridge/generated-keep.ejs.t +4 -0
  35. package/templates/subsystem/bridge/prompt.js +36 -0
  36. package/templates/subsystem/bridge-config/codegen-config-bridge-block.ejs.t +20 -0
  37. package/templates/subsystem/bridge-config/prompt.js +20 -0
  38. package/templates/subsystem/events/domain-events.schema.ejs.t +81 -0
  39. package/templates/subsystem/events/generated-keep.ejs.t +4 -0
  40. package/templates/subsystem/events/prompt.js +39 -0
  41. package/templates/subsystem/events-config/codegen-config-events-block.ejs.t +26 -0
  42. package/templates/subsystem/events-config/prompt.js +20 -0
  43. package/templates/subsystem/jobs/job-orchestration.schema.ejs.t +221 -0
  44. package/templates/subsystem/jobs/main-hook.ejs.t +11 -0
  45. package/templates/subsystem/jobs/prompt.js +40 -0
  46. package/templates/subsystem/jobs/worker.ejs.t +82 -0
  47. package/templates/subsystem/jobs-config/codegen-config-jobs-block.ejs.t +55 -0
  48. package/templates/subsystem/jobs-config/prompt.js +20 -0
  49. package/templates/subsystem/sync/prompt.js +43 -0
  50. package/templates/subsystem/sync/sync-audit.schema.ejs.t +195 -0
  51. package/templates/subsystem/sync-config/codegen-config-sync-block.ejs.t +29 -0
  52. package/templates/subsystem/sync-config/prompt.js +22 -0
@@ -1305,6 +1305,14 @@ declare const EntityDefinitionSchema: z.ZodObject<{
1305
1305
  name: string;
1306
1306
  options?: Record<string, unknown> | undefined;
1307
1307
  }>]>, "many">>>;
1308
+ generate: z.ZodOptional<z.ZodObject<{
1309
+ writes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1310
+ }, "strict", z.ZodTypeAny, {
1311
+ writes: boolean;
1312
+ }, {
1313
+ writes?: boolean | undefined;
1314
+ }>>;
1315
+ eav: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1308
1316
  queries: z.ZodOptional<z.ZodArray<z.ZodObject<{
1309
1317
  by: z.ZodArray<z.ZodString, "many">;
1310
1318
  unique: z.ZodOptional<z.ZodBoolean>;
@@ -1688,6 +1696,7 @@ declare const EntityDefinitionSchema: z.ZodObject<{
1688
1696
  name: string;
1689
1697
  options?: Record<string, unknown> | undefined;
1690
1698
  })[];
1699
+ eav: boolean;
1691
1700
  relationships?: Record<string, {
1692
1701
  type: "belongs_to" | "has_many" | "has_one";
1693
1702
  foreign_key: string;
@@ -1695,6 +1704,9 @@ declare const EntityDefinitionSchema: z.ZodObject<{
1695
1704
  through?: string | undefined;
1696
1705
  inverse?: string | undefined;
1697
1706
  }> | undefined;
1707
+ generate?: {
1708
+ writes: boolean;
1709
+ } | undefined;
1698
1710
  queries?: {
1699
1711
  by: string[];
1700
1712
  unique?: boolean | undefined;
@@ -1831,6 +1843,10 @@ declare const EntityDefinitionSchema: z.ZodObject<{
1831
1843
  name: string;
1832
1844
  options?: Record<string, unknown> | undefined;
1833
1845
  })[] | undefined;
1846
+ generate?: {
1847
+ writes?: boolean | undefined;
1848
+ } | undefined;
1849
+ eav?: boolean | undefined;
1834
1850
  queries?: {
1835
1851
  by: string[];
1836
1852
  unique?: boolean | undefined;
package/dist/src/index.js CHANGED
@@ -337,12 +337,37 @@ var AnalyticsBlockSchema = z.object({
337
337
  cube_name: z.string().optional(),
338
338
  metrics: z.record(z.string(), MetricDefinitionSchema).optional()
339
339
  });
340
+ var GenerateConfigSchema = z.object({
341
+ writes: z.boolean().optional().default(true)
342
+ }).strict();
340
343
  var EntityDefinitionSchema = z.object({
341
344
  entity: EntityConfigSchema,
342
345
  fields: z.record(z.string(), FieldDefinitionSchema),
343
346
  relationships: z.record(z.string(), RelationshipSchema).optional(),
344
347
  // Behaviors add cross-cutting concerns (timestamps, soft_delete, user_tracking, etc.)
345
348
  behaviors: z.array(BehaviorConfigSchema).optional().default([]),
349
+ // Per-entity generation toggles (e.g. disable write-side emission)
350
+ generate: GenerateConfigSchema.optional(),
351
+ // EAV (entity-attribute-value) dual-write + paired reads (ADR-13).
352
+ // When `true`, codegen emits:
353
+ // - FindXWithFieldsUseCase + ListXWithFieldsUseCase (paired reads)
354
+ // - CreateX / UpdateX use cases in transactional compound-write shape
355
+ // (composes entity service + FieldValueService in one db.transaction,
356
+ // splits `{ fields, ...core }` from the DTO)
357
+ // - GET /:id/with-fields + GET /with-fields controller routes
358
+ // - Service with injected FieldValueRepository + findByIdWithFields /
359
+ // listWithFields paired read methods
360
+ //
361
+ // Consumer contract (must be in place before regen):
362
+ // - BaseService.create/update/delete accept optional `tx` parameter
363
+ // - `@shared/eav-helpers` exports `toEavRows(entityId, entityType, fields)`
364
+ // and `mergeEavRows(rows)`
365
+ // - FieldValueService exposes `upsertMany(rows, tx?)` (inherited from
366
+ // MetadataEntityService)
367
+ // - DRIZZLE_DB injection token available via `@shared/constants/tokens`
368
+ //
369
+ // Defaults to `false` — opt in per entity that needs dynamic/custom fields.
370
+ eav: z.boolean().optional().default(false),
346
371
  // v2: Declarative query generation (ADR-005)
347
372
  // Generates repository + service + use case methods from declarations
348
373
  queries: z.array(QueryDeclarationSchema).optional(),