@snowtop/ent 0.2.6 → 0.2.8
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 +4 -4
- package/action/operations.js +3 -0
- package/action/orchestrator.js +10 -12
- package/action/topological_sort.d.ts +9 -0
- package/action/topological_sort.js +46 -0
- package/core/async_utils.d.ts +1 -0
- package/core/async_utils.js +29 -0
- package/core/base.d.ts +12 -5
- package/core/clause.d.ts +3 -5
- package/core/clause.js +32 -0
- package/core/config.d.ts +28 -2
- package/core/config.js +14 -1
- package/core/context.d.ts +3 -1
- package/core/context.js +90 -26
- package/core/db.d.ts +12 -2
- package/core/db.js +102 -7
- package/core/dev_schema.d.ts +9 -0
- package/core/dev_schema.js +306 -0
- package/core/ent.d.ts +5 -7
- package/core/ent.js +33 -48
- package/core/extensions.d.ts +25 -0
- package/core/extensions.js +220 -0
- package/core/loaders/assoc_count_loader.js +3 -6
- package/core/loaders/assoc_edge_loader.d.ts +3 -0
- package/core/loaders/assoc_edge_loader.js +48 -19
- package/core/loaders/index.d.ts +2 -1
- package/core/loaders/index.js +5 -1
- package/core/loaders/loader.d.ts +31 -0
- package/core/loaders/loader.js +141 -2
- package/core/loaders/object_loader.d.ts +2 -2
- package/core/loaders/object_loader.js +39 -57
- package/core/loaders/query_loader.d.ts +2 -5
- package/core/loaders/query_loader.js +45 -24
- package/core/loaders/raw_count_loader.d.ts +2 -2
- package/core/loaders/raw_count_loader.js +12 -14
- package/core/memoize.d.ts +1 -0
- package/core/memoize.js +15 -0
- package/core/metrics.d.ts +22 -0
- package/core/metrics.js +31 -0
- package/core/query/custom_clause_query.js +5 -1
- package/core/query/query.d.ts +1 -1
- package/core/query/query.js +10 -7
- package/core/query_expression.d.ts +6 -0
- package/core/query_expression.js +2 -0
- package/core/query_impl.d.ts +19 -3
- package/core/query_impl.js +148 -35
- package/index.d.ts +7 -2
- package/index.js +12 -2
- package/package.json +1 -7
- package/parse_schema/parse.d.ts +2 -12
- package/parse_schema/parse.js +22 -41
- package/schema/index.d.ts +1 -1
- package/schema/schema.d.ts +20 -1
- package/scripts/custom_graphql.js +12 -5
- package/scripts/fix_action_exports.js +1 -1
- package/scripts/migrate_v0.1.js +2 -5
- package/scripts/move_types.js +1 -1
- package/scripts/read_schema.js +2 -5
- package/testutils/builder.js +1 -2
- package/testutils/parse_sql.js +1 -1
- package/tsc/compilerOptions.d.ts +2 -2
- package/tsc/compilerOptions.js +12 -18
- package/tsc/move_generated.js +2 -2
- package/tsc/transform.d.ts +1 -1
- package/tsc/transform.js +16 -2
- package/tsc/transform_action.d.ts +1 -1
- package/tsc/transform_action.js +1 -1
- package/tsc/transform_ent.d.ts +1 -1
- package/tsc/transform_ent.js +1 -1
- package/tsc/transform_schema.d.ts +1 -1
- package/tsc/transform_schema.js +2 -2
- /package/core/{loaders/cache_utils.d.ts → cache_utils.d.ts} +0 -0
- /package/core/{loaders/cache_utils.js → cache_utils.js} +0 -0
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, FieldMap, GlobalSchema, EdgeIndex, TransformReadBetaResult, CanViewerDo } from "../schema/schema";
|
|
2
|
+
import { ActionField, Type, DBExtension, FieldMap, GlobalSchema, EdgeIndex, TransformReadBetaResult, CanViewerDo } from "../schema/schema";
|
|
3
3
|
export declare function processFields(src: FieldMap | Field[], patternName?: string): Promise<ProcessedField[]>;
|
|
4
4
|
declare enum NullableResult {
|
|
5
5
|
CONTENTS = "contents",
|
|
@@ -68,22 +68,11 @@ interface Result {
|
|
|
68
68
|
schemas: schemasDict;
|
|
69
69
|
patterns: patternsDict;
|
|
70
70
|
globalSchema?: ProcessedGlobalSchema;
|
|
71
|
-
config?: {
|
|
72
|
-
rome?: BiomeConfig;
|
|
73
|
-
};
|
|
74
71
|
}
|
|
75
72
|
declare type PotentialSchemas = {
|
|
76
73
|
[key: string]: any;
|
|
77
74
|
};
|
|
78
75
|
export declare function parseSchema(potentialSchemas: PotentialSchemas, globalSchema?: GlobalSchema): Promise<Result>;
|
|
79
|
-
interface BiomeConfig {
|
|
80
|
-
indentStyle?: string;
|
|
81
|
-
lineWidth?: number;
|
|
82
|
-
indentSize?: number;
|
|
83
|
-
quoteStyle?: string;
|
|
84
|
-
quoteProperties?: string;
|
|
85
|
-
trailingComma?: string;
|
|
86
|
-
}
|
|
87
76
|
interface ProcessedGlobalSchema {
|
|
88
77
|
globalEdges: ProcessedAssocEdge[];
|
|
89
78
|
extraEdgeFields: ProcessedField[];
|
|
@@ -91,5 +80,6 @@ interface ProcessedGlobalSchema {
|
|
|
91
80
|
init?: boolean;
|
|
92
81
|
transformsEdges?: boolean;
|
|
93
82
|
globalFields?: ProcessedField[];
|
|
83
|
+
dbExtensions?: DBExtension[];
|
|
94
84
|
}
|
|
95
85
|
export {};
|
package/parse_schema/parse.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.processFields = processFields;
|
|
4
4
|
exports.parseSchema = parseSchema;
|
|
5
|
-
const cosmiconfig_1 = require("cosmiconfig");
|
|
6
5
|
const const_1 = require("../core/const");
|
|
7
6
|
const global_schema_1 = require("../core/global_schema");
|
|
8
7
|
async function processFields(src, patternName) {
|
|
@@ -448,53 +447,31 @@ async function parseSchema(potentialSchemas, globalSchema) {
|
|
|
448
447
|
}
|
|
449
448
|
schemas[key] = processedSchema;
|
|
450
449
|
}
|
|
451
|
-
const biome = translatePrettier();
|
|
452
450
|
return {
|
|
453
451
|
schemas,
|
|
454
452
|
patterns: processPatterns.patternsDict,
|
|
455
453
|
globalSchema: parsedGlobalSchema,
|
|
456
|
-
config: {
|
|
457
|
-
rome: biome,
|
|
458
|
-
},
|
|
459
454
|
};
|
|
460
455
|
}
|
|
461
|
-
function
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
return;
|
|
465
|
-
}
|
|
466
|
-
const ret = {};
|
|
467
|
-
if (r.config.printWidth !== undefined) {
|
|
468
|
-
ret.lineWidth = parseInt(r.config.printWidth);
|
|
469
|
-
}
|
|
470
|
-
if (r.config.useTabs) {
|
|
471
|
-
ret.indentStyle = "tab";
|
|
472
|
-
}
|
|
473
|
-
else {
|
|
474
|
-
ret.indentStyle = "space";
|
|
475
|
-
}
|
|
476
|
-
if (r.config.tabWidth !== undefined) {
|
|
477
|
-
ret.indentSize = parseInt(r.config.tabWidth);
|
|
478
|
-
}
|
|
479
|
-
if (r.config.singleQuote) {
|
|
480
|
-
ret.quoteStyle = "single";
|
|
481
|
-
}
|
|
482
|
-
else {
|
|
483
|
-
ret.quoteStyle = "double";
|
|
484
|
-
}
|
|
485
|
-
if (r.config.quoteProps !== undefined) {
|
|
486
|
-
if (r.config.quoteProps === "consistent") {
|
|
487
|
-
// biome doesn't support this
|
|
488
|
-
ret.quoteProperties = "as-needed";
|
|
489
|
-
}
|
|
490
|
-
else {
|
|
491
|
-
ret.quoteProperties = r.config.quoteProps;
|
|
492
|
-
}
|
|
456
|
+
function normalizeProvisionedBy(extension) {
|
|
457
|
+
if (extension.provisionedBy === "ent" ||
|
|
458
|
+
extension.provisionedBy === "external") {
|
|
459
|
+
return extension.provisionedBy;
|
|
493
460
|
}
|
|
494
|
-
if (
|
|
495
|
-
|
|
461
|
+
if (extension.provisionedBy) {
|
|
462
|
+
throw new Error(`invalid provisionedBy ${extension.provisionedBy} for db extension ${extension.name}`);
|
|
496
463
|
}
|
|
497
|
-
return
|
|
464
|
+
return "ent";
|
|
465
|
+
}
|
|
466
|
+
function processDBExtensions(src) {
|
|
467
|
+
return src
|
|
468
|
+
.map((extension) => ({
|
|
469
|
+
...extension,
|
|
470
|
+
provisionedBy: normalizeProvisionedBy(extension),
|
|
471
|
+
runtimeSchemas: extension.runtimeSchemas || [],
|
|
472
|
+
dropCascade: extension.dropCascade === true,
|
|
473
|
+
}))
|
|
474
|
+
.sort((lhs, rhs) => lhs.name.localeCompare(rhs.name));
|
|
498
475
|
}
|
|
499
476
|
async function parseGlobalSchema(s) {
|
|
500
477
|
const ret = {
|
|
@@ -504,7 +481,8 @@ async function parseGlobalSchema(s) {
|
|
|
504
481
|
!!s.edgeIndices ||
|
|
505
482
|
s.transformEdgeRead !== undefined ||
|
|
506
483
|
s.transformEdgeWrite !== undefined ||
|
|
507
|
-
s.fields !== undefined
|
|
484
|
+
s.fields !== undefined ||
|
|
485
|
+
!!s.dbExtensions?.length,
|
|
508
486
|
transformsEdges: !!s.transformEdgeRead || !!s.transformEdgeWrite,
|
|
509
487
|
};
|
|
510
488
|
if (s.extraEdgeFields) {
|
|
@@ -519,5 +497,8 @@ async function parseGlobalSchema(s) {
|
|
|
519
497
|
if (s.fields) {
|
|
520
498
|
ret.globalFields = await processFields(s.fields);
|
|
521
499
|
}
|
|
500
|
+
if (s.dbExtensions) {
|
|
501
|
+
ret.dbExtensions = processDBExtensions(s.dbExtensions);
|
|
502
|
+
}
|
|
522
503
|
return ret;
|
|
523
504
|
}
|
package/schema/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Schema from "./schema";
|
|
2
2
|
export { Schema };
|
|
3
|
-
export { Field, AssocEdge, AssocEdgeGroup, InverseAssocEdge, Edge, Pattern, DBType, Type, FieldOptions, SchemaConstructor, SchemaInputType, getFields, getFieldsWithPrivacy, getFieldsWithEditPrivacy, getStorageKey, ActionOperation, Action, EdgeAction, NoFields, FieldMap, Constraint, Index, EdgeIndex, ConstraintType, ForeignKeyInfo, requiredField, optionalField, UpdateOperation, TransformedUpdateOperation, SQLStatementOperation, EdgeUpdateOperation, TransformedEdgeUpdateOperation, getTransformedReadClause, getObjectLoaderProperties, GlobalSchema, ActionField, } from "./schema";
|
|
3
|
+
export { Field, AssocEdge, AssocEdgeGroup, InverseAssocEdge, Edge, Pattern, DBType, Type, FieldOptions, SchemaConstructor, SchemaInputType, getFields, getFieldsWithPrivacy, getFieldsWithEditPrivacy, getStorageKey, ActionOperation, Action, EdgeAction, NoFields, FieldMap, Constraint, Index, EdgeIndex, ConstraintType, ForeignKeyInfo, requiredField, optionalField, UpdateOperation, TransformedUpdateOperation, SQLStatementOperation, EdgeUpdateOperation, TransformedEdgeUpdateOperation, getTransformedReadClause, getObjectLoaderProperties, GlobalSchema, DBExtension, ActionField, } from "./schema";
|
|
4
4
|
export { Timestamps, Node, BaseEntSchema, BaseEntSchemaWithTZ, EntSchema, EntSchemaWithTZ, SchemaConfig, } from "./base_schema";
|
|
5
5
|
export * from "./field";
|
|
6
6
|
export * from "./json_field";
|
package/schema/schema.d.ts
CHANGED
|
@@ -13,6 +13,15 @@ interface FieldInfo {
|
|
|
13
13
|
export type FieldInfoMap = {
|
|
14
14
|
[key: string]: FieldInfo;
|
|
15
15
|
};
|
|
16
|
+
export interface DBExtension {
|
|
17
|
+
name: string;
|
|
18
|
+
provisionedBy?: "ent" | "external";
|
|
19
|
+
version?: string;
|
|
20
|
+
installSchema?: string;
|
|
21
|
+
runtimeSchemas?: string[];
|
|
22
|
+
dropCascade?: boolean;
|
|
23
|
+
[x: string]: any;
|
|
24
|
+
}
|
|
16
25
|
export interface GlobalSchema {
|
|
17
26
|
edges?: Edge[];
|
|
18
27
|
extraEdgeFields?: FieldMap;
|
|
@@ -20,6 +29,7 @@ export interface GlobalSchema {
|
|
|
20
29
|
transformEdgeRead?: () => Clause;
|
|
21
30
|
transformEdgeWrite?: (stmt: EdgeUpdateOperation) => TransformedEdgeUpdateOperation | null;
|
|
22
31
|
fields?: FieldMap;
|
|
32
|
+
dbExtensions?: DBExtension[];
|
|
23
33
|
}
|
|
24
34
|
type FieldOverride = Pick<FieldOptions, "nullable" | "storageKey" | "serverDefault" | "unique" | "hideFromGraphQL" | "graphqlName" | "index" | "indexConcurrently" | "indexWhere">;
|
|
25
35
|
export type FieldOverrideMap = {
|
|
@@ -186,6 +196,8 @@ export interface Type {
|
|
|
186
196
|
deprecatedIntEnumMap?: IntEnumMap;
|
|
187
197
|
disableUnknownType?: boolean;
|
|
188
198
|
globalType?: string;
|
|
199
|
+
postgresType?: string;
|
|
200
|
+
dbExtension?: string;
|
|
189
201
|
importType?: DeprecatedImportType;
|
|
190
202
|
subFields?: FieldMap;
|
|
191
203
|
unionFields?: FieldMap;
|
|
@@ -361,9 +373,16 @@ export interface Index {
|
|
|
361
373
|
columns: string[];
|
|
362
374
|
unique?: boolean;
|
|
363
375
|
fulltext?: FullText;
|
|
364
|
-
indexType?:
|
|
376
|
+
indexType?: string;
|
|
365
377
|
concurrently?: boolean;
|
|
366
378
|
where?: string;
|
|
379
|
+
ops?: {
|
|
380
|
+
[column: string]: string;
|
|
381
|
+
};
|
|
382
|
+
indexParams?: {
|
|
383
|
+
[key: string]: string | number | boolean;
|
|
384
|
+
};
|
|
385
|
+
dbExtension?: string;
|
|
367
386
|
[x: string]: any;
|
|
368
387
|
}
|
|
369
388
|
export interface EdgeIndex extends Omit<Index, "name"> {
|
|
@@ -38,20 +38,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
};
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
40
|
const glob = __importStar(require("glob"));
|
|
41
|
-
const json5_1 = __importDefault(require("json5"));
|
|
42
|
-
const minimist_1 = __importDefault(require("minimist"));
|
|
43
41
|
const path = __importStar(require("path"));
|
|
44
42
|
const fs = __importStar(require("fs"));
|
|
43
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
45
44
|
const graphql_1 = require("../graphql/graphql");
|
|
46
45
|
const readline = __importStar(require("readline"));
|
|
47
46
|
const imports_1 = require("../imports");
|
|
48
47
|
const process_1 = require("process");
|
|
49
48
|
const child_process_1 = require("child_process");
|
|
50
49
|
const const_1 = require("../core/const");
|
|
50
|
+
const { parseArgs } = require("./parse_args");
|
|
51
51
|
// need to use the GQLCapture from the package so that when we call GQLCapture.enable()
|
|
52
52
|
// we're affecting the local paths as opposed to a different instance
|
|
53
53
|
// life is hard
|
|
54
54
|
const MODULE_PATH = const_1.GRAPHQL_PATH;
|
|
55
|
+
function parseJSONC(fileName, text) {
|
|
56
|
+
const { config, error } = typescript_1.default.parseConfigFileTextToJson(fileName, text);
|
|
57
|
+
if (error) {
|
|
58
|
+
throw new Error(typescript_1.default.flattenDiagnosticMessageText(error.messageText, "\n"));
|
|
59
|
+
}
|
|
60
|
+
return config;
|
|
61
|
+
}
|
|
55
62
|
async function readInputs() {
|
|
56
63
|
return new Promise((resolve) => {
|
|
57
64
|
const rl = readline.createInterface({
|
|
@@ -195,7 +202,7 @@ async function captureDynamic(filePath, gqlCapture) {
|
|
|
195
202
|
reject(new Error(`error code ${code} on dynamic path`));
|
|
196
203
|
return;
|
|
197
204
|
}
|
|
198
|
-
|
|
205
|
+
const json = parseJSONC(filePath, datas.join(""));
|
|
199
206
|
processJSON(gqlCapture, json);
|
|
200
207
|
resolve(undefined);
|
|
201
208
|
});
|
|
@@ -228,7 +235,7 @@ async function processJSON(gqlCapture, json) {
|
|
|
228
235
|
}
|
|
229
236
|
async function captureCustom(filePath, filesCsv, jsonPath, gqlCapture) {
|
|
230
237
|
if (jsonPath !== undefined) {
|
|
231
|
-
|
|
238
|
+
const json = parseJSONC(jsonPath, fs.readFileSync(jsonPath, {
|
|
232
239
|
encoding: "utf8",
|
|
233
240
|
}));
|
|
234
241
|
processJSON(gqlCapture, json);
|
|
@@ -331,7 +338,7 @@ function findGraphQLPath(filePath) {
|
|
|
331
338
|
// also, there should be a way to get the list of objects here that's not manual
|
|
332
339
|
//echo "User\nContact\nContactEmail\nComment" | ts-node-script --log-error --project ./tsconfig.json -r tsconfig-paths/register ../../ts/src/scripts/custom_graphql.ts --path ~/code/ent/examples/simple/src/
|
|
333
340
|
async function main() {
|
|
334
|
-
const options = (
|
|
341
|
+
const options = parseArgs(process.argv.slice(2));
|
|
335
342
|
if (!options.path) {
|
|
336
343
|
throw new Error("path required");
|
|
337
344
|
}
|
|
@@ -39,7 +39,7 @@ const typescript_1 = __importStar(require("typescript"));
|
|
|
39
39
|
class FixActionExports {
|
|
40
40
|
constructor() {
|
|
41
41
|
this.glob = "src/ent/**/actions/*_action.ts";
|
|
42
|
-
this.
|
|
42
|
+
this.formatGlob = "src/ent/**/actions/*_action.ts";
|
|
43
43
|
}
|
|
44
44
|
traverseChild(sourceFile, contents, file, node) {
|
|
45
45
|
if (!(0, typescript_1.isClassDeclaration)(node)) {
|
package/scripts/migrate_v0.1.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
3
|
+
const { parseArgs } = require("./parse_args");
|
|
7
4
|
const transform_1 = require("../tsc/transform");
|
|
8
5
|
const transform_schema_1 = require("../tsc/transform_schema");
|
|
9
6
|
const transform_ent_1 = require("../tsc/transform_ent");
|
|
@@ -14,7 +11,7 @@ const ast_1 = require("../tsc/ast");
|
|
|
14
11
|
// ts-node-script --swc --project ./tsconfig.json -r tsconfig-paths/register ../../ts/src/scripts/migrate_v0.1.ts --transform_schema --old_base_class BaseEntTodoSchema --new_schema_class TodoEntSchema --transform_path src/schema/patterns/base
|
|
15
12
|
function main() {
|
|
16
13
|
const customInfo = (0, ast_1.getCustomInfo)();
|
|
17
|
-
const options = (
|
|
14
|
+
const options = parseArgs(process.argv.slice(2));
|
|
18
15
|
// install 0.1.x dependencies
|
|
19
16
|
// maybe provide options to make this easier if someone wants to do this in steps to see what's happening
|
|
20
17
|
if (options.move_generated) {
|
package/scripts/move_types.js
CHANGED
|
@@ -66,7 +66,7 @@ class GatherExportsInGeneratedTypes {
|
|
|
66
66
|
class TransformImports {
|
|
67
67
|
constructor() {
|
|
68
68
|
this.glob = "src/**/*.ts";
|
|
69
|
-
this.
|
|
69
|
+
this.formatGlob = "src/**/*.ts";
|
|
70
70
|
this.impsToMove = new Map();
|
|
71
71
|
this.cwd = "";
|
|
72
72
|
this.relative = false;
|
package/scripts/read_schema.js
CHANGED
|
@@ -32,18 +32,15 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
36
|
const glob = __importStar(require("glob"));
|
|
40
37
|
const path = __importStar(require("path"));
|
|
41
|
-
const
|
|
38
|
+
const { parseArgs } = require("./parse_args");
|
|
42
39
|
const parse_1 = require("../parse_schema/parse");
|
|
43
40
|
const ast_1 = require("../tsc/ast");
|
|
44
41
|
const names_1 = require("../names/names");
|
|
45
42
|
function main() {
|
|
46
|
-
const options = (
|
|
43
|
+
const options = parseArgs(process.argv.slice(2));
|
|
47
44
|
if (!options.path) {
|
|
48
45
|
throw new Error("path required");
|
|
49
46
|
}
|
package/testutils/builder.js
CHANGED
|
@@ -195,8 +195,7 @@ class SimpleBuilder {
|
|
|
195
195
|
// create dynamic placeholder
|
|
196
196
|
// TODO: do we need to use this as the node when there's an existingEnt
|
|
197
197
|
// same for generated builders.
|
|
198
|
-
this.placeholderID = `$ent.idPlaceholderID$ ${randomNum()}-${schema.ent
|
|
199
|
-
?.name}`;
|
|
198
|
+
this.placeholderID = `$ent.idPlaceholderID$ ${randomNum()}-${schema.ent?.name}`;
|
|
200
199
|
if (this.operation === action_1.WriteOperation.Insert) {
|
|
201
200
|
for (const [key, value] of fields) {
|
|
202
201
|
if (key === "id" && value === "{id}") {
|
package/testutils/parse_sql.js
CHANGED
|
@@ -584,7 +584,7 @@ function parseUpdateStatement(ast, values, map, returningAll) {
|
|
|
584
584
|
const colRef = "type" in setAny
|
|
585
585
|
? setAny
|
|
586
586
|
: "column" in setAny
|
|
587
|
-
? setAny.column ?? setAny
|
|
587
|
+
? (setAny.column ?? setAny)
|
|
588
588
|
: setAny;
|
|
589
589
|
const colName = typeof colRef === "string" ? colRef : getColumnFromRef(colRef);
|
|
590
590
|
let value = getValueFromRegex(set.value, values);
|
package/tsc/compilerOptions.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
export declare function readCompilerOptions(filePath: string): ts.CompilerOptions;
|
|
3
|
-
export declare function getTarget(target?: string): ts.ScriptTarget;
|
|
4
|
-
export declare function getModule(module?: string): ts.ModuleKind;
|
|
3
|
+
export declare function getTarget(target?: string | number): ts.ScriptTarget;
|
|
4
|
+
export declare function getModule(module?: string | number): ts.ModuleKind;
|
|
5
5
|
export declare function getTargetFromCurrentDir(): ts.ScriptTarget;
|
|
6
6
|
export declare function createSourceFile(target: ts.ScriptTarget, file: string): {
|
|
7
7
|
contents: string;
|
package/tsc/compilerOptions.js
CHANGED
|
@@ -42,7 +42,6 @@ exports.getModule = getModule;
|
|
|
42
42
|
exports.getTargetFromCurrentDir = getTargetFromCurrentDir;
|
|
43
43
|
exports.createSourceFile = createSourceFile;
|
|
44
44
|
const fs = __importStar(require("fs"));
|
|
45
|
-
const json5_1 = __importDefault(require("json5"));
|
|
46
45
|
const typescript_1 = __importDefault(require("typescript"));
|
|
47
46
|
const path = __importStar(require("path"));
|
|
48
47
|
function findTSConfigFile(filePath) {
|
|
@@ -56,29 +55,21 @@ function findTSConfigFile(filePath) {
|
|
|
56
55
|
return null;
|
|
57
56
|
}
|
|
58
57
|
function readCompilerOptions(filePath) {
|
|
59
|
-
|
|
58
|
+
const configPath = findTSConfigFile(filePath);
|
|
60
59
|
if (!configPath) {
|
|
61
60
|
return {};
|
|
62
61
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
json = json5_1.default.parse(fs.readFileSync(configPath, {
|
|
66
|
-
encoding: "utf8",
|
|
67
|
-
}));
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
62
|
+
const { config, error } = typescript_1.default.readConfigFile(configPath, typescript_1.default.sys.readFile);
|
|
63
|
+
if (error) {
|
|
70
64
|
console.error("couldn't read tsconfig.json file");
|
|
65
|
+
return {};
|
|
71
66
|
}
|
|
72
|
-
|
|
73
|
-
// @ts-ignore
|
|
74
|
-
if (options.moduleResolution === "node") {
|
|
75
|
-
options.moduleResolution = typescript_1.default.ModuleResolutionKind.NodeJs;
|
|
76
|
-
}
|
|
77
|
-
options.target = getTarget(options.target);
|
|
78
|
-
options.module = getModule(options.module);
|
|
79
|
-
return options;
|
|
67
|
+
return typescript_1.default.parseJsonConfigFileContent(config, typescript_1.default.sys, path.dirname(configPath), undefined, configPath).options;
|
|
80
68
|
}
|
|
81
69
|
function getTarget(target) {
|
|
70
|
+
if (typeof target === "number") {
|
|
71
|
+
return target;
|
|
72
|
+
}
|
|
82
73
|
switch (target?.toLowerCase()) {
|
|
83
74
|
case "es2015":
|
|
84
75
|
return typescript_1.default.ScriptTarget.ES2015;
|
|
@@ -105,6 +96,9 @@ function getTarget(target) {
|
|
|
105
96
|
}
|
|
106
97
|
}
|
|
107
98
|
function getModule(module) {
|
|
99
|
+
if (typeof module === "number") {
|
|
100
|
+
return module;
|
|
101
|
+
}
|
|
108
102
|
switch (module?.toLowerCase()) {
|
|
109
103
|
case "none":
|
|
110
104
|
return typescript_1.default.ModuleKind.None;
|
|
@@ -134,7 +128,7 @@ function getModule(module) {
|
|
|
134
128
|
}
|
|
135
129
|
function getTargetFromCurrentDir() {
|
|
136
130
|
const options = readCompilerOptions(".");
|
|
137
|
-
return getTarget(options.target
|
|
131
|
+
return getTarget(options.target);
|
|
138
132
|
}
|
|
139
133
|
function createSourceFile(target, file) {
|
|
140
134
|
let contents = fs.readFileSync(file).toString();
|
package/tsc/move_generated.js
CHANGED
|
@@ -53,9 +53,9 @@ class MoveFiles {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
class TransformImports {
|
|
56
|
-
constructor(glob,
|
|
56
|
+
constructor(glob, formatGlob, relativeImports, checkRelativeImportsValid) {
|
|
57
57
|
this.glob = glob;
|
|
58
|
-
this.
|
|
58
|
+
this.formatGlob = formatGlob;
|
|
59
59
|
this.relativeImports = relativeImports;
|
|
60
60
|
this.checkRelativeImportsValid = checkRelativeImportsValid;
|
|
61
61
|
this.globOptions = {
|
package/tsc/transform.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface TransformFile {
|
|
|
16
16
|
filter?(files: string[]): string[];
|
|
17
17
|
fileToWrite?(file: string): string;
|
|
18
18
|
postProcess?(file: string): void;
|
|
19
|
-
|
|
19
|
+
formatGlob?: string;
|
|
20
20
|
}
|
|
21
21
|
export declare function transform(transform: TransformFile): void;
|
|
22
22
|
export {};
|
package/tsc/transform.js
CHANGED
|
@@ -177,8 +177,22 @@ function transform(transform) {
|
|
|
177
177
|
transform.postProcess(file);
|
|
178
178
|
}
|
|
179
179
|
});
|
|
180
|
-
if (transform.
|
|
181
|
-
|
|
180
|
+
if (transform.formatGlob) {
|
|
181
|
+
const files = glob
|
|
182
|
+
.sync(transform.formatGlob, transform.globOptions ?? {})
|
|
183
|
+
.map((f) => (typeof f === "string" ? f : f.path));
|
|
184
|
+
if (!files.length) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const result = (0, child_process_1.spawnSync)(`biome`, ["format", "--write", "--files-ignore-unknown=true", ...files], {
|
|
188
|
+
encoding: "utf8",
|
|
189
|
+
});
|
|
190
|
+
if (result.error) {
|
|
191
|
+
throw result.error;
|
|
192
|
+
}
|
|
193
|
+
if (result.status !== 0) {
|
|
194
|
+
throw new Error(result.stderr || "biome format failed");
|
|
195
|
+
}
|
|
182
196
|
}
|
|
183
197
|
}
|
|
184
198
|
function isRequireStatement(node, sourceFile) {
|
|
@@ -4,7 +4,7 @@ import { TransformFile } from "./transform";
|
|
|
4
4
|
export declare class TransformAction implements TransformFile {
|
|
5
5
|
private customInfo;
|
|
6
6
|
glob: string;
|
|
7
|
-
|
|
7
|
+
formatGlob: string;
|
|
8
8
|
constructor(customInfo: customInfo);
|
|
9
9
|
traverseChild(sourceFile: ts.SourceFile, contents: string, file: string, node: ts.Node): {
|
|
10
10
|
node: ts.Node;
|
package/tsc/transform_action.js
CHANGED
|
@@ -120,7 +120,7 @@ class TransformAction {
|
|
|
120
120
|
constructor(customInfo) {
|
|
121
121
|
this.customInfo = customInfo;
|
|
122
122
|
this.glob = "src/ent/**/actions/**/*_action.ts";
|
|
123
|
-
this.
|
|
123
|
+
this.formatGlob = "src/ent/**/actions/**.ts";
|
|
124
124
|
}
|
|
125
125
|
traverseChild(sourceFile, contents, file, node) {
|
|
126
126
|
if (!typescript_1.default.isClassDeclaration(node) || !node.heritageClauses) {
|
package/tsc/transform_ent.d.ts
CHANGED
package/tsc/transform_ent.js
CHANGED
|
@@ -14,7 +14,7 @@ function isPrivacyPolicy(mm) {
|
|
|
14
14
|
class TransformEnt {
|
|
15
15
|
constructor() {
|
|
16
16
|
this.glob = "src/ent/*.ts";
|
|
17
|
-
this.
|
|
17
|
+
this.formatGlob = "src/ent/*.ts";
|
|
18
18
|
}
|
|
19
19
|
traverseChild(sourceFile, contents, file, node) {
|
|
20
20
|
if (!typescript_1.default.isClassDeclaration(node) || !node.heritageClauses) {
|
package/tsc/transform_schema.js
CHANGED
|
@@ -211,7 +211,7 @@ function getConstructorElementInfo(fileContents, member, sourceFile) {
|
|
|
211
211
|
return {
|
|
212
212
|
key: "patterns",
|
|
213
213
|
// remove this.addPatterns at the front, remove trailing ) at the end
|
|
214
|
-
// if there's a trailing comma, it'll be handled by
|
|
214
|
+
// if there's a trailing comma, it'll be handled by the formatter
|
|
215
215
|
value: `[${line.slice(addPatterns.length, -1)}]`,
|
|
216
216
|
comment: "",
|
|
217
217
|
};
|
|
@@ -343,7 +343,7 @@ class TransformSchema {
|
|
|
343
343
|
this.newSchemaClass = newSchemaClass;
|
|
344
344
|
this.transformPath = transformPath;
|
|
345
345
|
this.glob = "src/schema/*.ts";
|
|
346
|
-
this.
|
|
346
|
+
this.formatGlob = "src/schema/*.ts";
|
|
347
347
|
}
|
|
348
348
|
transformSchema(className) {
|
|
349
349
|
if (className === "BaseEntSchema" || className === "BaseEntSchemaWithTZ") {
|
|
File without changes
|
|
File without changes
|