joist-codegen 2.5.0-next.3 → 2.5.0-next.30
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/build/EntityDbMetadata.cjs +29 -5
- package/build/EntityDbMetadata.cjs.map +1 -1
- package/build/EntityDbMetadata.d.cts +8 -3
- package/build/EntityDbMetadata.d.cts.map +1 -1
- package/build/EntityDbMetadata.d.mts +8 -3
- package/build/EntityDbMetadata.d.mts.map +1 -1
- package/build/EntityDbMetadata.js +29 -6
- package/build/EntityDbMetadata.js.map +1 -1
- package/build/_virtual/_rolldown/runtime.cjs +1 -2
- package/build/_virtual/_rolldown/runtime.js +1 -2
- package/build/assignTags.cjs +2 -3
- package/build/assignTags.cjs.map +1 -1
- package/build/assignTags.d.cts +0 -2
- package/build/assignTags.d.cts.map +1 -1
- package/build/assignTags.d.mts +0 -2
- package/build/assignTags.d.mts.map +1 -1
- package/build/assignTags.js +2 -3
- package/build/codemods/Codemod.d.cts +0 -2
- package/build/codemods/Codemod.d.cts.map +1 -1
- package/build/codemods/Codemod.d.mts +0 -2
- package/build/codemods/Codemod.d.mts.map +1 -1
- package/build/codemods/JscodeshiftMod.cjs +2 -3
- package/build/codemods/JscodeshiftMod.cjs.map +1 -1
- package/build/codemods/JscodeshiftMod.d.cts +0 -2
- package/build/codemods/JscodeshiftMod.d.cts.map +1 -1
- package/build/codemods/JscodeshiftMod.d.mts +0 -2
- package/build/codemods/JscodeshiftMod.d.mts.map +1 -1
- package/build/codemods/JscodeshiftMod.js +2 -3
- package/build/codemods/JscodeshiftMod.js.map +1 -1
- package/build/codemods/codemod_0001-rename_has_async_property.cjs +1 -2
- package/build/codemods/codemod_0001-rename_has_async_property.d.cts +0 -2
- package/build/codemods/codemod_0001-rename_has_async_property.d.cts.map +1 -1
- package/build/codemods/codemod_0001-rename_has_async_property.d.mts +0 -2
- package/build/codemods/codemod_0001-rename_has_async_property.d.mts.map +1 -1
- package/build/codemods/codemod_0001-rename_has_async_property.js +1 -2
- package/build/codemods/codemod_0002-rename_async_query_fields.cjs +1 -2
- package/build/codemods/codemod_0002-rename_async_query_fields.d.cts +0 -2
- package/build/codemods/codemod_0002-rename_async_query_fields.d.cts.map +1 -1
- package/build/codemods/codemod_0002-rename_async_query_fields.d.mts +0 -2
- package/build/codemods/codemod_0002-rename_async_query_fields.d.mts.map +1 -1
- package/build/codemods/codemod_0002-rename_async_query_fields.js +1 -2
- package/build/codemods/codemod_0003-rename_find_paginated.cjs +1 -2
- package/build/codemods/codemod_0003-rename_find_paginated.d.cts +0 -2
- package/build/codemods/codemod_0003-rename_find_paginated.d.cts.map +1 -1
- package/build/codemods/codemod_0003-rename_find_paginated.d.mts +0 -2
- package/build/codemods/codemod_0003-rename_find_paginated.d.mts.map +1 -1
- package/build/codemods/codemod_0003-rename_find_paginated.js +1 -2
- package/build/codemods/index.cjs +2 -3
- package/build/codemods/index.d.cts +0 -2
- package/build/codemods/index.d.cts.map +1 -1
- package/build/codemods/index.d.mts +0 -2
- package/build/codemods/index.d.mts.map +1 -1
- package/build/codemods/index.js +2 -3
- package/build/config.cjs +5 -4
- package/build/config.cjs.map +1 -1
- package/build/config.d.cts +1 -2
- package/build/config.d.cts.map +1 -1
- package/build/config.d.mts +1 -2
- package/build/config.d.mts.map +1 -1
- package/build/config.js +5 -4
- package/build/config.js.map +1 -1
- package/build/docs/cache.cjs +1 -2
- package/build/docs/cache.cjs.map +1 -1
- package/build/docs/cache.d.cts +0 -2
- package/build/docs/cache.d.cts.map +1 -1
- package/build/docs/cache.d.mts +0 -2
- package/build/docs/cache.d.mts.map +1 -1
- package/build/docs/cache.js +1 -2
- package/build/docs/cache.js.map +1 -1
- package/build/docs/generate-metadata-docs.cjs +2 -3
- package/build/docs/generate-metadata-docs.cjs.map +1 -1
- package/build/docs/generate-metadata-docs.d.cts +0 -2
- package/build/docs/generate-metadata-docs.d.cts.map +1 -1
- package/build/docs/generate-metadata-docs.d.mts +0 -2
- package/build/docs/generate-metadata-docs.d.mts.map +1 -1
- package/build/docs/generate-metadata-docs.js +2 -3
- package/build/docs/index.cjs +1 -2
- package/build/docs/index.cjs.map +1 -1
- package/build/docs/index.d.cts +0 -2
- package/build/docs/index.d.cts.map +1 -1
- package/build/docs/index.d.mts +0 -2
- package/build/docs/index.d.mts.map +1 -1
- package/build/docs/index.js +1 -2
- package/build/docs/markdown.cjs +1 -2
- package/build/docs/markdown.cjs.map +1 -1
- package/build/docs/markdown.d.cts +0 -2
- package/build/docs/markdown.d.cts.map +1 -1
- package/build/docs/markdown.d.mts +0 -2
- package/build/docs/markdown.d.mts.map +1 -1
- package/build/docs/markdown.js +1 -2
- package/build/docs/parsing.cjs +1 -2
- package/build/docs/parsing.cjs.map +1 -1
- package/build/docs/parsing.d.cts +1 -3
- package/build/docs/parsing.d.cts.map +1 -1
- package/build/docs/parsing.d.mts +0 -2
- package/build/docs/parsing.d.mts.map +1 -1
- package/build/docs/parsing.js +1 -2
- package/build/findEntityScopes.cjs +1 -2
- package/build/findEntityScopes.cjs.map +1 -1
- package/build/findEntityScopes.d.cts +0 -2
- package/build/findEntityScopes.d.cts.map +1 -1
- package/build/findEntityScopes.d.mts +0 -2
- package/build/findEntityScopes.d.mts.map +1 -1
- package/build/findEntityScopes.js +1 -2
- package/build/foreignKeyOrdering.cjs +4 -5
- package/build/foreignKeyOrdering.cjs.map +1 -1
- package/build/foreignKeyOrdering.d.cts +0 -2
- package/build/foreignKeyOrdering.d.cts.map +1 -1
- package/build/foreignKeyOrdering.d.mts +0 -2
- package/build/foreignKeyOrdering.d.mts.map +1 -1
- package/build/foreignKeyOrdering.js +4 -5
- package/build/generate.cjs +21 -18
- package/build/generate.cjs.map +1 -1
- package/build/generate.d.cts +0 -2
- package/build/generate.d.cts.map +1 -1
- package/build/generate.d.mts +0 -2
- package/build/generate.d.mts.map +1 -1
- package/build/generate.js +21 -18
- package/build/generate.js.map +1 -1
- package/build/generateEntitiesFile.cjs +4 -5
- package/build/generateEntitiesFile.cjs.map +1 -1
- package/build/generateEntitiesFile.d.cts +2 -4
- package/build/generateEntitiesFile.d.cts.map +1 -1
- package/build/generateEntitiesFile.d.mts +2 -4
- package/build/generateEntitiesFile.d.mts.map +1 -1
- package/build/generateEntitiesFile.js +4 -5
- package/build/generateEntityCodegenFile.cjs +36 -23
- package/build/generateEntityCodegenFile.cjs.map +1 -1
- package/build/generateEntityCodegenFile.d.cts +1 -3
- package/build/generateEntityCodegenFile.d.cts.map +1 -1
- package/build/generateEntityCodegenFile.d.mts +2 -4
- package/build/generateEntityCodegenFile.d.mts.map +1 -1
- package/build/generateEntityCodegenFile.js +36 -23
- package/build/generateEntityCodegenFile.js.map +1 -1
- package/build/generateEntityFile.cjs +1 -2
- package/build/generateEntityFile.cjs.map +1 -1
- package/build/generateEntityFile.d.cts +0 -2
- package/build/generateEntityFile.d.cts.map +1 -1
- package/build/generateEntityFile.d.mts +0 -2
- package/build/generateEntityFile.d.mts.map +1 -1
- package/build/generateEntityFile.js +1 -2
- package/build/generateEntityTestFile.cjs +1 -2
- package/build/generateEntityTestFile.cjs.map +1 -1
- package/build/generateEntityTestFile.d.cts +0 -2
- package/build/generateEntityTestFile.d.cts.map +1 -1
- package/build/generateEntityTestFile.d.mts +0 -2
- package/build/generateEntityTestFile.d.mts.map +1 -1
- package/build/generateEntityTestFile.js +1 -2
- package/build/generateEnumFile.cjs +2 -3
- package/build/generateEnumFile.cjs.map +1 -1
- package/build/generateEnumFile.d.cts +0 -2
- package/build/generateEnumFile.d.cts.map +1 -1
- package/build/generateEnumFile.d.mts +0 -2
- package/build/generateEnumFile.d.mts.map +1 -1
- package/build/generateEnumFile.js +2 -3
- package/build/generateFactoriesFiles.cjs +2 -3
- package/build/generateFactoriesFiles.cjs.map +1 -1
- package/build/generateFactoriesFiles.d.cts +0 -2
- package/build/generateFactoriesFiles.d.cts.map +1 -1
- package/build/generateFactoriesFiles.d.mts +0 -2
- package/build/generateFactoriesFiles.d.mts.map +1 -1
- package/build/generateFactoriesFiles.js +2 -3
- package/build/generateFlushFunction.cjs +1 -2
- package/build/generateFlushFunction.d.cts +0 -2
- package/build/generateFlushFunction.d.cts.map +1 -1
- package/build/generateFlushFunction.d.mts +0 -2
- package/build/generateFlushFunction.d.mts.map +1 -1
- package/build/generateFlushFunction.js +1 -2
- package/build/generateMetadataFile.cjs +6 -4
- package/build/generateMetadataFile.cjs.map +1 -1
- package/build/generateMetadataFile.d.cts +0 -2
- package/build/generateMetadataFile.d.cts.map +1 -1
- package/build/generateMetadataFile.d.mts +0 -2
- package/build/generateMetadataFile.d.mts.map +1 -1
- package/build/generateMetadataFile.js +6 -4
- package/build/generateMetadataFile.js.map +1 -1
- package/build/generatePgEnumFile.cjs +1 -2
- package/build/generatePgEnumFile.cjs.map +1 -1
- package/build/generatePgEnumFile.d.cts +0 -2
- package/build/generatePgEnumFile.d.cts.map +1 -1
- package/build/generatePgEnumFile.d.mts +0 -2
- package/build/generatePgEnumFile.d.mts.map +1 -1
- package/build/generatePgEnumFile.js +1 -2
- package/build/index.cjs +8 -9
- package/build/index.cjs.map +1 -1
- package/build/index.d.cts +2 -3
- package/build/index.d.mts +1 -3
- package/build/index.d.mts.map +1 -1
- package/build/index.js +8 -9
- package/build/inheritance.cjs +2 -3
- package/build/inheritance.cjs.map +1 -1
- package/build/inheritance.d.cts +0 -2
- package/build/inheritance.d.cts.map +1 -1
- package/build/inheritance.d.mts +0 -2
- package/build/inheritance.d.mts.map +1 -1
- package/build/inheritance.js +2 -3
- package/build/installSkills.cjs +1 -2
- package/build/installSkills.cjs.map +1 -1
- package/build/installSkills.d.cts +0 -2
- package/build/installSkills.d.cts.map +1 -1
- package/build/installSkills.d.mts +0 -2
- package/build/installSkills.d.mts.map +1 -1
- package/build/installSkills.js +1 -2
- package/build/keywords.cjs +1 -2
- package/build/keywords.d.cts +0 -2
- package/build/keywords.d.cts.map +1 -1
- package/build/keywords.d.mts +0 -2
- package/build/keywords.d.mts.map +1 -1
- package/build/keywords.js +1 -2
- package/build/loadMetadata.cjs +2 -3
- package/build/loadMetadata.d.cts +1 -3
- package/build/loadMetadata.d.cts.map +1 -1
- package/build/loadMetadata.d.mts +1 -3
- package/build/loadMetadata.d.mts.map +1 -1
- package/build/loadMetadata.js +2 -3
- package/build/logger.cjs +1 -2
- package/build/logger.d.cts +0 -2
- package/build/logger.d.cts.map +1 -1
- package/build/logger.d.mts +0 -2
- package/build/logger.d.mts.map +1 -1
- package/build/logger.js +1 -2
- package/build/pgMetadata.cjs +1 -2
- package/build/pgMetadata.cjs.map +1 -1
- package/build/pgMetadata.d.cts +0 -2
- package/build/pgMetadata.d.cts.map +1 -1
- package/build/pgMetadata.d.mts +0 -2
- package/build/pgMetadata.d.mts.map +1 -1
- package/build/pgMetadata.js +1 -2
- package/build/pgMetadata.js.map +1 -1
- package/build/scanEntityFiles.cjs +1 -2
- package/build/scanEntityFiles.d.cts +0 -2
- package/build/scanEntityFiles.d.cts.map +1 -1
- package/build/scanEntityFiles.d.mts +0 -2
- package/build/scanEntityFiles.d.mts.map +1 -1
- package/build/scanEntityFiles.js +1 -2
- package/build/sortForeignKeys.cjs +1 -2
- package/build/sortForeignKeys.d.cts +0 -2
- package/build/sortForeignKeys.d.cts.map +1 -1
- package/build/sortForeignKeys.d.mts +0 -2
- package/build/sortForeignKeys.d.mts.map +1 -1
- package/build/sortForeignKeys.js +1 -2
- package/build/symbols.cjs +1 -2
- package/build/symbols.d.cts +0 -2
- package/build/symbols.d.cts.map +1 -1
- package/build/symbols.d.mts +0 -2
- package/build/symbols.d.mts.map +1 -1
- package/build/symbols.js +1 -2
- package/build/tsdoc.cjs +1 -2
- package/build/tsdoc.d.cts +0 -2
- package/build/tsdoc.d.cts.map +1 -1
- package/build/tsdoc.d.mts +0 -2
- package/build/tsdoc.d.mts.map +1 -1
- package/build/tsdoc.js +1 -2
- package/build/utils.cjs +2 -3
- package/build/utils.cjs.map +1 -1
- package/build/utils.d.cts +1 -3
- package/build/utils.d.cts.map +1 -1
- package/build/utils.d.mts +1 -3
- package/build/utils.d.mts.map +1 -1
- package/build/utils.js +2 -3
- package/build/write-json-schema.cjs +1 -2
- package/build/write-json-schema.cjs.map +1 -1
- package/build/write-json-schema.js +1 -2
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JscodeshiftMod.js","names":["jscodeshift"],"sources":["../../src/codemods/JscodeshiftMod.ts"],"sourcesContent":["import path from \"path\";\n\nimport fastglob from \"fast-glob\";\nimport { run as jscodeshift } from \"jscodeshift/src/Runner.js\";\n\nimport { type Config } from \"../config.ts\";\nimport { type Codemod } from \"./Codemod.ts\";\n\nexport class JscodeshiftMod implements Codemod {\n constructor(\n public codemodVersion: number,\n public name: string,\n public description: string,\n private glob: (config: Config) => string = defaultGlob,\n ) {}\n\n async run(config: Config): Promise<void> {\n const glob = this.glob(config);\n const extension = import.meta.filename.endsWith(\".cjs\") ? \".cjs\" : \".js\";\n const transformPath = path.resolve(import.meta.dirname, `${this.name}${extension}`);\n const paths = await fastglob(glob);\n console.log(`Running ${transformPath} against ${paths.length} files`);\n console.log(`There will be a lot of jscodeshift output after this...\\n\\n\\n`);\n await jscodeshift(transformPath, paths, {\n verbose: true,\n parser: \"ts\",\n });\n }\n}\n\n/** Returns the default source tree for project-wide codemods. */\nfunction defaultGlob(config: Config): string {\n return `${path.dirname(config.entitiesDirectory)}/**/*.ts`;\n}\n"],"mappings":";;;;;;AAQA,IAAa,iBAAb,MAA+C;CAEpC;CACA;CACA;CACC;CAJV,
|
|
1
|
+
{"version":3,"file":"JscodeshiftMod.js","names":["jscodeshift"],"sources":["../../src/codemods/JscodeshiftMod.ts"],"sourcesContent":["import path from \"path\";\n\nimport fastglob from \"fast-glob\";\nimport { run as jscodeshift } from \"jscodeshift/src/Runner.js\";\n\nimport { type Config } from \"../config.ts\";\nimport { type Codemod } from \"./Codemod.ts\";\n\nexport class JscodeshiftMod implements Codemod {\n constructor(\n public codemodVersion: number,\n public name: string,\n public description: string,\n private glob: (config: Config) => string = defaultGlob,\n ) {}\n\n async run(config: Config): Promise<void> {\n const glob = this.glob(config);\n const extension = import.meta.filename.endsWith(\".cjs\") ? \".cjs\" : \".js\";\n const transformPath = path.resolve(import.meta.dirname, `${this.name}${extension}`);\n const paths = await fastglob(glob);\n console.log(`Running ${transformPath} against ${paths.length} files`);\n console.log(`There will be a lot of jscodeshift output after this...\\n\\n\\n`);\n await jscodeshift(transformPath, paths, {\n verbose: true,\n parser: \"ts\",\n });\n }\n}\n\n/** Returns the default source tree for project-wide codemods. */\nfunction defaultGlob(config: Config): string {\n return `${path.dirname(config.entitiesDirectory)}/**/*.ts`;\n}\n"],"mappings":";;;;;;AAQA,IAAa,iBAAb,MAA+C;CAEpC;CACA;CACA;CACC;CAJV,YACS,gBACA,MACA,aACC,OAAmC,aAC3C;EAJO,KAAA,iBAAA;EACA,KAAA,OAAA;EACA,KAAA,cAAA;EACC,KAAA,OAAA;CACP;CAEH,MAAM,IAAI,QAA+B;EACvC,MAAM,OAAO,KAAK,KAAK,MAAM;EAC7B,MAAM,YAAY,YAAY,SAAS,SAAS,MAAM,IAAI,SAAS;EACnE,MAAM,gBAAgB,KAAK,QAAQ,YAAY,SAAS,GAAG,KAAK,OAAO,WAAW;EAClF,MAAM,QAAQ,MAAM,SAAS,IAAI;EACjC,QAAQ,IAAI,WAAW,cAAc,WAAW,MAAM,OAAO,OAAO;EACpE,QAAQ,IAAI,+DAA+D;EAC3E,MAAMA,IAAY,eAAe,OAAO;GACtC,SAAS;GACT,QAAQ;EACV,CAAC;CACH;AACF;;AAGA,SAAS,YAAY,QAAwB;CAC3C,OAAO,GAAG,KAAK,QAAQ,OAAO,iBAAiB,EAAE;AACnD"}
|
|
@@ -4,7 +4,7 @@ Object.defineProperties(exports, {
|
|
|
4
4
|
});
|
|
5
5
|
const require_codemods_JscodeshiftMod = require("./JscodeshiftMod.cjs");
|
|
6
6
|
require("jscodeshift");
|
|
7
|
-
|
|
7
|
+
// src/codemods/codemod_0001-rename_has_async_property.ts
|
|
8
8
|
const codemod_0001_rename_has_async_property = new require_codemods_JscodeshiftMod.JscodeshiftMod(1, "codemod_0001-rename_has_async_property", "Rename `hasAsyncProperty` to `hasProperty`");
|
|
9
9
|
const renames = /* @__PURE__ */ new Map([
|
|
10
10
|
["hasAsyncProperty", "hasProperty"],
|
|
@@ -23,7 +23,6 @@ const transform = function(file, api) {
|
|
|
23
23
|
j(path).replaceWith(j.identifier(rename));
|
|
24
24
|
}).toSource();
|
|
25
25
|
};
|
|
26
|
-
//#endregion
|
|
27
26
|
exports.codemod_0001_rename_has_async_property = codemod_0001_rename_has_async_property;
|
|
28
27
|
exports.default = transform;
|
|
29
28
|
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { JscodeshiftMod } from "./JscodeshiftMod.cjs";
|
|
2
2
|
import { Transform } from "jscodeshift";
|
|
3
|
-
//#region src/codemods/codemod_0001-rename_has_async_property.d.ts
|
|
4
3
|
export declare const codemod_0001_rename_has_async_property: JscodeshiftMod;
|
|
5
4
|
/** Find/replace the various `*AsyncProperty*` symbols with their `*Property*` counterparts. */
|
|
6
5
|
declare const transform: Transform;
|
|
7
|
-
//#endregion
|
|
8
6
|
export { transform as default };
|
|
9
7
|
//# sourceMappingURL=codemod_0001-rename_has_async_property.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codemod_0001-rename_has_async_property.d.cts","names":[],"sources":["../../src/codemods/codemod_0001-rename_has_async_property.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"codemod_0001-rename_has_async_property.d.cts","names":[],"sources":["../../src/codemods/codemod_0001-rename_has_async_property.ts"],"mappings":";;qBAIa,wCAAsC;;cAgB7C,WAAW"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { JscodeshiftMod } from "./JscodeshiftMod.mjs";
|
|
2
2
|
import { Transform } from "jscodeshift";
|
|
3
|
-
//#region src/codemods/codemod_0001-rename_has_async_property.d.ts
|
|
4
3
|
export declare const codemod_0001_rename_has_async_property: JscodeshiftMod;
|
|
5
4
|
/** Find/replace the various `*AsyncProperty*` symbols with their `*Property*` counterparts. */
|
|
6
5
|
declare const transform: Transform;
|
|
7
|
-
//#endregion
|
|
8
6
|
export { transform as default };
|
|
9
7
|
//# sourceMappingURL=codemod_0001-rename_has_async_property.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codemod_0001-rename_has_async_property.d.mts","names":[],"sources":["../../src/codemods/codemod_0001-rename_has_async_property.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"codemod_0001-rename_has_async_property.d.mts","names":[],"sources":["../../src/codemods/codemod_0001-rename_has_async_property.ts"],"mappings":";;qBAIa,wCAAsC;;cAgB7C,WAAW"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JscodeshiftMod } from "./JscodeshiftMod.js";
|
|
2
2
|
import "jscodeshift";
|
|
3
|
-
|
|
3
|
+
// src/codemods/codemod_0001-rename_has_async_property.ts
|
|
4
4
|
const codemod_0001_rename_has_async_property = new JscodeshiftMod(1, "codemod_0001-rename_has_async_property", "Rename `hasAsyncProperty` to `hasProperty`");
|
|
5
5
|
const renames = /* @__PURE__ */ new Map([
|
|
6
6
|
["hasAsyncProperty", "hasProperty"],
|
|
@@ -19,7 +19,6 @@ const transform = function(file, api) {
|
|
|
19
19
|
j(path).replaceWith(j.identifier(rename));
|
|
20
20
|
}).toSource();
|
|
21
21
|
};
|
|
22
|
-
//#endregion
|
|
23
22
|
export { codemod_0001_rename_has_async_property, transform as default };
|
|
24
23
|
|
|
25
24
|
//# sourceMappingURL=codemod_0001-rename_has_async_property.js.map
|
|
@@ -4,7 +4,7 @@ Object.defineProperties(exports, {
|
|
|
4
4
|
});
|
|
5
5
|
const require_codemods_JscodeshiftMod = require("./JscodeshiftMod.cjs");
|
|
6
6
|
require("jscodeshift");
|
|
7
|
-
|
|
7
|
+
// src/codemods/codemod_0002-rename_async_query_fields.ts
|
|
8
8
|
const codemod_0002_rename_async_query_fields = new require_codemods_JscodeshiftMod.JscodeshiftMod(2, "codemod_0002-rename_async_query_fields", "Rename async query property/field APIs to async property/field APIs");
|
|
9
9
|
const renames = /* @__PURE__ */ new Map([
|
|
10
10
|
["AsyncQueryProperty", "Property"],
|
|
@@ -43,7 +43,6 @@ function renameModulePath(value) {
|
|
|
43
43
|
const rename = value.replace(/hasAsyncQueryProperty$/, "AsyncProperty").replace(/ReactiveQueryField$/, "AsyncReactiveField");
|
|
44
44
|
return rename === value ? void 0 : rename;
|
|
45
45
|
}
|
|
46
|
-
//#endregion
|
|
47
46
|
exports.codemod_0002_rename_async_query_fields = codemod_0002_rename_async_query_fields;
|
|
48
47
|
exports.default = transform;
|
|
49
48
|
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { JscodeshiftMod } from "./JscodeshiftMod.cjs";
|
|
2
2
|
import { Transform } from "jscodeshift";
|
|
3
|
-
//#region src/codemods/codemod_0002-rename_async_query_fields.d.ts
|
|
4
3
|
export declare const codemod_0002_rename_async_query_fields: JscodeshiftMod;
|
|
5
4
|
/** Find/replace the async query symbols with their async property/field counterparts. */
|
|
6
5
|
declare const transform: Transform;
|
|
7
|
-
//#endregion
|
|
8
6
|
export { transform as default };
|
|
9
7
|
//# sourceMappingURL=codemod_0002-rename_async_query_fields.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codemod_0002-rename_async_query_fields.d.cts","names":[],"sources":["../../src/codemods/codemod_0002-rename_async_query_fields.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"codemod_0002-rename_async_query_fields.d.cts","names":[],"sources":["../../src/codemods/codemod_0002-rename_async_query_fields.ts"],"mappings":";;qBAIa,wCAAsC;;cAoB7C,WAAW"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { JscodeshiftMod } from "./JscodeshiftMod.mjs";
|
|
2
2
|
import { Transform } from "jscodeshift";
|
|
3
|
-
//#region src/codemods/codemod_0002-rename_async_query_fields.d.ts
|
|
4
3
|
export declare const codemod_0002_rename_async_query_fields: JscodeshiftMod;
|
|
5
4
|
/** Find/replace the async query symbols with their async property/field counterparts. */
|
|
6
5
|
declare const transform: Transform;
|
|
7
|
-
//#endregion
|
|
8
6
|
export { transform as default };
|
|
9
7
|
//# sourceMappingURL=codemod_0002-rename_async_query_fields.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codemod_0002-rename_async_query_fields.d.mts","names":[],"sources":["../../src/codemods/codemod_0002-rename_async_query_fields.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"codemod_0002-rename_async_query_fields.d.mts","names":[],"sources":["../../src/codemods/codemod_0002-rename_async_query_fields.ts"],"mappings":";;qBAIa,wCAAsC;;cAoB7C,WAAW"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JscodeshiftMod } from "./JscodeshiftMod.js";
|
|
2
2
|
import "jscodeshift";
|
|
3
|
-
|
|
3
|
+
// src/codemods/codemod_0002-rename_async_query_fields.ts
|
|
4
4
|
const codemod_0002_rename_async_query_fields = new JscodeshiftMod(2, "codemod_0002-rename_async_query_fields", "Rename async query property/field APIs to async property/field APIs");
|
|
5
5
|
const renames = /* @__PURE__ */ new Map([
|
|
6
6
|
["AsyncQueryProperty", "Property"],
|
|
@@ -39,7 +39,6 @@ function renameModulePath(value) {
|
|
|
39
39
|
const rename = value.replace(/hasAsyncQueryProperty$/, "AsyncProperty").replace(/ReactiveQueryField$/, "AsyncReactiveField");
|
|
40
40
|
return rename === value ? void 0 : rename;
|
|
41
41
|
}
|
|
42
|
-
//#endregion
|
|
43
42
|
export { codemod_0002_rename_async_query_fields, transform as default };
|
|
44
43
|
|
|
45
44
|
//# sourceMappingURL=codemod_0002-rename_async_query_fields.js.map
|
|
@@ -4,7 +4,7 @@ Object.defineProperties(exports, {
|
|
|
4
4
|
});
|
|
5
5
|
const require_codemods_JscodeshiftMod = require("./JscodeshiftMod.cjs");
|
|
6
6
|
require("jscodeshift");
|
|
7
|
-
|
|
7
|
+
// src/codemods/codemod_0003-rename_find_paginated.ts
|
|
8
8
|
const codemod_0003_rename_find_paginated = new require_codemods_JscodeshiftMod.JscodeshiftMod(3, "codemod_0003-rename_find_paginated", "Rename EntityManager findPaginated APIs to find APIs");
|
|
9
9
|
const renames = /* @__PURE__ */ new Map([["findPaginated", "find"], ["findGqlPaginated", "findGql"]]);
|
|
10
10
|
/** Rewrites EntityManager paginated find method calls to the now-paginated find APIs. */
|
|
@@ -18,7 +18,6 @@ const transform = function(file, api) {
|
|
|
18
18
|
property.name = rename;
|
|
19
19
|
}).toSource();
|
|
20
20
|
};
|
|
21
|
-
//#endregion
|
|
22
21
|
exports.codemod_0003_rename_find_paginated = codemod_0003_rename_find_paginated;
|
|
23
22
|
exports.default = transform;
|
|
24
23
|
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { JscodeshiftMod } from "./JscodeshiftMod.cjs";
|
|
2
2
|
import { Transform } from "jscodeshift";
|
|
3
|
-
//#region src/codemods/codemod_0003-rename_find_paginated.d.ts
|
|
4
3
|
export declare const codemod_0003_rename_find_paginated: JscodeshiftMod;
|
|
5
4
|
/** Rewrites EntityManager paginated find method calls to the now-paginated find APIs. */
|
|
6
5
|
declare const transform: Transform;
|
|
7
|
-
//#endregion
|
|
8
6
|
export { transform as default };
|
|
9
7
|
//# sourceMappingURL=codemod_0003-rename_find_paginated.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codemod_0003-rename_find_paginated.d.cts","names":[],"sources":["../../src/codemods/codemod_0003-rename_find_paginated.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"codemod_0003-rename_find_paginated.d.cts","names":[],"sources":["../../src/codemods/codemod_0003-rename_find_paginated.ts"],"mappings":";;qBAIa,oCAAkC;;cAYzC,WAAW"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { JscodeshiftMod } from "./JscodeshiftMod.mjs";
|
|
2
2
|
import { Transform } from "jscodeshift";
|
|
3
|
-
//#region src/codemods/codemod_0003-rename_find_paginated.d.ts
|
|
4
3
|
export declare const codemod_0003_rename_find_paginated: JscodeshiftMod;
|
|
5
4
|
/** Rewrites EntityManager paginated find method calls to the now-paginated find APIs. */
|
|
6
5
|
declare const transform: Transform;
|
|
7
|
-
//#endregion
|
|
8
6
|
export { transform as default };
|
|
9
7
|
//# sourceMappingURL=codemod_0003-rename_find_paginated.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codemod_0003-rename_find_paginated.d.mts","names":[],"sources":["../../src/codemods/codemod_0003-rename_find_paginated.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"codemod_0003-rename_find_paginated.d.mts","names":[],"sources":["../../src/codemods/codemod_0003-rename_find_paginated.ts"],"mappings":";;qBAIa,oCAAkC;;cAYzC,WAAW"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JscodeshiftMod } from "./JscodeshiftMod.js";
|
|
2
2
|
import "jscodeshift";
|
|
3
|
-
|
|
3
|
+
// src/codemods/codemod_0003-rename_find_paginated.ts
|
|
4
4
|
const codemod_0003_rename_find_paginated = new JscodeshiftMod(3, "codemod_0003-rename_find_paginated", "Rename EntityManager findPaginated APIs to find APIs");
|
|
5
5
|
const renames = /* @__PURE__ */ new Map([["findPaginated", "find"], ["findGqlPaginated", "findGql"]]);
|
|
6
6
|
/** Rewrites EntityManager paginated find method calls to the now-paginated find APIs. */
|
|
@@ -14,7 +14,6 @@ const transform = function(file, api) {
|
|
|
14
14
|
property.name = rename;
|
|
15
15
|
}).toSource();
|
|
16
16
|
};
|
|
17
|
-
//#endregion
|
|
18
17
|
export { codemod_0003_rename_find_paginated, transform as default };
|
|
19
18
|
|
|
20
19
|
//# sourceMappingURL=codemod_0003-rename_find_paginated.js.map
|
package/build/codemods/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../config.cjs");
|
|
2
3
|
require("./Codemod.cjs");
|
|
3
4
|
const require_codemods_codemod_0001_rename_has_async_property = require("./codemod_0001-rename_has_async_property.cjs");
|
|
4
5
|
const require_codemods_codemod_0002_rename_async_query_fields = require("./codemod_0002-rename_async_query_fields.cjs");
|
|
5
6
|
const require_codemods_codemod_0003_rename_find_paginated = require("./codemod_0003-rename_find_paginated.cjs");
|
|
6
|
-
|
|
7
|
-
//#region src/codemods/index.ts
|
|
7
|
+
// src/codemods/index.ts
|
|
8
8
|
const codemods = [
|
|
9
9
|
require_codemods_codemod_0001_rename_has_async_property.codemod_0001_rename_has_async_property,
|
|
10
10
|
require_codemods_codemod_0002_rename_async_query_fields.codemod_0002_rename_async_query_fields,
|
|
@@ -41,7 +41,6 @@ function getLatestCodemodVersion() {
|
|
|
41
41
|
function findApplicableCodemods(codemodVersion) {
|
|
42
42
|
return codemods.filter((codemod) => codemod.codemodVersion > codemodVersion);
|
|
43
43
|
}
|
|
44
|
-
//#endregion
|
|
45
44
|
exports.findApplicableCodemods = findApplicableCodemods;
|
|
46
45
|
exports.getLatestCodemodVersion = getLatestCodemodVersion;
|
|
47
46
|
exports.maybeRunTransforms = maybeRunTransforms;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { Config } from "../config.cjs";
|
|
2
2
|
import { Codemod } from "./Codemod.cjs";
|
|
3
|
-
//#region src/codemods/index.d.ts
|
|
4
3
|
/** Prompts for and runs pending codemods for the user's project. */
|
|
5
4
|
export declare function maybeRunTransforms(config: Config): Promise<void>;
|
|
6
5
|
/** Returns the highest codemod counter known by this version of codegen. */
|
|
7
6
|
export declare function getLatestCodemodVersion(): number;
|
|
8
7
|
/** Returns codemods that have not yet been applied to the user's project. */
|
|
9
8
|
export declare function findApplicableCodemods(codemodVersion: number): Codemod[];
|
|
10
|
-
//#endregion
|
|
11
9
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/codemods/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/codemods/index.ts"],"mappings":";;;wBAasB,mBAAmB,QAAQ,SAAS;;wBA0C1C;;wBAKA,uBAAuB,yBAAyB"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { Config } from "../config.mjs";
|
|
2
2
|
import { Codemod } from "./Codemod.mjs";
|
|
3
|
-
//#region src/codemods/index.d.ts
|
|
4
3
|
/** Prompts for and runs pending codemods for the user's project. */
|
|
5
4
|
export declare function maybeRunTransforms(config: Config): Promise<void>;
|
|
6
5
|
/** Returns the highest codemod counter known by this version of codegen. */
|
|
7
6
|
export declare function getLatestCodemodVersion(): number;
|
|
8
7
|
/** Returns codemods that have not yet been applied to the user's project. */
|
|
9
8
|
export declare function findApplicableCodemods(codemodVersion: number): Codemod[];
|
|
10
|
-
//#endregion
|
|
11
9
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/codemods/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/codemods/index.ts"],"mappings":";;;wBAasB,mBAAmB,QAAQ,SAAS;;wBA0C1C;;wBAKA,uBAAuB,yBAAyB"}
|
package/build/codemods/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import "../config.js";
|
|
1
2
|
import "./Codemod.js";
|
|
2
3
|
import { codemod_0001_rename_has_async_property } from "./codemod_0001-rename_has_async_property.js";
|
|
3
4
|
import { codemod_0002_rename_async_query_fields } from "./codemod_0002-rename_async_query_fields.js";
|
|
4
5
|
import { codemod_0003_rename_find_paginated } from "./codemod_0003-rename_find_paginated.js";
|
|
5
|
-
|
|
6
|
-
//#region src/codemods/index.ts
|
|
6
|
+
// src/codemods/index.ts
|
|
7
7
|
const codemods = [
|
|
8
8
|
codemod_0001_rename_has_async_property,
|
|
9
9
|
codemod_0002_rename_async_query_fields,
|
|
@@ -40,7 +40,6 @@ function getLatestCodemodVersion() {
|
|
|
40
40
|
function findApplicableCodemods(codemodVersion) {
|
|
41
41
|
return codemods.filter((codemod) => codemod.codemodVersion > codemodVersion);
|
|
42
42
|
}
|
|
43
|
-
//#endregion
|
|
44
43
|
export { findApplicableCodemods, getLatestCodemodVersion, maybeRunTransforms };
|
|
45
44
|
|
|
46
45
|
//# sourceMappingURL=index.js.map
|
package/build/config.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_codemods_index = require("./codemods/index.cjs");
|
|
3
|
-
|
|
3
|
+
require("./EntityDbMetadata.cjs");
|
|
4
4
|
const require_inheritance = require("./inheritance.cjs");
|
|
5
5
|
const require_logger = require("./logger.cjs");
|
|
6
|
-
require("./
|
|
6
|
+
const require_utils = require("./utils.cjs");
|
|
7
7
|
let joist_utils = require("joist-utils");
|
|
8
8
|
let fs = require("fs");
|
|
9
9
|
let path = require("path");
|
|
@@ -11,7 +11,7 @@ let _dprint_formatter = require("@dprint/formatter");
|
|
|
11
11
|
let _dprint_json = require("@dprint/json");
|
|
12
12
|
let jsonc_parser = require("jsonc-parser");
|
|
13
13
|
let zod = require("zod");
|
|
14
|
-
|
|
14
|
+
// src/config.ts
|
|
15
15
|
const jsonFormatter = (0, _dprint_formatter.createFromBuffer)((0, fs.readFileSync)((0, _dprint_json.getPath)()));
|
|
16
16
|
const fieldConfig = zod.z.object({
|
|
17
17
|
derived: zod.z.optional(zod.z.union([zod.z.literal("sync"), zod.z.literal("async")])),
|
|
@@ -116,6 +116,8 @@ const config = zod.z.object({
|
|
|
116
116
|
* of test database names, i.e. `mydb_test_1`, `mydb_test_2`, etc.
|
|
117
117
|
*/
|
|
118
118
|
createFlushFunction: zod.z.optional(zod.z.union([zod.z.boolean(), zod.z.array(zod.z.string())])),
|
|
119
|
+
/** Creates a starter test alongside each new entity file unless explicitly disabled. */
|
|
120
|
+
scaffoldTests: zod.z.optional(zod.z.boolean()),
|
|
119
121
|
entitiesDirectory: zod.z.string().default("./src/entities"),
|
|
120
122
|
codegenPlugins: zod.z.optional(zod.z.array(zod.z.string())),
|
|
121
123
|
entities: zod.z.record(zod.z.string(), entityConfig).default({}),
|
|
@@ -356,7 +358,6 @@ function findTsConfigFile(directory) {
|
|
|
356
358
|
directory = parent;
|
|
357
359
|
}
|
|
358
360
|
}
|
|
359
|
-
//#endregion
|
|
360
361
|
exports.config = config;
|
|
361
362
|
exports.fieldTypeConfig = fieldTypeConfig;
|
|
362
363
|
exports.getTimestampConfig = getTimestampConfig;
|
package/build/config.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.cjs","names":["createFromBuffer","readFileSync","getPath","z","groupBy","getStiEntities","trueIfResolved","getLatestCodemodVersion","sortKeys","parse","join","existsSync","dirname"],"sources":["../src/config.ts"],"sourcesContent":["import { existsSync, promises as fs, readFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\n\nimport { createFromBuffer } from \"@dprint/formatter\";\nimport { getPath } from \"@dprint/json\";\nimport { groupBy } from \"joist-utils\";\nimport { type ParseError, parse } from \"jsonc-parser\";\nimport { z } from \"zod\";\n\nimport { getLatestCodemodVersion } from \"./codemods/index.ts\";\nimport { type DbMetadata, type Entity, type EntityDbMetadata } from \"./EntityDbMetadata.ts\";\nimport { getStiEntities } from \"./inheritance.ts\";\nimport { logger } from \"./logger.ts\";\nimport { fail, sortKeys, trueIfResolved } from \"./utils.ts\";\n\nconst jsonFormatter = createFromBuffer(readFileSync(getPath()));\n\nconst fieldConfig = z\n .object({\n // For getters & ReactiveFields\n derived: z.optional(z.union([z.literal(\"sync\"), z.literal(\"async\")])),\n protected: z.optional(z.boolean()),\n ignore: z.optional(z.boolean()),\n superstruct: z.optional(z.string()),\n zodSchema: z.optional(z.string()),\n type: z.optional(z.string()),\n serde: z.optional(z.string()),\n stiDiscriminator: z.optional(z.record(z.string(), z.string())),\n stiType: z.optional(z.union([z.string(), z.array(z.string())])),\n // Allow subclasses to mark fields as required\n notNull: z.optional(z.boolean()),\n // Allow overriding scanEntities default detection for fields with defaults added by helpers\n hasDefault: z.optional(z.boolean()),\n // Exclude a (large jsonb/text) column from the default SELECT and expose it as a lazy-loaded LazyField\n lazy: z.optional(z.boolean()),\n /** Mark the entity for read locking whenever the field's value is read. */\n assertUnchanged: z.optional(z.boolean()),\n })\n .strict()\n .refine((field) => !field.assertUnchanged || (!field.derived && !field.lazy && !field.ignore), {\n message: \"assertUnchanged requires a non-derived, non-lazy, non-ignored field\",\n path: [\"assertUnchanged\"],\n });\n\nexport type FieldConfig = z.infer<typeof fieldConfig>;\n\nconst relationConfig = z\n .object({\n // For ReactiveReferences\n derived: z.optional(z.literal(\"async\")),\n polymorphic: z.optional(z.union([z.literal(\"notNull\"), z.literal(true)])),\n large: z.optional(z.boolean()),\n orderBy: z.optional(z.string()),\n /**\n * Controls whether this collection's `.get`/`.load` hide soft-deleted entities.\n *\n * Defaults to `\"exclude\"` (soft-deleted entities are hidden); set to `\"include\"` to have\n * this specific o2m/m2m always return soft-deleted entities from `.get`/`.load`.\n */\n softDeletes: z.optional(z.union([z.literal(\"include\"), z.literal(\"exclude\")])),\n // Allow pushing m2o/m2m/o2o relations in a base type (Task) down to a subtype (TaskOld)\n stiType: z.optional(z.union([z.string(), z.array(z.string())])),\n /**\n * Allow specializing a base type relation (SmallPublisher.group: SmallPublisherGroup).\n *\n * Self-referential FKs also support `subType: \"self\"` that means each subtype will point\n * at its own subtype.\n */\n subType: z.optional(z.string()),\n /** Allow skipping self-referential fields getting a `...Recursive` relation. */\n skipRecursiveRelations: z.optional(z.boolean()),\n // Allow marking m2o FKs as required on subclasses\n notNull: z.optional(z.boolean()),\n // Allow overriding scanEntities default detection for fields with defaults added by helpers\n hasDefault: z.optional(z.boolean()),\n })\n .strict();\n\nexport type RelationConfig = z.infer<typeof relationConfig>;\n\nconst uniqueByConfig = z\n .union([z.string(), z.array(z.string()), z.array(z.array(z.string()))])\n .transform(normalizeUniqueByConfig);\n\nconst entityConfig = z\n .object({\n tag: z.string(),\n tableName: z.optional(z.string()),\n fields: z.optional(z.record(z.string(), fieldConfig)),\n relations: z.optional(z.record(z.string(), relationConfig)),\n /** Whether this entity should be abstract, e.g. for inheritance a subtype must be instantiated instead of this type. */\n abstract: z.optional(z.boolean()),\n orderBy: z.optional(z.string()),\n uniqueBy: z.optional(uniqueByConfig),\n })\n .strict();\n\nexport type EntityConfig = z.infer<typeof entityConfig>;\n\nconst timestampConfig = z\n .object({\n /** The names to check for this timestamp, i.e. `created_at` `created`, etc. */\n names: z.array(z.string()),\n /** Whether this timestamp column is required to consider a table an entity, defaults to `false`. */\n required: z.optional(z.boolean()),\n })\n .strict();\n\nexport type TimestampConfig = z.infer<typeof timestampConfig>;\n\nexport const config = z\n .object({\n /** The _build-time_ database URL for reading database metadata. */\n databaseUrl: z.optional(z.string()),\n /** Your application's request-level `Context` type. */\n contextType: z.optional(z.string()),\n /** Your application's database client's `Transaction` type. */\n transactionType: z.optional(z.string()),\n /**\n * Allows the user to specify the `updated_at` / `created_at` column names to look up, and if they're optional.\n *\n * We default to looking for `updated_at`, `updatedAt`, `created_at`, `createdAt`, and optional to true,\n * e.g. tables are not required to have both timestamp columns to be considered entities.\n *\n * These defaults are the most lenient, to facilitate running Joist against an existing schema and\n * seeing all of your entities, regardless of your previous conventions.\n */\n timestampColumns: z.optional(\n z.object({\n createdAt: z.optional(timestampConfig),\n updatedAt: z.optional(timestampConfig),\n deletedAt: z.optional(timestampConfig),\n }),\n ),\n /**\n * Allows the user to have codegen output `Temporal` types instead of the base JS `Date`\n *\n * Additionally, allows for specifying the default time zone for `Temporal` types when converting dates to/from\n * the database.\n */\n temporal: z.optional(z.union([z.boolean(), z.object({ timeZone: z.string() })])),\n /**\n * By default, we create a `flush_database` function for fast testing.\n *\n * However, if you don't want to use this, or you have your own bespoke function like we do\n * that is more application-aware, then you can disable Joist's out-of-the-box one.\n *\n * If you have more than one test database, you can set `createFlushFunction` to the array\n * of test database names, i.e. `mydb_test_1`, `mydb_test_2`, etc.\n */\n createFlushFunction: z.optional(z.union([z.boolean(), z.array(z.string())])),\n entitiesDirectory: z.string().default(\"./src/entities\"),\n codegenPlugins: z.optional(z.array(z.string())),\n entities: z.record(z.string(), entityConfig).default({}),\n ignoredTables: z.optional(z.array(z.string())),\n /** The type of entity `id` fields; defaults to `tagged-string`. */\n idType: z.optional(z.union([z.literal(\"tagged-string\"), z.literal(\"untagged-string\"), z.literal(\"number\")])),\n /** The separator between entity tags and ids; defaults to `:`, and `\"\"` disables the separator. */\n tagDelimiter: z.optional(z.string()),\n /** How we should support non-deferred foreign keys. */\n nonDeferredForeignKeys: z.optional(z.union([z.literal(\"error\"), z.literal(\"warn\"), z.literal(\"ignore\")])),\n /** Enables esm output. */\n esm: z.optional(z.boolean()),\n /** Controls the style of GraphQL pagination scaffolding. */\n paginationStyle: z.optional(z.union([z.literal(\"cursor\"), z.literal(\"limit\")])).default(\"cursor\"),\n /** Enables documentation syncing between .md files and JSDocs. */\n docs: z.optional(z.boolean()),\n /** Installs Joist's bundled Agent Skills into `.claude/skills` and `.agents/skills`; on by default, set `false` to disable. */\n skills: z.optional(z.boolean()),\n /** Output a metadata-docs.ts file with entity/field documentation available at runtime. */\n outputDocs: z.optional(z.boolean()),\n /** Auto-set by probing the project's `tsconfig.json` file. */\n allowImportingTsExtensions: z.optional(z.boolean()),\n /** The latest Joist codemod counter that has been applied to this project. */\n codemodVersion: z.number().int().min(0).default(0),\n\n /** A list of postgres schemas to use for finding tables */\n schemas: z.optional(z.array(z.string())),\n })\n .strict();\n\nexport type Config = z.infer<typeof config> & {\n // We don't persist this, and instead just use it as a cache\n __tableToEntityName?: Record<string, string>;\n};\n\nexport const ormMaintainedFields = [\"createdAt\", \"updatedAt\"];\n\n/** Ensure the user doesn't have any typos in their config. */\nexport function warnInvalidConfigEntries(config: Config, db: DbMetadata): void {\n const entitiesByName = groupBy(db.entities, (e) => e.name);\n for (const [entityName, entityConfig] of Object.entries(config.entities)) {\n const entities = entitiesByName[entityName];\n if (!entities) {\n logger.warn(`Found config for non-existent entity ${entityName}`);\n continue;\n }\n // We don't have keyBy...\n const [entity] = entities;\n\n // Check fields\n const fields = [...entity.primitives, ...entity.enums];\n for (const [name, config] of Object.entries(entityConfig.fields || {})) {\n if (config.ignore) continue;\n let field = fields.find((f) => f.fieldName === name);\n // STI types might be in the base type\n if (!field && entity.stiDiscriminatorField) {\n const stiEntities = getStiEntities(db.entities).get(entity.name)?.subTypes;\n field = stiEntities?.flatMap((st) => [...st.primitives, ...st.enums]).find((f) => f.fieldName === name);\n }\n if (!field) logger.warn(`Found config for non-existent field ${entityName}.${name}`);\n }\n\n // Check relations\n const relations = [\n ...entity.manyToOnes,\n ...entity.oneToManys,\n ...entity.manyToManys,\n ...entity.manyToManyEnums,\n ...entity.oneToOnes,\n ...entity.largeOneToManys,\n ...entity.largeManyToManys,\n ...entity.polymorphics,\n ];\n for (const [name, _] of Object.entries(entityConfig.relations || {})) {\n let relation = relations.find((r) => r.fieldName === name);\n // STI types might be in the subtypes\n if (!relation && entity.stiDiscriminatorField) {\n const stiEntities = getStiEntities(db.entities).get(entity.name)?.subTypes;\n relation = stiEntities\n ?.flatMap((entity) => [\n ...entity.manyToOnes,\n ...entity.oneToManys,\n ...entity.manyToManys,\n ...entity.oneToOnes,\n ...entity.largeOneToManys,\n ...entity.largeManyToManys,\n ...entity.polymorphics,\n ])\n ?.find((f) => f.fieldName === name);\n }\n // CTI subtype specializations (i.e. SmallPublisher.group: SmallPublisherGroup) need to look in the base type\n if (!relation && entity.baseType) {\n const baseType = entity.baseType;\n relation = [\n ...baseType.manyToOnes,\n ...baseType.oneToManys,\n ...baseType.manyToManys,\n ...baseType.oneToOnes,\n ...baseType.largeOneToManys,\n ...baseType.largeManyToManys,\n ...baseType.polymorphics,\n ].find((f) => f.fieldName === name);\n }\n\n if (!relation) logger.warn(`Found config for non-existent relation ${entityName}.${name}`);\n }\n\n const uniqueFields = [\n ...entity.primitives,\n ...entity.enums,\n ...entity.pgEnums,\n ...entity.manyToOnes,\n ...entity.polymorphics,\n ];\n for (const uniqueBy of entityConfig.uniqueBy || []) {\n for (const name of uniqueBy) {\n const field = uniqueFields.find((f) => f.fieldName === name);\n if (!field) {\n logger.warn(`Found uniqueBy for non-existent or non-queryable field ${entityName}.${name}`);\n } else if (field.kind === \"primitive\" && (field.derived || field.customSerde)) {\n logger.warn(`Found uniqueBy for unsupported primitive field ${entityName}.${name}`);\n } else if (field.kind === \"enum\" && (field.derived || field.isArray)) {\n logger.warn(`Found uniqueBy for unsupported enum field ${entityName}.${name}`);\n }\n }\n }\n }\n}\n\nexport function isGetterField(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.derived === \"sync\";\n}\n\nexport function isReactiveField(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.derived === \"async\";\n}\n\nexport function isReactiveReference(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.relations?.[fieldName]?.derived === \"async\";\n}\n\n/** Returns true if this m2m relation is configured as a ReactiveManyToMany (derived: async). */\nexport function isReactiveManyToMany(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.relations?.[fieldName]?.derived === \"async\";\n}\n\nexport function isProtected(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.protected === true;\n}\n\n/** Whether a column should be excluded from the default SELECT and exposed as a lazy-loaded `LazyField`. */\nexport function isLazyField(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.lazy === true;\n}\n\nexport function serdeConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.serde;\n}\n\nexport function superstructConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.superstruct;\n}\n\nexport function zodSchemaConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.zodSchema;\n}\n\nexport function fieldTypeConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.type;\n}\n\nexport function isLargeCollection(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.relations?.[fieldName]?.large === true;\n}\n\n/** Whether a collection should include (or exclude) soft-deleted entities from `.get`/`.load`. */\nexport function softDeletesConfig(\n config: Config,\n entity: Entity,\n fieldName: string,\n): \"include\" | \"exclude\" | undefined {\n return config.entities[entity.name]?.relations?.[fieldName]?.softDeletes;\n}\n\nexport function isFieldIgnored(\n config: Config,\n entity: Entity,\n fieldName: string,\n notNull: boolean = false,\n hasDefault: boolean = false,\n): boolean {\n const ignore = config.entities[entity.name]?.fields?.[fieldName]?.ignore === true;\n if (ignore && notNull && !hasDefault) {\n fail(\n `notNull field ${entity.name}.${fieldName} cannot be ignored. Alter the column to be optional or have a default value prior to ignoring it.`,\n );\n }\n return ignore;\n}\n\nexport function isFieldHasDefault(config: Config, entity: Entity, fieldName: string): boolean {\n const entityConfig = config.entities[entity.name] ?? {};\n const fieldConfig = entityConfig.fields?.[fieldName] ?? entityConfig.relations?.[fieldName] ?? {};\n return fieldConfig.hasDefault === true;\n}\n\nconst configPath = \"./joist-config.json\";\n\nexport async function loadConfig(): Promise<Config> {\n const exists = await trueIfResolved(fs.access(configPath));\n if (exists) {\n const content = await fs.readFile(configPath);\n const result = config.safeParse(stripLegacyConfigKeys(JSON.parse(content.toString())));\n if (!result.success) {\n throw new Error(\n `Invalid joist-config.json: ${result.error.issues\n .map((ze) => `${ze.path.map(String).join(\"/\")} ${ze.message}`)\n .join(\"\\n\")}`,\n );\n }\n result.data.allowImportingTsExtensions ??= projectIsUsingEsmWithImports();\n return result.data;\n }\n // Brand-new projects should not be prompted to run historical codemods.\n const initial = config.parse({ codemodVersion: getLatestCodemodVersion() });\n initial.allowImportingTsExtensions ??= projectIsUsingEsmWithImports();\n return initial;\n}\n\n/**\n * Writes the potentially-updated config entry back to `joist-config.json`.\n *\n * We format the output with prettier so it should both a) look nice and b) be deterministic,\n * such that no changes to the config show up as noops to the scm.\n */\nexport async function writeConfig(config: Config): Promise<void> {\n const sorted: Partial<Config> = sortKeys(config);\n delete sorted.__tableToEntityName;\n delete sorted.allowImportingTsExtensions;\n if (sorted.paginationStyle === \"cursor\") {\n delete sorted.paginationStyle;\n }\n const input = JSON.stringify(sorted);\n const content = jsonFormatter.formatText({ filePath: \"test.json\", fileText: input });\n await fs.writeFile(configPath, content);\n}\n\nexport function stripStiPlaceholders(config: Config, entities: EntityDbMetadata[]): void {\n // Defacto (with today's setup) the config of STI entities lives on the base entity,\n // so don't write confusing subtype-specific entries into the config file.\n // ...hopefully we don't have any code accidentally looking for the STI config...\n for (const entity of entities) {\n if (entity.inheritanceType === \"sti\" && entity.stiDiscriminatorValue) {\n delete config.entities[entity.name];\n }\n }\n}\n\n/** Applies defaults to the timestamp config. */\nexport function getTimestampConfig(config: Config): {\n updatedAtConf: Required<TimestampConfig>;\n createdAtConf: Required<TimestampConfig>;\n deletedAtConf: Required<TimestampConfig>;\n} {\n return {\n createdAtConf: {\n names: [\"created_at\", \"createdAt\"],\n required: false,\n ...config?.timestampColumns?.createdAt,\n },\n updatedAtConf: {\n names: [\"updated_at\", \"updatedAt\"],\n required: false,\n ...config?.timestampColumns?.updatedAt,\n },\n deletedAtConf: {\n names: [\"deleted_at\", \"deletedAt\"],\n required: false,\n ...config?.timestampColumns?.deletedAt,\n },\n };\n}\n\nfunction projectIsUsingEsmWithImports(): boolean {\n // Attempt to find the project's tsconfig.json in the current directory or up the directory hierarchy\n const configPath = findTsConfigFile(process.cwd());\n if (!configPath) {\n return false;\n }\n try {\n // Use jsonc-parser to parse the tsconfig.json file (not the old tsc readConfigFile which was\n // dropped in TypeScript 7), allowing for comments and trailing commas.\n const errors: ParseError[] = [];\n const parsed: unknown = parse(readFileSync(configPath, \"utf8\"), errors, { allowTrailingComma: true });\n if (errors.length > 0 || typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) return false;\n const compilerOptions = (parsed as Record<string, unknown>).compilerOptions;\n return (\n typeof compilerOptions === \"object\" &&\n compilerOptions !== null &&\n !Array.isArray(compilerOptions) &&\n (compilerOptions as Record<string, unknown>).allowImportingTsExtensions === true\n );\n } catch {\n return false;\n }\n}\n\n/** Normalizes `uniqueBy` config sugar into runtime identity candidates. */\nfunction normalizeUniqueByConfig(uniqueBy: string | string[] | string[][]): string[][] {\n if (typeof uniqueBy === \"string\") return [[uniqueBy]];\n if (uniqueBy.every((field) => typeof field === \"string\")) return [uniqueBy];\n return uniqueBy;\n}\n\nfunction stripLegacyConfigKeys(raw: unknown): unknown {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) {\n return raw;\n }\n // Accept old configs so the deprecated key disappears on the next write.\n const parsed = { ...(raw as Record<string, unknown>) };\n delete parsed.version;\n return parsed;\n}\n\n/** Finds the nearest `tsconfig.json` in `directory` or one of its ancestors. */\nfunction findTsConfigFile(directory: string): string | undefined {\n while (true) {\n const fileName = join(directory, \"tsconfig.json\");\n if (existsSync(fileName)) return fileName;\n const parent = dirname(directory);\n if (parent === directory) return undefined;\n directory = parent;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAM,iBAAA,GAAgBA,kBAAAA,iBAAAA,EAAAA,GAAiBC,GAAAA,aAAAA,EAAAA,GAAaC,aAAAA,QAAAA,CAAQ,CAAC,CAAC;AAE9D,MAAM,cAAcC,IAAAA,EACjB,OAAO;CAEN,SAASA,IAAAA,EAAE,SAASA,IAAAA,EAAE,MAAM,CAACA,IAAAA,EAAE,QAAQ,MAAM,GAAGA,IAAAA,EAAE,QAAQ,OAAO,CAAC,CAAC,CAAC;CACpE,WAAWA,IA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AAO,aAAa,UAAU,OAAO,CAAC,CAAC,QAAQ,CAAC;CACpD,IAAI,SAAS,OAAO,UAAU,OAAO,UAAU,QAAQ,GAAG,OAAO,CAAC,QAAQ;CAC1E,OAAO;AACT;AAEA,SAAS,sBAAsB,KAAuB;CACpD,IAAI,CAAC,OAAO,OAAO,QAAQ,YAAY,MAAM,QAAQ,GAAG,GACtD,OAAO;CAGT,MAAM,SAAS,EAAE,GAAI,IAAgC;CACrD,OAAO,OAAO;CACd,OAAO;AACT;;AAGA,SAAS,iBAAiB,WAAuC;CAC/D,OAAO,MAAM;EACX,MAAM,YAAA,GAAWS,KAAAA,KAAAA,CAAK,WAAW,eAAe;EAChD,KAAA,GAAIC,GAAAA,WAAAA,CAAW,QAAQ,GAAG,OAAO;EACjC,MAAM,UAAA,GAASC,KAAAA,QAAAA,CAAQ,SAAS;EAChC,IAAI,WAAW,WAAW,OAAO,KAAA;EACjC,YAAY;CACd;AACF"}
|
|
1
|
+
{"version":3,"file":"config.cjs","names":["createFromBuffer","readFileSync","getPath","z","groupBy","logger","getStiEntities","fail","trueIfResolved","fs","getLatestCodemodVersion","sortKeys","parse","join","existsSync","dirname"],"sources":["../src/config.ts"],"sourcesContent":["import { existsSync, promises as fs, readFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\n\nimport { createFromBuffer } from \"@dprint/formatter\";\nimport { getPath } from \"@dprint/json\";\nimport { groupBy } from \"joist-utils\";\nimport { type ParseError, parse } from \"jsonc-parser\";\nimport { z } from \"zod\";\n\nimport { getLatestCodemodVersion } from \"./codemods/index.ts\";\nimport { type DbMetadata, type Entity, type EntityDbMetadata } from \"./EntityDbMetadata.ts\";\nimport { getStiEntities } from \"./inheritance.ts\";\nimport { logger } from \"./logger.ts\";\nimport { fail, sortKeys, trueIfResolved } from \"./utils.ts\";\n\nconst jsonFormatter = createFromBuffer(readFileSync(getPath()));\n\nconst fieldConfig = z\n .object({\n // For getters & ReactiveFields\n derived: z.optional(z.union([z.literal(\"sync\"), z.literal(\"async\")])),\n protected: z.optional(z.boolean()),\n ignore: z.optional(z.boolean()),\n superstruct: z.optional(z.string()),\n zodSchema: z.optional(z.string()),\n type: z.optional(z.string()),\n serde: z.optional(z.string()),\n stiDiscriminator: z.optional(z.record(z.string(), z.string())),\n stiType: z.optional(z.union([z.string(), z.array(z.string())])),\n // Allow subclasses to mark fields as required\n notNull: z.optional(z.boolean()),\n // Allow overriding scanEntities default detection for fields with defaults added by helpers\n hasDefault: z.optional(z.boolean()),\n // Exclude a (large jsonb/text) column from the default SELECT and expose it as a lazy-loaded LazyField\n lazy: z.optional(z.boolean()),\n /** Mark the entity for read locking whenever the field's value is read. */\n assertUnchanged: z.optional(z.boolean()),\n })\n .strict()\n .refine((field) => !field.assertUnchanged || (!field.derived && !field.lazy && !field.ignore), {\n message: \"assertUnchanged requires a non-derived, non-lazy, non-ignored field\",\n path: [\"assertUnchanged\"],\n });\n\nexport type FieldConfig = z.infer<typeof fieldConfig>;\n\nconst relationConfig = z\n .object({\n // For ReactiveReferences\n derived: z.optional(z.literal(\"async\")),\n polymorphic: z.optional(z.union([z.literal(\"notNull\"), z.literal(true)])),\n large: z.optional(z.boolean()),\n orderBy: z.optional(z.string()),\n /**\n * Controls whether this collection's `.get`/`.load` hide soft-deleted entities.\n *\n * Defaults to `\"exclude\"` (soft-deleted entities are hidden); set to `\"include\"` to have\n * this specific o2m/m2m always return soft-deleted entities from `.get`/`.load`.\n */\n softDeletes: z.optional(z.union([z.literal(\"include\"), z.literal(\"exclude\")])),\n // Allow pushing m2o/m2m/o2o relations in a base type (Task) down to a subtype (TaskOld)\n stiType: z.optional(z.union([z.string(), z.array(z.string())])),\n /**\n * Allow specializing a base type relation (SmallPublisher.group: SmallPublisherGroup).\n *\n * Self-referential FKs also support `subType: \"self\"` that means each subtype will point\n * at its own subtype.\n */\n subType: z.optional(z.string()),\n /** Allow skipping self-referential fields getting a `...Recursive` relation. */\n skipRecursiveRelations: z.optional(z.boolean()),\n // Allow marking m2o FKs as required on subclasses\n notNull: z.optional(z.boolean()),\n // Allow overriding scanEntities default detection for fields with defaults added by helpers\n hasDefault: z.optional(z.boolean()),\n })\n .strict();\n\nexport type RelationConfig = z.infer<typeof relationConfig>;\n\nconst uniqueByConfig = z\n .union([z.string(), z.array(z.string()), z.array(z.array(z.string()))])\n .transform(normalizeUniqueByConfig);\n\nconst entityConfig = z\n .object({\n tag: z.string(),\n tableName: z.optional(z.string()),\n fields: z.optional(z.record(z.string(), fieldConfig)),\n relations: z.optional(z.record(z.string(), relationConfig)),\n /** Whether this entity should be abstract, e.g. for inheritance a subtype must be instantiated instead of this type. */\n abstract: z.optional(z.boolean()),\n orderBy: z.optional(z.string()),\n uniqueBy: z.optional(uniqueByConfig),\n })\n .strict();\n\nexport type EntityConfig = z.infer<typeof entityConfig>;\n\nconst timestampConfig = z\n .object({\n /** The names to check for this timestamp, i.e. `created_at` `created`, etc. */\n names: z.array(z.string()),\n /** Whether this timestamp column is required to consider a table an entity, defaults to `false`. */\n required: z.optional(z.boolean()),\n })\n .strict();\n\nexport type TimestampConfig = z.infer<typeof timestampConfig>;\n\nexport const config = z\n .object({\n /** The _build-time_ database URL for reading database metadata. */\n databaseUrl: z.optional(z.string()),\n /** Your application's request-level `Context` type. */\n contextType: z.optional(z.string()),\n /** Your application's database client's `Transaction` type. */\n transactionType: z.optional(z.string()),\n /**\n * Allows the user to specify the `updated_at` / `created_at` column names to look up, and if they're optional.\n *\n * We default to looking for `updated_at`, `updatedAt`, `created_at`, `createdAt`, and optional to true,\n * e.g. tables are not required to have both timestamp columns to be considered entities.\n *\n * These defaults are the most lenient, to facilitate running Joist against an existing schema and\n * seeing all of your entities, regardless of your previous conventions.\n */\n timestampColumns: z.optional(\n z.object({\n createdAt: z.optional(timestampConfig),\n updatedAt: z.optional(timestampConfig),\n deletedAt: z.optional(timestampConfig),\n }),\n ),\n /**\n * Allows the user to have codegen output `Temporal` types instead of the base JS `Date`\n *\n * Additionally, allows for specifying the default time zone for `Temporal` types when converting dates to/from\n * the database.\n */\n temporal: z.optional(z.union([z.boolean(), z.object({ timeZone: z.string() })])),\n /**\n * By default, we create a `flush_database` function for fast testing.\n *\n * However, if you don't want to use this, or you have your own bespoke function like we do\n * that is more application-aware, then you can disable Joist's out-of-the-box one.\n *\n * If you have more than one test database, you can set `createFlushFunction` to the array\n * of test database names, i.e. `mydb_test_1`, `mydb_test_2`, etc.\n */\n createFlushFunction: z.optional(z.union([z.boolean(), z.array(z.string())])),\n /** Creates a starter test alongside each new entity file unless explicitly disabled. */\n scaffoldTests: z.optional(z.boolean()),\n entitiesDirectory: z.string().default(\"./src/entities\"),\n codegenPlugins: z.optional(z.array(z.string())),\n entities: z.record(z.string(), entityConfig).default({}),\n ignoredTables: z.optional(z.array(z.string())),\n /** The type of entity `id` fields; defaults to `tagged-string`. */\n idType: z.optional(z.union([z.literal(\"tagged-string\"), z.literal(\"untagged-string\"), z.literal(\"number\")])),\n /** The separator between entity tags and ids; defaults to `:`, and `\"\"` disables the separator. */\n tagDelimiter: z.optional(z.string()),\n /** How we should support non-deferred foreign keys. */\n nonDeferredForeignKeys: z.optional(z.union([z.literal(\"error\"), z.literal(\"warn\"), z.literal(\"ignore\")])),\n /** Enables esm output. */\n esm: z.optional(z.boolean()),\n /** Controls the style of GraphQL pagination scaffolding. */\n paginationStyle: z.optional(z.union([z.literal(\"cursor\"), z.literal(\"limit\")])).default(\"cursor\"),\n /** Enables documentation syncing between .md files and JSDocs. */\n docs: z.optional(z.boolean()),\n /** Installs Joist's bundled Agent Skills into `.claude/skills` and `.agents/skills`; on by default, set `false` to disable. */\n skills: z.optional(z.boolean()),\n /** Output a metadata-docs.ts file with entity/field documentation available at runtime. */\n outputDocs: z.optional(z.boolean()),\n /** Auto-set by probing the project's `tsconfig.json` file. */\n allowImportingTsExtensions: z.optional(z.boolean()),\n /** The latest Joist codemod counter that has been applied to this project. */\n codemodVersion: z.number().int().min(0).default(0),\n\n /** A list of postgres schemas to use for finding tables */\n schemas: z.optional(z.array(z.string())),\n })\n .strict();\n\nexport type Config = z.infer<typeof config> & {\n // We don't persist this, and instead just use it as a cache\n __tableToEntityName?: Record<string, string>;\n};\n\nexport const ormMaintainedFields = [\"createdAt\", \"updatedAt\"];\n\n/** Ensure the user doesn't have any typos in their config. */\nexport function warnInvalidConfigEntries(config: Config, db: DbMetadata): void {\n const entitiesByName = groupBy(db.entities, (e) => e.name);\n for (const [entityName, entityConfig] of Object.entries(config.entities)) {\n const entities = entitiesByName[entityName];\n if (!entities) {\n logger.warn(`Found config for non-existent entity ${entityName}`);\n continue;\n }\n // We don't have keyBy...\n const [entity] = entities;\n\n // Check fields\n const fields = [...entity.primitives, ...entity.enums];\n for (const [name, config] of Object.entries(entityConfig.fields || {})) {\n if (config.ignore) continue;\n let field = fields.find((f) => f.fieldName === name);\n // STI types might be in the base type\n if (!field && entity.stiDiscriminatorField) {\n const stiEntities = getStiEntities(db.entities).get(entity.name)?.subTypes;\n field = stiEntities?.flatMap((st) => [...st.primitives, ...st.enums]).find((f) => f.fieldName === name);\n }\n if (!field) logger.warn(`Found config for non-existent field ${entityName}.${name}`);\n }\n\n // Check relations\n const relations = [\n ...entity.manyToOnes,\n ...entity.oneToManys,\n ...entity.manyToManys,\n ...entity.manyToManyEnums,\n ...entity.oneToOnes,\n ...entity.largeOneToManys,\n ...entity.largeManyToManys,\n ...entity.polymorphics,\n ];\n for (const [name, _] of Object.entries(entityConfig.relations || {})) {\n let relation = relations.find((r) => r.fieldName === name);\n // STI types might be in the subtypes\n if (!relation && entity.stiDiscriminatorField) {\n const stiEntities = getStiEntities(db.entities).get(entity.name)?.subTypes;\n relation = stiEntities\n ?.flatMap((entity) => [\n ...entity.manyToOnes,\n ...entity.oneToManys,\n ...entity.manyToManys,\n ...entity.oneToOnes,\n ...entity.largeOneToManys,\n ...entity.largeManyToManys,\n ...entity.polymorphics,\n ])\n ?.find((f) => f.fieldName === name);\n }\n // CTI subtype specializations (i.e. SmallPublisher.group: SmallPublisherGroup) need to look in the base type\n if (!relation && entity.baseType) {\n const baseType = entity.baseType;\n relation = [\n ...baseType.manyToOnes,\n ...baseType.oneToManys,\n ...baseType.manyToManys,\n ...baseType.oneToOnes,\n ...baseType.largeOneToManys,\n ...baseType.largeManyToManys,\n ...baseType.polymorphics,\n ].find((f) => f.fieldName === name);\n }\n\n if (!relation) logger.warn(`Found config for non-existent relation ${entityName}.${name}`);\n }\n\n const uniqueFields = [\n ...entity.primitives,\n ...entity.enums,\n ...entity.pgEnums,\n ...entity.manyToOnes,\n ...entity.polymorphics,\n ];\n for (const uniqueBy of entityConfig.uniqueBy || []) {\n for (const name of uniqueBy) {\n const field = uniqueFields.find((f) => f.fieldName === name);\n if (!field) {\n logger.warn(`Found uniqueBy for non-existent or non-queryable field ${entityName}.${name}`);\n } else if (field.kind === \"primitive\" && (field.derived || field.customSerde)) {\n logger.warn(`Found uniqueBy for unsupported primitive field ${entityName}.${name}`);\n } else if (field.kind === \"enum\" && (field.derived || field.isArray)) {\n logger.warn(`Found uniqueBy for unsupported enum field ${entityName}.${name}`);\n }\n }\n }\n }\n}\n\nexport function isGetterField(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.derived === \"sync\";\n}\n\nexport function isReactiveField(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.derived === \"async\";\n}\n\nexport function isReactiveReference(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.relations?.[fieldName]?.derived === \"async\";\n}\n\n/** Returns true if this m2m relation is configured as a ReactiveManyToMany (derived: async). */\nexport function isReactiveManyToMany(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.relations?.[fieldName]?.derived === \"async\";\n}\n\nexport function isProtected(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.protected === true;\n}\n\n/** Whether a column should be excluded from the default SELECT and exposed as a lazy-loaded `LazyField`. */\nexport function isLazyField(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.lazy === true;\n}\n\nexport function serdeConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.serde;\n}\n\nexport function superstructConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.superstruct;\n}\n\nexport function zodSchemaConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.zodSchema;\n}\n\nexport function fieldTypeConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.type;\n}\n\nexport function isLargeCollection(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.relations?.[fieldName]?.large === true;\n}\n\n/** Whether a collection should include (or exclude) soft-deleted entities from `.get`/`.load`. */\nexport function softDeletesConfig(\n config: Config,\n entity: Entity,\n fieldName: string,\n): \"include\" | \"exclude\" | undefined {\n return config.entities[entity.name]?.relations?.[fieldName]?.softDeletes;\n}\n\nexport function isFieldIgnored(\n config: Config,\n entity: Entity,\n fieldName: string,\n notNull: boolean = false,\n hasDefault: boolean = false,\n): boolean {\n const ignore = config.entities[entity.name]?.fields?.[fieldName]?.ignore === true;\n if (ignore && notNull && !hasDefault) {\n fail(\n `notNull field ${entity.name}.${fieldName} cannot be ignored. Alter the column to be optional or have a default value prior to ignoring it.`,\n );\n }\n return ignore;\n}\n\nexport function isFieldHasDefault(config: Config, entity: Entity, fieldName: string): boolean {\n const entityConfig = config.entities[entity.name] ?? {};\n const fieldConfig = entityConfig.fields?.[fieldName] ?? entityConfig.relations?.[fieldName] ?? {};\n return fieldConfig.hasDefault === true;\n}\n\nconst configPath = \"./joist-config.json\";\n\nexport async function loadConfig(): Promise<Config> {\n const exists = await trueIfResolved(fs.access(configPath));\n if (exists) {\n const content = await fs.readFile(configPath);\n const result = config.safeParse(stripLegacyConfigKeys(JSON.parse(content.toString())));\n if (!result.success) {\n throw new Error(\n `Invalid joist-config.json: ${result.error.issues\n .map((ze) => `${ze.path.map(String).join(\"/\")} ${ze.message}`)\n .join(\"\\n\")}`,\n );\n }\n result.data.allowImportingTsExtensions ??= projectIsUsingEsmWithImports();\n return result.data;\n }\n // Brand-new projects should not be prompted to run historical codemods.\n const initial = config.parse({ codemodVersion: getLatestCodemodVersion() });\n initial.allowImportingTsExtensions ??= projectIsUsingEsmWithImports();\n return initial;\n}\n\n/**\n * Writes the potentially-updated config entry back to `joist-config.json`.\n *\n * We format the output with prettier so it should both a) look nice and b) be deterministic,\n * such that no changes to the config show up as noops to the scm.\n */\nexport async function writeConfig(config: Config): Promise<void> {\n const sorted: Partial<Config> = sortKeys(config);\n delete sorted.__tableToEntityName;\n delete sorted.allowImportingTsExtensions;\n if (sorted.paginationStyle === \"cursor\") {\n delete sorted.paginationStyle;\n }\n const input = JSON.stringify(sorted);\n const content = jsonFormatter.formatText({ filePath: \"test.json\", fileText: input });\n await fs.writeFile(configPath, content);\n}\n\nexport function stripStiPlaceholders(config: Config, entities: EntityDbMetadata[]): void {\n // Defacto (with today's setup) the config of STI entities lives on the base entity,\n // so don't write confusing subtype-specific entries into the config file.\n // ...hopefully we don't have any code accidentally looking for the STI config...\n for (const entity of entities) {\n if (entity.inheritanceType === \"sti\" && entity.stiDiscriminatorValue) {\n delete config.entities[entity.name];\n }\n }\n}\n\n/** Applies defaults to the timestamp config. */\nexport function getTimestampConfig(config: Config): {\n updatedAtConf: Required<TimestampConfig>;\n createdAtConf: Required<TimestampConfig>;\n deletedAtConf: Required<TimestampConfig>;\n} {\n return {\n createdAtConf: {\n names: [\"created_at\", \"createdAt\"],\n required: false,\n ...config?.timestampColumns?.createdAt,\n },\n updatedAtConf: {\n names: [\"updated_at\", \"updatedAt\"],\n required: false,\n ...config?.timestampColumns?.updatedAt,\n },\n deletedAtConf: {\n names: [\"deleted_at\", \"deletedAt\"],\n required: false,\n ...config?.timestampColumns?.deletedAt,\n },\n };\n}\n\nfunction projectIsUsingEsmWithImports(): boolean {\n // Attempt to find the project's tsconfig.json in the current directory or up the directory hierarchy\n const configPath = findTsConfigFile(process.cwd());\n if (!configPath) {\n return false;\n }\n try {\n // Use jsonc-parser to parse the tsconfig.json file (not the old tsc readConfigFile which was\n // dropped in TypeScript 7), allowing for comments and trailing commas.\n const errors: ParseError[] = [];\n const parsed: unknown = parse(readFileSync(configPath, \"utf8\"), errors, { allowTrailingComma: true });\n if (errors.length > 0 || typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) return false;\n const compilerOptions = (parsed as Record<string, unknown>).compilerOptions;\n return (\n typeof compilerOptions === \"object\" &&\n compilerOptions !== null &&\n !Array.isArray(compilerOptions) &&\n (compilerOptions as Record<string, unknown>).allowImportingTsExtensions === true\n );\n } catch {\n return false;\n }\n}\n\n/** Normalizes `uniqueBy` config sugar into runtime identity candidates. */\nfunction normalizeUniqueByConfig(uniqueBy: string | string[] | string[][]): string[][] {\n if (typeof uniqueBy === \"string\") return [[uniqueBy]];\n if (uniqueBy.every((field) => typeof field === \"string\")) return [uniqueBy];\n return uniqueBy;\n}\n\nfunction stripLegacyConfigKeys(raw: unknown): unknown {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) {\n return raw;\n }\n // Accept old configs so the deprecated key disappears on the next write.\n const parsed = { ...(raw as Record<string, unknown>) };\n delete parsed.version;\n return parsed;\n}\n\n/** Finds the nearest `tsconfig.json` in `directory` or one of its ancestors. */\nfunction findTsConfigFile(directory: string): string | undefined {\n while (true) {\n const fileName = join(directory, \"tsconfig.json\");\n if (existsSync(fileName)) return fileName;\n const parent = dirname(directory);\n if (parent === directory) return undefined;\n directory = parent;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAM,iBAAA,GAAgBA,kBAAAA,iBAAAA,EAAAA,GAAiBC,GAAAA,aAAAA,EAAAA,GAAaC,aAAAA,QAAAA,CAAQ,CAAC,CAAC;AAE9D,MAAM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AO,WAAW,YAAY,WAAW,QAAQ,MAAM,QAAQ,MAAM,GAAG,OAAO;EACxG,MAAM,kBAAmB,OAAmC;EAC5D,OACE,OAAO,oBAAoB,YAC3B,oBAAoB,QACpB,CAAC,MAAM,QAAQ,eAAe,KAC7B,gBAA4C,+BAA+B;CAEhF,QAAQ;EACN,OAAO;CACT;AACF;;AAGA,SAAS,wBAAwB,UAAsD;CACrF,IAAI,OAAO,aAAa,UAAU,OAAO,CAAC,CAAC,QAAQ,CAAC;CACpD,IAAI,SAAS,OAAO,UAAU,OAAO,UAAU,QAAQ,GAAG,OAAO,CAAC,QAAQ;CAC1E,OAAO;AACT;AAEA,SAAS,sBAAsB,KAAuB;CACpD,IAAI,CAAC,OAAO,OAAO,QAAQ,YAAY,MAAM,QAAQ,GAAG,GACtD,OAAO;CAGT,MAAM,SAAS,EAAE,GAAI,IAAgC;CACrD,OAAO,OAAO;CACd,OAAO;AACT;;AAGA,SAAS,iBAAiB,WAAuC;CAC/D,OAAO,MAAM;EACX,MAAM,YAAA,GAAWY,KAAAA,KAAAA,CAAK,WAAW,eAAe;EAChD,KAAA,GAAIC,GAAAA,WAAAA,CAAW,QAAQ,GAAG,OAAO;EACjC,MAAM,UAAA,GAASC,KAAAA,QAAAA,CAAQ,SAAS;EAChC,IAAI,WAAW,WAAW,OAAO,KAAA;EACjC,YAAY;CACd;AACF"}
|
package/build/config.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DbMetadata, Entity, EntityDbMetadata } from "./EntityDbMetadata.cjs";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
//#region src/config.d.ts
|
|
4
3
|
declare const fieldConfig: z.ZodObject<{
|
|
5
4
|
derived: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"sync">, z.ZodLiteral<"async">]>>;
|
|
6
5
|
protected: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -92,6 +91,7 @@ export declare const config: z.ZodObject<{
|
|
|
92
91
|
timeZone: z.ZodString;
|
|
93
92
|
}, z.core.$strip>]>>;
|
|
94
93
|
createFlushFunction: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
|
|
94
|
+
scaffoldTests: z.ZodOptional<z.ZodBoolean>;
|
|
95
95
|
entitiesDirectory: z.ZodDefault<z.ZodString>;
|
|
96
96
|
codegenPlugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
97
97
|
entities: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
@@ -179,6 +179,5 @@ export declare function getTimestampConfig(config: Config): {
|
|
|
179
179
|
createdAtConf: Required<TimestampConfig>;
|
|
180
180
|
deletedAtConf: Required<TimestampConfig>;
|
|
181
181
|
};
|
|
182
|
-
//#endregion
|
|
183
182
|
export {};
|
|
184
183
|
//# sourceMappingURL=config.d.cts.map
|
package/build/config.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.cts","names":[],"sources":["../src/config.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.cts","names":[],"sources":["../src/config.ts"],"mappings":";;cAiBM,aAAW,EAAA;;;;;;;;;;;;;;GAyBb,EAAA,KAAA;YAEQ,cAAc,EAAE,aAAa;cAEnC,gBAAc,EAAA;;;;;;;;;;;GA8BT,EAAA,KAAA;YAEC,iBAAiB,EAAE,aAAa;cAMtC,cAAY,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAWP,EAAA,KAAA;YAEC,eAAe,EAAE,aAAa;cAEpC,iBAAe,EAAA;;;GAOV,EAAA,KAAA;YAEC,kBAAkB,EAAE,aAAa;qBAEhC,QAAM,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuER,EAAA,KAAA;YAEC,SAAS,EAAE,aAAa;EAElC,sBAAsB;;qBAGX;;wBAGG,yBAAyB,QAAQ,QAAQ,IAAI;wBA2F7C,cAAc,QAAQ,QAAQ,QAAQ,QAAQ;wBAI9C,gBAAgB,QAAQ,QAAQ,QAAQ,QAAQ;wBAIhD,oBAAoB,QAAQ,QAAQ,QAAQ,QAAQ;;wBAKpD,qBAAqB,QAAQ,QAAQ,QAAQ,QAAQ;wBAIrD,YAAY,QAAQ,QAAQ,QAAQ,QAAQ;;wBAK5C,YAAY,QAAQ,QAAQ,QAAQ,QAAQ;wBAI5C,YAAY,QAAQ,QAAQ,QAAQ,QAAQ;wBAI5C,kBAAkB,QAAQ,QAAQ,QAAQ,QAAQ;wBAIlD,gBAAgB,QAAQ,QAAQ,QAAQ,QAAQ;wBAIhD,gBAAgB,QAAQ,QAAQ,QAAQ,QAAQ;wBAIhD,kBAAkB,QAAQ,QAAQ,QAAQ,QAAQ;;wBAKlD,kBACd,QAAQ,QACR,QAAQ,QACR;wBAKc,eACd,QAAQ,QACR,QAAQ,QACR,mBACA,mBACA;wBAWc,kBAAkB,QAAQ,QAAQ,QAAQ,QAAQ;wBAQ5C,cAAc,QAAQ;;;;;;;wBA2BtB,YAAY,QAAQ,SAAS;wBAYnC,qBAAqB,QAAQ,QAAQ,UAAU;;wBAY/C,mBAAmB,QAAQ;EACzC,eAAe,SAAS;EACxB,eAAe,SAAS;EACxB,eAAe,SAAS"}
|
package/build/config.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DbMetadata, Entity, EntityDbMetadata } from "./EntityDbMetadata.mjs";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
//#region src/config.d.ts
|
|
4
3
|
declare const fieldConfig: z.ZodObject<{
|
|
5
4
|
derived: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"sync">, z.ZodLiteral<"async">]>>;
|
|
6
5
|
protected: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -92,6 +91,7 @@ export declare const config: z.ZodObject<{
|
|
|
92
91
|
timeZone: z.ZodString;
|
|
93
92
|
}, z.core.$strip>]>>;
|
|
94
93
|
createFlushFunction: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
|
|
94
|
+
scaffoldTests: z.ZodOptional<z.ZodBoolean>;
|
|
95
95
|
entitiesDirectory: z.ZodDefault<z.ZodString>;
|
|
96
96
|
codegenPlugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
97
97
|
entities: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
@@ -179,6 +179,5 @@ export declare function getTimestampConfig(config: Config): {
|
|
|
179
179
|
createdAtConf: Required<TimestampConfig>;
|
|
180
180
|
deletedAtConf: Required<TimestampConfig>;
|
|
181
181
|
};
|
|
182
|
-
//#endregion
|
|
183
182
|
export {};
|
|
184
183
|
//# sourceMappingURL=config.d.mts.map
|
package/build/config.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.mts","names":[],"sources":["../src/config.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.mts","names":[],"sources":["../src/config.ts"],"mappings":";;cAiBM,aAAW,EAAA;;;;;;;;;;;;;;GAyBb,EAAA,KAAA;YAEQ,cAAc,EAAE,aAAa;cAEnC,gBAAc,EAAA;;;;;;;;;;;GA8BT,EAAA,KAAA;YAEC,iBAAiB,EAAE,aAAa;cAMtC,cAAY,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAWP,EAAA,KAAA;YAEC,eAAe,EAAE,aAAa;cAEpC,iBAAe,EAAA;;;GAOV,EAAA,KAAA;YAEC,kBAAkB,EAAE,aAAa;qBAEhC,QAAM,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuER,EAAA,KAAA;YAEC,SAAS,EAAE,aAAa;EAElC,sBAAsB;;qBAGX;;wBAGG,yBAAyB,QAAQ,QAAQ,IAAI;wBA2F7C,cAAc,QAAQ,QAAQ,QAAQ,QAAQ;wBAI9C,gBAAgB,QAAQ,QAAQ,QAAQ,QAAQ;wBAIhD,oBAAoB,QAAQ,QAAQ,QAAQ,QAAQ;;wBAKpD,qBAAqB,QAAQ,QAAQ,QAAQ,QAAQ;wBAIrD,YAAY,QAAQ,QAAQ,QAAQ,QAAQ;;wBAK5C,YAAY,QAAQ,QAAQ,QAAQ,QAAQ;wBAI5C,YAAY,QAAQ,QAAQ,QAAQ,QAAQ;wBAI5C,kBAAkB,QAAQ,QAAQ,QAAQ,QAAQ;wBAIlD,gBAAgB,QAAQ,QAAQ,QAAQ,QAAQ;wBAIhD,gBAAgB,QAAQ,QAAQ,QAAQ,QAAQ;wBAIhD,kBAAkB,QAAQ,QAAQ,QAAQ,QAAQ;;wBAKlD,kBACd,QAAQ,QACR,QAAQ,QACR;wBAKc,eACd,QAAQ,QACR,QAAQ,QACR,mBACA,mBACA;wBAWc,kBAAkB,QAAQ,QAAQ,QAAQ,QAAQ;wBAQ5C,cAAc,QAAQ;;;;;;;wBA2BtB,YAAY,QAAQ,SAAS;wBAYnC,qBAAqB,QAAQ,QAAQ,UAAU;;wBAY/C,mBAAmB,QAAQ;EACzC,eAAe,SAAS;EACxB,eAAe,SAAS;EACxB,eAAe,SAAS"}
|
package/build/config.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getLatestCodemodVersion } from "./codemods/index.js";
|
|
2
|
-
import
|
|
2
|
+
import "./EntityDbMetadata.js";
|
|
3
3
|
import { getStiEntities } from "./inheritance.js";
|
|
4
4
|
import { logger } from "./logger.js";
|
|
5
|
-
import "./
|
|
5
|
+
import { fail, sortKeys, trueIfResolved } from "./utils.js";
|
|
6
6
|
import { groupBy } from "joist-utils";
|
|
7
7
|
import { existsSync, promises, readFileSync } from "fs";
|
|
8
8
|
import { dirname, join } from "path";
|
|
@@ -10,7 +10,7 @@ import { createFromBuffer } from "@dprint/formatter";
|
|
|
10
10
|
import { getPath } from "@dprint/json";
|
|
11
11
|
import { parse } from "jsonc-parser";
|
|
12
12
|
import { z } from "zod";
|
|
13
|
-
|
|
13
|
+
// src/config.ts
|
|
14
14
|
const jsonFormatter = createFromBuffer(readFileSync(getPath()));
|
|
15
15
|
const fieldConfig = z.object({
|
|
16
16
|
derived: z.optional(z.union([z.literal("sync"), z.literal("async")])),
|
|
@@ -115,6 +115,8 @@ const config = z.object({
|
|
|
115
115
|
* of test database names, i.e. `mydb_test_1`, `mydb_test_2`, etc.
|
|
116
116
|
*/
|
|
117
117
|
createFlushFunction: z.optional(z.union([z.boolean(), z.array(z.string())])),
|
|
118
|
+
/** Creates a starter test alongside each new entity file unless explicitly disabled. */
|
|
119
|
+
scaffoldTests: z.optional(z.boolean()),
|
|
118
120
|
entitiesDirectory: z.string().default("./src/entities"),
|
|
119
121
|
codegenPlugins: z.optional(z.array(z.string())),
|
|
120
122
|
entities: z.record(z.string(), entityConfig).default({}),
|
|
@@ -355,7 +357,6 @@ function findTsConfigFile(directory) {
|
|
|
355
357
|
directory = parent;
|
|
356
358
|
}
|
|
357
359
|
}
|
|
358
|
-
//#endregion
|
|
359
360
|
export { config, fieldTypeConfig, getTimestampConfig, isFieldHasDefault, isFieldIgnored, isGetterField, isLargeCollection, isLazyField, isProtected, isReactiveField, isReactiveManyToMany, isReactiveReference, loadConfig, ormMaintainedFields, serdeConfig, softDeletesConfig, stripStiPlaceholders, superstructConfig, warnInvalidConfigEntries, writeConfig, zodSchemaConfig };
|
|
360
361
|
|
|
361
362
|
//# sourceMappingURL=config.js.map
|