@snowtop/ent 0.1.0-alpha99 → 0.1.0

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 (115) hide show
  1. package/action/action.d.ts +8 -1
  2. package/action/executor.d.ts +16 -3
  3. package/action/executor.js +83 -27
  4. package/action/index.d.ts +2 -1
  5. package/action/operations.d.ts +126 -0
  6. package/action/operations.js +686 -0
  7. package/action/orchestrator.d.ts +22 -8
  8. package/action/orchestrator.js +278 -67
  9. package/core/base.d.ts +34 -24
  10. package/core/clause.d.ts +62 -79
  11. package/core/clause.js +77 -5
  12. package/core/config.d.ts +5 -1
  13. package/core/config.js +3 -0
  14. package/core/const.d.ts +3 -0
  15. package/core/const.js +6 -0
  16. package/core/context.d.ts +4 -3
  17. package/core/context.js +2 -1
  18. package/core/db.d.ts +1 -0
  19. package/core/db.js +7 -7
  20. package/core/ent.d.ts +53 -105
  21. package/core/ent.js +104 -599
  22. package/core/global_schema.d.ts +7 -0
  23. package/core/global_schema.js +51 -0
  24. package/core/loaders/assoc_count_loader.d.ts +4 -2
  25. package/core/loaders/assoc_count_loader.js +10 -2
  26. package/core/loaders/assoc_edge_loader.d.ts +2 -3
  27. package/core/loaders/assoc_edge_loader.js +16 -7
  28. package/core/loaders/index.d.ts +0 -1
  29. package/core/loaders/index.js +1 -3
  30. package/core/loaders/loader.d.ts +3 -3
  31. package/core/loaders/loader.js +3 -20
  32. package/core/loaders/object_loader.d.ts +30 -10
  33. package/core/loaders/object_loader.js +179 -40
  34. package/core/loaders/query_loader.d.ts +4 -4
  35. package/core/loaders/query_loader.js +14 -19
  36. package/core/loaders/raw_count_loader.d.ts +1 -0
  37. package/core/loaders/raw_count_loader.js +3 -2
  38. package/core/privacy.d.ts +19 -10
  39. package/core/privacy.js +47 -26
  40. package/core/query/assoc_query.js +1 -1
  41. package/core/query/custom_clause_query.d.ts +6 -3
  42. package/core/query/custom_clause_query.js +36 -9
  43. package/core/query/custom_query.d.ts +3 -1
  44. package/core/query/custom_query.js +29 -6
  45. package/core/query/query.d.ts +12 -2
  46. package/core/query/query.js +67 -38
  47. package/core/query/shared_assoc_test.js +151 -10
  48. package/core/query/shared_test.d.ts +2 -2
  49. package/core/query/shared_test.js +90 -30
  50. package/core/query_impl.d.ts +8 -0
  51. package/core/query_impl.js +28 -0
  52. package/core/viewer.d.ts +2 -0
  53. package/core/viewer.js +2 -0
  54. package/graphql/graphql.d.ts +103 -19
  55. package/graphql/graphql.js +169 -134
  56. package/graphql/graphql_field_helpers.d.ts +9 -3
  57. package/graphql/graphql_field_helpers.js +22 -2
  58. package/graphql/index.d.ts +2 -1
  59. package/graphql/index.js +5 -2
  60. package/graphql/scalars/orderby_direction.d.ts +2 -0
  61. package/graphql/scalars/orderby_direction.js +15 -0
  62. package/imports/dataz/example1/_auth.js +128 -47
  63. package/imports/dataz/example1/_viewer.js +87 -39
  64. package/imports/index.d.ts +1 -1
  65. package/imports/index.js +2 -2
  66. package/index.d.ts +12 -1
  67. package/index.js +18 -6
  68. package/package.json +20 -17
  69. package/parse_schema/parse.d.ts +10 -4
  70. package/parse_schema/parse.js +70 -24
  71. package/schema/base_schema.d.ts +8 -0
  72. package/schema/base_schema.js +11 -0
  73. package/schema/field.d.ts +6 -3
  74. package/schema/field.js +72 -17
  75. package/schema/index.d.ts +1 -1
  76. package/schema/index.js +2 -1
  77. package/schema/json_field.d.ts +3 -3
  78. package/schema/json_field.js +4 -1
  79. package/schema/schema.d.ts +42 -5
  80. package/schema/schema.js +35 -41
  81. package/schema/struct_field.d.ts +8 -6
  82. package/schema/struct_field.js +67 -8
  83. package/schema/union_field.d.ts +1 -1
  84. package/scripts/custom_compiler.js +4 -4
  85. package/scripts/custom_graphql.js +105 -75
  86. package/scripts/move_types.js +4 -1
  87. package/scripts/read_schema.js +2 -2
  88. package/testutils/action/complex_schemas.d.ts +1 -1
  89. package/testutils/action/complex_schemas.js +10 -3
  90. package/testutils/builder.d.ts +3 -0
  91. package/testutils/builder.js +6 -0
  92. package/testutils/db/temp_db.d.ts +9 -1
  93. package/testutils/db/temp_db.js +82 -14
  94. package/testutils/db_mock.js +1 -3
  95. package/testutils/ent-graphql-tests/index.d.ts +1 -1
  96. package/testutils/ent-graphql-tests/index.js +30 -19
  97. package/testutils/fake_comms.js +1 -1
  98. package/testutils/fake_data/fake_contact.d.ts +1 -1
  99. package/testutils/fake_data/fake_tag.d.ts +1 -1
  100. package/testutils/fake_data/fake_user.d.ts +3 -3
  101. package/testutils/fake_data/fake_user.js +15 -4
  102. package/testutils/fake_data/tag_query.js +8 -3
  103. package/testutils/fake_data/test_helpers.d.ts +3 -2
  104. package/testutils/fake_data/test_helpers.js +4 -4
  105. package/testutils/fake_data/user_query.d.ts +5 -2
  106. package/testutils/fake_data/user_query.js +19 -2
  107. package/testutils/fake_log.js +1 -1
  108. package/tsc/ast.js +2 -1
  109. package/tsc/move_generated.js +2 -2
  110. package/tsc/transform.d.ts +2 -2
  111. package/tsc/transform.js +4 -3
  112. package/tsc/transform_ent.js +2 -1
  113. package/tsc/transform_schema.js +4 -3
  114. package/core/loaders/index_loader.d.ts +0 -14
  115. package/core/loaders/index_loader.js +0 -27
@@ -21,12 +21,12 @@ class FakeLogger {
21
21
  this.logs = [];
22
22
  }
23
23
  }
24
- exports.FakeLogger = FakeLogger;
25
24
  // todo this is quick and ideal.
26
25
  // more ideal is capturing all console.logs
27
26
  // we do it in golang for example
28
27
  // and will need this for production launch anyways
29
28
  FakeLogger.logs = [];
29
+ exports.FakeLogger = FakeLogger;
30
30
  // TODO instead of needing to add this manually
31
31
  // we need to build a way to add global observers (and maybe triggers)
32
32
  // to be run on every action/mutation
package/tsc/ast.js CHANGED
@@ -31,6 +31,7 @@ const typescript_1 = __importDefault(require("typescript"));
31
31
  const path = __importStar(require("path"));
32
32
  const js_yaml_1 = require("js-yaml");
33
33
  const fs = __importStar(require("fs"));
34
+ const const_1 = require("../core/const");
34
35
  function getPreText(fileContents, node, sourceFile) {
35
36
  return fileContents.substring(node.getFullStart(), node.getStart(sourceFile));
36
37
  }
@@ -267,7 +268,7 @@ function getCustomInfo() {
267
268
  catch (e) { }
268
269
  return {
269
270
  viewerInfo: {
270
- path: "@snowtop/ent",
271
+ path: const_1.PACKAGE,
271
272
  name: "Viewer",
272
273
  },
273
274
  relativeImports,
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.moveGenerated = void 0;
30
- const glob_1 = require("glob");
30
+ const glob = __importStar(require("glob"));
31
31
  const path = __importStar(require("path"));
32
32
  const fs = __importStar(require("fs"));
33
33
  const typescript_1 = __importDefault(require("typescript"));
@@ -38,7 +38,7 @@ class MoveFiles {
38
38
  this.globPath = globPath;
39
39
  }
40
40
  move() {
41
- const files = glob_1.glob.sync(this.globPath);
41
+ const files = glob.sync(this.globPath);
42
42
  moveFiles(files);
43
43
  }
44
44
  }
@@ -1,4 +1,4 @@
1
- import { IOptions } from "glob";
1
+ import * as glob from "glob";
2
2
  import ts from "typescript";
3
3
  interface TraverseChildResponse {
4
4
  node?: ts.Node;
@@ -10,7 +10,7 @@ interface TraverseChildResponse {
10
10
  }
11
11
  export interface TransformFile {
12
12
  glob: string;
13
- globOptions?: IOptions;
13
+ globOptions?: glob.GlobOptions;
14
14
  preprocessFile?: (contents: string, file: string, sourceFile: ts.SourceFile) => boolean;
15
15
  traverseChild(sourceFile: ts.SourceFile, contents: string, file: string, node: ts.Node): TraverseChildResponse | undefined;
16
16
  filter?(files: string[]): string[];
package/tsc/transform.js CHANGED
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.transform = void 0;
30
- const glob_1 = require("glob");
30
+ const glob = __importStar(require("glob"));
31
31
  const typescript_1 = __importDefault(require("typescript"));
32
32
  const child_process_1 = require("child_process");
33
33
  const fs = __importStar(require("fs"));
@@ -40,10 +40,11 @@ function normalizePath(p) {
40
40
  return p;
41
41
  }
42
42
  function transform(transform) {
43
- let files = glob_1.glob.sync(transform.glob, transform.globOptions);
43
+ let files = glob.sync(transform.glob, transform.globOptions ?? {});
44
44
  const target = (0, compilerOptions_1.getTargetFromCurrentDir)();
45
45
  if (transform.filter) {
46
- files = transform.filter(files);
46
+ const f2 = files.map((f) => (typeof f === "string" ? f : f.path));
47
+ files = transform.filter(f2);
47
48
  }
48
49
  files.forEach((file) => {
49
50
  let { contents, sourceFile } = (0, compilerOptions_1.createSourceFile)(target, file);
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.TransformEnt = void 0;
7
+ const const_1 = require("../core/const");
7
8
  const typescript_1 = __importDefault(require("typescript"));
8
9
  const ast_1 = require("./ast");
9
10
  function isPrivacyPolicy(mm) {
@@ -52,7 +53,7 @@ class TransformEnt {
52
53
  return {
53
54
  rawString: classInfo.wrapClassContents(klassContents),
54
55
  traversed,
55
- imports: new Map([["@snowtop/ent", ["PrivacyPolicy"]]]),
56
+ imports: new Map([[const_1.PACKAGE, ["PrivacyPolicy"]]]),
56
57
  };
57
58
  }
58
59
  }
@@ -31,6 +31,7 @@ const typescript_1 = __importDefault(require("typescript"));
31
31
  const fs = __importStar(require("fs"));
32
32
  const path_1 = __importDefault(require("path"));
33
33
  const ast_1 = require("../tsc/ast");
34
+ const const_1 = require("../core/const");
34
35
  function traverseClass(fileContents, sourceFile, node, transformSchema) {
35
36
  const ci = getTransformClassInfo(fileContents, sourceFile, node, transformSchema);
36
37
  if (!ci) {
@@ -307,9 +308,9 @@ function parseFieldElement(element, sourceFile, fileContents, nested) {
307
308
  // find which of these importPaths is being used and use that to replace
308
309
  function findSchemaImportPath(sourceFile) {
309
310
  const paths = {
310
- "@snowtop/ent": true,
311
- "@snowtop/ent/schema": true,
312
- "@snowtop/ent/schema/": true,
311
+ [const_1.PACKAGE]: true,
312
+ [const_1.SCHEMA_PATH]: true,
313
+ [`${const_1.SCHEMA_PATH}/`]: true,
313
314
  };
314
315
  // @ts-ignore
315
316
  const importStatements = sourceFile.statements.filter((stmt) => typescript_1.default.isImportDeclaration(stmt));
@@ -1,14 +0,0 @@
1
- import { ID, SelectBaseDataOptions, Context, Data, LoaderFactory, EdgeQueryableDataOptions, Loader } from "../base";
2
- import * as clause from "../clause";
3
- import { ObjectLoaderFactory } from "./object_loader";
4
- export declare class IndexLoaderFactory implements LoaderFactory<ID, Data[]> {
5
- name: string;
6
- private factory;
7
- constructor(options: SelectBaseDataOptions, col: string, opts?: {
8
- extraClause?: clause.Clause;
9
- sortColumn?: string;
10
- toPrime?: ObjectLoaderFactory<ID>[];
11
- });
12
- createLoader(context?: Context): any;
13
- createConfigurableLoader(options: EdgeQueryableDataOptions, context?: Context): Loader<ID, Data[]>;
14
- }
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IndexLoaderFactory = void 0;
4
- const query_loader_1 = require("./query_loader");
5
- // we're keeping this for legacy reasons so as to not break existing callers
6
- // and to decouple the change here but all callers can safely be changed here to use QueryLoaderFactory
7
- // @deprecated use QueryLoaderFactory
8
- class IndexLoaderFactory {
9
- constructor(options, col, opts) {
10
- this.factory = new query_loader_1.QueryLoaderFactory({
11
- fields: options.fields,
12
- tableName: options.tableName,
13
- groupCol: col,
14
- clause: opts?.extraClause,
15
- sortColumn: opts?.sortColumn,
16
- toPrime: opts?.toPrime,
17
- });
18
- this.name = `indexLoader:${options.tableName}:${col}`;
19
- }
20
- createLoader(context) {
21
- return this.factory.createLoader(context);
22
- }
23
- createConfigurableLoader(options, context) {
24
- return this.factory.createConfigurableLoader(options, context);
25
- }
26
- }
27
- exports.IndexLoaderFactory = IndexLoaderFactory;