joist-codegen 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/EntityDbMetadata.cjs +672 -0
- package/build/EntityDbMetadata.cjs.map +1 -0
- package/build/EntityDbMetadata.d.cts +301 -0
- package/build/EntityDbMetadata.d.cts.map +1 -0
- package/build/EntityDbMetadata.d.mts +301 -0
- package/build/EntityDbMetadata.d.mts.map +1 -0
- package/build/EntityDbMetadata.js +550 -662
- 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 +1011 -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 +794 -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 +315 -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 +156 -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 +109 -127
- package/build/index.js.map +1 -1
- package/build/inheritance.cjs +258 -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 +238 -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/pgMetadata.cjs +332 -0
- package/build/pgMetadata.cjs.map +1 -0
- package/build/pgMetadata.d.cts +128 -0
- package/build/pgMetadata.d.cts.map +1 -0
- package/build/pgMetadata.d.mts +128 -0
- package/build/pgMetadata.d.mts.map +1 -0
- package/build/pgMetadata.js +320 -0
- package/build/pgMetadata.js.map +1 -0
- 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 +175 -0
- package/build/utils.cjs.map +1 -0
- package/build/utils.d.cts +36 -0
- package/build/utils.d.cts.map +1 -0
- package/build/utils.d.mts +36 -0
- package/build/utils.d.mts.map +1 -0
- package/build/utils.js +113 -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 +47 -18
- package/skills/joist-docs/SKILL.md +142 -0
- package/skills/joist-em-basics/SKILL.md +114 -0
- package/skills/joist-em-execute/SKILL.md +35 -0
- package/skills/joist-em-find/SKILL.md +27 -0
- package/skills/joist-em-query/SKILL.md +32 -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,320 @@
|
|
|
1
|
+
import pluralize from "pluralize";
|
|
2
|
+
//#region src/pgMetadata.ts
|
|
3
|
+
/** The small part of PostgreSQL's catalog model used by Joist codegen. */
|
|
4
|
+
var Items = class extends Array {
|
|
5
|
+
byName;
|
|
6
|
+
/** Looks up a column by name without scanning the table on every call. */
|
|
7
|
+
get(name) {
|
|
8
|
+
this.byName ??= new Map(this.map((item) => [item.name, item]));
|
|
9
|
+
const item = this.byName.get(name);
|
|
10
|
+
if (!item) throw new Error(`No item named ${name}`);
|
|
11
|
+
return item;
|
|
12
|
+
}
|
|
13
|
+
/** Keep the name index current if more catalog rows arrive after a lookup. */
|
|
14
|
+
push(...items) {
|
|
15
|
+
const length = super.push(...items);
|
|
16
|
+
if (this.byName) for (const item of items) this.byName.set(item.name, item);
|
|
17
|
+
return length;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var EnumType = class {
|
|
21
|
+
name;
|
|
22
|
+
values;
|
|
23
|
+
shortName;
|
|
24
|
+
constructor(name, values) {
|
|
25
|
+
this.name = name;
|
|
26
|
+
this.values = values;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var Column = class {
|
|
30
|
+
name;
|
|
31
|
+
type;
|
|
32
|
+
notNull;
|
|
33
|
+
defaultValue;
|
|
34
|
+
isGenerated;
|
|
35
|
+
arrayDimension;
|
|
36
|
+
comment;
|
|
37
|
+
foreignKeys = [];
|
|
38
|
+
uniqueIndexes = [];
|
|
39
|
+
isPrimaryKey = false;
|
|
40
|
+
constructor(name, type, notNull, defaultValue, isGenerated, arrayDimension, comment) {
|
|
41
|
+
this.name = name;
|
|
42
|
+
this.type = type;
|
|
43
|
+
this.notNull = notNull;
|
|
44
|
+
this.defaultValue = defaultValue;
|
|
45
|
+
this.isGenerated = isGenerated;
|
|
46
|
+
this.arrayDimension = arrayDimension;
|
|
47
|
+
this.comment = comment;
|
|
48
|
+
}
|
|
49
|
+
get isForeignKey() {
|
|
50
|
+
return this.foreignKeys.length > 0;
|
|
51
|
+
}
|
|
52
|
+
get default() {
|
|
53
|
+
return this.defaultValue?.replace(/^('.*?')::.+$/, "$1") ?? null;
|
|
54
|
+
}
|
|
55
|
+
get commentData() {
|
|
56
|
+
const data = this.comment?.match(/\[pg-structure\]([\s\S]*?)\[\/pg-structure\]/)?.[1];
|
|
57
|
+
return data ? JSON.parse(data) : void 0;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
var Index = class {
|
|
61
|
+
name;
|
|
62
|
+
columns;
|
|
63
|
+
isUnique;
|
|
64
|
+
isPartial;
|
|
65
|
+
constructor(name, columns, isUnique, isPartial) {
|
|
66
|
+
this.name = name;
|
|
67
|
+
this.columns = columns;
|
|
68
|
+
this.isUnique = isUnique;
|
|
69
|
+
this.isPartial = isPartial;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var ForeignKey = class {
|
|
73
|
+
name;
|
|
74
|
+
table;
|
|
75
|
+
referencedTable;
|
|
76
|
+
columns;
|
|
77
|
+
isDeferred;
|
|
78
|
+
isDeferrable;
|
|
79
|
+
onDelete;
|
|
80
|
+
constructor(name, table, referencedTable, columns, isDeferred, isDeferrable, onDelete) {
|
|
81
|
+
this.name = name;
|
|
82
|
+
this.table = table;
|
|
83
|
+
this.referencedTable = referencedTable;
|
|
84
|
+
this.columns = columns;
|
|
85
|
+
this.isDeferred = isDeferred;
|
|
86
|
+
this.isDeferrable = isDeferrable;
|
|
87
|
+
this.onDelete = onDelete;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
var M2ORelation = class {
|
|
91
|
+
foreignKey;
|
|
92
|
+
type = "m2o";
|
|
93
|
+
constructor(foreignKey) {
|
|
94
|
+
this.foreignKey = foreignKey;
|
|
95
|
+
}
|
|
96
|
+
get sourceTable() {
|
|
97
|
+
return this.foreignKey.table;
|
|
98
|
+
}
|
|
99
|
+
get targetTable() {
|
|
100
|
+
return this.foreignKey.referencedTable;
|
|
101
|
+
}
|
|
102
|
+
/** Uses the old short relation name so M2O metadata keeps its factory evaluation order. */
|
|
103
|
+
get name() {
|
|
104
|
+
const { foreignKey, sourceTable, targetTable } = this;
|
|
105
|
+
const hasOtherIncomingFKs = sourceTable.foreignKeys.some((fk) => fk !== foreignKey && fk.referencedTable === targetTable);
|
|
106
|
+
return pluralize.singular(hasOtherIncomingFKs ? foreignKey.columns[0].name.replace(/_id$/, "") : targetTable.name);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
var O2MRelation = class {
|
|
110
|
+
foreignKey;
|
|
111
|
+
type = "o2m";
|
|
112
|
+
constructor(foreignKey) {
|
|
113
|
+
this.foreignKey = foreignKey;
|
|
114
|
+
}
|
|
115
|
+
get sourceTable() {
|
|
116
|
+
return this.foreignKey.referencedTable;
|
|
117
|
+
}
|
|
118
|
+
get targetTable() {
|
|
119
|
+
return this.foreignKey.table;
|
|
120
|
+
}
|
|
121
|
+
/** Keeps inverse relations in the same short-name order as pg-structure. */
|
|
122
|
+
get name() {
|
|
123
|
+
const { foreignKey, sourceTable, targetTable } = this;
|
|
124
|
+
if (!targetTable.foreignKeys.some((fk) => fk !== foreignKey && fk.referencedTable === sourceTable)) return pluralize.plural(targetTable.name);
|
|
125
|
+
const columnName = foreignKey.columns[0].name.replace(/_id$/, "");
|
|
126
|
+
const sourceName = pluralize.singular(sourceTable.name);
|
|
127
|
+
const adjective = columnName.endsWith(`_${sourceName}`) ? columnName.slice(0, -sourceName.length - 1) : "";
|
|
128
|
+
if (sourceTable === targetTable) return pluralize.plural(adjective || targetTable.name);
|
|
129
|
+
return pluralize.plural(`${adjective || sourceTable.name}_${targetTable.name}`);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
var M2MRelation = class {
|
|
133
|
+
foreignKey;
|
|
134
|
+
targetForeignKey;
|
|
135
|
+
type = "m2m";
|
|
136
|
+
constructor(foreignKey, targetForeignKey) {
|
|
137
|
+
this.foreignKey = foreignKey;
|
|
138
|
+
this.targetForeignKey = targetForeignKey;
|
|
139
|
+
}
|
|
140
|
+
get sourceTable() {
|
|
141
|
+
return this.foreignKey.referencedTable;
|
|
142
|
+
}
|
|
143
|
+
get targetTable() {
|
|
144
|
+
return this.targetForeignKey.referencedTable;
|
|
145
|
+
}
|
|
146
|
+
get joinTable() {
|
|
147
|
+
return this.foreignKey.table;
|
|
148
|
+
}
|
|
149
|
+
/** Adds the join-table qualifier when more than one join path reaches the same target. */
|
|
150
|
+
get name() {
|
|
151
|
+
const { sourceTable, joinTable, targetTable } = this;
|
|
152
|
+
const joinTables = new Set(sourceTable.foreignKeysToThis.filter((fk) => fk.table.foreignKeys.some((other) => other !== fk && other.referencedTable === targetTable)).map((fk) => fk.table));
|
|
153
|
+
const targetName = pluralize.plural(targetTable.name);
|
|
154
|
+
if (joinTables.size < 2) return targetName;
|
|
155
|
+
return `${joinTable.name.replace(sourceTable.name, "").replace(targetTable.name, "").replace(/^_+|_+$/g, "")}_${targetName}`;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
var Table = class {
|
|
159
|
+
name;
|
|
160
|
+
schema;
|
|
161
|
+
columns = new Items();
|
|
162
|
+
indexes = new Items();
|
|
163
|
+
foreignKeys = [];
|
|
164
|
+
foreignKeysToThis = [];
|
|
165
|
+
uniqueConstraints = [];
|
|
166
|
+
primaryKey;
|
|
167
|
+
constructor(name, schema) {
|
|
168
|
+
this.name = name;
|
|
169
|
+
this.schema = schema;
|
|
170
|
+
}
|
|
171
|
+
get m2oRelations() {
|
|
172
|
+
return this.foreignKeys.map((fk) => new M2ORelation(fk)).sort((a, b) => compareNames(a.name, b.name));
|
|
173
|
+
}
|
|
174
|
+
get o2mRelations() {
|
|
175
|
+
return this.foreignKeysToThis.map((fk) => new O2MRelation(fk)).sort((a, b) => compareNames(a.name.toUpperCase(), b.name.toUpperCase()));
|
|
176
|
+
}
|
|
177
|
+
get m2mRelations() {
|
|
178
|
+
return this.foreignKeysToThis.flatMap((fk) => fk.table.foreignKeys.filter((other) => other !== fk).map((other) => new M2MRelation(fk, other))).sort((a, b) => compareNames(a.name.toUpperCase(), b.name.toUpperCase()));
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* Reads only the PostgreSQL catalog data used by codegen.
|
|
183
|
+
*
|
|
184
|
+
* Load tables and columns before constraints so each foreign key can link the same Table and Column
|
|
185
|
+
* objects used by entity fields. For example, books.author_id and authors.id are joined through
|
|
186
|
+
* the foreign key, while a trigger calling cyanaudit in another schema is irrelevant to codegen.
|
|
187
|
+
*/
|
|
188
|
+
async function loadPgMetadata(client) {
|
|
189
|
+
const tables = new Items();
|
|
190
|
+
const byOid = /* @__PURE__ */ new Map();
|
|
191
|
+
const columns = /* @__PURE__ */ new Map();
|
|
192
|
+
const tableRows = await client.query(`
|
|
193
|
+
SELECT c.oid, c.relname AS name, n.nspname AS schema
|
|
194
|
+
FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace
|
|
195
|
+
WHERE c.relkind IN ('r', 'p') AND n.nspname <> 'information_schema'
|
|
196
|
+
AND n.nspname NOT LIKE 'pg_%' AND NOT pg_is_other_temp_schema(n.oid)
|
|
197
|
+
ORDER BY n.nspname, c.relname
|
|
198
|
+
`);
|
|
199
|
+
for (const row of tableRows.rows) {
|
|
200
|
+
const table = new Table(row.name, { name: row.schema });
|
|
201
|
+
tables.push(table);
|
|
202
|
+
byOid.set(row.oid, table);
|
|
203
|
+
columns.set(row.oid, /* @__PURE__ */ new Map());
|
|
204
|
+
}
|
|
205
|
+
const enumRows = await client.query(`
|
|
206
|
+
SELECT t.oid, t.typname AS name, e.enumlabel AS value
|
|
207
|
+
FROM pg_type t JOIN pg_enum e ON e.enumtypid = t.oid
|
|
208
|
+
JOIN pg_namespace n ON n.oid = t.typnamespace
|
|
209
|
+
WHERE n.nspname <> 'information_schema' AND n.nspname NOT LIKE 'pg_%'
|
|
210
|
+
ORDER BY t.oid, e.enumsortorder
|
|
211
|
+
`);
|
|
212
|
+
const enums = /* @__PURE__ */ new Map();
|
|
213
|
+
for (const row of enumRows.rows) {
|
|
214
|
+
if (!enums.has(row.oid)) enums.set(row.oid, new EnumType(row.name, []));
|
|
215
|
+
enums.get(row.oid).values.push(row.value);
|
|
216
|
+
}
|
|
217
|
+
const columnRows = await client.query(`
|
|
218
|
+
SELECT a.attrelid AS "tableOid", a.attnum AS position, a.attname AS name,
|
|
219
|
+
COALESCE(NULLIF(t.typelem, 0), t.oid) AS "typeOid",
|
|
220
|
+
base.typname AS "typeName", a.attnotnull AS "notNull",
|
|
221
|
+
pg_get_expr(d.adbin, d.adrelid) AS "defaultValue", a.attgenerated AS generated,
|
|
222
|
+
a.attndims AS "arrayDimension", col_description(a.attrelid, a.attnum) AS comment
|
|
223
|
+
FROM pg_attribute a JOIN pg_type t ON t.oid = a.atttypid
|
|
224
|
+
JOIN pg_type base ON base.oid = COALESCE(NULLIF(t.typelem, 0), t.oid)
|
|
225
|
+
LEFT JOIN pg_attrdef d ON d.adrelid = a.attrelid AND d.adnum = a.attnum
|
|
226
|
+
WHERE a.attrelid = ANY($1::oid[]) AND a.attnum > 0 AND NOT a.attisdropped
|
|
227
|
+
ORDER BY a.attrelid, a.attnum
|
|
228
|
+
`, [Array.from(byOid.keys())]);
|
|
229
|
+
for (const row of columnRows.rows) {
|
|
230
|
+
const type = enums.get(row.typeOid) ?? sqlType(row.typeName);
|
|
231
|
+
const column = new Column(row.name, type, row.notNull, row.defaultValue, row.generated !== "", row.arrayDimension, row.comment);
|
|
232
|
+
byOid.get(row.tableOid).columns.push(column);
|
|
233
|
+
columns.get(row.tableOid).set(row.position, column);
|
|
234
|
+
}
|
|
235
|
+
const indexRows = await client.query(`
|
|
236
|
+
SELECT i.indrelid AS "tableOid", i.indexrelid AS "indexOid", c.relname AS name,
|
|
237
|
+
i.indkey::int2[] AS positions, i.indisunique AS unique, i.indpred IS NOT NULL AS partial
|
|
238
|
+
FROM pg_index i JOIN pg_class c ON c.oid = i.indexrelid
|
|
239
|
+
WHERE i.indrelid = ANY($1::oid[])
|
|
240
|
+
`, [Array.from(byOid.keys())]);
|
|
241
|
+
const indexes = /* @__PURE__ */ new Map();
|
|
242
|
+
for (const row of indexRows.rows) {
|
|
243
|
+
const table = byOid.get(row.tableOid);
|
|
244
|
+
const index = new Index(row.name, row.positions.flatMap((pos) => columns.get(row.tableOid).get(pos) ?? []), row.unique, row.partial);
|
|
245
|
+
table.indexes.push(index);
|
|
246
|
+
indexes.set(row.indexOid, index);
|
|
247
|
+
if (row.unique) for (const column of index.columns) column.uniqueIndexes.push(index);
|
|
248
|
+
}
|
|
249
|
+
const constraintRows = await client.query(`
|
|
250
|
+
SELECT conrelid AS "tableOid", confrelid AS "targetOid", conindid AS "indexOid",
|
|
251
|
+
conname AS name, contype AS kind, conkey AS positions,
|
|
252
|
+
condeferred AS deferred, condeferrable AS deferrable, confdeltype AS "onDelete"
|
|
253
|
+
FROM pg_constraint WHERE conrelid = ANY($1::oid[]) AND contype IN ('p', 'u', 'f')
|
|
254
|
+
ORDER BY conrelid, conname
|
|
255
|
+
`, [Array.from(byOid.keys())]);
|
|
256
|
+
for (const row of constraintRows.rows) {
|
|
257
|
+
const table = byOid.get(row.tableOid);
|
|
258
|
+
const keys = (row.positions ?? []).map((pos) => columns.get(row.tableOid).get(pos));
|
|
259
|
+
if (row.kind === "p") {
|
|
260
|
+
table.primaryKey = { columns: keys };
|
|
261
|
+
for (const column of keys) column.isPrimaryKey = true;
|
|
262
|
+
} else if (row.kind === "u") table.uniqueConstraints.push({
|
|
263
|
+
columns: keys,
|
|
264
|
+
index: indexes.get(row.indexOid)
|
|
265
|
+
});
|
|
266
|
+
else {
|
|
267
|
+
const target = byOid.get(row.targetOid);
|
|
268
|
+
if (!target) continue;
|
|
269
|
+
const fk = new ForeignKey(row.name, table, target, keys, row.deferred, row.deferrable, deleteAction(row.onDelete));
|
|
270
|
+
table.foreignKeys.push(fk);
|
|
271
|
+
target.foreignKeysToThis.push(fk);
|
|
272
|
+
for (const column of keys) column.foreignKeys.push(fk);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return {
|
|
276
|
+
tables,
|
|
277
|
+
types: Array.from(enums.values())
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
/** Matches the type names codegen expects from PostgreSQL's builtin aliases. */
|
|
281
|
+
function sqlType(name) {
|
|
282
|
+
switch (name) {
|
|
283
|
+
case "int2": return { name: "smallint" };
|
|
284
|
+
case "int4": return {
|
|
285
|
+
name: "integer",
|
|
286
|
+
shortName: "int"
|
|
287
|
+
};
|
|
288
|
+
case "int8": return { name: "bigint" };
|
|
289
|
+
case "bool": return { name: "boolean" };
|
|
290
|
+
case "float4": return { name: "real" };
|
|
291
|
+
case "float8": return { name: "double precision" };
|
|
292
|
+
case "varchar": return { name: "character varying" };
|
|
293
|
+
case "timestamptz": return { name: "timestamp with time zone" };
|
|
294
|
+
case "timestamp": return { name: "timestamp without time zone" };
|
|
295
|
+
case "time": return { name: "time without time zone" };
|
|
296
|
+
default: return {
|
|
297
|
+
name,
|
|
298
|
+
shortName: name
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
/** Decodes the pg_constraint foreign-key delete action. */
|
|
303
|
+
function deleteAction(code) {
|
|
304
|
+
switch (code) {
|
|
305
|
+
case "a": return "NO ACTION";
|
|
306
|
+
case "r": return "RESTRICT";
|
|
307
|
+
case "c": return "CASCADE";
|
|
308
|
+
case "n": return "SET NULL";
|
|
309
|
+
case "d": return "SET DEFAULT";
|
|
310
|
+
default: throw new Error(`Unknown PostgreSQL delete action: ${code}`);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/** Compares PostgreSQL relation names by code point, independent of the host locale. */
|
|
314
|
+
function compareNames(a, b) {
|
|
315
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
316
|
+
}
|
|
317
|
+
//#endregion
|
|
318
|
+
export { Column, EnumType, ForeignKey, Index, Items, M2MRelation, M2ORelation, O2MRelation, Table, loadPgMetadata };
|
|
319
|
+
|
|
320
|
+
//# sourceMappingURL=pgMetadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pgMetadata.js","names":[],"sources":["../src/pgMetadata.ts"],"sourcesContent":["import type { Client } from \"pg\";\nimport pluralize from \"pluralize\";\n\n/** The small part of PostgreSQL's catalog model used by Joist codegen. */\nexport class Items<T extends { name: string }> extends Array<T> {\n private byName?: Map<string, T>;\n\n /** Looks up a column by name without scanning the table on every call. */\n get(name: string): T {\n // Catalog rows are appended before codegen reads them. Build the index on first lookup\n // so derived arrays from filter/map can still be indexed without special handling.\n this.byName ??= new Map(this.map((item) => [item.name, item]));\n const item = this.byName.get(name);\n if (!item) throw new Error(`No item named ${name}`);\n return item;\n }\n\n /** Keep the name index current if more catalog rows arrive after a lookup. */\n push(...items: T[]): number {\n const length = super.push(...items);\n if (this.byName) for (const item of items) this.byName.set(item.name, item);\n return length;\n }\n}\n\nexport type Action = \"NO ACTION\" | \"RESTRICT\" | \"CASCADE\" | \"SET NULL\" | \"SET DEFAULT\";\nexport type JSONData = string | number | boolean | null | JSONData[] | { [key: string]: JSONData };\n\nexport class EnumType {\n readonly shortName?: string;\n constructor(\n public name: string,\n public values: string[],\n ) {}\n}\n\nexport class Column {\n readonly foreignKeys: ForeignKey[] = [];\n readonly uniqueIndexes: Index[] = [];\n isPrimaryKey = false;\n\n constructor(\n public name: string,\n public type: { name: string; shortName?: string } | EnumType,\n public notNull: boolean,\n public defaultValue: string | null,\n public isGenerated: boolean,\n public arrayDimension: number,\n public comment: string | null,\n ) {}\n\n get isForeignKey(): boolean {\n return this.foreignKeys.length > 0;\n }\n\n get default(): string | null {\n return this.defaultValue?.replace(/^('.*?')::.+$/, \"$1\") ?? null;\n }\n\n get commentData(): JSONData | undefined {\n const data = this.comment?.match(/\\[pg-structure\\]([\\s\\S]*?)\\[\\/pg-structure\\]/)?.[1];\n return data ? (JSON.parse(data) as JSONData) : undefined;\n }\n}\n\nexport class Index {\n constructor(\n public name: string,\n public columns: Column[],\n public isUnique: boolean,\n public isPartial: boolean,\n ) {}\n}\n\nexport class ForeignKey {\n constructor(\n public name: string,\n public table: Table,\n public referencedTable: Table,\n public columns: Column[],\n public isDeferred: boolean,\n public isDeferrable: boolean,\n public onDelete: Action,\n ) {}\n}\n\nexport class M2ORelation {\n readonly type = \"m2o\";\n\n constructor(public foreignKey: ForeignKey) {}\n\n get sourceTable(): Table {\n return this.foreignKey.table;\n }\n\n get targetTable(): Table {\n return this.foreignKey.referencedTable;\n }\n\n /** Uses the old short relation name so M2O metadata keeps its factory evaluation order. */\n get name(): string {\n const { foreignKey, sourceTable, targetTable } = this;\n // I.e. books.author_id and books.reviewer_id both target authors, so sort them as author and reviewer.\n const hasOtherIncomingFKs = sourceTable.foreignKeys.some(\n (fk) => fk !== foreignKey && fk.referencedTable === targetTable,\n );\n\n return pluralize.singular(hasOtherIncomingFKs ? foreignKey.columns[0].name.replace(/_id$/, \"\") : targetTable.name);\n }\n}\n\nexport class O2MRelation {\n readonly type = \"o2m\";\n\n constructor(public foreignKey: ForeignKey) {}\n\n get sourceTable(): Table {\n return this.foreignKey.referencedTable;\n }\n\n get targetTable(): Table {\n return this.foreignKey.table;\n }\n\n /** Keeps inverse relations in the same short-name order as pg-structure. */\n get name(): string {\n const { foreignKey, sourceTable, targetTable } = this;\n // I.e. books.author_id and books.reviewer_id are both incoming FKs to authors.\n const hasOtherIncomingFKs = targetTable.foreignKeys.some(\n (fk) => fk !== foreignKey && fk.referencedTable === sourceTable,\n );\n if (!hasOtherIncomingFKs) return pluralize.plural(targetTable.name);\n\n const columnName = foreignKey.columns[0].name.replace(/_id$/, \"\");\n const sourceName = pluralize.singular(sourceTable.name);\n const adjective = columnName.endsWith(`_${sourceName}`) ? columnName.slice(0, -sourceName.length - 1) : \"\";\n\n if (sourceTable === targetTable) return pluralize.plural(adjective || targetTable.name);\n return pluralize.plural(`${adjective || sourceTable.name}_${targetTable.name}`);\n }\n}\n\nexport class M2MRelation {\n readonly type = \"m2m\";\n\n constructor(\n public foreignKey: ForeignKey,\n public targetForeignKey: ForeignKey,\n ) {}\n\n get sourceTable(): Table {\n return this.foreignKey.referencedTable;\n }\n\n get targetTable(): Table {\n return this.targetForeignKey.referencedTable;\n }\n\n get joinTable(): Table {\n return this.foreignKey.table;\n }\n\n /** Adds the join-table qualifier when more than one join path reaches the same target. */\n get name(): string {\n const { sourceTable, joinTable, targetTable } = this;\n const joinTables = new Set(\n sourceTable.foreignKeysToThis\n .filter((fk) => fk.table.foreignKeys.some((other) => other !== fk && other.referencedTable === targetTable))\n .map((fk) => fk.table),\n );\n\n const targetName = pluralize.plural(targetTable.name);\n if (joinTables.size < 2) return targetName;\n\n const qualifier = joinTable.name\n .replace(sourceTable.name, \"\")\n .replace(targetTable.name, \"\")\n .replace(/^_+|_+$/g, \"\");\n return `${qualifier}_${targetName}`;\n }\n}\n\nexport class Table {\n readonly columns = new Items<Column>();\n readonly indexes = new Items<Index>();\n readonly foreignKeys: ForeignKey[] = [];\n readonly foreignKeysToThis: ForeignKey[] = [];\n readonly uniqueConstraints: { columns: Column[]; index: Index }[] = [];\n primaryKey?: { columns: Column[] };\n\n constructor(\n public name: string,\n public schema: { name: string },\n ) {}\n\n get m2oRelations(): M2ORelation[] {\n return this.foreignKeys.map((fk) => new M2ORelation(fk)).sort((a, b) => compareNames(a.name, b.name));\n }\n\n get o2mRelations(): O2MRelation[] {\n return this.foreignKeysToThis\n .map((fk) => new O2MRelation(fk))\n .sort((a, b) => compareNames(a.name.toUpperCase(), b.name.toUpperCase()));\n }\n\n get m2mRelations(): M2MRelation[] {\n return this.foreignKeysToThis\n .flatMap((fk) => fk.table.foreignKeys.filter((other) => other !== fk).map((other) => new M2MRelation(fk, other)))\n .sort((a, b) => compareNames(a.name.toUpperCase(), b.name.toUpperCase()));\n }\n}\n\nexport type Db = { tables: Items<Table>; types: EnumType[] };\n\n/**\n * Reads only the PostgreSQL catalog data used by codegen.\n *\n * Load tables and columns before constraints so each foreign key can link the same Table and Column\n * objects used by entity fields. For example, books.author_id and authors.id are joined through\n * the foreign key, while a trigger calling cyanaudit in another schema is irrelevant to codegen.\n */\nexport async function loadPgMetadata(client: Client): Promise<Db> {\n const tables = new Items<Table>();\n const byOid = new Map<number, Table>();\n const columns = new Map<number, Map<number, Column>>();\n\n const tableRows = await client.query<{ oid: number; name: string; schema: string }>(`\n SELECT c.oid, c.relname AS name, n.nspname AS schema\n FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace\n WHERE c.relkind IN ('r', 'p') AND n.nspname <> 'information_schema'\n AND n.nspname NOT LIKE 'pg_%' AND NOT pg_is_other_temp_schema(n.oid)\n ORDER BY n.nspname, c.relname\n `);\n for (const row of tableRows.rows) {\n const table = new Table(row.name, { name: row.schema });\n tables.push(table);\n byOid.set(row.oid, table);\n columns.set(row.oid, new Map());\n }\n\n const enumRows = await client.query<{ oid: number; name: string; value: string }>(`\n SELECT t.oid, t.typname AS name, e.enumlabel AS value\n FROM pg_type t JOIN pg_enum e ON e.enumtypid = t.oid\n JOIN pg_namespace n ON n.oid = t.typnamespace\n WHERE n.nspname <> 'information_schema' AND n.nspname NOT LIKE 'pg_%'\n ORDER BY t.oid, e.enumsortorder\n `);\n const enums = new Map<number, EnumType>();\n for (const row of enumRows.rows) {\n if (!enums.has(row.oid)) enums.set(row.oid, new EnumType(row.name, []));\n enums.get(row.oid)!.values.push(row.value);\n }\n\n const columnRows = await client.query<{\n tableOid: number;\n position: number;\n name: string;\n typeOid: number;\n typeName: string;\n notNull: boolean;\n defaultValue: string | null;\n generated: string;\n arrayDimension: number;\n comment: string | null;\n }>(\n `\n SELECT a.attrelid AS \"tableOid\", a.attnum AS position, a.attname AS name,\n COALESCE(NULLIF(t.typelem, 0), t.oid) AS \"typeOid\",\n base.typname AS \"typeName\", a.attnotnull AS \"notNull\",\n pg_get_expr(d.adbin, d.adrelid) AS \"defaultValue\", a.attgenerated AS generated,\n a.attndims AS \"arrayDimension\", col_description(a.attrelid, a.attnum) AS comment\n FROM pg_attribute a JOIN pg_type t ON t.oid = a.atttypid\n JOIN pg_type base ON base.oid = COALESCE(NULLIF(t.typelem, 0), t.oid)\n LEFT JOIN pg_attrdef d ON d.adrelid = a.attrelid AND d.adnum = a.attnum\n WHERE a.attrelid = ANY($1::oid[]) AND a.attnum > 0 AND NOT a.attisdropped\n ORDER BY a.attrelid, a.attnum\n `,\n [Array.from(byOid.keys())],\n );\n for (const row of columnRows.rows) {\n const type = enums.get(row.typeOid) ?? sqlType(row.typeName);\n const column = new Column(\n row.name,\n type,\n row.notNull,\n row.defaultValue,\n row.generated !== \"\",\n row.arrayDimension,\n row.comment,\n );\n byOid.get(row.tableOid)!.columns.push(column);\n columns.get(row.tableOid)!.set(row.position, column);\n }\n\n const indexRows = await client.query<{\n tableOid: number;\n indexOid: number;\n name: string;\n positions: number[];\n unique: boolean;\n partial: boolean;\n }>(\n `\n SELECT i.indrelid AS \"tableOid\", i.indexrelid AS \"indexOid\", c.relname AS name,\n i.indkey::int2[] AS positions, i.indisunique AS unique, i.indpred IS NOT NULL AS partial\n FROM pg_index i JOIN pg_class c ON c.oid = i.indexrelid\n WHERE i.indrelid = ANY($1::oid[])\n `,\n [Array.from(byOid.keys())],\n );\n const indexes = new Map<number, Index>();\n for (const row of indexRows.rows) {\n const table = byOid.get(row.tableOid)!;\n const index = new Index(\n row.name,\n row.positions.flatMap((pos) => columns.get(row.tableOid)!.get(pos) ?? []),\n row.unique,\n row.partial,\n );\n table.indexes.push(index);\n indexes.set(row.indexOid, index);\n if (row.unique) for (const column of index.columns) column.uniqueIndexes.push(index);\n }\n\n const constraintRows = await client.query<{\n tableOid: number;\n targetOid: number;\n indexOid: number;\n name: string;\n kind: string;\n positions: number[] | null;\n deferred: boolean;\n deferrable: boolean;\n onDelete: string;\n }>(\n `\n SELECT conrelid AS \"tableOid\", confrelid AS \"targetOid\", conindid AS \"indexOid\",\n conname AS name, contype AS kind, conkey AS positions,\n condeferred AS deferred, condeferrable AS deferrable, confdeltype AS \"onDelete\"\n FROM pg_constraint WHERE conrelid = ANY($1::oid[]) AND contype IN ('p', 'u', 'f')\n ORDER BY conrelid, conname\n `,\n [Array.from(byOid.keys())],\n );\n for (const row of constraintRows.rows) {\n const table = byOid.get(row.tableOid)!;\n const keys = (row.positions ?? []).map((pos) => columns.get(row.tableOid)!.get(pos)!);\n if (row.kind === \"p\") {\n table.primaryKey = { columns: keys };\n for (const column of keys) column.isPrimaryKey = true;\n } else if (row.kind === \"u\") {\n table.uniqueConstraints.push({ columns: keys, index: indexes.get(row.indexOid)! });\n } else {\n const target = byOid.get(row.targetOid);\n if (!target) continue;\n const fk = new ForeignKey(\n row.name,\n table,\n target,\n keys,\n row.deferred,\n row.deferrable,\n deleteAction(row.onDelete),\n );\n table.foreignKeys.push(fk);\n target.foreignKeysToThis.push(fk);\n for (const column of keys) column.foreignKeys.push(fk);\n }\n }\n\n return { tables, types: Array.from(enums.values()) };\n}\n\n/** Matches the type names codegen expects from PostgreSQL's builtin aliases. */\nfunction sqlType(name: string): { name: string; shortName?: string } {\n switch (name) {\n case \"int2\":\n return { name: \"smallint\" };\n case \"int4\":\n return { name: \"integer\", shortName: \"int\" };\n case \"int8\":\n return { name: \"bigint\" };\n case \"bool\":\n return { name: \"boolean\" };\n case \"float4\":\n return { name: \"real\" };\n case \"float8\":\n return { name: \"double precision\" };\n case \"varchar\":\n return { name: \"character varying\" };\n case \"timestamptz\":\n return { name: \"timestamp with time zone\" };\n case \"timestamp\":\n return { name: \"timestamp without time zone\" };\n case \"time\":\n return { name: \"time without time zone\" };\n default:\n // Foreign-key serdes need shortName even for types with no PostgreSQL alias, such as uuid.\n return { name, shortName: name };\n }\n}\n\n/** Decodes the pg_constraint foreign-key delete action. */\nfunction deleteAction(code: string): Action {\n switch (code) {\n case \"a\":\n return \"NO ACTION\";\n case \"r\":\n return \"RESTRICT\";\n case \"c\":\n return \"CASCADE\";\n case \"n\":\n return \"SET NULL\";\n case \"d\":\n return \"SET DEFAULT\";\n default:\n throw new Error(`Unknown PostgreSQL delete action: ${code}`);\n }\n}\n\n/** Compares PostgreSQL relation names by code point, independent of the host locale. */\nfunction compareNames(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n"],"mappings":";;;AAIA,IAAa,QAAb,cAAuD,MAAS;CAC9D;;CAGA,IAAI,MAAiB;EAGnB,KAAK,WAAW,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC,KAAK,MAAM,IAAI,CAAC,CAAC;EAC7D,MAAM,OAAO,KAAK,OAAO,IAAI,IAAI;EACjC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,iBAAiB,MAAM;EAClD,OAAO;CACT;;CAGA,KAAK,GAAG,OAAoB;EAC1B,MAAM,SAAS,MAAM,KAAK,GAAG,KAAK;EAClC,IAAI,KAAK,QAAQ,KAAK,MAAM,QAAQ,OAAO,KAAK,OAAO,IAAI,KAAK,MAAM,IAAI;EAC1E,OAAO;CACT;AACF;AAKA,IAAa,WAAb,MAAsB;CAGX;CACA;CAHT;CACA,YACE,MACA,QACA;EAFO,KAAA,OAAA;EACA,KAAA,SAAA;CACN;AACL;AAEA,IAAa,SAAb,MAAoB;CAMT;CACA;CACA;CACA;CACA;CACA;CACA;CAXT,cAAqC,CAAC;CACtC,gBAAkC,CAAC;CACnC,eAAe;CAEf,YACE,MACA,MACA,SACA,cACA,aACA,gBACA,SACA;EAPO,KAAA,OAAA;EACA,KAAA,OA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;GAAW,WAAW;EAAM;EAC7C,KAAK,QACH,OAAO,EAAE,MAAM,SAAS;EAC1B,KAAK,QACH,OAAO,EAAE,MAAM,UAAU;EAC3B,KAAK,UACH,OAAO,EAAE,MAAM,OAAO;EACxB,KAAK,UACH,OAAO,EAAE,MAAM,mBAAmB;EACpC,KAAK,WACH,OAAO,EAAE,MAAM,oBAAoB;EACrC,KAAK,eACH,OAAO,EAAE,MAAM,2BAA2B;EAC5C,KAAK,aACH,OAAO,EAAE,MAAM,8BAA8B;EAC/C,KAAK,QACH,OAAO,EAAE,MAAM,yBAAyB;EAC1C,SAEE,OAAO;GAAE;GAAM,WAAW;EAAK;CACnC;AACF;;AAGA,SAAS,aAAa,MAAsB;CAC1C,QAAQ,MAAR;EACE,KAAK,KACH,OAAO;EACT,KAAK,KACH,OAAO;EACT,KAAK,KACH,OAAO;EACT,KAAK,KACH,OAAO;EACT,KAAK,KACH,OAAO;EACT,SACE,MAAM,IAAI,MAAM,qCAAqC,MAAM;CAC/D;AACF;;AAGA,SAAS,aAAa,GAAW,GAAmB;CAClD,OAAO,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI;AAClC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("./config.cjs");
|
|
3
|
+
require("./EntityDbMetadata.cjs");
|
|
4
|
+
let path = require("path");
|
|
5
|
+
let fs_promises = require("fs/promises");
|
|
6
|
+
//#region src/scanEntityFiles.ts
|
|
7
|
+
const regex = /config\.setDefault\([\s\n]*["'](\w+)["']/g;
|
|
8
|
+
/** Scans the entity files themselves for usage hints (like `setDefault` calls) to drive our codegen output. */
|
|
9
|
+
async function scanEntityFiles(config, dbMeta) {
|
|
10
|
+
await Promise.all(dbMeta.entities.map(async (entity) => {
|
|
11
|
+
try {
|
|
12
|
+
const tsCode = (await (0, fs_promises.readFile)((0, path.join)(config.entitiesDirectory, `${entity.name}.ts`))).toString();
|
|
13
|
+
const defaultableFields = recursiveDefaultableFields(dbMeta, entity);
|
|
14
|
+
for (const match of tsCode.matchAll(regex)) {
|
|
15
|
+
const field = defaultableFields.find((f) => f.fieldName === match[1]);
|
|
16
|
+
if (field) field.hasConfigDefault = true;
|
|
17
|
+
}
|
|
18
|
+
} catch (e) {}
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Traverse the entity inheritance tree to find all fields that can have defaults set on them.
|
|
23
|
+
*
|
|
24
|
+
* I.e. a column defined in a base CTI table like `publishers.foo_bar` having a `config.setDefault` in
|
|
25
|
+
* `SmallPublisher` and/or `LargePublisher`, or the same scenario for an STI table like `tasks.foo_bar`
|
|
26
|
+
* with `TaskNew` and/or `TaskOld`.
|
|
27
|
+
*
|
|
28
|
+
* NOTE: I suspect here could be some edge cases here that will need to be ironed out, but should work
|
|
29
|
+
* for simple inheritance structures. In particular, there may be unexpected side effects if a base
|
|
30
|
+
* class field has a default set in one subtype, but not another.
|
|
31
|
+
*/
|
|
32
|
+
function recursiveDefaultableFields(dbMeta, entity) {
|
|
33
|
+
if (!entity) return [];
|
|
34
|
+
return [
|
|
35
|
+
...entity.primitives,
|
|
36
|
+
...entity.enums,
|
|
37
|
+
...entity.pgEnums,
|
|
38
|
+
...entity.manyToOnes,
|
|
39
|
+
...entity.polymorphics,
|
|
40
|
+
...entity.baseClassName ? recursiveDefaultableFields(dbMeta, dbMeta.entitiesByName[entity.baseClassName]) : []
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
exports.scanEntityFiles = scanEntityFiles;
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=scanEntityFiles.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanEntityFiles.cjs","names":["readFile","join"],"sources":["../src/scanEntityFiles.ts"],"sourcesContent":["import { readFile } from \"fs/promises\";\nimport { join } from \"path\";\n\nimport { type Config } from \"./config.ts\";\nimport {\n type DbMetadata,\n type EntityDbMetadata,\n type EnumField,\n type ManyToOneField,\n type PgEnumField,\n type PolymorphicField,\n type PrimitiveField,\n} from \"./EntityDbMetadata.ts\";\n\n// Erg, we need a regex in case the fieldName arg is wrapped onto a new line... :-/\nconst regex = /config\\.setDefault\\([\\s\\n]*[\"'](\\w+)[\"']/g;\n\n/** Scans the entity files themselves for usage hints (like `setDefault` calls) to drive our codegen output. */\nexport async function scanEntityFiles(config: Config, dbMeta: DbMetadata): Promise<void> {\n await Promise.all(\n dbMeta.entities.map(async (entity) => {\n try {\n // load the entity.ts file (as a promise with fs/promises)\n const tsCode = (await readFile(join(config.entitiesDirectory, `${entity.name}.ts`))).toString();\n const defaultableFields = recursiveDefaultableFields(dbMeta, entity);\n for (const match of tsCode.matchAll(regex)) {\n const field = defaultableFields.find((f) => f.fieldName === match[1]);\n if (field) {\n field.hasConfigDefault = true;\n }\n }\n } catch (e) {\n // Ignore file not existing yet\n }\n }),\n );\n}\n\n/**\n * Traverse the entity inheritance tree to find all fields that can have defaults set on them.\n *\n * I.e. a column defined in a base CTI table like `publishers.foo_bar` having a `config.setDefault` in\n * `SmallPublisher` and/or `LargePublisher`, or the same scenario for an STI table like `tasks.foo_bar`\n * with `TaskNew` and/or `TaskOld`.\n *\n * NOTE: I suspect here could be some edge cases here that will need to be ironed out, but should work\n * for simple inheritance structures. In particular, there may be unexpected side effects if a base\n * class field has a default set in one subtype, but not another.\n */\nfunction recursiveDefaultableFields(\n dbMeta: DbMetadata,\n entity: EntityDbMetadata | undefined,\n): Array<PrimitiveField | EnumField | PgEnumField | ManyToOneField | PolymorphicField> {\n if (!entity) return [];\n return [\n ...entity.primitives,\n ...entity.enums,\n ...entity.pgEnums,\n ...entity.manyToOnes,\n ...entity.polymorphics,\n ...(entity.baseClassName ? recursiveDefaultableFields(dbMeta, dbMeta.entitiesByName[entity.baseClassName]) : []),\n ];\n}\n"],"mappings":";;;;;;AAeA,MAAM,QAAQ;;AAGd,eAAsB,gBAAgB,QAAgB,QAAmC;CACvF,MAAM,QAAQ,IACZ,OAAO,SAAS,IAAI,OAAO,WAAW;EACpC,IAAI;GAEF,MAAM,UAAU,OAAA,GAAMA,YAAAA,SAAAA,EAAAA,GAASC,KAAAA,KAAAA,CAAK,OAAO,mBAAmB,GAAG,OAAO,KAAK,IAAI,CAAC,EAAA,CAAG,SAAS;GAC9F,MAAM,oBAAoB,2BAA2B,QAAQ,MAAM;GACnE,KAAK,MAAM,SAAS,OAAO,SAAS,KAAK,GAAG;IAC1C,MAAM,QAAQ,kBAAkB,MAAM,MAAM,EAAE,cAAc,MAAM,EAAE;IACpE,IAAI,OACF,MAAM,mBAAmB;GAE7B;EACF,SAAS,GAAG,CAEZ;CACF,CAAC,CACH;AACF;;;;;;;;;;;;AAaA,SAAS,2BACP,QACA,QACqF;CACrF,IAAI,CAAC,QAAQ,OAAO,CAAC;CACrB,OAAO;EACL,GAAG,OAAO;EACV,GAAG,OAAO;EACV,GAAG,OAAO;EACV,GAAG,OAAO;EACV,GAAG,OAAO;EACV,GAAI,OAAO,gBAAgB,2BAA2B,QAAQ,OAAO,eAAe,OAAO,cAAc,IAAI,CAAC;CAChH;AACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Config } from "./config.cjs";
|
|
2
|
+
import { DbMetadata } from "./EntityDbMetadata.cjs";
|
|
3
|
+
//#region src/scanEntityFiles.d.ts
|
|
4
|
+
/** Scans the entity files themselves for usage hints (like `setDefault` calls) to drive our codegen output. */
|
|
5
|
+
declare function scanEntityFiles(config: Config, dbMeta: DbMetadata): Promise<void>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { scanEntityFiles };
|
|
8
|
+
//# sourceMappingURL=scanEntityFiles.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanEntityFiles.d.cts","names":[],"sources":["../src/scanEntityFiles.ts"],"mappings":";;;;iBAkBsB,gBAAgB,QAAQ,QAAQ,QAAQ,aAAa"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Config } from "./config.mjs";
|
|
2
|
+
import { DbMetadata } from "./EntityDbMetadata.mjs";
|
|
3
|
+
//#region src/scanEntityFiles.d.ts
|
|
4
|
+
/** Scans the entity files themselves for usage hints (like `setDefault` calls) to drive our codegen output. */
|
|
5
|
+
declare function scanEntityFiles(config: Config, dbMeta: DbMetadata): Promise<void>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { scanEntityFiles };
|
|
8
|
+
//# sourceMappingURL=scanEntityFiles.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanEntityFiles.d.mts","names":[],"sources":["../src/scanEntityFiles.ts"],"mappings":";;;;iBAkBsB,gBAAgB,QAAQ,QAAQ,QAAQ,aAAa"}
|
package/build/scanEntityFiles.js
CHANGED
|
@@ -1,50 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// Erg, we need a regex in case the fieldName arg is wrapped onto a new line... :-/
|
|
1
|
+
import "./config.js";
|
|
2
|
+
import "./EntityDbMetadata.js";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
import { readFile } from "fs/promises";
|
|
5
|
+
//#region src/scanEntityFiles.ts
|
|
7
6
|
const regex = /config\.setDefault\([\s\n]*["'](\w+)["']/g;
|
|
8
7
|
/** Scans the entity files themselves for usage hints (like `setDefault` calls) to drive our codegen output. */
|
|
9
8
|
async function scanEntityFiles(config, dbMeta) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
catch (e) {
|
|
23
|
-
// Ignore file not existing yet
|
|
24
|
-
}
|
|
25
|
-
}));
|
|
9
|
+
await Promise.all(dbMeta.entities.map(async (entity) => {
|
|
10
|
+
try {
|
|
11
|
+
const tsCode = (await readFile(join(config.entitiesDirectory, `${entity.name}.ts`))).toString();
|
|
12
|
+
const defaultableFields = recursiveDefaultableFields(dbMeta, entity);
|
|
13
|
+
for (const match of tsCode.matchAll(regex)) {
|
|
14
|
+
const field = defaultableFields.find((f) => f.fieldName === match[1]);
|
|
15
|
+
if (field) field.hasConfigDefault = true;
|
|
16
|
+
}
|
|
17
|
+
} catch (e) {}
|
|
18
|
+
}));
|
|
26
19
|
}
|
|
27
20
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
21
|
+
* Traverse the entity inheritance tree to find all fields that can have defaults set on them.
|
|
22
|
+
*
|
|
23
|
+
* I.e. a column defined in a base CTI table like `publishers.foo_bar` having a `config.setDefault` in
|
|
24
|
+
* `SmallPublisher` and/or `LargePublisher`, or the same scenario for an STI table like `tasks.foo_bar`
|
|
25
|
+
* with `TaskNew` and/or `TaskOld`.
|
|
26
|
+
*
|
|
27
|
+
* NOTE: I suspect here could be some edge cases here that will need to be ironed out, but should work
|
|
28
|
+
* for simple inheritance structures. In particular, there may be unexpected side effects if a base
|
|
29
|
+
* class field has a default set in one subtype, but not another.
|
|
30
|
+
*/
|
|
38
31
|
function recursiveDefaultableFields(dbMeta, entity) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
];
|
|
32
|
+
if (!entity) return [];
|
|
33
|
+
return [
|
|
34
|
+
...entity.primitives,
|
|
35
|
+
...entity.enums,
|
|
36
|
+
...entity.pgEnums,
|
|
37
|
+
...entity.manyToOnes,
|
|
38
|
+
...entity.polymorphics,
|
|
39
|
+
...entity.baseClassName ? recursiveDefaultableFields(dbMeta, dbMeta.entitiesByName[entity.baseClassName]) : []
|
|
40
|
+
];
|
|
49
41
|
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { scanEntityFiles };
|
|
44
|
+
|
|
50
45
|
//# sourceMappingURL=scanEntityFiles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scanEntityFiles.js","
|
|
1
|
+
{"version":3,"file":"scanEntityFiles.js","names":[],"sources":["../src/scanEntityFiles.ts"],"sourcesContent":["import { readFile } from \"fs/promises\";\nimport { join } from \"path\";\n\nimport { type Config } from \"./config.ts\";\nimport {\n type DbMetadata,\n type EntityDbMetadata,\n type EnumField,\n type ManyToOneField,\n type PgEnumField,\n type PolymorphicField,\n type PrimitiveField,\n} from \"./EntityDbMetadata.ts\";\n\n// Erg, we need a regex in case the fieldName arg is wrapped onto a new line... :-/\nconst regex = /config\\.setDefault\\([\\s\\n]*[\"'](\\w+)[\"']/g;\n\n/** Scans the entity files themselves for usage hints (like `setDefault` calls) to drive our codegen output. */\nexport async function scanEntityFiles(config: Config, dbMeta: DbMetadata): Promise<void> {\n await Promise.all(\n dbMeta.entities.map(async (entity) => {\n try {\n // load the entity.ts file (as a promise with fs/promises)\n const tsCode = (await readFile(join(config.entitiesDirectory, `${entity.name}.ts`))).toString();\n const defaultableFields = recursiveDefaultableFields(dbMeta, entity);\n for (const match of tsCode.matchAll(regex)) {\n const field = defaultableFields.find((f) => f.fieldName === match[1]);\n if (field) {\n field.hasConfigDefault = true;\n }\n }\n } catch (e) {\n // Ignore file not existing yet\n }\n }),\n );\n}\n\n/**\n * Traverse the entity inheritance tree to find all fields that can have defaults set on them.\n *\n * I.e. a column defined in a base CTI table like `publishers.foo_bar` having a `config.setDefault` in\n * `SmallPublisher` and/or `LargePublisher`, or the same scenario for an STI table like `tasks.foo_bar`\n * with `TaskNew` and/or `TaskOld`.\n *\n * NOTE: I suspect here could be some edge cases here that will need to be ironed out, but should work\n * for simple inheritance structures. In particular, there may be unexpected side effects if a base\n * class field has a default set in one subtype, but not another.\n */\nfunction recursiveDefaultableFields(\n dbMeta: DbMetadata,\n entity: EntityDbMetadata | undefined,\n): Array<PrimitiveField | EnumField | PgEnumField | ManyToOneField | PolymorphicField> {\n if (!entity) return [];\n return [\n ...entity.primitives,\n ...entity.enums,\n ...entity.pgEnums,\n ...entity.manyToOnes,\n ...entity.polymorphics,\n ...(entity.baseClassName ? recursiveDefaultableFields(dbMeta, dbMeta.entitiesByName[entity.baseClassName]) : []),\n ];\n}\n"],"mappings":";;;;;AAeA,MAAM,QAAQ;;AAGd,eAAsB,gBAAgB,QAAgB,QAAmC;CACvF,MAAM,QAAQ,IACZ,OAAO,SAAS,IAAI,OAAO,WAAW;EACpC,IAAI;GAEF,MAAM,UAAU,MAAM,SAAS,KAAK,OAAO,mBAAmB,GAAG,OAAO,KAAK,IAAI,CAAC,EAAA,CAAG,SAAS;GAC9F,MAAM,oBAAoB,2BAA2B,QAAQ,MAAM;GACnE,KAAK,MAAM,SAAS,OAAO,SAAS,KAAK,GAAG;IAC1C,MAAM,QAAQ,kBAAkB,MAAM,MAAM,EAAE,cAAc,MAAM,EAAE;IACpE,IAAI,OACF,MAAM,mBAAmB;GAE7B;EACF,SAAS,GAAG,CAEZ;CACF,CAAC,CACH;AACF;;;;;;;;;;;;AAaA,SAAS,2BACP,QACA,QACqF;CACrF,IAAI,CAAC,QAAQ,OAAO,CAAC;CACrB,OAAO;EACL,GAAG,OAAO;EACV,GAAG,OAAO;EACV,GAAG,OAAO;EACV,GAAG,OAAO;EACV,GAAG,OAAO;EACV,GAAI,OAAO,gBAAgB,2BAA2B,QAAQ,OAAO,eAAe,OAAO,cAAc,IAAI,CAAC;CAChH;AACF"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("./EntityDbMetadata.cjs");
|
|
3
|
+
//#region src/sortForeignKeys.ts
|
|
4
|
+
/**
|
|
5
|
+
* Sorts entities by non-deferred foreign key order.
|
|
6
|
+
*
|
|
7
|
+
* Ideally databases/schemas will support/enable deferred FKs, which let us insert/delete rows
|
|
8
|
+
* in any arbitrary order, and the FK checks will not be applied until txn commit.
|
|
9
|
+
*
|
|
10
|
+
* However, if not enabled/support, we have to worry about two things:
|
|
11
|
+
*
|
|
12
|
+
* 1. Inserting "parents" before their children
|
|
13
|
+
* - And if the parent has a circular reference to not-yet-inserted cycle
|
|
14
|
+
* 2. Deleting "children" before their parents
|
|
15
|
+
* - Again if the parent has a circular reference to the child
|
|
16
|
+
*
|
|
17
|
+
* For both of these, we can just look at the FK ordering to "put the parent first",
|
|
18
|
+
* but run into two problems:
|
|
19
|
+
*
|
|
20
|
+
* - If there is a cycle for not-null FKs, that breaks both INSERTs and DELETEs, so we
|
|
21
|
+
* must warn the user about these to fix.
|
|
22
|
+
* - If there is a cycle with nullable FKs, we can work around that by using NULL as a
|
|
23
|
+
* transient/dummy value, for the initial insert, do the 2nd insert, and then "fixup" the
|
|
24
|
+
* first insert with a UPDATE to the actual column value.
|
|
25
|
+
*
|
|
26
|
+
* Given ^, we set the `entity.nonDeferredFkOrder` of each entity, and then also return
|
|
27
|
+
* two arrays of all soft-cycle (nullable, fixup-able) and hard-cycle (not-nullable, blocking)
|
|
28
|
+
* keys.
|
|
29
|
+
*/
|
|
30
|
+
function sortByNonDeferredForeignKeys(entities) {
|
|
31
|
+
const graph = Object.fromEntries(entities.map((e) => [e.name, {
|
|
32
|
+
entity: e,
|
|
33
|
+
upstreamFks: /* @__PURE__ */ new Set(),
|
|
34
|
+
downstreamFks: /* @__PURE__ */ new Set()
|
|
35
|
+
}]));
|
|
36
|
+
const nullableCycles = [];
|
|
37
|
+
const notNullCycles = [];
|
|
38
|
+
entities.forEach((entity) => {
|
|
39
|
+
entity.nonDeferredFks.filter((m2o) => m2o.notNull).forEach((m2o) => {
|
|
40
|
+
const added = addDependency(graph, entity, m2o);
|
|
41
|
+
if (Array.isArray(added)) notNullCycles.push(added.join(" -> "));
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
entities.forEach((entity) => {
|
|
45
|
+
entity.nonDeferredFks.filter((m2o) => !m2o.notNull).forEach((m2o) => {
|
|
46
|
+
const added = addDependency(graph, entity, m2o);
|
|
47
|
+
if (Array.isArray(added)) nullableCycles.push(added.join(" -> "));
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
let queue = Object.values(graph).filter((n) => n.upstreamFks.size === 0);
|
|
51
|
+
let level = 1;
|
|
52
|
+
while (queue.length > 0) {
|
|
53
|
+
const nextLevel = [];
|
|
54
|
+
for (const current of queue) {
|
|
55
|
+
current.entity.nonDeferredFkOrder = level;
|
|
56
|
+
current.downstreamFks.forEach((node) => {
|
|
57
|
+
if (node.upstreamFks.delete(current) && node.upstreamFks.size === 0) nextLevel.push(node);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
queue = nextLevel;
|
|
61
|
+
level++;
|
|
62
|
+
}
|
|
63
|
+
entities.filter((e) => e.nonDeferredFkOrder === -1).forEach((e) => e.nonDeferredFkOrder = 1e5);
|
|
64
|
+
return {
|
|
65
|
+
nullableCycles,
|
|
66
|
+
notNullCycles
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function addDependency(graph, entity, m2o) {
|
|
70
|
+
const from = graph[entity.name];
|
|
71
|
+
const to = graph[m2o.otherEntity.name];
|
|
72
|
+
const cycle = willCreateCycle(graph, from, to);
|
|
73
|
+
if (cycle) return cycle;
|
|
74
|
+
from.upstreamFks.add(to);
|
|
75
|
+
to.downstreamFks.add(from);
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
function willCreateCycle(graph, from, to) {
|
|
79
|
+
return dfs(graph, /* @__PURE__ */ new Set(), /* @__PURE__ */ new Set(), [], from, to);
|
|
80
|
+
}
|
|
81
|
+
function dfs(graph, visited, stack, path, current, target) {
|
|
82
|
+
visited.add(current);
|
|
83
|
+
stack.add(current);
|
|
84
|
+
path.push(current);
|
|
85
|
+
for (const neighbor of current.downstreamFks) {
|
|
86
|
+
if (neighbor === target) return [...path, neighbor].map((n) => n.entity.name);
|
|
87
|
+
if (!visited.has(neighbor)) {
|
|
88
|
+
const cycle = dfs(graph, visited, stack, path, neighbor, target);
|
|
89
|
+
if (cycle) return cycle;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
stack.delete(current);
|
|
93
|
+
path.pop();
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
exports.sortByNonDeferredForeignKeys = sortByNonDeferredForeignKeys;
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=sortForeignKeys.cjs.map
|