joist-codegen 2.3.0-next.5 → 2.3.0-next.50
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 +608 -0
- package/build/EntityDbMetadata.cjs.map +1 -0
- package/build/EntityDbMetadata.d.cts +274 -0
- package/build/EntityDbMetadata.d.cts.map +1 -0
- package/build/EntityDbMetadata.d.mts +274 -0
- package/build/EntityDbMetadata.d.mts.map +1 -0
- package/build/EntityDbMetadata.js +485 -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 +127 -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 +110 -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 +936 -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 +718 -826
- 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 +290 -0
- package/build/generateMetadataFile.cjs.map +1 -0
- package/build/generateMetadataFile.d.cts +8 -0
- package/build/generateMetadataFile.d.cts.map +1 -0
- package/build/generateMetadataFile.d.mts +8 -0
- package/build/generateMetadataFile.d.mts.map +1 -0
- package/build/generateMetadataFile.js +116 -140
- 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 +213 -0
- package/build/inheritance.cjs.map +1 -0
- package/build/inheritance.d.cts +12 -0
- package/build/inheritance.d.cts.map +1 -0
- package/build/inheritance.d.mts +12 -0
- package/build/inheritance.d.mts.map +1 -0
- package/build/inheritance.js +193 -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 +226 -0
- package/build/symbols.cjs.map +1 -0
- package/build/symbols.d.cts +114 -0
- package/build/symbols.d.cts.map +1 -0
- package/build/symbols.d.mts +114 -0
- package/build/symbols.d.mts.map +1 -0
- package/build/symbols.js +115 -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 +133 -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
|
@@ -0,0 +1,608 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_utils = require("./utils.cjs");
|
|
4
|
+
const require_config = require("./config.cjs");
|
|
5
|
+
const require_symbols = require("./symbols.cjs");
|
|
6
|
+
require("./loadMetadata.cjs");
|
|
7
|
+
let change_case = require("change-case");
|
|
8
|
+
let joist_utils = require("joist-utils");
|
|
9
|
+
let pg_structure = require("pg-structure");
|
|
10
|
+
let pluralize = require("pluralize");
|
|
11
|
+
pluralize = require_runtime.__toESM(pluralize, 1);
|
|
12
|
+
let ts_poet = require("ts-poet");
|
|
13
|
+
//#region src/EntityDbMetadata.ts
|
|
14
|
+
const { plural, singular } = pluralize.default;
|
|
15
|
+
/** Adapts the generally-great pg-structure metadata into our specific ORM types. */
|
|
16
|
+
var EntityDbMetadata = class {
|
|
17
|
+
entity;
|
|
18
|
+
primaryKey;
|
|
19
|
+
primitives;
|
|
20
|
+
enums;
|
|
21
|
+
pgEnums;
|
|
22
|
+
manyToOnes;
|
|
23
|
+
oneToManys;
|
|
24
|
+
largeOneToManys;
|
|
25
|
+
oneToOnes;
|
|
26
|
+
manyToManys;
|
|
27
|
+
largeManyToManys;
|
|
28
|
+
manyToManyEnums;
|
|
29
|
+
polymorphics;
|
|
30
|
+
tableName;
|
|
31
|
+
tagName;
|
|
32
|
+
createdAt;
|
|
33
|
+
updatedAt;
|
|
34
|
+
deletedAt;
|
|
35
|
+
baseClassName;
|
|
36
|
+
baseType;
|
|
37
|
+
subTypes = [];
|
|
38
|
+
inheritanceType;
|
|
39
|
+
/** This will only be set on the base meta. */
|
|
40
|
+
stiDiscriminatorField;
|
|
41
|
+
/** This will only be set on the sub metas. */
|
|
42
|
+
stiDiscriminatorValue;
|
|
43
|
+
abstract;
|
|
44
|
+
nonDeferredFkOrder = -1;
|
|
45
|
+
uniqueConstraints;
|
|
46
|
+
constructor(config, table, enums = {}) {
|
|
47
|
+
this.entity = makeEntity(require_utils.tableToEntityName(config, table));
|
|
48
|
+
if (require_utils.isSubClassTable(table)) {
|
|
49
|
+
this.baseClassName = require_utils.tableToEntityName(config, table.columns.get("id").foreignKeys[0].referencedTable);
|
|
50
|
+
this.inheritanceType = "cti";
|
|
51
|
+
}
|
|
52
|
+
this.primaryKey = table.columns.filter((c) => c.isPrimaryKey).map((column) => newPrimitive(config, this.entity, column, table))[0] || require_utils.fail(`No primary key found for ${table.name}`);
|
|
53
|
+
this.primitives = table.columns.filter((c) => !c.isPrimaryKey && !c.isForeignKey).filter((c) => !isEnumArray(c) && !isPgEnum(c)).map((column) => newPrimitive(config, this.entity, column, table)).filter((f) => !f.ignore);
|
|
54
|
+
this.enums = [...table.m2oRelations.filter((r) => require_utils.isEnumTable(config, r.targetTable)).map((r) => newEnumField(config, this.entity, r, enums)).filter((f) => !f.ignore), ...table.columns.filter((c) => isEnumArray(c)).map((column) => newEnumArrayField(config, this.entity, column, enums)).filter((f) => !f.ignore)];
|
|
55
|
+
this.pgEnums = table.columns.filter((c) => isPgEnum(c)).map((column) => newPgEnumField(config, this.entity, column)).filter((f) => !f.ignore);
|
|
56
|
+
this.manyToOnes = table.m2oRelations.filter((r) => !require_utils.isEnumTable(config, r.targetTable)).filter((r) => !isMultiColumnForeignKey(r)).filter((r) => !isComponentOfPolymorphicRelation(config, r)).filter((r) => !isBaseClassForeignKey(r)).map((r) => newManyToOneField(config, this.entity, r)).filter((f) => !f.ignore);
|
|
57
|
+
const allOneToManys = table.o2mRelations.filter((r) => !require_utils.isJoinTable(config, r.targetTable)).filter((r) => !isMultiColumnForeignKey(r)).filter((r) => !isOneToOneRelation(r)).map((r) => newOneToMany(config, this.entity, r)).filter((f) => !require_config.isReactiveReference(config, f.otherEntity, f.otherFieldName)).filter((f) => !f.ignore);
|
|
58
|
+
this.oneToManys = allOneToManys.filter((f) => !f.isLargeCollection);
|
|
59
|
+
this.largeOneToManys = allOneToManys.filter((f) => f.isLargeCollection);
|
|
60
|
+
this.oneToOnes = table.o2mRelations.filter((r) => !require_utils.isJoinTable(config, r.targetTable)).filter((r) => !isMultiColumnForeignKey(r)).filter((r) => !isBaseClassForeignKey(r)).filter((r) => isOneToOneRelation(r)).map((r) => newOneToOne(config, this.entity, r)).filter((f) => !f.ignore);
|
|
61
|
+
const allManyToManys = table.m2mRelations.filter((r) => require_utils.isJoinTable(config, r.joinTable)).filter((r) => !isMultiColumnForeignKey(r)).filter((r) => !require_utils.isEnumTable(config, r.targetTable)).map((r) => newManyToManyField(config, this.entity, r)).filter((f) => !f.ignore);
|
|
62
|
+
this.manyToManys = allManyToManys.filter((f) => !f.isLargeCollection);
|
|
63
|
+
this.largeManyToManys = allManyToManys.filter((f) => f.isLargeCollection);
|
|
64
|
+
this.manyToManyEnums = table.m2mRelations.filter((r) => require_utils.isJoinTable(config, r.joinTable)).filter((r) => !isMultiColumnForeignKey(r)).filter((r) => require_utils.isEnumTable(config, r.targetTable)).map((r) => newManyToManyEnumField(config, this.entity, r, enums)).filter((f) => !f.ignore);
|
|
65
|
+
this.polymorphics = polymorphicRelations(config, table).map((rc) => newPolymorphicField(config, table, this.entity, rc));
|
|
66
|
+
this.tableName = table.name;
|
|
67
|
+
this.tagName = config.entities[this.entity.name]?.tag;
|
|
68
|
+
this.abstract = config.entities[this.entity.name]?.abstract || false;
|
|
69
|
+
const { createdAtConf, updatedAtConf, deletedAtConf } = require_config.getTimestampConfig(config);
|
|
70
|
+
this.createdAt = this.primitives.find((f) => createdAtConf.names.includes(f.columnName));
|
|
71
|
+
this.updatedAt = this.primitives.find((f) => updatedAtConf.names.includes(f.columnName));
|
|
72
|
+
this.deletedAt = this.primitives.find((f) => deletedAtConf.names.includes(f.columnName));
|
|
73
|
+
this.uniqueConstraints = inferUniqueConstraints(this, table);
|
|
74
|
+
}
|
|
75
|
+
get name() {
|
|
76
|
+
return this.entity.name;
|
|
77
|
+
}
|
|
78
|
+
get nonDeferredFks() {
|
|
79
|
+
return [...this.manyToOnes.filter((r) => !r.isDeferredAndDeferrable), ...this.polymorphics.flatMap((p) => p.components).filter((c) => !c.isDeferredAndDeferrable)];
|
|
80
|
+
}
|
|
81
|
+
get nonDeferredManyToManyFks() {
|
|
82
|
+
return this.manyToManys.filter((r) => !r.isDeferredAndDeferrable);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
function isMultiColumnForeignKey(r) {
|
|
86
|
+
return r.foreignKey.columns.length > 1;
|
|
87
|
+
}
|
|
88
|
+
function isBaseClassForeignKey(r) {
|
|
89
|
+
return r.foreignKey.columns.length === 1 && r.foreignKey.columns[0].name === "id";
|
|
90
|
+
}
|
|
91
|
+
function isOneToOneRelation(r) {
|
|
92
|
+
const otherColumn = r.foreignKey.columns[0];
|
|
93
|
+
return (r.targetTable.columns.find((c) => c.name == otherColumn.name)?.uniqueIndexes || []).find(isOneToOneIndex) !== void 0;
|
|
94
|
+
}
|
|
95
|
+
function isOneToOneIndex(i) {
|
|
96
|
+
return i.columns.length === 1 && !i.isPartial;
|
|
97
|
+
}
|
|
98
|
+
/** Infers field names from unique constraints, i.e. `(author_id, title)` becomes `author, title`. */
|
|
99
|
+
function inferUniqueConstraints(meta, table) {
|
|
100
|
+
return table.uniqueConstraints.flatMap((constraint) => {
|
|
101
|
+
if (constraint.index.isPartial) return [];
|
|
102
|
+
const fields = Array.from(constraint.columns).map((column) => fieldNameForColumn(meta, column.name));
|
|
103
|
+
if (fields.some((field) => field === void 0)) return [];
|
|
104
|
+
return [fields];
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/** Returns the queryable field name for a unique constraint column. */
|
|
108
|
+
function fieldNameForColumn(meta, columnName) {
|
|
109
|
+
const primitive = meta.primitives.find((field) => field.columnName === columnName);
|
|
110
|
+
if (primitive && !primitive.derived && !primitive.isArray && !primitive.customSerde) return primitive.fieldName;
|
|
111
|
+
const enumField = meta.enums.find((field) => field.columnName === columnName);
|
|
112
|
+
if (enumField && !enumField.derived && !enumField.isArray) return enumField.fieldName;
|
|
113
|
+
const pgEnum = meta.pgEnums.find((field) => field.columnName === columnName);
|
|
114
|
+
if (pgEnum) return pgEnum.fieldName;
|
|
115
|
+
const manyToOne = meta.manyToOnes.find((field) => field.columnName === columnName);
|
|
116
|
+
if (manyToOne && !manyToOne.derived) return manyToOne.fieldName;
|
|
117
|
+
}
|
|
118
|
+
function polymorphicRelations(config, table) {
|
|
119
|
+
const entity = config.entities[require_utils.tableToEntityName(config, table)];
|
|
120
|
+
return Object.entries(entity?.relations ?? {}).filter(([, r]) => r.polymorphic).map(([fieldName, { polymorphic }]) => ({
|
|
121
|
+
fieldName,
|
|
122
|
+
notNull: polymorphic === "notNull"
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
function polymorphicFieldName(config, r) {
|
|
126
|
+
const { name } = r.foreignKey.columns[0];
|
|
127
|
+
return polymorphicRelations(config, r.type === "m2o" ? r.sourceTable : r.targetTable).find((pr) => name.startsWith(`${(0, change_case.snakeCase)(pr.fieldName)}_`))?.fieldName;
|
|
128
|
+
}
|
|
129
|
+
function isComponentOfPolymorphicRelation(config, r) {
|
|
130
|
+
return polymorphicFieldName(config, r) !== void 0;
|
|
131
|
+
}
|
|
132
|
+
function determineUserType(fieldType, superstruct, zodSchema, userFieldType) {
|
|
133
|
+
if (fieldType === "Object" && superstruct) return superstructType(superstruct);
|
|
134
|
+
if (fieldType === "Object" && zodSchema) return zodSchemaType(zodSchema);
|
|
135
|
+
if (userFieldType) return userFieldTypeType(userFieldType);
|
|
136
|
+
return fieldType;
|
|
137
|
+
}
|
|
138
|
+
function newPrimitive(config, entity, column, table) {
|
|
139
|
+
const fieldName = primitiveFieldName(column.name);
|
|
140
|
+
const columnName = column.name;
|
|
141
|
+
const columnType = column.type.shortName || column.type.name;
|
|
142
|
+
const array = isArray(column);
|
|
143
|
+
const fieldType = mapType(config, table.name, columnName, columnType);
|
|
144
|
+
const customSerde = require_config.serdeConfig(config, entity, fieldName);
|
|
145
|
+
const superstruct = require_config.superstructConfig(config, entity, fieldName);
|
|
146
|
+
const zodSchema = require_config.zodSchemaConfig(config, entity, fieldName);
|
|
147
|
+
const maybeUserType = determineUserType(fieldType, superstruct, zodSchema, require_config.fieldTypeConfig(config, entity, fieldName));
|
|
148
|
+
const unique = column.uniqueIndexes.find(isOneToOneIndex) !== void 0;
|
|
149
|
+
const hasConfigDefault = require_config.isFieldHasDefault(config, entity, fieldName);
|
|
150
|
+
return {
|
|
151
|
+
kind: "primitive",
|
|
152
|
+
fieldName,
|
|
153
|
+
columnName,
|
|
154
|
+
columnType,
|
|
155
|
+
fieldType: array ? ts_poet.code`${fieldType}[]` : maybeUserType,
|
|
156
|
+
rawFieldType: fieldType,
|
|
157
|
+
notNull: column.notNull,
|
|
158
|
+
columnDefault: column.default,
|
|
159
|
+
derived: fieldDerived(config, entity, fieldName),
|
|
160
|
+
protected: require_config.isProtected(config, entity, fieldName),
|
|
161
|
+
unique,
|
|
162
|
+
ignore: require_config.isFieldIgnored(config, entity, fieldName, column.notNull, column.default !== null),
|
|
163
|
+
superstruct: fieldType === "Object" && superstruct ? ts_poet.Import.from(superstruct) : void 0,
|
|
164
|
+
zodSchema: fieldType === "Object" && zodSchema ? ts_poet.Import.from(zodSchema) : void 0,
|
|
165
|
+
customSerde: customSerde ? serdeType(customSerde) : void 0,
|
|
166
|
+
isArray: array,
|
|
167
|
+
hasConfigDefault,
|
|
168
|
+
lazy: require_config.isLazyField(config, entity, fieldName)
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function fieldDerived(config, entity, fieldName) {
|
|
172
|
+
if (require_config.ormMaintainedFields.includes(fieldName)) return "orm";
|
|
173
|
+
else if (require_config.isGetterField(config, entity, fieldName)) return "sync";
|
|
174
|
+
else if (require_config.isReactiveField(config, entity, fieldName)) return "async";
|
|
175
|
+
else return false;
|
|
176
|
+
}
|
|
177
|
+
function fkFieldDerived(config, entity, fieldName) {
|
|
178
|
+
if (require_config.isReactiveReference(config, entity, fieldName)) return "async";
|
|
179
|
+
else return false;
|
|
180
|
+
}
|
|
181
|
+
function newEnumField(config, entity, r, enums) {
|
|
182
|
+
const column = r.foreignKey.columns[0];
|
|
183
|
+
const columnName = column.name;
|
|
184
|
+
const columnType = column.type.shortName || column.type.name;
|
|
185
|
+
const fieldName = enumFieldName(column.name);
|
|
186
|
+
const enumName = require_utils.tableToEntityName(config, r.targetTable);
|
|
187
|
+
const enumType = (0, ts_poet.imp)(`${enumName}@./entities.ts`);
|
|
188
|
+
const enumDetailType = (0, ts_poet.imp)(`${plural(enumName)}@./entities.ts`);
|
|
189
|
+
const enumDetailsType = (0, ts_poet.imp)(`${enumName}Details@./entities.ts`);
|
|
190
|
+
const notNull = column.notNull;
|
|
191
|
+
const ignore = require_config.isFieldIgnored(config, entity, fieldName, notNull, column.default !== null);
|
|
192
|
+
const hasConfigDefault = require_config.isFieldHasDefault(config, entity, fieldName);
|
|
193
|
+
return {
|
|
194
|
+
kind: "enum",
|
|
195
|
+
fieldName,
|
|
196
|
+
columnName,
|
|
197
|
+
columnType,
|
|
198
|
+
columnDefault: column.default,
|
|
199
|
+
derived: fieldDerived(config, entity, fieldName),
|
|
200
|
+
enumName,
|
|
201
|
+
enumType,
|
|
202
|
+
enumDetailType,
|
|
203
|
+
enumDetailsType,
|
|
204
|
+
notNull,
|
|
205
|
+
ignore,
|
|
206
|
+
enumRows: enums[r.targetTable.name].rows,
|
|
207
|
+
isArray: false,
|
|
208
|
+
hasConfigDefault
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function newEnumArrayField(config, entity, column, enums) {
|
|
212
|
+
const columnName = column.name;
|
|
213
|
+
const columnType = column.type.shortName || column.type.name;
|
|
214
|
+
const fieldName = enumFieldName(column.name);
|
|
215
|
+
const enumTable = column.comment.replace("enum=", "");
|
|
216
|
+
const enumName = (enums[enumTable] || require_utils.fail(`Could not find enum ${enumTable}`)).name;
|
|
217
|
+
const enumType = (0, ts_poet.imp)(`${enumName}@./entities.ts`);
|
|
218
|
+
const enumDetailType = (0, ts_poet.imp)(`${plural(enumName)}@./entities.ts`);
|
|
219
|
+
const enumDetailsType = (0, ts_poet.imp)(`${enumName}Details@./entities.ts`);
|
|
220
|
+
const notNull = column.notNull;
|
|
221
|
+
const ignore = require_config.isFieldIgnored(config, entity, fieldName, notNull, column.default !== null);
|
|
222
|
+
const hasConfigDefault = require_config.isFieldHasDefault(config, entity, fieldName);
|
|
223
|
+
return {
|
|
224
|
+
kind: "enum",
|
|
225
|
+
fieldName,
|
|
226
|
+
columnName,
|
|
227
|
+
columnType,
|
|
228
|
+
columnDefault: column.default,
|
|
229
|
+
derived: fieldDerived(config, entity, fieldName),
|
|
230
|
+
enumName,
|
|
231
|
+
enumType,
|
|
232
|
+
enumDetailType,
|
|
233
|
+
enumDetailsType,
|
|
234
|
+
notNull,
|
|
235
|
+
ignore,
|
|
236
|
+
enumRows: enums[enumTable].rows,
|
|
237
|
+
isArray: true,
|
|
238
|
+
hasConfigDefault
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
function newPgEnumField(config, entity, column) {
|
|
242
|
+
const fieldName = primitiveFieldName(column.name);
|
|
243
|
+
const columnName = column.name;
|
|
244
|
+
const enumName = (0, change_case.pascalCase)(column.type.name);
|
|
245
|
+
const enumType = (0, ts_poet.imp)(`${enumName}@./entities.ts`);
|
|
246
|
+
const hasConfigDefault = require_config.isFieldHasDefault(config, entity, fieldName);
|
|
247
|
+
return {
|
|
248
|
+
kind: "pg-enum",
|
|
249
|
+
fieldName,
|
|
250
|
+
columnName,
|
|
251
|
+
dbType: column.type.name,
|
|
252
|
+
enumType,
|
|
253
|
+
enumName,
|
|
254
|
+
enumValues: column.type.values,
|
|
255
|
+
notNull: column.notNull,
|
|
256
|
+
columnDefault: column.default,
|
|
257
|
+
ignore: require_config.isFieldIgnored(config, entity, fieldName, column.notNull, column.default !== null),
|
|
258
|
+
hasConfigDefault
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
function newManyToOneField(config, entity, r) {
|
|
262
|
+
const column = r.foreignKey.columns[0];
|
|
263
|
+
const columnName = column.name;
|
|
264
|
+
const dbType = r.foreignKey.columns[0].type.shortName;
|
|
265
|
+
const fieldName = referenceName(config, entity, r);
|
|
266
|
+
const otherEntity = makeEntity(require_utils.tableToEntityName(config, r.targetTable));
|
|
267
|
+
const otherFieldName = column.uniqueIndexes.find(isOneToOneIndex) !== void 0 ? oneToOneName(config, otherEntity, entity, r) : collectionName(config, otherEntity, entity, r).fieldName;
|
|
268
|
+
const notNull = column.notNull;
|
|
269
|
+
const ignore = require_config.isFieldIgnored(config, entity, fieldName, notNull, column.default !== null);
|
|
270
|
+
const isDeferredAndDeferrable = r.foreignKey.isDeferred && r.foreignKey.isDeferrable;
|
|
271
|
+
const derived = fkFieldDerived(config, entity, fieldName);
|
|
272
|
+
const hasConfigDefault = require_config.isFieldHasDefault(config, entity, fieldName);
|
|
273
|
+
return {
|
|
274
|
+
kind: "m2o",
|
|
275
|
+
fieldName,
|
|
276
|
+
columnName,
|
|
277
|
+
otherEntity,
|
|
278
|
+
otherFieldName,
|
|
279
|
+
notNull,
|
|
280
|
+
ignore,
|
|
281
|
+
derived,
|
|
282
|
+
dbType,
|
|
283
|
+
isDeferredAndDeferrable,
|
|
284
|
+
constraintName: r.foreignKey.name,
|
|
285
|
+
hasConfigDefault,
|
|
286
|
+
onDelete: r.foreignKey.onDelete
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
function newOneToMany(config, entity, r) {
|
|
290
|
+
const column = r.foreignKey.columns[0];
|
|
291
|
+
const otherEntity = makeEntity(require_utils.tableToEntityName(config, r.targetTable));
|
|
292
|
+
const { singularName, fieldName } = collectionName(config, entity, otherEntity, r);
|
|
293
|
+
const otherFieldName = referenceName(config, otherEntity, r);
|
|
294
|
+
const orderBy = config.entities[entity.name]?.relations?.[fieldName]?.orderBy ?? config.entities[otherEntity.name]?.orderBy;
|
|
295
|
+
return {
|
|
296
|
+
kind: "o2m",
|
|
297
|
+
fieldName,
|
|
298
|
+
singularName,
|
|
299
|
+
otherEntity,
|
|
300
|
+
otherFieldName,
|
|
301
|
+
otherColumnName: column.name,
|
|
302
|
+
otherColumnNotNull: column.notNull,
|
|
303
|
+
ignore: require_config.isFieldIgnored(config, entity, fieldName) || require_config.isFieldIgnored(config, otherEntity, otherFieldName),
|
|
304
|
+
isLargeCollection: require_config.isLargeCollection(config, entity, fieldName),
|
|
305
|
+
orderBy: require_utils.parseOrder(orderBy),
|
|
306
|
+
softDeletes: require_config.softDeletesConfig(config, entity, fieldName)
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
function newOneToOne(config, entity, r) {
|
|
310
|
+
const column = r.foreignKey.columns[0];
|
|
311
|
+
const otherEntity = makeEntity(require_utils.tableToEntityName(config, r.targetTable));
|
|
312
|
+
const fieldName = oneToOneName(config, entity, otherEntity, r);
|
|
313
|
+
const otherFieldName = referenceName(config, otherEntity, r);
|
|
314
|
+
return {
|
|
315
|
+
kind: "o2o",
|
|
316
|
+
fieldName,
|
|
317
|
+
otherEntity,
|
|
318
|
+
otherFieldName,
|
|
319
|
+
otherColumnName: column.name,
|
|
320
|
+
otherColumnNotNull: column.notNull,
|
|
321
|
+
ignore: require_config.isFieldIgnored(config, entity, fieldName) || require_config.isFieldIgnored(config, otherEntity, otherFieldName)
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function newManyToManyField(config, entity, r) {
|
|
325
|
+
const { foreignKey, targetForeignKey, targetTable } = r;
|
|
326
|
+
const otherEntity = makeEntity(require_utils.tableToEntityName(config, targetTable));
|
|
327
|
+
const fieldName = manyToManyName(targetForeignKey.columns[0]);
|
|
328
|
+
const otherFieldName = manyToManyName(foreignKey.columns[0]);
|
|
329
|
+
const isDeferredAndDeferrable = targetForeignKey.isDeferred && targetForeignKey.isDeferrable;
|
|
330
|
+
const isThisSideDerived = require_config.isReactiveManyToMany(config, entity, fieldName);
|
|
331
|
+
const isOtherSideDerived = require_config.isReactiveManyToMany(config, otherEntity, otherFieldName);
|
|
332
|
+
const derived = isThisSideDerived ? "async" : isOtherSideDerived ? "otherSide" : false;
|
|
333
|
+
return {
|
|
334
|
+
kind: "m2m",
|
|
335
|
+
joinTableName: r.joinTable.name,
|
|
336
|
+
fieldName,
|
|
337
|
+
singularName: singular(fieldName),
|
|
338
|
+
columnName: foreignKey.columns[0].name,
|
|
339
|
+
otherEntity,
|
|
340
|
+
otherFieldName,
|
|
341
|
+
otherColumnName: targetForeignKey.columns[0].name,
|
|
342
|
+
ignore: require_config.isFieldIgnored(config, entity, fieldName) || require_config.isFieldIgnored(config, otherEntity, otherFieldName),
|
|
343
|
+
isLargeCollection: require_config.isLargeCollection(config, entity, fieldName),
|
|
344
|
+
isDeferredAndDeferrable,
|
|
345
|
+
derived,
|
|
346
|
+
softDeletes: require_config.softDeletesConfig(config, entity, fieldName),
|
|
347
|
+
hasJoinTableId: require_utils.joinTableHasId(r.joinTable)
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function newManyToManyEnumField(config, entity, r, enums) {
|
|
351
|
+
const { foreignKey, targetForeignKey, targetTable } = r;
|
|
352
|
+
const fieldName = manyToManyName(targetForeignKey.columns[0]);
|
|
353
|
+
const enumName = require_utils.tableToEntityName(config, targetTable);
|
|
354
|
+
return {
|
|
355
|
+
kind: "m2mEnum",
|
|
356
|
+
joinTableName: r.joinTable.name,
|
|
357
|
+
fieldName,
|
|
358
|
+
columnName: foreignKey.columns[0].name,
|
|
359
|
+
otherColumnName: targetForeignKey.columns[0].name,
|
|
360
|
+
enumName,
|
|
361
|
+
enumType: (0, ts_poet.imp)(`${enumName}@./entities.ts`),
|
|
362
|
+
enumDetailType: (0, ts_poet.imp)(`${plural(enumName)}@./entities.ts`),
|
|
363
|
+
enumDetailsType: (0, ts_poet.imp)(`${enumName}Details@./entities.ts`),
|
|
364
|
+
enumRows: enums[targetTable.name].rows,
|
|
365
|
+
ignore: require_config.isFieldIgnored(config, entity, fieldName),
|
|
366
|
+
hasJoinTableId: require_utils.joinTableHasId(r.joinTable)
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
function newPolymorphicField(config, table, entity, pr) {
|
|
370
|
+
const { fieldName, notNull } = pr;
|
|
371
|
+
const components = table.m2oRelations.filter((r) => !require_utils.isEnumTable(config, r.targetTable)).filter((r) => !isMultiColumnForeignKey(r)).filter((r) => polymorphicFieldName(config, r) === fieldName).map((r) => newPolymorphicFieldComponent(config, entity, r));
|
|
372
|
+
return {
|
|
373
|
+
kind: "poly",
|
|
374
|
+
fieldName,
|
|
375
|
+
fieldType: `${entity.name}${(0, change_case.pascalCase)(fieldName)}`,
|
|
376
|
+
notNull,
|
|
377
|
+
components,
|
|
378
|
+
hasConfigDefault: require_config.isFieldHasDefault(config, entity, fieldName)
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
function newPolymorphicFieldComponent(config, entity, r) {
|
|
382
|
+
const column = r.foreignKey.columns[0];
|
|
383
|
+
const columnName = column.name;
|
|
384
|
+
const otherEntity = makeEntity(require_utils.tableToEntityName(config, r.targetTable));
|
|
385
|
+
return {
|
|
386
|
+
columnName,
|
|
387
|
+
otherEntity,
|
|
388
|
+
otherFieldName: column.uniqueIndexes.find(isOneToOneIndex) !== void 0 ? oneToOneName(config, otherEntity, entity, r) : collectionName(config, otherEntity, entity, r).fieldName,
|
|
389
|
+
isDeferredAndDeferrable: r.foreignKey.isDeferred && r.foreignKey.isDeferrable,
|
|
390
|
+
constraintName: r.foreignKey.name,
|
|
391
|
+
notNull: false
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
function isFieldNameOverrides(maybeOverride) {
|
|
395
|
+
return maybeOverride !== null && !Array.isArray(maybeOverride) && typeof maybeOverride === "object" && Object.keys(maybeOverride).some((k) => k === "fieldName" || k === "otherFieldName");
|
|
396
|
+
}
|
|
397
|
+
/** Finds the field name for o2o side of a o2o/m2o. */
|
|
398
|
+
function oneToOneName(config, refEntity, keyEntity, r) {
|
|
399
|
+
const overrides = r.foreignKey.columns[0].commentData;
|
|
400
|
+
if (isFieldNameOverrides(overrides) && overrides.otherFieldName) return overrides.otherFieldName;
|
|
401
|
+
if (!(r instanceof pg_structure.M2ORelation ? r.targetTable : r.sourceTable).m2oRelations.find((s) => require_utils.tableToEntityName(config, s.targetTable) === keyEntity.name)) return (0, change_case.camelCase)(keyEntity.name);
|
|
402
|
+
else {
|
|
403
|
+
let fieldName = r.foreignKey.columns[0].name.replace(idSuffix, "");
|
|
404
|
+
fieldName = `${fieldName}_${keyEntity.name}`;
|
|
405
|
+
fieldName = fieldName.replace(refEntity.name.toLowerCase(), "");
|
|
406
|
+
return (0, change_case.camelCase)(fieldName);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
const idSuffix = /_id$|Id$/;
|
|
410
|
+
function referenceName(config, entity, r) {
|
|
411
|
+
const [column] = r.foreignKey.columns;
|
|
412
|
+
const overrides = column.commentData;
|
|
413
|
+
return polymorphicFieldName(config, r) ?? (isFieldNameOverrides(overrides) ? overrides.fieldName : void 0) ?? (0, change_case.camelCase)(column.name.replace(idSuffix, ""));
|
|
414
|
+
}
|
|
415
|
+
function enumFieldName(columnName) {
|
|
416
|
+
return (0, change_case.camelCase)(columnName.replace(idSuffix, ""));
|
|
417
|
+
}
|
|
418
|
+
function primitiveFieldName(columnName) {
|
|
419
|
+
return (0, change_case.camelCase)(columnName);
|
|
420
|
+
}
|
|
421
|
+
function manyToManyName(column) {
|
|
422
|
+
const overrides = column.commentData;
|
|
423
|
+
if (isFieldNameOverrides(overrides) && overrides.otherFieldName) return overrides.otherFieldName;
|
|
424
|
+
return (0, change_case.camelCase)(plural(column.name.replace(idSuffix, "")));
|
|
425
|
+
}
|
|
426
|
+
/** Returns the collection name to use on `entity` when referring to `otherEntity`s. */
|
|
427
|
+
function collectionName(config, singleEntity, collectionEntity, r) {
|
|
428
|
+
const [column] = r.foreignKey.columns;
|
|
429
|
+
const overrides = column.commentData;
|
|
430
|
+
if (isFieldNameOverrides(overrides) && overrides.otherFieldName) {
|
|
431
|
+
const fieldName = overrides.otherFieldName;
|
|
432
|
+
return {
|
|
433
|
+
fieldName,
|
|
434
|
+
singularName: singular(fieldName)
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
let singularName = collectionEntity.name;
|
|
438
|
+
const sourceTable = r.type === "m2o" ? r.sourceTable : r.targetTable;
|
|
439
|
+
const targetTable = r.type === "m2o" ? r.targetTable : r.sourceTable;
|
|
440
|
+
if (r.type !== "m2m" && sourceTable.m2oRelations.filter((r) => r.targetTable === targetTable).length > 1) singularName = `${column.name.replace(idSuffix, "")}_${singularName}`;
|
|
441
|
+
if (singularName.length > singleEntity.name.length && singularName.startsWith(singleEntity.name)) singularName = singularName.substring(singleEntity.name.length);
|
|
442
|
+
singularName = (0, change_case.camelCase)(singularName);
|
|
443
|
+
return {
|
|
444
|
+
fieldName: plural(singularName),
|
|
445
|
+
singularName
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
function failIfOverlappingFieldNames(entity) {
|
|
449
|
+
const allFields = [
|
|
450
|
+
entity.primaryKey,
|
|
451
|
+
...entity.primitives,
|
|
452
|
+
...entity.enums,
|
|
453
|
+
...entity.pgEnums,
|
|
454
|
+
...entity.manyToOnes,
|
|
455
|
+
...entity.oneToManys,
|
|
456
|
+
...entity.largeOneToManys,
|
|
457
|
+
...entity.oneToOnes,
|
|
458
|
+
...entity.manyToManys,
|
|
459
|
+
...entity.largeManyToManys,
|
|
460
|
+
...entity.manyToManyEnums,
|
|
461
|
+
...entity.polymorphics
|
|
462
|
+
];
|
|
463
|
+
Object.entries((0, joist_utils.groupBy)(allFields, (f) => f.fieldName)).forEach(([fieldName, fields]) => {
|
|
464
|
+
if (fields.length > 1) throw new Error(`In ${entity.name}, found multiple fields named '${fieldName}': ${fields.map((f) => f.kind).join(" ")}`);
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
function makeEntity(entityName) {
|
|
468
|
+
const names = entitySymbolNames(entityName);
|
|
469
|
+
return {
|
|
470
|
+
name: entityName,
|
|
471
|
+
type: entityType(entityName),
|
|
472
|
+
typeSymbol: entityTypeSymbol(entityName),
|
|
473
|
+
typeForMetadataFile: entityTypeForMetadataFile(entityName),
|
|
474
|
+
metaName: metaName(entityName),
|
|
475
|
+
metaType: metaType(entityName),
|
|
476
|
+
idType: entityTypeImport(entityName, names.idName),
|
|
477
|
+
orderType: entityTypeImport(entityName, names.orderName),
|
|
478
|
+
optsType: entityTypeImport(entityName, names.optsName),
|
|
479
|
+
configConst: (0, ts_poet.imp)(`${(0, change_case.camelCase)(entityName)}Config@./entities.ts`, { definedIn: `./codegen/${entityName}Codegen.ts` }),
|
|
480
|
+
...names
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Collapses the per-relation `otherEntity` copies down to the one primary `Entity` per name.
|
|
485
|
+
*
|
|
486
|
+
* `makeEntity` mints a fresh `Entity` for every relation's `otherEntity`, so each entity ends up with
|
|
487
|
+
* many duplicate objects floating around. Pointing them all at the single `entitiesByName[name].entity`
|
|
488
|
+
* instance means later passes (i.e. `resolveNameConflicts`) only have to update one object per name.
|
|
489
|
+
*
|
|
490
|
+
* Must run after inheritance, since STI/CTI specialization both adds and re-points `otherEntity`s.
|
|
491
|
+
*/
|
|
492
|
+
function canonicalizeOtherEntities(db) {
|
|
493
|
+
const canonical = (other) => db.entitiesByName[other.name]?.entity ?? other;
|
|
494
|
+
for (const meta of db.entities) {
|
|
495
|
+
for (const field of [
|
|
496
|
+
...meta.manyToOnes,
|
|
497
|
+
...meta.oneToManys,
|
|
498
|
+
...meta.largeOneToManys,
|
|
499
|
+
...meta.oneToOnes,
|
|
500
|
+
...meta.manyToManys,
|
|
501
|
+
...meta.largeManyToManys
|
|
502
|
+
]) field.otherEntity = canonical(field.otherEntity);
|
|
503
|
+
for (const poly of meta.polymorphics) for (const comp of poly.components) comp.otherEntity = canonical(comp.otherEntity);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Rewrites codegen'd type names that collide with another exported type name.
|
|
508
|
+
*
|
|
509
|
+
* `makeEntity` defaults each name to the conventional `${name}<Suffix>`, but if a separate entity or
|
|
510
|
+
* enum is literally named e.g. `AuthorScope` or `AuthorOrder`, our generated type of the same name
|
|
511
|
+
* would collide with it, so we fall back to `Author_Scope` / `Author_Order`.
|
|
512
|
+
*
|
|
513
|
+
* Relies on `canonicalizeOtherEntities` having run, so mutating each primary `meta.entity` also updates
|
|
514
|
+
* the `otherEntity` references that point at it (e.g. `Book.author: AuthorId` follows `Author`'s rename).
|
|
515
|
+
*/
|
|
516
|
+
function resolveNameConflicts(config, db) {
|
|
517
|
+
const reserved = new Set(db.entities.map((meta) => meta.name));
|
|
518
|
+
for (const enumData of Object.values(db.enums)) {
|
|
519
|
+
const enumName = require_utils.tableToEntityName(config, enumData.table);
|
|
520
|
+
reserved.add(enumName).add(`${enumName}Details`).add(plural(enumName));
|
|
521
|
+
}
|
|
522
|
+
for (const pgEnum of Object.values(db.pgEnums)) reserved.add(pgEnum.name);
|
|
523
|
+
for (const meta of db.entities) if (hasNameConflict(meta.name, reserved)) applyEntityNames(meta.entity, reserved);
|
|
524
|
+
}
|
|
525
|
+
/** Computes the codegen'd type names for an entity, underscoring any that `reserved` already contains. */
|
|
526
|
+
function entitySymbolNames(name, reserved) {
|
|
527
|
+
const pick = (suffix) => reserved?.has(`${name}${suffix}`) ? `${name}_${suffix}` : `${name}${suffix}`;
|
|
528
|
+
return {
|
|
529
|
+
idName: pick("Id"),
|
|
530
|
+
fieldsName: pick("Fields"),
|
|
531
|
+
optsName: pick("Opts"),
|
|
532
|
+
idsOptsName: pick("IdsOpts"),
|
|
533
|
+
filterName: pick("Filter"),
|
|
534
|
+
graphqlFilterName: pick("GraphQLFilter"),
|
|
535
|
+
orderName: pick("Order"),
|
|
536
|
+
factoryExtrasName: pick("FactoryExtras"),
|
|
537
|
+
scopeName: pick("Scope"),
|
|
538
|
+
scopesName: pick("Scopes")
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
/** Returns true if any of the entity's conventional type names is already taken. */
|
|
542
|
+
function hasNameConflict(name, reserved) {
|
|
543
|
+
return Object.values(entitySymbolNames(name)).some((conventional) => reserved.has(conventional));
|
|
544
|
+
}
|
|
545
|
+
/** Rewrites an entity's type names (and the `Import`s built from them) to their de-conflicted form. */
|
|
546
|
+
function applyEntityNames(entity, reserved) {
|
|
547
|
+
const names = entitySymbolNames(entity.name, reserved);
|
|
548
|
+
Object.assign(entity, names);
|
|
549
|
+
entity.idType = entityTypeImport(entity.name, names.idName);
|
|
550
|
+
entity.orderType = entityTypeImport(entity.name, names.orderName);
|
|
551
|
+
entity.optsType = entityTypeImport(entity.name, names.optsName);
|
|
552
|
+
}
|
|
553
|
+
function entityTypeImport(entityName, symbolName) {
|
|
554
|
+
return (0, ts_poet.imp)(`t:${symbolName}@./entities.ts`, { definedIn: `./codegen/${entityName}Codegen.ts` });
|
|
555
|
+
}
|
|
556
|
+
function metaName(entityName) {
|
|
557
|
+
return `${(0, change_case.camelCase)(entityName)}Meta`;
|
|
558
|
+
}
|
|
559
|
+
function metaType(entityName) {
|
|
560
|
+
return (0, ts_poet.imp)(`${metaName(entityName)}@./entities.ts`);
|
|
561
|
+
}
|
|
562
|
+
function entityType(entityName) {
|
|
563
|
+
return (0, ts_poet.imp)(`t:${entityName}@./entities.ts`);
|
|
564
|
+
}
|
|
565
|
+
function entityTypeSymbol(entityName) {
|
|
566
|
+
return (0, ts_poet.imp)(`${entityName}@./entities.ts`);
|
|
567
|
+
}
|
|
568
|
+
function entityTypeForMetadataFile(entityName) {
|
|
569
|
+
return (0, ts_poet.imp)(`${entityName}@./${entityName}.ts`);
|
|
570
|
+
}
|
|
571
|
+
function mapType(config, tableName, columnName, dbColumnType) {
|
|
572
|
+
return require_utils.mapSimpleDbTypeToTypescriptType(config, dbColumnType);
|
|
573
|
+
}
|
|
574
|
+
function isEnumArray(c) {
|
|
575
|
+
return c.arrayDimension === 1 && !!c.comment && c.comment.startsWith("enum=");
|
|
576
|
+
}
|
|
577
|
+
function isArray(c) {
|
|
578
|
+
return c.arrayDimension === 1;
|
|
579
|
+
}
|
|
580
|
+
function isPgEnum(c) {
|
|
581
|
+
return c.type instanceof pg_structure.EnumType;
|
|
582
|
+
}
|
|
583
|
+
function superstructType(s) {
|
|
584
|
+
const [symbol, ...path] = s.split("@");
|
|
585
|
+
return ts_poet.Import.from(`${(0, change_case.pascalCase)(symbol)}@${path.join("@")}`);
|
|
586
|
+
}
|
|
587
|
+
function zodSchemaType(s) {
|
|
588
|
+
const schema = ts_poet.Import.from(s);
|
|
589
|
+
return ts_poet.code`${require_symbols.Zod}.input<typeof ${schema}>`;
|
|
590
|
+
}
|
|
591
|
+
function userFieldTypeType(s) {
|
|
592
|
+
return ts_poet.Import.from(`t:${s}`);
|
|
593
|
+
}
|
|
594
|
+
function serdeType(s) {
|
|
595
|
+
return ts_poet.Import.from(s);
|
|
596
|
+
}
|
|
597
|
+
//#endregion
|
|
598
|
+
exports.EntityDbMetadata = EntityDbMetadata;
|
|
599
|
+
exports.canonicalizeOtherEntities = canonicalizeOtherEntities;
|
|
600
|
+
exports.collectionName = collectionName;
|
|
601
|
+
exports.failIfOverlappingFieldNames = failIfOverlappingFieldNames;
|
|
602
|
+
exports.makeEntity = makeEntity;
|
|
603
|
+
exports.manyToManyName = manyToManyName;
|
|
604
|
+
exports.oneToOneName = oneToOneName;
|
|
605
|
+
exports.referenceName = referenceName;
|
|
606
|
+
exports.resolveNameConflicts = resolveNameConflicts;
|
|
607
|
+
|
|
608
|
+
//# sourceMappingURL=EntityDbMetadata.cjs.map
|