joist-codegen 2.3.0-next.9 → 2.3.0-next.90
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 +642 -0
- package/build/EntityDbMetadata.cjs.map +1 -0
- package/build/EntityDbMetadata.d.cts +299 -0
- package/build/EntityDbMetadata.d.cts.map +1 -0
- package/build/EntityDbMetadata.d.mts +299 -0
- package/build/EntityDbMetadata.d.mts.map +1 -0
- package/build/EntityDbMetadata.js +519 -661
- package/build/EntityDbMetadata.js.map +1 -1
- package/build/_virtual/_rolldown/runtime.cjs +23 -0
- package/build/_virtual/_rolldown/runtime.js +5 -0
- package/build/assignTags.cjs +45 -0
- package/build/assignTags.cjs.map +1 -0
- package/build/{assignTags.d.ts → assignTags.d.cts} +8 -4
- package/build/assignTags.d.cts.map +1 -0
- package/build/assignTags.d.mts +16 -0
- package/build/assignTags.d.mts.map +1 -0
- package/build/assignTags.js +37 -59
- package/build/assignTags.js.map +1 -1
- package/build/codemods/Codemod.cjs +2 -0
- package/build/codemods/Codemod.d.cts +17 -0
- package/build/codemods/Codemod.d.cts.map +1 -0
- package/build/codemods/Codemod.d.mts +17 -0
- package/build/codemods/Codemod.d.mts.map +1 -0
- package/build/codemods/Codemod.js +2 -3
- package/build/codemods/JscodeshiftMod.cjs +42 -0
- package/build/codemods/JscodeshiftMod.cjs.map +1 -0
- package/build/codemods/JscodeshiftMod.d.cts +14 -0
- package/build/codemods/JscodeshiftMod.d.cts.map +1 -0
- package/build/codemods/JscodeshiftMod.d.mts +14 -0
- package/build/codemods/JscodeshiftMod.d.mts.map +1 -0
- package/build/codemods/JscodeshiftMod.js +33 -33
- package/build/codemods/JscodeshiftMod.js.map +1 -1
- package/build/codemods/codemod_0001-rename_has_async_property.cjs +30 -0
- package/build/codemods/codemod_0001-rename_has_async_property.cjs.map +1 -0
- package/build/codemods/codemod_0001-rename_has_async_property.d.cts +9 -0
- package/build/codemods/codemod_0001-rename_has_async_property.d.cts.map +1 -0
- package/build/codemods/codemod_0001-rename_has_async_property.d.mts +9 -0
- package/build/codemods/codemod_0001-rename_has_async_property.d.mts.map +1 -0
- package/build/codemods/codemod_0001-rename_has_async_property.js +21 -25
- package/build/codemods/codemod_0001-rename_has_async_property.js.map +1 -1
- package/build/codemods/codemod_0002-rename_async_query_fields.cjs +50 -0
- package/build/codemods/codemod_0002-rename_async_query_fields.cjs.map +1 -0
- package/build/codemods/codemod_0002-rename_async_query_fields.d.cts +9 -0
- package/build/codemods/codemod_0002-rename_async_query_fields.d.cts.map +1 -0
- package/build/codemods/codemod_0002-rename_async_query_fields.d.mts +9 -0
- package/build/codemods/codemod_0002-rename_async_query_fields.d.mts.map +1 -0
- package/build/codemods/codemod_0002-rename_async_query_fields.js +38 -52
- package/build/codemods/codemod_0002-rename_async_query_fields.js.map +1 -1
- package/build/codemods/codemod_0003-rename_find_paginated.cjs +25 -0
- package/build/codemods/codemod_0003-rename_find_paginated.cjs.map +1 -0
- package/build/codemods/codemod_0003-rename_find_paginated.d.cts +9 -0
- package/build/codemods/codemod_0003-rename_find_paginated.d.cts.map +1 -0
- package/build/codemods/codemod_0003-rename_find_paginated.d.mts +9 -0
- package/build/codemods/codemod_0003-rename_find_paginated.d.mts.map +1 -0
- package/build/codemods/codemod_0003-rename_find_paginated.js +17 -26
- package/build/codemods/codemod_0003-rename_find_paginated.js.map +1 -1
- package/build/codemods/index.cjs +49 -0
- package/build/codemods/index.cjs.map +1 -0
- package/build/codemods/index.d.cts +12 -0
- package/build/codemods/index.d.cts.map +1 -0
- package/build/codemods/index.d.mts +12 -0
- package/build/codemods/index.d.mts.map +1 -0
- package/build/codemods/index.js +34 -42
- package/build/codemods/index.js.map +1 -1
- package/build/config.cjs +377 -0
- package/build/config.cjs.map +1 -0
- package/build/config.d.cts +181 -0
- package/build/config.d.cts.map +1 -0
- package/build/config.d.mts +181 -0
- package/build/config.d.mts.map +1 -0
- package/build/config.js +309 -347
- package/build/config.js.map +1 -1
- package/build/docs/cache.cjs +62 -0
- package/build/docs/cache.cjs.map +1 -0
- package/build/docs/cache.d.cts +17 -0
- package/build/docs/cache.d.cts.map +1 -0
- package/build/docs/cache.d.mts +17 -0
- package/build/docs/cache.d.mts.map +1 -0
- package/build/docs/cache.js +52 -53
- package/build/docs/cache.js.map +1 -1
- package/build/docs/generate-metadata-docs.cjs +32 -0
- package/build/docs/generate-metadata-docs.cjs.map +1 -0
- package/build/docs/generate-metadata-docs.d.cts +9 -0
- package/build/docs/generate-metadata-docs.d.cts.map +1 -0
- package/build/docs/generate-metadata-docs.d.mts +9 -0
- package/build/docs/generate-metadata-docs.d.mts.map +1 -0
- package/build/docs/generate-metadata-docs.js +19 -24
- package/build/docs/generate-metadata-docs.js.map +1 -1
- package/build/docs/index.cjs +90 -0
- package/build/docs/index.cjs.map +1 -0
- package/build/docs/index.d.cts +16 -0
- package/build/docs/index.d.cts.map +1 -0
- package/build/docs/index.d.mts +16 -0
- package/build/docs/index.d.mts.map +1 -0
- package/build/docs/index.js +75 -80
- package/build/docs/index.js.map +1 -1
- package/build/docs/markdown.cjs +181 -0
- package/build/docs/markdown.cjs.map +1 -0
- package/build/docs/{markdown.d.ts → markdown.d.cts} +14 -12
- package/build/docs/markdown.d.cts.map +1 -0
- package/build/docs/markdown.d.mts +32 -0
- package/build/docs/markdown.d.mts.map +1 -0
- package/build/docs/markdown.js +152 -220
- package/build/docs/markdown.js.map +1 -1
- package/build/docs/parsing.cjs +117 -0
- package/build/docs/parsing.cjs.map +1 -0
- package/build/docs/parsing.d.cts +48 -0
- package/build/docs/parsing.d.cts.map +1 -0
- package/build/docs/parsing.d.mts +48 -0
- package/build/docs/parsing.d.mts.map +1 -0
- package/build/docs/parsing.js +89 -88
- package/build/docs/parsing.js.map +1 -1
- package/build/findEntityScopes.cjs +119 -0
- package/build/findEntityScopes.cjs.map +1 -0
- package/build/findEntityScopes.d.cts +14 -0
- package/build/findEntityScopes.d.cts.map +1 -0
- package/build/findEntityScopes.d.mts +14 -0
- package/build/findEntityScopes.d.mts.map +1 -0
- package/build/findEntityScopes.js +83 -111
- package/build/findEntityScopes.js.map +1 -1
- package/build/foreignKeyOrdering.cjs +52 -0
- package/build/foreignKeyOrdering.cjs.map +1 -0
- package/build/foreignKeyOrdering.d.cts +8 -0
- package/build/foreignKeyOrdering.d.cts.map +1 -0
- package/build/foreignKeyOrdering.d.mts +8 -0
- package/build/foreignKeyOrdering.d.mts.map +1 -0
- package/build/foreignKeyOrdering.js +46 -55
- package/build/foreignKeyOrdering.js.map +1 -1
- package/build/generate.cjs +128 -0
- package/build/generate.cjs.map +1 -0
- package/build/generate.d.cts +17 -0
- package/build/generate.d.cts.map +1 -0
- package/build/generate.d.mts +17 -0
- package/build/generate.d.mts.map +1 -0
- package/build/generate.js +111 -124
- package/build/generate.js.map +1 -1
- package/build/generateEntitiesFile.cjs +46 -0
- package/build/generateEntitiesFile.cjs.map +1 -0
- package/build/generateEntitiesFile.d.cts +11 -0
- package/build/generateEntitiesFile.d.cts.map +1 -0
- package/build/generateEntitiesFile.d.mts +11 -0
- package/build/generateEntitiesFile.d.mts.map +1 -0
- package/build/generateEntitiesFile.js +28 -25
- package/build/generateEntitiesFile.js.map +1 -1
- package/build/generateEntityCodegenFile.cjs +1010 -0
- package/build/generateEntityCodegenFile.cjs.map +1 -0
- package/build/generateEntityCodegenFile.d.cts +16 -0
- package/build/generateEntityCodegenFile.d.cts.map +1 -0
- package/build/generateEntityCodegenFile.d.mts +16 -0
- package/build/generateEntityCodegenFile.d.mts.map +1 -0
- package/build/generateEntityCodegenFile.js +793 -827
- package/build/generateEntityCodegenFile.js.map +1 -1
- package/build/generateEntityFile.cjs +23 -0
- package/build/generateEntityFile.cjs.map +1 -0
- package/build/generateEntityFile.d.cts +9 -0
- package/build/generateEntityFile.d.cts.map +1 -0
- package/build/generateEntityFile.d.mts +9 -0
- package/build/generateEntityFile.d.mts.map +1 -0
- package/build/generateEntityFile.js +11 -8
- package/build/generateEntityFile.js.map +1 -1
- package/build/generateEntityTestFile.cjs +25 -0
- package/build/generateEntityTestFile.cjs.map +1 -0
- package/build/generateEntityTestFile.d.cts +9 -0
- package/build/generateEntityTestFile.d.cts.map +1 -0
- package/build/generateEntityTestFile.d.mts +9 -0
- package/build/generateEntityTestFile.d.mts.map +1 -0
- package/build/generateEntityTestFile.js +10 -7
- package/build/generateEntityTestFile.js.map +1 -1
- package/build/generateEnumFile.cjs +73 -0
- package/build/generateEnumFile.cjs.map +1 -0
- package/build/generateEnumFile.d.cts +9 -0
- package/build/generateEnumFile.d.cts.map +1 -0
- package/build/generateEnumFile.d.mts +9 -0
- package/build/generateEnumFile.d.mts.map +1 -0
- package/build/generateEnumFile.js +33 -43
- package/build/generateEnumFile.js.map +1 -1
- package/build/generateFactoriesFiles.cjs +28 -0
- package/build/generateFactoriesFiles.cjs.map +1 -0
- package/build/generateFactoriesFiles.d.cts +7 -0
- package/build/generateFactoriesFiles.d.cts.map +1 -0
- package/build/generateFactoriesFiles.d.mts +7 -0
- package/build/generateFactoriesFiles.d.mts.map +1 -0
- package/build/generateFactoriesFiles.js +21 -16
- package/build/generateFactoriesFiles.js.map +1 -1
- package/build/generateFlushFunction.cjs +61 -0
- package/build/generateFlushFunction.cjs.map +1 -0
- package/build/{generateFlushFunction.d.ts → generateFlushFunction.d.cts} +8 -5
- package/build/generateFlushFunction.d.cts.map +1 -0
- package/build/generateFlushFunction.d.mts +23 -0
- package/build/generateFlushFunction.d.mts.map +1 -0
- package/build/generateFlushFunction.js +32 -78
- package/build/generateFlushFunction.js.map +1 -1
- package/build/generateMetadataFile.cjs +307 -0
- package/build/generateMetadataFile.cjs.map +1 -0
- package/build/generateMetadataFile.d.cts +10 -0
- package/build/generateMetadataFile.d.cts.map +1 -0
- package/build/generateMetadataFile.d.mts +10 -0
- package/build/generateMetadataFile.d.mts.map +1 -0
- package/build/generateMetadataFile.js +148 -156
- package/build/generateMetadataFile.js.map +1 -1
- package/build/generatePgEnumFile.cjs +21 -0
- package/build/generatePgEnumFile.cjs.map +1 -0
- package/build/generatePgEnumFile.d.cts +9 -0
- package/build/generatePgEnumFile.d.cts.map +1 -0
- package/build/generatePgEnumFile.d.mts +9 -0
- package/build/generatePgEnumFile.d.mts.map +1 -0
- package/build/generatePgEnumFile.js +12 -9
- package/build/generatePgEnumFile.js.map +1 -1
- package/build/index.cjs +135 -0
- package/build/index.cjs.map +1 -0
- package/build/index.d.cts +12 -0
- package/build/index.d.cts.map +1 -0
- package/build/index.d.mts +12 -0
- package/build/index.d.mts.map +1 -0
- package/build/index.js +108 -127
- package/build/index.js.map +1 -1
- package/build/inheritance.cjs +257 -0
- package/build/inheritance.cjs.map +1 -0
- package/build/inheritance.d.cts +13 -0
- package/build/inheritance.d.cts.map +1 -0
- package/build/inheritance.d.mts +13 -0
- package/build/inheritance.d.mts.map +1 -0
- package/build/inheritance.js +237 -247
- package/build/inheritance.js.map +1 -1
- package/build/installSkills.cjs +68 -0
- package/build/installSkills.cjs.map +1 -0
- package/build/installSkills.d.cts +16 -0
- package/build/installSkills.d.cts.map +1 -0
- package/build/installSkills.d.mts +16 -0
- package/build/installSkills.d.mts.map +1 -0
- package/build/installSkills.js +67 -0
- package/build/installSkills.js.map +1 -0
- package/build/keywords.cjs +7 -0
- package/build/keywords.cjs.map +1 -0
- package/build/keywords.d.cts +5 -0
- package/build/keywords.d.cts.map +1 -0
- package/build/keywords.d.mts +5 -0
- package/build/keywords.d.mts.map +1 -0
- package/build/keywords.js +5 -4
- package/build/keywords.js.map +1 -1
- package/build/loadMetadata.cjs +39 -0
- package/build/loadMetadata.cjs.map +1 -0
- package/build/loadMetadata.d.cts +31 -0
- package/build/loadMetadata.d.cts.map +1 -0
- package/build/loadMetadata.d.mts +31 -0
- package/build/loadMetadata.d.mts.map +1 -0
- package/build/loadMetadata.js +32 -39
- package/build/loadMetadata.js.map +1 -1
- package/build/logger.cjs +28 -0
- package/build/logger.cjs.map +1 -0
- package/build/logger.d.cts +13 -0
- package/build/logger.d.cts.map +1 -0
- package/build/logger.d.mts +13 -0
- package/build/logger.d.mts.map +1 -0
- package/build/logger.js +17 -16
- package/build/logger.js.map +1 -1
- package/build/scanEntityFiles.cjs +46 -0
- package/build/scanEntityFiles.cjs.map +1 -0
- package/build/scanEntityFiles.d.cts +8 -0
- package/build/scanEntityFiles.d.cts.map +1 -0
- package/build/scanEntityFiles.d.mts +8 -0
- package/build/scanEntityFiles.d.mts.map +1 -0
- package/build/scanEntityFiles.js +37 -42
- package/build/scanEntityFiles.js.map +1 -1
- package/build/sortForeignKeys.cjs +99 -0
- package/build/sortForeignKeys.cjs.map +1 -0
- package/build/{sortForeignKeys.d.ts → sortForeignKeys.d.cts} +8 -5
- package/build/sortForeignKeys.d.cts.map +1 -0
- package/build/sortForeignKeys.d.mts +35 -0
- package/build/sortForeignKeys.d.mts.map +1 -0
- package/build/sortForeignKeys.js +88 -117
- package/build/sortForeignKeys.js.map +1 -1
- package/build/symbols.cjs +238 -0
- package/build/symbols.cjs.map +1 -0
- package/build/symbols.d.cts +120 -0
- package/build/symbols.d.cts.map +1 -0
- package/build/symbols.d.mts +120 -0
- package/build/symbols.d.mts.map +1 -0
- package/build/symbols.js +121 -113
- package/build/symbols.js.map +1 -1
- package/build/tsdoc.cjs +22 -0
- package/build/tsdoc.cjs.map +1 -0
- package/build/tsdoc.d.cts +15 -0
- package/build/tsdoc.d.cts.map +1 -0
- package/build/tsdoc.d.mts +15 -0
- package/build/tsdoc.d.mts.map +1 -0
- package/build/tsdoc.js +18 -15
- package/build/tsdoc.js.map +1 -1
- package/build/utils.cjs +173 -0
- package/build/utils.cjs.map +1 -0
- package/build/utils.d.cts +34 -0
- package/build/utils.d.cts.map +1 -0
- package/build/utils.d.mts +34 -0
- package/build/utils.d.mts.map +1 -0
- package/build/utils.js +112 -166
- package/build/utils.js.map +1 -1
- package/build/write-json-schema.cjs +23 -0
- package/build/write-json-schema.cjs.map +1 -0
- package/build/write-json-schema.d.cts +1 -0
- package/build/write-json-schema.d.mts +1 -0
- package/build/write-json-schema.js +19 -13
- package/build/write-json-schema.js.map +1 -1
- package/package.json +37 -17
- package/skills/joist-docs/SKILL.md +142 -0
- package/skills/joist-em-basics/SKILL.md +114 -0
- package/skills/joist-partial-updates/SKILL.md +352 -0
- package/skills/joist-reactive-hints/SKILL.md +150 -0
- package/skills/joist-test-factories/SKILL.md +397 -0
- package/skills/joist-upsert/SKILL.md +95 -0
- package/build/EntityDbMetadata.d.ts +0 -269
- package/build/EntityDbMetadata.d.ts.map +0 -1
- package/build/EntityDbMetadata.test.d.ts +0 -2
- package/build/EntityDbMetadata.test.d.ts.map +0 -1
- package/build/EntityDbMetadata.test.js +0 -211
- package/build/EntityDbMetadata.test.js.map +0 -1
- package/build/assignTags.d.ts.map +0 -1
- package/build/codemods/Codemod.d.ts +0 -14
- package/build/codemods/Codemod.d.ts.map +0 -1
- package/build/codemods/Codemod.js.map +0 -1
- package/build/codemods/JscodeshiftMod.d.ts +0 -11
- package/build/codemods/JscodeshiftMod.d.ts.map +0 -1
- package/build/codemods/__tests__/codemod_0001-rename_has_async_property.test.d.ts +0 -2
- package/build/codemods/__tests__/codemod_0001-rename_has_async_property.test.d.ts.map +0 -1
- package/build/codemods/__tests__/codemod_0001-rename_has_async_property.test.js +0 -9
- package/build/codemods/__tests__/codemod_0001-rename_has_async_property.test.js.map +0 -1
- package/build/codemods/__tests__/codemod_0002-rename_async_query_fields.test.d.ts +0 -2
- package/build/codemods/__tests__/codemod_0002-rename_async_query_fields.test.d.ts.map +0 -1
- package/build/codemods/__tests__/codemod_0002-rename_async_query_fields.test.js +0 -9
- package/build/codemods/__tests__/codemod_0002-rename_async_query_fields.test.js.map +0 -1
- package/build/codemods/__tests__/codemod_0003-rename_find_paginated.test.d.ts +0 -2
- package/build/codemods/__tests__/codemod_0003-rename_find_paginated.test.d.ts.map +0 -1
- package/build/codemods/__tests__/codemod_0003-rename_find_paginated.test.js +0 -9
- package/build/codemods/__tests__/codemod_0003-rename_find_paginated.test.js.map +0 -1
- package/build/codemods/codemod_0001-rename_has_async_property.d.ts +0 -7
- package/build/codemods/codemod_0001-rename_has_async_property.d.ts.map +0 -1
- package/build/codemods/codemod_0002-rename_async_query_fields.d.ts +0 -7
- package/build/codemods/codemod_0002-rename_async_query_fields.d.ts.map +0 -1
- package/build/codemods/codemod_0003-rename_find_paginated.d.ts +0 -7
- package/build/codemods/codemod_0003-rename_find_paginated.d.ts.map +0 -1
- package/build/codemods/index.d.ts +0 -9
- package/build/codemods/index.d.ts.map +0 -1
- package/build/codemods/index.test.d.ts +0 -2
- package/build/codemods/index.test.d.ts.map +0 -1
- package/build/codemods/index.test.js +0 -24
- package/build/codemods/index.test.js.map +0 -1
- package/build/config.d.ts +0 -167
- package/build/config.d.ts.map +0 -1
- package/build/config.test.d.ts +0 -2
- package/build/config.test.d.ts.map +0 -1
- package/build/config.test.js +0 -78
- package/build/config.test.js.map +0 -1
- package/build/docs/cache.d.ts +0 -14
- package/build/docs/cache.d.ts.map +0 -1
- package/build/docs/cache.test.d.ts +0 -2
- package/build/docs/cache.test.d.ts.map +0 -1
- package/build/docs/cache.test.js +0 -47
- package/build/docs/cache.test.js.map +0 -1
- package/build/docs/generate-metadata-docs.d.ts +0 -6
- package/build/docs/generate-metadata-docs.d.ts.map +0 -1
- package/build/docs/index.d.ts +0 -9
- package/build/docs/index.d.ts.map +0 -1
- package/build/docs/index.test.d.ts +0 -2
- package/build/docs/index.test.d.ts.map +0 -1
- package/build/docs/index.test.js +0 -100
- package/build/docs/index.test.js.map +0 -1
- package/build/docs/markdown.d.ts.map +0 -1
- package/build/docs/markdown.test.d.ts +0 -2
- package/build/docs/markdown.test.d.ts.map +0 -1
- package/build/docs/markdown.test.js +0 -280
- package/build/docs/markdown.test.js.map +0 -1
- package/build/docs/parsing.d.ts +0 -42
- package/build/docs/parsing.d.ts.map +0 -1
- package/build/docs/parsing.test.d.ts +0 -2
- package/build/docs/parsing.test.d.ts.map +0 -1
- package/build/docs/parsing.test.js +0 -190
- package/build/docs/parsing.test.js.map +0 -1
- package/build/findEntityScopes.d.ts +0 -11
- package/build/findEntityScopes.d.ts.map +0 -1
- package/build/foreignKeyOrdering.d.ts +0 -3
- package/build/foreignKeyOrdering.d.ts.map +0 -1
- package/build/generate.d.ts +0 -12
- package/build/generate.d.ts.map +0 -1
- package/build/generateEntitiesFile.d.ts +0 -7
- package/build/generateEntitiesFile.d.ts.map +0 -1
- package/build/generateEntityCodegenFile.d.ts +0 -11
- package/build/generateEntityCodegenFile.d.ts.map +0 -1
- package/build/generateEntityFile.d.ts +0 -6
- package/build/generateEntityFile.d.ts.map +0 -1
- package/build/generateEntityTestFile.d.ts +0 -6
- package/build/generateEntityTestFile.d.ts.map +0 -1
- package/build/generateEnumFile.d.ts +0 -5
- package/build/generateEnumFile.d.ts.map +0 -1
- package/build/generateFactoriesFiles.d.ts +0 -4
- package/build/generateFactoriesFiles.d.ts.map +0 -1
- package/build/generateFlushFunction.d.ts.map +0 -1
- package/build/generateMetadataFile.d.ts +0 -5
- package/build/generateMetadataFile.d.ts.map +0 -1
- package/build/generatePgEnumFile.d.ts +0 -5
- package/build/generatePgEnumFile.d.ts.map +0 -1
- package/build/index.d.ts +0 -11
- package/build/index.d.ts.map +0 -1
- package/build/inheritance.d.ts +0 -10
- package/build/inheritance.d.ts.map +0 -1
- package/build/keywords.d.ts +0 -2
- package/build/keywords.d.ts.map +0 -1
- package/build/loadMetadata.d.ts +0 -26
- package/build/loadMetadata.d.ts.map +0 -1
- package/build/logger.d.ts +0 -10
- package/build/logger.d.ts.map +0 -1
- package/build/scanEntityFiles.d.ts +0 -5
- package/build/scanEntityFiles.d.ts.map +0 -1
- package/build/sortForeignKeys.d.ts.map +0 -1
- package/build/symbols.d.ts +0 -108
- package/build/symbols.d.ts.map +0 -1
- package/build/tsdoc.d.ts +0 -12
- package/build/tsdoc.d.ts.map +0 -1
- package/build/utils.d.ts +0 -31
- package/build/utils.d.ts.map +0 -1
- package/build/write-json-schema.d.ts +0 -2
- package/build/write-json-schema.d.ts.map +0 -1
package/build/config.js
CHANGED
|
@@ -1,394 +1,356 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
/** Controls the style of GraphQL pagination scaffolding. */
|
|
150
|
-
paginationStyle: zod_1.z.optional(zod_1.z.union([zod_1.z.literal("cursor"), zod_1.z.literal("limit")])).default("cursor"),
|
|
151
|
-
/** Enables documentation syncing between .md files and JSDocs. */
|
|
152
|
-
docs: zod_1.z.optional(zod_1.z.boolean()),
|
|
153
|
-
/** Output a metadata-docs.ts file with entity/field documentation available at runtime. */
|
|
154
|
-
outputDocs: zod_1.z.optional(zod_1.z.boolean()),
|
|
155
|
-
/** Auto-set by probing the project's `tsconfig.json` file. */
|
|
156
|
-
allowImportingTsExtensions: zod_1.z.optional(zod_1.z.boolean()),
|
|
157
|
-
/** The latest Joist codemod counter that has been applied to this project. */
|
|
158
|
-
codemodVersion: zod_1.z.number().int().min(0).default(0),
|
|
159
|
-
/** A list of postgres schemas to use for finding tables */
|
|
160
|
-
schemas: zod_1.z.optional(zod_1.z.array(zod_1.z.string())),
|
|
161
|
-
})
|
|
162
|
-
.strict();
|
|
163
|
-
exports.ormMaintainedFields = ["createdAt", "updatedAt"];
|
|
1
|
+
import { getLatestCodemodVersion } from "./codemods/index.js";
|
|
2
|
+
import { fail, sortKeys, trueIfResolved } from "./utils.js";
|
|
3
|
+
import { getStiEntities } from "./inheritance.js";
|
|
4
|
+
import { logger } from "./logger.js";
|
|
5
|
+
import "./EntityDbMetadata.js";
|
|
6
|
+
import { groupBy } from "joist-utils";
|
|
7
|
+
import { existsSync, promises, readFileSync } from "fs";
|
|
8
|
+
import { dirname, join } from "path";
|
|
9
|
+
import { createFromBuffer } from "@dprint/formatter";
|
|
10
|
+
import { getPath } from "@dprint/json";
|
|
11
|
+
import { parse } from "jsonc-parser";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
//#region src/config.ts
|
|
14
|
+
const jsonFormatter = createFromBuffer(readFileSync(getPath()));
|
|
15
|
+
const fieldConfig = z.object({
|
|
16
|
+
derived: z.optional(z.union([z.literal("sync"), z.literal("async")])),
|
|
17
|
+
protected: z.optional(z.boolean()),
|
|
18
|
+
ignore: z.optional(z.boolean()),
|
|
19
|
+
superstruct: z.optional(z.string()),
|
|
20
|
+
zodSchema: z.optional(z.string()),
|
|
21
|
+
type: z.optional(z.string()),
|
|
22
|
+
serde: z.optional(z.string()),
|
|
23
|
+
stiDiscriminator: z.optional(z.record(z.string(), z.string())),
|
|
24
|
+
stiType: z.optional(z.union([z.string(), z.array(z.string())])),
|
|
25
|
+
notNull: z.optional(z.boolean()),
|
|
26
|
+
hasDefault: z.optional(z.boolean()),
|
|
27
|
+
lazy: z.optional(z.boolean())
|
|
28
|
+
}).strict();
|
|
29
|
+
const relationConfig = z.object({
|
|
30
|
+
derived: z.optional(z.literal("async")),
|
|
31
|
+
polymorphic: z.optional(z.union([z.literal("notNull"), z.literal(true)])),
|
|
32
|
+
large: z.optional(z.boolean()),
|
|
33
|
+
orderBy: z.optional(z.string()),
|
|
34
|
+
/**
|
|
35
|
+
* Controls whether this collection's `.get`/`.load` hide soft-deleted entities.
|
|
36
|
+
*
|
|
37
|
+
* Defaults to `"exclude"` (soft-deleted entities are hidden); set to `"include"` to have
|
|
38
|
+
* this specific o2m/m2m always return soft-deleted entities from `.get`/`.load`.
|
|
39
|
+
*/
|
|
40
|
+
softDeletes: z.optional(z.union([z.literal("include"), z.literal("exclude")])),
|
|
41
|
+
stiType: z.optional(z.union([z.string(), z.array(z.string())])),
|
|
42
|
+
/**
|
|
43
|
+
* Allow specializing a base type relation (SmallPublisher.group: SmallPublisherGroup).
|
|
44
|
+
*
|
|
45
|
+
* Self-referential FKs also support `subType: "self"` that means each subtype will point
|
|
46
|
+
* at its own subtype.
|
|
47
|
+
*/
|
|
48
|
+
subType: z.optional(z.string()),
|
|
49
|
+
/** Allow skipping self-referential fields getting a `...Recursive` relation. */
|
|
50
|
+
skipRecursiveRelations: z.optional(z.boolean()),
|
|
51
|
+
notNull: z.optional(z.boolean()),
|
|
52
|
+
hasDefault: z.optional(z.boolean())
|
|
53
|
+
}).strict();
|
|
54
|
+
const uniqueByConfig = z.union([
|
|
55
|
+
z.string(),
|
|
56
|
+
z.array(z.string()),
|
|
57
|
+
z.array(z.array(z.string()))
|
|
58
|
+
]).transform(normalizeUniqueByConfig);
|
|
59
|
+
const entityConfig = z.object({
|
|
60
|
+
tag: z.string(),
|
|
61
|
+
tableName: z.optional(z.string()),
|
|
62
|
+
fields: z.optional(z.record(z.string(), fieldConfig)),
|
|
63
|
+
relations: z.optional(z.record(z.string(), relationConfig)),
|
|
64
|
+
/** Whether this entity should be abstract, e.g. for inheritance a subtype must be instantiated instead of this type. */
|
|
65
|
+
abstract: z.optional(z.boolean()),
|
|
66
|
+
orderBy: z.optional(z.string()),
|
|
67
|
+
uniqueBy: z.optional(uniqueByConfig)
|
|
68
|
+
}).strict();
|
|
69
|
+
const timestampConfig = z.object({
|
|
70
|
+
/** The names to check for this timestamp, i.e. `created_at` `created`, etc. */
|
|
71
|
+
names: z.array(z.string()),
|
|
72
|
+
/** Whether this timestamp column is required to consider a table an entity, defaults to `false`. */
|
|
73
|
+
required: z.optional(z.boolean())
|
|
74
|
+
}).strict();
|
|
75
|
+
const config = z.object({
|
|
76
|
+
/** The _build-time_ database URL for reading database metadata. */
|
|
77
|
+
databaseUrl: z.optional(z.string()),
|
|
78
|
+
/** Your application's request-level `Context` type. */
|
|
79
|
+
contextType: z.optional(z.string()),
|
|
80
|
+
/** Your application's database client's `Transaction` type. */
|
|
81
|
+
transactionType: z.optional(z.string()),
|
|
82
|
+
/**
|
|
83
|
+
* Allows the user to specify the `updated_at` / `created_at` column names to look up, and if they're optional.
|
|
84
|
+
*
|
|
85
|
+
* We default to looking for `updated_at`, `updatedAt`, `created_at`, `createdAt`, and optional to true,
|
|
86
|
+
* e.g. tables are not required to have both timestamp columns to be considered entities.
|
|
87
|
+
*
|
|
88
|
+
* These defaults are the most lenient, to facilitate running Joist against an existing schema and
|
|
89
|
+
* seeing all of your entities, regardless of your previous conventions.
|
|
90
|
+
*/
|
|
91
|
+
timestampColumns: z.optional(z.object({
|
|
92
|
+
createdAt: z.optional(timestampConfig),
|
|
93
|
+
updatedAt: z.optional(timestampConfig),
|
|
94
|
+
deletedAt: z.optional(timestampConfig)
|
|
95
|
+
})),
|
|
96
|
+
/**
|
|
97
|
+
* Allows the user to have codegen output `Temporal` types instead of the base JS `Date`
|
|
98
|
+
*
|
|
99
|
+
* Additionally, allows for specifying the default time zone for `Temporal` types when converting dates to/from
|
|
100
|
+
* the database.
|
|
101
|
+
*/
|
|
102
|
+
temporal: z.optional(z.union([z.boolean(), z.object({ timeZone: z.string() })])),
|
|
103
|
+
/**
|
|
104
|
+
* By default, we create a `flush_database` function for fast testing.
|
|
105
|
+
*
|
|
106
|
+
* However, if you don't want to use this, or you have your own bespoke function like we do
|
|
107
|
+
* that is more application-aware, then you can disable Joist's out-of-the-box one.
|
|
108
|
+
*
|
|
109
|
+
* If you have more than one test database, you can set `createFlushFunction` to the array
|
|
110
|
+
* of test database names, i.e. `mydb_test_1`, `mydb_test_2`, etc.
|
|
111
|
+
*/
|
|
112
|
+
createFlushFunction: z.optional(z.union([z.boolean(), z.array(z.string())])),
|
|
113
|
+
entitiesDirectory: z.string().default("./src/entities"),
|
|
114
|
+
codegenPlugins: z.optional(z.array(z.string())),
|
|
115
|
+
entities: z.record(z.string(), entityConfig).default({}),
|
|
116
|
+
ignoredTables: z.optional(z.array(z.string())),
|
|
117
|
+
/** The type of entity `id` fields; defaults to `tagged-string`. */
|
|
118
|
+
idType: z.optional(z.union([
|
|
119
|
+
z.literal("tagged-string"),
|
|
120
|
+
z.literal("untagged-string"),
|
|
121
|
+
z.literal("number")
|
|
122
|
+
])),
|
|
123
|
+
/** The separator between entity tags and ids; defaults to `:`, and `""` disables the separator. */
|
|
124
|
+
tagDelimiter: z.optional(z.string()),
|
|
125
|
+
/** How we should support non-deferred foreign keys. */
|
|
126
|
+
nonDeferredForeignKeys: z.optional(z.union([
|
|
127
|
+
z.literal("error"),
|
|
128
|
+
z.literal("warn"),
|
|
129
|
+
z.literal("ignore")
|
|
130
|
+
])),
|
|
131
|
+
/** Enables esm output. */
|
|
132
|
+
esm: z.optional(z.boolean()),
|
|
133
|
+
/** Controls the style of GraphQL pagination scaffolding. */
|
|
134
|
+
paginationStyle: z.optional(z.union([z.literal("cursor"), z.literal("limit")])).default("cursor"),
|
|
135
|
+
/** Enables documentation syncing between .md files and JSDocs. */
|
|
136
|
+
docs: z.optional(z.boolean()),
|
|
137
|
+
/** Installs Joist's bundled Agent Skills into `.claude/skills` and `.agents/skills`; on by default, set `false` to disable. */
|
|
138
|
+
skills: z.optional(z.boolean()),
|
|
139
|
+
/** Output a metadata-docs.ts file with entity/field documentation available at runtime. */
|
|
140
|
+
outputDocs: z.optional(z.boolean()),
|
|
141
|
+
/** Auto-set by probing the project's `tsconfig.json` file. */
|
|
142
|
+
allowImportingTsExtensions: z.optional(z.boolean()),
|
|
143
|
+
/** The latest Joist codemod counter that has been applied to this project. */
|
|
144
|
+
codemodVersion: z.number().int().min(0).default(0),
|
|
145
|
+
/** A list of postgres schemas to use for finding tables */
|
|
146
|
+
schemas: z.optional(z.array(z.string()))
|
|
147
|
+
}).strict();
|
|
148
|
+
const ormMaintainedFields = ["createdAt", "updatedAt"];
|
|
164
149
|
/** Ensure the user doesn't have any typos in their config. */
|
|
165
150
|
function warnInvalidConfigEntries(config, db) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
if (!relation)
|
|
231
|
-
logger_1.logger.warn(`Found config for non-existent relation ${entityName}.${name}`);
|
|
232
|
-
}
|
|
233
|
-
const uniqueFields = [
|
|
234
|
-
...entity.primitives,
|
|
235
|
-
...entity.enums,
|
|
236
|
-
...entity.pgEnums,
|
|
237
|
-
...entity.manyToOnes,
|
|
238
|
-
...entity.polymorphics,
|
|
239
|
-
];
|
|
240
|
-
for (const uniqueBy of entityConfig.uniqueBy || []) {
|
|
241
|
-
for (const name of uniqueBy) {
|
|
242
|
-
const field = uniqueFields.find((f) => f.fieldName === name);
|
|
243
|
-
if (!field) {
|
|
244
|
-
logger_1.logger.warn(`Found uniqueBy for non-existent or non-queryable field ${entityName}.${name}`);
|
|
245
|
-
}
|
|
246
|
-
else if (field.kind === "primitive" && (field.derived || field.isArray || field.customSerde)) {
|
|
247
|
-
logger_1.logger.warn(`Found uniqueBy for unsupported primitive field ${entityName}.${name}`);
|
|
248
|
-
}
|
|
249
|
-
else if (field.kind === "enum" && (field.derived || field.isArray)) {
|
|
250
|
-
logger_1.logger.warn(`Found uniqueBy for unsupported enum field ${entityName}.${name}`);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
151
|
+
const entitiesByName = groupBy(db.entities, (e) => e.name);
|
|
152
|
+
for (const [entityName, entityConfig] of Object.entries(config.entities)) {
|
|
153
|
+
const entities = entitiesByName[entityName];
|
|
154
|
+
if (!entities) {
|
|
155
|
+
logger.warn(`Found config for non-existent entity ${entityName}`);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
const [entity] = entities;
|
|
159
|
+
const fields = [...entity.primitives, ...entity.enums];
|
|
160
|
+
for (const [name, config] of Object.entries(entityConfig.fields || {})) {
|
|
161
|
+
if (config.ignore) continue;
|
|
162
|
+
let field = fields.find((f) => f.fieldName === name);
|
|
163
|
+
if (!field && entity.stiDiscriminatorField) field = (getStiEntities(db.entities).get(entity.name)?.subTypes)?.flatMap((st) => [...st.primitives, ...st.enums]).find((f) => f.fieldName === name);
|
|
164
|
+
if (!field) logger.warn(`Found config for non-existent field ${entityName}.${name}`);
|
|
165
|
+
}
|
|
166
|
+
const relations = [
|
|
167
|
+
...entity.manyToOnes,
|
|
168
|
+
...entity.oneToManys,
|
|
169
|
+
...entity.manyToManys,
|
|
170
|
+
...entity.manyToManyEnums,
|
|
171
|
+
...entity.oneToOnes,
|
|
172
|
+
...entity.largeOneToManys,
|
|
173
|
+
...entity.largeManyToManys,
|
|
174
|
+
...entity.polymorphics
|
|
175
|
+
];
|
|
176
|
+
for (const [name, _] of Object.entries(entityConfig.relations || {})) {
|
|
177
|
+
let relation = relations.find((r) => r.fieldName === name);
|
|
178
|
+
if (!relation && entity.stiDiscriminatorField) relation = (getStiEntities(db.entities).get(entity.name)?.subTypes)?.flatMap((entity) => [
|
|
179
|
+
...entity.manyToOnes,
|
|
180
|
+
...entity.oneToManys,
|
|
181
|
+
...entity.manyToManys,
|
|
182
|
+
...entity.oneToOnes,
|
|
183
|
+
...entity.largeOneToManys,
|
|
184
|
+
...entity.largeManyToManys,
|
|
185
|
+
...entity.polymorphics
|
|
186
|
+
])?.find((f) => f.fieldName === name);
|
|
187
|
+
if (!relation && entity.baseType) {
|
|
188
|
+
const baseType = entity.baseType;
|
|
189
|
+
relation = [
|
|
190
|
+
...baseType.manyToOnes,
|
|
191
|
+
...baseType.oneToManys,
|
|
192
|
+
...baseType.manyToManys,
|
|
193
|
+
...baseType.oneToOnes,
|
|
194
|
+
...baseType.largeOneToManys,
|
|
195
|
+
...baseType.largeManyToManys,
|
|
196
|
+
...baseType.polymorphics
|
|
197
|
+
].find((f) => f.fieldName === name);
|
|
198
|
+
}
|
|
199
|
+
if (!relation) logger.warn(`Found config for non-existent relation ${entityName}.${name}`);
|
|
200
|
+
}
|
|
201
|
+
const uniqueFields = [
|
|
202
|
+
...entity.primitives,
|
|
203
|
+
...entity.enums,
|
|
204
|
+
...entity.pgEnums,
|
|
205
|
+
...entity.manyToOnes,
|
|
206
|
+
...entity.polymorphics
|
|
207
|
+
];
|
|
208
|
+
for (const uniqueBy of entityConfig.uniqueBy || []) for (const name of uniqueBy) {
|
|
209
|
+
const field = uniqueFields.find((f) => f.fieldName === name);
|
|
210
|
+
if (!field) logger.warn(`Found uniqueBy for non-existent or non-queryable field ${entityName}.${name}`);
|
|
211
|
+
else if (field.kind === "primitive" && (field.derived || field.isArray || field.customSerde)) logger.warn(`Found uniqueBy for unsupported primitive field ${entityName}.${name}`);
|
|
212
|
+
else if (field.kind === "enum" && (field.derived || field.isArray)) logger.warn(`Found uniqueBy for unsupported enum field ${entityName}.${name}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
255
215
|
}
|
|
256
216
|
function isGetterField(config, entity, fieldName) {
|
|
257
|
-
|
|
217
|
+
return config.entities[entity.name]?.fields?.[fieldName]?.derived === "sync";
|
|
258
218
|
}
|
|
259
219
|
function isReactiveField(config, entity, fieldName) {
|
|
260
|
-
|
|
220
|
+
return config.entities[entity.name]?.fields?.[fieldName]?.derived === "async";
|
|
261
221
|
}
|
|
262
222
|
function isReactiveReference(config, entity, fieldName) {
|
|
263
|
-
|
|
223
|
+
return config.entities[entity.name]?.relations?.[fieldName]?.derived === "async";
|
|
264
224
|
}
|
|
265
225
|
/** Returns true if this m2m relation is configured as a ReactiveManyToMany (derived: async). */
|
|
266
226
|
function isReactiveManyToMany(config, entity, fieldName) {
|
|
267
|
-
|
|
227
|
+
return config.entities[entity.name]?.relations?.[fieldName]?.derived === "async";
|
|
268
228
|
}
|
|
269
229
|
function isProtected(config, entity, fieldName) {
|
|
270
|
-
|
|
230
|
+
return config.entities[entity.name]?.fields?.[fieldName]?.protected === true;
|
|
231
|
+
}
|
|
232
|
+
/** Whether a column should be excluded from the default SELECT and exposed as a lazy-loaded `LazyField`. */
|
|
233
|
+
function isLazyField(config, entity, fieldName) {
|
|
234
|
+
return config.entities[entity.name]?.fields?.[fieldName]?.lazy === true;
|
|
271
235
|
}
|
|
272
236
|
function serdeConfig(config, entity, fieldName) {
|
|
273
|
-
|
|
237
|
+
return config.entities[entity.name]?.fields?.[fieldName]?.serde;
|
|
274
238
|
}
|
|
275
239
|
function superstructConfig(config, entity, fieldName) {
|
|
276
|
-
|
|
240
|
+
return config.entities[entity.name]?.fields?.[fieldName]?.superstruct;
|
|
277
241
|
}
|
|
278
242
|
function zodSchemaConfig(config, entity, fieldName) {
|
|
279
|
-
|
|
243
|
+
return config.entities[entity.name]?.fields?.[fieldName]?.zodSchema;
|
|
280
244
|
}
|
|
281
245
|
function fieldTypeConfig(config, entity, fieldName) {
|
|
282
|
-
|
|
246
|
+
return config.entities[entity.name]?.fields?.[fieldName]?.type;
|
|
283
247
|
}
|
|
284
248
|
function isLargeCollection(config, entity, fieldName) {
|
|
285
|
-
|
|
249
|
+
return config.entities[entity.name]?.relations?.[fieldName]?.large === true;
|
|
250
|
+
}
|
|
251
|
+
/** Whether a collection should include (or exclude) soft-deleted entities from `.get`/`.load`. */
|
|
252
|
+
function softDeletesConfig(config, entity, fieldName) {
|
|
253
|
+
return config.entities[entity.name]?.relations?.[fieldName]?.softDeletes;
|
|
286
254
|
}
|
|
287
255
|
function isFieldIgnored(config, entity, fieldName, notNull = false, hasDefault = false) {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
return ignore;
|
|
256
|
+
const ignore = config.entities[entity.name]?.fields?.[fieldName]?.ignore === true;
|
|
257
|
+
if (ignore && notNull && !hasDefault) fail(`notNull field ${entity.name}.${fieldName} cannot be ignored. Alter the column to be optional or have a default value prior to ignoring it.`);
|
|
258
|
+
return ignore;
|
|
293
259
|
}
|
|
294
260
|
function isFieldHasDefault(config, entity, fieldName) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
return fieldConfig.hasDefault === true;
|
|
261
|
+
const entityConfig = config.entities[entity.name] ?? {};
|
|
262
|
+
return (entityConfig.fields?.[fieldName] ?? entityConfig.relations?.[fieldName] ?? {}).hasDefault === true;
|
|
298
263
|
}
|
|
299
264
|
const configPath = "./joist-config.json";
|
|
300
265
|
async function loadConfig() {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
return result.data;
|
|
312
|
-
}
|
|
313
|
-
// Brand-new projects should not be prompted to run historical codemods.
|
|
314
|
-
const initial = exports.config.parse({ codemodVersion: (0, codemods_1.getLatestCodemodVersion)() });
|
|
315
|
-
initial.allowImportingTsExtensions ??= projectIsUsingEsmWithImports();
|
|
316
|
-
return initial;
|
|
266
|
+
if (await trueIfResolved(promises.access(configPath))) {
|
|
267
|
+
const content = await promises.readFile(configPath);
|
|
268
|
+
const result = config.safeParse(stripLegacyConfigKeys(JSON.parse(content.toString())));
|
|
269
|
+
if (!result.success) throw new Error(`Invalid joist-config.json: ${result.error.issues.map((ze) => `${ze.path.map(String).join("/")} ${ze.message}`).join("\n")}`);
|
|
270
|
+
result.data.allowImportingTsExtensions ??= projectIsUsingEsmWithImports();
|
|
271
|
+
return result.data;
|
|
272
|
+
}
|
|
273
|
+
const initial = config.parse({ codemodVersion: getLatestCodemodVersion() });
|
|
274
|
+
initial.allowImportingTsExtensions ??= projectIsUsingEsmWithImports();
|
|
275
|
+
return initial;
|
|
317
276
|
}
|
|
318
277
|
/**
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
278
|
+
* Writes the potentially-updated config entry back to `joist-config.json`.
|
|
279
|
+
*
|
|
280
|
+
* We format the output with prettier so it should both a) look nice and b) be deterministic,
|
|
281
|
+
* such that no changes to the config show up as noops to the scm.
|
|
282
|
+
*/
|
|
324
283
|
async function writeConfig(config) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
284
|
+
const sorted = sortKeys(config);
|
|
285
|
+
delete sorted.__tableToEntityName;
|
|
286
|
+
delete sorted.allowImportingTsExtensions;
|
|
287
|
+
if (sorted.paginationStyle === "cursor") delete sorted.paginationStyle;
|
|
288
|
+
const input = JSON.stringify(sorted);
|
|
289
|
+
const content = jsonFormatter.formatText({
|
|
290
|
+
filePath: "test.json",
|
|
291
|
+
fileText: input
|
|
292
|
+
});
|
|
293
|
+
await promises.writeFile(configPath, content);
|
|
334
294
|
}
|
|
335
295
|
function stripStiPlaceholders(config, entities) {
|
|
336
|
-
|
|
337
|
-
// so don't write confusing subtype-specific entries into the config file.
|
|
338
|
-
// ...hopefully we don't have any code accidentally looking for the STI config...
|
|
339
|
-
for (const entity of entities) {
|
|
340
|
-
if (entity.inheritanceType === "sti" && entity.stiDiscriminatorValue) {
|
|
341
|
-
delete config.entities[entity.name];
|
|
342
|
-
}
|
|
343
|
-
}
|
|
296
|
+
for (const entity of entities) if (entity.inheritanceType === "sti" && entity.stiDiscriminatorValue) delete config.entities[entity.name];
|
|
344
297
|
}
|
|
345
298
|
/** Applies defaults to the timestamp config. */
|
|
346
299
|
function getTimestampConfig(config) {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
300
|
+
return {
|
|
301
|
+
createdAtConf: {
|
|
302
|
+
names: ["created_at", "createdAt"],
|
|
303
|
+
required: false,
|
|
304
|
+
...config?.timestampColumns?.createdAt
|
|
305
|
+
},
|
|
306
|
+
updatedAtConf: {
|
|
307
|
+
names: ["updated_at", "updatedAt"],
|
|
308
|
+
required: false,
|
|
309
|
+
...config?.timestampColumns?.updatedAt
|
|
310
|
+
},
|
|
311
|
+
deletedAtConf: {
|
|
312
|
+
names: ["deleted_at", "deletedAt"],
|
|
313
|
+
required: false,
|
|
314
|
+
...config?.timestampColumns?.deletedAt
|
|
315
|
+
}
|
|
316
|
+
};
|
|
364
317
|
}
|
|
365
318
|
function projectIsUsingEsmWithImports() {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
319
|
+
const configPath = findTsConfigFile(process.cwd());
|
|
320
|
+
if (!configPath) return false;
|
|
321
|
+
try {
|
|
322
|
+
const errors = [];
|
|
323
|
+
const parsed = parse(readFileSync(configPath, "utf8"), errors, { allowTrailingComma: true });
|
|
324
|
+
if (errors.length > 0 || typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return false;
|
|
325
|
+
const compilerOptions = parsed.compilerOptions;
|
|
326
|
+
return typeof compilerOptions === "object" && compilerOptions !== null && !Array.isArray(compilerOptions) && compilerOptions.allowImportingTsExtensions === true;
|
|
327
|
+
} catch {
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
376
330
|
}
|
|
377
331
|
/** Normalizes `uniqueBy` config sugar into runtime identity candidates. */
|
|
378
332
|
function normalizeUniqueByConfig(uniqueBy) {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
return [uniqueBy];
|
|
383
|
-
return uniqueBy;
|
|
333
|
+
if (typeof uniqueBy === "string") return [[uniqueBy]];
|
|
334
|
+
if (uniqueBy.every((field) => typeof field === "string")) return [uniqueBy];
|
|
335
|
+
return uniqueBy;
|
|
384
336
|
}
|
|
385
337
|
function stripLegacyConfigKeys(raw) {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
338
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
339
|
+
const parsed = { ...raw };
|
|
340
|
+
delete parsed.version;
|
|
341
|
+
return parsed;
|
|
342
|
+
}
|
|
343
|
+
/** Finds the nearest `tsconfig.json` in `directory` or one of its ancestors. */
|
|
344
|
+
function findTsConfigFile(directory) {
|
|
345
|
+
while (true) {
|
|
346
|
+
const fileName = join(directory, "tsconfig.json");
|
|
347
|
+
if (existsSync(fileName)) return fileName;
|
|
348
|
+
const parent = dirname(directory);
|
|
349
|
+
if (parent === directory) return void 0;
|
|
350
|
+
directory = parent;
|
|
351
|
+
}
|
|
393
352
|
}
|
|
353
|
+
//#endregion
|
|
354
|
+
export { config, fieldTypeConfig, getTimestampConfig, isFieldHasDefault, isFieldIgnored, isGetterField, isLargeCollection, isLazyField, isProtected, isReactiveField, isReactiveManyToMany, isReactiveReference, loadConfig, ormMaintainedFields, serdeConfig, softDeletesConfig, stripStiPlaceholders, superstructConfig, warnInvalidConfigEntries, writeConfig, zodSchemaConfig };
|
|
355
|
+
|
|
394
356
|
//# sourceMappingURL=config.js.map
|