prisma-effect-kysely 1.13.1 → 1.14.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/CHANGELOG.md +35 -0
- package/README.md +30 -0
- package/dist/effect/enum.d.ts +1 -1
- package/dist/effect/enum.d.ts.map +1 -1
- package/dist/effect/enum.js +19 -22
- package/dist/effect/enum.js.map +1 -1
- package/dist/effect/generator.d.ts +1 -1
- package/dist/effect/generator.d.ts.map +1 -1
- package/dist/effect/generator.js +17 -20
- package/dist/effect/generator.js.map +1 -1
- package/dist/effect/join-table.d.ts +1 -1
- package/dist/effect/join-table.d.ts.map +1 -1
- package/dist/effect/join-table.js +7 -11
- package/dist/effect/join-table.js.map +1 -1
- package/dist/effect/type.js +10 -14
- package/dist/effect/type.js.map +1 -1
- package/dist/generator/config.d.ts +1 -1
- package/dist/generator/config.d.ts.map +1 -1
- package/dist/generator/config.js +10 -15
- package/dist/generator/config.js.map +1 -1
- package/dist/generator/contract-scaffolder.d.ts +2 -2
- package/dist/generator/contract-scaffolder.d.ts.map +1 -1
- package/dist/generator/contract-scaffolder.js +21 -65
- package/dist/generator/contract-scaffolder.js.map +1 -1
- package/dist/generator/domain-detector.d.ts.map +1 -1
- package/dist/generator/domain-detector.js +5 -43
- package/dist/generator/domain-detector.js.map +1 -1
- package/dist/generator/index.d.ts +2 -1
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/index.js +9 -27
- package/dist/generator/index.js.map +1 -1
- package/dist/generator/orchestrator.d.ts.map +1 -1
- package/dist/generator/orchestrator.js +33 -40
- package/dist/generator/orchestrator.js.map +1 -1
- package/dist/kysely/generator.d.ts +1 -1
- package/dist/kysely/generator.d.ts.map +1 -1
- package/dist/kysely/generator.js +9 -12
- package/dist/kysely/generator.js.map +1 -1
- package/dist/kysely/helpers.d.ts +4 -8
- package/dist/kysely/helpers.d.ts.map +1 -1
- package/dist/kysely/helpers.js +29 -71
- package/dist/kysely/helpers.js.map +1 -1
- package/dist/kysely/type.d.ts +1 -1
- package/dist/kysely/type.d.ts.map +1 -1
- package/dist/kysely/type.js +24 -38
- package/dist/kysely/type.js.map +1 -1
- package/dist/prisma/enum.d.ts +1 -1
- package/dist/prisma/enum.d.ts.map +1 -1
- package/dist/prisma/enum.js +3 -8
- package/dist/prisma/enum.js.map +1 -1
- package/dist/prisma/generator.d.ts +2 -2
- package/dist/prisma/generator.d.ts.map +1 -1
- package/dist/prisma/generator.js +6 -42
- package/dist/prisma/generator.js.map +1 -1
- package/dist/prisma/relation.d.ts.map +1 -1
- package/dist/prisma/relation.js +45 -48
- package/dist/prisma/relation.js.map +1 -1
- package/dist/prisma/type.d.ts +1 -1
- package/dist/prisma/type.d.ts.map +1 -1
- package/dist/prisma/type.js +16 -29
- package/dist/prisma/type.js.map +1 -1
- package/dist/utils/annotations.d.ts.map +1 -1
- package/dist/utils/annotations.js +3 -9
- package/dist/utils/annotations.js.map +1 -1
- package/dist/utils/codegen.js +1 -4
- package/dist/utils/codegen.js.map +1 -1
- package/dist/utils/file-manager.js +9 -12
- package/dist/utils/file-manager.js.map +1 -1
- package/dist/utils/naming.js +3 -8
- package/dist/utils/naming.js.map +1 -1
- package/dist/utils/templates.d.ts.map +1 -1
- package/dist/utils/templates.js +5 -43
- package/dist/utils/templates.js.map +1 -1
- package/package.json +33 -25
- package/dist/utils/unsupported-config.d.ts +0 -26
- package/dist/utils/unsupported-config.d.ts.map +0 -1
- package/dist/utils/unsupported-config.js +0 -36
- package/dist/utils/unsupported-config.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.14.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`b012d87`](https://github.com/samuelho-dev/prisma-effect-kysely/commit/b012d87262b8558dd5a7adc0af1ec59fa3e62a5f) Thanks [@samuelho-dev](https://github.com/samuelho-dev)! - Test workflow with PR creation permissions enabled
|
|
8
|
+
|
|
9
|
+
## 1.14.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`77a8de3`](https://github.com/samuelho-dev/prisma-effect-kysely/commit/77a8de3b790369455eed093d9d59baa4810e36d2) Thanks [@samuelho-dev](https://github.com/samuelho-dev)! - Test Changesets CI/CD integration workflow
|
|
14
|
+
|
|
15
|
+
## 1.14.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 48451f3: Migrate to Pure ESM standards.
|
|
20
|
+
- Change package type to module and update exports.
|
|
21
|
+
- Switch to ESNext module and Bundler resolution in tsconfig.
|
|
22
|
+
- Update test suite for ESM compatibility using @jest/globals and import.meta.dirname.
|
|
23
|
+
- Standardize imports with node: prefix and explicit re-exports.
|
|
24
|
+
- Ensure generated code and build output follow ESM standards.
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- 2c75314: Fix critical Effect Schema type errors and migrate to Biome linting
|
|
29
|
+
- Fix Schema.make context preservation in kysely helpers
|
|
30
|
+
- Replace Jest with Vitest for ESM compatibility
|
|
31
|
+
- Migrate from ESLint to Biome for modern linting
|
|
32
|
+
- Update all test files to use Vitest APIs
|
|
33
|
+
- Fix enum generation redeclaration conflicts
|
|
34
|
+
- Refactor complex functions to reduce cognitive complexity
|
|
35
|
+
- Remove all non-null assertions with proper null checks
|
|
36
|
+
- Update Node.js minimum version to 20.0.0
|
|
37
|
+
|
|
3
38
|
## 1.13.1
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -66,6 +66,7 @@ export type User = Schema.Schema.Type<typeof User>;
|
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
**Naming Convention**: All exported schemas and types use PascalCase, regardless of the Prisma model naming convention:
|
|
69
|
+
|
|
69
70
|
- Model `User` → `User`, `UserSelect`, `UserInsert`
|
|
70
71
|
- Model `session_preference` → `SessionPreference`, `SessionPreferenceSelect`, `SessionPreferenceInsert`
|
|
71
72
|
|
|
@@ -130,6 +131,33 @@ npm run typecheck
|
|
|
130
131
|
npm run build
|
|
131
132
|
```
|
|
132
133
|
|
|
134
|
+
## Releasing (CI/CD)
|
|
135
|
+
|
|
136
|
+
This repo uses **Changesets** to automate versioning, changelog updates, npm publishing, git tags, and GitHub Releases.
|
|
137
|
+
|
|
138
|
+
### For PR authors
|
|
139
|
+
|
|
140
|
+
Add a changeset for any user-facing change:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
pnpm changeset
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Commit the generated file in `.changeset/`.
|
|
147
|
+
|
|
148
|
+
### What happens on `main`
|
|
149
|
+
|
|
150
|
+
- When changesets land on `main`, CI opens/updates a **Version Packages** PR.
|
|
151
|
+
- When the **Version Packages** PR is merged, CI:
|
|
152
|
+
- updates `package.json` + `CHANGELOG.md`
|
|
153
|
+
- publishes to npm (with provenance)
|
|
154
|
+
- creates/pushes `vX.Y.Z` tag
|
|
155
|
+
- creates a GitHub Release
|
|
156
|
+
|
|
157
|
+
### Required GitHub repo secrets
|
|
158
|
+
|
|
159
|
+
- `NPM_TOKEN`: npm access token with permission to publish `prisma-effect-kysely`
|
|
160
|
+
|
|
133
161
|
## Architecture
|
|
134
162
|
|
|
135
163
|
### Type Safety
|
|
@@ -168,12 +196,14 @@ model User {
|
|
|
168
196
|
**Supported for**: All Prisma scalar types (String, Int, Float, Boolean, DateTime, BigInt, Decimal, Json, Bytes)
|
|
169
197
|
|
|
170
198
|
**Use cases**:
|
|
199
|
+
|
|
171
200
|
- Email/URL validation
|
|
172
201
|
- Number constraints (positive, range, etc.)
|
|
173
202
|
- Custom branded types
|
|
174
203
|
- Refined string patterns
|
|
175
204
|
|
|
176
205
|
**Examples**:
|
|
206
|
+
|
|
177
207
|
```typescript
|
|
178
208
|
// Generated from Prisma schema with @customType annotations
|
|
179
209
|
export const _User = Schema.Struct({
|
package/dist/effect/enum.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../src/effect/enum.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAKrD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../src/effect/enum.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAKrD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,UAoC7D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,IAAI,CAAC,aAAa,EAAE,UAMrE"}
|
package/dist/effect/enum.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.generateEnumsFile = generateEnumsFile;
|
|
5
|
-
const enum_1 = require("../prisma/enum");
|
|
6
|
-
const naming_1 = require("../utils/naming");
|
|
7
|
-
const codegen_1 = require("../utils/codegen");
|
|
1
|
+
import { getEnumValueDbName } from '../prisma/enum.js';
|
|
2
|
+
import { generateFileHeader } from '../utils/codegen.js';
|
|
3
|
+
import { toPascalCase } from '../utils/naming.js';
|
|
8
4
|
/**
|
|
9
5
|
* Generate TypeScript enum + Effect Schema.Enums wrapper
|
|
10
6
|
*
|
|
@@ -15,45 +11,46 @@ const codegen_1 = require("../utils/codegen");
|
|
|
15
11
|
* - Effect Schema.Enums() wrapper for validation
|
|
16
12
|
* - Type alias for convenience
|
|
17
13
|
*/
|
|
18
|
-
function generateEnumSchema(enumDef) {
|
|
14
|
+
export function generateEnumSchema(enumDef) {
|
|
19
15
|
// Preserve original enum name for the enum itself
|
|
20
16
|
const enumName = enumDef.name;
|
|
21
17
|
// Use PascalCase for Schema and Type exports
|
|
22
|
-
const pascalName =
|
|
18
|
+
const pascalName = toPascalCase(enumDef.name);
|
|
23
19
|
const schemaName = `${pascalName}Schema`;
|
|
24
20
|
const typeName = `${pascalName}Type`;
|
|
25
21
|
// Generate native TypeScript enum members (Tests 1-2)
|
|
26
22
|
const enumMembers = enumDef.values
|
|
27
23
|
.map((v) => {
|
|
28
|
-
const value =
|
|
24
|
+
const value = getEnumValueDbName(v);
|
|
29
25
|
return ` ${v.name} = "${value}"`;
|
|
30
26
|
})
|
|
31
|
-
.join(
|
|
27
|
+
.join(',\n');
|
|
32
28
|
// Generate: enum + Schema.Enums() wrapper + type (Tests 3-4)
|
|
33
29
|
// Explicitly NOT using Schema.Literal (Test 6)
|
|
34
30
|
//
|
|
35
|
-
// Also generate PascalCase aliases for better ergonomics
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
// Also generate PascalCase aliases for better ergonomics if name is different
|
|
32
|
+
const aliases = pascalName !== enumName
|
|
33
|
+
? `
|
|
34
|
+
|
|
35
|
+
// PascalCase aliases for better ergonomics
|
|
36
|
+
export const ${pascalName} = ${enumName};
|
|
37
|
+
export type ${pascalName} = ${typeName};`
|
|
38
|
+
: '';
|
|
38
39
|
return `export enum ${enumName} {
|
|
39
40
|
${enumMembers}
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
export const ${schemaName} = Schema.Enums(${enumName});
|
|
43
44
|
|
|
44
|
-
export type ${typeName} = Schema.Schema.Type<typeof ${schemaName}
|
|
45
|
-
|
|
46
|
-
// PascalCase aliases for better ergonomics
|
|
47
|
-
export const ${pascalName} = ${enumName};
|
|
48
|
-
export type ${pascalName} = ${typeName};`;
|
|
45
|
+
export type ${typeName} = Schema.Schema.Type<typeof ${schemaName}>;${aliases}`;
|
|
49
46
|
}
|
|
50
47
|
/**
|
|
51
48
|
* Generate all enum schemas as a single file content
|
|
52
49
|
*/
|
|
53
|
-
function generateEnumsFile(enums) {
|
|
54
|
-
const header =
|
|
50
|
+
export function generateEnumsFile(enums) {
|
|
51
|
+
const header = generateFileHeader();
|
|
55
52
|
const imports = `import { Schema } from "effect";`;
|
|
56
|
-
const enumSchemas = enums.map(generateEnumSchema).join(
|
|
53
|
+
const enumSchemas = enums.map(generateEnumSchema).join('\n\n');
|
|
57
54
|
return `${header}\n\n${imports}\n\n${enumSchemas}`;
|
|
58
55
|
}
|
|
59
56
|
//# sourceMappingURL=enum.js.map
|
package/dist/effect/enum.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../src/effect/enum.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../src/effect/enum.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA2B;IAC5D,kDAAkD;IAClD,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAC9B,6CAA6C;IAC7C,MAAM,UAAU,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,MAAM,UAAU,GAAG,GAAG,UAAU,QAAQ,CAAC;IACzC,MAAM,QAAQ,GAAG,GAAG,UAAU,MAAM,CAAC;IAErC,sDAAsD;IACtD,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM;SAC/B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,MAAM,KAAK,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;QACpC,OAAO,KAAK,CAAC,CAAC,IAAI,OAAO,KAAK,GAAG,CAAC;IACpC,CAAC,CAAC;SACD,IAAI,CAAC,KAAK,CAAC,CAAC;IAEf,6DAA6D;IAC7D,+CAA+C;IAC/C,EAAE;IACF,8EAA8E;IAC9E,MAAM,OAAO,GACX,UAAU,KAAK,QAAQ;QACrB,CAAC,CAAC;;;eAGO,UAAU,MAAM,QAAQ;cACzB,UAAU,MAAM,QAAQ,GAAG;QACnC,CAAC,CAAC,EAAE,CAAC;IAET,OAAO,eAAe,QAAQ;EAC9B,WAAW;;;eAGE,UAAU,mBAAmB,QAAQ;;cAEtC,QAAQ,gCAAgC,UAAU,KAAK,OAAO,EAAE,CAAC;AAC/E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAoC;IACpE,MAAM,MAAM,GAAG,kBAAkB,EAAE,CAAC;IACpC,MAAM,OAAO,GAAG,kCAAkC,CAAC;IACnD,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAE/D,OAAO,GAAG,MAAM,OAAO,OAAO,OAAO,WAAW,EAAE,CAAC;AACrD,CAAC"}
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/effect/generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAO3D;;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"}
|
package/dist/effect/generator.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const naming_1 = require("../utils/naming");
|
|
7
|
-
const codegen_1 = require("../utils/codegen");
|
|
8
|
-
const join_table_1 = require("./join-table");
|
|
1
|
+
import { generateFileHeader } from '../utils/codegen.js';
|
|
2
|
+
import { toPascalCase } from '../utils/naming.js';
|
|
3
|
+
import { generateEnumsFile } from './enum.js';
|
|
4
|
+
import { generateJoinTableKyselyInterface, generateJoinTableSchema } from './join-table.js';
|
|
5
|
+
import { buildFieldType } from './type.js';
|
|
9
6
|
/**
|
|
10
7
|
* Effect domain generator - orchestrates Effect Schema generation
|
|
11
8
|
*/
|
|
12
|
-
class EffectGenerator {
|
|
9
|
+
export class EffectGenerator {
|
|
10
|
+
dmmf;
|
|
13
11
|
constructor(dmmf) {
|
|
14
12
|
this.dmmf = dmmf;
|
|
15
13
|
}
|
|
@@ -17,7 +15,7 @@ class EffectGenerator {
|
|
|
17
15
|
* Generate enums.ts file content
|
|
18
16
|
*/
|
|
19
17
|
generateEnums(enums) {
|
|
20
|
-
return
|
|
18
|
+
return generateEnumsFile(enums);
|
|
21
19
|
}
|
|
22
20
|
/**
|
|
23
21
|
* Generate base schema for a model (_ModelName)
|
|
@@ -25,7 +23,7 @@ class EffectGenerator {
|
|
|
25
23
|
generateBaseSchema(model, fields) {
|
|
26
24
|
const fieldDefinitions = fields
|
|
27
25
|
.map((field) => {
|
|
28
|
-
const fieldType =
|
|
26
|
+
const fieldType = buildFieldType(field, this.dmmf);
|
|
29
27
|
return ` ${field.name}: ${fieldType}`;
|
|
30
28
|
})
|
|
31
29
|
.join(',\n');
|
|
@@ -40,7 +38,7 @@ ${fieldDefinitions}
|
|
|
40
38
|
*/
|
|
41
39
|
generateOperationalSchemas(model) {
|
|
42
40
|
const baseSchemaName = `_${model.name}`;
|
|
43
|
-
const operationalSchemaName =
|
|
41
|
+
const operationalSchemaName = toPascalCase(model.name);
|
|
44
42
|
return `export const ${operationalSchemaName} = getSchemas(${baseSchemaName});`;
|
|
45
43
|
}
|
|
46
44
|
/**
|
|
@@ -49,7 +47,7 @@ ${fieldDefinitions}
|
|
|
49
47
|
* Trusts runtime schema transformation - insertable() helper filters generated fields
|
|
50
48
|
*/
|
|
51
49
|
generateTypeExports(model, _fields) {
|
|
52
|
-
const name =
|
|
50
|
+
const name = toPascalCase(model.name);
|
|
53
51
|
// Application-side types (decoded - for repository layer)
|
|
54
52
|
const applicationTypes = `export type ${name}Select = Schema.Schema.Type<typeof ${name}.Selectable>;
|
|
55
53
|
export type ${name}Insert = Schema.Schema.Type<typeof ${name}.Insertable>;
|
|
@@ -58,7 +56,7 @@ export type ${name}Update = Schema.Schema.Type<typeof ${name}.Updateable>;`;
|
|
|
58
56
|
const encodedTypes = `export type ${name}SelectEncoded = Schema.Schema.Encoded<typeof ${name}.Selectable>;
|
|
59
57
|
export type ${name}InsertEncoded = Schema.Schema.Encoded<typeof ${name}.Insertable>;
|
|
60
58
|
export type ${name}UpdateEncoded = Schema.Schema.Encoded<typeof ${name}.Updateable>;`;
|
|
61
|
-
return applicationTypes
|
|
59
|
+
return `${applicationTypes}\n${encodedTypes}`;
|
|
62
60
|
}
|
|
63
61
|
/**
|
|
64
62
|
* Generate complete model schema (base + operational + types)
|
|
@@ -75,7 +73,7 @@ export type ${name}UpdateEncoded = Schema.Schema.Encoded<typeof ${name}.Updateab
|
|
|
75
73
|
* TDD: Satisfies tests 13-15 in import-generation.test.ts
|
|
76
74
|
*/
|
|
77
75
|
generateTypesHeader(hasEnums) {
|
|
78
|
-
const header =
|
|
76
|
+
const header = generateFileHeader();
|
|
79
77
|
const imports = [
|
|
80
78
|
`import { Schema } from "effect";`,
|
|
81
79
|
`import type { ColumnType } from "kysely";`,
|
|
@@ -87,11 +85,11 @@ export type ${name}UpdateEncoded = Schema.Schema.Encoded<typeof ${name}.Updateab
|
|
|
87
85
|
// No SCREAMING_SNAKE_CASE
|
|
88
86
|
const enumImports = this.dmmf.datamodel.enums
|
|
89
87
|
.map((e) => {
|
|
90
|
-
const baseName =
|
|
88
|
+
const baseName = toPascalCase(e.name);
|
|
91
89
|
return `${baseName}Schema`;
|
|
92
90
|
})
|
|
93
91
|
.join(', ');
|
|
94
|
-
imports.push(`import { ${enumImports} } from "./enums";`);
|
|
92
|
+
imports.push(`import { ${enumImports} } from "./enums.js";`);
|
|
95
93
|
}
|
|
96
94
|
return `${header}\n\n${imports.join('\n')}`;
|
|
97
95
|
}
|
|
@@ -99,14 +97,13 @@ export type ${name}UpdateEncoded = Schema.Schema.Encoded<typeof ${name}.Updateab
|
|
|
99
97
|
* Generate schemas for all join tables
|
|
100
98
|
*/
|
|
101
99
|
generateJoinTableSchemas(joinTables) {
|
|
102
|
-
return joinTables.map((jt) =>
|
|
100
|
+
return joinTables.map((jt) => generateJoinTableSchema(jt, this.dmmf)).join('\n\n');
|
|
103
101
|
}
|
|
104
102
|
/**
|
|
105
103
|
* Generate Kysely table interfaces for join tables
|
|
106
104
|
*/
|
|
107
105
|
generateJoinTableKyselyInterfaces(joinTables) {
|
|
108
|
-
return joinTables.map(
|
|
106
|
+
return joinTables.map(generateJoinTableKyselyInterface).join('\n\n');
|
|
109
107
|
}
|
|
110
108
|
}
|
|
111
|
-
exports.EffectGenerator = EffectGenerator;
|
|
112
109
|
//# sourceMappingURL=generator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/effect/generator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/effect/generator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,gCAAgC,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,eAAe;IACG;IAA7B,YAA6B,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAEpD;;OAEG;IACH,aAAa,CAAC,KAAoC;QAChD,OAAO,iBAAiB,CAAC,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,cAAc,CAAC,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,OA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AG;YACd,kCAAkC;YAClC,2CAA2C;YAC3C,2EAA2E;SAC5E,CAAC;QAEF,IAAI,QAAQ,EAAE,CAAC;YACb,qDAAqD;YACrD,2CAA2C;YAC3C,0BAA0B;YAC1B,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK;iBAC1C,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;gBACT,MAAM,QAAQ,GAAG,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBACtC,OAAO,GAAG,QAAQ,QAAQ,CAAC;YAC7B,CAAC,CAAC;iBACD,IAAI,CAAC,IAAI,CAAC,CAAC;YAEd,OAAO,CAAC,IAAI,CAAC,YAAY,WAAW,uBAAuB,CAAC,CAAC;QAC/D,CAAC;QAED,OAAO,GAAG,MAAM,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH,wBAAwB,CAAC,UAA2B;QAClD,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,uBAAuB,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrF,CAAC;IAED;;OAEG;IACH,iCAAiC,CAAC,UAA2B;QAC3D,OAAO,UAAU,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvE,CAAC;CACF"}
|
|
@@ -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,
|
|
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,uBAAuB,CAAC;AAG3D;;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,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateJoinTableKyselyInterface = generateJoinTableKyselyInterface;
|
|
4
|
-
exports.generateJoinTableSchema = generateJoinTableSchema;
|
|
5
|
-
const naming_1 = require("../utils/naming");
|
|
1
|
+
import { toSnakeCase } from '../utils/naming.js';
|
|
6
2
|
/**
|
|
7
3
|
* Generate Kysely table interface for a join table
|
|
8
4
|
*/
|
|
9
|
-
function generateJoinTableKyselyInterface(joinTable) {
|
|
5
|
+
export function generateJoinTableKyselyInterface(joinTable) {
|
|
10
6
|
const { relationName, modelA, modelB, columnAIsUuid, columnBIsUuid } = joinTable;
|
|
11
|
-
const modelAField =
|
|
12
|
-
const modelBField =
|
|
7
|
+
const modelAField = toSnakeCase(modelA);
|
|
8
|
+
const modelBField = toSnakeCase(modelB);
|
|
13
9
|
const aType = columnAIsUuid ? 'string' : 'number';
|
|
14
10
|
const bType = columnBIsUuid ? 'string' : 'number';
|
|
15
11
|
return `// Kysely table interface for ${relationName}
|
|
@@ -47,14 +43,14 @@ function mapColumnType(columnType, isUuid) {
|
|
|
47
43
|
* - TypeScript fields: product_id, product_tag_id (semantic snake_case)
|
|
48
44
|
* - Mapping: product_id → A, product_tag_id → B (via Schema.fromKey)
|
|
49
45
|
*/
|
|
50
|
-
function generateJoinTableSchema(joinTable, _dmmf) {
|
|
46
|
+
export function generateJoinTableSchema(joinTable, _dmmf) {
|
|
51
47
|
const { tableName, relationName, modelA, modelB, columnAType, columnBType, columnAIsUuid, columnBIsUuid, } = joinTable;
|
|
52
48
|
// Map column types to Effect Schema types
|
|
53
49
|
const columnASchema = mapColumnType(columnAType, columnAIsUuid);
|
|
54
50
|
const columnBSchema = mapColumnType(columnBType, columnBIsUuid);
|
|
55
51
|
// Generate semantic snake_case field names from model names
|
|
56
|
-
const columnAName = `${
|
|
57
|
-
const columnBName = `${
|
|
52
|
+
const columnAName = `${toSnakeCase(modelA)}_id`;
|
|
53
|
+
const columnBName = `${toSnakeCase(modelB)}_id`;
|
|
58
54
|
// Both columns are foreign keys, so use columnType for read-only behavior
|
|
59
55
|
// Use propertySignature with fromKey to map semantic names to actual A/B database columns
|
|
60
56
|
const columnAField = ` ${columnAName}: Schema.propertySignature(columnType(${columnASchema}, Schema.Never, Schema.Never)).pipe(Schema.fromKey("A"))`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"join-table.js","sourceRoot":"","sources":["../../src/effect/join-table.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"join-table.js","sourceRoot":"","sources":["../../src/effect/join-table.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;GAEG;AACH,MAAM,UAAU,gCAAgC,CAAC,SAAwB;IACvE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,SAAS,CAAC;IAEjF,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IAExC,MAAM,KAAK,GAAG,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;IAClD,MAAM,KAAK,GAAG,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;IAElD,OAAO,iCAAiC,YAAY;mBACnC,YAAY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C/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"}
|
package/dist/effect/type.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.buildFieldType = buildFieldType;
|
|
5
|
-
const type_1 = require("../prisma/type");
|
|
6
|
-
const annotations_1 = require("../utils/annotations");
|
|
7
|
-
const naming_1 = require("../utils/naming");
|
|
1
|
+
import { hasDefaultValue, isListField, isRequiredField, isUuidField } from '../prisma/type.js';
|
|
2
|
+
import { extractEffectTypeOverride } from '../utils/annotations.js';
|
|
3
|
+
import { toPascalCase } from '../utils/naming.js';
|
|
8
4
|
/**
|
|
9
5
|
* Prisma scalar type mapping to Effect Schema types
|
|
10
6
|
* Uses const assertion to avoid type guards
|
|
@@ -30,14 +26,14 @@ const PRISMA_SCALAR_MAP = {
|
|
|
30
26
|
* Map Prisma field type to Effect Schema type
|
|
31
27
|
* Priority order: annotation → UUID → scalar → enum → unknown fallback
|
|
32
28
|
*/
|
|
33
|
-
function mapFieldToEffectType(field, dmmf) {
|
|
29
|
+
export function mapFieldToEffectType(field, dmmf) {
|
|
34
30
|
// PRIORITY 1: Check for @customType annotation
|
|
35
|
-
const typeOverride =
|
|
31
|
+
const typeOverride = extractEffectTypeOverride(field);
|
|
36
32
|
if (typeOverride) {
|
|
37
33
|
return typeOverride;
|
|
38
34
|
}
|
|
39
35
|
// PRIORITY 2: Handle String type with UUID detection
|
|
40
|
-
if (field.type === 'String' &&
|
|
36
|
+
if (field.type === 'String' && isUuidField(field)) {
|
|
41
37
|
return 'Schema.UUID';
|
|
42
38
|
}
|
|
43
39
|
// PRIORITY 3: Handle scalar types with const assertion lookup
|
|
@@ -51,7 +47,7 @@ function mapFieldToEffectType(field, dmmf) {
|
|
|
51
47
|
if (enumDef) {
|
|
52
48
|
// Return Schema wrapper, not raw enum (Test 11)
|
|
53
49
|
// Use PascalCase + Schema suffix (Test 12)
|
|
54
|
-
return
|
|
50
|
+
return toPascalCase(field.type, 'Schema');
|
|
55
51
|
}
|
|
56
52
|
// PRIORITY 5: Fallback to Unknown
|
|
57
53
|
return 'Schema.Unknown';
|
|
@@ -59,14 +55,14 @@ function mapFieldToEffectType(field, dmmf) {
|
|
|
59
55
|
/**
|
|
60
56
|
* Build complete field type with array and optional wrapping
|
|
61
57
|
*/
|
|
62
|
-
function buildFieldType(field, dmmf) {
|
|
58
|
+
export function buildFieldType(field, dmmf) {
|
|
63
59
|
let baseType = mapFieldToEffectType(field, dmmf);
|
|
64
60
|
// Handle arrays
|
|
65
|
-
if (
|
|
61
|
+
if (isListField(field)) {
|
|
66
62
|
baseType = `Schema.Array(${baseType})`;
|
|
67
63
|
}
|
|
68
64
|
// Handle optional fields (only if NOT already has @default)
|
|
69
|
-
if (!(
|
|
65
|
+
if (!(isRequiredField(field) || hasDefaultValue(field))) {
|
|
70
66
|
baseType = `Schema.UndefinedOr(${baseType})`;
|
|
71
67
|
}
|
|
72
68
|
return baseType;
|
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":"AACA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,eAAe,EAA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AK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAED,kCAAkC;IAClC,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAiB,EAAE,IAAmB;IACnE,IAAI,QAAQ,GAAG,oBAAoB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAEjD,gBAAgB;IAChB,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,QAAQ,GAAG,gBAAgB,QAAQ,GAAG,CAAC;IACzC,CAAC;IAED,4DAA4D;IAC5D,IAAI,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACxD,QAAQ,GAAG,sBAAsB,QAAQ,GAAG,CAAC;IAC/C,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* with support for multi-domain organization and library scaffolding.
|
|
6
6
|
* Uses Effect Schema for strict validation.
|
|
7
7
|
*/
|
|
8
|
-
import { Schema } from 'effect';
|
|
9
8
|
import type { GeneratorOptions } from '@prisma/generator-helper';
|
|
9
|
+
import { Schema } from 'effect';
|
|
10
10
|
/**
|
|
11
11
|
* Generator configuration schema
|
|
12
12
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/generator/config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/generator/config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAOhC;;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"}
|
package/dist/generator/config.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Generator Configuration
|
|
4
3
|
*
|
|
@@ -6,23 +5,19 @@
|
|
|
6
5
|
* with support for multi-domain organization and library scaffolding.
|
|
7
6
|
* Uses Effect Schema for strict validation.
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
|
-
exports.parseGeneratorConfig = parseGeneratorConfig;
|
|
11
|
-
exports.isMultiDomainEnabled = isMultiDomainEnabled;
|
|
12
|
-
exports.isScaffoldingEnabled = isScaffoldingEnabled;
|
|
13
|
-
const effect_1 = require("effect");
|
|
8
|
+
import { Schema } from 'effect';
|
|
14
9
|
/**
|
|
15
10
|
* Boolean string schema - strictly validates 'true' or 'false'
|
|
16
11
|
*/
|
|
17
|
-
const BooleanString =
|
|
12
|
+
const BooleanString = Schema.Literal('true', 'false');
|
|
18
13
|
/**
|
|
19
14
|
* Generator configuration schema
|
|
20
15
|
*/
|
|
21
|
-
const GeneratorConfigSchema =
|
|
16
|
+
const GeneratorConfigSchema = Schema.Struct({
|
|
22
17
|
/**
|
|
23
18
|
* Output directory for generated Effect schemas
|
|
24
19
|
*/
|
|
25
|
-
output:
|
|
20
|
+
output: Schema.String,
|
|
26
21
|
/**
|
|
27
22
|
* Enable multi-domain detection from schema file structure
|
|
28
23
|
*/
|
|
@@ -34,16 +29,16 @@ const GeneratorConfigSchema = effect_1.Schema.Struct({
|
|
|
34
29
|
/**
|
|
35
30
|
* Path to monorepo-library-generator for library scaffolding
|
|
36
31
|
*/
|
|
37
|
-
libraryGenerator:
|
|
32
|
+
libraryGenerator: Schema.optional(Schema.String),
|
|
38
33
|
/**
|
|
39
34
|
* Preview features to enable
|
|
40
35
|
*/
|
|
41
|
-
previewFeatures:
|
|
36
|
+
previewFeatures: Schema.Array(Schema.String),
|
|
42
37
|
});
|
|
43
38
|
/**
|
|
44
39
|
* Parse and validate generator configuration from Prisma options
|
|
45
40
|
*/
|
|
46
|
-
function parseGeneratorConfig(options) {
|
|
41
|
+
export function parseGeneratorConfig(options) {
|
|
47
42
|
const { generator } = options;
|
|
48
43
|
// Validate required output path
|
|
49
44
|
const output = generator.output?.value;
|
|
@@ -61,7 +56,7 @@ function parseGeneratorConfig(options) {
|
|
|
61
56
|
previewFeatures: getArrayValue(config, 'previewFeatures'),
|
|
62
57
|
};
|
|
63
58
|
// Validate with Effect Schema - throws on invalid input
|
|
64
|
-
return
|
|
59
|
+
return Schema.decodeUnknownSync(GeneratorConfigSchema)(rawConfig);
|
|
65
60
|
}
|
|
66
61
|
/**
|
|
67
62
|
* Extract string value from config
|
|
@@ -97,13 +92,13 @@ function getArrayValue(config, key) {
|
|
|
97
92
|
/**
|
|
98
93
|
* Check if multi-domain mode is enabled
|
|
99
94
|
*/
|
|
100
|
-
function isMultiDomainEnabled(config) {
|
|
95
|
+
export function isMultiDomainEnabled(config) {
|
|
101
96
|
return config.multiFileDomains === 'true';
|
|
102
97
|
}
|
|
103
98
|
/**
|
|
104
99
|
* Check if library scaffolding is enabled
|
|
105
100
|
*/
|
|
106
|
-
function isScaffoldingEnabled(config) {
|
|
101
|
+
export function isScaffoldingEnabled(config) {
|
|
107
102
|
return config.scaffoldLibraries === 'true' && isMultiDomainEnabled(config);
|
|
108
103
|
}
|
|
109
104
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/generator/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/generator/config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;GAEG;AACH,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEtD;;GAEG;AACH,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1C;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM;IAErB;;OAEG;IACH,gBAAgB,EAAE,aAAa;IAE/B;;OAEG;IACH,iBAAiB,EAAE,aAAa;IAEhC;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IAEhD;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;CAC7C,CAAC,CAAC;AAOH;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAyB;IAC5D,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAE9B,gCAAgC;IAChC,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC;IACvC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,wDAAwD;YACtD,uDAAuD,CAC1D,CAAC;IACJ,CAAC;IAED,+BAA+B;IAC/B,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,IAAI,EAAE,CAAC;IACtC,MAAM,SAAS,GAAG;QAChB,MAAM;QACN,gBAAgB,EAAE,cAAc,CAAC,MAAM,EAAE,kBAAkB,CAAC,IAAI,OAAO;QACvE,iBAAiB,EAAE,cAAc,CAAC,MAAM,EAAE,mBAAmB,CAAC,IAAI,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IAC1D,OAAO,MAAM,CAAC,gBAAgB,KAAK,MAAM,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAuB;IAC1D,OAAO,MAAM,CAAC,iBAAiB,KAAK,MAAM,IAAI,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAC7E,CAAC"}
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* Uses Effect Schema for strict validation.
|
|
7
7
|
*/
|
|
8
8
|
import { Schema } from 'effect';
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
9
|
+
import type { GeneratorConfig } from './config.js';
|
|
10
|
+
import type { DomainInfo } from './domain-detector.js';
|
|
11
11
|
/**
|
|
12
12
|
* Scaffold result schema
|
|
13
13
|
*/
|
|
@@ -1 +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,
|
|
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,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAOvD;;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;AAoJD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,EAAE,QAc3D"}
|