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