@snowtop/ent 0.1.0-alpha160-test6 → 0.1.0-alpha160

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.
Files changed (317) hide show
  1. package/core/query/shared_assoc_test.d.ts +2 -0
  2. package/core/query/shared_assoc_test.js +804 -0
  3. package/core/query/shared_test.d.ts +21 -0
  4. package/core/query/shared_test.js +736 -0
  5. package/graphql/query/shared_assoc_test.d.ts +1 -0
  6. package/graphql/query/shared_assoc_test.js +203 -0
  7. package/package.json +6 -48
  8. package/{dist/scripts → scripts}/custom_compiler.js +0 -0
  9. package/{dist/scripts → scripts}/custom_graphql.js +0 -0
  10. package/dist/package.json +0 -64
  11. package/src/action/action.ts +0 -330
  12. package/src/action/executor.ts +0 -453
  13. package/src/action/experimental_action.ts +0 -277
  14. package/src/action/index.ts +0 -31
  15. package/src/action/operations.ts +0 -967
  16. package/src/action/orchestrator.ts +0 -1527
  17. package/src/action/privacy.ts +0 -37
  18. package/src/action/relative_value.ts +0 -242
  19. package/src/action/transaction.ts +0 -38
  20. package/src/auth/auth.ts +0 -77
  21. package/src/auth/index.ts +0 -8
  22. package/src/core/base.ts +0 -367
  23. package/src/core/clause.ts +0 -1065
  24. package/src/core/config.ts +0 -219
  25. package/src/core/const.ts +0 -5
  26. package/src/core/context.ts +0 -135
  27. package/src/core/convert.ts +0 -106
  28. package/src/core/date.ts +0 -23
  29. package/src/core/db.ts +0 -498
  30. package/src/core/ent.ts +0 -1740
  31. package/src/core/global_schema.ts +0 -49
  32. package/src/core/loaders/assoc_count_loader.ts +0 -99
  33. package/src/core/loaders/assoc_edge_loader.ts +0 -250
  34. package/src/core/loaders/index.ts +0 -12
  35. package/src/core/loaders/loader.ts +0 -66
  36. package/src/core/loaders/object_loader.ts +0 -489
  37. package/src/core/loaders/query_loader.ts +0 -314
  38. package/src/core/loaders/raw_count_loader.ts +0 -175
  39. package/src/core/logger.ts +0 -49
  40. package/src/core/privacy.ts +0 -660
  41. package/src/core/query/assoc_query.ts +0 -240
  42. package/src/core/query/custom_clause_query.ts +0 -174
  43. package/src/core/query/custom_query.ts +0 -302
  44. package/src/core/query/index.ts +0 -9
  45. package/src/core/query/query.ts +0 -674
  46. package/src/core/query_impl.ts +0 -32
  47. package/src/core/viewer.ts +0 -52
  48. package/src/ent.code-workspace +0 -73
  49. package/src/graphql/builtins/connection.ts +0 -25
  50. package/src/graphql/builtins/edge.ts +0 -16
  51. package/src/graphql/builtins/node.ts +0 -12
  52. package/src/graphql/graphql.ts +0 -891
  53. package/src/graphql/graphql_field_helpers.ts +0 -221
  54. package/src/graphql/index.ts +0 -42
  55. package/src/graphql/mutations/union.ts +0 -39
  56. package/src/graphql/node_resolver.ts +0 -122
  57. package/src/graphql/query/connection_type.ts +0 -113
  58. package/src/graphql/query/edge_connection.ts +0 -171
  59. package/src/graphql/query/page_info.ts +0 -34
  60. package/src/graphql/query/shared_edge_connection.ts +0 -287
  61. package/src/graphql/scalars/orderby_direction.ts +0 -13
  62. package/src/graphql/scalars/time.ts +0 -38
  63. package/src/imports/dataz/example1/_auth.ts +0 -51
  64. package/src/imports/dataz/example1/_viewer.ts +0 -35
  65. package/src/imports/index.ts +0 -213
  66. package/src/index.ts +0 -145
  67. package/src/parse_schema/parse.ts +0 -585
  68. package/src/schema/base_schema.ts +0 -224
  69. package/src/schema/field.ts +0 -1087
  70. package/src/schema/index.ts +0 -53
  71. package/src/schema/json_field.ts +0 -94
  72. package/src/schema/schema.ts +0 -1028
  73. package/src/schema/struct_field.ts +0 -234
  74. package/src/schema/union_field.ts +0 -105
  75. package/src/scripts/custom_compiler.ts +0 -331
  76. package/src/scripts/custom_graphql.ts +0 -550
  77. package/src/scripts/migrate_v0.1.ts +0 -41
  78. package/src/scripts/move_types.ts +0 -131
  79. package/src/scripts/read_schema.ts +0 -67
  80. package/src/setupPackage.js +0 -42
  81. package/src/testutils/action/complex_schemas.ts +0 -517
  82. package/src/testutils/builder.ts +0 -422
  83. package/src/testutils/context/test_context.ts +0 -25
  84. package/src/testutils/db/fixture.ts +0 -32
  85. package/src/testutils/db/temp_db.ts +0 -941
  86. package/src/testutils/db/value.ts +0 -294
  87. package/src/testutils/db_mock.ts +0 -351
  88. package/src/testutils/db_time_zone.ts +0 -40
  89. package/src/testutils/ent-graphql-tests/index.ts +0 -653
  90. package/src/testutils/fake_comms.ts +0 -50
  91. package/src/testutils/fake_data/const.ts +0 -64
  92. package/src/testutils/fake_data/events_query.ts +0 -145
  93. package/src/testutils/fake_data/fake_contact.ts +0 -150
  94. package/src/testutils/fake_data/fake_event.ts +0 -150
  95. package/src/testutils/fake_data/fake_tag.ts +0 -139
  96. package/src/testutils/fake_data/fake_user.ts +0 -232
  97. package/src/testutils/fake_data/index.ts +0 -1
  98. package/src/testutils/fake_data/internal.ts +0 -8
  99. package/src/testutils/fake_data/tag_query.ts +0 -56
  100. package/src/testutils/fake_data/test_helpers.ts +0 -388
  101. package/src/testutils/fake_data/user_query.ts +0 -524
  102. package/src/testutils/fake_log.ts +0 -52
  103. package/src/testutils/mock_date.ts +0 -10
  104. package/src/testutils/mock_log.ts +0 -39
  105. package/src/testutils/parse_sql.ts +0 -685
  106. package/src/testutils/test_edge_global_schema.ts +0 -49
  107. package/src/testutils/write.ts +0 -70
  108. package/src/tsc/ast.ts +0 -351
  109. package/src/tsc/compilerOptions.ts +0 -85
  110. package/src/tsc/move_generated.ts +0 -191
  111. package/src/tsc/transform.ts +0 -226
  112. package/src/tsc/transform_action.ts +0 -224
  113. package/src/tsc/transform_ent.ts +0 -66
  114. package/src/tsc/transform_schema.ts +0 -546
  115. package/tsconfig.json +0 -20
  116. /package/{dist/action → action}/action.d.ts +0 -0
  117. /package/{dist/action → action}/action.js +0 -0
  118. /package/{dist/action → action}/executor.d.ts +0 -0
  119. /package/{dist/action → action}/executor.js +0 -0
  120. /package/{dist/action → action}/experimental_action.d.ts +0 -0
  121. /package/{dist/action → action}/experimental_action.js +0 -0
  122. /package/{dist/action → action}/index.d.ts +0 -0
  123. /package/{dist/action → action}/index.js +0 -0
  124. /package/{dist/action → action}/operations.d.ts +0 -0
  125. /package/{dist/action → action}/operations.js +0 -0
  126. /package/{dist/action → action}/orchestrator.d.ts +0 -0
  127. /package/{dist/action → action}/orchestrator.js +0 -0
  128. /package/{dist/action → action}/privacy.d.ts +0 -0
  129. /package/{dist/action → action}/privacy.js +0 -0
  130. /package/{dist/action → action}/relative_value.d.ts +0 -0
  131. /package/{dist/action → action}/relative_value.js +0 -0
  132. /package/{dist/action → action}/transaction.d.ts +0 -0
  133. /package/{dist/action → action}/transaction.js +0 -0
  134. /package/{dist/auth → auth}/auth.d.ts +0 -0
  135. /package/{dist/auth → auth}/auth.js +0 -0
  136. /package/{dist/auth → auth}/index.d.ts +0 -0
  137. /package/{dist/auth → auth}/index.js +0 -0
  138. /package/{dist/core → core}/base.d.ts +0 -0
  139. /package/{dist/core → core}/base.js +0 -0
  140. /package/{dist/core → core}/clause.d.ts +0 -0
  141. /package/{dist/core → core}/clause.js +0 -0
  142. /package/{dist/core → core}/config.d.ts +0 -0
  143. /package/{dist/core → core}/config.js +0 -0
  144. /package/{dist/core → core}/const.d.ts +0 -0
  145. /package/{dist/core → core}/const.js +0 -0
  146. /package/{dist/core → core}/context.d.ts +0 -0
  147. /package/{dist/core → core}/context.js +0 -0
  148. /package/{dist/core → core}/convert.d.ts +0 -0
  149. /package/{dist/core → core}/convert.js +0 -0
  150. /package/{dist/core → core}/date.d.ts +0 -0
  151. /package/{dist/core → core}/date.js +0 -0
  152. /package/{dist/core → core}/db.d.ts +0 -0
  153. /package/{dist/core → core}/db.js +0 -0
  154. /package/{dist/core → core}/ent.d.ts +0 -0
  155. /package/{dist/core → core}/ent.js +0 -0
  156. /package/{dist/core → core}/global_schema.d.ts +0 -0
  157. /package/{dist/core → core}/global_schema.js +0 -0
  158. /package/{dist/core → core}/loaders/assoc_count_loader.d.ts +0 -0
  159. /package/{dist/core → core}/loaders/assoc_count_loader.js +0 -0
  160. /package/{dist/core → core}/loaders/assoc_edge_loader.d.ts +0 -0
  161. /package/{dist/core → core}/loaders/assoc_edge_loader.js +0 -0
  162. /package/{dist/core → core}/loaders/index.d.ts +0 -0
  163. /package/{dist/core → core}/loaders/index.js +0 -0
  164. /package/{dist/core → core}/loaders/loader.d.ts +0 -0
  165. /package/{dist/core → core}/loaders/loader.js +0 -0
  166. /package/{dist/core → core}/loaders/object_loader.d.ts +0 -0
  167. /package/{dist/core → core}/loaders/object_loader.js +0 -0
  168. /package/{dist/core → core}/loaders/query_loader.d.ts +0 -0
  169. /package/{dist/core → core}/loaders/query_loader.js +0 -0
  170. /package/{dist/core → core}/loaders/raw_count_loader.d.ts +0 -0
  171. /package/{dist/core → core}/loaders/raw_count_loader.js +0 -0
  172. /package/{dist/core → core}/logger.d.ts +0 -0
  173. /package/{dist/core → core}/logger.js +0 -0
  174. /package/{dist/core → core}/privacy.d.ts +0 -0
  175. /package/{dist/core → core}/privacy.js +0 -0
  176. /package/{dist/core → core}/query/assoc_query.d.ts +0 -0
  177. /package/{dist/core → core}/query/assoc_query.js +0 -0
  178. /package/{dist/core → core}/query/custom_clause_query.d.ts +0 -0
  179. /package/{dist/core → core}/query/custom_clause_query.js +0 -0
  180. /package/{dist/core → core}/query/custom_query.d.ts +0 -0
  181. /package/{dist/core → core}/query/custom_query.js +0 -0
  182. /package/{dist/core → core}/query/index.d.ts +0 -0
  183. /package/{dist/core → core}/query/index.js +0 -0
  184. /package/{dist/core → core}/query/query.d.ts +0 -0
  185. /package/{dist/core → core}/query/query.js +0 -0
  186. /package/{dist/core → core}/query_impl.d.ts +0 -0
  187. /package/{dist/core → core}/query_impl.js +0 -0
  188. /package/{dist/core → core}/viewer.d.ts +0 -0
  189. /package/{dist/core → core}/viewer.js +0 -0
  190. /package/{dist/graphql → graphql}/builtins/connection.d.ts +0 -0
  191. /package/{dist/graphql → graphql}/builtins/connection.js +0 -0
  192. /package/{dist/graphql → graphql}/builtins/edge.d.ts +0 -0
  193. /package/{dist/graphql → graphql}/builtins/edge.js +0 -0
  194. /package/{dist/graphql → graphql}/builtins/node.d.ts +0 -0
  195. /package/{dist/graphql → graphql}/builtins/node.js +0 -0
  196. /package/{dist/graphql → graphql}/graphql.d.ts +0 -0
  197. /package/{dist/graphql → graphql}/graphql.js +0 -0
  198. /package/{dist/graphql → graphql}/graphql_field_helpers.d.ts +0 -0
  199. /package/{dist/graphql → graphql}/graphql_field_helpers.js +0 -0
  200. /package/{dist/graphql → graphql}/index.d.ts +0 -0
  201. /package/{dist/graphql → graphql}/index.js +0 -0
  202. /package/{dist/graphql → graphql}/mutations/union.d.ts +0 -0
  203. /package/{dist/graphql → graphql}/mutations/union.js +0 -0
  204. /package/{dist/graphql → graphql}/node_resolver.d.ts +0 -0
  205. /package/{dist/graphql → graphql}/node_resolver.js +0 -0
  206. /package/{dist/graphql → graphql}/query/connection_type.d.ts +0 -0
  207. /package/{dist/graphql → graphql}/query/connection_type.js +0 -0
  208. /package/{dist/graphql → graphql}/query/edge_connection.d.ts +0 -0
  209. /package/{dist/graphql → graphql}/query/edge_connection.js +0 -0
  210. /package/{dist/graphql → graphql}/query/page_info.d.ts +0 -0
  211. /package/{dist/graphql → graphql}/query/page_info.js +0 -0
  212. /package/{dist/graphql → graphql}/query/shared_edge_connection.d.ts +0 -0
  213. /package/{dist/graphql → graphql}/query/shared_edge_connection.js +0 -0
  214. /package/{dist/graphql → graphql}/scalars/orderby_direction.d.ts +0 -0
  215. /package/{dist/graphql → graphql}/scalars/orderby_direction.js +0 -0
  216. /package/{dist/graphql → graphql}/scalars/time.d.ts +0 -0
  217. /package/{dist/graphql → graphql}/scalars/time.js +0 -0
  218. /package/{dist/imports → imports}/dataz/example1/_auth.d.ts +0 -0
  219. /package/{dist/imports → imports}/dataz/example1/_auth.js +0 -0
  220. /package/{dist/imports → imports}/dataz/example1/_viewer.d.ts +0 -0
  221. /package/{dist/imports → imports}/dataz/example1/_viewer.js +0 -0
  222. /package/{dist/imports → imports}/index.d.ts +0 -0
  223. /package/{dist/imports → imports}/index.js +0 -0
  224. /package/{dist/index.d.ts → index.d.ts} +0 -0
  225. /package/{dist/index.js → index.js} +0 -0
  226. /package/{dist/parse_schema → parse_schema}/parse.d.ts +0 -0
  227. /package/{dist/parse_schema → parse_schema}/parse.js +0 -0
  228. /package/{dist/schema → schema}/base_schema.d.ts +0 -0
  229. /package/{dist/schema → schema}/base_schema.js +0 -0
  230. /package/{dist/schema → schema}/field.d.ts +0 -0
  231. /package/{dist/schema → schema}/field.js +0 -0
  232. /package/{dist/schema → schema}/index.d.ts +0 -0
  233. /package/{dist/schema → schema}/index.js +0 -0
  234. /package/{dist/schema → schema}/json_field.d.ts +0 -0
  235. /package/{dist/schema → schema}/json_field.js +0 -0
  236. /package/{dist/schema → schema}/schema.d.ts +0 -0
  237. /package/{dist/schema → schema}/schema.js +0 -0
  238. /package/{dist/schema → schema}/struct_field.d.ts +0 -0
  239. /package/{dist/schema → schema}/struct_field.js +0 -0
  240. /package/{dist/schema → schema}/union_field.d.ts +0 -0
  241. /package/{dist/schema → schema}/union_field.js +0 -0
  242. /package/{dist/scripts → scripts}/custom_compiler.d.ts +0 -0
  243. /package/{dist/scripts → scripts}/custom_graphql.d.ts +0 -0
  244. /package/{dist/scripts → scripts}/migrate_v0.1.d.ts +0 -0
  245. /package/{dist/scripts → scripts}/migrate_v0.1.js +0 -0
  246. /package/{dist/scripts → scripts}/move_types.d.ts +0 -0
  247. /package/{dist/scripts → scripts}/move_types.js +0 -0
  248. /package/{dist/scripts → scripts}/read_schema.d.ts +0 -0
  249. /package/{dist/scripts → scripts}/read_schema.js +0 -0
  250. /package/{dist/testutils → testutils}/action/complex_schemas.d.ts +0 -0
  251. /package/{dist/testutils → testutils}/action/complex_schemas.js +0 -0
  252. /package/{dist/testutils → testutils}/builder.d.ts +0 -0
  253. /package/{dist/testutils → testutils}/builder.js +0 -0
  254. /package/{dist/testutils → testutils}/context/test_context.d.ts +0 -0
  255. /package/{dist/testutils → testutils}/context/test_context.js +0 -0
  256. /package/{dist/testutils → testutils}/db/fixture.d.ts +0 -0
  257. /package/{dist/testutils → testutils}/db/fixture.js +0 -0
  258. /package/{dist/testutils → testutils}/db/temp_db.d.ts +0 -0
  259. /package/{dist/testutils → testutils}/db/temp_db.js +0 -0
  260. /package/{dist/testutils → testutils}/db/value.d.ts +0 -0
  261. /package/{dist/testutils → testutils}/db/value.js +0 -0
  262. /package/{dist/testutils → testutils}/db_mock.d.ts +0 -0
  263. /package/{dist/testutils → testutils}/db_mock.js +0 -0
  264. /package/{dist/testutils → testutils}/db_time_zone.d.ts +0 -0
  265. /package/{dist/testutils → testutils}/db_time_zone.js +0 -0
  266. /package/{dist/testutils → testutils}/ent-graphql-tests/index.d.ts +0 -0
  267. /package/{dist/testutils → testutils}/ent-graphql-tests/index.js +0 -0
  268. /package/{dist/testutils → testutils}/fake_comms.d.ts +0 -0
  269. /package/{dist/testutils → testutils}/fake_comms.js +0 -0
  270. /package/{dist/testutils → testutils}/fake_data/const.d.ts +0 -0
  271. /package/{dist/testutils → testutils}/fake_data/const.js +0 -0
  272. /package/{dist/testutils → testutils}/fake_data/events_query.d.ts +0 -0
  273. /package/{dist/testutils → testutils}/fake_data/events_query.js +0 -0
  274. /package/{dist/testutils → testutils}/fake_data/fake_contact.d.ts +0 -0
  275. /package/{dist/testutils → testutils}/fake_data/fake_contact.js +0 -0
  276. /package/{dist/testutils → testutils}/fake_data/fake_event.d.ts +0 -0
  277. /package/{dist/testutils → testutils}/fake_data/fake_event.js +0 -0
  278. /package/{dist/testutils → testutils}/fake_data/fake_tag.d.ts +0 -0
  279. /package/{dist/testutils → testutils}/fake_data/fake_tag.js +0 -0
  280. /package/{dist/testutils → testutils}/fake_data/fake_user.d.ts +0 -0
  281. /package/{dist/testutils → testutils}/fake_data/fake_user.js +0 -0
  282. /package/{dist/testutils → testutils}/fake_data/index.d.ts +0 -0
  283. /package/{dist/testutils → testutils}/fake_data/index.js +0 -0
  284. /package/{dist/testutils → testutils}/fake_data/internal.d.ts +0 -0
  285. /package/{dist/testutils → testutils}/fake_data/internal.js +0 -0
  286. /package/{dist/testutils → testutils}/fake_data/tag_query.d.ts +0 -0
  287. /package/{dist/testutils → testutils}/fake_data/tag_query.js +0 -0
  288. /package/{dist/testutils → testutils}/fake_data/test_helpers.d.ts +0 -0
  289. /package/{dist/testutils → testutils}/fake_data/test_helpers.js +0 -0
  290. /package/{dist/testutils → testutils}/fake_data/user_query.d.ts +0 -0
  291. /package/{dist/testutils → testutils}/fake_data/user_query.js +0 -0
  292. /package/{dist/testutils → testutils}/fake_log.d.ts +0 -0
  293. /package/{dist/testutils → testutils}/fake_log.js +0 -0
  294. /package/{dist/testutils → testutils}/mock_date.d.ts +0 -0
  295. /package/{dist/testutils → testutils}/mock_date.js +0 -0
  296. /package/{dist/testutils → testutils}/mock_log.d.ts +0 -0
  297. /package/{dist/testutils → testutils}/mock_log.js +0 -0
  298. /package/{dist/testutils → testutils}/parse_sql.d.ts +0 -0
  299. /package/{dist/testutils → testutils}/parse_sql.js +0 -0
  300. /package/{dist/testutils → testutils}/test_edge_global_schema.d.ts +0 -0
  301. /package/{dist/testutils → testutils}/test_edge_global_schema.js +0 -0
  302. /package/{dist/testutils → testutils}/write.d.ts +0 -0
  303. /package/{dist/testutils → testutils}/write.js +0 -0
  304. /package/{dist/tsc → tsc}/ast.d.ts +0 -0
  305. /package/{dist/tsc → tsc}/ast.js +0 -0
  306. /package/{dist/tsc → tsc}/compilerOptions.d.ts +0 -0
  307. /package/{dist/tsc → tsc}/compilerOptions.js +0 -0
  308. /package/{dist/tsc → tsc}/move_generated.d.ts +0 -0
  309. /package/{dist/tsc → tsc}/move_generated.js +0 -0
  310. /package/{dist/tsc → tsc}/transform.d.ts +0 -0
  311. /package/{dist/tsc → tsc}/transform.js +0 -0
  312. /package/{dist/tsc → tsc}/transform_action.d.ts +0 -0
  313. /package/{dist/tsc → tsc}/transform_action.js +0 -0
  314. /package/{dist/tsc → tsc}/transform_ent.d.ts +0 -0
  315. /package/{dist/tsc → tsc}/transform_ent.js +0 -0
  316. /package/{dist/tsc → tsc}/transform_schema.d.ts +0 -0
  317. /package/{dist/tsc → tsc}/transform_schema.js +0 -0
@@ -1,941 +0,0 @@
1
- import { Client as PGClient } from "pg";
2
- import DB, { Sqlite, Dialect, Client, SyncClient } from "../../core/db";
3
- // this should only be used in tests so we expect to be able to import without shenanigans
4
- import sqlite, { Database as SqliteDatabase } from "better-sqlite3";
5
- import { loadConfig } from "../../core/config";
6
- import * as fs from "fs";
7
- import { ConstraintType, DBType, Field, getFields } from "../../schema";
8
- import { snakeCase } from "snake-case";
9
- import { BuilderSchema, getTableName } from "../builder";
10
- import { Ent } from "../../core/base";
11
- import { testEdgeGlobalSchema } from "../test_edge_global_schema";
12
-
13
- interface SchemaItem {
14
- name: string;
15
- }
16
-
17
- interface Column extends SchemaItem {
18
- datatype(): string;
19
- nullable?: boolean; // defaults to false
20
- primaryKey?: boolean;
21
- unique?: boolean;
22
- default?: string;
23
- index?: boolean | indexOptions;
24
- foreignKey?: { table: string; col: string };
25
- }
26
-
27
- interface Constraint extends SchemaItem {
28
- generate(): string;
29
- postCreate?(): boolean;
30
- }
31
-
32
- interface Index extends SchemaItem {
33
- generate(): string;
34
- postCreate?(): boolean;
35
- }
36
-
37
- interface PostCreateIndex extends Index {
38
- postCreate(): boolean;
39
- }
40
-
41
- // TODO need a better shared name for Table|Type
42
- export interface CoreConcept {
43
- name: string;
44
-
45
- create(): string;
46
- postCreate?(): string[];
47
- drop(): string;
48
- }
49
-
50
- export interface Table extends CoreConcept {
51
- columns: Column[];
52
- constraints?: Constraint[];
53
- }
54
-
55
- type options = Pick<
56
- Column,
57
- "nullable" | "primaryKey" | "default" | "foreignKey" | "unique" | "index"
58
- >;
59
-
60
- export function primaryKey(name: string, cols: string[]): Constraint {
61
- return {
62
- name: name,
63
- generate() {
64
- return `CONSTRAINT ${name} PRIMARY KEY(${cols.join(",")})`;
65
- },
66
- };
67
- }
68
-
69
- export function foreignKey(
70
- name: string,
71
- cols: string[],
72
- fkey: { table: string; cols: string[] },
73
- ): Constraint {
74
- return {
75
- name,
76
- generate() {
77
- return `CONSTRAINT ${name} FOREIGN KEY(${cols.join(",")}) REFERENCES ${
78
- fkey.table
79
- }(${fkey.cols.join(",")})`;
80
- },
81
- };
82
- }
83
-
84
- export function check(name: string, condition: string): Constraint {
85
- return {
86
- name,
87
- generate() {
88
- return `CONSTRAINT ${name} CHECK(${condition})`;
89
- },
90
- };
91
- }
92
-
93
- function unique(name: string, cols: string[], tableName: string): Constraint {
94
- return {
95
- name,
96
- generate() {
97
- if (Dialect.SQLite === DB.getDialect()) {
98
- return `UNIQUE (${cols.join(",")})`;
99
- }
100
- return `ALTER TABLE ${tableName} ADD CONSTRAINT ${name} UNIQUE (${cols.join(
101
- ", ",
102
- )});`;
103
- },
104
- postCreate() {
105
- return Dialect.Postgres === DB.getDialect();
106
- },
107
- };
108
- }
109
-
110
- interface indexOptions {
111
- type?: string;
112
- unique?: boolean;
113
- }
114
-
115
- function isPostCreateIndex(s: SchemaItem): s is PostCreateIndex {
116
- return (
117
- (s as PostCreateIndex).postCreate !== undefined &&
118
- (s as PostCreateIndex).postCreate()
119
- );
120
- }
121
-
122
- export function index(
123
- tableName: string,
124
- cols: string[],
125
- opts?: indexOptions,
126
- ): Index {
127
- const name = `${tableName}_${cols.join("_")}_idx`;
128
- return {
129
- name,
130
- generate() {
131
- if (opts?.unique && Dialect.SQLite === DB.getDialect()) {
132
- return `UNIQUE (${cols.join(",")})`;
133
- }
134
- return `CREATE ${
135
- opts?.unique ? "UNIQUE " : ""
136
- }INDEX ${name} ON ${tableName} USING ${
137
- opts?.type || "btree"
138
- } (${cols.join(",")});`;
139
- },
140
- postCreate() {
141
- return Dialect.Postgres === DB.getDialect() && !!opts?.unique;
142
- },
143
- };
144
- }
145
-
146
- export function uuid(name: string, opts?: options): Column {
147
- return {
148
- name,
149
- datatype() {
150
- return "uuid";
151
- },
152
- ...opts,
153
- };
154
- }
155
-
156
- export function text(name: string, opts?: options): Column {
157
- return {
158
- name,
159
- datatype() {
160
- return "TEXT";
161
- },
162
- ...opts,
163
- };
164
- }
165
-
166
- export function enumCol(name: string, type: string): Column {
167
- return {
168
- name,
169
- datatype() {
170
- return type;
171
- },
172
- };
173
- }
174
-
175
- export function timestamp(name: string, opts?: options): Column {
176
- return {
177
- name,
178
- datatype() {
179
- return "TIMESTAMP WITHOUT TIME ZONE";
180
- },
181
- ...opts,
182
- };
183
- }
184
-
185
- export function timestamptz(name: string, opts?: options): Column {
186
- return {
187
- name,
188
- datatype() {
189
- if (DB.getDialect() === Dialect.Postgres) {
190
- return "TIMESTAMP WITH TIME ZONE";
191
- } else {
192
- return "TEXT";
193
- }
194
- },
195
- ...opts,
196
- };
197
- }
198
-
199
- export function time(name: string, opts?: options): Column {
200
- return {
201
- name,
202
- datatype() {
203
- return "TIME WITHOUT TIME ZONE";
204
- },
205
- ...opts,
206
- };
207
- }
208
-
209
- export function timetz(name: string, opts?: options): Column {
210
- return {
211
- name,
212
- datatype() {
213
- return "TIME WITH TIME ZONE";
214
- },
215
- ...opts,
216
- };
217
- }
218
-
219
- export function date(name: string, opts?: options): Column {
220
- return {
221
- name,
222
- datatype() {
223
- return "DATE";
224
- },
225
- ...opts,
226
- };
227
- }
228
-
229
- export function bool(name: string, opts?: options): Column {
230
- const dialect = DB.getDialect();
231
- if (opts?.default === "FALSE" && dialect === Dialect.SQLite) {
232
- opts.default = "0";
233
- }
234
- return {
235
- name,
236
- datatype() {
237
- if (dialect === Dialect.Postgres) {
238
- return "BOOLEAN";
239
- }
240
- return "INTEGER";
241
- },
242
- ...opts,
243
- };
244
- }
245
-
246
- export function integer(name: string, opts?: options): Column {
247
- return {
248
- name,
249
- datatype() {
250
- return "INTEGER";
251
- },
252
- ...opts,
253
- };
254
- }
255
-
256
- export function float(name: string, opts?: options): Column {
257
- return {
258
- name,
259
- datatype() {
260
- return "REAL";
261
- },
262
- ...opts,
263
- };
264
- }
265
-
266
- export function json(name: string, opts?: options): Column {
267
- return {
268
- name,
269
- datatype() {
270
- return "JSON";
271
- },
272
- ...opts,
273
- };
274
- }
275
-
276
- export function jsonb(name: string, opts?: options): Column {
277
- return {
278
- name,
279
- datatype() {
280
- return "JSONB";
281
- },
282
- ...opts,
283
- };
284
- }
285
-
286
- function list(name: string, col: Column, opts?: options): Column {
287
- return {
288
- name,
289
- datatype() {
290
- return `${col.datatype()}[]`;
291
- },
292
- ...opts,
293
- };
294
- }
295
-
296
- export function textList(name: string, opts?: options): Column {
297
- return list(name, text(name), opts);
298
- }
299
-
300
- export function integerList(name: string, opts?: options): Column {
301
- return list(name, integer(name), opts);
302
- }
303
-
304
- export function uuidList(name: string, opts?: options): Column {
305
- return list(name, uuid(name), opts);
306
- }
307
-
308
- export function timestampList(name: string, opts?: options): Column {
309
- return list(name, timestamp(name), opts);
310
- }
311
-
312
- export function timestamptzList(name: string, opts?: options): Column {
313
- return list(name, timestamptz(name), opts);
314
- }
315
-
316
- export function timeList(name: string, opts?: options): Column {
317
- return list(name, time(name), opts);
318
- }
319
-
320
- export function timetzList(name: string, opts?: options): Column {
321
- return list(name, timetz(name), opts);
322
- }
323
-
324
- export function dateList(name: string, opts?: options): Column {
325
- return list(name, date(name), opts);
326
- }
327
-
328
- export function boolList(name: string, opts?: options): Column {
329
- return list(name, bool(name), opts);
330
- }
331
-
332
- export function table(name: string, ...items: SchemaItem[]): Table {
333
- let cols: Column[] = [];
334
- let constraints: Constraint[] = [];
335
- let indexes: Index[] = [];
336
-
337
- for (const item of items) {
338
- if ((item as Column).datatype !== undefined) {
339
- const col = item as Column;
340
- if (col.index) {
341
- let opts: indexOptions = {
342
- type: "btree",
343
- };
344
- if (col.index === true) {
345
- opts = {
346
- type: "btree",
347
- };
348
- } else {
349
- opts = col.index;
350
- }
351
- indexes.push(index(name, [col.name], opts));
352
- }
353
-
354
- // add it as a constraint
355
- if (col.foreignKey) {
356
- constraints.push(
357
- foreignKey(`${name}_${col.name}_fkey`, [col.name], {
358
- table: col.foreignKey.table,
359
- cols: [col.foreignKey.col],
360
- }),
361
- );
362
- }
363
- cols.push(item as Column);
364
- } else if ((item as Constraint).generate !== undefined) {
365
- if (isPostCreateIndex(item) && item.postCreate()) {
366
- indexes.push(item);
367
- } else {
368
- constraints.push(item as Constraint);
369
- }
370
- }
371
- }
372
-
373
- return {
374
- name,
375
- columns: cols,
376
- constraints: constraints,
377
- create() {
378
- let schemaStr = cols.map((col) => {
379
- let parts = [col.name, col.datatype()];
380
- if (!col.nullable) {
381
- parts.push("NOT NULL");
382
- }
383
- if (col.primaryKey) {
384
- parts.push("PRIMARY KEY");
385
- }
386
- if (col.default !== undefined) {
387
- if (Dialect.SQLite === DB.getDialect()) {
388
- parts.push(`DEFAULT "${col.default}"`);
389
- } else {
390
- parts.push(`DEFAULT ${col.default}`);
391
- }
392
- }
393
-
394
- if (col.unique) {
395
- parts.push("UNIQUE");
396
- }
397
- return parts.join(" ");
398
- });
399
-
400
- constraints.forEach((constraint) =>
401
- schemaStr.push(constraint.generate()),
402
- );
403
-
404
- return `CREATE TABLE IF NOT EXISTS ${name} (\n ${schemaStr})`;
405
- },
406
- postCreate() {
407
- return indexes.map((index) => index.generate());
408
- },
409
- drop() {
410
- return `DROP TABLE IF EXISTS ${name}`;
411
- },
412
- };
413
- }
414
-
415
- export function enumType(name: string, values: string[]): CoreConcept {
416
- return {
417
- name,
418
- drop() {
419
- return `DROP TYPE ${name}`;
420
- },
421
- create() {
422
- return `CREATE TYPE ${name} as ENUM(${values.join(", ")})`;
423
- },
424
- };
425
- }
426
-
427
- function randomDB(): string {
428
- let str = Math.random().toString(16).substring(2);
429
-
430
- // always ensure it starts with an alpha character
431
- return "abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random() * 26)] + str;
432
- }
433
-
434
- interface TempDBOptions {
435
- dialect: Dialect;
436
- sqliteConnString?: string;
437
- tables?: CoreConcept[] | (() => CoreConcept[]);
438
- }
439
-
440
- export class TempDB {
441
- private db: string;
442
- private client: PGClient;
443
- private dbClient: PGClient;
444
- private tables = new Map<string, CoreConcept>();
445
- private dialect: Dialect;
446
- private sqlite: SqliteDatabase;
447
- private setTables: CoreConcept[] | (() => CoreConcept[]) | undefined;
448
- private sqliteConnString: string | undefined;
449
-
450
- constructor(dialect: Dialect, tables?: CoreConcept[] | (() => CoreConcept[]));
451
- constructor(opts: TempDBOptions);
452
- constructor(
453
- dialect: Dialect | TempDBOptions,
454
- tables?: CoreConcept[] | (() => CoreConcept[]),
455
- ) {
456
- if (typeof dialect === "string") {
457
- this.dialect = dialect;
458
- this.setTables = tables;
459
- } else {
460
- this.dialect = dialect.dialect;
461
- this.setTables = dialect.tables;
462
- this.sqliteConnString = dialect.sqliteConnString;
463
- }
464
- }
465
-
466
- getDialect() {
467
- return this.dialect;
468
- }
469
-
470
- // NB: this won't be set until after beforeAll() is called since it depends on
471
- // dialect being correctly set
472
- __getTables() {
473
- return this.tables;
474
- }
475
-
476
- async beforeAll(setupConnString: boolean = true) {
477
- if (this.dialect === Dialect.Postgres) {
478
- const user = process.env.POSTGRES_USER || "";
479
- const password = process.env.POSTGRES_PASSWORD || "";
480
-
481
- this.client = new PGClient({
482
- host: "localhost",
483
- user,
484
- password,
485
- });
486
- await this.client.connect();
487
-
488
- this.db = randomDB();
489
-
490
- await this.client.query(`CREATE DATABASE ${this.db}`);
491
-
492
- if (setupConnString) {
493
- delete process.env.DB_CONNECTION_STRING;
494
- let connStr = "";
495
- if (user && password) {
496
- connStr = `postgres://${user}:${password}@localhost:5432/${this.db}`;
497
- } else {
498
- connStr = `postgres://localhost/${this.db}?`;
499
- }
500
- DB.initDB({
501
- connectionString: connStr,
502
- cfg: {
503
- max: 100,
504
- idleTimeoutMillis: 100,
505
- },
506
- });
507
- } else {
508
- // will probably be setup via loadConfig
509
- delete process.env.DB_CONNECTION_STRING;
510
- }
511
-
512
- this.dbClient = new PGClient({
513
- host: "localhost",
514
- database: this.db,
515
- user,
516
- password,
517
- });
518
- await this.dbClient.connect();
519
- } else {
520
- let connString: string;
521
- if (this.sqliteConnString) {
522
- connString = this.sqliteConnString;
523
- } else {
524
- if (process.env.DB_CONNECTION_STRING === undefined) {
525
- throw new Error(
526
- `DB_CONNECTION_STRING required for sqlite if sqliteConnString is not set`,
527
- );
528
- }
529
- connString = process.env.DB_CONNECTION_STRING;
530
- }
531
- const filePath = connString.substr(10);
532
- this.sqlite = sqlite(filePath);
533
- }
534
-
535
- if (this.setTables) {
536
- let tables: CoreConcept[] = [];
537
- if (typeof this.setTables === "function") {
538
- tables = this.setTables();
539
- } else {
540
- tables = this.setTables;
541
- }
542
- tables.forEach((table) => this.tables.set(table.name, table));
543
- }
544
-
545
- for (const [_, table] of this.tables) {
546
- await this.createImpl(table);
547
- }
548
- }
549
-
550
- async createImpl(table: CoreConcept) {
551
- if (this.dialect == Dialect.Postgres) {
552
- await this.dbClient.query(table.create());
553
- if (table.postCreate) {
554
- for (const q of table.postCreate()) {
555
- await this.dbClient.query(q);
556
- }
557
- }
558
- } else {
559
- this.sqlite.exec(table.create());
560
- if (table.postCreate) {
561
- for (const q of table.postCreate()) {
562
- this.sqlite.exec(q);
563
- }
564
- }
565
- }
566
- }
567
-
568
- getSqliteClient(): SqliteDatabase {
569
- return this.sqlite;
570
- }
571
-
572
- getPostgresClient(): PGClient {
573
- return this.dbClient;
574
- }
575
-
576
- async afterAll() {
577
- if (this.dialect === Dialect.SQLite) {
578
- this.sqlite.close();
579
- if (!this.sqlite.memory) {
580
- const f = this.getSqliteClient().name;
581
- fs.rmSync(f);
582
- fs.rmSync(`${f}-shm`, {
583
- force: true,
584
- });
585
- fs.rmSync(`${f}-wal`, {
586
- force: true,
587
- });
588
- }
589
- return;
590
- }
591
-
592
- // end our connection to db
593
- await this.dbClient.end();
594
- // end any pool connection
595
- await DB.getInstance().endPool();
596
-
597
- // drop db
598
- await this.client.query(`DROP DATABASE ${this.db}`);
599
- // console.log(this.db);
600
-
601
- await this.client.end();
602
- }
603
-
604
- getDB(): string {
605
- return this.db;
606
- }
607
-
608
- async dropAll() {
609
- for (const [t, _] of this.tables) {
610
- await this.drop(t);
611
- }
612
- }
613
-
614
- async drop(...tables: string[]) {
615
- for (const tableName of tables) {
616
- const table = this.tables.get(tableName);
617
- if (!table) {
618
- continue;
619
- }
620
- if (this.dialect === Dialect.Postgres) {
621
- await this.dbClient.query(table.drop());
622
- } else {
623
- this.sqlite.exec(table.drop());
624
- }
625
- this.tables.delete(tableName);
626
- }
627
- }
628
-
629
- async create(...tables: CoreConcept[]) {
630
- for (const table of tables) {
631
- if (this.tables.has(table.name)) {
632
- throw new Error(`table with name ${table.name} already exists`);
633
- }
634
- await this.createImpl(table);
635
- this.tables.set(table.name, table);
636
- }
637
- }
638
- }
639
-
640
- export function assoc_edge_config_table() {
641
- return table(
642
- "assoc_edge_config",
643
- // edge_type and inverse_edge_type are text intentionally instead of uuid...
644
- text("edge_type", { primaryKey: true }),
645
- text("edge_name"),
646
- bool("symmetric_edge", { default: "FALSE" }),
647
- text("inverse_edge_type", { nullable: true }),
648
- text("edge_table"),
649
- timestamptz("created_at"),
650
- timestamptz("updated_at"),
651
- );
652
- }
653
-
654
- // if global flag is true, add any column from testEdgeGlobalSchema
655
- // up to caller to set/clear that as needed
656
- export function assoc_edge_table(
657
- name: string,
658
- global?: boolean,
659
- unique_edge?: boolean,
660
- ) {
661
- const items: SchemaItem[] = [
662
- uuid("id1"),
663
- text("id1_type"),
664
- // same as in assoc_edge_config_table
665
- text("edge_type"),
666
- uuid("id2"),
667
- text("id2_type"),
668
- timestamptz("time"),
669
- text("data", { nullable: true }),
670
- primaryKey(`${name}_pkey`, ["id1", "id2", "edge_type"]),
671
- ];
672
- if (unique_edge) {
673
- items.push(
674
- unique(`${name}_unique_id1_edge_type`, ["id1", "edge_type"], name),
675
- );
676
- }
677
- const t = table(name, ...items);
678
-
679
- if (global) {
680
- for (const k in testEdgeGlobalSchema.extraEdgeFields) {
681
- const col = getColumnFromField(
682
- k,
683
- testEdgeGlobalSchema.extraEdgeFields[k],
684
- Dialect.Postgres,
685
- );
686
- t.columns.push(col);
687
- }
688
- }
689
- return t;
690
- }
691
-
692
- interface setupOptions {
693
- disableDeleteAfterEachTest?: boolean;
694
- }
695
-
696
- export function setupSqlite(
697
- connString: string,
698
- tables: () => Table[],
699
- opts?: setupOptions,
700
- ) {
701
- let tdb: TempDB = new TempDB({
702
- dialect: Dialect.SQLite,
703
- tables,
704
- sqliteConnString: connString,
705
- });
706
-
707
- beforeAll(async () => {
708
- loadConfig({
709
- dbConnectionString: connString,
710
- });
711
- await tdb.beforeAll();
712
-
713
- const conn = DB.getInstance().getConnection();
714
- expect((conn as Sqlite).db.memory).toBe(false);
715
- });
716
-
717
- if (!opts?.disableDeleteAfterEachTest) {
718
- afterEach(async () => {
719
- const client = await DB.getInstance().getNewClient();
720
- for (const [key, _] of tdb.__getTables()) {
721
- const query = `delete from ${key}`;
722
- if (isSyncClient(client))
723
- if (client.execSync) {
724
- client.execSync(query);
725
- } else {
726
- await client.exec(query);
727
- }
728
- }
729
- });
730
- }
731
-
732
- afterAll(async () => {
733
- await tdb.afterAll();
734
-
735
- delete process.env.DB_CONNECTION_STRING;
736
- });
737
-
738
- return tdb;
739
- }
740
-
741
- export function setupPostgres(tables: () => Table[], opts?: setupOptions) {
742
- let tdb: TempDB;
743
- beforeAll(async () => {
744
- tdb = new TempDB(Dialect.Postgres, tables());
745
- await tdb.beforeAll();
746
- });
747
-
748
- // TODO need to fix this implementation...
749
- if (!opts?.disableDeleteAfterEachTest) {
750
- afterEach(async () => {
751
- const client = await DB.getInstance().getNewClient();
752
- for (const [key, _] of tdb.__getTables()) {
753
- const query = `delete from ${key}`;
754
- await client.exec(query);
755
- }
756
- client.release();
757
- });
758
- }
759
-
760
- afterAll(async () => {
761
- await tdb.afterAll();
762
- });
763
- }
764
-
765
- export async function doSQLiteTestFromSchemas(
766
- schemas: BuilderSchema<Ent>[],
767
- doTest: () => Promise<void>,
768
- db?: string,
769
- ) {
770
- const connString = `sqlite:///${db || randomDB()}.db`;
771
- const tables = schemas.map((schema) =>
772
- getSchemaTable(schema, Dialect.SQLite),
773
- );
774
- let tdb: TempDB = new TempDB(Dialect.SQLite, tables);
775
-
776
- process.env.DB_CONNECTION_STRING = connString;
777
- loadConfig();
778
- await tdb.beforeAll();
779
-
780
- await doTest();
781
-
782
- await tdb.afterAll();
783
- delete process.env.DB_CONNECTION_STRING;
784
-
785
- return tdb;
786
- }
787
-
788
- export function getSchemaTable(schema: BuilderSchema<Ent>, dialect: Dialect) {
789
- const fields = getFields(schema);
790
-
791
- const items: SchemaItem[] = [];
792
- for (const [fieldName, field] of fields) {
793
- items.push(getColumnFromField(fieldName, field, dialect));
794
- }
795
-
796
- const tableName = getTableName(schema);
797
-
798
- if (schema.constraints) {
799
- for (const constraint of schema.constraints) {
800
- switch (constraint.type) {
801
- case ConstraintType.PrimaryKey:
802
- items.push(primaryKey(constraint.name, constraint.columns));
803
- break;
804
- case ConstraintType.ForeignKey:
805
- if (!constraint.fkey) {
806
- throw new Error(`need 'fkey' field for foreign key constraint`);
807
- }
808
- items.push(
809
- foreignKey(constraint.name, constraint.columns, {
810
- table: constraint.fkey.tableName,
811
- cols: constraint.fkey.columns,
812
- }),
813
- );
814
- break;
815
-
816
- case ConstraintType.Check:
817
- if (!constraint.condition) {
818
- throw new Error(`need 'condition' field for check constraint`);
819
- }
820
- items.push(check(constraint.name, constraint.condition));
821
- break;
822
-
823
- case ConstraintType.Unique:
824
- items.push(unique(constraint.name, constraint.columns, tableName));
825
- break;
826
-
827
- default:
828
- throw new Error(`unknown constraint type ${constraint.type}`);
829
- }
830
- }
831
- }
832
- return table(tableName, ...items);
833
- }
834
-
835
- function getColumnForDbType(
836
- t: DBType,
837
- dialect: Dialect,
838
- ): ((name: string) => Column) | undefined {
839
- switch (t) {
840
- case DBType.UUID:
841
- if (dialect === Dialect.Postgres) {
842
- return uuid;
843
- }
844
- return text;
845
- case DBType.Int64ID:
846
- case DBType.Int:
847
- return integer;
848
- case DBType.Boolean:
849
- return bool;
850
- case DBType.Timestamp:
851
- return timestamp;
852
- case DBType.Timestamptz:
853
- return timestamptz;
854
- case DBType.String:
855
- case DBType.StringEnum:
856
- return text;
857
- case DBType.Float:
858
- return float;
859
- case DBType.Date:
860
- return date;
861
- case DBType.Time:
862
- return time;
863
- case DBType.Timetz:
864
- return timetz;
865
- case DBType.JSONB:
866
- return jsonb;
867
- case DBType.JSON:
868
- return json;
869
-
870
- default:
871
- return undefined;
872
- }
873
- }
874
-
875
- export function getColumnFromField(
876
- fieldName: string,
877
- f: Field,
878
- dialect: Dialect,
879
- ) {
880
- switch (f.type.dbType) {
881
- case DBType.List:
882
- const elemType = f.type.listElemType;
883
- if (elemType === undefined) {
884
- throw new Error(`unsupported list type with no elem type`);
885
- }
886
- const elemFn = getColumnForDbType(elemType.dbType, dialect);
887
- if (elemFn === undefined) {
888
- throw new Error(`unsupported type for ${elemType}`);
889
- }
890
- return list(storageKey(fieldName, f), elemFn("ignore"), buildOpts(f));
891
-
892
- default:
893
- const fn = getColumnForDbType(f.type.dbType, dialect);
894
- if (fn === undefined) {
895
- throw new Error(`unsupported type ${f.type.dbType}`);
896
- }
897
- return getColumn(fieldName, f, fn);
898
- }
899
- }
900
-
901
- function getColumn(
902
- fieldName: string,
903
- f: Field,
904
- col: (name: string, opts?: options) => Column,
905
- ) {
906
- return col(storageKey(fieldName, f), buildOpts(f));
907
- }
908
-
909
- function buildOpts(f: Field): options {
910
- let ret: options = {};
911
- if (f.primaryKey) {
912
- ret.primaryKey = true;
913
- }
914
- if (f.nullable) {
915
- ret.nullable = true;
916
- }
917
- if (f.foreignKey !== undefined) {
918
- console.error("TODO:foreign key not yet converted");
919
- // ret.foreignKey =
920
- }
921
- if (f.serverDefault) {
922
- ret.default = f.serverDefault;
923
- }
924
-
925
- if (f.unique) {
926
- ret.unique = true;
927
- }
928
- return ret;
929
- }
930
-
931
- function storageKey(fieldName: string, f: Field): string {
932
- if (f.storageKey) {
933
- return f.storageKey;
934
- }
935
-
936
- return snakeCase(fieldName);
937
- }
938
-
939
- function isSyncClient(client: Client): client is SyncClient {
940
- return (client as SyncClient).execSync !== undefined;
941
- }