@snowtop/ent 0.1.0-alpha9 → 0.1.0-alpha90
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.
- package/action/action.d.ts +36 -31
- package/action/action.js +2 -6
- package/action/executor.d.ts +3 -3
- package/action/executor.js +2 -2
- package/action/experimental_action.d.ts +29 -22
- package/action/experimental_action.js +29 -6
- package/action/orchestrator.d.ts +38 -16
- package/action/orchestrator.js +219 -61
- package/action/privacy.d.ts +2 -2
- package/core/base.d.ts +45 -24
- package/core/base.js +7 -1
- package/core/clause.d.ts +68 -7
- package/core/clause.js +291 -62
- package/core/config.d.ts +8 -0
- package/core/context.d.ts +5 -3
- package/core/context.js +20 -2
- package/core/convert.d.ts +1 -1
- package/core/db.d.ts +2 -2
- package/core/db.js +1 -1
- package/core/ent.d.ts +79 -24
- package/core/ent.js +520 -168
- package/core/loaders/assoc_count_loader.d.ts +2 -2
- package/core/loaders/assoc_count_loader.js +6 -1
- package/core/loaders/assoc_edge_loader.d.ts +2 -2
- package/core/loaders/index.d.ts +1 -1
- package/core/loaders/index.js +1 -3
- package/core/loaders/index_loader.d.ts +2 -2
- package/core/loaders/loader.js +5 -5
- package/core/loaders/object_loader.d.ts +6 -5
- package/core/loaders/object_loader.js +62 -58
- package/core/loaders/query_loader.d.ts +6 -12
- package/core/loaders/query_loader.js +47 -10
- package/core/loaders/raw_count_loader.d.ts +2 -2
- package/core/logger.d.ts +1 -1
- package/core/logger.js +1 -0
- package/core/privacy.d.ts +26 -25
- package/core/privacy.js +21 -25
- package/core/query/assoc_query.d.ts +6 -6
- package/core/query/custom_clause_query.d.ts +24 -0
- package/core/query/custom_clause_query.js +72 -0
- package/core/query/custom_query.d.ts +20 -5
- package/core/query/custom_query.js +77 -10
- package/core/query/index.d.ts +1 -0
- package/core/query/index.js +3 -1
- package/core/query/query.d.ts +1 -1
- package/core/query/query.js +8 -1
- package/core/query/shared_assoc_test.d.ts +1 -1
- package/core/query/shared_assoc_test.js +17 -5
- package/core/query/shared_test.d.ts +3 -0
- package/core/query/shared_test.js +211 -30
- package/core/viewer.d.ts +3 -3
- package/core/viewer.js +1 -1
- package/graphql/graphql.js +6 -0
- package/graphql/query/edge_connection.d.ts +9 -9
- package/graphql/query/page_info.d.ts +1 -1
- package/index.d.ts +11 -5
- package/index.js +15 -6
- package/package.json +1 -1
- package/parse_schema/parse.d.ts +12 -3
- package/parse_schema/parse.js +70 -11
- package/schema/base_schema.js +3 -0
- package/schema/field.d.ts +44 -8
- package/schema/field.js +125 -9
- package/schema/index.d.ts +2 -2
- package/schema/json_field.d.ts +13 -1
- package/schema/json_field.js +28 -1
- package/schema/schema.d.ts +65 -11
- package/schema/schema.js +18 -4
- package/schema/struct_field.d.ts +11 -1
- package/schema/struct_field.js +44 -5
- package/scripts/custom_graphql.js +8 -3
- package/scripts/{transform_schema.d.ts → migrate_v0.1.d.ts} +0 -0
- package/scripts/migrate_v0.1.js +36 -0
- package/scripts/read_schema.js +15 -4
- package/testutils/builder.d.ts +31 -21
- package/testutils/builder.js +83 -29
- package/testutils/db/fixture.d.ts +10 -0
- package/testutils/db/fixture.js +26 -0
- package/testutils/db/{test_db.d.ts → temp_db.d.ts} +15 -3
- package/testutils/db/{test_db.js → temp_db.js} +70 -16
- package/testutils/db/value.d.ts +6 -0
- package/testutils/db/value.js +251 -0
- package/testutils/db_time_zone.d.ts +4 -0
- package/testutils/db_time_zone.js +41 -0
- package/testutils/fake_data/fake_contact.d.ts +5 -4
- package/testutils/fake_data/fake_contact.js +14 -6
- package/testutils/fake_data/fake_event.d.ts +5 -3
- package/testutils/fake_data/fake_event.js +8 -5
- package/testutils/fake_data/fake_user.d.ts +4 -4
- package/testutils/fake_data/fake_user.js +16 -13
- package/testutils/fake_data/test_helpers.d.ts +3 -2
- package/testutils/fake_data/test_helpers.js +8 -6
- package/testutils/fake_data/user_query.d.ts +8 -6
- package/testutils/fake_data/user_query.js +28 -21
- package/testutils/fake_log.d.ts +3 -3
- package/testutils/parse_sql.d.ts +6 -0
- package/testutils/parse_sql.js +16 -2
- package/testutils/test_edge_global_schema.d.ts +15 -0
- package/testutils/test_edge_global_schema.js +58 -0
- package/testutils/write.d.ts +2 -2
- package/testutils/write.js +29 -7
- package/tsc/ast.d.ts +44 -0
- package/tsc/ast.js +267 -0
- package/tsc/compilerOptions.d.ts +6 -0
- package/tsc/compilerOptions.js +40 -1
- package/tsc/move_generated.d.ts +1 -0
- package/tsc/move_generated.js +160 -0
- package/tsc/transform.d.ts +21 -0
- package/tsc/transform.js +167 -0
- package/tsc/transform_action.d.ts +22 -0
- package/tsc/transform_action.js +179 -0
- package/tsc/transform_ent.d.ts +17 -0
- package/tsc/transform_ent.js +59 -0
- package/tsc/transform_schema.d.ts +27 -0
- package/tsc/transform_schema.js +379 -0
- package/scripts/transform_schema.js +0 -445
|
@@ -6,9 +6,13 @@ const ent_1 = require("../ent");
|
|
|
6
6
|
const viewer_1 = require("../viewer");
|
|
7
7
|
const index_1 = require("../../testutils/fake_data/index");
|
|
8
8
|
const test_helpers_1 = require("../../testutils/fake_data/test_helpers");
|
|
9
|
-
const
|
|
9
|
+
const temp_db_1 = require("../../testutils/db/temp_db");
|
|
10
10
|
const test_context_1 = require("../../testutils/context/test_context");
|
|
11
11
|
const logger_1 = require("../logger");
|
|
12
|
+
const test_edge_global_schema_1 = require("../../testutils/test_edge_global_schema");
|
|
13
|
+
const builder_1 = require("../../testutils/builder");
|
|
14
|
+
const action_1 = require("../../action");
|
|
15
|
+
const mock_log_1 = require("../../testutils/mock_log");
|
|
12
16
|
class TestQueryFilter {
|
|
13
17
|
constructor(filter, newQuery, ents, defaultViewer) {
|
|
14
18
|
this.filter = filter;
|
|
@@ -17,11 +21,15 @@ class TestQueryFilter {
|
|
|
17
21
|
this.defaultViewer = defaultViewer;
|
|
18
22
|
this.allContacts = [];
|
|
19
23
|
this.filteredContacts = [];
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
const q = this.newQuery(this.defaultViewer);
|
|
26
|
+
// TODO sad not generic enough
|
|
27
|
+
this.customQuery =
|
|
28
|
+
q instanceof index_1.UserToContactsFkeyQuery ||
|
|
29
|
+
q instanceof index_1.UserToContactsFkeyQueryDeprecated;
|
|
20
30
|
}
|
|
21
|
-
async
|
|
22
|
-
// console.log("sss");
|
|
31
|
+
async createData() {
|
|
23
32
|
[this.user, this.allContacts] = await (0, test_helpers_1.createAllContacts)();
|
|
24
|
-
// console.log(this.user, this.contacts);
|
|
25
33
|
// this.allContacts = this.allContacts.reverse();
|
|
26
34
|
this.filteredContacts = this.ents(this.allContacts);
|
|
27
35
|
db_mock_1.QueryRecorder.clearQueries();
|
|
@@ -37,19 +45,19 @@ class TestQueryFilter {
|
|
|
37
45
|
expect(ids).toEqual(this.filteredContacts.map((contact) => contact.id));
|
|
38
46
|
}
|
|
39
47
|
// rawCount isn't affected by filters...
|
|
40
|
-
async testRawCount() {
|
|
48
|
+
async testRawCount(expectedCount) {
|
|
41
49
|
const count = await this.getQuery().queryRawCount();
|
|
42
|
-
this.verifyRawCount(count);
|
|
50
|
+
this.verifyRawCount(count, expectedCount);
|
|
43
51
|
}
|
|
44
|
-
verifyRawCount(count) {
|
|
45
|
-
expect(count).toBe(test_helpers_1.inputs.length);
|
|
52
|
+
verifyRawCount(count, expectedCount) {
|
|
53
|
+
expect(count).toBe(expectedCount ?? test_helpers_1.inputs.length);
|
|
46
54
|
}
|
|
47
|
-
async testCount() {
|
|
55
|
+
async testCount(expectedCount) {
|
|
48
56
|
const count = await this.getQuery().queryCount();
|
|
49
|
-
this.verifyCount(count);
|
|
57
|
+
this.verifyCount(count, expectedCount);
|
|
50
58
|
}
|
|
51
|
-
verifyCount(count) {
|
|
52
|
-
expect(count).toBe(this.filteredContacts.length);
|
|
59
|
+
verifyCount(count, expectedCount) {
|
|
60
|
+
expect(count).toBe(expectedCount ?? this.filteredContacts.length);
|
|
53
61
|
}
|
|
54
62
|
async testEdges() {
|
|
55
63
|
const edges = await this.getQuery().queryEdges();
|
|
@@ -58,21 +66,60 @@ class TestQueryFilter {
|
|
|
58
66
|
verifyEdges(edges) {
|
|
59
67
|
const q = this.getQuery();
|
|
60
68
|
// TODO sad not generic enough
|
|
61
|
-
if (
|
|
69
|
+
if (this.customQuery) {
|
|
62
70
|
(0, test_helpers_1.verifyUserToContactRawData)(this.user, edges, this.filteredContacts);
|
|
63
71
|
}
|
|
64
72
|
else {
|
|
65
73
|
(0, test_helpers_1.verifyUserToContactEdges)(this.user, edges, this.filteredContacts);
|
|
66
74
|
}
|
|
67
75
|
}
|
|
68
|
-
async testEnts() {
|
|
69
|
-
const
|
|
70
|
-
this.verifyEnts(
|
|
76
|
+
async testEnts(v) {
|
|
77
|
+
const ents = await this.getQuery(v || new viewer_1.IDViewer(this.user.id)).queryEnts();
|
|
78
|
+
this.verifyEnts(ents);
|
|
79
|
+
return ents;
|
|
80
|
+
}
|
|
81
|
+
async testEntsCache() {
|
|
82
|
+
if (!this.customQuery) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
(0, logger_1.setLogLevels)(["query", "cache"]);
|
|
86
|
+
const ml = new mock_log_1.MockLogs();
|
|
87
|
+
ml.mock();
|
|
88
|
+
const v = new test_context_1.TestContext(new viewer_1.IDViewer(this.user.id)).getViewer();
|
|
89
|
+
const ents = await this.testEnts(v);
|
|
90
|
+
expect(ml.logs.length).toBe(1);
|
|
91
|
+
expect(ml.logs[0].query).toMatch(/SELECT (.+) FROM /);
|
|
92
|
+
await Promise.all(ents.map((ent) => index_1.FakeContact.loadX(v, ent.id)));
|
|
93
|
+
expect(ml.logs.length).toBe(this.filteredContacts.length + 1);
|
|
94
|
+
for (const log of ml.logs.slice(1)) {
|
|
95
|
+
expect(log["ent-cache-hit"]).toBeDefined();
|
|
96
|
+
}
|
|
97
|
+
ml.restore();
|
|
98
|
+
(0, logger_1.clearLogLevels)();
|
|
99
|
+
}
|
|
100
|
+
async testDataCache() {
|
|
101
|
+
if (!this.customQuery) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
(0, logger_1.setLogLevels)(["query", "cache"]);
|
|
105
|
+
const ml = new mock_log_1.MockLogs();
|
|
106
|
+
ml.mock();
|
|
107
|
+
const v = new test_context_1.TestContext(new viewer_1.IDViewer(this.user.id)).getViewer();
|
|
108
|
+
const ents = await this.testEnts(v);
|
|
109
|
+
expect(ml.logs.length).toBe(1);
|
|
110
|
+
expect(ml.logs[0].query).toMatch(/SELECT (.+) FROM /);
|
|
111
|
+
await Promise.all(ents.map((ent) => index_1.FakeContact.loadRawData(ent.id, v.context)));
|
|
112
|
+
expect(ml.logs.length).toBe(this.filteredContacts.length + 1);
|
|
113
|
+
for (const log of ml.logs.slice(1)) {
|
|
114
|
+
expect(log["dataloader-cache-hit"]).toBeDefined();
|
|
115
|
+
}
|
|
116
|
+
ml.restore();
|
|
117
|
+
(0, logger_1.clearLogLevels)();
|
|
71
118
|
}
|
|
72
119
|
verifyEnts(ents) {
|
|
73
120
|
(0, test_helpers_1.verifyUserToContacts)(this.user, ents, this.filteredContacts);
|
|
74
121
|
}
|
|
75
|
-
async testAll() {
|
|
122
|
+
async testAll(expectedCount) {
|
|
76
123
|
const query = this.getQuery(new viewer_1.IDViewer(this.user.id));
|
|
77
124
|
const [edges, count, ids, rawCount, ents] = await Promise.all([
|
|
78
125
|
query.queryEdges(),
|
|
@@ -81,10 +128,10 @@ class TestQueryFilter {
|
|
|
81
128
|
query.queryRawCount(),
|
|
82
129
|
query.queryEnts(),
|
|
83
130
|
]);
|
|
84
|
-
this.verifyCount(count);
|
|
131
|
+
this.verifyCount(count, expectedCount);
|
|
85
132
|
this.verifyEdges(edges);
|
|
86
133
|
this.verifyIDs(ids);
|
|
87
|
-
this.verifyRawCount(rawCount);
|
|
134
|
+
this.verifyRawCount(rawCount, expectedCount);
|
|
88
135
|
this.verifyEnts(ents);
|
|
89
136
|
}
|
|
90
137
|
}
|
|
@@ -125,7 +172,19 @@ const commonTests = (opts) => {
|
|
|
125
172
|
expect(queries.length).toBe(length);
|
|
126
173
|
const query = queries[0];
|
|
127
174
|
const result = [...opts.where.matchAll(preparedVar)];
|
|
128
|
-
|
|
175
|
+
let parts = opts.where.split(" AND ");
|
|
176
|
+
if (parts[parts.length - 1] === "deleted_at IS NULL") {
|
|
177
|
+
parts = parts
|
|
178
|
+
.slice(0, parts.length - 1)
|
|
179
|
+
.concat([
|
|
180
|
+
`${opts.sortCol} < $${result.length + 1}`,
|
|
181
|
+
"deleted_at IS NULL",
|
|
182
|
+
]);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
parts.push(`${opts.sortCol} < $${result.length + 1}`);
|
|
186
|
+
}
|
|
187
|
+
expect(query.qs?.whereClause).toBe(`${parts.join(" AND ")} ORDER BY ${opts.sortCol} DESC LIMIT 4`);
|
|
129
188
|
}
|
|
130
189
|
function verifyLastBeforeCursorQuery(length = 1) {
|
|
131
190
|
if (opts.livePostgresDB || opts.sqlite) {
|
|
@@ -135,9 +194,21 @@ const commonTests = (opts) => {
|
|
|
135
194
|
expect(queries.length).toBe(length);
|
|
136
195
|
const query = queries[0];
|
|
137
196
|
const result = [...opts.where.matchAll(preparedVar)];
|
|
197
|
+
let parts = opts.where.split(" AND ");
|
|
198
|
+
if (parts[parts.length - 1] === "deleted_at IS NULL") {
|
|
199
|
+
parts = parts
|
|
200
|
+
.slice(0, parts.length - 1)
|
|
201
|
+
.concat([
|
|
202
|
+
`${opts.sortCol} > $${result.length + 1}`,
|
|
203
|
+
"deleted_at IS NULL",
|
|
204
|
+
]);
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
parts.push(`${opts.sortCol} > $${result.length + 1}`);
|
|
208
|
+
}
|
|
138
209
|
expect(query.qs?.whereClause).toBe(
|
|
139
210
|
// extra fetched for pagination
|
|
140
|
-
`${
|
|
211
|
+
`${parts.join(" AND ")} ORDER BY ${opts.sortCol} ASC LIMIT 4`);
|
|
141
212
|
}
|
|
142
213
|
function getViewer() {
|
|
143
214
|
// live db, let's do context because we're testing complicated paths
|
|
@@ -171,20 +242,26 @@ const commonTests = (opts) => {
|
|
|
171
242
|
cursorKey: opts.sortCol,
|
|
172
243
|
});
|
|
173
244
|
}
|
|
245
|
+
if (opts.globalSchema) {
|
|
246
|
+
(0, ent_1.setGlobalSchema)(test_edge_global_schema_1.testEdgeGlobalSchema);
|
|
247
|
+
}
|
|
174
248
|
let tdb;
|
|
175
249
|
if (opts.sqlite) {
|
|
176
|
-
|
|
177
|
-
|
|
250
|
+
(0, temp_db_1.setupSqlite)(`sqlite:///shared_test+${opts.uniqKey}.db`, () => (0, test_helpers_1.tempDBTables)(opts.globalSchema), {
|
|
251
|
+
disableDeleteAfterEachTest: true,
|
|
252
|
+
});
|
|
178
253
|
}
|
|
179
254
|
beforeAll(async () => {
|
|
180
255
|
// want error on by default in tests?
|
|
181
256
|
(0, logger_1.setLogLevels)(["error", "warn", "info"]);
|
|
182
257
|
if (opts.livePostgresDB) {
|
|
183
258
|
tdb = await (0, test_helpers_1.setupTempDB)();
|
|
259
|
+
return;
|
|
184
260
|
}
|
|
261
|
+
await (0, test_helpers_1.createEdges)();
|
|
185
262
|
});
|
|
186
263
|
beforeEach(async () => {
|
|
187
|
-
if (opts.livePostgresDB) {
|
|
264
|
+
if (opts.livePostgresDB || opts.sqlite) {
|
|
188
265
|
return;
|
|
189
266
|
}
|
|
190
267
|
await (0, test_helpers_1.createEdges)();
|
|
@@ -196,7 +273,7 @@ const commonTests = (opts) => {
|
|
|
196
273
|
});
|
|
197
274
|
describe("simple queries", () => {
|
|
198
275
|
const filter = new TestQueryFilter((q) => {
|
|
199
|
-
// no
|
|
276
|
+
// no filters
|
|
200
277
|
return q;
|
|
201
278
|
}, opts.newQuery, (contacts) => {
|
|
202
279
|
// nothing to do here
|
|
@@ -204,7 +281,7 @@ const commonTests = (opts) => {
|
|
|
204
281
|
return contacts.reverse();
|
|
205
282
|
}, getViewer());
|
|
206
283
|
beforeEach(async () => {
|
|
207
|
-
await filter.
|
|
284
|
+
await filter.createData();
|
|
208
285
|
});
|
|
209
286
|
test("ids", async () => {
|
|
210
287
|
await filter.testIDs();
|
|
@@ -229,6 +306,67 @@ const commonTests = (opts) => {
|
|
|
229
306
|
test("all", async () => {
|
|
230
307
|
await filter.testAll();
|
|
231
308
|
});
|
|
309
|
+
test("ents cache", async () => {
|
|
310
|
+
await filter.testEntsCache();
|
|
311
|
+
});
|
|
312
|
+
test("data cache", async () => {
|
|
313
|
+
await filter.testDataCache();
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
describe("after delete", () => {
|
|
317
|
+
const filter = new TestQueryFilter((q) => {
|
|
318
|
+
// no filters
|
|
319
|
+
return q;
|
|
320
|
+
}, opts.newQuery, (contacts) => {
|
|
321
|
+
// nothing expected since deleted
|
|
322
|
+
return [];
|
|
323
|
+
}, getViewer());
|
|
324
|
+
beforeEach(async () => {
|
|
325
|
+
await filter.createData();
|
|
326
|
+
const action = new builder_1.SimpleAction(filter.user.viewer, index_1.FakeUserSchema, new Map(), action_1.WriteOperation.Edit, filter.user);
|
|
327
|
+
await Promise.all(filter.allContacts.map(async (contact) => {
|
|
328
|
+
action.builder.orchestrator.removeOutboundEdge(contact.id, index_1.EdgeType.UserToContacts);
|
|
329
|
+
const action2 = new builder_1.SimpleAction(filter.user.viewer, index_1.FakeContactSchema, new Map(), action_1.WriteOperation.Delete, contact);
|
|
330
|
+
await action2.save();
|
|
331
|
+
}));
|
|
332
|
+
await action.save();
|
|
333
|
+
db_mock_1.QueryRecorder.clearQueries();
|
|
334
|
+
});
|
|
335
|
+
test("ids", async () => {
|
|
336
|
+
await filter.testIDs();
|
|
337
|
+
verifyQuery({});
|
|
338
|
+
});
|
|
339
|
+
test("rawCount", async () => {
|
|
340
|
+
await filter.testRawCount(0);
|
|
341
|
+
verifyCountQuery({});
|
|
342
|
+
});
|
|
343
|
+
test("count", async () => {
|
|
344
|
+
await filter.testCount(0);
|
|
345
|
+
verifyQuery({});
|
|
346
|
+
});
|
|
347
|
+
test("edges", async () => {
|
|
348
|
+
await filter.testEdges();
|
|
349
|
+
verifyQuery({});
|
|
350
|
+
});
|
|
351
|
+
test("ents", async () => {
|
|
352
|
+
await filter.testEnts();
|
|
353
|
+
// no ents so no subsequent query. just the edge query
|
|
354
|
+
verifyQuery({ length: 1 });
|
|
355
|
+
});
|
|
356
|
+
test("all", async () => {
|
|
357
|
+
await filter.testAll(0);
|
|
358
|
+
});
|
|
359
|
+
test("raw_data", async () => {
|
|
360
|
+
if (opts.rawDataVerify) {
|
|
361
|
+
await opts.rawDataVerify(filter.user);
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
test("ents cache", async () => {
|
|
365
|
+
await filter.testEntsCache();
|
|
366
|
+
});
|
|
367
|
+
test("data cache", async () => {
|
|
368
|
+
await filter.testDataCache();
|
|
369
|
+
});
|
|
232
370
|
});
|
|
233
371
|
describe("first. no cursor", () => {
|
|
234
372
|
const N = 2;
|
|
@@ -239,7 +377,7 @@ const commonTests = (opts) => {
|
|
|
239
377
|
return contacts.reverse().slice(0, N);
|
|
240
378
|
}, getViewer());
|
|
241
379
|
beforeEach(async () => {
|
|
242
|
-
await filter.
|
|
380
|
+
await filter.createData();
|
|
243
381
|
});
|
|
244
382
|
test("ids", async () => {
|
|
245
383
|
await filter.testIDs();
|
|
@@ -264,6 +402,12 @@ const commonTests = (opts) => {
|
|
|
264
402
|
test("all", async () => {
|
|
265
403
|
await filter.testAll();
|
|
266
404
|
});
|
|
405
|
+
test("ents cache", async () => {
|
|
406
|
+
await filter.testEntsCache();
|
|
407
|
+
});
|
|
408
|
+
test("data cache", async () => {
|
|
409
|
+
await filter.testDataCache();
|
|
410
|
+
});
|
|
267
411
|
});
|
|
268
412
|
describe("last", () => {
|
|
269
413
|
const N = 2;
|
|
@@ -275,7 +419,7 @@ const commonTests = (opts) => {
|
|
|
275
419
|
return contacts.slice(0, N).reverse();
|
|
276
420
|
}, getViewer());
|
|
277
421
|
beforeEach(async () => {
|
|
278
|
-
await filter.
|
|
422
|
+
await filter.createData();
|
|
279
423
|
});
|
|
280
424
|
test("ids", async () => {
|
|
281
425
|
await filter.testIDs();
|
|
@@ -300,6 +444,12 @@ const commonTests = (opts) => {
|
|
|
300
444
|
test("all", async () => {
|
|
301
445
|
await filter.testAll();
|
|
302
446
|
});
|
|
447
|
+
test("ents cache", async () => {
|
|
448
|
+
await filter.testEntsCache();
|
|
449
|
+
});
|
|
450
|
+
test("data cache", async () => {
|
|
451
|
+
await filter.testDataCache();
|
|
452
|
+
});
|
|
303
453
|
});
|
|
304
454
|
describe("first after cursor", () => {
|
|
305
455
|
const idx = 2;
|
|
@@ -310,8 +460,18 @@ const commonTests = (opts) => {
|
|
|
310
460
|
// < check so we shouldn't get that index
|
|
311
461
|
return contacts.reverse().slice(idx + 1, idx + N);
|
|
312
462
|
}, getViewer());
|
|
463
|
+
beforeAll(async () => {
|
|
464
|
+
if (opts.livePostgresDB || opts.sqlite) {
|
|
465
|
+
await filter.createData();
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
// TODO do we still need QueryRecorder?
|
|
469
|
+
// should just delete this...
|
|
313
470
|
beforeEach(async () => {
|
|
314
|
-
|
|
471
|
+
if (opts.livePostgresDB || opts.sqlite) {
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
await filter.createData();
|
|
315
475
|
});
|
|
316
476
|
test("ids", async () => {
|
|
317
477
|
await filter.testIDs();
|
|
@@ -336,6 +496,12 @@ const commonTests = (opts) => {
|
|
|
336
496
|
test("all", async () => {
|
|
337
497
|
await filter.testAll();
|
|
338
498
|
});
|
|
499
|
+
test("ents cache", async () => {
|
|
500
|
+
await filter.testEntsCache();
|
|
501
|
+
});
|
|
502
|
+
test("data cache", async () => {
|
|
503
|
+
await filter.testDataCache();
|
|
504
|
+
});
|
|
339
505
|
});
|
|
340
506
|
test("first. after each cursor", async () => {
|
|
341
507
|
let [user, contacts] = await (0, test_helpers_1.createAllContacts)();
|
|
@@ -378,8 +544,17 @@ const commonTests = (opts) => {
|
|
|
378
544
|
// > check so we don't want that index
|
|
379
545
|
return contacts.reverse().slice(0, idx).reverse(); // because of order returned
|
|
380
546
|
}, getViewer());
|
|
547
|
+
beforeAll(async () => {
|
|
548
|
+
if (opts.livePostgresDB || opts.sqlite) {
|
|
549
|
+
await filter.createData();
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
// same TODO above
|
|
381
553
|
beforeEach(async () => {
|
|
382
|
-
|
|
554
|
+
if (opts.livePostgresDB || opts.sqlite) {
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
await filter.createData();
|
|
383
558
|
});
|
|
384
559
|
test("ids", async () => {
|
|
385
560
|
await filter.testIDs();
|
|
@@ -404,6 +579,12 @@ const commonTests = (opts) => {
|
|
|
404
579
|
test("all", async () => {
|
|
405
580
|
await filter.testAll();
|
|
406
581
|
});
|
|
582
|
+
test("ents cache", async () => {
|
|
583
|
+
await filter.testEntsCache();
|
|
584
|
+
});
|
|
585
|
+
test("data cache", async () => {
|
|
586
|
+
await filter.testDataCache();
|
|
587
|
+
});
|
|
407
588
|
});
|
|
408
589
|
test("last. before each cursor", async () => {
|
|
409
590
|
let [user, contacts] = await (0, test_helpers_1.createAllContacts)();
|
package/core/viewer.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ID, Ent, Viewer, Context } from "./base";
|
|
2
2
|
export declare class LoggedOutViewer implements Viewer {
|
|
3
|
-
context?: Context | undefined;
|
|
4
|
-
constructor(context?: Context | undefined);
|
|
3
|
+
context?: Context<Viewer<Ent<any> | null, ID | null>> | undefined;
|
|
4
|
+
constructor(context?: Context<Viewer<Ent<any> | null, ID | null>> | undefined);
|
|
5
5
|
viewerID: null;
|
|
6
6
|
viewer(): Promise<null>;
|
|
7
7
|
instanceKey(): string;
|
|
@@ -18,6 +18,6 @@ export declare class IDViewer implements Viewer {
|
|
|
18
18
|
constructor(viewerID: ID, opts?: Partial<IDViewerOptions>);
|
|
19
19
|
constructor(opts: IDViewerOptions);
|
|
20
20
|
setContext(ctx: Context): this;
|
|
21
|
-
viewer(): Promise<Ent | null>;
|
|
21
|
+
viewer(): Promise<Ent<Viewer<Ent<any> | null, ID | null>> | null>;
|
|
22
22
|
instanceKey(): string;
|
|
23
23
|
}
|
package/core/viewer.js
CHANGED
package/graphql/graphql.js
CHANGED
|
@@ -85,6 +85,12 @@ const addCustomType = (type) => {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
catch (e) {
|
|
88
|
+
if (type.secondaryImportPath) {
|
|
89
|
+
(0, exports.addCustomType)({
|
|
90
|
+
...type,
|
|
91
|
+
importPath: type.secondaryImportPath,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
88
94
|
return;
|
|
89
95
|
}
|
|
90
96
|
GQLCapture.getCustomTypes().set(type.type, type);
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import { EdgeQuery, PaginationInfo } from "../../core/query/query";
|
|
2
|
-
import { Data, Ent, Viewer } from "../../core/base";
|
|
2
|
+
import { Data, Ent, ID, Viewer } from "../../core/base";
|
|
3
3
|
export interface GraphQLEdge<T extends Data> {
|
|
4
4
|
edge: T;
|
|
5
5
|
node: Ent;
|
|
6
6
|
cursor: string;
|
|
7
7
|
}
|
|
8
|
-
interface edgeQueryCtr<T extends Ent, TEdge extends Data> {
|
|
9
|
-
(v:
|
|
8
|
+
interface edgeQueryCtr<T extends Ent, TEdge extends Data, TViewer extends Viewer> {
|
|
9
|
+
(v: TViewer, src: T): EdgeQuery<T, Ent, TEdge>;
|
|
10
10
|
}
|
|
11
|
-
interface edgeQueryCtr2<T extends Ent, TEdge extends Data> {
|
|
12
|
-
(v:
|
|
11
|
+
interface edgeQueryCtr2<T extends Ent, TEdge extends Data, TViewer extends Viewer> {
|
|
12
|
+
(v: TViewer): EdgeQuery<T, Ent, TEdge>;
|
|
13
13
|
}
|
|
14
|
-
export declare class GraphQLEdgeConnection<TSource extends Ent, TEdge extends Data> {
|
|
14
|
+
export declare class GraphQLEdgeConnection<TSource extends Ent, TEdge extends Data, TViewer extends Viewer = Viewer> {
|
|
15
15
|
query: EdgeQuery<TSource, Ent, TEdge>;
|
|
16
16
|
private results;
|
|
17
17
|
private viewer;
|
|
18
18
|
private source?;
|
|
19
19
|
private args?;
|
|
20
|
-
constructor(viewer:
|
|
21
|
-
constructor(viewer:
|
|
20
|
+
constructor(viewer: TViewer, source: TSource, getQuery: edgeQueryCtr<TSource, TEdge, TViewer>, args?: Data);
|
|
21
|
+
constructor(viewer: TViewer, getQuery: edgeQueryCtr2<TSource, TEdge, TViewer>, args?: Data);
|
|
22
22
|
first(limit: number, cursor?: string): void;
|
|
23
23
|
last(limit: number, cursor?: string): void;
|
|
24
24
|
modifyQuery(fn: (query: EdgeQuery<TSource, Ent, TEdge>) => EdgeQuery<TSource, Ent, TEdge>): void;
|
|
25
25
|
queryTotalCount(): Promise<number>;
|
|
26
26
|
queryEdges(): Promise<GraphQLEdge<TEdge>[]>;
|
|
27
|
-
queryNodes(): Promise<Ent[]>;
|
|
27
|
+
queryNodes(): Promise<Ent<Viewer<Ent<any> | null, ID | null>>[]>;
|
|
28
28
|
private defaultPageInfo;
|
|
29
29
|
queryPageInfo(): Promise<PaginationInfo>;
|
|
30
30
|
private queryData;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { GraphQLObjectType } from "graphql";
|
|
2
2
|
import { RequestContext } from "../../core/context";
|
|
3
3
|
import { PaginationInfo } from "../../core/query/query";
|
|
4
|
-
export declare const GraphQLPageInfo: GraphQLObjectType<PaginationInfo, RequestContext
|
|
4
|
+
export declare const GraphQLPageInfo: GraphQLObjectType<PaginationInfo, RequestContext<import("../..").Viewer<import("../..").Ent<any> | null, import("../..").ID | null>>>;
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from "./core/base";
|
|
2
|
-
export { loadEnt, loadCustomData, loadCustomEnts, loadEntX, loadEnts, CustomQuery, loadDerivedEnt, loadDerivedEntX, loadEntViaKey, loadEntXViaKey, performRawQuery, loadRowX, loadRow, loadRows, DataOperation, EditNodeOptions, EditNodeOperation, EdgeOperation, DeleteNodeOperation, AssocEdge, AssocEdgeInputOptions, AssocEdgeInput, AssocEdgeData, loadEdgeData, loadEdgeDatas, loadEdges, loadUniqueEdge, loadUniqueNode, loadRawEdgeCountX, loadEdgeForID2, loadNodesByEdge, getEdgeTypeInGroup, } from "./core/ent";
|
|
2
|
+
export { loadEnt, loadCustomData, loadCustomEnts, loadCustomCount, loadEntX, loadEnts, CustomQuery, loadDerivedEnt, loadDerivedEntX, loadEntViaKey, loadEntXViaKey, performRawQuery, loadRowX, loadRow, loadRows, DataOperation, EditNodeOptions, EditNodeOperation, RawQueryOperation, EdgeOperation, DeleteNodeOperation, AssocEdge, AssocEdgeInputOptions, AssocEdgeInput, AssocEdgeData, loadEdgeData, loadEdgeDatas, loadEdges, loadUniqueEdge, loadUniqueNode, loadRawEdgeCountX, loadEdgeForID2, loadNodesByEdge, getEdgeTypeInGroup, setGlobalSchema, } from "./core/ent";
|
|
3
3
|
import DB from "./core/db";
|
|
4
4
|
export * from "./core/loaders";
|
|
5
5
|
export { DB };
|
|
@@ -13,6 +13,7 @@ declare const query: {
|
|
|
13
13
|
And: typeof q.And;
|
|
14
14
|
AndOptional: typeof q.AndOptional;
|
|
15
15
|
Or: typeof q.Or;
|
|
16
|
+
OrOptional: typeof q.OrOptional;
|
|
16
17
|
In: typeof q.In;
|
|
17
18
|
Greater: typeof q.Greater;
|
|
18
19
|
Less: typeof q.Less;
|
|
@@ -20,10 +21,15 @@ declare const query: {
|
|
|
20
21
|
LessEq: typeof q.LessEq;
|
|
21
22
|
ArrayEq: typeof q.ArrayEq;
|
|
22
23
|
ArrayNotEq: typeof q.ArrayNotEq;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
PostgresArrayContainsValue: typeof q.PostgresArrayContainsValue;
|
|
25
|
+
PostgresArrayContains: typeof q.PostgresArrayContains;
|
|
26
|
+
PostgresArrayNotContainsValue: typeof q.PostgresArrayNotContainsValue;
|
|
27
|
+
PostgresArrayNotContains: typeof q.PostgresArrayNotContains;
|
|
28
|
+
PostgresArrayOverlaps: typeof q.PostgresArrayOverlaps;
|
|
29
|
+
PostgresArrayNotOverlaps: typeof q.PostgresArrayNotOverlaps;
|
|
30
|
+
JSONPathValuePredicate: typeof q.JSONPathValuePredicate;
|
|
31
|
+
JSONObjectFieldKeyASJSON: typeof q.JSONObjectFieldKeyASJSON;
|
|
32
|
+
JSONObjectFieldKeyAsText: typeof q.JSONObjectFieldKeyAsText;
|
|
27
33
|
TsQuery: typeof q.TsQuery;
|
|
28
34
|
PlainToTsQuery: typeof q.PlainToTsQuery;
|
|
29
35
|
PhraseToTsQuery: typeof q.PhraseToTsQuery;
|
package/index.js
CHANGED
|
@@ -25,13 +25,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.
|
|
29
|
-
exports.setLogLevels = exports.loadConfig = exports.LoggedOutViewer = exports.IDViewer = exports.ContextCache = exports.query = exports.AllowIfViewerHasIdentityPrivacyPolicy = exports.AllowIfViewerPrivacyPolicy = exports.AllowIfSubPolicyAllowsRule = exports.AllowIfConditionAppliesRule = exports.AlwaysDenyPrivacyPolicy = exports.AlwaysAllowPrivacyPolicy = exports.applyPrivacyPolicyX = exports.applyPrivacyPolicy = exports.DelayedResultRule = exports.DenyIfEntIsVisiblePolicy = exports.AllowIfEntIsVisiblePolicy = exports.DenyIfEntIsNotVisibleRule = exports.DenyIfEntIsVisibleRule = exports.AllowIfEntIsNotVisibleRule = exports.AllowIfEntIsVisibleRule = exports.DenyIfViewerOutboundEdgeDoesNotExistRule = void 0;
|
|
28
|
+
exports.DenyIfViewerInboundEdgeExistsRule = exports.DenyIfEdgeExistsRule = exports.AllowIfViewerOutboundEdgeExistsRule = exports.AllowIfViewerInboundEdgeExistsRule = exports.AllowIfEdgeExistsRule = exports.DenyIfViewerEqualsRule = exports.AllowIfViewerEqualsRule = exports.DenyIfEntPropertyIsRule = exports.AllowIfEntPropertyIsRule = exports.AllowIfViewerIsEntPropertyRule = exports.AllowIfViewerIsRule = exports.AllowIfFuncRule = exports.AllowIfViewerRule = exports.AllowIfHasIdentity = exports.DenyIfLoggedOutRule = exports.DenyIfLoggedInRule = exports.AlwaysDenyRule = exports.AlwaysAllowRule = exports.EntPrivacyError = exports.DB = exports.setGlobalSchema = exports.getEdgeTypeInGroup = exports.loadNodesByEdge = exports.loadEdgeForID2 = exports.loadRawEdgeCountX = exports.loadUniqueNode = exports.loadUniqueEdge = exports.loadEdges = exports.loadEdgeDatas = exports.loadEdgeData = exports.AssocEdgeData = exports.AssocEdge = exports.DeleteNodeOperation = exports.EdgeOperation = exports.RawQueryOperation = exports.EditNodeOperation = exports.loadRows = exports.loadRow = exports.loadRowX = exports.performRawQuery = exports.loadEntXViaKey = exports.loadEntViaKey = exports.loadDerivedEntX = exports.loadDerivedEnt = exports.loadEnts = exports.loadEntX = exports.loadCustomCount = exports.loadCustomEnts = exports.loadCustomData = exports.loadEnt = void 0;
|
|
29
|
+
exports.setLogLevels = exports.loadConfig = exports.LoggedOutViewer = exports.IDViewer = exports.ContextCache = exports.query = exports.AllowIfViewerHasIdentityPrivacyPolicy = exports.AllowIfViewerPrivacyPolicy = exports.AllowIfSubPolicyAllowsRule = exports.AllowIfConditionAppliesRule = exports.AlwaysDenyPrivacyPolicy = exports.AlwaysAllowPrivacyPolicy = exports.applyPrivacyPolicyX = exports.applyPrivacyPolicy = exports.DelayedResultRule = exports.DenyIfEntIsVisiblePolicy = exports.AllowIfEntIsVisiblePolicy = exports.DenyIfEntIsNotVisibleRule = exports.DenyIfEntIsVisibleRule = exports.AllowIfEntIsNotVisibleRule = exports.AllowIfEntIsVisibleRule = exports.DenyIfViewerOutboundEdgeDoesNotExistRule = exports.DenyIfViewerInboundEdgeDoesNotExistRule = exports.DenyIfEdgeDoesNotExistRule = exports.DenyIfViewerOutboundEdgeExistsRule = void 0;
|
|
30
30
|
__exportStar(require("./core/base"), exports);
|
|
31
31
|
var ent_1 = require("./core/ent");
|
|
32
32
|
Object.defineProperty(exports, "loadEnt", { enumerable: true, get: function () { return ent_1.loadEnt; } });
|
|
33
33
|
Object.defineProperty(exports, "loadCustomData", { enumerable: true, get: function () { return ent_1.loadCustomData; } });
|
|
34
34
|
Object.defineProperty(exports, "loadCustomEnts", { enumerable: true, get: function () { return ent_1.loadCustomEnts; } });
|
|
35
|
+
Object.defineProperty(exports, "loadCustomCount", { enumerable: true, get: function () { return ent_1.loadCustomCount; } });
|
|
35
36
|
Object.defineProperty(exports, "loadEntX", { enumerable: true, get: function () { return ent_1.loadEntX; } });
|
|
36
37
|
Object.defineProperty(exports, "loadEnts", { enumerable: true, get: function () { return ent_1.loadEnts; } });
|
|
37
38
|
Object.defineProperty(exports, "loadDerivedEnt", { enumerable: true, get: function () { return ent_1.loadDerivedEnt; } });
|
|
@@ -44,6 +45,7 @@ Object.defineProperty(exports, "loadRowX", { enumerable: true, get: function ()
|
|
|
44
45
|
Object.defineProperty(exports, "loadRow", { enumerable: true, get: function () { return ent_1.loadRow; } });
|
|
45
46
|
Object.defineProperty(exports, "loadRows", { enumerable: true, get: function () { return ent_1.loadRows; } });
|
|
46
47
|
Object.defineProperty(exports, "EditNodeOperation", { enumerable: true, get: function () { return ent_1.EditNodeOperation; } });
|
|
48
|
+
Object.defineProperty(exports, "RawQueryOperation", { enumerable: true, get: function () { return ent_1.RawQueryOperation; } });
|
|
47
49
|
Object.defineProperty(exports, "EdgeOperation", { enumerable: true, get: function () { return ent_1.EdgeOperation; } });
|
|
48
50
|
Object.defineProperty(exports, "DeleteNodeOperation", { enumerable: true, get: function () { return ent_1.DeleteNodeOperation; } });
|
|
49
51
|
Object.defineProperty(exports, "AssocEdge", { enumerable: true, get: function () { return ent_1.AssocEdge; } });
|
|
@@ -57,6 +59,7 @@ Object.defineProperty(exports, "loadRawEdgeCountX", { enumerable: true, get: fun
|
|
|
57
59
|
Object.defineProperty(exports, "loadEdgeForID2", { enumerable: true, get: function () { return ent_1.loadEdgeForID2; } });
|
|
58
60
|
Object.defineProperty(exports, "loadNodesByEdge", { enumerable: true, get: function () { return ent_1.loadNodesByEdge; } });
|
|
59
61
|
Object.defineProperty(exports, "getEdgeTypeInGroup", { enumerable: true, get: function () { return ent_1.getEdgeTypeInGroup; } });
|
|
62
|
+
Object.defineProperty(exports, "setGlobalSchema", { enumerable: true, get: function () { return ent_1.setGlobalSchema; } });
|
|
60
63
|
const db_1 = __importDefault(require("./core/db"));
|
|
61
64
|
exports.DB = db_1.default;
|
|
62
65
|
__exportStar(require("./core/loaders"), exports);
|
|
@@ -109,6 +112,7 @@ const query = {
|
|
|
109
112
|
And: q.And,
|
|
110
113
|
AndOptional: q.AndOptional,
|
|
111
114
|
Or: q.Or,
|
|
115
|
+
OrOptional: q.OrOptional,
|
|
112
116
|
In: q.In,
|
|
113
117
|
Greater: q.Greater,
|
|
114
118
|
Less: q.Less,
|
|
@@ -116,10 +120,15 @@ const query = {
|
|
|
116
120
|
LessEq: q.LessEq,
|
|
117
121
|
ArrayEq: q.ArrayEq,
|
|
118
122
|
ArrayNotEq: q.ArrayNotEq,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
+
PostgresArrayContainsValue: q.PostgresArrayContainsValue,
|
|
124
|
+
PostgresArrayContains: q.PostgresArrayContains,
|
|
125
|
+
PostgresArrayNotContainsValue: q.PostgresArrayNotContainsValue,
|
|
126
|
+
PostgresArrayNotContains: q.PostgresArrayNotContains,
|
|
127
|
+
PostgresArrayOverlaps: q.PostgresArrayOverlaps,
|
|
128
|
+
PostgresArrayNotOverlaps: q.PostgresArrayNotOverlaps,
|
|
129
|
+
JSONPathValuePredicate: q.JSONPathValuePredicate,
|
|
130
|
+
JSONObjectFieldKeyASJSON: q.JSONObjectFieldKeyASJSON,
|
|
131
|
+
JSONObjectFieldKeyAsText: q.JSONObjectFieldKeyAsText,
|
|
123
132
|
TsQuery: q.TsQuery,
|
|
124
133
|
PlainToTsQuery: q.PlainToTsQuery,
|
|
125
134
|
PhraseToTsQuery: q.PhraseToTsQuery,
|
package/package.json
CHANGED
package/parse_schema/parse.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema, Field, AssocEdge, AssocEdgeGroup, Action } from "../schema";
|
|
2
|
-
import { ActionField, Type } from "../schema/schema";
|
|
2
|
+
import { ActionField, Type, GlobalSchema } from "../schema/schema";
|
|
3
3
|
declare enum NullableResult {
|
|
4
4
|
CONTENTS = "contents",
|
|
5
5
|
CONTENTS_AND_LIST = "contentsAndList",
|
|
@@ -24,6 +24,7 @@ declare type ProcessedSchema = Omit<Schema, "edges" | "actions" | "edgeGroups" |
|
|
|
24
24
|
assocEdgeGroups: ProcessedAssocEdgeGroup[];
|
|
25
25
|
fields: ProcessedField[];
|
|
26
26
|
schemaPath?: string;
|
|
27
|
+
patternNames?: string[];
|
|
27
28
|
};
|
|
28
29
|
declare type ProcessedAssocEdgeGroup = Omit<AssocEdgeGroup, "edgeAction"> & {
|
|
29
30
|
edgeAction?: OutputAction;
|
|
@@ -38,13 +39,14 @@ interface ProcessedPattern {
|
|
|
38
39
|
name: string;
|
|
39
40
|
assocEdges: ProcessedAssocEdge[];
|
|
40
41
|
fields: ProcessedField[];
|
|
42
|
+
disableMixin?: boolean;
|
|
41
43
|
}
|
|
42
44
|
declare type ProcessedType = Omit<Type, "subFields" | "listElemType" | "unionFields"> & {
|
|
43
45
|
subFields?: ProcessedField[];
|
|
44
46
|
listElemType?: ProcessedType;
|
|
45
47
|
unionFields?: ProcessedField[];
|
|
46
48
|
};
|
|
47
|
-
declare type ProcessedField = Omit<Field, "defaultValueOnEdit" | "defaultValueOnCreate" | "privacyPolicy" | "type"> & {
|
|
49
|
+
declare type ProcessedField = Omit<Field, "defaultValueOnEdit" | "defaultValueOnCreate" | "privacyPolicy" | "type" | "serverDefault"> & {
|
|
48
50
|
name: string;
|
|
49
51
|
hasDefaultValueOnCreate?: boolean;
|
|
50
52
|
hasDefaultValueOnEdit?: boolean;
|
|
@@ -52,6 +54,7 @@ declare type ProcessedField = Omit<Field, "defaultValueOnEdit" | "defaultValueOn
|
|
|
52
54
|
hasFieldPrivacy?: boolean;
|
|
53
55
|
derivedFields?: ProcessedField[];
|
|
54
56
|
type: ProcessedType;
|
|
57
|
+
serverDefault?: string;
|
|
55
58
|
};
|
|
56
59
|
interface patternsDict {
|
|
57
60
|
[key: string]: ProcessedPattern;
|
|
@@ -59,9 +62,15 @@ interface patternsDict {
|
|
|
59
62
|
interface Result {
|
|
60
63
|
schemas: schemasDict;
|
|
61
64
|
patterns: patternsDict;
|
|
65
|
+
globalSchema?: ProcessedGlobalSchema;
|
|
62
66
|
}
|
|
63
67
|
declare type PotentialSchemas = {
|
|
64
68
|
[key: string]: any;
|
|
65
69
|
};
|
|
66
|
-
export declare function parseSchema(potentialSchemas: PotentialSchemas): Result
|
|
70
|
+
export declare function parseSchema(potentialSchemas: PotentialSchemas, globalSchema?: GlobalSchema): Promise<Result>;
|
|
71
|
+
interface ProcessedGlobalSchema {
|
|
72
|
+
globalEdges: ProcessedAssocEdge[];
|
|
73
|
+
extraEdgeFields: ProcessedField[];
|
|
74
|
+
initForEdges?: boolean;
|
|
75
|
+
}
|
|
67
76
|
export {};
|