@snowtop/ent 0.2.4 → 0.2.6
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.js +5 -5
- package/action/executor.d.ts +1 -1
- package/action/executor.js +4 -4
- package/action/experimental_action.d.ts +7 -4
- package/action/experimental_action.js +18 -8
- package/action/operations.js +17 -7
- package/action/orchestrator.d.ts +10 -2
- package/action/orchestrator.js +29 -31
- package/action/privacy.d.ts +2 -2
- package/action/relative_value.js +3 -3
- package/auth/auth.d.ts +0 -1
- package/auth/auth.js +4 -5
- package/core/base.js +5 -5
- package/core/clause.js +76 -67
- package/core/config.d.ts +1 -1
- package/core/config.js +22 -9
- package/core/context.d.ts +0 -1
- package/core/convert.d.ts +0 -1
- package/core/convert.js +16 -17
- package/core/date.js +1 -2
- package/core/db.js +17 -7
- package/core/ent.d.ts +2 -0
- package/core/ent.js +127 -92
- package/core/global_schema.js +6 -7
- package/core/loaders/assoc_count_loader.d.ts +2 -2
- package/core/loaders/assoc_count_loader.js +17 -7
- package/core/loaders/assoc_edge_loader.d.ts +2 -2
- package/core/loaders/assoc_edge_loader.js +44 -20
- package/core/loaders/cache_utils.d.ts +1 -0
- package/core/loaders/cache_utils.js +28 -0
- package/core/loaders/index.d.ts +1 -0
- package/core/loaders/index.js +4 -1
- package/core/loaders/loader.d.ts +2 -0
- package/core/loaders/loader.js +20 -3
- package/core/loaders/object_loader.d.ts +6 -4
- package/core/loaders/object_loader.js +86 -48
- package/core/loaders/query_loader.d.ts +2 -2
- package/core/loaders/query_loader.js +25 -9
- package/core/loaders/raw_count_loader.d.ts +2 -2
- package/core/loaders/raw_count_loader.js +22 -10
- package/core/logger.js +6 -7
- package/core/privacy.d.ts +2 -2
- package/core/privacy.js +4 -5
- package/core/query/assoc_query.js +17 -7
- package/core/query/query.js +17 -7
- package/core/query/shared_assoc_test.js +1 -2
- package/core/query_impl.js +4 -5
- package/core/viewer.d.ts +2 -2
- package/graphql/graphql_field_helpers.js +22 -22
- package/graphql/mutations/union.js +1 -2
- package/graphql/node_resolver.js +7 -7
- package/graphql/query/shared_assoc_test.js +1 -2
- package/graphql/scalars/date.js +8 -3
- package/graphql/scalars/time.d.ts +1 -1
- package/imports/dataz/example1/_auth.js +14 -10
- package/imports/index.js +18 -9
- package/index.js +17 -7
- package/names/names.js +61 -18
- package/package.json +14 -17
- package/parse_schema/parse.js +2 -3
- package/schema/binary_field.js +3 -3
- package/schema/field.js +45 -35
- package/schema/json_field.js +7 -7
- package/schema/schema.js +12 -12
- package/schema/struct_field.js +4 -4
- package/schema/union_field.js +3 -3
- package/scripts/custom_compiler.js +17 -7
- package/scripts/custom_graphql.js +17 -7
- package/scripts/fix_action_exports.js +17 -7
- package/scripts/move_types.js +17 -7
- package/scripts/read_schema.js +17 -7
- package/testutils/action/complex_schemas.js +28 -18
- package/testutils/builder.d.ts +1 -1
- package/testutils/builder.js +7 -7
- package/testutils/db/fixture.js +1 -2
- package/testutils/db/temp_db.js +54 -44
- package/testutils/db/value.js +3 -4
- package/testutils/db_mock.js +12 -0
- package/testutils/ent-graphql-tests/index.d.ts +3 -3
- package/testutils/ent-graphql-tests/index.js +27 -18
- package/testutils/fake_data/const.js +2 -2
- package/testutils/fake_data/fake_contact.js +20 -10
- package/testutils/fake_data/fake_event.js +20 -10
- package/testutils/fake_data/fake_tag.js +21 -11
- package/testutils/fake_data/fake_user.js +21 -11
- package/testutils/fake_data/test_helpers.js +17 -17
- package/testutils/fake_data/user_query.js +19 -9
- package/testutils/parse_sql.js +151 -43
- package/testutils/query.js +2 -3
- package/testutils/soft_delete.js +17 -7
- package/testutils/test_edge_global_schema.js +17 -7
- package/testutils/write.js +20 -11
- package/tsc/ast.js +27 -18
- package/tsc/compilerOptions.js +22 -13
- package/tsc/move_generated.js +18 -9
- package/tsc/transform.js +18 -9
- package/tsc/transform_action.js +17 -7
- package/tsc/transform_schema.js +17 -7
package/testutils/parse_sql.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
6
|
+
exports.OrOp = exports.AndOp = exports.InOp = exports.LessEqOp = exports.GreaterEqOp = exports.LessOp = exports.GreaterOp = exports.NotEqOp = exports.EqOp = void 0;
|
|
7
|
+
exports.getDataToReturn = getDataToReturn;
|
|
8
|
+
exports.performQuery = performQuery;
|
|
9
|
+
const node_sql_parser_1 = __importDefault(require("node-sql-parser"));
|
|
5
10
|
function getTableName(table) {
|
|
6
11
|
if (Array.isArray(table)) {
|
|
7
12
|
table = table[0];
|
|
@@ -37,20 +42,56 @@ function getColumns(cols) {
|
|
|
37
42
|
}
|
|
38
43
|
let result = [];
|
|
39
44
|
let count;
|
|
45
|
+
let allCols = false;
|
|
40
46
|
for (let col of cols) {
|
|
41
47
|
if (typeof col === "string") {
|
|
42
48
|
result.push(col);
|
|
43
49
|
}
|
|
44
50
|
else {
|
|
51
|
+
if (col.expr?.type === "column_ref") {
|
|
52
|
+
const colName = getColumnFromRef(col.expr);
|
|
53
|
+
if (colName === "*") {
|
|
54
|
+
allCols = true;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
result.push(colName);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (typeof col.column === "string") {
|
|
61
|
+
result.push(col.column);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (col.type === "column_ref") {
|
|
65
|
+
const colName = getColumnFromRef(col);
|
|
66
|
+
if (colName === "*") {
|
|
67
|
+
allCols = true;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
result.push(colName);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (col.type === "column" && typeof col.value === "string") {
|
|
74
|
+
result.push(col.value);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (col.type === "default" && typeof col.value === "string") {
|
|
78
|
+
result.push(col.value);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
45
81
|
assert(col.type === "expr", "invalid col type");
|
|
46
82
|
if (col.as !== "count") {
|
|
47
83
|
// count supported as function below...
|
|
48
84
|
assert(col.as === null, "column as not-null"); // TODO support this
|
|
49
85
|
}
|
|
50
86
|
assert(col.expr !== null, "null col expr");
|
|
51
|
-
if (col.expr.
|
|
52
|
-
|
|
53
|
-
|
|
87
|
+
if (col.expr.type === "column_ref") {
|
|
88
|
+
const colName = getColumnFromRef(col.expr);
|
|
89
|
+
if (colName === "*") {
|
|
90
|
+
allCols = true;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
result.push(colName);
|
|
94
|
+
}
|
|
54
95
|
}
|
|
55
96
|
else if (col.expr.type === "function") {
|
|
56
97
|
assert(col.expr.name === "count", "count is the only supported function for now");
|
|
@@ -68,31 +109,67 @@ function getColumns(cols) {
|
|
|
68
109
|
}
|
|
69
110
|
else if (col.expr.type == "aggr_func") {
|
|
70
111
|
assert(col.expr.name === "COUNT", "count is the only supported function for now");
|
|
71
|
-
if (col.expr.args?.expr?.type
|
|
112
|
+
if (col.expr.args?.expr?.type === "star") {
|
|
113
|
+
count = true;
|
|
114
|
+
}
|
|
115
|
+
else if (col.expr.args?.expr?.type === "number" &&
|
|
116
|
+
col.expr.args.expr.value === 1) {
|
|
117
|
+
count = true;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
72
120
|
throw new Error("unsupported count expr");
|
|
73
121
|
}
|
|
74
|
-
count = true;
|
|
75
122
|
}
|
|
76
123
|
else {
|
|
77
124
|
throw new Error("unsupported expr type");
|
|
78
125
|
}
|
|
79
126
|
}
|
|
80
127
|
}
|
|
128
|
+
if (allCols) {
|
|
129
|
+
return { allCols: true, count };
|
|
130
|
+
}
|
|
81
131
|
return { columns: result, count };
|
|
82
132
|
}
|
|
83
133
|
function getColumnFromRef(col) {
|
|
84
134
|
assert(col !== null, "null column ref");
|
|
135
|
+
if (col.expr?.type === "column_ref") {
|
|
136
|
+
return getColumnFromRef(col.expr);
|
|
137
|
+
}
|
|
138
|
+
if (col.expr?.type === "default") {
|
|
139
|
+
return col.expr.value;
|
|
140
|
+
}
|
|
141
|
+
if (col.type === "expr" && col.expr?.type === "column_ref") {
|
|
142
|
+
return getColumnFromRef(col.expr);
|
|
143
|
+
}
|
|
144
|
+
if (col.type === "column" && typeof col.value === "string") {
|
|
145
|
+
return col.value;
|
|
146
|
+
}
|
|
147
|
+
if (col.type === "default" && typeof col.value === "string") {
|
|
148
|
+
return col.value;
|
|
149
|
+
}
|
|
85
150
|
assert(col.type === "column_ref", "column type column_ref");
|
|
86
151
|
assert(col.table === null, "column table not null");
|
|
87
|
-
|
|
152
|
+
if (typeof col.column === "string") {
|
|
153
|
+
return col.column;
|
|
154
|
+
}
|
|
155
|
+
if (col.column?.expr?.type === "default") {
|
|
156
|
+
return col.column.expr.value;
|
|
157
|
+
}
|
|
158
|
+
if (col.column?.value) {
|
|
159
|
+
return col.column.value;
|
|
160
|
+
}
|
|
161
|
+
throw new Error("unsupported column ref");
|
|
88
162
|
}
|
|
89
163
|
function isPreparedStatementValue(val) {
|
|
90
|
-
if (val.type
|
|
91
|
-
|
|
164
|
+
if (val.type === "origin") {
|
|
165
|
+
let str = val.value;
|
|
166
|
+
// TODO this should work for not-postgres
|
|
167
|
+
return str.startsWith("$");
|
|
92
168
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
169
|
+
if (val.type === "var") {
|
|
170
|
+
return val.prefix === "$";
|
|
171
|
+
}
|
|
172
|
+
return false;
|
|
96
173
|
}
|
|
97
174
|
// regex from https://www.regextester.com/97766
|
|
98
175
|
const isoStringRegex = /^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]+)?(Z)?$/;
|
|
@@ -120,7 +197,6 @@ function getDataToReturn(data, colNames, returningAll) {
|
|
|
120
197
|
}
|
|
121
198
|
return ret;
|
|
122
199
|
}
|
|
123
|
-
exports.getDataToReturn = getDataToReturn;
|
|
124
200
|
function processBeforeStoring(val) {
|
|
125
201
|
if (typeof val !== "string") {
|
|
126
202
|
return val;
|
|
@@ -142,10 +218,13 @@ returningAll) {
|
|
|
142
218
|
const tableName = getTableName(ast.table);
|
|
143
219
|
const colInfo = getColumns(ast.columns);
|
|
144
220
|
let data = {};
|
|
145
|
-
if (ast.values.
|
|
146
|
-
throw new Error(`unexpected
|
|
221
|
+
if (ast.values.type !== "values") {
|
|
222
|
+
throw new Error(`unexpected insert values type ${ast.values.type}`);
|
|
223
|
+
}
|
|
224
|
+
if (ast.values.values.length !== 1) {
|
|
225
|
+
throw new Error(`unexpected number of values ${ast.values.values}`);
|
|
147
226
|
}
|
|
148
|
-
const val = ast.values[0];
|
|
227
|
+
const val = ast.values.values[0];
|
|
149
228
|
for (const val2 of val.value) {
|
|
150
229
|
assert(isPreparedStatementValue(val2), "prepared statement");
|
|
151
230
|
}
|
|
@@ -278,6 +357,9 @@ const preparedRegex = new RegExp(/\$(\d+)/);
|
|
|
278
357
|
function getValueFromRegex(val, values) {
|
|
279
358
|
// TODO support non-prepared statements
|
|
280
359
|
assert(isPreparedStatementValue(val), "prepared statement");
|
|
360
|
+
if (val.type === "var" && val.prefix === "$") {
|
|
361
|
+
return values[val.name - 1];
|
|
362
|
+
}
|
|
281
363
|
const result = preparedRegex.exec(val.value);
|
|
282
364
|
assert(result !== null);
|
|
283
365
|
let pos = parseInt(result[1], 10);
|
|
@@ -348,7 +430,9 @@ map) {
|
|
|
348
430
|
assert(ast.groupby === null, "non-null groupby");
|
|
349
431
|
assert(ast.having === null, "non-null having");
|
|
350
432
|
assert(ast.with === null, "non-null with");
|
|
351
|
-
|
|
433
|
+
const distinct = ast.distinct;
|
|
434
|
+
const hasDistinct = distinct != null && distinct.type != null;
|
|
435
|
+
assert(!hasDistinct, "non-null distinct");
|
|
352
436
|
assert(ast.options === null, "non-null options");
|
|
353
437
|
const tableName = getTableName(ast.from);
|
|
354
438
|
const colsInfo = getColumns(ast.columns);
|
|
@@ -357,26 +441,36 @@ map) {
|
|
|
357
441
|
let offset = null;
|
|
358
442
|
if (ast.limit !== null) {
|
|
359
443
|
const limitInfo = ast.limit;
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
assert(value.type == "number", "limit type was not 0");
|
|
364
|
-
return value.value;
|
|
365
|
-
});
|
|
366
|
-
const separator = limitInfo.seperator || "";
|
|
367
|
-
if (parsedValues.length === 1) {
|
|
368
|
-
limit = parsedValues[0];
|
|
369
|
-
}
|
|
370
|
-
else if (separator === ",") {
|
|
371
|
-
offset = parsedValues[0];
|
|
372
|
-
limit = parsedValues[1];
|
|
373
|
-
}
|
|
374
|
-
else if (separator === "offset") {
|
|
375
|
-
limit = parsedValues[0];
|
|
376
|
-
offset = parsedValues[1];
|
|
444
|
+
const limitValues = limitInfo.value || [];
|
|
445
|
+
if (limitValues.length === 0) {
|
|
446
|
+
// no limit
|
|
377
447
|
}
|
|
378
448
|
else {
|
|
379
|
-
|
|
449
|
+
assert(limitValues.length >= 1 && limitValues.length <= 2, "ast limit not as expected");
|
|
450
|
+
const parsedValues = limitValues.map((value) => {
|
|
451
|
+
if (value.type === "number") {
|
|
452
|
+
return value.value;
|
|
453
|
+
}
|
|
454
|
+
if (isPreparedStatementValue(value)) {
|
|
455
|
+
return getValueFromRegex(value, values);
|
|
456
|
+
}
|
|
457
|
+
throw new Error("limit type was not 0");
|
|
458
|
+
});
|
|
459
|
+
const separator = limitInfo.seperator || "";
|
|
460
|
+
if (parsedValues.length === 1) {
|
|
461
|
+
limit = parsedValues[0];
|
|
462
|
+
}
|
|
463
|
+
else if (separator === ",") {
|
|
464
|
+
offset = parsedValues[0];
|
|
465
|
+
limit = parsedValues[1];
|
|
466
|
+
}
|
|
467
|
+
else if (separator === "offset") {
|
|
468
|
+
limit = parsedValues[0];
|
|
469
|
+
offset = parsedValues[1];
|
|
470
|
+
}
|
|
471
|
+
else {
|
|
472
|
+
throw new Error(`unsupported limit separator: ${separator}`);
|
|
473
|
+
}
|
|
380
474
|
}
|
|
381
475
|
}
|
|
382
476
|
const astOffset = ast.offset;
|
|
@@ -390,8 +484,15 @@ map) {
|
|
|
390
484
|
offset = offsetValue;
|
|
391
485
|
}
|
|
392
486
|
else if (Array.isArray(offsetValue) && offsetValue.length) {
|
|
393
|
-
|
|
394
|
-
|
|
487
|
+
if (offsetValue[0].type === "number") {
|
|
488
|
+
offset = offsetValue[0].value;
|
|
489
|
+
}
|
|
490
|
+
else if (isPreparedStatementValue(offsetValue[0])) {
|
|
491
|
+
offset = getValueFromRegex(offsetValue[0], values);
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
throw new Error("offset type was not 0");
|
|
495
|
+
}
|
|
395
496
|
}
|
|
396
497
|
}
|
|
397
498
|
}
|
|
@@ -399,7 +500,7 @@ map) {
|
|
|
399
500
|
if (ast.orderby !== null) {
|
|
400
501
|
for (const order of ast.orderby) {
|
|
401
502
|
const col = getColumnFromRef(order.expr);
|
|
402
|
-
orderings.push([col, order.type]);
|
|
503
|
+
orderings.push([col, order.type ?? "ASC"]);
|
|
403
504
|
}
|
|
404
505
|
// TODO fix this
|
|
405
506
|
if (colsInfo.count) {
|
|
@@ -479,9 +580,15 @@ function parseUpdateStatement(ast, values, map, returningAll) {
|
|
|
479
580
|
assert(Array.isArray(ast.set));
|
|
480
581
|
let overwrite = {};
|
|
481
582
|
for (const set of ast.set) {
|
|
482
|
-
|
|
583
|
+
const setAny = set;
|
|
584
|
+
const colRef = "type" in setAny
|
|
585
|
+
? setAny
|
|
586
|
+
: "column" in setAny
|
|
587
|
+
? setAny.column ?? setAny
|
|
588
|
+
: setAny;
|
|
589
|
+
const colName = typeof colRef === "string" ? colRef : getColumnFromRef(colRef);
|
|
483
590
|
let value = getValueFromRegex(set.value, values);
|
|
484
|
-
overwrite[
|
|
591
|
+
overwrite[colName] = processBeforeStoring(value);
|
|
485
592
|
}
|
|
486
593
|
let columns = new Set();
|
|
487
594
|
if (ast.returning) {
|
|
@@ -569,7 +676,7 @@ function getAst(query) {
|
|
|
569
676
|
}
|
|
570
677
|
let ast;
|
|
571
678
|
try {
|
|
572
|
-
const p = new
|
|
679
|
+
const p = new Parser();
|
|
573
680
|
const parsed = p.parse(query, {
|
|
574
681
|
database: "postgresql",
|
|
575
682
|
});
|
|
@@ -617,4 +724,5 @@ function performQuery(query, values, map) {
|
|
|
617
724
|
parseDeleteStatement(ast, values, map);
|
|
618
725
|
}
|
|
619
726
|
}
|
|
620
|
-
|
|
727
|
+
const Parser = node_sql_parser_1.default
|
|
728
|
+
.Parser;
|
package/testutils/query.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getVerifyAfterEachCursorGeneric = getVerifyAfterEachCursorGeneric;
|
|
4
|
+
exports.getWhereClause = getWhereClause;
|
|
4
5
|
function getVerifyAfterEachCursorGeneric(edges, pageLength, user, getQuery, ml, verifyQuery) {
|
|
5
6
|
let query;
|
|
6
7
|
async function verify(i, hasEdge, hasNextPage, cursor) {
|
|
@@ -34,7 +35,6 @@ function getVerifyAfterEachCursorGeneric(edges, pageLength, user, getQuery, ml,
|
|
|
34
35
|
}
|
|
35
36
|
return { verify, getCursor };
|
|
36
37
|
}
|
|
37
|
-
exports.getVerifyAfterEachCursorGeneric = getVerifyAfterEachCursorGeneric;
|
|
38
38
|
function getWhereClause(query) {
|
|
39
39
|
const idx = query.query.indexOf("WHERE");
|
|
40
40
|
if (idx !== -1) {
|
|
@@ -42,4 +42,3 @@ function getWhereClause(query) {
|
|
|
42
42
|
}
|
|
43
43
|
return null;
|
|
44
44
|
}
|
|
45
|
-
exports.getWhereClause = getWhereClause;
|
package/testutils/soft_delete.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.DeletedAtPatternWithExtraWrites = exports.DeletedAtSnakeCasePattern = exports.DeletedAtPattern = void 0;
|
|
27
37
|
const orchestrator_1 = require("../action/orchestrator");
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.testEdgeGlobalSchema = exports.EdgeWithDeletedAt = void 0;
|
|
27
37
|
const schema_1 = require("../schema");
|
package/testutils/write.js
CHANGED
|
@@ -15,15 +15,27 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
36
|
+
exports.createRowForTest = createRowForTest;
|
|
37
|
+
exports.editRowForTest = editRowForTest;
|
|
38
|
+
exports.deleteRowsForTest = deleteRowsForTest;
|
|
27
39
|
const ent_1 = require("../core/ent");
|
|
28
40
|
const db_1 = __importStar(require("../core/db"));
|
|
29
41
|
function isSyncClient(client) {
|
|
@@ -47,7 +59,6 @@ async function createRowForTest(options, suffix) {
|
|
|
47
59
|
client.release();
|
|
48
60
|
}
|
|
49
61
|
}
|
|
50
|
-
exports.createRowForTest = createRowForTest;
|
|
51
62
|
async function editRowForTest(options, suffix) {
|
|
52
63
|
const client = await db_1.default.getInstance().getNewClient();
|
|
53
64
|
try {
|
|
@@ -60,7 +71,6 @@ async function editRowForTest(options, suffix) {
|
|
|
60
71
|
client.release();
|
|
61
72
|
}
|
|
62
73
|
}
|
|
63
|
-
exports.editRowForTest = editRowForTest;
|
|
64
74
|
async function deleteRowsForTest(options, cls) {
|
|
65
75
|
const client = await db_1.default.getInstance().getNewClient();
|
|
66
76
|
try {
|
|
@@ -73,4 +83,3 @@ async function deleteRowsForTest(options, cls) {
|
|
|
73
83
|
client.release();
|
|
74
84
|
}
|
|
75
85
|
}
|
|
76
|
-
exports.deleteRowsForTest = deleteRowsForTest;
|
package/tsc/ast.js
CHANGED
|
@@ -15,18 +15,37 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
39
|
+
exports.getPreText = getPreText;
|
|
40
|
+
exports.getClassInfo = getClassInfo;
|
|
41
|
+
exports.transformImport = transformImport;
|
|
42
|
+
exports.updateImportPath = updateImportPath;
|
|
43
|
+
exports.isRelativeImport = isRelativeImport;
|
|
44
|
+
exports.isRelativeGeneratedImport = isRelativeGeneratedImport;
|
|
45
|
+
exports.isSrcGeneratedImport = isSrcGeneratedImport;
|
|
46
|
+
exports.getImportInfo = getImportInfo;
|
|
47
|
+
exports.transformRelative = transformRelative;
|
|
48
|
+
exports.getCustomInfo = getCustomInfo;
|
|
30
49
|
const typescript_1 = __importDefault(require("typescript"));
|
|
31
50
|
const path = __importStar(require("path"));
|
|
32
51
|
const js_yaml_1 = require("js-yaml");
|
|
@@ -35,7 +54,6 @@ const const_1 = require("../core/const");
|
|
|
35
54
|
function getPreText(fileContents, node, sourceFile) {
|
|
36
55
|
return fileContents.substring(node.getFullStart(), node.getStart(sourceFile));
|
|
37
56
|
}
|
|
38
|
-
exports.getPreText = getPreText;
|
|
39
57
|
function getClassInfo(fileContents, sourceFile, node, override) {
|
|
40
58
|
let className = node.name?.text;
|
|
41
59
|
let classExtends;
|
|
@@ -108,7 +126,6 @@ function getClassInfo(fileContents, sourceFile, node, override) {
|
|
|
108
126
|
default: hasDefault,
|
|
109
127
|
};
|
|
110
128
|
}
|
|
111
|
-
exports.getClassInfo = getClassInfo;
|
|
112
129
|
function transformImport(fileContents, importNode, sourceFile, opts) {
|
|
113
130
|
// remove quotes too
|
|
114
131
|
const text = importNode.moduleSpecifier.getText(sourceFile).slice(1, -1);
|
|
@@ -163,7 +180,6 @@ function transformImport(fileContents, importNode, sourceFile, opts) {
|
|
|
163
180
|
text +
|
|
164
181
|
'";');
|
|
165
182
|
}
|
|
166
|
-
exports.transformImport = transformImport;
|
|
167
183
|
function updateImportPath(fileContents, importNode, sourceFile, newPath) {
|
|
168
184
|
const comment = getPreText(fileContents, importNode, sourceFile);
|
|
169
185
|
// all this copied from above...
|
|
@@ -186,23 +202,19 @@ function updateImportPath(fileContents, importNode, sourceFile, newPath) {
|
|
|
186
202
|
newPath +
|
|
187
203
|
'";');
|
|
188
204
|
}
|
|
189
|
-
exports.updateImportPath = updateImportPath;
|
|
190
205
|
function isRelativeImport(node, sourceFile) {
|
|
191
206
|
const text = node.moduleSpecifier.getText(sourceFile).slice(1, -1);
|
|
192
207
|
return text.startsWith("..") || text.startsWith("./");
|
|
193
208
|
}
|
|
194
|
-
exports.isRelativeImport = isRelativeImport;
|
|
195
209
|
function isRelativeGeneratedImport(node, sourceFile) {
|
|
196
210
|
const text = node.moduleSpecifier.getText(sourceFile).slice(1, -1);
|
|
197
211
|
return ((text.startsWith("..") || text.startsWith("./")) &&
|
|
198
212
|
text.indexOf("/generated") !== -1);
|
|
199
213
|
}
|
|
200
|
-
exports.isRelativeGeneratedImport = isRelativeGeneratedImport;
|
|
201
214
|
function isSrcGeneratedImport(node, sourceFile) {
|
|
202
215
|
const text = node.moduleSpecifier.getText(sourceFile).slice(1, -1);
|
|
203
216
|
return text.startsWith("src") && text.includes("/generated");
|
|
204
217
|
}
|
|
205
|
-
exports.isSrcGeneratedImport = isSrcGeneratedImport;
|
|
206
218
|
// TODO doesn't support default + {} yet
|
|
207
219
|
function getImportInfo(imp, sourceFile) {
|
|
208
220
|
const importText = imp.importClause?.getText(sourceFile) || "";
|
|
@@ -232,7 +244,6 @@ function getImportInfo(imp, sourceFile) {
|
|
|
232
244
|
default: def,
|
|
233
245
|
};
|
|
234
246
|
}
|
|
235
|
-
exports.getImportInfo = getImportInfo;
|
|
236
247
|
function transformRelative(file, importPath, relative) {
|
|
237
248
|
if (!relative || !importPath.startsWith("src")) {
|
|
238
249
|
return importPath;
|
|
@@ -242,7 +253,6 @@ function transformRelative(file, importPath, relative) {
|
|
|
242
253
|
// relative path is from directory
|
|
243
254
|
return normalizePath(path.relative(path.dirname(fileFullPath), impFullPath));
|
|
244
255
|
}
|
|
245
|
-
exports.transformRelative = transformRelative;
|
|
246
256
|
function normalizePath(p) {
|
|
247
257
|
if (p.endsWith("..")) {
|
|
248
258
|
return p + "/";
|
|
@@ -279,4 +289,3 @@ function getCustomInfo() {
|
|
|
279
289
|
globalSchemaPath: yaml.globalSchemaPath,
|
|
280
290
|
};
|
|
281
291
|
}
|
|
282
|
-
exports.getCustomInfo = getCustomInfo;
|
package/tsc/compilerOptions.js
CHANGED
|
@@ -15,18 +15,32 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
39
|
+
exports.readCompilerOptions = readCompilerOptions;
|
|
40
|
+
exports.getTarget = getTarget;
|
|
41
|
+
exports.getModule = getModule;
|
|
42
|
+
exports.getTargetFromCurrentDir = getTargetFromCurrentDir;
|
|
43
|
+
exports.createSourceFile = createSourceFile;
|
|
30
44
|
const fs = __importStar(require("fs"));
|
|
31
45
|
const json5_1 = __importDefault(require("json5"));
|
|
32
46
|
const typescript_1 = __importDefault(require("typescript"));
|
|
@@ -64,7 +78,6 @@ function readCompilerOptions(filePath) {
|
|
|
64
78
|
options.module = getModule(options.module);
|
|
65
79
|
return options;
|
|
66
80
|
}
|
|
67
|
-
exports.readCompilerOptions = readCompilerOptions;
|
|
68
81
|
function getTarget(target) {
|
|
69
82
|
switch (target?.toLowerCase()) {
|
|
70
83
|
case "es2015":
|
|
@@ -91,7 +104,6 @@ function getTarget(target) {
|
|
|
91
104
|
return typescript_1.default.ScriptTarget.ESNext;
|
|
92
105
|
}
|
|
93
106
|
}
|
|
94
|
-
exports.getTarget = getTarget;
|
|
95
107
|
function getModule(module) {
|
|
96
108
|
switch (module?.toLowerCase()) {
|
|
97
109
|
case "none":
|
|
@@ -120,16 +132,13 @@ function getModule(module) {
|
|
|
120
132
|
return typescript_1.default.ModuleKind.CommonJS;
|
|
121
133
|
}
|
|
122
134
|
}
|
|
123
|
-
exports.getModule = getModule;
|
|
124
135
|
function getTargetFromCurrentDir() {
|
|
125
136
|
const options = readCompilerOptions(".");
|
|
126
137
|
return getTarget(options.target?.toString());
|
|
127
138
|
}
|
|
128
|
-
exports.getTargetFromCurrentDir = getTargetFromCurrentDir;
|
|
129
139
|
function createSourceFile(target, file) {
|
|
130
140
|
let contents = fs.readFileSync(file).toString();
|
|
131
141
|
// go through the file and print everything back if not starting immediately after other position
|
|
132
142
|
const sourceFile = typescript_1.default.createSourceFile(file, contents, target, false, typescript_1.default.ScriptKind.TS);
|
|
133
143
|
return { contents, sourceFile };
|
|
134
144
|
}
|
|
135
|
-
exports.createSourceFile = createSourceFile;
|