hekireki 0.34.0 → 0.35.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/README.md +16 -16
- package/dist/bin/activerecord.js +1 -1
- package/dist/bin/ajv.js +1 -1
- package/dist/bin/arktype.js +1 -1
- package/dist/bin/atlas.js +1 -1
- package/dist/bin/django.js +1 -1
- package/dist/bin/drizzle.js +1 -1
- package/dist/bin/ecto.js +1 -1
- package/dist/bin/efcore.js +1 -1
- package/dist/bin/effect.js +1 -1
- package/dist/bin/eloquent.js +1 -1
- package/dist/bin/er.js +1 -1
- package/dist/bin/exposed.js +1 -1
- package/dist/bin/gorm.js +1 -1
- package/dist/bin/hekireki.js +5 -5
- package/dist/bin/kysely.js +1 -1
- package/dist/bin/pydantic.js +1 -1
- package/dist/bin/sea-orm.js +1 -1
- package/dist/bin/seed.js +1 -1
- package/dist/bin/sqlalchemy.js +1 -1
- package/dist/bin/typebox.js +1 -1
- package/dist/bin/valibot.js +1 -1
- package/dist/bin/zod.js +1 -1
- package/dist/{bin-B2PLRVJb.js → bin-C0Ai2A-I.js} +55 -71
- package/dist/{discover-BNQ5gbRn.js → discover--iPWKb4M.js} +1 -1
- package/dist/{emit-BeblTVH8.js → emit-J65acfDW.js} +1 -1
- package/dist/{migrate-Icu7Se0-.js → migrate-Cg4iEPuL.js} +3 -3
- package/dist/{plan-EKATG1WY.js → plan-C7eaA9eW.js} +3 -3
- package/dist/{run-C13eFGuX.js → run-DBSsSPvv.js} +4 -4
- package/dist/{schema-RYU_i7qd.js → schema-DIEoug_s.js} +1 -1
- package/dist/{sql-F40UQMF6.js → sql-D_F3Jcnx.js} +1 -1
- package/dist/{start-HLOLxRBL.js → start-BnxrNq5D.js} +5 -5
- package/dist/{utils-ckthTWS0.js → utils-BkyzXzxi.js} +3 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,22 +26,22 @@ generator Hekireki-Zod {
|
|
|
26
26
|
}
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
| Provider | Generates | Options
|
|
30
|
-
| --------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
|
|
31
|
-
| `hekireki-zod` | [Zod](https://zod.dev/) | `type`, `
|
|
32
|
-
| `hekireki-valibot`, `hekireki-arktype`, `hekireki-effect`, `hekireki-typebox`, `hekireki-ajv` | Valibot, ArkType, Effect Schema, TypeBox, AJV | `type`, `
|
|
33
|
-
| `hekireki-pydantic` | Pydantic | `relation`
|
|
34
|
-
| `hekireki-drizzle`, `hekireki-kysely`, `hekireki-sqlalchemy`, `hekireki-django` | Drizzle, Kysely, SQLAlchemy, Django |
|
|
35
|
-
| `hekireki-activerecord` | Active Record | `locales`
|
|
36
|
-
| `hekireki-gorm` | GORM | `package`
|
|
37
|
-
| `hekireki-sea-orm` | SeaORM | `renameAll`
|
|
38
|
-
| `hekireki-ecto` | Ecto | `app`
|
|
39
|
-
| `hekireki-eloquent` | Eloquent | `namespace`
|
|
40
|
-
| `hekireki-efcore` (PostgreSQL, MySQL, SQLite) | EF Core | `namespace`, `context`
|
|
41
|
-
| `hekireki-exposed` (PostgreSQL) | Exposed | `package`, `dao`
|
|
42
|
-
| `hekireki-atlas` | Atlas HCL | `schemaName`
|
|
43
|
-
| `hekireki-er` | ER diagram | `outputs` (`.md`, `.dbml`, `.png`, `.svg`), `theme`
|
|
44
|
-
| `hekireki-seed` | The schema module `hekireki.config.ts` is typed against |
|
|
29
|
+
| Provider | Generates | Options |
|
|
30
|
+
| --------------------------------------------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------------------- |
|
|
31
|
+
| `hekireki-zod` | [Zod](https://zod.dev/) | `type`, `relation`, `zod` (`"v4"`, `"mini"`, `"@hono/zod-openapi"`) |
|
|
32
|
+
| `hekireki-valibot`, `hekireki-arktype`, `hekireki-effect`, `hekireki-typebox`, `hekireki-ajv` | Valibot, ArkType, Effect Schema, TypeBox, AJV | `type`, `relation` |
|
|
33
|
+
| `hekireki-pydantic` | Pydantic | `relation` |
|
|
34
|
+
| `hekireki-drizzle`, `hekireki-kysely`, `hekireki-sqlalchemy`, `hekireki-django` | Drizzle, Kysely, SQLAlchemy, Django | |
|
|
35
|
+
| `hekireki-activerecord` | Active Record | `locales` |
|
|
36
|
+
| `hekireki-gorm` | GORM | `package` |
|
|
37
|
+
| `hekireki-sea-orm` | SeaORM | `renameAll` |
|
|
38
|
+
| `hekireki-ecto` | Ecto | `app` |
|
|
39
|
+
| `hekireki-eloquent` | Eloquent | `namespace` |
|
|
40
|
+
| `hekireki-efcore` (PostgreSQL, MySQL, SQLite) | EF Core | `namespace`, `context` |
|
|
41
|
+
| `hekireki-exposed` (PostgreSQL) | Exposed | `package`, `dao` |
|
|
42
|
+
| `hekireki-atlas` | Atlas HCL | `schemaName` |
|
|
43
|
+
| `hekireki-er` | ER diagram | `outputs` (`.md`, `.dbml`, `.png`, `.svg`), `theme` |
|
|
44
|
+
| `hekireki-seed` | The schema module `hekireki.config.ts` is typed against | |
|
|
45
45
|
|
|
46
46
|
On MySQL, `hekireki-drizzle` reads and writes a `@db.Timestamp` column as UTC, and MySQL converts a
|
|
47
47
|
`TIMESTAMP` through the connection's `time_zone`: set it to `'+00:00'` on drizzle's connection, as
|
package/dist/bin/activerecord.js
CHANGED
package/dist/bin/ajv.js
CHANGED
package/dist/bin/arktype.js
CHANGED
package/dist/bin/atlas.js
CHANGED
package/dist/bin/django.js
CHANGED
package/dist/bin/drizzle.js
CHANGED
package/dist/bin/ecto.js
CHANGED
package/dist/bin/efcore.js
CHANGED
package/dist/bin/effect.js
CHANGED
package/dist/bin/eloquent.js
CHANGED
package/dist/bin/er.js
CHANGED
package/dist/bin/exposed.js
CHANGED
package/dist/bin/gorm.js
CHANGED
package/dist/bin/hekireki.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Console, Data, Effect, Schema } from "effect";
|
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { CliError, Command, Flag } from "effect/unstable/cli";
|
|
7
7
|
//#region package.json
|
|
8
|
-
var version = "0.
|
|
8
|
+
var version = "0.35.0";
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region src/studio/server/constants/index.ts
|
|
11
11
|
/** Studio only listens on loopback: the API serves the raw schema and runs SQL without authentication. */
|
|
@@ -80,7 +80,7 @@ const studioFlags = {
|
|
|
80
80
|
function runStudio(args) {
|
|
81
81
|
return Effect.gen(function* () {
|
|
82
82
|
const schemaPath = yield* resolveSchemaPath(args.schema, [COMMAND_NAME, "studio"]);
|
|
83
|
-
const { startStudioServer } = yield* Effect.promise(() => import("../start-
|
|
83
|
+
const { startStudioServer } = yield* Effect.promise(() => import("../start-BnxrNq5D.js"));
|
|
84
84
|
const started = yield* startStudioServer({
|
|
85
85
|
schemaPath,
|
|
86
86
|
port: args.port,
|
|
@@ -128,7 +128,7 @@ const seedFlags = {
|
|
|
128
128
|
};
|
|
129
129
|
function runSeedCommand(args) {
|
|
130
130
|
return Effect.gen(function* () {
|
|
131
|
-
const { runSeed, seedBanner } = yield* Effect.promise(() => import("../run-
|
|
131
|
+
const { runSeed, seedBanner } = yield* Effect.promise(() => import("../run-DBSsSPvv.js"));
|
|
132
132
|
const report = yield* runSeed(args, process.cwd()).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
|
|
133
133
|
yield* Console.log(seedBanner(report));
|
|
134
134
|
});
|
|
@@ -171,7 +171,7 @@ function runMigrateCheckCommand(args) {
|
|
|
171
171
|
"migrate",
|
|
172
172
|
"check"
|
|
173
173
|
]);
|
|
174
|
-
const { checkBanner, checkJson, runMigrateCheck, summarize } = yield* Effect.promise(() => import("../migrate-
|
|
174
|
+
const { checkBanner, checkJson, runMigrateCheck, summarize } = yield* Effect.promise(() => import("../migrate-Cg4iEPuL.js"));
|
|
175
175
|
const report = yield* runMigrateCheck({
|
|
176
176
|
...args,
|
|
177
177
|
schemaPath,
|
|
@@ -218,7 +218,7 @@ function runMigratePlanCommand(args) {
|
|
|
218
218
|
"migrate",
|
|
219
219
|
"plan"
|
|
220
220
|
]);
|
|
221
|
-
const { checkBanner, planSql, readMigration, runMigrateCheck, summarize, writePlan } = yield* Effect.promise(() => import("../migrate-
|
|
221
|
+
const { checkBanner, planSql, readMigration, runMigrateCheck, summarize, writePlan } = yield* Effect.promise(() => import("../migrate-Cg4iEPuL.js"));
|
|
222
222
|
const report = yield* runMigrateCheck({
|
|
223
223
|
...args,
|
|
224
224
|
schemaPath,
|
package/dist/bin/kysely.js
CHANGED
package/dist/bin/pydantic.js
CHANGED
package/dist/bin/sea-orm.js
CHANGED
package/dist/bin/seed.js
CHANGED
package/dist/bin/sqlalchemy.js
CHANGED
package/dist/bin/typebox.js
CHANGED
package/dist/bin/valibot.js
CHANGED
package/dist/bin/zod.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
import { n as emitMany, r as emitRaw, t as emit } from "./emit-
|
|
3
|
-
import { a as erRelations, i as erKey, n as makeSchema, o as inferredERRelations, r as annotatedERRelations } from "./schema-
|
|
1
|
+
import { _ as schemaFromFields, a as getString, c as indexPrefix, h as makeValidationExtractor, i as getBool, l as isAnnotationLine, m as makeSnakeCase, n as constraintName, o as getStrings, p as makePascalCase, r as extractObjectType, s as groupByModel, u as isFields, v as stripAnnotations } from "./utils-BkyzXzxi.js";
|
|
2
|
+
import { n as emitMany, r as emitRaw, t as emit } from "./emit-J65acfDW.js";
|
|
3
|
+
import { a as erRelations, i as erKey, n as makeSchema, o as inferredERRelations, r as annotatedERRelations } from "./schema-DIEoug_s.js";
|
|
4
4
|
import { NodeFileSystem } from "@effect/platform-node";
|
|
5
5
|
import { Data, Effect } from "effect";
|
|
6
6
|
import path from "node:path";
|
|
@@ -1626,17 +1626,15 @@ function activerecord(options) {
|
|
|
1626
1626
|
//#endregion
|
|
1627
1627
|
//#region src/utils/validation-schema.ts
|
|
1628
1628
|
function makePropertiesGenerator(libraryPrefix, wrapCardinality) {
|
|
1629
|
-
return function makeProperties(modelFields
|
|
1629
|
+
return function makeProperties(modelFields) {
|
|
1630
1630
|
return modelFields.filter((field) => field.validation).map((field) => {
|
|
1631
|
-
const cleanLines = field.comment.filter((line) => !(line.includes("@relation") || line.includes("@z") || line.includes("@v") || line.includes("@a") || line.includes("@e") || line.includes("@t") || line.includes("@j") || line.includes("@p")));
|
|
1632
|
-
const docComment = includeComments ? makeCommentBlock(cleanLines, 2) : "";
|
|
1633
1631
|
const base = `${libraryPrefix}.${field.validation}`;
|
|
1634
1632
|
const wrapped = wrapCardinality ? wrapCardinality(base, field.isRequired) : base;
|
|
1635
|
-
return
|
|
1633
|
+
return ` ${field.fieldName}: ${wrapped}`;
|
|
1636
1634
|
}).join(",\n");
|
|
1637
1635
|
};
|
|
1638
1636
|
}
|
|
1639
|
-
function validationSchemas(models, type,
|
|
1637
|
+
function validationSchemas(models, type, config) {
|
|
1640
1638
|
const modelInfos = models.map((model) => ({
|
|
1641
1639
|
documentation: model.documentation ?? "",
|
|
1642
1640
|
name: model.name,
|
|
@@ -1659,7 +1657,6 @@ function validationSchemas(models, type, comment, config) {
|
|
|
1659
1657
|
documentation: model.documentation,
|
|
1660
1658
|
modelName: model.name,
|
|
1661
1659
|
fieldName: field.name,
|
|
1662
|
-
comment: config.parseDocument(field.documentation),
|
|
1663
1660
|
validation: resolveValidation(field),
|
|
1664
1661
|
isRequired: field.isRequired
|
|
1665
1662
|
})));
|
|
@@ -1678,7 +1675,7 @@ function validationSchemas(models, type, comment, config) {
|
|
|
1678
1675
|
const schemas = Object.values(groupByModel(isFields(modelFields))).map((fields) => {
|
|
1679
1676
|
const objectType = extractObjectType(fields[0].documentation, config.annotationPrefix);
|
|
1680
1677
|
return {
|
|
1681
|
-
schema: config.schemas(fields,
|
|
1678
|
+
schema: config.schemas(fields, objectType),
|
|
1682
1679
|
inferType: type ? config.inferType(fields[0].modelName) : ""
|
|
1683
1680
|
};
|
|
1684
1681
|
}).flatMap(({ schema, inferType }) => [schema, inferType].filter(Boolean)).join("\n\n");
|
|
@@ -1707,11 +1704,9 @@ const PRISMA_TO_AJV = {
|
|
|
1707
1704
|
Json: "{}",
|
|
1708
1705
|
Bytes: "{ type: 'string' as const }"
|
|
1709
1706
|
};
|
|
1710
|
-
function makeAjvSchemas(modelFields,
|
|
1707
|
+
function makeAjvSchemas(modelFields, objectType) {
|
|
1711
1708
|
const modelName = modelFields[0].modelName;
|
|
1712
|
-
const properties = modelFields.map((field) => {
|
|
1713
|
-
return `${comment ? makeCommentBlock(field.comment, 4) : ""} ${field.fieldName}: ${field.validation ?? "{ type: 'unknown' as const }"},`;
|
|
1714
|
-
}).join("\n");
|
|
1709
|
+
const properties = modelFields.map((field) => ` ${field.fieldName}: ${field.validation ?? "{ type: 'unknown' as const }"},`).join("\n");
|
|
1715
1710
|
const requiredFields = modelFields.filter((f) => f.isRequired).map((f) => f.fieldName);
|
|
1716
1711
|
return `export const ${modelName}Schema = {\n type: 'object' as const,\n properties: {\n${properties}\n },${requiredFields.length > 0 ? `\n required: [${requiredFields.map((f) => `'${f}'`).join(", ")}] as const,` : ""}\n additionalProperties: ${objectType === "loose" ? "true" : "false"},\n} as const`;
|
|
1717
1712
|
}
|
|
@@ -1722,11 +1717,10 @@ function makeAjvRelations(model, relProps, options) {
|
|
|
1722
1717
|
const typeLine = options?.includeType ? `\n\nexport type ${model.name}Relations = FromSchema<typeof ${model.name}RelationsSchema>` : "";
|
|
1723
1718
|
return `export const ${model.name}RelationsSchema = {\n type: 'object' as const,\n properties: {\n${base}\n${rels}\n },\n additionalProperties: false,\n} as const${typeLine}`;
|
|
1724
1719
|
}
|
|
1725
|
-
function ajvSchemaCode(models, type,
|
|
1726
|
-
return validationSchemas(models, type,
|
|
1720
|
+
function ajvSchemaCode(models, type, enums) {
|
|
1721
|
+
return validationSchemas(models, type, {
|
|
1727
1722
|
importStatement: type ? `import type { FromSchema } from 'json-schema-to-ts'` : "",
|
|
1728
1723
|
annotationPrefix: "@j.",
|
|
1729
|
-
parseDocument: parseDocumentWithoutAnnotations,
|
|
1730
1724
|
extractValidation: makeValidationExtractor("@j."),
|
|
1731
1725
|
inferType: makeAjvInfer,
|
|
1732
1726
|
schemas: makeAjvSchemas,
|
|
@@ -1757,8 +1751,8 @@ function makeRelationsOnly(dmmf, includeType, makeRelations) {
|
|
|
1757
1751
|
}
|
|
1758
1752
|
//#endregion
|
|
1759
1753
|
//#region src/generator/ajv.ts
|
|
1760
|
-
function ajvCode(dmmf, type,
|
|
1761
|
-
return [ajvSchemaCode(dmmf.datamodel.models, type,
|
|
1754
|
+
function ajvCode(dmmf, type, relation) {
|
|
1755
|
+
return [ajvSchemaCode(dmmf.datamodel.models, type, dmmf.datamodel.enums), relation ? makeRelationsOnly(dmmf, type, makeAjvRelations) : ""].filter(Boolean).join("\n\n");
|
|
1762
1756
|
}
|
|
1763
1757
|
//#endregion
|
|
1764
1758
|
//#region src/core/ajv.ts
|
|
@@ -1773,7 +1767,7 @@ function ajv(options) {
|
|
|
1773
1767
|
dir: output,
|
|
1774
1768
|
file: path.join(output, "index.ts")
|
|
1775
1769
|
};
|
|
1776
|
-
const code = ajvCode(options.dmmf, getBool(options.generator.config?.type), getBool(options.generator.config?.
|
|
1770
|
+
const code = ajvCode(options.dmmf, getBool(options.generator.config?.type), getBool(options.generator.config?.relation));
|
|
1777
1771
|
return yield* emit(code, resolved.dir, resolved.file);
|
|
1778
1772
|
});
|
|
1779
1773
|
}
|
|
@@ -1785,10 +1779,8 @@ function makeArktypeInfer(modelName) {
|
|
|
1785
1779
|
function makeArktypeSchema(modelName, fields, objectType) {
|
|
1786
1780
|
return `export const ${modelName}Schema = type({${objectType === "strict" ? "\n \"+\": \"reject\",\n" : objectType === "loose" ? "\n \"+\": \"ignore\",\n" : "\n"}${fields}\n})`;
|
|
1787
1781
|
}
|
|
1788
|
-
function makeArktypeProperties(fields
|
|
1789
|
-
return fields.map((field) => {
|
|
1790
|
-
return `${comment ? makeCommentBlock(field.comment, 2) : ""} ${field.fieldName}: ${field.validation ?? "\"unknown\""},`;
|
|
1791
|
-
}).join("\n");
|
|
1782
|
+
function makeArktypeProperties(fields) {
|
|
1783
|
+
return fields.map((field) => ` ${field.fieldName}: ${field.validation ?? "\"unknown\""},`).join("\n");
|
|
1792
1784
|
}
|
|
1793
1785
|
function makeArktypeEnumExpression(values) {
|
|
1794
1786
|
return `"${values.map((v) => `'${v}'`).join(" | ")}"`;
|
|
@@ -1804,8 +1796,8 @@ const PRISMA_TO_ARKTYPE = {
|
|
|
1804
1796
|
Json: "\"unknown\"",
|
|
1805
1797
|
Bytes: "\"unknown\""
|
|
1806
1798
|
};
|
|
1807
|
-
function makeArktypeSchemas(modelFields,
|
|
1808
|
-
return schemaFromFields(modelFields,
|
|
1799
|
+
function makeArktypeSchemas(modelFields, objectType) {
|
|
1800
|
+
return schemaFromFields(modelFields, makeArktypeSchema, makeArktypeProperties, objectType);
|
|
1809
1801
|
}
|
|
1810
1802
|
function makeArktypeRelations(model, relProps, options) {
|
|
1811
1803
|
if (relProps.length === 0) return null;
|
|
@@ -1814,11 +1806,10 @@ function makeArktypeRelations(model, relProps, options) {
|
|
|
1814
1806
|
const typeLine = options?.includeType ? `\n\nexport type ${model.name}Relations = typeof ${model.name}RelationsSchema.infer` : "";
|
|
1815
1807
|
return `export const ${model.name}RelationsSchema = type({${base}${rels}})${typeLine}`;
|
|
1816
1808
|
}
|
|
1817
|
-
function arktypeSchemaCode(models, type,
|
|
1818
|
-
return validationSchemas(models, type,
|
|
1809
|
+
function arktypeSchemaCode(models, type, enums) {
|
|
1810
|
+
return validationSchemas(models, type, {
|
|
1819
1811
|
importStatement: `import { type } from 'arktype'`,
|
|
1820
1812
|
annotationPrefix: "@a.",
|
|
1821
|
-
parseDocument: parseDocumentWithoutAnnotations,
|
|
1822
1813
|
extractValidation: makeValidationExtractor("@a."),
|
|
1823
1814
|
inferType: makeArktypeInfer,
|
|
1824
1815
|
schemas: makeArktypeSchemas,
|
|
@@ -1829,8 +1820,8 @@ function arktypeSchemaCode(models, type, comment, enums) {
|
|
|
1829
1820
|
}
|
|
1830
1821
|
//#endregion
|
|
1831
1822
|
//#region src/generator/arktype.ts
|
|
1832
|
-
function arktypeCode(dmmf, type,
|
|
1833
|
-
return [arktypeSchemaCode(dmmf.datamodel.models, type,
|
|
1823
|
+
function arktypeCode(dmmf, type, relation) {
|
|
1824
|
+
return [arktypeSchemaCode(dmmf.datamodel.models, type, dmmf.datamodel.enums), relation ? makeRelationsOnly(dmmf, type, makeArktypeRelations) : ""].filter(Boolean).join("\n\n");
|
|
1834
1825
|
}
|
|
1835
1826
|
//#endregion
|
|
1836
1827
|
//#region src/core/arktype.ts
|
|
@@ -1845,7 +1836,7 @@ function arktype(options) {
|
|
|
1845
1836
|
dir: output,
|
|
1846
1837
|
file: path.join(output, "index.ts")
|
|
1847
1838
|
};
|
|
1848
|
-
const code = arktypeCode(options.dmmf, getBool(options.generator.config?.type), getBool(options.generator.config?.
|
|
1839
|
+
const code = arktypeCode(options.dmmf, getBool(options.generator.config?.type), getBool(options.generator.config?.relation));
|
|
1849
1840
|
return yield* emit(code, resolved.dir, resolved.file);
|
|
1850
1841
|
});
|
|
1851
1842
|
}
|
|
@@ -6203,10 +6194,8 @@ function makeEffectInfer(modelName) {
|
|
|
6203
6194
|
function makeEffectSchema(modelName, fields) {
|
|
6204
6195
|
return `export const ${modelName}Schema = Schema.Struct({\n${fields}\n})`;
|
|
6205
6196
|
}
|
|
6206
|
-
function makeEffectProperties(fields
|
|
6207
|
-
return fields.map((field) => {
|
|
6208
|
-
return `${comment ? makeCommentBlock(field.comment, 2) : ""} ${field.fieldName}: ${field.validation ?? "Schema.Unknown"},`;
|
|
6209
|
-
}).join("\n");
|
|
6197
|
+
function makeEffectProperties(fields) {
|
|
6198
|
+
return fields.map((field) => ` ${field.fieldName}: ${field.validation ?? "Schema.Unknown"},`).join("\n");
|
|
6210
6199
|
}
|
|
6211
6200
|
function makeEffectEnumExpression(values) {
|
|
6212
6201
|
return `Schema.Literal(${values.map((v) => `'${v}'`).join(", ")})`;
|
|
@@ -6222,8 +6211,8 @@ const PRISMA_TO_EFFECT = {
|
|
|
6222
6211
|
Json: "Schema.Unknown",
|
|
6223
6212
|
Bytes: "Schema.Unknown"
|
|
6224
6213
|
};
|
|
6225
|
-
function makeEffectSchemas(modelFields
|
|
6226
|
-
return schemaFromFields(modelFields,
|
|
6214
|
+
function makeEffectSchemas(modelFields) {
|
|
6215
|
+
return schemaFromFields(modelFields, makeEffectSchema, makeEffectProperties);
|
|
6227
6216
|
}
|
|
6228
6217
|
function makeEffectRelations(model, relProps, options) {
|
|
6229
6218
|
if (relProps.length === 0) return null;
|
|
@@ -6232,11 +6221,10 @@ function makeEffectRelations(model, relProps, options) {
|
|
|
6232
6221
|
const typeLine = options?.includeType ? `\n\nexport type ${model.name}Relations = typeof ${model.name}RelationsSchema.Type` : "";
|
|
6233
6222
|
return `export const ${model.name}RelationsSchema = Schema.Struct({${base}${rels}})${typeLine}`;
|
|
6234
6223
|
}
|
|
6235
|
-
function effectSchemaCode(models, type,
|
|
6236
|
-
return validationSchemas(models, type,
|
|
6224
|
+
function effectSchemaCode(models, type, enums) {
|
|
6225
|
+
return validationSchemas(models, type, {
|
|
6237
6226
|
importStatement: `import { Schema } from 'effect'`,
|
|
6238
6227
|
annotationPrefix: "@e.",
|
|
6239
|
-
parseDocument: parseDocumentWithoutAnnotations,
|
|
6240
6228
|
extractValidation: makeValidationExtractor("@e."),
|
|
6241
6229
|
inferType: makeEffectInfer,
|
|
6242
6230
|
schemas: makeEffectSchemas,
|
|
@@ -6247,8 +6235,8 @@ function effectSchemaCode(models, type, comment, enums) {
|
|
|
6247
6235
|
}
|
|
6248
6236
|
//#endregion
|
|
6249
6237
|
//#region src/generator/effect.ts
|
|
6250
|
-
function effectCode(dmmf, type,
|
|
6251
|
-
return [effectSchemaCode(dmmf.datamodel.models, type,
|
|
6238
|
+
function effectCode(dmmf, type, relation) {
|
|
6239
|
+
return [effectSchemaCode(dmmf.datamodel.models, type, dmmf.datamodel.enums), relation ? makeRelationsOnly(dmmf, type, makeEffectRelations) : ""].filter(Boolean).join("\n\n");
|
|
6252
6240
|
}
|
|
6253
6241
|
//#endregion
|
|
6254
6242
|
//#region src/core/effect.ts
|
|
@@ -6263,7 +6251,7 @@ function effect(options) {
|
|
|
6263
6251
|
dir: output,
|
|
6264
6252
|
file: path.join(output, "index.ts")
|
|
6265
6253
|
};
|
|
6266
|
-
const code = effectCode(options.dmmf, getBool(options.generator.config?.type), getBool(options.generator.config?.
|
|
6254
|
+
const code = effectCode(options.dmmf, getBool(options.generator.config?.type), getBool(options.generator.config?.relation));
|
|
6267
6255
|
return yield* emit(code, resolved.dir, resolved.file);
|
|
6268
6256
|
});
|
|
6269
6257
|
}
|
|
@@ -14276,12 +14264,11 @@ function makeTypeBoxSchema(modelName, fields, objectType) {
|
|
|
14276
14264
|
const obj = `Type.Object({\n${fields}\n})`;
|
|
14277
14265
|
return objectType === "strict" ? `export const ${modelName}Schema = Type.Strict(${obj})` : `export const ${modelName}Schema = ${obj}`;
|
|
14278
14266
|
}
|
|
14279
|
-
function makeTypeBoxProperties(fields
|
|
14267
|
+
function makeTypeBoxProperties(fields) {
|
|
14280
14268
|
return fields.map((field) => {
|
|
14281
|
-
const commentBlock = comment ? makeCommentBlock(field.comment, 2) : "";
|
|
14282
14269
|
const expr = field.validation ?? "Type.Unknown()";
|
|
14283
14270
|
const wrapped = field.isRequired ? expr : `Type.Optional(${expr})`;
|
|
14284
|
-
return
|
|
14271
|
+
return ` ${field.fieldName}: ${wrapped},`;
|
|
14285
14272
|
}).join("\n");
|
|
14286
14273
|
}
|
|
14287
14274
|
function makeTypeBoxEnumExpression(values) {
|
|
@@ -14298,8 +14285,8 @@ const PRISMA_TO_TYPEBOX = {
|
|
|
14298
14285
|
Json: "Type.Unknown()",
|
|
14299
14286
|
Bytes: "Type.Any()"
|
|
14300
14287
|
};
|
|
14301
|
-
function makeTypeBoxSchemas(modelFields,
|
|
14302
|
-
return schemaFromFields(modelFields,
|
|
14288
|
+
function makeTypeBoxSchemas(modelFields, objectType) {
|
|
14289
|
+
return schemaFromFields(modelFields, makeTypeBoxSchema, makeTypeBoxProperties, objectType);
|
|
14303
14290
|
}
|
|
14304
14291
|
function makeTypeBoxRelations(model, relProps, options) {
|
|
14305
14292
|
if (relProps.length === 0) return null;
|
|
@@ -14308,11 +14295,10 @@ function makeTypeBoxRelations(model, relProps, options) {
|
|
|
14308
14295
|
const typeLine = options?.includeType ? `\n\nexport type ${model.name}Relations = Static<typeof ${model.name}RelationsSchema>` : "";
|
|
14309
14296
|
return `export const ${model.name}RelationsSchema = Type.Object({\n${base}\n${rels}\n})${typeLine}`;
|
|
14310
14297
|
}
|
|
14311
|
-
function typeboxSchemaCode(models, type,
|
|
14312
|
-
return validationSchemas(models, type,
|
|
14298
|
+
function typeboxSchemaCode(models, type, enums) {
|
|
14299
|
+
return validationSchemas(models, type, {
|
|
14313
14300
|
importStatement: type ? `import { type Static, Type } from '@sinclair/typebox'` : `import { Type } from '@sinclair/typebox'`,
|
|
14314
14301
|
annotationPrefix: "@t.",
|
|
14315
|
-
parseDocument: parseDocumentWithoutAnnotations,
|
|
14316
14302
|
extractValidation: makeValidationExtractor("@t."),
|
|
14317
14303
|
inferType: makeTypeBoxInfer,
|
|
14318
14304
|
schemas: makeTypeBoxSchemas,
|
|
@@ -14323,8 +14309,8 @@ function typeboxSchemaCode(models, type, comment, enums) {
|
|
|
14323
14309
|
}
|
|
14324
14310
|
//#endregion
|
|
14325
14311
|
//#region src/generator/typebox.ts
|
|
14326
|
-
function typeboxCode(dmmf, type,
|
|
14327
|
-
return [typeboxSchemaCode(dmmf.datamodel.models, type,
|
|
14312
|
+
function typeboxCode(dmmf, type, relation) {
|
|
14313
|
+
return [typeboxSchemaCode(dmmf.datamodel.models, type, dmmf.datamodel.enums), relation ? makeRelationsOnly(dmmf, type, makeTypeBoxRelations) : ""].filter(Boolean).join("\n\n");
|
|
14328
14314
|
}
|
|
14329
14315
|
//#endregion
|
|
14330
14316
|
//#region src/core/typebox.ts
|
|
@@ -14339,7 +14325,7 @@ function typebox(options) {
|
|
|
14339
14325
|
dir: output,
|
|
14340
14326
|
file: path.join(output, "index.ts")
|
|
14341
14327
|
};
|
|
14342
|
-
const code = typeboxCode(options.dmmf, getBool(options.generator.config?.type), getBool(options.generator.config?.
|
|
14328
|
+
const code = typeboxCode(options.dmmf, getBool(options.generator.config?.type), getBool(options.generator.config?.relation));
|
|
14343
14329
|
return yield* emit(code, resolved.dir, resolved.file);
|
|
14344
14330
|
});
|
|
14345
14331
|
}
|
|
@@ -14365,8 +14351,8 @@ const PRISMA_TO_VALIBOT = {
|
|
|
14365
14351
|
Json: "unknown()",
|
|
14366
14352
|
Bytes: "any()"
|
|
14367
14353
|
};
|
|
14368
|
-
function makeValibotSchemas(modelFields,
|
|
14369
|
-
return schemaFromFields(modelFields,
|
|
14354
|
+
function makeValibotSchemas(modelFields, objectType) {
|
|
14355
|
+
return schemaFromFields(modelFields, makeValibotSchema, makePropertiesGenerator("v", (expr, isRequired) => isRequired ? expr : `v.exactOptional(${expr})`), objectType);
|
|
14370
14356
|
}
|
|
14371
14357
|
function makeValibotRelations(model, relProps, options) {
|
|
14372
14358
|
if (relProps.length === 0) return null;
|
|
@@ -14375,11 +14361,10 @@ function makeValibotRelations(model, relProps, options) {
|
|
|
14375
14361
|
const typeLine = options?.includeType ? `\n\nexport type ${model.name}Relations = v.InferOutput<typeof ${model.name}RelationsSchema>` : "";
|
|
14376
14362
|
return `export const ${model.name}RelationsSchema = v.object({\n${base}\n${rels}\n})${typeLine}`;
|
|
14377
14363
|
}
|
|
14378
|
-
function valibotSchemaCode(models, type,
|
|
14379
|
-
return validationSchemas(models, type,
|
|
14364
|
+
function valibotSchemaCode(models, type, enums) {
|
|
14365
|
+
return validationSchemas(models, type, {
|
|
14380
14366
|
importStatement: `import * as v from 'valibot'`,
|
|
14381
14367
|
annotationPrefix: "@v.",
|
|
14382
|
-
parseDocument: parseDocumentWithoutAnnotations,
|
|
14383
14368
|
extractValidation: makeValidationExtractor("@v."),
|
|
14384
14369
|
inferType: makeValibotInfer,
|
|
14385
14370
|
schemas: makeValibotSchemas,
|
|
@@ -14390,8 +14375,8 @@ function valibotSchemaCode(models, type, comment, enums) {
|
|
|
14390
14375
|
}
|
|
14391
14376
|
//#endregion
|
|
14392
14377
|
//#region src/generator/valibot.ts
|
|
14393
|
-
function valibotCode(dmmf, type,
|
|
14394
|
-
return [valibotSchemaCode(dmmf.datamodel.models, type,
|
|
14378
|
+
function valibotCode(dmmf, type, relation) {
|
|
14379
|
+
return [valibotSchemaCode(dmmf.datamodel.models, type, dmmf.datamodel.enums), relation ? makeRelationsOnly(dmmf, type, makeValibotRelations) : ""].filter(Boolean).join("\n\n");
|
|
14395
14380
|
}
|
|
14396
14381
|
//#endregion
|
|
14397
14382
|
//#region src/core/valibot.ts
|
|
@@ -14406,7 +14391,7 @@ function valibot(options) {
|
|
|
14406
14391
|
dir: output,
|
|
14407
14392
|
file: path.join(output, "index.ts")
|
|
14408
14393
|
};
|
|
14409
|
-
const code = valibotCode(options.dmmf, getBool(options.generator.config?.type), getBool(options.generator.config?.
|
|
14394
|
+
const code = valibotCode(options.dmmf, getBool(options.generator.config?.type), getBool(options.generator.config?.relation));
|
|
14410
14395
|
return yield* emit(code, resolved.dir, resolved.file);
|
|
14411
14396
|
});
|
|
14412
14397
|
}
|
|
@@ -14432,8 +14417,8 @@ const PRISMA_TO_ZOD = {
|
|
|
14432
14417
|
Json: "unknown()",
|
|
14433
14418
|
Bytes: "any()"
|
|
14434
14419
|
};
|
|
14435
|
-
function makeZodSchemas(modelFields,
|
|
14436
|
-
return schemaFromFields(modelFields,
|
|
14420
|
+
function makeZodSchemas(modelFields, objectType) {
|
|
14421
|
+
return schemaFromFields(modelFields, makeZodSchema, makePropertiesGenerator("z", (expr, isRequired) => isRequired ? expr : `${expr}.exactOptional()`), objectType);
|
|
14437
14422
|
}
|
|
14438
14423
|
function makeZodRelations(model, relProps, options) {
|
|
14439
14424
|
if (relProps.length === 0) return null;
|
|
@@ -14442,11 +14427,10 @@ function makeZodRelations(model, relProps, options) {
|
|
|
14442
14427
|
const typeLine = options?.includeType ? `\n\nexport type ${model.name}Relations = z.infer<typeof ${model.name}RelationsSchema>` : "";
|
|
14443
14428
|
return `export const ${model.name}RelationsSchema = z.object({\n${base}\n${rels}\n})${typeLine}`;
|
|
14444
14429
|
}
|
|
14445
|
-
function zodSchemaCode(models, type,
|
|
14446
|
-
return validationSchemas(models, type,
|
|
14430
|
+
function zodSchemaCode(models, type, zodVersion, enums) {
|
|
14431
|
+
return validationSchemas(models, type, {
|
|
14447
14432
|
importStatement: zodVersion === "mini" ? `import * as z from 'zod/mini'` : zodVersion === "@hono/zod-openapi" ? `import { z } from '@hono/zod-openapi'` : `import * as z from 'zod'`,
|
|
14448
14433
|
annotationPrefix: "@z.",
|
|
14449
|
-
parseDocument: parseDocumentWithoutAnnotations,
|
|
14450
14434
|
extractValidation: makeValidationExtractor("@z."),
|
|
14451
14435
|
inferType: makeZodInfer,
|
|
14452
14436
|
schemas: makeZodSchemas,
|
|
@@ -14457,8 +14441,8 @@ function zodSchemaCode(models, type, comment, zodVersion, enums) {
|
|
|
14457
14441
|
}
|
|
14458
14442
|
//#endregion
|
|
14459
14443
|
//#region src/generator/zod.ts
|
|
14460
|
-
function zodCode(dmmf, type,
|
|
14461
|
-
return [zodSchemaCode(dmmf.datamodel.models, type,
|
|
14444
|
+
function zodCode(dmmf, type, relation, version) {
|
|
14445
|
+
return [zodSchemaCode(dmmf.datamodel.models, type, version, dmmf.datamodel.enums), relation ? makeRelationsOnly(dmmf, type, makeZodRelations) : ""].filter(Boolean).join("\n\n");
|
|
14462
14446
|
}
|
|
14463
14447
|
//#endregion
|
|
14464
14448
|
//#region src/core/zod.ts
|
|
@@ -14473,7 +14457,7 @@ function zod(options) {
|
|
|
14473
14457
|
dir: output,
|
|
14474
14458
|
file: path.join(output, "index.ts")
|
|
14475
14459
|
};
|
|
14476
|
-
const code = zodCode(options.dmmf, getBool(options.generator.config?.type), getBool(options.generator.config?.
|
|
14460
|
+
const code = zodCode(options.dmmf, getBool(options.generator.config?.type), getBool(options.generator.config?.relation), getString(options.generator.config?.zod) ?? "v4");
|
|
14477
14461
|
return yield* emit(code, resolved.dir, resolved.file);
|
|
14478
14462
|
});
|
|
14479
14463
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as makePostgresSchema, m as makeSqliteFilePath, w as SeedDatabaseError } from "./sql-
|
|
1
|
+
import { f as makePostgresSchema, m as makeSqliteFilePath, w as SeedDatabaseError } from "./sql-D_F3Jcnx.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { Effect } from "effect";
|
|
4
4
|
import path from "node:path";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { s as readFile } from "./file-Df9ykHXv.js";
|
|
2
|
-
import { r as emitRaw } from "./emit-
|
|
3
|
-
import { L as splitStatements, R as MigrateConfigError, i as lostInRebuild, l as runMigrateCheck, n as isDestructiveStep, o as BLOCK_QUOTE, r as isLossyFix, s as rewriteMigration, t as batchedStatements } from "./plan-
|
|
4
|
-
import "./sql-
|
|
2
|
+
import { r as emitRaw } from "./emit-J65acfDW.js";
|
|
3
|
+
import { L as splitStatements, R as MigrateConfigError, i as lostInRebuild, l as runMigrateCheck, n as isDestructiveStep, o as BLOCK_QUOTE, r as isLossyFix, s as rewriteMigration, t as batchedStatements } from "./plan-C7eaA9eW.js";
|
|
4
|
+
import "./sql-D_F3Jcnx.js";
|
|
5
5
|
import { Effect } from "effect";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
//#region src/migrate/adapter/plan-file.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { c as removePath, i as makeDirectory, r as isDirectory, s as readFile, t as exists, u as writeFile } from "./file-Df9ykHXv.js";
|
|
2
2
|
import { a as DatabaseUnavailableError, i as DatabaseError } from "./bin/hekireki.js";
|
|
3
|
-
import { f as lowerFirst } from "./utils-
|
|
4
|
-
import "./schema-
|
|
5
|
-
import { _ as readSchemaFiles, a as placeholder, c as stringLiteral, d as makeDialect, f as makePostgresSchema, g as parseSchema, h as dialectOf, l as resolveDatabaseUrl, m as makeSqliteFilePath, n as renderLiteral, o as qualifiedName, p as makeRedactedUrl, s as quoteIdentifier, v as schemaText, x as readConfigUrl, y as withTypeScriptImports } from "./sql-
|
|
3
|
+
import { f as lowerFirst } from "./utils-BkyzXzxi.js";
|
|
4
|
+
import "./schema-DIEoug_s.js";
|
|
5
|
+
import { _ as readSchemaFiles, a as placeholder, c as stringLiteral, d as makeDialect, f as makePostgresSchema, g as parseSchema, h as dialectOf, l as resolveDatabaseUrl, m as makeSqliteFilePath, n as renderLiteral, o as qualifiedName, p as makeRedactedUrl, s as quoteIdentifier, v as schemaText, x as readConfigUrl, y as withTypeScriptImports } from "./sql-D_F3Jcnx.js";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
7
|
import { NodeFileSystem } from "@effect/platform-node";
|
|
8
8
|
import { Data, Effect } from "effect";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as exists } from "./file-Df9ykHXv.js";
|
|
2
|
-
import { f as lowerFirst, t as chunks } from "./utils-
|
|
3
|
-
import { r as emitRaw } from "./emit-
|
|
4
|
-
import { C as SeedConfigError, S as resolveConfigPath, T as SeedGenerationError, _ as readSchemaFiles, b as loadSeedConfig, g as parseSchema, h as dialectOf, l as resolveDatabaseUrl, r as sequenceSql, t as makeSeedSql, v as schemaText, w as SeedDatabaseError, y as withTypeScriptImports } from "./sql-
|
|
5
|
-
import { r as discoverClient, t as ADAPTERS } from "./discover
|
|
2
|
+
import { f as lowerFirst, t as chunks } from "./utils-BkyzXzxi.js";
|
|
3
|
+
import { r as emitRaw } from "./emit-J65acfDW.js";
|
|
4
|
+
import { C as SeedConfigError, S as resolveConfigPath, T as SeedGenerationError, _ as readSchemaFiles, b as loadSeedConfig, g as parseSchema, h as dialectOf, l as resolveDatabaseUrl, r as sequenceSql, t as makeSeedSql, v as schemaText, w as SeedDatabaseError, y as withTypeScriptImports } from "./sql-D_F3Jcnx.js";
|
|
5
|
+
import { r as discoverClient, t as ADAPTERS } from "./discover--iPWKb4M.js";
|
|
6
6
|
import { Effect } from "effect";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import * as z from "zod";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as readDirectory, r as isDirectory, s as readFile, t as exists, u as writeFile } from "./file-Df9ykHXv.js";
|
|
2
|
-
import { t as chunks } from "./utils-
|
|
2
|
+
import { t as chunks } from "./utils-BkyzXzxi.js";
|
|
3
3
|
import nodeModule from "node:module";
|
|
4
4
|
import { Config, ConfigProvider, Data, Effect, FileSystem, Option, Schema, SchemaIssue } from "effect";
|
|
5
5
|
import path from "node:path";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { a as readBytes, c as removePath, i as makeDirectory, l as watch, n as fileStamp, o as readDirectory, r as isDirectory, s as readFile, t as exists, u as writeFile$1 } from "./file-Df9ykHXv.js";
|
|
2
2
|
import { c as InvalidInputError, d as ServerListenError, f as UnknownFileError, g as PRISMA_FILE_URI, h as MIGRATIONS_POLL_MS, l as SchemaLoadError, m as FORBIDDEN_HOST_MESSAGE, n as ClientUnavailableError, o as FileWriteError, p as UnknownModelError, r as ContractViolationError, s as FormatError, t as ClientQueryError, u as SchemaParseError, v as STUDIO_HOSTNAME } from "./bin/hekireki.js";
|
|
3
|
-
import { d as isLoopbackHostname,
|
|
4
|
-
import { n as makeSchema, t as makeAnalysisSchema } from "./schema-
|
|
5
|
-
import { A as makeRow, B as MigrateEngineError, C as columnName, D as tableColumns, E as makeEnumReadValues, F as makeSqlParams, I as makeClientQuery, L as splitStatements, M as makeGeneratedDefaults, N as makeClientTouched, O as tableName, P as makeClientResult, R as MigrateConfigError, S as makeUpdateStatement, T as makeColumnValues, V as MigrationNotFoundError, _ as openSqliteCopy, a as makePlan, b as makeInsertStatement, c as checkOpened, d as DECISIONS_FILE, f as readDecisions, g as openShadowDatabase, h as openMysqlCopy, j as makeDocs, k as makeBindValue, m as connectDatabase, p as writeDecisions, u as introspectDatabase, v as makeCountStatement, w as keyFields, x as makeSelectStatement, y as makeDeleteStatement, z as MigrateDatabaseError } from "./plan-
|
|
6
|
-
import { c as stringLiteral, f as makePostgresSchema, g as parseSchema, i as formatSql, o as qualifiedName, s as quoteIdentifier, u as environmentVariable, x as readConfigUrl, y as withTypeScriptImports } from "./sql-
|
|
7
|
-
import { n as clientSource, r as discoverClient, t as ADAPTERS } from "./discover
|
|
3
|
+
import { d as isLoopbackHostname, y as fmt } from "./utils-BkyzXzxi.js";
|
|
4
|
+
import { n as makeSchema, t as makeAnalysisSchema } from "./schema-DIEoug_s.js";
|
|
5
|
+
import { A as makeRow, B as MigrateEngineError, C as columnName, D as tableColumns, E as makeEnumReadValues, F as makeSqlParams, I as makeClientQuery, L as splitStatements, M as makeGeneratedDefaults, N as makeClientTouched, O as tableName, P as makeClientResult, R as MigrateConfigError, S as makeUpdateStatement, T as makeColumnValues, V as MigrationNotFoundError, _ as openSqliteCopy, a as makePlan, b as makeInsertStatement, c as checkOpened, d as DECISIONS_FILE, f as readDecisions, g as openShadowDatabase, h as openMysqlCopy, j as makeDocs, k as makeBindValue, m as connectDatabase, p as writeDecisions, u as introspectDatabase, v as makeCountStatement, w as keyFields, x as makeSelectStatement, y as makeDeleteStatement, z as MigrateDatabaseError } from "./plan-C7eaA9eW.js";
|
|
6
|
+
import { c as stringLiteral, f as makePostgresSchema, g as parseSchema, i as formatSql, o as qualifiedName, s as quoteIdentifier, u as environmentVariable, x as readConfigUrl, y as withTypeScriptImports } from "./sql-D_F3Jcnx.js";
|
|
7
|
+
import { n as clientSource, r as discoverClient, t as ADAPTERS } from "./discover--iPWKb4M.js";
|
|
8
8
|
import { createRequire } from "node:module";
|
|
9
9
|
import { NodeFileSystem } from "@effect/platform-node";
|
|
10
10
|
import { Context, Duration, Effect, Layer, ManagedRuntime, Match, Option, Ref, Schedule, Semaphore, Stream } from "effect";
|
|
@@ -51,9 +51,6 @@ function makeValidationExtractor(annotationPrefix) {
|
|
|
51
51
|
return documentation.match(regex)?.[1]?.trim() ?? null;
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
-
function parseDocumentWithoutAnnotations(documentation) {
|
|
55
|
-
return documentationLines(documentation).filter((line) => line.length > 0);
|
|
56
|
-
}
|
|
57
54
|
const ANNOTATION_PREFIXES = [
|
|
58
55
|
"@z.",
|
|
59
56
|
"@v.",
|
|
@@ -101,11 +98,6 @@ function extractObjectType(documentation, prefix) {
|
|
|
101
98
|
if (match.includes("strictObject")) return "strict";
|
|
102
99
|
return "loose";
|
|
103
100
|
}
|
|
104
|
-
function makeCommentBlock(lines, indent) {
|
|
105
|
-
if (lines.length === 0) return "";
|
|
106
|
-
const prefix = " ".repeat(indent);
|
|
107
|
-
return `${prefix}/**\n${lines.map((c) => `${prefix} * ${c}`).join("\n")}\n${prefix} */\n`;
|
|
108
|
-
}
|
|
109
101
|
function groupByModel(validFields) {
|
|
110
102
|
const raw = Object.groupBy(validFields, (f) => f.modelName);
|
|
111
103
|
return Object.fromEntries(Object.entries(raw).filter((entry) => entry[1] !== void 0));
|
|
@@ -113,9 +105,9 @@ function groupByModel(validFields) {
|
|
|
113
105
|
function isFields(modelFields) {
|
|
114
106
|
return modelFields.flat().filter((field) => field.validation !== null);
|
|
115
107
|
}
|
|
116
|
-
function schemaFromFields(modelFields,
|
|
108
|
+
function schemaFromFields(modelFields, schemaBuilder, propertiesGenerator, objectType) {
|
|
117
109
|
const modelName = modelFields[0].modelName;
|
|
118
|
-
return schemaBuilder(modelName, propertiesGenerator(modelFields
|
|
110
|
+
return schemaBuilder(modelName, propertiesGenerator(modelFields), objectType);
|
|
119
111
|
}
|
|
120
112
|
/** The items in runs of at most `size`, in order: a batch of rows per statement. */
|
|
121
113
|
function chunks(items, size) {
|
|
@@ -160,4 +152,4 @@ function indexPrefix(model, field) {
|
|
|
160
152
|
return field.length === void 0 || field.length >= size ? void 0 : field.length;
|
|
161
153
|
}
|
|
162
154
|
//#endregion
|
|
163
|
-
export {
|
|
155
|
+
export { schemaFromFields as _, getString as a, indexPrefix as c, isLoopbackHostname as d, lowerFirst as f, parseRelation as g, makeValidationExtractor as h, getBool as i, isAnnotationLine as l, makeSnakeCase as m, constraintName as n, getStrings as o, makePascalCase as p, extractObjectType as r, groupByModel as s, chunks as t, isFields as u, stripAnnotations as v, fmt as y };
|
package/package.json
CHANGED