prisma-effect-kysely 1.10.0 → 1.12.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 (44) hide show
  1. package/dist/effect/generator.d.ts +4 -0
  2. package/dist/effect/generator.d.ts.map +1 -1
  3. package/dist/effect/generator.js +7 -0
  4. package/dist/effect/generator.js.map +1 -1
  5. package/dist/effect/join-table.d.ts +4 -0
  6. package/dist/effect/join-table.d.ts.map +1 -1
  7. package/dist/effect/join-table.js +16 -0
  8. package/dist/effect/join-table.js.map +1 -1
  9. package/dist/effect/type.d.ts +1 -1
  10. package/dist/effect/type.d.ts.map +1 -1
  11. package/dist/effect/type.js +18 -12
  12. package/dist/effect/type.js.map +1 -1
  13. package/dist/generator/config.d.ts +58 -0
  14. package/dist/generator/config.d.ts.map +1 -0
  15. package/dist/generator/config.js +109 -0
  16. package/dist/generator/config.js.map +1 -0
  17. package/dist/generator/contract-scaffolder.d.ts +45 -0
  18. package/dist/generator/contract-scaffolder.d.ts.map +1 -0
  19. package/dist/generator/contract-scaffolder.js +244 -0
  20. package/dist/generator/contract-scaffolder.js.map +1 -0
  21. package/dist/generator/domain-detector.d.ts +50 -0
  22. package/dist/generator/domain-detector.d.ts.map +1 -0
  23. package/dist/generator/domain-detector.js +187 -0
  24. package/dist/generator/domain-detector.js.map +1 -0
  25. package/dist/generator/orchestrator.d.ts +24 -4
  26. package/dist/generator/orchestrator.d.ts.map +1 -1
  27. package/dist/generator/orchestrator.js +139 -21
  28. package/dist/generator/orchestrator.js.map +1 -1
  29. package/dist/kysely/generator.d.ts +4 -0
  30. package/dist/kysely/generator.d.ts.map +1 -1
  31. package/dist/kysely/generator.js +6 -0
  32. package/dist/kysely/generator.js.map +1 -1
  33. package/dist/kysely/helpers.d.ts +5 -1
  34. package/dist/kysely/helpers.d.ts.map +1 -1
  35. package/dist/kysely/helpers.js +54 -27
  36. package/dist/kysely/helpers.js.map +1 -1
  37. package/dist/kysely/type.d.ts +19 -2
  38. package/dist/kysely/type.d.ts.map +1 -1
  39. package/dist/kysely/type.js +82 -4
  40. package/dist/kysely/type.js.map +1 -1
  41. package/dist/utils/annotations.d.ts.map +1 -1
  42. package/dist/utils/codegen.d.ts.map +1 -1
  43. package/dist/utils/naming.d.ts.map +1 -1
  44. package/package.json +16 -13
@@ -38,5 +38,9 @@ export declare class EffectGenerator {
38
38
  * Generate schemas for all join tables
39
39
  */
40
40
  generateJoinTableSchemas(joinTables: JoinTableInfo[]): string;
41
+ /**
42
+ * Generate Kysely table interfaces for join tables
43
+ */
44
+ generateJoinTableKyselyInterfaces(joinTables: JoinTableInfo[]): string;
41
45
  }
42
46
  //# sourceMappingURL=generator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/effect/generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAMrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;GAEG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,IAAI,CAAC,QAAQ;IAEhD;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,SAAS,IAAI,CAAC,aAAa,EAAE;IAIlD;;OAEG;IACH,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE;IAgBnE;;OAEG;IACH,0BAA0B,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK;IAO5C;;;;OAIG;IACH,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE;IAgBrE;;OAEG;IACH,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE;IAQ3D;;;;OAIG;IACH,mBAAmB,CAAC,QAAQ,EAAE,OAAO;IAyBrC;;OAEG;IACH,wBAAwB,CAAC,UAAU,EAAE,aAAa,EAAE;CAGrD"}
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/effect/generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAMrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;GAEG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,IAAI,CAAC,QAAQ;IAEhD;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,SAAS,IAAI,CAAC,aAAa,EAAE;IAIlD;;OAEG;IACH,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE;IAgBnE;;OAEG;IACH,0BAA0B,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK;IAO5C;;;;OAIG;IACH,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE;IAgBrE;;OAEG;IACH,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE;IAQ3D;;;;OAIG;IACH,mBAAmB,CAAC,QAAQ,EAAE,OAAO;IA0BrC;;OAEG;IACH,wBAAwB,CAAC,UAAU,EAAE,aAAa,EAAE;IAIpD;;OAEG;IACH,iCAAiC,CAAC,UAAU,EAAE,aAAa,EAAE;CAG9D"}
@@ -78,6 +78,7 @@ export type ${name}UpdateEncoded = Schema.Schema.Encoded<typeof ${name}.Updateab
78
78
  const header = (0, codegen_1.generateFileHeader)();
79
79
  const imports = [
80
80
  `import { Schema } from "effect";`,
81
+ `import type { ColumnType } from "kysely";`,
81
82
  `import { columnType, generated, getSchemas } from "prisma-effect-kysely";`,
82
83
  ];
83
84
  if (hasEnums) {
@@ -100,6 +101,12 @@ export type ${name}UpdateEncoded = Schema.Schema.Encoded<typeof ${name}.Updateab
100
101
  generateJoinTableSchemas(joinTables) {
101
102
  return joinTables.map((jt) => (0, join_table_1.generateJoinTableSchema)(jt, this.dmmf)).join('\n\n');
102
103
  }
104
+ /**
105
+ * Generate Kysely table interfaces for join tables
106
+ */
107
+ generateJoinTableKyselyInterfaces(joinTables) {
108
+ return joinTables.map(join_table_1.generateJoinTableKyselyInterface).join('\n\n');
109
+ }
103
110
  }
104
111
  exports.EffectGenerator = EffectGenerator;
105
112
  //# sourceMappingURL=generator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/effect/generator.ts"],"names":[],"mappings":";;;AACA,iCAA2C;AAC3C,iCAAwC;AACxC,4CAA+C;AAC/C,8CAAsD;AACtD,6CAAuD;AAGvD;;GAEG;AACH,MAAa,eAAe;IAC1B,YAA6B,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAEpD;;OAEG;IACH,aAAa,CAAC,KAAoC;QAChD,OAAO,IAAA,wBAAiB,EAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,kBAAkB,CAAC,KAAiB,EAAE,MAA6B;QACjE,MAAM,gBAAgB,GAAG,MAAM;aAC5B,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACb,MAAM,SAAS,GAAG,IAAA,qBAAc,EAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACnD,OAAO,KAAK,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACzC,CAAC,CAAC;aACD,IAAI,CAAC,KAAK,CAAC,CAAC;QAEf,MAAM,cAAc,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;QAExC,OAAO,MAAM,KAAK,CAAC,IAAI;eACZ,cAAc;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C;IACvE,CAAC;CACF;AAnHD,0CAmHC"}
@@ -1,5 +1,9 @@
1
1
  import type { DMMF } from '@prisma/generator-helper';
2
2
  import type { JoinTableInfo } from '../prisma/relation';
3
+ /**
4
+ * Generate Kysely table interface for a join table
5
+ */
6
+ export declare function generateJoinTableKyselyInterface(joinTable: JoinTableInfo): string;
3
7
  /**
4
8
  * Generate Effect Schema for an implicit many-to-many join table
5
9
  *
@@ -1 +1 @@
1
- {"version":3,"file":"join-table.d.ts","sourceRoot":"","sources":["../../src/effect/join-table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAqBxD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,GAAG,MAAM,CAgD9F"}
1
+ {"version":3,"file":"join-table.d.ts","sourceRoot":"","sources":["../../src/effect/join-table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD;;GAEG;AACH,wBAAgB,gCAAgC,CAAC,SAAS,EAAE,aAAa,UAcxE;AAoBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,UAgDrF"}
@@ -1,7 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateJoinTableKyselyInterface = generateJoinTableKyselyInterface;
3
4
  exports.generateJoinTableSchema = generateJoinTableSchema;
4
5
  const naming_1 = require("../utils/naming");
6
+ /**
7
+ * Generate Kysely table interface for a join table
8
+ */
9
+ function generateJoinTableKyselyInterface(joinTable) {
10
+ const { relationName, modelA, modelB, columnAIsUuid, columnBIsUuid } = joinTable;
11
+ const modelAField = (0, naming_1.toSnakeCase)(modelA);
12
+ const modelBField = (0, naming_1.toSnakeCase)(modelB);
13
+ const aType = columnAIsUuid ? 'string' : 'number';
14
+ const bType = columnBIsUuid ? 'string' : 'number';
15
+ return `// Kysely table interface for ${relationName}
16
+ export interface ${relationName}Table {
17
+ ${modelAField}: ColumnType<${aType}, never, never>;
18
+ ${modelBField}: ColumnType<${bType}, never, never>;
19
+ }`;
20
+ }
5
21
  /**
6
22
  * Map join table column type to Effect Schema type
7
23
  * Uses same mapping as regular fields
@@ -1 +1 @@
1
- {"version":3,"file":"join-table.js","sourceRoot":"","sources":["../../src/effect/join-table.ts"],"names":[],"mappings":";;AAoCA,0DAgDC;AAlFD,4CAA8C;AAE9C;;;GAGG;AACH,SAAS,aAAa,CAAC,UAAkB,EAAE,MAAe;IACxD,IAAI,UAAU,KAAK,QAAQ,IAAI,MAAM,EAAE,CAAC;QACtC,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,MAAM,SAAS,GAA2B;QACxC,MAAM,EAAE,eAAe;QACvB,GAAG,EAAE,eAAe;QACpB,MAAM,EAAE,eAAe;KACxB,CAAC;IAEF,OAAO,SAAS,CAAC,UAAU,CAAC,IAAI,gBAAgB,CAAC;AACnD,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,uBAAuB,CAAC,SAAwB,EAAE,KAAoB;IACpF,MAAM,EACJ,SAAS,EACT,YAAY,EACZ,MAAM,EACN,MAAM,EACN,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,GACd,GAAG,SAAS,CAAC;IAEd,0CAA0C;IAC1C,MAAM,aAAa,GAAG,aAAa,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAChE,MAAM,aAAa,GAAG,aAAa,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAEhE,4DAA4D;IAC5D,MAAM,WAAW,GAAG,GAAG,IAAA,oBAAW,EAAC,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,YAAY,GAAG,KAAK,WAAW,yCAAyC,aAAa,0DAA0D,CAAC;IAEtJ,uBAAuB;IACvB,MAAM,UAAU,GAAG,MAAM,SAAS;0BACV,MAAM,SAAS,MAAM;wBACvB,WAAW,KAAK,WAAW;gBACnC,YAAY;EAC1B,YAAY;EACZ,YAAY;IACV,CAAC;IAEH,+BAA+B;IAC/B,MAAM,iBAAiB,GAAG,gBAAgB,YAAY,kBAAkB,YAAY,IAAI,CAAC;IAEzF,wBAAwB;IACxB,MAAM,WAAW,GAAG,eAAe,YAAY,sCAAsC,YAAY;cACrF,YAAY,sCAAsC,YAAY;cAC9D,YAAY,sCAAsC,YAAY,eAAe,CAAC;IAE1F,gCAAgC;IAChC,MAAM,cAAc,GAAG,eAAe,YAAY,gDAAgD,YAAY;cAClG,YAAY,gDAAgD,YAAY;cACxE,YAAY,gDAAgD,YAAY,eAAe,CAAC;IAEpG,OAAO,GAAG,UAAU,OAAO,iBAAiB,OAAO,WAAW,KAAK,cAAc,EAAE,CAAC;AACtF,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { DMMF } from "@prisma/generator-helper";
1
+ import type { DMMF } from '@prisma/generator-helper';
2
2
  /**
3
3
  * Map Prisma field type to Effect Schema type
4
4
  * Priority order: annotation → UUID → scalar → enum → unknown fallback
@@ -1 +1 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/effect/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AA0BrD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,UA8B1E;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,UAcpE"}
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/effect/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AA2BrD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,UA6B1E;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,UAcpE"}
@@ -8,17 +8,23 @@ const naming_1 = require("../utils/naming");
8
8
  /**
9
9
  * Prisma scalar type mapping to Effect Schema types
10
10
  * Uses const assertion to avoid type guards
11
+ *
12
+ * Note: DateTime uses Schema.DateFromSelf (not Schema.Date) so that:
13
+ * - Type = Date (runtime)
14
+ * - Encoded = Date (database)
15
+ * This allows Kysely to work with native Date objects directly.
16
+ * Schema.Date would encode to string, requiring ISO string conversions.
11
17
  */
12
18
  const PRISMA_SCALAR_MAP = {
13
- String: "Schema.String",
14
- Int: "Schema.Number",
15
- Float: "Schema.Number",
16
- BigInt: "Schema.BigInt",
17
- Decimal: "Schema.String", // For precision
18
- Boolean: "Schema.Boolean",
19
- DateTime: "Schema.Date",
20
- Json: "Schema.Unknown", // Safe unknown type
21
- Bytes: "Schema.Uint8Array",
19
+ String: 'Schema.String',
20
+ Int: 'Schema.Number',
21
+ Float: 'Schema.Number',
22
+ BigInt: 'Schema.BigInt',
23
+ Decimal: 'Schema.String', // For precision
24
+ Boolean: 'Schema.Boolean',
25
+ DateTime: 'Schema.DateFromSelf', // Native Date type for Kysely compatibility
26
+ Json: 'Schema.Unknown', // Safe unknown type
27
+ Bytes: 'Schema.Uint8Array',
22
28
  };
23
29
  /**
24
30
  * Map Prisma field type to Effect Schema type
@@ -31,8 +37,8 @@ function mapFieldToEffectType(field, dmmf) {
31
37
  return typeOverride;
32
38
  }
33
39
  // PRIORITY 2: Handle String type with UUID detection
34
- if (field.type === "String" && (0, type_1.isUuidField)(field)) {
35
- return "Schema.UUID";
40
+ if (field.type === 'String' && (0, type_1.isUuidField)(field)) {
41
+ return 'Schema.UUID';
36
42
  }
37
43
  // PRIORITY 3: Handle scalar types with const assertion lookup
38
44
  const scalarType = PRISMA_SCALAR_MAP[field.type];
@@ -48,7 +54,7 @@ function mapFieldToEffectType(field, dmmf) {
48
54
  return (0, naming_1.toPascalCase)(field.type, 'Schema');
49
55
  }
50
56
  // PRIORITY 5: Fallback to Unknown
51
- return "Schema.Unknown";
57
+ return 'Schema.Unknown';
52
58
  }
53
59
  /**
54
60
  * Build complete field type with array and optional wrapping
@@ -1 +1 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/effect/type.ts"],"names":[],"mappings":";;AA8BA,oDA8BC;AAKD,wCAcC;AA9ED,yCAKwB;AACxB,sDAAiE;AACjE,4CAA+C;AAE/C;;;GAGG;AACH,MAAM,iBAAiB,GAAG;IACxB,MAAM,EAAE,eAAe;IACvB,GAAG,EAAE,eAAe;IACpB,KAAK,EAAE,eAAe;IACtB,MAAM,EAAE,eAAe;IACvB,OAAO,EAAE,eAAe,EAAE,gBAAgB;IAC1C,OAAO,EAAE,gBAAgB;IACzB,QAAQ,EAAE,aAAa;IACvB,IAAI,EAAE,gBAAgB,EAAE,oBAAoB;IAC5C,KAAK,EAAE,mBAAmB;CAClB,CAAC;AAEX;;;GAGG;AACH,SAAgB,oBAAoB,CAAC,KAAiB,EAAE,IAAmB;IACzE,+CAA+C;IAC/C,MAAM,YAAY,GAAG,IAAA,uCAAyB,EAAC,KAAK,CAAC,CAAC;IACtD,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,qDAAqD;IACrD,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAA,kBAAW,EAAC,KAAK,CAAC,EAAE,CAAC;QAClD,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,8DAA8D;IAC9D,MAAM,UAAU,GACd,iBAAiB,CAAC,KAAK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IAAA,kBAAW,EAAC,KAAK,CAAC,EAAE,CAAC;QACvB,QAAQ,GAAG,gBAAgB,QAAQ,GAAG,CAAC;IACzC,CAAC;IAED,4DAA4D;IAC5D,IAAI,CAAC,IAAA,sBAAe,EAAC,KAAK,CAAC,IAAI,CAAC,IAAA,sBAAe,EAAC,KAAK,CAAC,EAAE,CAAC;QACvD,QAAQ,GAAG,sBAAsB,QAAQ,GAAG,CAAC;IAC/C,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Generator Configuration
3
+ *
4
+ * Defines configuration options for prisma-effect-kysely generator
5
+ * with support for multi-domain organization and library scaffolding.
6
+ * Uses Effect Schema for strict validation.
7
+ */
8
+ import { Schema } from 'effect';
9
+ import type { GeneratorOptions } from '@prisma/generator-helper';
10
+ /**
11
+ * Generator configuration schema
12
+ */
13
+ declare const GeneratorConfigSchema: Schema.Struct<{
14
+ /**
15
+ * Output directory for generated Effect schemas
16
+ */
17
+ output: typeof Schema.String;
18
+ /**
19
+ * Enable multi-domain detection from schema file structure
20
+ */
21
+ multiFileDomains: Schema.Literal<["true", "false"]>;
22
+ /**
23
+ * Automatically scaffold contract libraries for detected domains
24
+ */
25
+ scaffoldLibraries: Schema.Literal<["true", "false"]>;
26
+ /**
27
+ * Path to monorepo-library-generator for library scaffolding
28
+ */
29
+ libraryGenerator: Schema.optional<typeof Schema.String>;
30
+ /**
31
+ * Preview features to enable
32
+ */
33
+ previewFeatures: Schema.Array$<typeof Schema.String>;
34
+ }>;
35
+ /**
36
+ * Generator configuration type derived from schema
37
+ */
38
+ export type GeneratorConfig = Schema.Schema.Type<typeof GeneratorConfigSchema>;
39
+ /**
40
+ * Parse and validate generator configuration from Prisma options
41
+ */
42
+ export declare function parseGeneratorConfig(options: GeneratorOptions): {
43
+ readonly output: string;
44
+ readonly multiFileDomains: "true" | "false";
45
+ readonly scaffoldLibraries: "true" | "false";
46
+ readonly libraryGenerator?: string | undefined;
47
+ readonly previewFeatures: readonly string[];
48
+ };
49
+ /**
50
+ * Check if multi-domain mode is enabled
51
+ */
52
+ export declare function isMultiDomainEnabled(config: GeneratorConfig): boolean;
53
+ /**
54
+ * Check if library scaffolding is enabled
55
+ */
56
+ export declare function isScaffoldingEnabled(config: GeneratorConfig): boolean;
57
+ export {};
58
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/generator/config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAOjE;;GAEG;AACH,QAAA,MAAM,qBAAqB;IACzB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE/E;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,gBAAgB;;;;;;EAwB7D;AAoCD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,WAE3D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,WAE3D"}
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ /**
3
+ * Generator Configuration
4
+ *
5
+ * Defines configuration options for prisma-effect-kysely generator
6
+ * with support for multi-domain organization and library scaffolding.
7
+ * Uses Effect Schema for strict validation.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.parseGeneratorConfig = parseGeneratorConfig;
11
+ exports.isMultiDomainEnabled = isMultiDomainEnabled;
12
+ exports.isScaffoldingEnabled = isScaffoldingEnabled;
13
+ const effect_1 = require("effect");
14
+ /**
15
+ * Boolean string schema - strictly validates 'true' or 'false'
16
+ */
17
+ const BooleanString = effect_1.Schema.Literal('true', 'false');
18
+ /**
19
+ * Generator configuration schema
20
+ */
21
+ const GeneratorConfigSchema = effect_1.Schema.Struct({
22
+ /**
23
+ * Output directory for generated Effect schemas
24
+ */
25
+ output: effect_1.Schema.String,
26
+ /**
27
+ * Enable multi-domain detection from schema file structure
28
+ */
29
+ multiFileDomains: BooleanString,
30
+ /**
31
+ * Automatically scaffold contract libraries for detected domains
32
+ */
33
+ scaffoldLibraries: BooleanString,
34
+ /**
35
+ * Path to monorepo-library-generator for library scaffolding
36
+ */
37
+ libraryGenerator: effect_1.Schema.optional(effect_1.Schema.String),
38
+ /**
39
+ * Preview features to enable
40
+ */
41
+ previewFeatures: effect_1.Schema.Array(effect_1.Schema.String),
42
+ });
43
+ /**
44
+ * Parse and validate generator configuration from Prisma options
45
+ */
46
+ function parseGeneratorConfig(options) {
47
+ const { generator } = options;
48
+ // Validate required output path
49
+ const output = generator.output?.value;
50
+ if (!output) {
51
+ throw new Error('Prisma Effect Generator: output path not configured.\n' +
52
+ 'Add "output" to your generator block in schema.prisma');
53
+ }
54
+ // Extract configuration values
55
+ const config = generator.config || {};
56
+ const rawConfig = {
57
+ output,
58
+ multiFileDomains: getStringValue(config, 'multiFileDomains') ?? 'false',
59
+ scaffoldLibraries: getStringValue(config, 'scaffoldLibraries') ?? 'false',
60
+ libraryGenerator: getStringValue(config, 'libraryGenerator'),
61
+ previewFeatures: getArrayValue(config, 'previewFeatures'),
62
+ };
63
+ // Validate with Effect Schema - throws on invalid input
64
+ return effect_1.Schema.decodeUnknownSync(GeneratorConfigSchema)(rawConfig);
65
+ }
66
+ /**
67
+ * Extract string value from config
68
+ */
69
+ function getStringValue(config, key) {
70
+ const value = config[key];
71
+ if (typeof value === 'string') {
72
+ return value;
73
+ }
74
+ return undefined;
75
+ }
76
+ /**
77
+ * Extract array value from config
78
+ */
79
+ function getArrayValue(config, key) {
80
+ const value = config[key];
81
+ if (!value)
82
+ return [];
83
+ if (Array.isArray(value)) {
84
+ return value;
85
+ }
86
+ if (typeof value === 'string') {
87
+ try {
88
+ const parsed = JSON.parse(value);
89
+ return Array.isArray(parsed) ? parsed : [];
90
+ }
91
+ catch {
92
+ return value.split(',').map((v) => v.trim());
93
+ }
94
+ }
95
+ return [];
96
+ }
97
+ /**
98
+ * Check if multi-domain mode is enabled
99
+ */
100
+ function isMultiDomainEnabled(config) {
101
+ return config.multiFileDomains === 'true';
102
+ }
103
+ /**
104
+ * Check if library scaffolding is enabled
105
+ */
106
+ function isScaffoldingEnabled(config) {
107
+ return config.scaffoldLibraries === 'true' && isMultiDomainEnabled(config);
108
+ }
109
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/generator/config.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAgDH,oDAwBC;AAuCD,oDAEC;AAKD,oDAEC;AAtHD,mCAAgC;AAGhC;;GAEG;AACH,MAAM,aAAa,GAAG,eAAM,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEtD;;GAEG;AACH,MAAM,qBAAqB,GAAG,eAAM,CAAC,MAAM,CAAC;IAC1C;;OAEG;IACH,MAAM,EAAE,eAAM,CAAC,MAAM;IAErB;;OAEG;IACH,gBAAgB,EAAE,aAAa;IAE/B;;OAEG;IACH,iBAAiB,EAAE,aAAa;IAEhC;;OAEG;IACH,gBAAgB,EAAE,eAAM,CAAC,QAAQ,CAAC,eAAM,CAAC,MAAM,CAAC;IAEhD;;OAEG;IACH,eAAe,EAAE,eAAM,CAAC,KAAK,CAAC,eAAM,CAAC,MAAM,CAAC;CAC7C,CAAC,CAAC;AAOH;;GAEG;AACH,SAAgB,oBAAoB,CAAC,OAAyB;IAC5D,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAE9B,gCAAgC;IAChC,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE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jC,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7C,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,MAAuB;IAC1D,OAAO,MAAM,CAAC,gBAAgB,KAAK,MAAM,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,MAAuB;IAC1D,OAAO,MAAM,CAAC,iBAAiB,KAAK,MAAM,IAAI,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAC7E,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Contract Library Scaffolding
3
+ *
4
+ * Scaffolds contract libraries for detected domains.
5
+ * Uses monorepo-library-generator if available, falls back to manual scaffolding.
6
+ * Uses Effect Schema for strict validation.
7
+ */
8
+ import { Schema } from 'effect';
9
+ import type { DomainInfo } from './domain-detector';
10
+ import type { GeneratorConfig } from './config';
11
+ /**
12
+ * Scaffold result schema
13
+ */
14
+ declare const ScaffoldResultSchema: Schema.Struct<{
15
+ domain: typeof Schema.String;
16
+ outputPath: typeof Schema.String;
17
+ scaffolded: typeof Schema.Boolean;
18
+ method: Schema.Literal<["generator", "manual", "existing"]>;
19
+ error: Schema.optional<typeof Schema.String>;
20
+ }>;
21
+ /**
22
+ * Scaffold result type derived from schema
23
+ */
24
+ export type ScaffoldResult = Schema.Schema.Type<typeof ScaffoldResultSchema>;
25
+ /**
26
+ * Scaffold contract libraries for all domains
27
+ *
28
+ * For each domain:
29
+ * 1. Check if contract library already exists
30
+ * 2. Use monorepo-library-generator if available and configured
31
+ * 3. Fall back to manual scaffolding if generator not available
32
+ */
33
+ export declare function scaffoldContractLibraries(domains: DomainInfo[], config: GeneratorConfig): Promise<{
34
+ readonly domain: string;
35
+ readonly outputPath: string;
36
+ readonly scaffolded: boolean;
37
+ readonly method: "generator" | "manual" | "existing";
38
+ readonly error?: string | undefined;
39
+ }[]>;
40
+ /**
41
+ * Log scaffolding results
42
+ */
43
+ export declare function logScaffoldResults(results: ScaffoldResult[]): void;
44
+ export {};
45
+ //# sourceMappingURL=contract-scaffolder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-scaffolder.d.ts","sourceRoot":"","sources":["../../src/generator/contract-scaffolder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAOhD;;GAEG;AACH,QAAA,MAAM,oBAAoB;;;;;;EAMxB,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAO7E;;;;;;;GAOG;AACH,wBAAsB,yBAAyB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,eAAe;;;;;;KAqB7F;AAgKD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,EAAE,QAkB3D"}
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+ /**
3
+ * Contract Library Scaffolding
4
+ *
5
+ * Scaffolds contract libraries for detected domains.
6
+ * Uses monorepo-library-generator if available, falls back to manual scaffolding.
7
+ * Uses Effect Schema for strict validation.
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.scaffoldContractLibraries = scaffoldContractLibraries;
44
+ exports.logScaffoldResults = logScaffoldResults;
45
+ const path = __importStar(require("path"));
46
+ const fs = __importStar(require("fs"));
47
+ const child_process_1 = require("child_process");
48
+ const effect_1 = require("effect");
49
+ /**
50
+ * Scaffold method schema
51
+ */
52
+ const ScaffoldMethod = effect_1.Schema.Literal('generator', 'manual', 'existing');
53
+ /**
54
+ * Scaffold result schema
55
+ */
56
+ const ScaffoldResultSchema = effect_1.Schema.Struct({
57
+ domain: effect_1.Schema.String,
58
+ outputPath: effect_1.Schema.String,
59
+ scaffolded: effect_1.Schema.Boolean,
60
+ method: ScaffoldMethod,
61
+ error: effect_1.Schema.optional(effect_1.Schema.String),
62
+ });
63
+ /**
64
+ * Create a validated scaffold result
65
+ */
66
+ const createResult = effect_1.Schema.decodeUnknownSync(ScaffoldResultSchema);
67
+ /**
68
+ * Scaffold contract libraries for all domains
69
+ *
70
+ * For each domain:
71
+ * 1. Check if contract library already exists
72
+ * 2. Use monorepo-library-generator if available and configured
73
+ * 3. Fall back to manual scaffolding if generator not available
74
+ */
75
+ async function scaffoldContractLibraries(domains, config) {
76
+ const results = [];
77
+ for (const domain of domains) {
78
+ try {
79
+ const result = await scaffoldDomainLibrary(domain, config);
80
+ results.push(result);
81
+ }
82
+ catch (error) {
83
+ results.push(createResult({
84
+ domain: domain.name,
85
+ outputPath: '',
86
+ scaffolded: false,
87
+ method: 'manual',
88
+ error: error instanceof Error ? error.message : String(error),
89
+ }));
90
+ }
91
+ }
92
+ return results;
93
+ }
94
+ /**
95
+ * Scaffold a contract library for a single domain
96
+ */
97
+ async function scaffoldDomainLibrary(domain, config) {
98
+ const outputPath = getContractOutputPath(config.output, domain.name);
99
+ // Check if library already exists
100
+ if (fs.existsSync(outputPath)) {
101
+ console.log(`[Contract Scaffolder] Library already exists: ${domain.name}`);
102
+ return createResult({
103
+ domain: domain.name,
104
+ outputPath,
105
+ scaffolded: false,
106
+ method: 'existing',
107
+ });
108
+ }
109
+ // Try using monorepo-library-generator
110
+ if (config.libraryGenerator) {
111
+ const generatorResult = await tryGeneratorScaffold(domain, config);
112
+ if (generatorResult) {
113
+ return generatorResult;
114
+ }
115
+ }
116
+ // Fall back to manual scaffolding
117
+ return manualScaffold(domain, config);
118
+ }
119
+ /**
120
+ * Try scaffolding using monorepo-library-generator
121
+ */
122
+ async function tryGeneratorScaffold(domain, config) {
123
+ const generatorPath = config.libraryGenerator;
124
+ if (!generatorPath) {
125
+ return null;
126
+ }
127
+ try {
128
+ // Check if generator exists
129
+ if (!fs.existsSync(generatorPath)) {
130
+ console.warn(`[Contract Scaffolder] Generator not found at: ${generatorPath}, using manual scaffolding`);
131
+ return null;
132
+ }
133
+ // Use the contract generator from monorepo-library-generator
134
+ const command = `node ${generatorPath}/dist/cli/index.js generate contract ${domain.name} --description "Contract library for ${domain.name} domain (generated by prisma-effect-kysely)"`;
135
+ console.log(`[Contract Scaffolder] Running: ${command}`);
136
+ (0, child_process_1.execSync)(command, { stdio: 'inherit' });
137
+ const outputPath = getContractOutputPath(config.output, domain.name);
138
+ return createResult({
139
+ domain: domain.name,
140
+ outputPath,
141
+ scaffolded: true,
142
+ method: 'generator',
143
+ });
144
+ }
145
+ catch (error) {
146
+ console.warn(`[Contract Scaffolder] Generator failed for ${domain.name}:`, error instanceof Error ? error.message : String(error));
147
+ return null;
148
+ }
149
+ }
150
+ /**
151
+ * Manual scaffolding fallback
152
+ *
153
+ * Creates minimal contract library structure:
154
+ * - package.json
155
+ * - tsconfig.json
156
+ * - src/index.ts
157
+ * - src/generated/ (for Prisma-generated schemas)
158
+ */
159
+ async function manualScaffold(domain, config) {
160
+ const outputPath = getContractOutputPath(config.output, domain.name);
161
+ console.log(`[Contract Scaffolder] Manually scaffolding: ${domain.name}`);
162
+ // Create directory structure
163
+ fs.mkdirSync(path.join(outputPath, 'src', 'generated'), { recursive: true });
164
+ // Create package.json
165
+ const packageJson = {
166
+ name: `@proj/contract-${domain.name}`,
167
+ version: '0.0.1',
168
+ type: 'module',
169
+ main: './src/index.ts',
170
+ exports: {
171
+ '.': {
172
+ import: './src/index.ts',
173
+ types: './src/index.ts',
174
+ },
175
+ },
176
+ dependencies: {},
177
+ peerDependencies: {
178
+ effect: '^3.0.0',
179
+ kysely: '^0.28.0',
180
+ },
181
+ };
182
+ fs.writeFileSync(path.join(outputPath, 'package.json'), JSON.stringify(packageJson, null, 2));
183
+ // Create tsconfig.json
184
+ const tsConfig = {
185
+ extends: '../../../tsconfig.base.json',
186
+ compilerOptions: {
187
+ outDir: `../../../dist/libs/contract/${domain.name}`,
188
+ composite: true,
189
+ declaration: true,
190
+ declarationMap: true,
191
+ },
192
+ include: ['src/**/*.ts'],
193
+ exclude: ['node_modules', 'dist', '**/*.spec.ts'],
194
+ };
195
+ fs.writeFileSync(path.join(outputPath, 'tsconfig.json'), JSON.stringify(tsConfig, null, 2));
196
+ // Create src/index.ts
197
+ const indexContent = `/**
198
+ * ${domain.name.charAt(0).toUpperCase() + domain.name.slice(1)} Domain Contract
199
+ *
200
+ * Generated by prisma-effect-kysely
201
+ * This file re-exports generated schemas from the generated/ directory.
202
+ */
203
+
204
+ export * from './generated';
205
+ `;
206
+ fs.writeFileSync(path.join(outputPath, 'src', 'index.ts'), indexContent);
207
+ // Create .gitkeep in generated directory
208
+ fs.writeFileSync(path.join(outputPath, 'src', 'generated', '.gitkeep'), '');
209
+ return createResult({
210
+ domain: domain.name,
211
+ outputPath,
212
+ scaffolded: true,
213
+ method: 'manual',
214
+ });
215
+ }
216
+ /**
217
+ * Get output path for a domain's contract library
218
+ *
219
+ * @example
220
+ * getContractOutputPath("../libs/contract", "user")
221
+ * // => "../libs/contract/user"
222
+ */
223
+ function getContractOutputPath(baseOutput, domainName) {
224
+ return path.join(baseOutput, domainName);
225
+ }
226
+ /**
227
+ * Log scaffolding results
228
+ */
229
+ function logScaffoldResults(results) {
230
+ console.log('\n[Contract Scaffolder] Scaffolding Summary:');
231
+ for (const result of results) {
232
+ const status = result.scaffolded ? '✓' : result.error ? '✗' : '○';
233
+ const method = result.method === 'generator'
234
+ ? '(generator)'
235
+ : result.method === 'manual'
236
+ ? '(manual)'
237
+ : '(existing)';
238
+ console.log(` ${status} ${result.domain} ${method}`);
239
+ if (result.error) {
240
+ console.log(` Error: ${result.error}`);
241
+ }
242
+ }
243
+ }
244
+ //# sourceMappingURL=contract-scaffolder.js.map