@snowtop/ent 0.1.0-alpha53 → 0.1.0-alpha58

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 (40) hide show
  1. package/action/experimental_action.d.ts +1 -1
  2. package/action/orchestrator.js +21 -1
  3. package/core/base.d.ts +1 -1
  4. package/core/clause.d.ts +36 -7
  5. package/core/clause.js +133 -32
  6. package/core/config.d.ts +5 -2
  7. package/core/ent.d.ts +16 -3
  8. package/core/ent.js +147 -35
  9. package/core/loaders/assoc_count_loader.js +6 -1
  10. package/core/query/shared_assoc_test.d.ts +1 -1
  11. package/core/query/shared_assoc_test.js +17 -5
  12. package/core/query/shared_test.d.ts +3 -0
  13. package/core/query/shared_test.js +95 -17
  14. package/index.d.ts +5 -5
  15. package/index.js +7 -6
  16. package/package.json +1 -1
  17. package/parse_schema/parse.d.ts +8 -2
  18. package/parse_schema/parse.js +22 -2
  19. package/schema/field.js +4 -0
  20. package/schema/index.d.ts +1 -1
  21. package/schema/schema.d.ts +16 -0
  22. package/scripts/custom_graphql.js +2 -0
  23. package/scripts/read_schema.js +10 -1
  24. package/testutils/db/{test_db.d.ts → temp_db.d.ts} +15 -3
  25. package/testutils/db/{test_db.js → temp_db.js} +62 -15
  26. package/testutils/fake_data/fake_contact.d.ts +1 -1
  27. package/testutils/fake_data/fake_contact.js +2 -2
  28. package/testutils/fake_data/fake_event.d.ts +1 -1
  29. package/testutils/fake_data/fake_event.js +3 -3
  30. package/testutils/fake_data/fake_user.d.ts +1 -1
  31. package/testutils/fake_data/fake_user.js +2 -2
  32. package/testutils/fake_data/test_helpers.d.ts +2 -2
  33. package/testutils/fake_data/test_helpers.js +5 -5
  34. package/testutils/parse_sql.js +4 -0
  35. package/testutils/test_edge_global_schema.d.ts +15 -0
  36. package/testutils/test_edge_global_schema.js +58 -0
  37. package/testutils/write.d.ts +2 -2
  38. package/testutils/write.js +3 -3
  39. package/tsc/ast.d.ts +1 -0
  40. package/tsc/ast.js +3 -0
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.testEdgeGlobalSchema = exports.EdgeWithDeletedAt = void 0;
23
+ const schema_1 = require("../schema");
24
+ const clause = __importStar(require("../core/clause"));
25
+ const ent_1 = require("../core/ent");
26
+ class EdgeWithDeletedAt extends ent_1.AssocEdge {
27
+ constructor(data) {
28
+ super(data);
29
+ this.deletedAt = data.deleted_at;
30
+ }
31
+ }
32
+ exports.EdgeWithDeletedAt = EdgeWithDeletedAt;
33
+ exports.testEdgeGlobalSchema = {
34
+ extraEdgeFields: {
35
+ // need this to be lowerCamelCase because we do this based on field name
36
+ // #510
37
+ deletedAt: (0, schema_1.TimestampType)({
38
+ nullable: true,
39
+ index: true,
40
+ defaultValueOnCreate: () => null,
41
+ }),
42
+ },
43
+ transformEdgeRead() {
44
+ return clause.Eq("deleted_at", null);
45
+ },
46
+ transformEdgeWrite(stmt) {
47
+ switch (stmt.op) {
48
+ case schema_1.SQLStatementOperation.Delete:
49
+ return {
50
+ op: schema_1.SQLStatementOperation.Update,
51
+ data: {
52
+ deleted_at: new Date(),
53
+ },
54
+ };
55
+ }
56
+ return null;
57
+ },
58
+ };
@@ -1,5 +1,5 @@
1
- import { EditRowOptions, Data, ID, DataOptions, CreateRowOptions } from "../core/base";
1
+ import { EditRowOptions, Data, DataOptions, CreateRowOptions } from "../core/base";
2
2
  import * as clause from "../core/clause";
3
3
  export declare function createRowForTest(options: CreateRowOptions, suffix?: string): Promise<Data | null>;
4
- export declare function editRowForTest(options: EditRowOptions, id: ID, suffix?: string): Promise<Data | null>;
4
+ export declare function editRowForTest(options: EditRowOptions, suffix?: string): Promise<Data | null>;
5
5
  export declare function deleteRowsForTest(options: DataOptions, cls: clause.Clause): Promise<void>;
@@ -22,13 +22,13 @@ async function createRowForTest(options, suffix) {
22
22
  }
23
23
  }
24
24
  exports.createRowForTest = createRowForTest;
25
- async function editRowForTest(options, id, suffix) {
25
+ async function editRowForTest(options, suffix) {
26
26
  const client = await db_1.default.getInstance().getNewClient();
27
27
  try {
28
28
  if (isSyncClient(client)) {
29
- return (0, ent_1.editRowSync)(client, options, id, suffix || "");
29
+ return (0, ent_1.editRowSync)(client, options, suffix || "");
30
30
  }
31
- return await (0, ent_1.editRow)(client, options, id, suffix);
31
+ return await (0, ent_1.editRow)(client, options, suffix);
32
32
  }
33
33
  finally {
34
34
  client.release();
package/tsc/ast.d.ts CHANGED
@@ -38,6 +38,7 @@ export interface customInfo {
38
38
  name: string;
39
39
  };
40
40
  relativeImports?: boolean;
41
+ globalSchemaPath?: string;
41
42
  }
42
43
  export declare function getCustomInfo(): customInfo;
43
44
  export {};
package/tsc/ast.js CHANGED
@@ -237,6 +237,7 @@ function normalizePath(p) {
237
237
  }
238
238
  return p;
239
239
  }
240
+ // also used in parse schema logic
240
241
  function getCustomInfo() {
241
242
  let yaml = {};
242
243
  let relativeImports = false;
@@ -249,6 +250,7 @@ function getCustomInfo() {
249
250
  return {
250
251
  viewerInfo: yaml.codegen.templatizedViewer,
251
252
  relativeImports,
253
+ globalSchemaPath: yaml.globalSchemaPath,
252
254
  };
253
255
  }
254
256
  }
@@ -259,6 +261,7 @@ function getCustomInfo() {
259
261
  name: "Viewer",
260
262
  },
261
263
  relativeImports,
264
+ globalSchemaPath: yaml.globalSchemaPath,
262
265
  };
263
266
  }
264
267
  exports.getCustomInfo = getCustomInfo;