joist-codegen 2.3.0-next.42 → 2.3.0-next.44
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 -664
- 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 -3
- 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 -46
- 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 +300 -382
- 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 +18 -20
- 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 +72 -91
- 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 -11
- 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 +86 -91
- 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 +79 -121
- 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 +109 -129
- 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 +707 -852
- 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 -4
- 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 -73
- 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 +111 -142
- 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 +105 -147
- 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.ts → installSkills.d.cts} +5 -1
- 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 +55 -57
- package/build/installSkills.js.map +1 -1
- 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 -4
- 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 -116
- 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 +28 -5
- package/build/EntityDbMetadata.d.ts +0 -271
- package/build/codemods/Codemod.d.ts +0 -13
- package/build/codemods/Codemod.js.map +0 -1
- package/build/codemods/JscodeshiftMod.d.ts +0 -10
- package/build/codemods/codemod_0001-rename_has_async_property.d.ts +0 -6
- package/build/codemods/codemod_0002-rename_async_query_fields.d.ts +0 -6
- package/build/codemods/codemod_0003-rename_find_paginated.d.ts +0 -6
- package/build/codemods/index.d.ts +0 -8
- package/build/config.d.ts +0 -178
- package/build/docs/cache.d.ts +0 -13
- package/build/docs/generate-metadata-docs.d.ts +0 -5
- package/build/docs/index.d.ts +0 -13
- package/build/docs/parsing.d.ts +0 -45
- package/build/findEntityScopes.d.ts +0 -10
- package/build/foreignKeyOrdering.d.ts +0 -2
- package/build/generate.d.ts +0 -11
- package/build/generateEntitiesFile.d.ts +0 -6
- package/build/generateEntityCodegenFile.d.ts +0 -11
- package/build/generateEntityFile.d.ts +0 -5
- package/build/generateEntityTestFile.d.ts +0 -5
- package/build/generateEnumFile.d.ts +0 -4
- package/build/generateFactoriesFiles.d.ts +0 -3
- package/build/generateMetadataFile.d.ts +0 -4
- package/build/generatePgEnumFile.d.ts +0 -4
- package/build/index.d.ts +0 -11
- package/build/inheritance.d.ts +0 -9
- package/build/keywords.d.ts +0 -1
- package/build/loadMetadata.d.ts +0 -25
- package/build/logger.d.ts +0 -9
- package/build/scanEntityFiles.d.ts +0 -4
- package/build/symbols.d.ts +0 -110
- package/build/tsdoc.d.ts +0 -11
- package/build/utils.d.ts +0 -30
- package/build/write-json-schema.d.ts +0 -1
package/build/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,6CAAyC;AACzC,6CAA4C;AAE5C,0DAAkC;A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AAI,SAAS,KAAK,MAAM,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,sBAAsB,SAAS,4BAA4B,CAAC,CAAC;IAC/E,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AAC9B,CAAC;AAED,WAAkB,CAAqB;IACrC,OAAO,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;AAClD,CAAC;AAED,sBAA6B,CAAS;IACpC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,SAAS,CAAC,MAAc,EAAE,CAAQ;IACzC,OAAO,CAAC,MAAM,CAAC,aAAa,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AACtH,CAAC;AAED,SAAS,mBAAmB,CAAC,MAAc,EAAE,CAAQ;IACnD,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC9F,CAAC"}
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import { pascalCase } from \"change-case\";\nimport { isPlainObject } from \"joist-utils\";\nimport { type Table } from \"pg-structure\";\nimport pluralize from \"pluralize\";\nimport { code, imp } from \"ts-poet\";\n\nimport { type Config, getTimestampConfig } from \"./config.ts\";\nimport { type DatabaseColumnType, type PrimitiveTypescriptType } from \"./EntityDbMetadata.ts\";\n\nexport function assertNever(x: never): never {\n throw new Error(\"Unexpected object: \" + x);\n}\n\nexport function isEntityTable(config: Config, t: Table): boolean {\n if (isIgnored(config, t) || isJoinTable(config, t)) {\n return false;\n }\n\n // Depending on the config settings, we may/may not require the presence of timestamp\n // fields to determine whether a table is an entity.\n const columnNames = t.columns.map((c) => c.name);\n const { updatedAtConf, createdAtConf } = getTimestampConfig(config);\n const hasCreatedAt = createdAtConf.names.some((c) => columnNames.includes(c));\n const hasUpdatedAt = updatedAtConf.names.some((c) => columnNames.includes(c));\n\n // Entities always require an id column\n const hasIdColumn = columnNames.includes(\"id\");\n if (!hasIdColumn) return false;\n\n // If we have no timestamp columns, but do have `name` and `code`, we're probably an enum.\n if (hasIdColumn && !hasCreatedAt && !hasUpdatedAt) {\n if ([\"name\", \"code\"].every((c) => columnNames.includes(c))) {\n return false;\n }\n }\n\n // If the ID column is a FK then we're a subclass\n if (isSubClassTable(t)) return true;\n\n // Otherwise respect the created_at/updated_at required rules\n return hasIdColumn && (hasCreatedAt || !createdAtConf.required) && (hasUpdatedAt || !updatedAtConf.required);\n}\n\nexport function isSubClassTable(t: Table): boolean {\n // Note that `.get(\"id\")` will blow up if there is no id column\n return t.columns.get(\"id\").foreignKeys.length === 1;\n}\n\nexport function isEnumTable(config: Config, t: Table): boolean {\n if (isIgnored(config, t)) {\n return false;\n }\n const columnNames = t.columns.map((c) => c.name);\n return [\"id\", \"code\", \"name\"].every((c) => columnNames.includes(c)) && !isEntityTable(config, t);\n}\n\n// Oddly enough isJoinTable showed up as a hot spot, so cache its calculation.\nconst joinTables: Map<string, boolean> = new Map();\n\nexport function isJoinTable(config: Config, t: Table): boolean {\n if (isIgnored(config, t)) {\n return false;\n }\n return getOrElse(joinTables, t.name, () => {\n const { columns } = t;\n const fks = columns.filter((c) => c.isForeignKey);\n const pks = columns.filter((c) => c.isPrimaryKey);\n // Every join table is two FKs, plus either a surrogate `id` PK (\"id-ful\") or no surrogate\n // at all, in which case the two FKs are themselves the composite PK (\"id-less\").\n if (fks.length !== 2) return false;\n if (!joinTableHasId(t) && !(pks.length === 2 && pks.every((c) => c.isForeignKey))) return false;\n // Any column beyond the two FKs and the optional `id` PK must be a single created_at.\n const others = columns.length - fks.length - (joinTableHasId(t) ? 1 : 0);\n const createdAts = columns.filter((c) => c.name === \"created_at\" || c.name === \"createdAt\").length;\n return others === 0 || (others === 1 && createdAts === 1);\n });\n}\n\n/** Whether a join table has a surrogate `id` primary key (vs. an id-less FK-pair composite PK). */\nexport function joinTableHasId(t: Table): boolean {\n const pks = t.columns.filter((c) => c.isPrimaryKey);\n return pks.length === 1 && !pks[0].isForeignKey;\n}\n\nfunction getOrElse<K, V>(map: Map<K, V>, key: K, fn: () => V): V {\n let value = map.get(key);\n if (value === undefined) {\n value = fn();\n map.set(key, value);\n }\n return value;\n}\n\n/** Converts `projects` to `Project`. */\nexport function tableToEntityName(config: Config, table: Table): string {\n let entityName = config.__tableToEntityName?.[table.name];\n if (!entityName) {\n const configEntityName = Object.entries(config.entities)\n .filter(([, conf]) => conf.tableName === table.name)\n .map(([entityName]) => entityName)[0];\n entityName = configEntityName || pascalCase(pluralize.singular(table.name));\n (config.__tableToEntityName ??= {})[table.name] = entityName;\n }\n return entityName;\n}\n\nexport const dateCode = code`Date`;\nexport const plainDateCode = code`${imp(\"Temporal@joist-orm\")}.PlainDate`;\nexport const plainTimeCode = code`${imp(\"Temporal@joist-orm\")}.PlainTime`;\nexport const plainDateTimeCode = code`${imp(\"Temporal@joist-orm\")}.PlainDateTime`;\nexport const zonedDateTimeCode = code`${imp(\"Temporal@joist-orm\")}.ZonedDateTime`;\n\n/** Maps db types, i.e. `int`, to JS types, i.e. `number`. */\nexport function mapSimpleDbTypeToTypescriptType(config: Config, dbType: DatabaseColumnType): PrimitiveTypescriptType {\n switch (dbType) {\n case \"boolean\":\n return \"boolean\";\n case \"int\":\n case \"numeric\":\n case \"smallint\":\n case \"integer\":\n case \"decimal\":\n case \"real\":\n case \"smallserial\":\n case \"serial\":\n case \"double precision\":\n return \"number\";\n case \"bigserial\":\n case \"bigint\":\n return \"bigint\";\n case \"text\":\n case \"citext\":\n case \"character varying\":\n case \"varchar\":\n case \"uuid\":\n case \"tsvector\":\n case \"tstzrange\":\n return \"string\";\n case \"time without time zone\":\n return config.temporal\n ? plainTimeCode\n : fail(\"Joist doesn't support 'time without time zone' unless temporal is enabled\");\n case \"timestamp with time zone\":\n return config.temporal ? zonedDateTimeCode : dateCode;\n case \"timestamp without time zone\":\n return config.temporal ? plainDateTimeCode : dateCode;\n case \"date\":\n return config.temporal ? plainDateCode : dateCode;\n case \"jsonb\":\n return \"Object\";\n case \"bytea\":\n return \"Uint8Array\";\n default:\n assertNever(dbType);\n }\n}\n\nexport function merge<T>(a: T[], b: T[]): T[] {\n return [...a, ...b];\n}\n\n/** Returns true if `p` is resolved, otherwise false if it is rejected. */\nexport async function trueIfResolved(p: Promise<unknown>): Promise<boolean> {\n return p.then(\n () => true,\n () => false,\n );\n}\n\nexport function fail(message?: string): never {\n throw new Error(message || \"Failed\");\n}\n\nexport function sortKeys<T extends object>(o: T): T {\n return Object.keys(o)\n .sort()\n .reduce(\n (acc, key) => {\n const value = o[key as keyof T];\n const newValue = typeof value === \"object\" && isPlainObject(value) ? sortKeys(value as any as object) : value;\n acc[key as keyof T] = newValue as any;\n return acc;\n },\n {} as any as T,\n );\n}\n\nexport function parseOrder(order: string | undefined): { field: string; direction: \"ASC\" | \"DESC\" } | undefined {\n if (!order) {\n return undefined;\n }\n const [field, direction = \"ASC\"] = order.split(\" \");\n if (direction !== \"ASC\" && direction !== \"DESC\") {\n throw new Error(`Invalid direction: ${direction} (must be \"ASC\" or \"DESC\")`);\n }\n return { field, direction };\n}\n\nexport function q(s: string | undefined): string {\n return s === undefined ? \"undefined\" : `\"${s}\"`;\n}\n\nexport function uncapitalize(s: string): string {\n return s.charAt(0).toLowerCase() + s.slice(1);\n}\n\nfunction isIgnored(config: Config, t: Table): boolean {\n return (config.ignoredTables || [\"migrations\", \"pgmigrations\"]).includes(t.name) || !shouldIncludeSchema(config, t);\n}\n\nfunction shouldIncludeSchema(config: Config, t: Table): boolean {\n return config.schemas ? config.schemas.includes(t.schema.name) : t.schema.name === \"public\";\n}\n"],"mappings":";;;;;;;;AASA,SAAgB,YAAY,GAAiB;CAC3C,MAAM,IAAI,MAAM,wBAAwB,CAAC;AAC3C;AAEA,SAAgB,cAAc,QAAgB,GAAmB;CAC/D,IAAI,UAAU,QAAQ,CAAC,KAAK,YAAY,QAAQ,CAAC,GAC/C,OAAO;CAKT,MAAM,cAAc,EAAE,QAAQ,KAAK,MAAM,EAAE,IAAI;CAC/C,MAAM,EAAE,eAAe,kBAAkB,mBAAmB,MAAM;CAClE,MAAM,eAAe,cAAc,MAAM,MAAM,MAAM,YAAY,SAAS,CAAC,CAAC;CAC5E,MAAM,eAAe,cAAc,MAAM,MAAM,MAAM,YAAY,SAAS,CAAC,CAAC;CAG5E,MAAM,cAAc,YAAY,SAAS,IAAI;CAC7C,IAAI,CAAC,aAAa,OAAO;CAGzB,IAAI,eAAe,CAAC,gBAAgB,CAAC,cAC/B;MAAA,CAAC,QAAQ,MAAM,CAAC,CAAC,OAAO,MAAM,YAAY,SAAS,CAAC,CAAC,GACvD,OAAO;CAAA;CAKX,IAAI,gBAAgB,CAAC,GAAG,OAAO;CAG/B,OAAO,gBAAgB,gBAAgB,CAAC,cAAc,cAAc,gBAAgB,CAAC,cAAc;AACrG;AAEA,SAAgB,gBAAgB,GAAmB;CAEjD,OAAO,EAAE,QAAQ,IAAI,IAAI,CAAC,CAAC,YAAY,WAAW;AACpD;AAEA,SAAgB,YAAY,QAAgB,GAAmB;CAC7D,IAAI,UAAU,QAAQ,CAAC,GACrB,OAAO;CAET,MAAM,cAAc,EAAE,QAAQ,KAAK,MAAM,EAAE,IAAI;CAC/C,OAAO;EAAC;EAAM;EAAQ;CAAM,CAAC,CAAC,OAAO,MAAM,YAAY,SAAS,CAAC,CAAC,KAAK,CAAC,cAAc,QAAQ,CAAC;AACjG;AAGA,MAAM,6BAAm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E;EAEhB,IAAI,OADa,OAAO,UAAU,YAAY,cAAc,KAAK,IAAI,SAAS,KAAsB,IAAI;EAExG,OAAO;CACT,GACA,CAAC,CACH;AACJ;AAEA,SAAgB,WAAW,OAAqF;CAC9G,IAAI,CAAC,OACH;CAEF,MAAM,CAAC,OAAO,YAAY,SAAS,MAAM,MAAM,GAAG;CAClD,IAAI,cAAc,SAAS,cAAc,QACvC,MAAM,IAAI,MAAM,sBAAsB,UAAU,2BAA2B;CAE7E,OAAO;EAAE;EAAO;CAAU;AAC5B;AAEA,SAAgB,EAAE,GAA+B;CAC/C,OAAO,MAAM,KAAA,IAAY,cAAc,IAAI,EAAE;AAC/C;AAEA,SAAgB,aAAa,GAAmB;CAC9C,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,EAAE,MAAM,CAAC;AAC9C;AAEA,SAAS,UAAU,QAAgB,GAAmB;CACpD,QAAQ,OAAO,iBAAiB,CAAC,cAAc,cAAc,EAAA,CAAG,SAAS,EAAE,IAAI,KAAK,CAAC,oBAAoB,QAAQ,CAAC;AACpH;AAEA,SAAS,oBAAoB,QAAgB,GAAmB;CAC9D,OAAO,OAAO,UAAU,OAAO,QAAQ,SAAS,EAAE,OAAO,IAAI,IAAI,EAAE,OAAO,SAAS;AACrF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_config = require("./config.cjs");
|
|
3
|
+
let fs = require("fs");
|
|
4
|
+
let _dprint_formatter = require("@dprint/formatter");
|
|
5
|
+
let _dprint_json = require("@dprint/json");
|
|
6
|
+
let zod = require("zod");
|
|
7
|
+
//#region src/write-json-schema.ts
|
|
8
|
+
const jsonFormatter = (0, _dprint_formatter.createFromBuffer)((0, fs.readFileSync)((0, _dprint_json.getPath)()));
|
|
9
|
+
async function main() {
|
|
10
|
+
const jsonSchema = zod.z.toJSONSchema(require_config.config, {
|
|
11
|
+
io: "input",
|
|
12
|
+
unrepresentable: "any"
|
|
13
|
+
});
|
|
14
|
+
const content = jsonFormatter.formatText({
|
|
15
|
+
filePath: "test.json",
|
|
16
|
+
fileText: JSON.stringify(jsonSchema)
|
|
17
|
+
});
|
|
18
|
+
await fs.promises.writeFile("./config-json-schema.json", content);
|
|
19
|
+
}
|
|
20
|
+
main();
|
|
21
|
+
//#endregion
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=write-json-schema.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-json-schema.cjs","names":["createFromBuffer","readFileSync","getPath","z","config"],"sources":["../src/write-json-schema.ts"],"sourcesContent":["import { promises as fs, readFileSync } from \"fs\";\n\nimport { createFromBuffer } from \"@dprint/formatter\";\nimport { getPath } from \"@dprint/json\";\nimport { z } from \"zod\";\n\nimport { config } from \"./config.ts\";\n\nconst jsonFormatter = createFromBuffer(readFileSync(getPath()));\n\nasync function main() {\n // `io: \"input\"` since the schema validates the user-authored joist-config.json, and\n // `unrepresentable: \"any\"` to skip the `uniqueBy` transform that has no JSON Schema form.\n const jsonSchema = z.toJSONSchema(config, { io: \"input\", unrepresentable: \"any\" });\n const content = jsonFormatter.formatText({ filePath: \"test.json\", fileText: JSON.stringify(jsonSchema) });\n await fs.writeFile(\"./config-json-schema.json\", content);\n}\n\nmain();\n"],"mappings":";;;;;;;AAQA,MAAM,iBAAA,GAAgBA,kBAAAA,iBAAAA,EAAAA,GAAiBC,GAAAA,aAAAA,EAAAA,GAAaC,aAAAA,QAAAA,CAAQ,CAAC,CAAC;AAE9D,eAAe,OAAO;CAGpB,MAAM,aAAaC,IAAAA,EAAE,aAAaC,eAAAA,QAAQ;EAAE,IAAI;EAAS,iBAAiB;CAAM,CAAC;CACjF,MAAM,UAAU,cAAc,WAAW;EAAE,UAAU;EAAa,UAAU,KAAK,UAAU,UAAU;CAAE,CAAC;CACxG,MAAM,GAAA,SAAG,UAAU,6BAA6B,OAAO;AACzD;AAEA,KAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const jsonFormatter = (0, formatter_1.createFromBuffer)((0, fs_1.readFileSync)((0, json_1.getPath)()));
|
|
1
|
+
import { config } from "./config.js";
|
|
2
|
+
import { promises, readFileSync } from "fs";
|
|
3
|
+
import { createFromBuffer } from "@dprint/formatter";
|
|
4
|
+
import { getPath } from "@dprint/json";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
//#region src/write-json-schema.ts
|
|
7
|
+
const jsonFormatter = createFromBuffer(readFileSync(getPath()));
|
|
9
8
|
async function main() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
const jsonSchema = z.toJSONSchema(config, {
|
|
10
|
+
io: "input",
|
|
11
|
+
unrepresentable: "any"
|
|
12
|
+
});
|
|
13
|
+
const content = jsonFormatter.formatText({
|
|
14
|
+
filePath: "test.json",
|
|
15
|
+
fileText: JSON.stringify(jsonSchema)
|
|
16
|
+
});
|
|
17
|
+
await promises.writeFile("./config-json-schema.json", content);
|
|
15
18
|
}
|
|
16
19
|
main();
|
|
20
|
+
//#endregion
|
|
21
|
+
export {};
|
|
22
|
+
|
|
17
23
|
//# sourceMappingURL=write-json-schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-json-schema.js","
|
|
1
|
+
{"version":3,"file":"write-json-schema.js","names":["fs"],"sources":["../src/write-json-schema.ts"],"sourcesContent":["import { promises as fs, readFileSync } from \"fs\";\n\nimport { createFromBuffer } from \"@dprint/formatter\";\nimport { getPath } from \"@dprint/json\";\nimport { z } from \"zod\";\n\nimport { config } from \"./config.ts\";\n\nconst jsonFormatter = createFromBuffer(readFileSync(getPath()));\n\nasync function main() {\n // `io: \"input\"` since the schema validates the user-authored joist-config.json, and\n // `unrepresentable: \"any\"` to skip the `uniqueBy` transform that has no JSON Schema form.\n const jsonSchema = z.toJSONSchema(config, { io: \"input\", unrepresentable: \"any\" });\n const content = jsonFormatter.formatText({ filePath: \"test.json\", fileText: JSON.stringify(jsonSchema) });\n await fs.writeFile(\"./config-json-schema.json\", content);\n}\n\nmain();\n"],"mappings":";;;;;;AAQA,MAAM,gBAAgB,iBAAiB,aAAa,QAAQ,CAAC,CAAC;AAE9D,eAAe,OAAO;CAGpB,MAAM,aAAa,EAAE,aAAa,QAAQ;EAAE,IAAI;EAAS,iBAAiB;CAAM,CAAC;CACjF,MAAM,UAAU,cAAc,WAAW;EAAE,UAAU;EAAa,UAAU,KAAK,UAAU,UAAU;CAAE,CAAC;CACxG,MAAMA,SAAG,UAAU,6BAA6B,OAAO;AACzD;AAEA,KAAK"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "joist-codegen",
|
|
3
|
-
"version": "2.3.0-next.
|
|
3
|
+
"version": "2.3.0-next.44",
|
|
4
4
|
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
7
8
|
"url": "https://github.com/joist-orm/joist-orm.git",
|
|
8
9
|
"directory": "packages/codegen"
|
|
9
10
|
},
|
|
10
|
-
"main": "build/index.
|
|
11
|
-
"
|
|
12
|
-
"
|
|
11
|
+
"main": "build/index.cjs",
|
|
12
|
+
"module": "build/index.js",
|
|
13
|
+
"types": "build/index.d.mts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"bun": {
|
|
17
|
+
"types": "./build/index.d.mts",
|
|
18
|
+
"default": "./build/index.js"
|
|
19
|
+
},
|
|
20
|
+
"module-sync": {
|
|
21
|
+
"types": "./build/index.d.mts",
|
|
22
|
+
"default": "./build/index.js"
|
|
23
|
+
},
|
|
24
|
+
"import": {
|
|
25
|
+
"types": "./build/index.d.mts",
|
|
26
|
+
"default": "./build/index.js"
|
|
27
|
+
},
|
|
28
|
+
"require": {
|
|
29
|
+
"types": "./build/index.d.cts",
|
|
30
|
+
"default": "./build/index.cjs"
|
|
31
|
+
},
|
|
32
|
+
"default": "./build/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"bin": "build/index.cjs",
|
|
13
36
|
"files": [
|
|
14
37
|
"build",
|
|
15
38
|
"skills"
|
|
16
39
|
],
|
|
17
40
|
"peerDependencies": {
|
|
18
|
-
"joist-utils": "2.3.0-next.
|
|
41
|
+
"joist-utils": "2.3.0-next.44",
|
|
19
42
|
"knex": "^3.1.0",
|
|
20
43
|
"pg": "^8.22.0"
|
|
21
44
|
},
|
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
import { Action, Column, M2MRelation, M2ORelation, O2MRelation, Table } from "pg-structure";
|
|
2
|
-
import { Code, Import } from "ts-poet";
|
|
3
|
-
import { Config } from "./config";
|
|
4
|
-
import { EnumMetadata, EnumRow, PgEnumMetadata } from "./loadMetadata";
|
|
5
|
-
/** All the entities + enums in our database. */
|
|
6
|
-
export interface DbMetadata {
|
|
7
|
-
entities: EntityDbMetadata[];
|
|
8
|
-
/** Type name i.e. `Author` to metadata. */
|
|
9
|
-
entitiesByName: Record<string, EntityDbMetadata>;
|
|
10
|
-
enums: EnumMetadata;
|
|
11
|
-
pgEnums: PgEnumMetadata;
|
|
12
|
-
joinTables: string[];
|
|
13
|
-
/** Other non-joist tables in the schema. */
|
|
14
|
-
otherTables: string[];
|
|
15
|
-
totalTables: number;
|
|
16
|
-
}
|
|
17
|
-
/** Codegen-time metadata about a given domain entity. */
|
|
18
|
-
export type Entity = {
|
|
19
|
-
name: string;
|
|
20
|
-
/** The _type_ symbol pointing to the entity itself. */
|
|
21
|
-
type: Import;
|
|
22
|
-
/** The symbol pointing to the entity itself. */
|
|
23
|
-
typeSymbol: Import;
|
|
24
|
-
/** The symbol pointing to the entity itself, directly rather than via entities.ts */
|
|
25
|
-
typeForMetadataFile: Import;
|
|
26
|
-
/** The name of the entity's runtime metadata const. */
|
|
27
|
-
metaName: string;
|
|
28
|
-
/** The symbol pointing to the entity's runtime metadata const. */
|
|
29
|
-
metaType: Import;
|
|
30
|
-
/** The symbol pointing to the entity's EntityId type. */
|
|
31
|
-
idType: Import;
|
|
32
|
-
/** The symbol pointing to the entity's Order type. */
|
|
33
|
-
orderType: Import;
|
|
34
|
-
/** The symbol pointing to the entity's config const. */
|
|
35
|
-
configConst: Import;
|
|
36
|
-
optsType: Import;
|
|
37
|
-
/** i.e. `AuthorId` (or `Author_Id` on conflict). */
|
|
38
|
-
idName: string;
|
|
39
|
-
/** i.e. `AuthorFields`. */
|
|
40
|
-
fieldsName: string;
|
|
41
|
-
/** i.e. `AuthorOpts`. */
|
|
42
|
-
optsName: string;
|
|
43
|
-
/** i.e. `AuthorIdsOpts`. */
|
|
44
|
-
idsOptsName: string;
|
|
45
|
-
/** i.e. `AuthorFilter`. */
|
|
46
|
-
filterName: string;
|
|
47
|
-
/** i.e. `AuthorGraphQLFilter`. */
|
|
48
|
-
graphqlFilterName: string;
|
|
49
|
-
/** i.e. `AuthorOrder`. */
|
|
50
|
-
orderName: string;
|
|
51
|
-
/** i.e. `AuthorFactoryExtras`. */
|
|
52
|
-
factoryExtrasName: string;
|
|
53
|
-
/** i.e. `AuthorScope`. */
|
|
54
|
-
scopeName: string;
|
|
55
|
-
/** i.e. `AuthorScopes`. */
|
|
56
|
-
scopesName: string;
|
|
57
|
-
};
|
|
58
|
-
export type DatabaseColumnType = "boolean" | "int" | "uuid" | "numeric" | "smallint" | "integer" | "bigint" | "decimal" | "real" | "smallserial" | "serial" | "bigserial" | "double precision" | "text" | "citext" | "character varying" | "varchar" | "time without time zone" | "timestamp with time zone" | "timestamp without time zone" | "date" | "jsonb" | "bytea" | "tsvector" | "tstzrange";
|
|
59
|
-
/**
|
|
60
|
-
* A logical entity field.
|
|
61
|
-
*
|
|
62
|
-
* I.e. it may be a physical db column, or multiple physical db columns, or a "virtual" field like
|
|
63
|
-
* the one-to-many collection side of a many-to-one foreign key. */
|
|
64
|
-
interface Field {
|
|
65
|
-
fieldName: string;
|
|
66
|
-
ignore?: boolean;
|
|
67
|
-
}
|
|
68
|
-
export type PrimitiveTypescriptType = "boolean" | "string" | "number" | "Object" | "bigint" | "Uint8Array" | Code;
|
|
69
|
-
export type PrimitiveField = Field & {
|
|
70
|
-
kind: "primitive";
|
|
71
|
-
columnName: string;
|
|
72
|
-
columnType: DatabaseColumnType;
|
|
73
|
-
columnDefault: number | boolean | string | null;
|
|
74
|
-
fieldType: PrimitiveTypescriptType | Import;
|
|
75
|
-
rawFieldType: PrimitiveTypescriptType;
|
|
76
|
-
notNull: boolean;
|
|
77
|
-
derived: "orm" | "sync" | "async" | false;
|
|
78
|
-
protected: boolean;
|
|
79
|
-
unique: boolean;
|
|
80
|
-
superstruct: Import | undefined;
|
|
81
|
-
zodSchema: Import | undefined;
|
|
82
|
-
customSerde: Import | undefined;
|
|
83
|
-
isArray: boolean;
|
|
84
|
-
hasConfigDefault: boolean;
|
|
85
|
-
lazy?: boolean;
|
|
86
|
-
};
|
|
87
|
-
export type EnumField = Field & {
|
|
88
|
-
kind: "enum";
|
|
89
|
-
columnName: string;
|
|
90
|
-
columnType: DatabaseColumnType;
|
|
91
|
-
columnDefault: number | boolean | string | null;
|
|
92
|
-
derived: "sync" | "async" | false;
|
|
93
|
-
enumName: string;
|
|
94
|
-
enumType: Import;
|
|
95
|
-
enumDetailType: Import;
|
|
96
|
-
enumDetailsType: Import;
|
|
97
|
-
enumRows: EnumRow[];
|
|
98
|
-
notNull: boolean;
|
|
99
|
-
isArray: boolean;
|
|
100
|
-
hasConfigDefault: boolean;
|
|
101
|
-
};
|
|
102
|
-
export type PgEnumField = Field & {
|
|
103
|
-
kind: "pg-enum";
|
|
104
|
-
columnName: string;
|
|
105
|
-
columnDefault: number | boolean | string | null;
|
|
106
|
-
/** I.e. `favorite_shape`. */
|
|
107
|
-
dbType: string;
|
|
108
|
-
/** I.e. `FavoriteShape`. */
|
|
109
|
-
enumName: string;
|
|
110
|
-
enumType: Import;
|
|
111
|
-
enumValues: string[];
|
|
112
|
-
notNull: boolean;
|
|
113
|
-
hasConfigDefault: boolean;
|
|
114
|
-
};
|
|
115
|
-
/** I.e. a `Book.author` reference pointing to an `Author`. */
|
|
116
|
-
export type ManyToOneField = Field & {
|
|
117
|
-
kind: "m2o";
|
|
118
|
-
columnName: string;
|
|
119
|
-
dbType: string;
|
|
120
|
-
otherFieldName: string;
|
|
121
|
-
otherEntity: Entity;
|
|
122
|
-
notNull: boolean;
|
|
123
|
-
isDeferredAndDeferrable: boolean;
|
|
124
|
-
constraintName: string;
|
|
125
|
-
derived: "async" | false;
|
|
126
|
-
hasConfigDefault: boolean;
|
|
127
|
-
onDelete: Action;
|
|
128
|
-
};
|
|
129
|
-
/** I.e. a `Author.books` collection. */
|
|
130
|
-
export type OneToManyField = Field & {
|
|
131
|
-
kind: "o2m";
|
|
132
|
-
singularName: string;
|
|
133
|
-
otherEntity: Entity;
|
|
134
|
-
otherFieldName: string;
|
|
135
|
-
otherColumnName: string;
|
|
136
|
-
otherColumnNotNull: boolean;
|
|
137
|
-
isLargeCollection: boolean;
|
|
138
|
-
orderBy: {
|
|
139
|
-
field: string;
|
|
140
|
-
direction: "ASC" | "DESC";
|
|
141
|
-
} | undefined;
|
|
142
|
-
softDeletes: "include" | "exclude" | undefined;
|
|
143
|
-
};
|
|
144
|
-
/** I.e. a `Author.image` reference when `image.author_id` is unique. */
|
|
145
|
-
export type OneToOneField = Field & {
|
|
146
|
-
kind: "o2o";
|
|
147
|
-
otherEntity: Entity;
|
|
148
|
-
otherFieldName: string;
|
|
149
|
-
otherColumnName: string;
|
|
150
|
-
otherColumnNotNull: boolean;
|
|
151
|
-
};
|
|
152
|
-
export type ManyToManyField = Field & {
|
|
153
|
-
kind: "m2m";
|
|
154
|
-
joinTableName: string;
|
|
155
|
-
singularName: string;
|
|
156
|
-
columnName: string;
|
|
157
|
-
otherEntity: Entity;
|
|
158
|
-
otherFieldName: string;
|
|
159
|
-
otherColumnName: string;
|
|
160
|
-
isLargeCollection: boolean;
|
|
161
|
-
isDeferredAndDeferrable: boolean;
|
|
162
|
-
derived: "async" | "otherSide" | false;
|
|
163
|
-
softDeletes: "include" | "exclude" | undefined;
|
|
164
|
-
/** Whether the join table has a surrogate `id` PK; if false the FK pair is the composite PK. */
|
|
165
|
-
hasJoinTableId: boolean;
|
|
166
|
-
};
|
|
167
|
-
/** I.e. a `Publisher.logoColors` m2m to the `color` enum table, backed by `publisher_logo_colors`. */
|
|
168
|
-
export type ManyToManyEnumField = Field & {
|
|
169
|
-
kind: "m2mEnum";
|
|
170
|
-
joinTableName: string;
|
|
171
|
-
/** The entity's FK column, e.g. `publisher_id`. */
|
|
172
|
-
columnName: string;
|
|
173
|
-
/** The enum's FK column, e.g. `logo_color_id`. */
|
|
174
|
-
otherColumnName: string;
|
|
175
|
-
enumName: string;
|
|
176
|
-
enumType: Import;
|
|
177
|
-
enumDetailType: Import;
|
|
178
|
-
enumDetailsType: Import;
|
|
179
|
-
enumRows: EnumRow[];
|
|
180
|
-
/** Whether the join table has a surrogate `id` PK; if false the FK pair is the composite PK. */
|
|
181
|
-
hasJoinTableId: boolean;
|
|
182
|
-
};
|
|
183
|
-
/** I.e. a `Comment.parent` reference that groups `comments.parent_book_id` and `comments.parent_book_review_id`. */
|
|
184
|
-
export type PolymorphicField = Field & {
|
|
185
|
-
kind: "poly";
|
|
186
|
-
fieldType: string;
|
|
187
|
-
notNull: boolean;
|
|
188
|
-
hasConfigDefault: boolean;
|
|
189
|
-
components: PolymorphicFieldComponent[];
|
|
190
|
-
};
|
|
191
|
-
export type PolymorphicFieldComponent = {
|
|
192
|
-
columnName: string;
|
|
193
|
-
otherFieldName: string;
|
|
194
|
-
otherEntity: Entity;
|
|
195
|
-
isDeferredAndDeferrable: boolean;
|
|
196
|
-
constraintName: string;
|
|
197
|
-
notNull: false;
|
|
198
|
-
};
|
|
199
|
-
export type FieldNameOverrides = {
|
|
200
|
-
fieldName?: string;
|
|
201
|
-
otherFieldName?: string;
|
|
202
|
-
};
|
|
203
|
-
/** Adapts the generally-great pg-structure metadata into our specific ORM types. */
|
|
204
|
-
export declare class EntityDbMetadata {
|
|
205
|
-
entity: Entity;
|
|
206
|
-
primaryKey: PrimitiveField;
|
|
207
|
-
primitives: PrimitiveField[];
|
|
208
|
-
enums: EnumField[];
|
|
209
|
-
pgEnums: PgEnumField[];
|
|
210
|
-
manyToOnes: ManyToOneField[];
|
|
211
|
-
oneToManys: OneToManyField[];
|
|
212
|
-
largeOneToManys: OneToManyField[];
|
|
213
|
-
oneToOnes: OneToOneField[];
|
|
214
|
-
manyToManys: ManyToManyField[];
|
|
215
|
-
largeManyToManys: ManyToManyField[];
|
|
216
|
-
manyToManyEnums: ManyToManyEnumField[];
|
|
217
|
-
polymorphics: PolymorphicField[];
|
|
218
|
-
tableName: string;
|
|
219
|
-
tagName: string;
|
|
220
|
-
createdAt: PrimitiveField | undefined;
|
|
221
|
-
updatedAt: PrimitiveField | undefined;
|
|
222
|
-
deletedAt: PrimitiveField | undefined;
|
|
223
|
-
baseClassName: string | undefined;
|
|
224
|
-
baseType: EntityDbMetadata | undefined;
|
|
225
|
-
subTypes: EntityDbMetadata[];
|
|
226
|
-
inheritanceType: "sti" | "cti" | undefined;
|
|
227
|
-
/** This will only be set on the base meta. */
|
|
228
|
-
stiDiscriminatorField?: string;
|
|
229
|
-
/** This will only be set on the sub metas. */
|
|
230
|
-
stiDiscriminatorValue?: number;
|
|
231
|
-
abstract: boolean;
|
|
232
|
-
nonDeferredFkOrder: number;
|
|
233
|
-
uniqueConstraints?: string[][];
|
|
234
|
-
constructor(config: Config, table: Table, enums?: EnumMetadata);
|
|
235
|
-
get name(): string;
|
|
236
|
-
get nonDeferredFks(): Array<ManyToOneField | PolymorphicFieldComponent>;
|
|
237
|
-
get nonDeferredManyToManyFks(): Array<ManyToManyField>;
|
|
238
|
-
}
|
|
239
|
-
/** Finds the field name for o2o side of a o2o/m2o. */
|
|
240
|
-
export declare function oneToOneName(config: Config, refEntity: Entity, keyEntity: Entity, r: M2ORelation | O2MRelation): string;
|
|
241
|
-
export declare function referenceName(config: Config, entity: Entity, r: M2ORelation | O2MRelation): string;
|
|
242
|
-
export declare function manyToManyName(column: Column): string;
|
|
243
|
-
/** Returns the collection name to use on `entity` when referring to `otherEntity`s. */
|
|
244
|
-
export declare function collectionName(config: Config, singleEntity: Entity, collectionEntity: Entity, r: M2ORelation | O2MRelation | M2MRelation): {
|
|
245
|
-
fieldName: string;
|
|
246
|
-
singularName: string;
|
|
247
|
-
};
|
|
248
|
-
export declare function failIfOverlappingFieldNames(entity: EntityDbMetadata): void;
|
|
249
|
-
export declare function makeEntity(entityName: string): Entity;
|
|
250
|
-
/**
|
|
251
|
-
* Collapses the per-relation `otherEntity` copies down to the one primary `Entity` per name.
|
|
252
|
-
*
|
|
253
|
-
* `makeEntity` mints a fresh `Entity` for every relation's `otherEntity`, so each entity ends up with
|
|
254
|
-
* many duplicate objects floating around. Pointing them all at the single `entitiesByName[name].entity`
|
|
255
|
-
* instance means later passes (i.e. `resolveNameConflicts`) only have to update one object per name.
|
|
256
|
-
*
|
|
257
|
-
* Must run after inheritance, since STI/CTI specialization both adds and re-points `otherEntity`s.
|
|
258
|
-
*/
|
|
259
|
-
export declare function canonicalizeOtherEntities(db: DbMetadata): void;
|
|
260
|
-
/**
|
|
261
|
-
* Rewrites codegen'd type names that collide with another exported type name.
|
|
262
|
-
*
|
|
263
|
-
* `makeEntity` defaults each name to the conventional `${name}<Suffix>`, but if a separate entity or
|
|
264
|
-
* enum is literally named e.g. `AuthorScope` or `AuthorOrder`, our generated type of the same name
|
|
265
|
-
* would collide with it, so we fall back to `Author_Scope` / `Author_Order`.
|
|
266
|
-
*
|
|
267
|
-
* Relies on `canonicalizeOtherEntities` having run, so mutating each primary `meta.entity` also updates
|
|
268
|
-
* the `otherEntity` references that point at it (e.g. `Book.author: AuthorId` follows `Author`'s rename).
|
|
269
|
-
*/
|
|
270
|
-
export declare function resolveNameConflicts(config: Config, db: DbMetadata): void;
|
|
271
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type Config } from "../config";
|
|
2
|
-
/**
|
|
3
|
-
* A generic interface for Joist codemods.
|
|
4
|
-
*
|
|
5
|
-
* This can either be traditional jscodeshift mods that change the AST, or
|
|
6
|
-
* also "dumber" mods that `mv` files around.
|
|
7
|
-
*/
|
|
8
|
-
export type Codemod = {
|
|
9
|
-
codemodVersion: number;
|
|
10
|
-
name: string;
|
|
11
|
-
description: string;
|
|
12
|
-
run(config: Config): Promise<void>;
|
|
13
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Codemod.js","sourceRoot":"","sources":["../../src/codemods/Codemod.ts"],"names":[],"mappings":""}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type Config } from "../config";
|
|
2
|
-
import { type Codemod } from "./Codemod";
|
|
3
|
-
export declare class JscodeshiftMod implements Codemod {
|
|
4
|
-
codemodVersion: number;
|
|
5
|
-
name: string;
|
|
6
|
-
description: string;
|
|
7
|
-
private glob;
|
|
8
|
-
constructor(codemodVersion: number, name: string, description: string, glob?: (config: Config) => string);
|
|
9
|
-
run(config: Config): Promise<void>;
|
|
10
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type Transform } from "jscodeshift";
|
|
2
|
-
import { JscodeshiftMod } from "./JscodeshiftMod";
|
|
3
|
-
export declare const codemod_0001_rename_has_async_property: JscodeshiftMod;
|
|
4
|
-
/** Find/replace the various `*AsyncProperty*` symbols with their `*Property*` counterparts. */
|
|
5
|
-
declare const transform: Transform;
|
|
6
|
-
export default transform;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type Transform } from "jscodeshift";
|
|
2
|
-
import { JscodeshiftMod } from "./JscodeshiftMod";
|
|
3
|
-
export declare const codemod_0002_rename_async_query_fields: JscodeshiftMod;
|
|
4
|
-
/** Find/replace the async query symbols with their async property/field counterparts. */
|
|
5
|
-
declare const transform: Transform;
|
|
6
|
-
export default transform;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type Transform } from "jscodeshift";
|
|
2
|
-
import { JscodeshiftMod } from "./JscodeshiftMod";
|
|
3
|
-
export declare const codemod_0003_rename_find_paginated: JscodeshiftMod;
|
|
4
|
-
/** Rewrites EntityManager paginated find method calls to the now-paginated find APIs. */
|
|
5
|
-
declare const transform: Transform;
|
|
6
|
-
export default transform;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type Config } from "../config";
|
|
2
|
-
import { type Codemod } from "./Codemod";
|
|
3
|
-
/** Prompts for and runs pending codemods for the user's project. */
|
|
4
|
-
export declare function maybeRunTransforms(config: Config): Promise<void>;
|
|
5
|
-
/** Returns the highest codemod counter known by this version of codegen. */
|
|
6
|
-
export declare function getLatestCodemodVersion(): number;
|
|
7
|
-
/** Returns codemods that have not yet been applied to the user's project. */
|
|
8
|
-
export declare function findApplicableCodemods(codemodVersion: number): Codemod[];
|