@snowtop/ent 0.1.0-alpha142 → 0.1.0-alpha144
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/executor.js +2 -2
- package/core/config.d.ts +4 -1
- package/core/config.js +3 -0
- package/core/ent.d.ts +2 -1
- package/core/ent.js +11 -4
- package/core/loaders/assoc_edge_loader.js +2 -2
- package/core/loaders/query_loader.js +2 -2
- package/core/query/custom_clause_query.js +2 -2
- package/core/query/custom_query.js +1 -1
- package/core/query/query.js +1 -1
- package/core/query/shared_assoc_test.js +9 -9
- package/core/query/shared_test.js +63 -1
- package/imports/index.d.ts +1 -1
- package/imports/index.js +2 -2
- package/package.json +11 -11
- package/parse_schema/parse.js +1 -0
- package/schema/base_schema.d.ts +2 -0
- package/schema/base_schema.js +2 -0
- package/schema/schema.d.ts +1 -0
- package/scripts/custom_compiler.js +2 -2
- package/scripts/custom_graphql.js +3 -3
- package/scripts/read_schema.js +2 -2
- package/testutils/db/temp_db.d.ts +7 -0
- package/testutils/db/temp_db.js +27 -8
- package/testutils/db_mock.js +0 -2
- package/tsc/move_generated.js +2 -2
- package/tsc/transform.d.ts +2 -2
- package/tsc/transform.js +4 -3
package/action/executor.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.executeOperations = exports.ComplexExecutor = exports.ListBasedExecutor = void 0;
|
|
7
|
-
const graph_data_structure_1 =
|
|
7
|
+
const graph_data_structure_1 = require("graph-data-structure");
|
|
8
8
|
const ent_1 = require("../core/ent");
|
|
9
9
|
const db_1 = __importDefault(require("../core/db"));
|
|
10
10
|
const logger_1 = require("../core/logger");
|
|
@@ -123,7 +123,7 @@ class ComplexExecutor {
|
|
|
123
123
|
this.executors = [];
|
|
124
124
|
this.updatedOps = new Map();
|
|
125
125
|
this.builder = options?.builder;
|
|
126
|
-
let graph = (0, graph_data_structure_1.
|
|
126
|
+
let graph = (0, graph_data_structure_1.Graph)();
|
|
127
127
|
const changesetMap = new Map();
|
|
128
128
|
const impl = (c) => {
|
|
129
129
|
changesetMap.set(c.placeholderID.toString(), c);
|
package/core/config.d.ts
CHANGED
|
@@ -18,8 +18,11 @@ export interface Config {
|
|
|
18
18
|
dbFile?: string;
|
|
19
19
|
db?: Database | DBDict;
|
|
20
20
|
log?: logType | logType[];
|
|
21
|
-
codegen?: CodegenConfig;
|
|
22
21
|
logQueryWithError?: boolean;
|
|
22
|
+
defaultConnectionLimit?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface ConfigWithCodegen extends Config {
|
|
25
|
+
codegen?: CodegenConfig;
|
|
23
26
|
customGraphQLJSONPath?: string;
|
|
24
27
|
dynamicScriptCustomGraphQLJSONPath?: string;
|
|
25
28
|
globalSchemaPath?: string;
|
package/core/config.js
CHANGED
|
@@ -62,6 +62,9 @@ function setConfig(cfg) {
|
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
(0, ent_1.___setLogQueryErrorWithError)(cfg.logQueryWithError);
|
|
65
|
+
if (cfg.defaultConnectionLimit) {
|
|
66
|
+
(0, ent_1.setDefaultLimit)(cfg.defaultConnectionLimit);
|
|
67
|
+
}
|
|
65
68
|
}
|
|
66
69
|
function isBuffer(b) {
|
|
67
70
|
return b.write !== undefined;
|
package/core/ent.d.ts
CHANGED
|
@@ -131,7 +131,8 @@ interface loadEdgesOptions {
|
|
|
131
131
|
interface loadCustomEdgesOptions<T extends AssocEdge> extends loadEdgesOptions {
|
|
132
132
|
ctr: AssocEdgeConstructor<T>;
|
|
133
133
|
}
|
|
134
|
-
export declare
|
|
134
|
+
export declare function setDefaultLimit(limit: number): void;
|
|
135
|
+
export declare function getDefaultLimit(): number;
|
|
135
136
|
export declare function loadEdges(options: loadEdgesOptions): Promise<AssocEdge[]>;
|
|
136
137
|
export declare function getEdgeClauseAndFields(cls: clause.Clause, options: Pick<loadEdgesOptions, "disableTransformations">): {
|
|
137
138
|
cls: clause.Clause<Data, string | number>;
|
package/core/ent.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.getEdgeTypeInGroup = exports.applyPrivacyPolicyForRows = exports.applyPrivacyPolicyForRow = exports.loadNodesByEdge = exports.loadEdgeForID2 = exports.loadRawEdgeCountX = exports.loadUniqueNode = exports.loadUniqueEdge = exports.loadCustomEdges = exports.getEdgeClauseAndFields = exports.loadEdges = exports.
|
|
29
|
+
exports.getEdgeTypeInGroup = exports.applyPrivacyPolicyForRows = exports.applyPrivacyPolicyForRow = exports.loadNodesByEdge = exports.loadEdgeForID2 = exports.loadRawEdgeCountX = exports.loadUniqueNode = exports.loadUniqueEdge = exports.loadCustomEdges = exports.getEdgeClauseAndFields = exports.loadEdges = exports.getDefaultLimit = exports.setDefaultLimit = exports.loadEdgeDatas = exports.loadEdgeData = exports.assocEdgeLoader = exports.AssocEdgeData = exports.getCursor = exports.AssocEdge = exports.deleteRowsSync = exports.deleteRows = exports.editRowSync = exports.editRow = exports.buildUpdateQuery = exports.createRowSync = exports.createRow = exports.buildInsertQuery = exports.buildGroupQuery = exports.buildQuery = exports.loadRows = exports.performRawQuery = exports.___setLogQueryErrorWithError = exports.loadRow = exports.loadRowX = exports.logQuery = exports.loadDerivedEntX = exports.loadDerivedEnt = exports.loadCustomCount = exports.loadCustomData = exports.loadCustomEnts = exports.loadEntsFromClause = exports.loadEntsList = exports.loadEnts = exports.loadEntXFromClause = exports.loadEntFromClause = exports.loadEntXViaKey = exports.loadEntX = exports.loadEntViaKey = exports.loadEnt = exports.getEntKey = void 0;
|
|
30
30
|
const db_1 = __importStar(require("./db"));
|
|
31
31
|
const privacy_1 = require("./privacy");
|
|
32
32
|
const clause = __importStar(require("./clause"));
|
|
@@ -955,8 +955,15 @@ const edgeFields = [
|
|
|
955
955
|
"time",
|
|
956
956
|
"data",
|
|
957
957
|
];
|
|
958
|
-
|
|
959
|
-
|
|
958
|
+
let defaultLimit = 1000;
|
|
959
|
+
function setDefaultLimit(limit) {
|
|
960
|
+
defaultLimit = limit;
|
|
961
|
+
}
|
|
962
|
+
exports.setDefaultLimit = setDefaultLimit;
|
|
963
|
+
function getDefaultLimit() {
|
|
964
|
+
return defaultLimit;
|
|
965
|
+
}
|
|
966
|
+
exports.getDefaultLimit = getDefaultLimit;
|
|
960
967
|
function defaultEdgeQueryOptions(id1, edgeType, id2) {
|
|
961
968
|
let cls = clause.And(clause.Eq("id1", id1), clause.Eq("edge_type", edgeType));
|
|
962
969
|
if (id2) {
|
|
@@ -965,7 +972,7 @@ function defaultEdgeQueryOptions(id1, edgeType, id2) {
|
|
|
965
972
|
return {
|
|
966
973
|
clause: cls,
|
|
967
974
|
orderby: "time DESC",
|
|
968
|
-
limit:
|
|
975
|
+
limit: defaultLimit,
|
|
969
976
|
};
|
|
970
977
|
}
|
|
971
978
|
async function loadEdges(options) {
|
|
@@ -61,7 +61,7 @@ function createLoader(options, edgeType, edgeCtr, edgeData) {
|
|
|
61
61
|
}
|
|
62
62
|
options.orderby = options.orderby || "time DESC";
|
|
63
63
|
// TODO defaultEdgeQueryOptions
|
|
64
|
-
options.limit = options.limit || ent_1.
|
|
64
|
+
options.limit = options.limit || (0, ent_1.getDefaultLimit)();
|
|
65
65
|
const tableName = edgeData.edgeTable;
|
|
66
66
|
const { cls: cls1, fields } = (0, ent_1.getEdgeClauseAndFields)(clause.Eq("edge_type", edgeType), {});
|
|
67
67
|
const [query, cls] = (0, ent_1.buildGroupQuery)({
|
|
@@ -69,7 +69,7 @@ function createLoader(options, edgeType, edgeCtr, edgeData) {
|
|
|
69
69
|
fields,
|
|
70
70
|
values: keys,
|
|
71
71
|
orderby: options.orderby,
|
|
72
|
-
limit: options.limit || ent_1.
|
|
72
|
+
limit: options.limit || (0, ent_1.getDefaultLimit)(),
|
|
73
73
|
groupColumn: "id1",
|
|
74
74
|
clause: cls1,
|
|
75
75
|
});
|
|
@@ -67,7 +67,7 @@ async function simpleCase(options, id, queryOptions) {
|
|
|
67
67
|
...options,
|
|
68
68
|
clause: cls,
|
|
69
69
|
orderby: getOrderBy(sortCol, queryOptions?.orderby),
|
|
70
|
-
limit: queryOptions?.limit || ent_1.
|
|
70
|
+
limit: queryOptions?.limit || (0, ent_1.getDefaultLimit)(),
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
function createLoader(options, queryOptions) {
|
|
@@ -110,7 +110,7 @@ function createLoader(options, queryOptions) {
|
|
|
110
110
|
fields: options.fields,
|
|
111
111
|
values: keys,
|
|
112
112
|
orderby: getOrderBy(sortCol, queryOptions?.orderby),
|
|
113
|
-
limit: queryOptions?.limit || ent_1.
|
|
113
|
+
limit: queryOptions?.limit || (0, ent_1.getDefaultLimit)(),
|
|
114
114
|
groupColumn: col,
|
|
115
115
|
clause: extraClause,
|
|
116
116
|
});
|
|
@@ -62,14 +62,14 @@ class CustomClauseQuery extends query_1.BaseEdgeQuery {
|
|
|
62
62
|
options.orderby = `${this.options.sortColumn} ${direction}`;
|
|
63
63
|
}
|
|
64
64
|
if (!options.limit) {
|
|
65
|
-
options.limit = ent_1.
|
|
65
|
+
options.limit = (0, ent_1.getDefaultLimit)();
|
|
66
66
|
}
|
|
67
67
|
const rows = await (0, ent_1.loadRows)({
|
|
68
68
|
tableName: this.options.loadEntOptions.tableName,
|
|
69
69
|
fields: this.options.loadEntOptions.fields,
|
|
70
70
|
clause: (0, clause_1.AndOptional)(this.clause, options.clause),
|
|
71
71
|
orderby: (0, query_loader_1.getOrderBy)(this.getSortCol(), options?.orderby),
|
|
72
|
-
limit: options?.limit || ent_1.
|
|
72
|
+
limit: options?.limit || (0, ent_1.getDefaultLimit)(),
|
|
73
73
|
context: this.viewer.context,
|
|
74
74
|
});
|
|
75
75
|
this.edges.set(1, rows);
|
|
@@ -127,7 +127,7 @@ class CustomEdgeQueryBase extends query_1.BaseEdgeQuery {
|
|
|
127
127
|
options.orderby = `${this.getSortCol()} DESC`;
|
|
128
128
|
}
|
|
129
129
|
if (!options.limit) {
|
|
130
|
-
options.limit = ent_1.
|
|
130
|
+
options.limit = (0, ent_1.getDefaultLimit)();
|
|
131
131
|
}
|
|
132
132
|
const loader = this.getQueryLoader(options);
|
|
133
133
|
const info = infos[0];
|
package/core/query/query.js
CHANGED
|
@@ -351,7 +351,7 @@ class BaseEdgeQuery {
|
|
|
351
351
|
const idsInfo = await this.genIDInfosToFetch();
|
|
352
352
|
if (!this.filters.length) {
|
|
353
353
|
// if no filter, we add the firstN filter to ensure we get pagination info
|
|
354
|
-
this.first(ent_1.
|
|
354
|
+
this.first((0, ent_1.getDefaultLimit)());
|
|
355
355
|
}
|
|
356
356
|
let options = {};
|
|
357
357
|
// TODO once we add a lot of complex filters, this needs to be more complicated
|
|
@@ -52,7 +52,7 @@ function assocTests(ml, global = false) {
|
|
|
52
52
|
let execArray = /^SELECT (.+) FROM (.+) WHERE (.+)?/.exec(query.query);
|
|
53
53
|
return execArray?.[3];
|
|
54
54
|
}
|
|
55
|
-
function verifyQuery({ length = 1, numQueries = 1, limit = ent_1.
|
|
55
|
+
function verifyQuery({ length = 1, numQueries = 1, limit = (0, ent_1.getDefaultLimit)(), disablePaginationBump = false, }) {
|
|
56
56
|
expect(ml.logs.length).toBe(length);
|
|
57
57
|
for (let i = 0; i < numQueries; i++) {
|
|
58
58
|
const whereClause = getWhereClause(ml.logs[i]);
|
|
@@ -118,7 +118,7 @@ function assocTests(ml, global = false) {
|
|
|
118
118
|
verifyQuery({
|
|
119
119
|
length: this.dataz.length,
|
|
120
120
|
numQueries: this.dataz.length,
|
|
121
|
-
limit: this.limit || ent_1.
|
|
121
|
+
limit: this.limit || (0, ent_1.getDefaultLimit)(),
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
// rawCount isn't affected by filters...
|
|
@@ -141,7 +141,7 @@ function assocTests(ml, global = false) {
|
|
|
141
141
|
verifyQuery({
|
|
142
142
|
length: this.dataz.length,
|
|
143
143
|
numQueries: this.dataz.length,
|
|
144
|
-
limit: this.limit || ent_1.
|
|
144
|
+
limit: this.limit || (0, ent_1.getDefaultLimit)(),
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
async testEdges() {
|
|
@@ -154,7 +154,7 @@ function assocTests(ml, global = false) {
|
|
|
154
154
|
verifyQuery({
|
|
155
155
|
length: this.dataz.length,
|
|
156
156
|
numQueries: this.dataz.length,
|
|
157
|
-
limit: this.limit || ent_1.
|
|
157
|
+
limit: this.limit || (0, ent_1.getDefaultLimit)(),
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
160
|
async testEnts() {
|
|
@@ -178,7 +178,7 @@ function assocTests(ml, global = false) {
|
|
|
178
178
|
// and then twice to fetch all the nodes for the contacts
|
|
179
179
|
length: this.dataz.length + this.dataz.length + this.dataz.length * 2,
|
|
180
180
|
numQueries: this.dataz.length,
|
|
181
|
-
limit: this.limit || ent_1.
|
|
181
|
+
limit: this.limit || (0, ent_1.getDefaultLimit)(),
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
184
|
}
|
|
@@ -464,7 +464,7 @@ function assocTests(ml, global = false) {
|
|
|
464
464
|
verifyQuery({
|
|
465
465
|
length: 1,
|
|
466
466
|
numQueries: 1,
|
|
467
|
-
limit: this.limit || ent_1.
|
|
467
|
+
limit: this.limit || (0, ent_1.getDefaultLimit)(),
|
|
468
468
|
});
|
|
469
469
|
}
|
|
470
470
|
// rawCount isn't affected by filters...
|
|
@@ -479,7 +479,7 @@ function assocTests(ml, global = false) {
|
|
|
479
479
|
verifyQuery({
|
|
480
480
|
length: 1,
|
|
481
481
|
numQueries: 1,
|
|
482
|
-
limit: this.limit || ent_1.
|
|
482
|
+
limit: this.limit || (0, ent_1.getDefaultLimit)(),
|
|
483
483
|
});
|
|
484
484
|
}
|
|
485
485
|
async testEdges() {
|
|
@@ -500,7 +500,7 @@ function assocTests(ml, global = false) {
|
|
|
500
500
|
verifyQuery({
|
|
501
501
|
length: 1,
|
|
502
502
|
numQueries: 1,
|
|
503
|
-
limit: this.limit || ent_1.
|
|
503
|
+
limit: this.limit || (0, ent_1.getDefaultLimit)(),
|
|
504
504
|
});
|
|
505
505
|
}
|
|
506
506
|
async testEnts() {
|
|
@@ -524,7 +524,7 @@ function assocTests(ml, global = false) {
|
|
|
524
524
|
// // 1 for edges, 1 for users, 1 for events
|
|
525
525
|
// length: 3,
|
|
526
526
|
// numQueries: 3,
|
|
527
|
-
// limit: this.limit ||
|
|
527
|
+
// limit: this.limit || getDefaultLimit(),
|
|
528
528
|
// });
|
|
529
529
|
}
|
|
530
530
|
}
|
|
@@ -147,7 +147,7 @@ const commonTests = (opts) => {
|
|
|
147
147
|
this.verifyEnts(ents);
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
function verifyQuery(filter, { length = 1, numQueries = 1, limit = ent_1.
|
|
150
|
+
function verifyQuery(filter, { length = 1, numQueries = 1, limit = (0, ent_1.getDefaultLimit)(), disablePaginationBump = false, orderby = opts.orderby, }) {
|
|
151
151
|
const uniqCol = isCustomQuery(filter) ? "id" : "id2";
|
|
152
152
|
expect(ml.logs.length).toBe(length);
|
|
153
153
|
for (let i = 0; i < numQueries; i++) {
|
|
@@ -355,6 +355,68 @@ const commonTests = (opts) => {
|
|
|
355
355
|
await filter.testDataCache();
|
|
356
356
|
});
|
|
357
357
|
});
|
|
358
|
+
describe("override default limit", () => {
|
|
359
|
+
const filter = new TestQueryFilter((q) => {
|
|
360
|
+
// no filters
|
|
361
|
+
return q;
|
|
362
|
+
}, opts.newQuery, (contacts) => {
|
|
363
|
+
// nothing to do here
|
|
364
|
+
// reverse because edges are most recent first
|
|
365
|
+
if (opts.orderby === "DESC") {
|
|
366
|
+
return contacts.reverse();
|
|
367
|
+
}
|
|
368
|
+
return contacts;
|
|
369
|
+
}, getViewer());
|
|
370
|
+
const OUR_DEFAULT_LIMIT = 10;
|
|
371
|
+
beforeAll(async () => {
|
|
372
|
+
(0, ent_1.setDefaultLimit)(OUR_DEFAULT_LIMIT);
|
|
373
|
+
});
|
|
374
|
+
afterAll(async () => {
|
|
375
|
+
//set it back to real default
|
|
376
|
+
(0, ent_1.setDefaultLimit)(1000);
|
|
377
|
+
});
|
|
378
|
+
beforeEach(async () => {
|
|
379
|
+
await filter.createData();
|
|
380
|
+
});
|
|
381
|
+
test("ids", async () => {
|
|
382
|
+
await filter.testIDs();
|
|
383
|
+
verifyQuery(filter, {
|
|
384
|
+
limit: OUR_DEFAULT_LIMIT,
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
test("rawCount", async () => {
|
|
388
|
+
await filter.testRawCount();
|
|
389
|
+
verifyCountQuery({});
|
|
390
|
+
});
|
|
391
|
+
test("count", async () => {
|
|
392
|
+
await filter.testCount();
|
|
393
|
+
verifyQuery(filter, {
|
|
394
|
+
limit: OUR_DEFAULT_LIMIT,
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
test("edges", async () => {
|
|
398
|
+
await filter.testEdges();
|
|
399
|
+
verifyQuery(filter, {
|
|
400
|
+
limit: OUR_DEFAULT_LIMIT,
|
|
401
|
+
});
|
|
402
|
+
});
|
|
403
|
+
test("ents", async () => {
|
|
404
|
+
await filter.testEnts();
|
|
405
|
+
verifyQuery(filter, {
|
|
406
|
+
length: opts.entsLength,
|
|
407
|
+
limit: OUR_DEFAULT_LIMIT,
|
|
408
|
+
});
|
|
409
|
+
});
|
|
410
|
+
test("all", async () => {
|
|
411
|
+
await filter.testAll();
|
|
412
|
+
});
|
|
413
|
+
test("ents cache", async () => {
|
|
414
|
+
await filter.testEntsCache();
|
|
415
|
+
});
|
|
416
|
+
test("data cache", async () => {
|
|
417
|
+
await filter.testDataCache();
|
|
418
|
+
});
|
|
419
|
+
});
|
|
358
420
|
describe("after delete", () => {
|
|
359
421
|
const filter = new TestQueryFilter((q) => {
|
|
360
422
|
// no filters
|
package/imports/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface Options {
|
|
2
2
|
filter?: (file: string, index: number, array: string[]) => boolean;
|
|
3
3
|
justCurrentDir?: boolean;
|
|
4
|
-
ignore?: string |
|
|
4
|
+
ignore?: string | string[] | undefined;
|
|
5
5
|
}
|
|
6
6
|
export interface PathResult {
|
|
7
7
|
m: Map<string, file[]>;
|
package/imports/index.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.parseCustomImports = void 0;
|
|
30
|
-
const
|
|
30
|
+
const glob = __importStar(require("glob"));
|
|
31
31
|
const typescript_1 = __importDefault(require("typescript"));
|
|
32
32
|
const fs = __importStar(require("fs"));
|
|
33
33
|
const path = __importStar(require("path"));
|
|
@@ -42,7 +42,7 @@ function getFiles(filePath, opts) {
|
|
|
42
42
|
if (opts?.justCurrentDir) {
|
|
43
43
|
pattern = `${filePath}/**.ts`;
|
|
44
44
|
}
|
|
45
|
-
let files =
|
|
45
|
+
let files = glob.sync(pattern, {
|
|
46
46
|
ignore: opts?.ignore,
|
|
47
47
|
});
|
|
48
48
|
if (opts?.filter) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snowtop/ent",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-alpha144",
|
|
4
4
|
"description": "snowtop ent framework",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -9,24 +9,24 @@
|
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@swc-node/register": "^1.6.5",
|
|
12
|
-
"@types/node": "^
|
|
12
|
+
"@types/node": "^20.2.5",
|
|
13
13
|
"camel-case": "^4.1.2",
|
|
14
|
-
"cosmiconfig": "^8.
|
|
15
|
-
"dataloader": "^2.
|
|
16
|
-
"glob": "^
|
|
17
|
-
"graph-data-structure": "^
|
|
14
|
+
"cosmiconfig": "^8.1.3",
|
|
15
|
+
"dataloader": "^2.2.2",
|
|
16
|
+
"glob": "^10.2.6",
|
|
17
|
+
"graph-data-structure": "^3.3.0",
|
|
18
18
|
"js-yaml": "^4.1.0",
|
|
19
|
-
"json5": "^2.2.
|
|
20
|
-
"luxon": "^3.
|
|
19
|
+
"json5": "^2.2.3",
|
|
20
|
+
"luxon": "^3.3.0",
|
|
21
21
|
"memoizee": "^0.4.15",
|
|
22
|
-
"minimist": "^1.2.
|
|
22
|
+
"minimist": "^1.2.8",
|
|
23
23
|
"pascal-case": "^3.1.2",
|
|
24
24
|
"pg": "^8.11.0",
|
|
25
|
-
"prettier": "^2.8.
|
|
25
|
+
"prettier": "^2.8.8",
|
|
26
26
|
"snake-case": "^3.0.4",
|
|
27
27
|
"ts-node": "^10.9.1",
|
|
28
28
|
"tsconfig-paths": "^4.2.0",
|
|
29
|
-
"tslib": "^2.5.
|
|
29
|
+
"tslib": "^2.5.2",
|
|
30
30
|
"typescript": "^5.0.4",
|
|
31
31
|
"uuid": "^9.0.0"
|
|
32
32
|
},
|
package/parse_schema/parse.js
CHANGED
|
@@ -269,6 +269,7 @@ async function parseSchema(potentialSchemas, globalSchema) {
|
|
|
269
269
|
assocEdgeGroups: [],
|
|
270
270
|
customGraphQLInterfaces: schema.customGraphQLInterfaces,
|
|
271
271
|
supportUpsert: schema.supportUpsert,
|
|
272
|
+
supportCanViewerSee: schema.supportCanViewerSee,
|
|
272
273
|
};
|
|
273
274
|
// let's put patterns first just so we have id, created_at, updated_at first
|
|
274
275
|
// ¯\_(ツ)_/¯
|
package/schema/base_schema.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export declare class EntSchema implements Schema {
|
|
|
21
21
|
hideFromGraphQL?: boolean;
|
|
22
22
|
customGraphQLInterfaces?: string[] | undefined;
|
|
23
23
|
supportUpsert?: boolean | undefined;
|
|
24
|
+
supportCanViewerSee?: boolean | undefined;
|
|
24
25
|
constructor(cfg: SchemaConfig);
|
|
25
26
|
}
|
|
26
27
|
export declare class EntSchemaWithTZ implements Schema {
|
|
@@ -40,6 +41,7 @@ export declare class EntSchemaWithTZ implements Schema {
|
|
|
40
41
|
hideFromGraphQL?: boolean;
|
|
41
42
|
customGraphQLInterfaces?: string[] | undefined;
|
|
42
43
|
supportUpsert?: boolean | undefined;
|
|
44
|
+
supportCanViewerSee?: boolean | undefined;
|
|
43
45
|
constructor(cfg: SchemaConfig);
|
|
44
46
|
}
|
|
45
47
|
export declare abstract class BaseEntSchema {
|
package/schema/base_schema.js
CHANGED
|
@@ -91,6 +91,7 @@ class EntSchema {
|
|
|
91
91
|
// TODO annoying that have to list these...
|
|
92
92
|
this.customGraphQLInterfaces = cfg.customGraphQLInterfaces;
|
|
93
93
|
this.supportUpsert = cfg.supportUpsert;
|
|
94
|
+
this.supportCanViewerSee = cfg.supportCanViewerSee;
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
exports.EntSchema = EntSchema;
|
|
@@ -121,6 +122,7 @@ class EntSchemaWithTZ {
|
|
|
121
122
|
// TODO annoying that have to list these...
|
|
122
123
|
this.customGraphQLInterfaces = cfg.customGraphQLInterfaces;
|
|
123
124
|
this.supportUpsert = cfg.supportUpsert;
|
|
125
|
+
this.supportCanViewerSee = cfg.supportCanViewerSee;
|
|
124
126
|
}
|
|
125
127
|
}
|
|
126
128
|
exports.EntSchemaWithTZ = EntSchemaWithTZ;
|
package/schema/schema.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
30
|
const typescript_1 = __importDefault(require("typescript"));
|
|
31
31
|
const path = __importStar(require("path"));
|
|
32
|
-
const
|
|
32
|
+
const glob = __importStar(require("glob"));
|
|
33
33
|
const compilerOptions_1 = require("../tsc/compilerOptions");
|
|
34
34
|
// TODO this should probably be its own package but for now it's here
|
|
35
35
|
class Compiler {
|
|
@@ -265,6 +265,6 @@ class Compiler {
|
|
|
265
265
|
// todo this should be configurable
|
|
266
266
|
// TODO this should be broken into its own repo and npm module
|
|
267
267
|
// TODO use includes and exclude in tsconfig.json if it exists
|
|
268
|
-
new Compiler(
|
|
268
|
+
new Compiler(glob.sync("**/*.ts", {
|
|
269
269
|
ignore: ["node_modules/**", "tests/**", "**/*.test.ts"],
|
|
270
270
|
}), ["node_modules/@types/node"]).compile();
|
|
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
const
|
|
30
|
+
const glob = __importStar(require("glob"));
|
|
31
31
|
const json5_1 = __importDefault(require("json5"));
|
|
32
32
|
const minimist_1 = __importDefault(require("minimist"));
|
|
33
33
|
const path = __importStar(require("path"));
|
|
@@ -256,12 +256,12 @@ async function captureCustom(filePath, filesCsv, jsonPath, gqlCapture) {
|
|
|
256
256
|
// ignore test files.
|
|
257
257
|
"**/*.test.ts",
|
|
258
258
|
];
|
|
259
|
-
const customGQLResolvers =
|
|
259
|
+
const customGQLResolvers = glob.sync(path.join(filePath, "/graphql/resolvers/**/*.ts"), {
|
|
260
260
|
// no actions for now to speed things up
|
|
261
261
|
// no index.ts or internal file.
|
|
262
262
|
ignore: ignore,
|
|
263
263
|
});
|
|
264
|
-
const customGQLMutations =
|
|
264
|
+
const customGQLMutations = glob.sync(path.join(filePath, "/graphql/mutations/**/*.ts"), {
|
|
265
265
|
// no actions for now to speed things up
|
|
266
266
|
// no index.ts or internal file.
|
|
267
267
|
ignore: ignore,
|
package/scripts/read_schema.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const
|
|
29
|
+
const glob = __importStar(require("glob"));
|
|
30
30
|
const path = __importStar(require("path"));
|
|
31
31
|
const pascal_case_1 = require("pascal-case");
|
|
32
32
|
const minimist_1 = __importDefault(require("minimist"));
|
|
@@ -42,7 +42,7 @@ function main() {
|
|
|
42
42
|
let globalSchema;
|
|
43
43
|
const r = /(\w+).ts/;
|
|
44
44
|
// do we still even need this...
|
|
45
|
-
const paths =
|
|
45
|
+
const paths = glob.sync(path.join(options.path, "*.ts"), {
|
|
46
46
|
ignore: [`\d+_read_schema.ts`],
|
|
47
47
|
});
|
|
48
48
|
let potentialSchemas = {};
|
|
@@ -73,6 +73,11 @@ export declare function dateList(name: string, opts?: options): Column;
|
|
|
73
73
|
export declare function boolList(name: string, opts?: options): Column;
|
|
74
74
|
export declare function table(name: string, ...items: SchemaItem[]): Table;
|
|
75
75
|
export declare function enumType(name: string, values: string[]): CoreConcept;
|
|
76
|
+
interface TempDBOptions {
|
|
77
|
+
dialect: Dialect;
|
|
78
|
+
sqliteConnString?: string;
|
|
79
|
+
tables?: CoreConcept[] | (() => CoreConcept[]);
|
|
80
|
+
}
|
|
76
81
|
export declare class TempDB {
|
|
77
82
|
private db;
|
|
78
83
|
private client;
|
|
@@ -81,7 +86,9 @@ export declare class TempDB {
|
|
|
81
86
|
private dialect;
|
|
82
87
|
private sqlite;
|
|
83
88
|
private setTables;
|
|
89
|
+
private sqliteConnString;
|
|
84
90
|
constructor(dialect: Dialect, tables?: CoreConcept[] | (() => CoreConcept[]));
|
|
91
|
+
constructor(opts: TempDBOptions);
|
|
85
92
|
getDialect(): Dialect;
|
|
86
93
|
__getTables(): Map<string, CoreConcept>;
|
|
87
94
|
beforeAll(setupConnString?: boolean): Promise<void>;
|
package/testutils/db/temp_db.js
CHANGED
|
@@ -381,8 +381,15 @@ function randomDB() {
|
|
|
381
381
|
class TempDB {
|
|
382
382
|
constructor(dialect, tables) {
|
|
383
383
|
this.tables = new Map();
|
|
384
|
-
|
|
385
|
-
|
|
384
|
+
if (typeof dialect === "string") {
|
|
385
|
+
this.dialect = dialect;
|
|
386
|
+
this.setTables = tables;
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
this.dialect = dialect.dialect;
|
|
390
|
+
this.setTables = dialect.tables;
|
|
391
|
+
this.sqliteConnString = dialect.sqliteConnString;
|
|
392
|
+
}
|
|
386
393
|
}
|
|
387
394
|
getDialect() {
|
|
388
395
|
return this.dialect;
|
|
@@ -434,10 +441,17 @@ class TempDB {
|
|
|
434
441
|
await this.dbClient.connect();
|
|
435
442
|
}
|
|
436
443
|
else {
|
|
437
|
-
|
|
438
|
-
|
|
444
|
+
let connString;
|
|
445
|
+
if (this.sqliteConnString) {
|
|
446
|
+
connString = this.sqliteConnString;
|
|
439
447
|
}
|
|
440
|
-
|
|
448
|
+
else {
|
|
449
|
+
if (process.env.DB_CONNECTION_STRING === undefined) {
|
|
450
|
+
throw new Error(`DB_CONNECTION_STRING required for sqlite if sqliteConnString is not set`);
|
|
451
|
+
}
|
|
452
|
+
connString = process.env.DB_CONNECTION_STRING;
|
|
453
|
+
}
|
|
454
|
+
const filePath = connString.substr(10);
|
|
441
455
|
this.sqlite = (0, better_sqlite3_1.default)(filePath);
|
|
442
456
|
}
|
|
443
457
|
if (this.setTables) {
|
|
@@ -563,10 +577,15 @@ function assoc_edge_table(name, global, unique_edge) {
|
|
|
563
577
|
}
|
|
564
578
|
exports.assoc_edge_table = assoc_edge_table;
|
|
565
579
|
function setupSqlite(connString, tables, opts) {
|
|
566
|
-
let tdb = new TempDB(
|
|
580
|
+
let tdb = new TempDB({
|
|
581
|
+
dialect: db_1.Dialect.SQLite,
|
|
582
|
+
tables,
|
|
583
|
+
sqliteConnString: connString,
|
|
584
|
+
});
|
|
567
585
|
beforeAll(async () => {
|
|
568
|
-
|
|
569
|
-
|
|
586
|
+
(0, config_1.loadConfig)({
|
|
587
|
+
dbConnectionString: connString,
|
|
588
|
+
});
|
|
570
589
|
await tdb.beforeAll();
|
|
571
590
|
const conn = db_1.default.getInstance().getConnection();
|
|
572
591
|
expect(conn.db.memory).toBe(false);
|
package/testutils/db_mock.js
CHANGED
package/tsc/move_generated.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.moveGenerated = void 0;
|
|
30
|
-
const
|
|
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 =
|
|
41
|
+
const files = glob.sync(this.globPath);
|
|
42
42
|
moveFiles(files);
|
|
43
43
|
}
|
|
44
44
|
}
|
package/tsc/transform.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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?:
|
|
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
|
|
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 =
|
|
43
|
+
let files = glob.sync(transform.glob, transform.globOptions ?? {});
|
|
44
44
|
const target = (0, compilerOptions_1.getTargetFromCurrentDir)();
|
|
45
45
|
if (transform.filter) {
|
|
46
|
-
|
|
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);
|