prisma-effect-kysely 1.11.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.
- package/dist/effect/join-table.d.ts.map +1 -1
- package/dist/effect/type.d.ts +1 -1
- package/dist/effect/type.d.ts.map +1 -1
- package/dist/effect/type.js +18 -12
- package/dist/effect/type.js.map +1 -1
- package/dist/generator/config.d.ts +58 -0
- package/dist/generator/config.d.ts.map +1 -0
- package/dist/generator/config.js +109 -0
- package/dist/generator/config.js.map +1 -0
- package/dist/generator/contract-scaffolder.d.ts +45 -0
- package/dist/generator/contract-scaffolder.d.ts.map +1 -0
- package/dist/generator/contract-scaffolder.js +244 -0
- package/dist/generator/contract-scaffolder.js.map +1 -0
- package/dist/generator/domain-detector.d.ts +50 -0
- package/dist/generator/domain-detector.d.ts.map +1 -0
- package/dist/generator/domain-detector.js +187 -0
- package/dist/generator/domain-detector.js.map +1 -0
- package/dist/generator/orchestrator.d.ts +24 -4
- package/dist/generator/orchestrator.d.ts.map +1 -1
- package/dist/generator/orchestrator.js +124 -16
- package/dist/generator/orchestrator.js.map +1 -1
- package/dist/kysely/helpers.d.ts +5 -1
- package/dist/kysely/helpers.d.ts.map +1 -1
- package/dist/kysely/helpers.js +54 -27
- package/dist/kysely/helpers.js.map +1 -1
- package/dist/kysely/type.d.ts.map +1 -1
- package/dist/utils/annotations.d.ts.map +1 -1
- package/dist/utils/codegen.d.ts.map +1 -1
- package/dist/utils/naming.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -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;AAGxD;;GAEG;AACH,wBAAgB,gCAAgC,CAAC,SAAS,EAAE,aAAa,
|
|
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"}
|
package/dist/effect/type.d.ts
CHANGED
|
@@ -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;
|
|
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"}
|
package/dist/effect/type.js
CHANGED
|
@@ -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:
|
|
14
|
-
Int:
|
|
15
|
-
Float:
|
|
16
|
-
BigInt:
|
|
17
|
-
Decimal:
|
|
18
|
-
Boolean:
|
|
19
|
-
DateTime:
|
|
20
|
-
Json:
|
|
21
|
-
Bytes:
|
|
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 ===
|
|
35
|
-
return
|
|
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
|
|
57
|
+
return 'Schema.Unknown';
|
|
52
58
|
}
|
|
53
59
|
/**
|
|
54
60
|
* Build complete field type with array and optional wrapping
|
package/dist/effect/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/effect/type.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/effect/type.ts"],"names":[],"mappings":";;AA+BA,oDA6BC;AAKD,wCAcC;AA9ED,yCAA4F;AAC5F,sDAAiE;AACjE,4CAA+C;AAE/C;;;;;;;;;GASG;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,qBAAqB,EAAE,4CAA4C;IAC7E,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,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAsC,CAAC,CAAC;IACnF,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,oCAAoC;IACpC,8DAA8D;IAC9D,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC;IACxE,IAAI,OAAO,EAAE,CAAC;QACZ,gDAAgD;QAChD,2CAA2C;QAC3C,OAAO,IAAA,qBAAY,EAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAED,kCAAkC;IAClC,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,KAAiB,EAAE,IAAmB;IACnE,IAAI,QAAQ,GAAG,oBAAoB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAEjD,gBAAgB;IAChB,IAAI,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;IAC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AO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,MAAwD,EAAE,GAAW;IAC1F,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IAEtB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACjC,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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-scaffolder.js","sourceRoot":"","sources":["../../src/generator/contract-scaffolder.ts"],"names":[],"mappings":";AAAA;;;;;;GAM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schema organization.
|
|
5
|
+
* Supports Prisma's multi-file schema feature (v5.15.0+) where schemas
|
|
6
|
+
* are organized in separate files per domain (e.g., user.prisma, product.prisma).
|
|
7
|
+
*/
|
|
8
|
+
import type { DMMF } from '@prisma/generator-helper';
|
|
9
|
+
/**
|
|
10
|
+
* Information about a detected domain
|
|
11
|
+
*/
|
|
12
|
+
export interface DomainInfo {
|
|
13
|
+
/**
|
|
14
|
+
* Domain name (e.g., "user", "product")
|
|
15
|
+
* Derived from schema file name
|
|
16
|
+
*/
|
|
17
|
+
name: string;
|
|
18
|
+
/**
|
|
19
|
+
* Models belonging to this domain
|
|
20
|
+
*/
|
|
21
|
+
models: readonly DMMF.Model[];
|
|
22
|
+
/**
|
|
23
|
+
* Source file path for this domain
|
|
24
|
+
* @example "prisma/schemas/user.prisma"
|
|
25
|
+
*/
|
|
26
|
+
sourceFile?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Detect domains from Prisma schema file structure
|
|
30
|
+
*
|
|
31
|
+
* Strategy:
|
|
32
|
+
* 1. If multiSchema preview feature is enabled, use DMMF schema information
|
|
33
|
+
* 2. Otherwise, scan prisma/schemas/ directory for *.prisma files
|
|
34
|
+
* 3. Group models by domain based on file names
|
|
35
|
+
* 4. Default domain is "shared" for models without explicit domain
|
|
36
|
+
*
|
|
37
|
+
* @param dmmf - Prisma DMMF (Data Model Meta Format)
|
|
38
|
+
* @param schemaPath - Path to prisma schema directory
|
|
39
|
+
* @returns Array of detected domains with their models
|
|
40
|
+
*/
|
|
41
|
+
export declare function detectDomains(dmmf: DMMF.Document, schemaPath?: string): DomainInfo[];
|
|
42
|
+
/**
|
|
43
|
+
* Get all unique domain names from detected domains
|
|
44
|
+
*/
|
|
45
|
+
export declare function getDomainNames(domains: DomainInfo[]): string[];
|
|
46
|
+
/**
|
|
47
|
+
* Get models for a specific domain
|
|
48
|
+
*/
|
|
49
|
+
export declare function getModelsForDomain(domains: DomainInfo[], domainName: string): readonly DMMF.Model[];
|
|
50
|
+
//# sourceMappingURL=domain-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain-detector.d.ts","sourceRoot":"","sources":["../../src/generator/domain-detector.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAIrD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,MAAM,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE,CAAC;IAE9B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,UAAU,EAAE,CAsBpF;AAgHD;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,EAAE,CAE9D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,UAAU,EAAE,EACrB,UAAU,EAAE,MAAM,GACjB,SAAS,IAAI,CAAC,KAAK,EAAE,CAGvB"}
|