@snowtop/ent 0.0.40-alpha6 → 0.1.0-alpha10

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 (65) hide show
  1. package/action/action.d.ts +14 -14
  2. package/action/executor.d.ts +1 -1
  3. package/action/experimental_action.d.ts +20 -20
  4. package/action/experimental_action.js +1 -1
  5. package/action/orchestrator.d.ts +10 -10
  6. package/action/orchestrator.js +14 -14
  7. package/core/base.d.ts +6 -6
  8. package/core/ent.d.ts +2 -1
  9. package/core/ent.js +14 -10
  10. package/core/privacy.d.ts +1 -1
  11. package/core/query/assoc_query.js +2 -2
  12. package/core/query/query.d.ts +1 -1
  13. package/graphql/builtins/connection.js +3 -3
  14. package/graphql/builtins/edge.js +2 -2
  15. package/graphql/builtins/node.js +1 -1
  16. package/graphql/graphql.js +2 -2
  17. package/graphql/index.d.ts +1 -0
  18. package/graphql/index.js +3 -1
  19. package/graphql/mutations/union.d.ts +2 -0
  20. package/graphql/mutations/union.js +35 -0
  21. package/graphql/query/connection_type.js +6 -6
  22. package/graphql/query/page_info.js +4 -4
  23. package/graphql/query/shared_assoc_test.js +2 -2
  24. package/graphql/scalars/time.d.ts +1 -1
  25. package/imports/index.d.ts +0 -1
  26. package/imports/index.js +3 -36
  27. package/package.json +2 -2
  28. package/parse_schema/parse.d.ts +15 -3
  29. package/parse_schema/parse.js +42 -7
  30. package/schema/base_schema.d.ts +36 -1
  31. package/schema/base_schema.js +63 -17
  32. package/schema/field.d.ts +25 -25
  33. package/schema/field.js +42 -33
  34. package/schema/index.d.ts +4 -2
  35. package/schema/index.js +5 -1
  36. package/schema/json_field.d.ts +6 -6
  37. package/schema/json_field.js +2 -2
  38. package/schema/schema.d.ts +11 -6
  39. package/schema/schema.js +46 -12
  40. package/schema/struct_field.d.ts +17 -0
  41. package/schema/struct_field.js +102 -0
  42. package/schema/union_field.d.ts +23 -0
  43. package/schema/union_field.js +79 -0
  44. package/scripts/custom_compiler.js +2 -19
  45. package/scripts/read_schema.js +15 -1
  46. package/scripts/transform_code.d.ts +1 -0
  47. package/scripts/transform_code.js +114 -0
  48. package/scripts/transform_schema.d.ts +1 -0
  49. package/scripts/transform_schema.js +357 -0
  50. package/testutils/builder.d.ts +19 -15
  51. package/testutils/builder.js +41 -7
  52. package/testutils/db/test_db.js +9 -9
  53. package/testutils/ent-graphql-tests/index.js +19 -12
  54. package/testutils/fake_data/fake_contact.d.ts +3 -7
  55. package/testutils/fake_data/fake_contact.js +14 -26
  56. package/testutils/fake_data/fake_event.d.ts +3 -7
  57. package/testutils/fake_data/fake_event.js +20 -33
  58. package/testutils/fake_data/fake_user.d.ts +3 -7
  59. package/testutils/fake_data/fake_user.js +22 -36
  60. package/testutils/fake_data/test_helpers.js +1 -1
  61. package/testutils/fake_data/user_query.d.ts +2 -2
  62. package/tsc/ast.d.ts +20 -0
  63. package/tsc/ast.js +131 -0
  64. package/tsc/compilerOptions.d.ts +7 -0
  65. package/tsc/compilerOptions.js +95 -0
@@ -44,7 +44,21 @@ function main() {
44
44
  if (!match) {
45
45
  throw new Error(`non-typescript file ${p} returned by glob`);
46
46
  }
47
- potentialSchemas[(0, pascal_case_1.pascalCase)(match[1])] = require(p).default;
47
+ let schema = match[1];
48
+ // convert foo_schema.ts -> foo
49
+ if (schema.endsWith("_schema")) {
50
+ schema = schema.slice(0, -7);
51
+ }
52
+ let relativePath;
53
+ const index = p.indexOf("src/schema");
54
+ if (index !== -1) {
55
+ relativePath = p.substring(index);
56
+ }
57
+ const s = require(p).default;
58
+ if (relativePath !== undefined) {
59
+ s.schemaPath = relativePath;
60
+ }
61
+ potentialSchemas[(0, pascal_case_1.pascalCase)(schema)] = s;
48
62
  }
49
63
  // console.log(potentialSchemas);
50
64
  const result = (0, parse_1.parseSchema)(potentialSchemas);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,114 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ const glob_1 = require("glob");
26
+ const typescript_1 = __importDefault(require("typescript"));
27
+ const compilerOptions_1 = require("../tsc/compilerOptions");
28
+ const ast_1 = require("../tsc/ast");
29
+ const child_process_1 = require("child_process");
30
+ const fs = __importStar(require("fs"));
31
+ async function main() {
32
+ const options = (0, compilerOptions_1.readCompilerOptions)(".");
33
+ let files = glob_1.glob.sync("src/ent/*.ts");
34
+ const target = (0, compilerOptions_1.getTarget)(options.target?.toString());
35
+ files.forEach((file) => {
36
+ let { contents, sourceFile } = (0, compilerOptions_1.createSourceFile)(target, file);
37
+ let traversed = false;
38
+ let nodes = [];
39
+ typescript_1.default.forEachChild(sourceFile, function (node) {
40
+ if (!typescript_1.default.isClassDeclaration(node) || !node.heritageClauses) {
41
+ nodes.push({ node });
42
+ return;
43
+ }
44
+ let classInfo = (0, ast_1.getClassInfo)(contents, sourceFile, node);
45
+ // only do classes which extend a base class e.g. User extends UserBase
46
+ if (!classInfo || classInfo.extends !== classInfo.name + "Base") {
47
+ return;
48
+ }
49
+ // need to check for PrivacyPolicy import...
50
+ traversed = true;
51
+ let klassContents = "";
52
+ for (const mm of node.members) {
53
+ if (isPrivacyPolicy(mm)) {
54
+ const property = mm;
55
+ // if invalid privacy policy, bounce
56
+ if (!property.initializer) {
57
+ traversed = false;
58
+ return;
59
+ }
60
+ const pp = property.initializer.getFullText(sourceFile);
61
+ const code = `getPrivacyPolicy(): PrivacyPolicy<this> {
62
+ return ${pp}
63
+ }`;
64
+ klassContents += code;
65
+ }
66
+ else {
67
+ klassContents += mm.getFullText(sourceFile);
68
+ }
69
+ }
70
+ // wrap comments and transform to export class Foo extends Bar { ${inner} }
71
+ nodes.push({ rawString: classInfo.wrapClassContents(klassContents) });
72
+ // console.debug(classInfo.wrapClassContents(klassContents));
73
+ });
74
+ // if traversed, overwrite.
75
+ if (!traversed) {
76
+ return;
77
+ }
78
+ let newContents = "";
79
+ for (const node of nodes) {
80
+ if (node.node) {
81
+ if (typescript_1.default.isImportDeclaration(node.node)) {
82
+ let transformed = (0, ast_1.transformImport)(contents, node.node, sourceFile, {
83
+ newImports: ["PrivacyPolicy"],
84
+ });
85
+ if (transformed) {
86
+ newContents += transformed;
87
+ continue;
88
+ }
89
+ }
90
+ newContents += node.node.getFullText(sourceFile);
91
+ }
92
+ else if (node.rawString) {
93
+ newContents += node.rawString;
94
+ }
95
+ else {
96
+ throw new Error(`malformed node with no node or rawString`);
97
+ }
98
+ fs.writeFileSync(file, newContents);
99
+ }
100
+ });
101
+ (0, child_process_1.execSync)("prettier src/ent/*.ts --write");
102
+ }
103
+ function isPrivacyPolicy(mm) {
104
+ return (mm.kind === typescript_1.default.SyntaxKind.PropertyDeclaration &&
105
+ mm.name.escapedText === "privacyPolicy");
106
+ }
107
+ main()
108
+ .then(() => {
109
+ process.exit(0);
110
+ })
111
+ .catch((err) => {
112
+ console.error(err);
113
+ process.exit(1);
114
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,357 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ const glob_1 = require("glob");
26
+ const typescript_1 = __importDefault(require("typescript"));
27
+ const fs = __importStar(require("fs"));
28
+ const compilerOptions_1 = require("../tsc/compilerOptions");
29
+ const child_process_1 = require("child_process");
30
+ const path_1 = __importDefault(require("path"));
31
+ const ast_1 = require("../tsc/ast");
32
+ async function main() {
33
+ // this assumes this is being run from root of directory
34
+ const options = (0, compilerOptions_1.readCompilerOptions)(".");
35
+ let files = glob_1.glob.sync("src/schema/*.ts");
36
+ const target = (0, compilerOptions_1.getTarget)(options.target?.toString());
37
+ // filter to only event.ts e.g. for comments and whitespace...
38
+ // files = files.filter((f) => f.endsWith("event.ts"));
39
+ files.forEach((file) => {
40
+ // assume valid file since we do glob above
41
+ // const idx = file.lastIndexOf(".ts");
42
+ // const writeFile = file.substring(0, idx) + "2" + ".ts";
43
+ // console.debug(file);
44
+ const writeFile = "src/schema/" + path_1.default.basename(file).slice(0, -3) + "_schema.ts";
45
+ // const writeFile = file;
46
+ // console.debug(file, writeFile);
47
+ // go through the file and print everything back if not starting immediately after other position
48
+ let { contents, sourceFile } = (0, compilerOptions_1.createSourceFile)(target, file);
49
+ const nodes = [];
50
+ let updateImport = false;
51
+ let removeImports = [];
52
+ const f = {
53
+ trackNode: function (tni) {
54
+ nodes.push({
55
+ node: tni.node,
56
+ importNode: tni.node && typescript_1.default.isImportDeclaration(tni.node),
57
+ rawString: tni.rawString,
58
+ });
59
+ if (tni.removeImports) {
60
+ removeImports.push(...tni.removeImports);
61
+ }
62
+ },
63
+ flagUpdateImport() {
64
+ updateImport = true;
65
+ },
66
+ };
67
+ if (!traverse(contents, sourceFile, f)) {
68
+ return;
69
+ }
70
+ let newContents = "";
71
+ for (const node of nodes) {
72
+ if (updateImport && node.importNode) {
73
+ const importNode = node.node;
74
+ const transformedImport = (0, ast_1.transformImport)(contents, importNode, sourceFile, {
75
+ removeImports,
76
+ transform: transformSchema,
77
+ });
78
+ if (transformedImport) {
79
+ newContents += transformedImport;
80
+ continue;
81
+ }
82
+ }
83
+ if (node.node) {
84
+ newContents += node.node.getFullText(sourceFile);
85
+ }
86
+ else if (node.rawString) {
87
+ newContents += node.rawString;
88
+ }
89
+ else {
90
+ console.error("invalid node");
91
+ }
92
+ }
93
+ // console.debug(newContents);
94
+ // ideally there's a flag that indicates if we write
95
+ fs.writeFileSync(writeFile, newContents);
96
+ fs.rmSync(file);
97
+ });
98
+ (0, child_process_1.execSync)("prettier src/schema/*.ts --write");
99
+ }
100
+ function traverse(fileContents, sourceFile, f) {
101
+ let traversed = false;
102
+ typescript_1.default.forEachChild(sourceFile, function (node) {
103
+ if (typescript_1.default.isClassDeclaration(node)) {
104
+ traversed = true;
105
+ // TODO address implicit schema doesn't work here...
106
+ // console.debug(sourceFile.fileName, node.kind);
107
+ if (traverseClass(fileContents, sourceFile, node, f)) {
108
+ f.flagUpdateImport();
109
+ return;
110
+ }
111
+ }
112
+ f.trackNode({ node });
113
+ });
114
+ return traversed;
115
+ }
116
+ function traverseClass(fileContents, sourceFile, node, f) {
117
+ const ci = getTransformClassInfo(fileContents, sourceFile, node);
118
+ if (!ci) {
119
+ return false;
120
+ }
121
+ let klassContents = `${ci.comment}const ${ci.name} = new ${ci.class}({\n`;
122
+ let removeImports = [];
123
+ if (ci.implementsSchema) {
124
+ removeImports.push("Schema");
125
+ }
126
+ for (let member of node.members) {
127
+ const fInfo = getClassElementInfo(fileContents, member, sourceFile);
128
+ if (!fInfo) {
129
+ return false;
130
+ }
131
+ klassContents += `${fInfo.comment}${fInfo.key}:${fInfo.value},\n`;
132
+ if (fInfo.type) {
133
+ removeImports.push(fInfo.type);
134
+ }
135
+ }
136
+ klassContents += "\n})";
137
+ if (ci.export && ci.default) {
138
+ klassContents += `\n export default ${ci.name};`;
139
+ }
140
+ else if (ci.export) {
141
+ klassContents = "export " + klassContents;
142
+ }
143
+ // console.debug(klassContents);
144
+ f.trackNode({ rawString: klassContents, removeImports: removeImports });
145
+ return true;
146
+ }
147
+ function transformSchema(str) {
148
+ // only do known class names
149
+ if (str === "BaseEntSchema" || str === "BaseEntSchemaWithTZ") {
150
+ return str.substring(4);
151
+ }
152
+ return str;
153
+ }
154
+ // TODO need to generify this...
155
+ // and then have a schema specific version
156
+ // may make sense to just duplicate this logic...
157
+ function getTransformClassInfo(fileContents, sourceFile, node) {
158
+ const generic = (0, ast_1.getClassInfo)(fileContents, sourceFile, node);
159
+ if (!generic) {
160
+ return;
161
+ }
162
+ let className = generic.name;
163
+ if (!className?.endsWith("Schema")) {
164
+ className += "Schema";
165
+ }
166
+ let implementsSchema = generic.implements?.some((v) => v == "Schema");
167
+ let classExtends = generic.extends;
168
+ if (classExtends && classExtends === transformSchema(classExtends)) {
169
+ return undefined;
170
+ }
171
+ if (!className || !node.heritageClauses || !classExtends) {
172
+ return undefined;
173
+ }
174
+ let ci = {
175
+ ...generic,
176
+ name: className,
177
+ class: classExtends,
178
+ implementsSchema,
179
+ };
180
+ return ci;
181
+ }
182
+ // intentionally doesn't parse decorators since we don't need it
183
+ function getClassElementInfo(fileContents, member, sourceFile) {
184
+ if (isFieldElement(member, sourceFile)) {
185
+ return getFieldElementInfo(fileContents, member, sourceFile);
186
+ }
187
+ if (member.kind === typescript_1.default.SyntaxKind.Constructor) {
188
+ return getConstructorElementInfo(fileContents, member, sourceFile);
189
+ }
190
+ if (member.kind !== typescript_1.default.SyntaxKind.PropertyDeclaration) {
191
+ return;
192
+ }
193
+ // other properties
194
+ const property = member;
195
+ if (!property.initializer) {
196
+ return;
197
+ }
198
+ const token = property.name;
199
+ return {
200
+ key: token.escapedText.toString(),
201
+ value: property.initializer?.getFullText(sourceFile),
202
+ comment: (0, ast_1.getPreText)(fileContents, member, sourceFile),
203
+ type: getType(property, sourceFile),
204
+ };
205
+ }
206
+ function getType(property, sourceFile) {
207
+ let propertytype = property.type?.getText(sourceFile) || "";
208
+ let ends = ["| null", "[]"];
209
+ for (const end of ends) {
210
+ if (propertytype.endsWith(end)) {
211
+ propertytype = propertytype.slice(0, -1 * end.length);
212
+ }
213
+ }
214
+ return propertytype;
215
+ }
216
+ function getFieldElementInfo(fileContents, member, sourceFile) {
217
+ let fieldMap = "";
218
+ // need to change to fields: {code: StringType()};
219
+ const property = member;
220
+ const initializer = property.initializer;
221
+ fieldMap += "{";
222
+ for (const element of initializer.elements) {
223
+ const parsed = parseFieldElement(element, sourceFile, fileContents);
224
+ if (parsed === null) {
225
+ return;
226
+ }
227
+ const { callEx, name, nameComment, properties } = parsed;
228
+ let property = "";
229
+ const fieldComment = (0, ast_1.getPreText)(fileContents, element, sourceFile).trim();
230
+ if (fieldComment) {
231
+ property += "\n" + fieldComment + "\n";
232
+ }
233
+ if (nameComment) {
234
+ property += nameComment + "\n";
235
+ }
236
+ // e.g. UUIDType, StringType etc
237
+ let call = callEx.expression.getText(sourceFile);
238
+ let fnCall = "";
239
+ if (properties.length) {
240
+ fnCall = `{${properties.join(",")}}`;
241
+ }
242
+ property += `${name}:${call}(${fnCall}),`;
243
+ fieldMap += property;
244
+ }
245
+ fieldMap += "}";
246
+ return {
247
+ key: "fields",
248
+ value: fieldMap,
249
+ comment: (0, ast_1.getPreText)(fileContents, member, sourceFile),
250
+ type: getType(property, sourceFile),
251
+ };
252
+ }
253
+ function getConstructorElementInfo(fileContents, member, sourceFile) {
254
+ const c = member;
255
+ //remove {}
256
+ let fullText = c.body?.getFullText(sourceFile) || "";
257
+ fullText = fullText.trim().slice(1, -1).trim();
258
+ // convert something like
259
+ /*
260
+ constructor() {
261
+ super();
262
+ this.addPatterns(
263
+ new Feedback(),
264
+ new DayOfWeek(),
265
+ new Feedback(),
266
+ new DayOfWeek(),
267
+ );
268
+ }
269
+ */
270
+ // into this.addPatterns(new Feedback(),new DayOfWeek(),new Feedback(),new DayOfWeek(),)
271
+ const lines = fullText
272
+ .split("\n")
273
+ .map((line) => line.trim())
274
+ .join("")
275
+ .split(";")
276
+ .filter((f) => f != "super()" && f != "");
277
+ // at this point there should be only line for what we handle
278
+ if (lines.length != 1) {
279
+ return;
280
+ }
281
+ const line = lines[0];
282
+ const addPatterns = "this.addPatterns(";
283
+ if (!line.startsWith(addPatterns)) {
284
+ return;
285
+ }
286
+ return {
287
+ key: "patterns",
288
+ // remove this.addPatterns at the front, remove trailing ) at the end
289
+ // if there's a trailing comma, it'll be handled by prettier
290
+ value: `[${line.slice(addPatterns.length, -1)}]`,
291
+ comment: "",
292
+ };
293
+ }
294
+ function isFieldElement(member, sourceFile) {
295
+ if (member.kind !== typescript_1.default.SyntaxKind.PropertyDeclaration) {
296
+ return false;
297
+ }
298
+ const property = member;
299
+ const token = property.name;
300
+ if (token.escapedText !== "fields") {
301
+ return false;
302
+ }
303
+ const propertytype = property.type?.getText(sourceFile);
304
+ if (propertytype !== "Field[]") {
305
+ return false;
306
+ }
307
+ if (property.initializer?.kind !== typescript_1.default.SyntaxKind.ArrayLiteralExpression) {
308
+ console.error("invalid array type");
309
+ return false;
310
+ }
311
+ return true;
312
+ }
313
+ function parseFieldElement(element, sourceFile, fileContents) {
314
+ if (element.kind !== typescript_1.default.SyntaxKind.CallExpression) {
315
+ console.error("skipped non-call expression");
316
+ return null;
317
+ }
318
+ let callEx = element;
319
+ if (callEx.arguments.length !== 1) {
320
+ console.error("callExpression with arguments not of length 1");
321
+ return null;
322
+ }
323
+ let arg = callEx.arguments[0];
324
+ if (arg.kind !== typescript_1.default.SyntaxKind.ObjectLiteralExpression) {
325
+ console.error("not objectLiteralExpression");
326
+ return null;
327
+ }
328
+ let expr = arg;
329
+ let name = "";
330
+ let propertyComment;
331
+ let properties = [];
332
+ for (const p of expr.properties) {
333
+ const p2 = p;
334
+ // found name property
335
+ if (p2.name.escapedText === "name") {
336
+ name = p2.initializer.getText(sourceFile);
337
+ // check for any comment associated with name: "fooo"
338
+ propertyComment = (0, ast_1.getPreText)(fileContents, p, sourceFile).trim();
339
+ }
340
+ else {
341
+ properties.push(p.getFullText(sourceFile));
342
+ }
343
+ }
344
+ if (!name) {
345
+ console.error(`couldn't find name property`);
346
+ return null;
347
+ }
348
+ // remove quotes
349
+ name = name.slice(1, -1);
350
+ return {
351
+ callEx,
352
+ name,
353
+ properties,
354
+ nameComment: propertyComment,
355
+ };
356
+ }
357
+ Promise.resolve(main());
@@ -1,14 +1,15 @@
1
- import { Ent, ID, Viewer, Data, EntConstructor } from "../core/base";
1
+ import { Ent, ID, Viewer, Data, EntConstructor, PrivacyPolicy } from "../core/base";
2
2
  import { Orchestrator } from "../action/orchestrator";
3
3
  import { Action, Builder, Changeset, WriteOperation, Validator, Trigger, Observer } from "../action";
4
- import { Schema } from "../schema";
4
+ import { FieldMap, Schema } from "../schema";
5
+ import { SchemaConfig } from "../schema/base_schema";
5
6
  export declare class User implements Ent {
6
7
  viewer: Viewer;
7
8
  data: Data;
8
9
  id: ID;
9
10
  accountID: string;
10
11
  nodeType: string;
11
- privacyPolicy: import("../core/base").PrivacyPolicy;
12
+ getPrivacyPolicy(): PrivacyPolicy<this>;
12
13
  firstName: string;
13
14
  constructor(viewer: Viewer, data: Data);
14
15
  }
@@ -18,7 +19,7 @@ export declare class Event implements Ent {
18
19
  id: ID;
19
20
  accountID: string;
20
21
  nodeType: string;
21
- privacyPolicy: import("../core/base").PrivacyPolicy;
22
+ getPrivacyPolicy(): PrivacyPolicy<this>;
22
23
  constructor(viewer: Viewer, data: Data);
23
24
  }
24
25
  export declare class Contact implements Ent {
@@ -27,7 +28,7 @@ export declare class Contact implements Ent {
27
28
  id: ID;
28
29
  accountID: string;
29
30
  nodeType: string;
30
- privacyPolicy: import("../core/base").PrivacyPolicy;
31
+ getPrivacyPolicy(): PrivacyPolicy<this>;
31
32
  constructor(viewer: Viewer, data: Data);
32
33
  }
33
34
  export declare class Group implements Ent {
@@ -36,7 +37,7 @@ export declare class Group implements Ent {
36
37
  id: ID;
37
38
  accountID: string;
38
39
  nodeType: string;
39
- privacyPolicy: import("../core/base").PrivacyPolicy;
40
+ getPrivacyPolicy(): PrivacyPolicy<this>;
40
41
  constructor(viewer: Viewer, data: Data);
41
42
  }
42
43
  export declare class Message implements Ent {
@@ -45,7 +46,7 @@ export declare class Message implements Ent {
45
46
  id: ID;
46
47
  accountID: string;
47
48
  nodeType: string;
48
- privacyPolicy: import("../core/base").PrivacyPolicy;
49
+ getPrivacyPolicy(): PrivacyPolicy<this>;
49
50
  constructor(viewer: Viewer, data: Data);
50
51
  }
51
52
  export declare class Address implements Ent {
@@ -54,12 +55,15 @@ export declare class Address implements Ent {
54
55
  id: ID;
55
56
  accountID: string;
56
57
  nodeType: string;
57
- privacyPolicy: import("../core/base").PrivacyPolicy;
58
+ getPrivacyPolicy(): PrivacyPolicy<this>;
58
59
  constructor(viewer: Viewer, data: Data);
59
60
  }
60
61
  export interface BuilderSchema<T extends Ent> extends Schema {
61
62
  ent: EntConstructor<T>;
62
63
  }
64
+ export declare function getBuilderSchema<T extends Ent>(cfg: SchemaConfig, ent: EntConstructor<T>): BuilderSchema<T>;
65
+ export declare function getBuilderSchemaFromFields<T extends Ent>(fields: FieldMap, ent: EntConstructor<T>): BuilderSchema<T>;
66
+ export declare function getBuilderSchemaTZFromFields<T extends Ent>(fields: FieldMap, ent: EntConstructor<T>): BuilderSchema<T>;
63
67
  export declare function getSchemaName(value: BuilderSchema<Ent>): string;
64
68
  export declare function getTableName(value: BuilderSchema<Ent>): string;
65
69
  export declare class SimpleBuilder<T extends Ent> implements Builder<T> {
@@ -69,10 +73,10 @@ export declare class SimpleBuilder<T extends Ent> implements Builder<T> {
69
73
  existingEnt: T | undefined;
70
74
  ent: EntConstructor<T>;
71
75
  placeholderID: ID;
72
- orchestrator: Orchestrator<T>;
76
+ orchestrator: Orchestrator<T, Data>;
73
77
  fields: Map<string, any>;
74
78
  nodeType: string;
75
- constructor(viewer: Viewer, schema: BuilderSchema<T>, fields: Map<string, any>, operation?: WriteOperation, existingEnt?: T | undefined, action?: Action<T> | undefined);
79
+ constructor(viewer: Viewer, schema: BuilderSchema<T>, fields: Map<string, any>, operation?: WriteOperation, existingEnt?: T | undefined, action?: Action<T, SimpleBuilder<T>, Data> | undefined);
76
80
  build(): Promise<Changeset<T>>;
77
81
  editedEnt(): Promise<T | null>;
78
82
  editedEntX(): Promise<T>;
@@ -84,16 +88,16 @@ export declare class SimpleBuilder<T extends Ent> implements Builder<T> {
84
88
  interface viewerEntLoadFunc {
85
89
  (data: Data): Viewer | Promise<Viewer>;
86
90
  }
87
- export declare class SimpleAction<T extends Ent> implements Action<T> {
91
+ export declare class SimpleAction<T extends Ent> implements Action<T, SimpleBuilder<T>, Data> {
88
92
  viewer: Viewer;
89
93
  private fields;
90
94
  builder: SimpleBuilder<T>;
91
- validators: Validator<T>[];
92
- triggers: Trigger<T>[];
93
- observers: Observer<T>[];
95
+ validators: Validator<SimpleBuilder<T>, Data>[];
96
+ triggers: Trigger<SimpleBuilder<T>, Data>[];
97
+ observers: Observer<SimpleBuilder<T>, Data>[];
94
98
  viewerForEntLoad: viewerEntLoadFunc | undefined;
95
99
  constructor(viewer: Viewer, schema: BuilderSchema<T>, fields: Map<string, any>, operation?: WriteOperation, existingEnt?: T | undefined);
96
- getPrivacyPolicy(): import("../core/base").PrivacyPolicy;
100
+ getPrivacyPolicy(): PrivacyPolicy<Ent>;
97
101
  getInput(): Data;
98
102
  changeset(): Promise<Changeset<T>>;
99
103
  valid(): Promise<boolean>;