@snowtop/ent 0.2.4 → 0.2.6

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 (98) hide show
  1. package/action/action.js +5 -5
  2. package/action/executor.d.ts +1 -1
  3. package/action/executor.js +4 -4
  4. package/action/experimental_action.d.ts +7 -4
  5. package/action/experimental_action.js +18 -8
  6. package/action/operations.js +17 -7
  7. package/action/orchestrator.d.ts +10 -2
  8. package/action/orchestrator.js +29 -31
  9. package/action/privacy.d.ts +2 -2
  10. package/action/relative_value.js +3 -3
  11. package/auth/auth.d.ts +0 -1
  12. package/auth/auth.js +4 -5
  13. package/core/base.js +5 -5
  14. package/core/clause.js +76 -67
  15. package/core/config.d.ts +1 -1
  16. package/core/config.js +22 -9
  17. package/core/context.d.ts +0 -1
  18. package/core/convert.d.ts +0 -1
  19. package/core/convert.js +16 -17
  20. package/core/date.js +1 -2
  21. package/core/db.js +17 -7
  22. package/core/ent.d.ts +2 -0
  23. package/core/ent.js +127 -92
  24. package/core/global_schema.js +6 -7
  25. package/core/loaders/assoc_count_loader.d.ts +2 -2
  26. package/core/loaders/assoc_count_loader.js +17 -7
  27. package/core/loaders/assoc_edge_loader.d.ts +2 -2
  28. package/core/loaders/assoc_edge_loader.js +44 -20
  29. package/core/loaders/cache_utils.d.ts +1 -0
  30. package/core/loaders/cache_utils.js +28 -0
  31. package/core/loaders/index.d.ts +1 -0
  32. package/core/loaders/index.js +4 -1
  33. package/core/loaders/loader.d.ts +2 -0
  34. package/core/loaders/loader.js +20 -3
  35. package/core/loaders/object_loader.d.ts +6 -4
  36. package/core/loaders/object_loader.js +86 -48
  37. package/core/loaders/query_loader.d.ts +2 -2
  38. package/core/loaders/query_loader.js +25 -9
  39. package/core/loaders/raw_count_loader.d.ts +2 -2
  40. package/core/loaders/raw_count_loader.js +22 -10
  41. package/core/logger.js +6 -7
  42. package/core/privacy.d.ts +2 -2
  43. package/core/privacy.js +4 -5
  44. package/core/query/assoc_query.js +17 -7
  45. package/core/query/query.js +17 -7
  46. package/core/query/shared_assoc_test.js +1 -2
  47. package/core/query_impl.js +4 -5
  48. package/core/viewer.d.ts +2 -2
  49. package/graphql/graphql_field_helpers.js +22 -22
  50. package/graphql/mutations/union.js +1 -2
  51. package/graphql/node_resolver.js +7 -7
  52. package/graphql/query/shared_assoc_test.js +1 -2
  53. package/graphql/scalars/date.js +8 -3
  54. package/graphql/scalars/time.d.ts +1 -1
  55. package/imports/dataz/example1/_auth.js +14 -10
  56. package/imports/index.js +18 -9
  57. package/index.js +17 -7
  58. package/names/names.js +61 -18
  59. package/package.json +14 -17
  60. package/parse_schema/parse.js +2 -3
  61. package/schema/binary_field.js +3 -3
  62. package/schema/field.js +45 -35
  63. package/schema/json_field.js +7 -7
  64. package/schema/schema.js +12 -12
  65. package/schema/struct_field.js +4 -4
  66. package/schema/union_field.js +3 -3
  67. package/scripts/custom_compiler.js +17 -7
  68. package/scripts/custom_graphql.js +17 -7
  69. package/scripts/fix_action_exports.js +17 -7
  70. package/scripts/move_types.js +17 -7
  71. package/scripts/read_schema.js +17 -7
  72. package/testutils/action/complex_schemas.js +28 -18
  73. package/testutils/builder.d.ts +1 -1
  74. package/testutils/builder.js +7 -7
  75. package/testutils/db/fixture.js +1 -2
  76. package/testutils/db/temp_db.js +54 -44
  77. package/testutils/db/value.js +3 -4
  78. package/testutils/db_mock.js +12 -0
  79. package/testutils/ent-graphql-tests/index.d.ts +3 -3
  80. package/testutils/ent-graphql-tests/index.js +27 -18
  81. package/testutils/fake_data/const.js +2 -2
  82. package/testutils/fake_data/fake_contact.js +20 -10
  83. package/testutils/fake_data/fake_event.js +20 -10
  84. package/testutils/fake_data/fake_tag.js +21 -11
  85. package/testutils/fake_data/fake_user.js +21 -11
  86. package/testutils/fake_data/test_helpers.js +17 -17
  87. package/testutils/fake_data/user_query.js +19 -9
  88. package/testutils/parse_sql.js +151 -43
  89. package/testutils/query.js +2 -3
  90. package/testutils/soft_delete.js +17 -7
  91. package/testutils/test_edge_global_schema.js +17 -7
  92. package/testutils/write.js +20 -11
  93. package/tsc/ast.js +27 -18
  94. package/tsc/compilerOptions.js +22 -13
  95. package/tsc/move_generated.js +18 -9
  96. package/tsc/transform.js +18 -9
  97. package/tsc/transform_action.js +17 -7
  98. package/tsc/transform_schema.js +17 -7
package/names/names.js CHANGED
@@ -1,10 +1,58 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._splitCamelCase = exports.toClassName = exports.toFieldName = exports.toFilePath = exports.toDBColumnOrTable = void 0;
4
- const camel_case_1 = require("camel-case");
5
- const pascal_case_1 = require("pascal-case");
6
- const snake_case_1 = require("snake-case");
3
+ exports.toDBColumnOrTable = toDBColumnOrTable;
4
+ exports.toFilePath = toFilePath;
5
+ exports.toFieldName = toFieldName;
6
+ exports.toClassName = toClassName;
7
+ exports._splitCamelCase = _splitCamelCase;
7
8
  // TODO tests and update functionality to match golang
9
+ function splitWords(input) {
10
+ if (!input) {
11
+ return [];
12
+ }
13
+ const parts = input.split(/[^A-Za-z0-9]+/).filter(Boolean);
14
+ const words = [];
15
+ for (const part of parts) {
16
+ const split = _splitCamelCase(part);
17
+ for (const piece of split) {
18
+ if (!piece.s) {
19
+ continue;
20
+ }
21
+ if (piece.type === "digit" && words.length > 0) {
22
+ words[words.length - 1] += piece.s;
23
+ }
24
+ else {
25
+ words.push(piece.s);
26
+ }
27
+ }
28
+ }
29
+ return words;
30
+ }
31
+ function upperFirst(input) {
32
+ if (!input) {
33
+ return "";
34
+ }
35
+ return input[0].toUpperCase() + input.slice(1);
36
+ }
37
+ function camelCase(input) {
38
+ const words = splitWords(input);
39
+ if (words.length === 0) {
40
+ return "";
41
+ }
42
+ const [first, ...rest] = words;
43
+ return (first.toLowerCase() +
44
+ rest.map((word) => upperFirst(word.toLowerCase())).join(""));
45
+ }
46
+ function pascalCase(input) {
47
+ return splitWords(input)
48
+ .map((word) => upperFirst(word.toLowerCase()))
49
+ .join("");
50
+ }
51
+ function snakeCase(input) {
52
+ return splitWords(input)
53
+ .map((word) => word.toLowerCase())
54
+ .join("_");
55
+ }
8
56
  function toDBColumnOrTable(...strs) {
9
57
  let name = "";
10
58
  for (let i = 0; i < strs.length; i++) {
@@ -16,29 +64,27 @@ function toDBColumnOrTable(...strs) {
16
64
  const nextLast = split[split.length - 2];
17
65
  if (last.s === "s" && nextLast.type === "upper") {
18
66
  // get the first n-2 words
19
- name += (0, snake_case_1.snakeCase)(split
67
+ name += snakeCase(split
20
68
  .map((v) => v.s)
21
69
  .slice(0, split.length - 2)
22
70
  .join(""));
23
71
  name += "_";
24
72
  // combine the last two
25
- name += (0, snake_case_1.snakeCase)(nextLast.s);
73
+ name += snakeCase(nextLast.s);
26
74
  name += last.s;
27
75
  continue;
28
76
  }
29
77
  }
30
- name += (0, snake_case_1.snakeCase)(s);
78
+ name += snakeCase(s);
31
79
  if (i !== strs.length - 1) {
32
80
  name += "_";
33
81
  }
34
82
  }
35
83
  return name;
36
84
  }
37
- exports.toDBColumnOrTable = toDBColumnOrTable;
38
85
  function toFilePath(s) {
39
- return (0, snake_case_1.snakeCase)(s);
86
+ return snakeCase(s);
40
87
  }
41
- exports.toFilePath = toFilePath;
42
88
  function toFieldName(...strs) {
43
89
  let name = "";
44
90
  let hasDoneLower = false;
@@ -50,32 +96,30 @@ function toFieldName(...strs) {
50
96
  const nextLast = split[split.length - 2];
51
97
  if (last.s === "s" && nextLast.type === "upper") {
52
98
  // get the first n-2 words
53
- name += (0, camel_case_1.camelCase)(split
99
+ name += camelCase(split
54
100
  .map((v) => v.s)
55
101
  .slice(0, split.length - 2)
56
102
  .join(""));
57
103
  // combine the last two
58
- name += (0, pascal_case_1.pascalCase)(nextLast.s);
104
+ name += pascalCase(nextLast.s);
59
105
  name += last.s;
60
106
  hasDoneLower = true;
61
107
  continue;
62
108
  }
63
109
  }
64
110
  if (!hasDoneLower) {
65
- name += (0, camel_case_1.camelCase)(s);
111
+ name += camelCase(s);
66
112
  hasDoneLower = true;
67
113
  }
68
114
  else {
69
- name += (0, pascal_case_1.pascalCase)(s);
115
+ name += pascalCase(s);
70
116
  }
71
117
  }
72
118
  return name;
73
119
  }
74
- exports.toFieldName = toFieldName;
75
120
  function toClassName(str) {
76
- return (0, pascal_case_1.pascalCase)(str);
121
+ return pascalCase(str);
77
122
  }
78
- exports.toClassName = toClassName;
79
123
  function isUpper(s) {
80
124
  for (const c of s) {
81
125
  if (!(c >= "A" && c <= "Z")) {
@@ -154,4 +198,3 @@ function _splitCamelCase(s) {
154
198
  }
155
199
  return results;
156
200
  }
157
- exports._splitCamelCase = _splitCamelCase;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowtop/ent",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "snowtop ent framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -8,30 +8,27 @@
8
8
  "example": "examples"
9
9
  },
10
10
  "dependencies": {
11
- "@types/node": "^20.10.4",
12
- "camel-case": "^4.1.2",
11
+ "@types/node": "^25.0.3",
13
12
  "cosmiconfig": "^9.0.0",
14
- "dataloader": "^2.2.2",
15
- "glob": "^10.3.10",
16
- "graph-data-structure": "^3.5.0",
17
- "js-yaml": "^4.1.0",
13
+ "dataloader": "^2.2.3",
14
+ "glob": "^13.0.0",
15
+ "graph-data-structure": "^4.5.0",
16
+ "js-yaml": "^4.1.1",
18
17
  "json5": "^2.2.3",
19
- "luxon": "^3.4.4",
20
- "memoizee": "^0.4.15",
18
+ "luxon": "^3.7.2",
19
+ "memoizee": "^0.4.17",
21
20
  "minimist": "^1.2.8",
22
- "pascal-case": "^3.1.2",
23
- "pg": "^8.11.3",
24
- "prettier": "^3.1.0",
25
- "snake-case": "^3.0.4",
21
+ "pg": "^8.16.3",
22
+ "prettier": "^3.7.4",
26
23
  "ts-node": "^11.0.0-beta.1",
27
24
  "tsconfig-paths": "^4.2.0",
28
- "tslib": "^2.6.2",
29
- "typescript": "^5.3.3",
25
+ "tslib": "^2.8.1",
26
+ "typescript": "^5.9.3",
30
27
  "uuid": "^9.0.1"
31
28
  },
32
29
  "peerDependencies": {
33
30
  "@swc-node/register": "^1.6.8",
34
- "better-sqlite3": "^9.2.2",
31
+ "better-sqlite3": "^12.5.0",
35
32
  "graphql": "^16.8.1"
36
33
  },
37
34
  "peerDependenciesMeta": {
@@ -43,7 +40,7 @@
43
40
  }
44
41
  },
45
42
  "engines": {
46
- "node": ">=16.0"
43
+ "node": ">=20.9.0"
47
44
  },
48
45
  "devDependencies": {},
49
46
  "scripts": {},
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseSchema = exports.processFields = void 0;
3
+ exports.processFields = processFields;
4
+ exports.parseSchema = parseSchema;
4
5
  const cosmiconfig_1 = require("cosmiconfig");
5
6
  const const_1 = require("../core/const");
6
7
  const global_schema_1 = require("../core/global_schema");
@@ -87,7 +88,6 @@ async function processFields(src, patternName) {
87
88
  }
88
89
  return ret;
89
90
  }
90
- exports.processFields = processFields;
91
91
  async function transformServerDefault(name, f, value) {
92
92
  if (f.valid) {
93
93
  if (!(await f.valid(value))) {
@@ -458,7 +458,6 @@ async function parseSchema(potentialSchemas, globalSchema) {
458
458
  },
459
459
  };
460
460
  }
461
- exports.parseSchema = parseSchema;
462
461
  function translatePrettier() {
463
462
  const r = (0, cosmiconfig_1.cosmiconfigSync)("prettier").search();
464
463
  if (!r) {
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BinaryTextType = exports.BinaryTextField = exports.ByteaType = exports.ByteaField = void 0;
3
+ exports.BinaryTextField = exports.ByteaField = void 0;
4
+ exports.ByteaType = ByteaType;
5
+ exports.BinaryTextType = BinaryTextType;
4
6
  const field_1 = require("./field");
5
7
  const schema_1 = require("./schema");
6
8
  class ByteaField extends field_1.BaseField {
@@ -26,7 +28,6 @@ function ByteaType(options) {
26
28
  const result = new ByteaField();
27
29
  return Object.assign(result, options);
28
30
  }
29
- exports.ByteaType = ByteaType;
30
31
  class BinaryTextField extends field_1.BaseField {
31
32
  constructor() {
32
33
  super(...arguments);
@@ -50,4 +51,3 @@ function BinaryTextType(options) {
50
51
  const result = new BinaryTextField();
51
52
  return Object.assign(result, options);
52
53
  }
53
- exports.BinaryTextType = BinaryTextType;
package/schema/field.js CHANGED
@@ -15,15 +15,52 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.UUIDListType = exports.IntegerEnumListType = exports.EnumListType = exports.DateListType = exports.TimetzListType = exports.TimeListType = exports.TimestamptzListType = exports.TimestampListType = exports.BooleanListType = exports.BigIntegerListType = exports.FloatListType = exports.IntegerListType = exports.IntListType = exports.StringListType = exports.ListField = exports.IntegerEnumType = exports.IntegerEnumField = exports.EnumType = exports.StringEnumField = exports.EnumField = exports.DateType = exports.DateField = exports.TimetzType = exports.TimeType = exports.TimeField = exports.leftPad = exports.TimestamptzType = exports.TimestampType = exports.TimestampField = exports.StringType = exports.PolymorphicStringField = exports.StringField = exports.BooleanType = exports.BooleanField = exports.FloatType = exports.FloatField = exports.BigIntegerType = exports.BigIntegerField = exports.IntegerType = exports.IntegerField = exports.NumberField = exports.UUIDType = exports.UUIDField = exports.BaseField = void 0;
36
+ exports.ListField = exports.IntegerEnumField = exports.StringEnumField = exports.EnumField = exports.DateField = exports.TimeField = exports.leftPad = exports.TimestampField = exports.PolymorphicStringField = exports.StringField = exports.BooleanField = exports.FloatField = exports.BigIntegerField = exports.IntegerField = exports.NumberField = exports.UUIDField = exports.BaseField = void 0;
37
+ exports.UUIDType = UUIDType;
38
+ exports.IntegerType = IntegerType;
39
+ exports.BigIntegerType = BigIntegerType;
40
+ exports.FloatType = FloatType;
41
+ exports.BooleanType = BooleanType;
42
+ exports.StringType = StringType;
43
+ exports.TimestampType = TimestampType;
44
+ exports.TimestamptzType = TimestamptzType;
45
+ exports.TimeType = TimeType;
46
+ exports.TimetzType = TimetzType;
47
+ exports.DateType = DateType;
48
+ exports.EnumType = EnumType;
49
+ exports.IntegerEnumType = IntegerEnumType;
50
+ exports.StringListType = StringListType;
51
+ exports.IntListType = IntListType;
52
+ exports.IntegerListType = IntegerListType;
53
+ exports.FloatListType = FloatListType;
54
+ exports.BigIntegerListType = BigIntegerListType;
55
+ exports.BooleanListType = BooleanListType;
56
+ exports.TimestampListType = TimestampListType;
57
+ exports.TimestamptzListType = TimestamptzListType;
58
+ exports.TimeListType = TimeListType;
59
+ exports.TimetzListType = TimetzListType;
60
+ exports.DateListType = DateListType;
61
+ exports.EnumListType = EnumListType;
62
+ exports.IntegerEnumListType = IntegerEnumListType;
63
+ exports.UUIDListType = UUIDListType;
27
64
  const luxon_1 = require("luxon");
28
65
  const types_1 = require("util/types");
29
66
  const uuid_1 = require("uuid");
@@ -121,7 +158,6 @@ function UUIDType(options) {
121
158
  let result = new UUIDField(options);
122
159
  return Object.assign(result, options);
123
160
  }
124
- exports.UUIDType = UUIDType;
125
161
  class NumberField extends BaseField {
126
162
  constructor(options) {
127
163
  super();
@@ -181,7 +217,6 @@ function IntegerType(options) {
181
217
  let result = new IntegerField(options);
182
218
  return Object.assign(result, options);
183
219
  }
184
- exports.IntegerType = IntegerType;
185
220
  class BigIntegerField extends NumberField {
186
221
  constructor() {
187
222
  super(...arguments);
@@ -193,7 +228,6 @@ function BigIntegerType(options) {
193
228
  let result = new BigIntegerField(options);
194
229
  return Object.assign(result, options);
195
230
  }
196
- exports.BigIntegerType = BigIntegerType;
197
231
  class FloatField extends NumberField {
198
232
  constructor() {
199
233
  super(...arguments);
@@ -205,7 +239,6 @@ function FloatType(options) {
205
239
  let result = new FloatField(options);
206
240
  return Object.assign(result, options);
207
241
  }
208
- exports.FloatType = FloatType;
209
242
  class BooleanField extends BaseField {
210
243
  constructor() {
211
244
  super(...arguments);
@@ -217,7 +250,6 @@ function BooleanType(options) {
217
250
  let result = new BooleanField();
218
251
  return Object.assign(result, options);
219
252
  }
220
- exports.BooleanType = BooleanType;
221
253
  class StringField extends BaseField {
222
254
  constructor(options) {
223
255
  super();
@@ -387,7 +419,6 @@ function StringType(options) {
387
419
  }
388
420
  return Object.assign(result, options2);
389
421
  }
390
- exports.StringType = StringType;
391
422
  class TimestampField extends BaseField {
392
423
  constructor(options) {
393
424
  super();
@@ -420,13 +451,11 @@ function TimestampType(options) {
420
451
  let result = new TimestampField({ ...options });
421
452
  return Object.assign(result, options);
422
453
  }
423
- exports.TimestampType = TimestampType;
424
454
  function TimestamptzType(options) {
425
455
  let opts = { withTimezone: true, ...options };
426
456
  let result = new TimestampField(opts);
427
457
  return Object.assign(result, opts);
428
458
  }
429
- exports.TimestamptzType = TimestamptzType;
430
459
  const leftPad = (val) => {
431
460
  if (val >= 0) {
432
461
  if (val < 10) {
@@ -479,7 +508,6 @@ function TimeType(options) {
479
508
  let result = new TimeField(options);
480
509
  return Object.assign(result, options);
481
510
  }
482
- exports.TimeType = TimeType;
483
511
  function TimetzType(options) {
484
512
  let opts = {
485
513
  withTimezone: true,
@@ -488,7 +516,6 @@ function TimetzType(options) {
488
516
  let result = new TimeField(opts);
489
517
  return Object.assign(result, opts);
490
518
  }
491
- exports.TimetzType = TimetzType;
492
519
  class DateField extends BaseField {
493
520
  constructor() {
494
521
  super(...arguments);
@@ -515,7 +542,6 @@ function DateType(options) {
515
542
  let result = new DateField();
516
543
  return Object.assign(result, options);
517
544
  }
518
- exports.DateType = DateType;
519
545
  /**
520
546
  * @deprecated Use StringEnumField
521
547
  */
@@ -618,7 +644,6 @@ function EnumType(options) {
618
644
  let result = new StringEnumField(options);
619
645
  return Object.assign(result, options);
620
646
  }
621
- exports.EnumType = EnumType;
622
647
  class IntegerEnumField extends BaseField {
623
648
  constructor(options) {
624
649
  super();
@@ -693,7 +718,6 @@ function IntegerEnumType(options) {
693
718
  let result = new IntegerEnumField(options);
694
719
  return Object.assign(result, options);
695
720
  }
696
- exports.IntegerEnumType = IntegerEnumType;
697
721
  class ListField extends BaseField {
698
722
  constructor(field, options) {
699
723
  super();
@@ -817,47 +841,36 @@ exports.ListField = ListField;
817
841
  function StringListType(options) {
818
842
  return new ListField(StringType(options), options);
819
843
  }
820
- exports.StringListType = StringListType;
821
844
  function IntListType(options) {
822
845
  return new ListField(IntegerType(options), options);
823
846
  }
824
- exports.IntListType = IntListType;
825
847
  function IntegerListType(options) {
826
848
  return new ListField(IntegerType(options), options);
827
849
  }
828
- exports.IntegerListType = IntegerListType;
829
850
  function FloatListType(options) {
830
851
  return new ListField(FloatType(options), options);
831
852
  }
832
- exports.FloatListType = FloatListType;
833
853
  function BigIntegerListType(options) {
834
854
  return new ListField(BigIntegerType(options), options);
835
855
  }
836
- exports.BigIntegerListType = BigIntegerListType;
837
856
  function BooleanListType(options) {
838
857
  return new ListField(BooleanType(options), options);
839
858
  }
840
- exports.BooleanListType = BooleanListType;
841
859
  function TimestampListType(options) {
842
860
  return new ListField(TimestampType(options), options);
843
861
  }
844
- exports.TimestampListType = TimestampListType;
845
862
  function TimestamptzListType(options) {
846
863
  return new ListField(TimestamptzType(options), options);
847
864
  }
848
- exports.TimestamptzListType = TimestamptzListType;
849
865
  function TimeListType(options) {
850
866
  return new ListField(TimeType(options), options);
851
867
  }
852
- exports.TimeListType = TimeListType;
853
868
  function TimetzListType(options) {
854
869
  return new ListField(TimetzType(options), options);
855
870
  }
856
- exports.TimetzListType = TimetzListType;
857
871
  function DateListType(options) {
858
872
  return new ListField(DateType(options), options);
859
873
  }
860
- exports.DateListType = DateListType;
861
874
  function EnumListType(options) {
862
875
  if (options.createEnumType) {
863
876
  throw new Error(`createEnumType is currently unsupported in enum list`);
@@ -871,7 +884,6 @@ function EnumListType(options) {
871
884
  // unclear what the behavior is
872
885
  return new ListField(EnumType(options), options);
873
886
  }
874
- exports.EnumListType = EnumListType;
875
887
  function IntegerEnumListType(options) {
876
888
  // not all of these will make sense in a list...
877
889
  // can make it work eventually but involves work we're not currently trying to do
@@ -879,11 +891,9 @@ function IntegerEnumListType(options) {
879
891
  // unclear what the behavior is
880
892
  return new ListField(IntegerEnumType(options), options);
881
893
  }
882
- exports.IntegerEnumListType = IntegerEnumListType;
883
894
  function UUIDListType(options) {
884
895
  return new ListField(UUIDType(options), {
885
896
  ...options,
886
897
  disableJSONStringify: true,
887
898
  });
888
899
  }
889
- exports.UUIDListType = UUIDListType;
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JSONTypeAsList = exports.JSONBTypeAsList = exports.JSONListType = exports.JSONBListType = exports.JSONBType = exports.JSONType = exports.JSONField = void 0;
3
+ exports.JSONField = void 0;
4
+ exports.JSONType = JSONType;
5
+ exports.JSONBType = JSONBType;
6
+ exports.JSONBListType = JSONBListType;
7
+ exports.JSONListType = JSONListType;
8
+ exports.JSONBTypeAsList = JSONBTypeAsList;
9
+ exports.JSONTypeAsList = JSONTypeAsList;
4
10
  const schema_1 = require("./schema");
5
11
  const field_1 = require("./field");
6
12
  class JSONField extends field_1.BaseField {
@@ -40,26 +46,22 @@ function JSONType(options) {
40
46
  let result = new JSONField(false, options);
41
47
  return Object.assign(result, options);
42
48
  }
43
- exports.JSONType = JSONType;
44
49
  function JSONBType(options) {
45
50
  let result = new JSONField(true, options);
46
51
  return Object.assign(result, options);
47
52
  }
48
- exports.JSONBType = JSONBType;
49
53
  /**
50
54
  * @deprecated use JSONBTypeAsList
51
55
  */
52
56
  function JSONBListType(options) {
53
57
  return new field_1.ListField(JSONBType(options), options);
54
58
  }
55
- exports.JSONBListType = JSONBListType;
56
59
  /**
57
60
  * @deprecated use JSONTypeAsList
58
61
  */
59
62
  function JSONListType(options) {
60
63
  return new field_1.ListField(JSONType(options), options);
61
64
  }
62
- exports.JSONListType = JSONListType;
63
65
  function JSONBTypeAsList(options) {
64
66
  let result = new JSONField(true, {
65
67
  ...options,
@@ -67,7 +69,6 @@ function JSONBTypeAsList(options) {
67
69
  });
68
70
  return Object.assign(result, options);
69
71
  }
70
- exports.JSONBTypeAsList = JSONBTypeAsList;
71
72
  function JSONTypeAsList(options) {
72
73
  let result = new JSONField(false, {
73
74
  ...options,
@@ -75,4 +76,3 @@ function JSONTypeAsList(options) {
75
76
  });
76
77
  return Object.assign(result, options);
77
78
  }
78
- exports.JSONTypeAsList = JSONTypeAsList;
package/schema/schema.js CHANGED
@@ -1,6 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConstraintType = exports.optionalField = exports.requiredField = exports.NoFields = exports.ActionOperation = exports.getTransformedUpdateOp = exports.getObjectLoaderProperties = exports.getTransformedReadClause = exports.getFieldsForCreateAction = exports.getFieldsWithEditPrivacy = exports.getFieldsWithPrivacy = exports.getStorageKey = exports.getFields = exports.getSchema = exports.DBType = exports.SQLStatementOperation = void 0;
3
+ exports.ConstraintType = exports.NoFields = exports.ActionOperation = exports.DBType = exports.SQLStatementOperation = void 0;
4
+ exports.getSchema = getSchema;
5
+ exports.getFields = getFields;
6
+ exports.getStorageKey = getStorageKey;
7
+ exports.getFieldsWithPrivacy = getFieldsWithPrivacy;
8
+ exports.getFieldsWithEditPrivacy = getFieldsWithEditPrivacy;
9
+ exports.getFieldsForCreateAction = getFieldsForCreateAction;
10
+ exports.getTransformedReadClause = getTransformedReadClause;
11
+ exports.getObjectLoaderProperties = getObjectLoaderProperties;
12
+ exports.getTransformedUpdateOp = getTransformedUpdateOp;
13
+ exports.requiredField = requiredField;
14
+ exports.optionalField = optionalField;
4
15
  const names_1 = require("../names/names");
5
16
  // we also want this transformation to exist on a per-action basis
6
17
  // if it exists on an action, we don't do the global schema transformation
@@ -54,7 +65,6 @@ function getSchema(value) {
54
65
  return new value();
55
66
  }
56
67
  }
57
- exports.getSchema = getSchema;
58
68
  function getFields(value) {
59
69
  const schema = getSchema(value);
60
70
  function addFields(fields) {
@@ -78,27 +88,22 @@ function getFields(value) {
78
88
  addFields(schema.fields);
79
89
  return m;
80
90
  }
81
- exports.getFields = getFields;
82
91
  function getStorageKey(field, fieldName) {
83
92
  return field.storageKey || (0, names_1.toDBColumnOrTable)(fieldName);
84
93
  }
85
- exports.getStorageKey = getStorageKey;
86
94
  // returns a mapping of storage key to field privacy
87
95
  function getFieldsWithPrivacy(value, fieldInfoMap) {
88
96
  return getFieldsWithPrivacyImpl(value, fieldInfoMap, ["privacyPolicy"]);
89
97
  }
90
- exports.getFieldsWithPrivacy = getFieldsWithPrivacy;
91
98
  function getFieldsWithEditPrivacy(value, fieldInfoMap) {
92
99
  return getFieldsWithPrivacyImpl(value, fieldInfoMap, ["editPrivacyPolicy"]);
93
100
  }
94
- exports.getFieldsWithEditPrivacy = getFieldsWithEditPrivacy;
95
101
  function getFieldsForCreateAction(value, fieldInfoMap) {
96
102
  return getFieldsWithPrivacyImpl(value, fieldInfoMap, [
97
103
  "createOnlyOverrideEditPrivacyPolicy",
98
104
  "editPrivacyPolicy",
99
105
  ]);
100
106
  }
101
- exports.getFieldsForCreateAction = getFieldsForCreateAction;
102
107
  function getFieldsWithPrivacyImpl(value, fieldInfoMap, keys) {
103
108
  const schema = getSchema(value);
104
109
  function addFields(fields) {
@@ -149,7 +154,6 @@ function getTransformedReadClause(value) {
149
154
  }
150
155
  return;
151
156
  }
152
- exports.getTransformedReadClause = getTransformedReadClause;
153
157
  // would like to avoid calling this so that itwe don't run into circular dependencies
154
158
  // but the fact that it returns a clause makes it hard since we don't control the patterns...
155
159
  // we can make each clause return a format that can be extrapolated and used in codegen...
@@ -159,7 +163,6 @@ function getObjectLoaderProperties(value, tableName) {
159
163
  instanceKey: `${tableName}:transformedReadClause`,
160
164
  };
161
165
  }
162
- exports.getObjectLoaderProperties = getObjectLoaderProperties;
163
166
  function getTransformedUpdateOp(value, stmt) {
164
167
  const schema = getSchema(value);
165
168
  if (!schema.patterns) {
@@ -172,7 +175,6 @@ function getTransformedUpdateOp(value, stmt) {
172
175
  }
173
176
  return null;
174
177
  }
175
- exports.getTransformedUpdateOp = getTransformedUpdateOp;
176
178
  // this maps to ActionOperation in ent/action.go
177
179
  var ActionOperation;
178
180
  (function (ActionOperation) {
@@ -207,11 +209,9 @@ exports.NoFields = "__NO_FIELDS__";
207
209
  function requiredField(field) {
208
210
  return `__required__.${field}.__required__`;
209
211
  }
210
- exports.requiredField = requiredField;
211
212
  function optionalField(field) {
212
213
  return `__optional__.${field}.__optional__`;
213
214
  }
214
- exports.optionalField = optionalField;
215
215
  var ConstraintType;
216
216
  (function (ConstraintType) {
217
217
  ConstraintType["PrimaryKey"] = "primary";
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StructTypeAsList = exports.StructListType = exports.StructType = exports.StructField = void 0;
3
+ exports.StructField = void 0;
4
+ exports.StructType = StructType;
5
+ exports.StructListType = StructListType;
6
+ exports.StructTypeAsList = StructTypeAsList;
4
7
  const field_1 = require("./field");
5
8
  const schema_1 = require("./schema");
6
9
  const global_schema_1 = require("../core/global_schema");
@@ -249,16 +252,13 @@ function StructType(options) {
249
252
  let result = new StructField(options);
250
253
  return Object.assign(result, options);
251
254
  }
252
- exports.StructType = StructType;
253
255
  /**
254
256
  * @deprecated use StructTypeAsList
255
257
  */
256
258
  function StructListType(options) {
257
259
  return new field_1.ListField(StructType(options), options);
258
260
  }
259
- exports.StructListType = StructListType;
260
261
  function StructTypeAsList(options) {
261
262
  let result = new StructField(options, true);
262
263
  return Object.assign(result, options);
263
264
  }
264
- exports.StructTypeAsList = StructTypeAsList;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UnionListType = exports.UnionType = exports.UnionField = void 0;
3
+ exports.UnionField = void 0;
4
+ exports.UnionType = UnionType;
5
+ exports.UnionListType = UnionListType;
4
6
  const schema_1 = require("./schema");
5
7
  const field_1 = require("./field");
6
8
  // used to know which key in the union is valid.
@@ -72,8 +74,6 @@ function UnionType(options) {
72
74
  let result = new UnionField(options);
73
75
  return Object.assign(result, options);
74
76
  }
75
- exports.UnionType = UnionType;
76
77
  function UnionListType(options) {
77
78
  return new field_1.ListField(UnionType(options), options);
78
79
  }
79
- exports.UnionListType = UnionListType;