@supacloud/cli 0.53.1 → 0.54.0
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/dist/index.js +467 -284
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -206633,9 +206633,9 @@ var ACTION_POLICY = {
|
|
|
206633
206633
|
local: ["list"]
|
|
206634
206634
|
},
|
|
206635
206635
|
database: {
|
|
206636
|
-
read: ["list_tables", "describe_columns", "list_indexes", "list_constraints", "list_extensions", "rls_status", "rls_policies", "list_auth_users", "get_auth_user", "connections", "stats", "slow_queries", "list_migrations", "migration_inventory", "project_url", "generate_types", "database_lint", "db_lint", "rpc_catalog", "list_rpcs"],
|
|
206636
|
+
read: ["list_tables", "describe_columns", "list_indexes", "list_constraints", "list_extensions", "extension_catalog", "rls_status", "rls_policies", "list_auth_users", "get_auth_user", "connections", "stats", "slow_queries", "list_migrations", "migration_inventory", "project_url", "generate_types", "database_lint", "db_lint", "rpc_catalog", "list_rpcs"],
|
|
206637
206637
|
local: ["lint_migrations", "lint"],
|
|
206638
|
-
write: ["query", "execute", "apply_migration", "push_migrations", "baseline_migrations", "create_table_rls"]
|
|
206638
|
+
write: ["query", "execute", "apply_migration", "push_migrations", "baseline_migrations", "create_table_rls", "enable_extension", "disable_extension"]
|
|
206639
206639
|
},
|
|
206640
206640
|
supabase: {
|
|
206641
206641
|
local: ["version", "migration_new", "db_diff", "db_reset", "db_pull", "db_dump", "migration_list", "gen_types"],
|
|
@@ -208317,6 +208317,7 @@ function registerDatabaseTools(server2, http, config = {}) {
|
|
|
208317
208317
|
"list_indexes",
|
|
208318
208318
|
"list_constraints",
|
|
208319
208319
|
"list_extensions",
|
|
208320
|
+
"extension_catalog",
|
|
208320
208321
|
"rls_status",
|
|
208321
208322
|
"rls_policies",
|
|
208322
208323
|
"list_auth_users",
|
|
@@ -208333,7 +208334,7 @@ function registerDatabaseTools(server2, http, config = {}) {
|
|
|
208333
208334
|
"rpc_catalog",
|
|
208334
208335
|
"list_rpcs"
|
|
208335
208336
|
];
|
|
208336
|
-
const writeActions = ["execute", "apply_migration", "push_migrations", "baseline_migrations", "create_table_rls"];
|
|
208337
|
+
const writeActions = ["execute", "apply_migration", "push_migrations", "baseline_migrations", "create_table_rls", "enable_extension", "disable_extension"];
|
|
208337
208338
|
const remoteActions = [...readActions, ...localActions];
|
|
208338
208339
|
const allActions = localOnly ? localActions : readOnly ? remoteActions : [...remoteActions, ...writeActions];
|
|
208339
208340
|
server2.tool("database", `Database operations: query, schema, RLS, migrations, stats.
|
|
@@ -208358,7 +208359,8 @@ Actions: ${allActions.join(", ")}${localOnly ? " (local-only mode)" : readOnly ?
|
|
|
208358
208359
|
name: optional(Type.String(), "[apply_migration] Migration name"),
|
|
208359
208360
|
columns: optional(Type.String(), "[create_table_rls] Column definitions"),
|
|
208360
208361
|
policy_mode: optional(stringEnum(["deny_all", "owner"]), "[create_table_rls] RLS policy mode (default: deny_all)"),
|
|
208361
|
-
owner_column: optional(Type.String(), "[create_table_rls owner] UUID owner column matched to auth.uid()")
|
|
208362
|
+
owner_column: optional(Type.String(), "[create_table_rls owner] UUID owner column matched to auth.uid()"),
|
|
208363
|
+
extension: optional(Type.String(), "[enable_extension/disable_extension] PostgreSQL extension or pgflow")
|
|
208362
208364
|
}, async (args) => {
|
|
208363
208365
|
const { action } = args;
|
|
208364
208366
|
if (localOnly && action !== "lint_migrations" && action !== "lint") {
|
|
@@ -208447,6 +208449,29 @@ Actions: ${allActions.join(", ")}${localOnly ? " (local-only mode)" : readOnly ?
|
|
|
208447
208449
|
text = r.ok ? formatExtensionList(r.data) : `❌ Failed (${r.status})`;
|
|
208448
208450
|
break;
|
|
208449
208451
|
}
|
|
208452
|
+
case "extension_catalog": {
|
|
208453
|
+
const path = `/v1/projects/${projectRefPathSegment(ref, action)}/database/extensions/catalog`;
|
|
208454
|
+
const result = await managementHttp().get(path);
|
|
208455
|
+
if (!result.ok || !Array.isArray(result.data))
|
|
208456
|
+
throw new Error("Extension inventory unavailable");
|
|
208457
|
+
return { content: [{ type: "text", text: JSON.stringify(result.data) }] };
|
|
208458
|
+
}
|
|
208459
|
+
case "enable_extension":
|
|
208460
|
+
case "disable_extension": {
|
|
208461
|
+
if (readOnly)
|
|
208462
|
+
throw new Error("Extension mutation blocked by read-only mode");
|
|
208463
|
+
if (typeof args.extension !== "string" || !/^[A-Za-z_][A-Za-z0-9_-]{0,62}$/.test(args.extension)) {
|
|
208464
|
+
throw new Error("A valid extension name is required");
|
|
208465
|
+
}
|
|
208466
|
+
const enabled = action === "enable_extension";
|
|
208467
|
+
const path = `/v1/projects/${projectRefPathSegment(ref, action)}/database/extensions`;
|
|
208468
|
+
const result = enabled ? await managementHttp().postReleaseMutation(path, { name: args.extension }) : await managementHttp().deleteReleaseMutation(path, { name: args.extension });
|
|
208469
|
+
const data = result.data;
|
|
208470
|
+
if (!result.ok || result.status !== 200 || !data || typeof data !== "object" || !("name" in data) || data.name !== args.extension || !("is_installed" in data) || typeof data.is_installed !== "boolean" || !("installed_version" in data) || (data.is_installed ? typeof data.installed_version !== "string" || !data.installed_version : data.installed_version !== null) || (args.extension === "pgflow" ? !("is_enabled" in data) || data.is_enabled !== enabled || enabled && !data.is_installed : data.is_installed !== enabled)) {
|
|
208471
|
+
throw new Error("Extension outcome unconfirmed; refresh inventory before retrying");
|
|
208472
|
+
}
|
|
208473
|
+
return { content: [{ type: "text", text: JSON.stringify(data) }] };
|
|
208474
|
+
}
|
|
208450
208475
|
case "rls_status": {
|
|
208451
208476
|
const sql = `SELECT tablename, rowsecurity as rls_enabled FROM pg_tables WHERE schemaname = '${schema}' ORDER BY tablename;`;
|
|
208452
208477
|
const r = await execSql(sql);
|
|
@@ -214499,8 +214524,8 @@ import { mkdir as mkdir3, readFile as readFile3, writeFile as writeFile3 } from
|
|
|
214499
214524
|
import { dirname as dirname6, join as join12, resolve as resolve11 } from "node:path";
|
|
214500
214525
|
|
|
214501
214526
|
// node_modules/@supacloud/compiler/dist/index.js
|
|
214502
|
-
var
|
|
214503
|
-
var
|
|
214527
|
+
var ts7 = __toESM(require_typescript(), 1);
|
|
214528
|
+
var ts8 = __toESM(require_typescript(), 1);
|
|
214504
214529
|
var import_graphql99 = __toESM(require_graphql2(), 1);
|
|
214505
214530
|
import { createHash as createHash42 } from "node:crypto";
|
|
214506
214531
|
import { access, mkdir, rename, unlink, writeFile } from "node:fs/promises";
|
|
@@ -219877,9 +219902,11 @@ var findTransformedDefinitions = (visitedResult) => {
|
|
|
219877
219902
|
};
|
|
219878
219903
|
|
|
219879
219904
|
// node_modules/@supacloud/compiler/dist/index.js
|
|
219880
|
-
var
|
|
219905
|
+
var ts13 = __toESM(require_typescript(), 1);
|
|
219906
|
+
var ts4 = __toESM(require_typescript(), 1);
|
|
219881
219907
|
var ts2 = __toESM(require_typescript(), 1);
|
|
219882
219908
|
var ts = __toESM(require_typescript(), 1);
|
|
219909
|
+
var ts3 = __toESM(require_typescript(), 1);
|
|
219883
219910
|
import { createHash as createHash32 } from "node:crypto";
|
|
219884
219911
|
import { relative as relative22, resolve as resolvePath, sep as sep22 } from "node:path";
|
|
219885
219912
|
import { createHash as createHash22 } from "node:crypto";
|
|
@@ -219887,17 +219914,18 @@ import { existsSync as existsSync9, readFileSync as readFileSync7 } from "node:f
|
|
|
219887
219914
|
import { dirname as dirname4, join as join10, resolve as resolve9 } from "node:path";
|
|
219888
219915
|
import { createHash as createHash6 } from "node:crypto";
|
|
219889
219916
|
import { dirname as dirname22, relative as relative5, sep as sep3 } from "node:path";
|
|
219890
|
-
var
|
|
219917
|
+
var ts6 = __toESM(require_typescript(), 1);
|
|
219918
|
+
var ts5 = __toESM(require_typescript(), 1);
|
|
219891
219919
|
import { access as access2, readFile as readFile2 } from "node:fs/promises";
|
|
219892
219920
|
import { join as join42 } from "node:path";
|
|
219893
219921
|
import { existsSync as existsSync22, readFileSync as readFileSync22 } from "node:fs";
|
|
219894
219922
|
import { dirname as dirname32, join as join32, relative as relative32, resolve as resolve22, sep as sep32 } from "node:path";
|
|
219895
|
-
var ts8 = __toESM(require_typescript(), 1);
|
|
219896
|
-
var ts7 = __toESM(require_typescript(), 1);
|
|
219897
|
-
var ts9 = __toESM(require_typescript(), 1);
|
|
219898
219923
|
var ts10 = __toESM(require_typescript(), 1);
|
|
219924
|
+
var ts9 = __toESM(require_typescript(), 1);
|
|
219925
|
+
var ts11 = __toESM(require_typescript(), 1);
|
|
219926
|
+
var ts12 = __toESM(require_typescript(), 1);
|
|
219899
219927
|
import { existsSync as existsSync52 } from "node:fs";
|
|
219900
|
-
import { join as join82, resolve as
|
|
219928
|
+
import { join as join82, resolve as resolve14 } from "node:path";
|
|
219901
219929
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
219902
219930
|
var __defProp2 = Object.defineProperty;
|
|
219903
219931
|
var __returnValue2 = (v) => v;
|
|
@@ -220249,7 +220277,7 @@ class ModuleGenerator {
|
|
|
220249
220277
|
this.imports = imports;
|
|
220250
220278
|
this.pascal = pascalName(module.name);
|
|
220251
220279
|
if (module.providers.some((provider) => (provider.functionalInjects?.length ?? 0) > 0) || module.controllers.some((controller) => (controller.functionalInjects?.length ?? 0) > 0)) {
|
|
220252
|
-
|
|
220280
|
+
throw new Error("SC2012: Compiled DI requires constructor injection; property inject() is not supported.");
|
|
220253
220281
|
}
|
|
220254
220282
|
}
|
|
220255
220283
|
renderFactories() {
|
|
@@ -220283,6 +220311,7 @@ class ModuleGenerator {
|
|
|
220283
220311
|
lines.push(` jobs: ${this.renderJobs()},`);
|
|
220284
220312
|
if (this.module.aspects && this.module.aspects.length > 0) {
|
|
220285
220313
|
lines.push(` aspects: ${this.renderAspects(this.module.aspects)},`);
|
|
220314
|
+
lines.push(` aspectPipeline: ${this.renderAspectPipeline(this.module.aspects)},`);
|
|
220286
220315
|
}
|
|
220287
220316
|
lines.push(`}`);
|
|
220288
220317
|
return lines.join(`
|
|
@@ -220359,6 +220388,7 @@ class ModuleGenerator {
|
|
|
220359
220388
|
}
|
|
220360
220389
|
if (route.aspects && route.aspects.length > 0) {
|
|
220361
220390
|
fields.push(`aspects: ${this.renderAspects(route.aspects)}`);
|
|
220391
|
+
fields.push(`aspectPipeline: ${this.renderAspectPipeline(route.aspects)}`);
|
|
220362
220392
|
}
|
|
220363
220393
|
const invokerArgs = (route.handlerParams ?? []).map((hp) => {
|
|
220364
220394
|
if (hp.kind === "param") {
|
|
@@ -220439,7 +220469,7 @@ ${indent5(item, 2)}`).join(",")}
|
|
|
220439
220469
|
`idempotency: ${JSON.stringify(command.idempotency)}`,
|
|
220440
220470
|
...command.rpc ? [`rpc: ${JSON.stringify(command.rpc)}`] : [],
|
|
220441
220471
|
...command.standalone ? ["standalone: true"] : [],
|
|
220442
|
-
...command.aspects && command.aspects.length > 0 ? [`aspects: ${this.renderAspects(command.aspects)}`] : []
|
|
220472
|
+
...command.aspects && command.aspects.length > 0 ? [`aspects: ${this.renderAspects(command.aspects)}`, `aspectPipeline: ${this.renderAspectPipeline(command.aspects)}`] : []
|
|
220443
220473
|
];
|
|
220444
220474
|
return `{ ${fields.join(", ")} }`;
|
|
220445
220475
|
}).join(", ")}]`;
|
|
@@ -220472,6 +220502,7 @@ ${indent5(item, 2)}`).join(",")}
|
|
|
220472
220502
|
fields.push(`idempotency: ${JSON.stringify(job.idempotency)}`);
|
|
220473
220503
|
if (job.aspects && job.aspects.length > 0) {
|
|
220474
220504
|
fields.push(`aspects: ${this.renderAspects(job.aspects)}`);
|
|
220505
|
+
fields.push(`aspectPipeline: ${this.renderAspectPipeline(job.aspects)}`);
|
|
220475
220506
|
}
|
|
220476
220507
|
return `{ ${fields.join(", ")}, }`;
|
|
220477
220508
|
}).join(", ")}]`;
|
|
@@ -220479,6 +220510,24 @@ ${indent5(item, 2)}`).join(",")}
|
|
|
220479
220510
|
renderAspects(aspects) {
|
|
220480
220511
|
return `[${aspects.map((aspect) => this.imports.add(aspect.name, aspect.importPath, aspect.importModule)).join(", ")}]`;
|
|
220481
220512
|
}
|
|
220513
|
+
renderAspectPipeline(aspects) {
|
|
220514
|
+
const lines = [
|
|
220515
|
+
`async (context, next, observe) => {`,
|
|
220516
|
+
` const state = { active: true };`,
|
|
220517
|
+
` const step${aspects.length} = compiledAspectNext(next, state);`
|
|
220518
|
+
];
|
|
220519
|
+
for (let index = aspects.length - 1;index >= 0; index--) {
|
|
220520
|
+
const aspect = aspects[index];
|
|
220521
|
+
if (!aspect)
|
|
220522
|
+
continue;
|
|
220523
|
+
const name = this.imports.add(aspect.name, aspect.importPath, aspect.importModule);
|
|
220524
|
+
const stage = JSON.stringify(`aspect[${index}]:${aspect.name}`);
|
|
220525
|
+
lines.push(` const step${index} = compiledAspectNext(() => observeCompiledAspect(observe, ${stage}, () => ${name}(context, step${index + 1})), state);`);
|
|
220526
|
+
}
|
|
220527
|
+
lines.push(` try { return await step0(); } finally { state.active = false; }`, `}`);
|
|
220528
|
+
return lines.join(`
|
|
220529
|
+
`);
|
|
220530
|
+
}
|
|
220482
220531
|
renderServicesFactory() {
|
|
220483
220532
|
return [
|
|
220484
220533
|
`function create${this.pascal}Services(`,
|
|
@@ -220593,7 +220642,7 @@ ${indent5(item, 2)}`).join(",")}
|
|
|
220593
220642
|
const args = provider.deps.map((dep, index) => this.typedDepExpr(dep, kind, this.depOptions(provider, dep), `ConstructorParameters<typeof ${useClass}>[${index}]`)).join(", ");
|
|
220594
220643
|
const local = this.localVar(isMulti ? provider.useClass ?? `${provider.token}Item` : provider.token, kind);
|
|
220595
220644
|
return {
|
|
220596
|
-
constLine: `const ${local} = ${
|
|
220645
|
+
constLine: `const ${local} = new ${useClass}(${args});`,
|
|
220597
220646
|
key,
|
|
220598
220647
|
expr: local
|
|
220599
220648
|
};
|
|
@@ -220629,32 +220678,11 @@ ${indent5(item, 2)}`).join(",")}
|
|
|
220629
220678
|
const key = camelName(controller.className);
|
|
220630
220679
|
const local = this.localVar(controller.className, kind);
|
|
220631
220680
|
return {
|
|
220632
|
-
constLine: `const ${local} = ${
|
|
220681
|
+
constLine: `const ${local} = new ${className}(${args});`,
|
|
220633
220682
|
key,
|
|
220634
220683
|
expr: local
|
|
220635
220684
|
};
|
|
220636
220685
|
}
|
|
220637
|
-
instantiate(className, args, kind, functionalInjects) {
|
|
220638
|
-
if (!functionalInjects || functionalInjects.length === 0) {
|
|
220639
|
-
return `new ${className}(${args})`;
|
|
220640
|
-
}
|
|
220641
|
-
const clauses = functionalInjects.map((entry) => {
|
|
220642
|
-
const token = this.imports.add(entry.expression, entry.importPath, entry.importModule);
|
|
220643
|
-
const value = this.depExpr(entry.token, kind, entry);
|
|
220644
|
-
return `if (token === ${token}) return ${value} as T;`;
|
|
220645
|
-
});
|
|
220646
|
-
const missing = `if (options?.optional) return undefined; throw new Error("Static inject token not available: " + String(token));`;
|
|
220647
|
-
const injector = [
|
|
220648
|
-
`{`,
|
|
220649
|
-
`get<T>(token: unknown, options?: { optional?: boolean; self?: boolean; skipSelf?: boolean; host?: boolean }): T | undefined {`,
|
|
220650
|
-
...clauses,
|
|
220651
|
-
missing,
|
|
220652
|
-
`},`,
|
|
220653
|
-
`}`
|
|
220654
|
-
].join(`
|
|
220655
|
-
`);
|
|
220656
|
-
return `runInInjectionContext(${injector}, () => new ${className}(${args}))`;
|
|
220657
|
-
}
|
|
220658
220686
|
localVar(token, kind) {
|
|
220659
220687
|
const locals = this.locals[kind];
|
|
220660
220688
|
const existing = locals.get(token);
|
|
@@ -221828,6 +221856,7 @@ var INTERFACES = `export interface CompiledRoute {
|
|
|
221828
221856
|
title?: string;
|
|
221829
221857
|
data?: Record<string, unknown>;
|
|
221830
221858
|
aspects?: CompiledAspect[];
|
|
221859
|
+
aspectPipeline?: CompiledAspectPipeline;
|
|
221831
221860
|
invoker?: (
|
|
221832
221861
|
controller: unknown,
|
|
221833
221862
|
request: {
|
|
@@ -221851,6 +221880,7 @@ export interface CompiledCommand {
|
|
|
221851
221880
|
idempotency: "required" | "none";
|
|
221852
221881
|
standalone?: boolean;
|
|
221853
221882
|
aspects?: CompiledAspect[];
|
|
221883
|
+
aspectPipeline?: CompiledAspectPipeline;
|
|
221854
221884
|
}
|
|
221855
221885
|
|
|
221856
221886
|
export interface CompiledJob {
|
|
@@ -221865,6 +221895,7 @@ export interface CompiledJob {
|
|
|
221865
221895
|
maxAttempts?: number;
|
|
221866
221896
|
idempotency?: "required" | "none";
|
|
221867
221897
|
aspects?: CompiledAspect[];
|
|
221898
|
+
aspectPipeline?: CompiledAspectPipeline;
|
|
221868
221899
|
}
|
|
221869
221900
|
|
|
221870
221901
|
export interface CompiledAspectContext {
|
|
@@ -221912,8 +221943,25 @@ export interface CompiledModule {
|
|
|
221912
221943
|
commands: CompiledCommand[];
|
|
221913
221944
|
jobs: CompiledJob[];
|
|
221914
221945
|
aspects?: CompiledAspect[];
|
|
221946
|
+
aspectPipeline?: CompiledAspectPipeline;
|
|
221915
221947
|
}`;
|
|
221916
|
-
var TYPE_GUARDS = `
|
|
221948
|
+
var TYPE_GUARDS = `type CompiledAspectObserver = (stage: string, run: () => unknown | Promise<unknown>) => unknown | Promise<unknown>;
|
|
221949
|
+
type CompiledAspectPipeline = (context: CompiledAspectContext, next: () => unknown | Promise<unknown>, observe?: CompiledAspectObserver) => unknown | Promise<unknown>;
|
|
221950
|
+
|
|
221951
|
+
function compiledAspectNext(next: () => unknown | Promise<unknown>, state: { active: boolean }): () => Promise<unknown> {
|
|
221952
|
+
let called = false;
|
|
221953
|
+
return async () => {
|
|
221954
|
+
if (!state.active) throw new Error("Aspect continuation is closed");
|
|
221955
|
+
if (called) throw new Error("Aspect continuation called multiple times");
|
|
221956
|
+
called = true;
|
|
221957
|
+
return await next();
|
|
221958
|
+
};
|
|
221959
|
+
}
|
|
221960
|
+
function observeCompiledAspect(observe: CompiledAspectObserver | undefined, stage: string, run: () => unknown | Promise<unknown>): unknown | Promise<unknown> {
|
|
221961
|
+
return observe ? observe(stage, run) : run();
|
|
221962
|
+
}
|
|
221963
|
+
|
|
221964
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
221917
221965
|
return typeof value === "object" && value !== null;
|
|
221918
221966
|
}
|
|
221919
221967
|
|
|
@@ -222098,7 +222146,7 @@ function graphqlInputPaths(options) {
|
|
|
222098
222146
|
}
|
|
222099
222147
|
const root = resolve32(options.rootDir);
|
|
222100
222148
|
const schema = resolve32(root, options.graphql.schema);
|
|
222101
|
-
const documents =
|
|
222149
|
+
const documents = ts7.sys.readDirectory(root, [".graphql", ".gql"], ["**/node_modules/**", "**/.git/**", resolve32(options.outDir)], options.graphql.documents ?? ["**/*.graphql", "**/*.gql"]).map((path) => resolve32(path)).filter((path) => path !== schema);
|
|
222102
222150
|
return [schema, ...[...new Set(documents)].sort()];
|
|
222103
222151
|
}
|
|
222104
222152
|
var init_graphql_inputs = __esm2(() => {
|
|
@@ -222114,18 +222162,18 @@ function renderGraphqlValidators(source, operationNames) {
|
|
|
222114
222162
|
noPropertyAccessFromIndexSignature: true,
|
|
222115
222163
|
noFallthroughCasesInSwitch: true,
|
|
222116
222164
|
skipLibCheck: false,
|
|
222117
|
-
target:
|
|
222165
|
+
target: ts8.ScriptTarget.ES2022,
|
|
222118
222166
|
lib: ["lib.es2022.d.ts"],
|
|
222119
222167
|
types: [],
|
|
222120
222168
|
noEmit: true
|
|
222121
222169
|
};
|
|
222122
|
-
const host =
|
|
222170
|
+
const host = ts8.createCompilerHost(options);
|
|
222123
222171
|
const getSourceFile = host.getSourceFile.bind(host);
|
|
222124
|
-
host.getSourceFile = (path, languageVersion, onError, shouldCreateNewSourceFile) => path === fileName ?
|
|
222125
|
-
const program =
|
|
222126
|
-
const diagnostics =
|
|
222172
|
+
host.getSourceFile = (path, languageVersion, onError, shouldCreateNewSourceFile) => path === fileName ? ts8.createSourceFile(path, source, languageVersion, true) : getSourceFile(path, languageVersion, onError, shouldCreateNewSourceFile);
|
|
222173
|
+
const program = ts8.createProgram([fileName], options, host);
|
|
222174
|
+
const diagnostics = ts8.getPreEmitDiagnostics(program);
|
|
222127
222175
|
if (diagnostics.length) {
|
|
222128
|
-
throw new Error(`Generated GraphQL types cannot be validated: ${diagnostics.map((item) =>
|
|
222176
|
+
throw new Error(`Generated GraphQL types cannot be validated: ${diagnostics.map((item) => ts8.flattenDiagnosticMessageText(item.messageText, `
|
|
222129
222177
|
`)).join("; ")}`);
|
|
222130
222178
|
}
|
|
222131
222179
|
const checker = program.getTypeChecker();
|
|
@@ -222155,25 +222203,25 @@ function renderGraphqlValidators(source, operationNames) {
|
|
|
222155
222203
|
return name;
|
|
222156
222204
|
}
|
|
222157
222205
|
function expression(type) {
|
|
222158
|
-
if (type.flags &
|
|
222206
|
+
if (type.flags & ts8.TypeFlags.Any)
|
|
222159
222207
|
return unsupported(type);
|
|
222160
|
-
if (type.flags &
|
|
222208
|
+
if (type.flags & ts8.TypeFlags.Unknown)
|
|
222161
222209
|
return "true";
|
|
222162
|
-
if (type.flags &
|
|
222210
|
+
if (type.flags & ts8.TypeFlags.Never)
|
|
222163
222211
|
return "false";
|
|
222164
|
-
if (type.flags &
|
|
222212
|
+
if (type.flags & ts8.TypeFlags.Null)
|
|
222165
222213
|
return "value === null";
|
|
222166
|
-
if (type.flags &
|
|
222214
|
+
if (type.flags & ts8.TypeFlags.Undefined)
|
|
222167
222215
|
return "value === undefined";
|
|
222168
222216
|
if (type.isStringLiteral() || type.isNumberLiteral())
|
|
222169
222217
|
return `value === ${JSON.stringify(type.value)}`;
|
|
222170
|
-
if (type.flags &
|
|
222218
|
+
if (type.flags & ts8.TypeFlags.BooleanLiteral)
|
|
222171
222219
|
return `value === ${checker.typeToString(type)}`;
|
|
222172
|
-
if (type.flags &
|
|
222220
|
+
if (type.flags & ts8.TypeFlags.String)
|
|
222173
222221
|
return 'typeof value === "string"';
|
|
222174
|
-
if (type.flags &
|
|
222222
|
+
if (type.flags & ts8.TypeFlags.Number)
|
|
222175
222223
|
return 'typeof value === "number" && Number.isFinite(value)';
|
|
222176
|
-
if (type.flags &
|
|
222224
|
+
if (type.flags & ts8.TypeFlags.Boolean)
|
|
222177
222225
|
return 'typeof value === "boolean"';
|
|
222178
222226
|
if (type.isUnion())
|
|
222179
222227
|
return type.types.map((part) => `${reference(part)}(value)`).join(" || ");
|
|
@@ -222182,16 +222230,16 @@ function renderGraphqlValidators(source, operationNames) {
|
|
|
222182
222230
|
if (checker.isTupleType(type))
|
|
222183
222231
|
return unsupported(type);
|
|
222184
222232
|
if (checker.isArrayType(type)) {
|
|
222185
|
-
const item = checker.getIndexTypeOfType(type,
|
|
222233
|
+
const item = checker.getIndexTypeOfType(type, ts8.IndexKind.Number);
|
|
222186
222234
|
if (!item)
|
|
222187
222235
|
return unsupported(type);
|
|
222188
222236
|
return `isGraphqlArray(value) && Array.from(value).every(${reference(item)})`;
|
|
222189
222237
|
}
|
|
222190
|
-
if (type.flags &
|
|
222238
|
+
if (type.flags & ts8.TypeFlags.Object) {
|
|
222191
222239
|
if (type.getCallSignatures().length || type.getConstructSignatures().length)
|
|
222192
222240
|
return unsupported(type);
|
|
222193
222241
|
const indexes = checker.getIndexInfosOfType(type);
|
|
222194
|
-
if (indexes.some((index) => !(index.keyType.flags &
|
|
222242
|
+
if (indexes.some((index) => !(index.keyType.flags & ts8.TypeFlags.String)))
|
|
222195
222243
|
return unsupported(type);
|
|
222196
222244
|
const properties = checker.getPropertiesOfType(type).map((property) => {
|
|
222197
222245
|
const declaration = property.valueDeclaration ?? property.declarations?.[0];
|
|
@@ -222200,7 +222248,7 @@ function renderGraphqlValidators(source, operationNames) {
|
|
|
222200
222248
|
const check = reference(checker.getTypeOfSymbolAtLocation(property, declaration));
|
|
222201
222249
|
const key = JSON.stringify(property.name);
|
|
222202
222250
|
const present = `Object.prototype.hasOwnProperty.call(value, ${key})`;
|
|
222203
|
-
return property.flags &
|
|
222251
|
+
return property.flags & ts8.SymbolFlags.Optional ? `(!${present} || ${check}(value[${key}]))` : `(${present} && ${check}(value[${key}]))`;
|
|
222204
222252
|
});
|
|
222205
222253
|
const indexedValues = indexes.map((index) => `Object.values(value).every(${reference(index.type)})`);
|
|
222206
222254
|
return ["isGraphqlRecord(value)", ...properties, ...indexedValues].join(" && ");
|
|
@@ -222440,6 +222488,11 @@ var init_graphql_schema = __esm2(() => {
|
|
|
222440
222488
|
init_generate();
|
|
222441
222489
|
init_graphql_options();
|
|
222442
222490
|
});
|
|
222491
|
+
var init_database_contracts = __esm2(() => {
|
|
222492
|
+
init_graphql();
|
|
222493
|
+
init_generate();
|
|
222494
|
+
init_graphql_options();
|
|
222495
|
+
});
|
|
222443
222496
|
|
|
222444
222497
|
class TraitCompiler {
|
|
222445
222498
|
handlers;
|
|
@@ -223020,6 +223073,7 @@ var COMPILER_DIAGNOSTIC_CODES = {
|
|
|
223020
223073
|
"missing-token-factory": { code: "SC2009", docsUrl: "https://supacloud.dev/errors/SC2009" },
|
|
223021
223074
|
"provider-type-mismatch": { code: "SC2010", docsUrl: "https://supacloud.dev/errors/SC2010" },
|
|
223022
223075
|
"unsupported-provider-helper": { code: "SC2011", docsUrl: "https://supacloud.dev/errors/SC2011" },
|
|
223076
|
+
"runtime-injection-disallowed": { code: "SC2012", docsUrl: "https://supacloud.dev/errors/SC2012" },
|
|
223023
223077
|
"command-missing-permission": { code: "SC4001", docsUrl: "https://supacloud.dev/errors/SC4001" },
|
|
223024
223078
|
"duplicate-command": { code: "SC4002", docsUrl: "https://supacloud.dev/errors/SC4002" },
|
|
223025
223079
|
"route-command-unresolved": { code: "SC4003", docsUrl: "https://supacloud.dev/errors/SC4003" },
|
|
@@ -223066,6 +223120,20 @@ var COMPILER_DIAGNOSTIC_CODES = {
|
|
|
223066
223120
|
function validateGraph(graph, options = false) {
|
|
223067
223121
|
const strict = typeof options === "boolean" ? options : options.strict ?? false;
|
|
223068
223122
|
const diagnostics = [];
|
|
223123
|
+
for (const module of graph.modules) {
|
|
223124
|
+
for (const owner of [...module.providers, ...module.controllers]) {
|
|
223125
|
+
if (owner.functionalInjects?.length)
|
|
223126
|
+
diagnostics.push({
|
|
223127
|
+
severity: "error",
|
|
223128
|
+
code: "runtime-injection-disallowed",
|
|
223129
|
+
errorCode: "SC2012",
|
|
223130
|
+
docsUrl: "https://supacloud.dev/errors/SC2012",
|
|
223131
|
+
file: owner.file,
|
|
223132
|
+
message: "Property inject() requires runtime token resolution. Compiled applications require constructor injection.",
|
|
223133
|
+
suggestion: "Move injected fields into typed constructor parameters with @Inject(TOKEN) where needed."
|
|
223134
|
+
});
|
|
223135
|
+
}
|
|
223136
|
+
}
|
|
223069
223137
|
let moduleBoundaries;
|
|
223070
223138
|
if (typeof options === "object") {
|
|
223071
223139
|
try {
|
|
@@ -223846,6 +223914,65 @@ function detectOrphanModules(graph) {
|
|
|
223846
223914
|
}
|
|
223847
223915
|
return diagnostics;
|
|
223848
223916
|
}
|
|
223917
|
+
var runtimeApis = new Set([
|
|
223918
|
+
"inject",
|
|
223919
|
+
"createEnvironmentInjector",
|
|
223920
|
+
"runInInjectionContext",
|
|
223921
|
+
"EnvironmentInjector",
|
|
223922
|
+
"bootstrapBun",
|
|
223923
|
+
"runInScope",
|
|
223924
|
+
"runInRequestContext",
|
|
223925
|
+
"runInJobContext",
|
|
223926
|
+
"runInTransactionContext"
|
|
223927
|
+
]);
|
|
223928
|
+
function scanRuntimeDi(source, file) {
|
|
223929
|
+
const diagnostics = [];
|
|
223930
|
+
const namespaces = new Set;
|
|
223931
|
+
const report = (node) => diagnostics.push({
|
|
223932
|
+
severity: "error",
|
|
223933
|
+
code: "runtime-injection-disallowed",
|
|
223934
|
+
errorCode: "SC2012",
|
|
223935
|
+
docsUrl: "https://supacloud.dev/errors/SC2012",
|
|
223936
|
+
file,
|
|
223937
|
+
line: source.getLineAndCharacterOfPosition(node.getStart()).line + 1,
|
|
223938
|
+
message: "Compiled applications cannot import runtime DI. Use explicit constructors and generated scope factories."
|
|
223939
|
+
});
|
|
223940
|
+
for (const statement of source.statements) {
|
|
223941
|
+
if (!(ts3.isImportDeclaration(statement) || ts3.isExportDeclaration(statement)) || !statement.moduleSpecifier || !ts3.isStringLiteral(statement.moduleSpecifier) || !/^@supacloud\/app(?:\/|$)/.test(statement.moduleSpecifier.text))
|
|
223942
|
+
continue;
|
|
223943
|
+
if (ts3.isImportDeclaration(statement)) {
|
|
223944
|
+
if (statement.importClause?.isTypeOnly)
|
|
223945
|
+
continue;
|
|
223946
|
+
const binding = statement.importClause?.namedBindings;
|
|
223947
|
+
if (binding && ts3.isNamespaceImport(binding))
|
|
223948
|
+
namespaces.add(binding.name.text);
|
|
223949
|
+
if (binding && ts3.isNamedImports(binding))
|
|
223950
|
+
for (const item of binding.elements) {
|
|
223951
|
+
if (!item.isTypeOnly && runtimeApis.has((item.propertyName ?? item.name).text))
|
|
223952
|
+
report(item);
|
|
223953
|
+
}
|
|
223954
|
+
} else if (!statement.isTypeOnly) {
|
|
223955
|
+
if (!statement.exportClause)
|
|
223956
|
+
report(statement);
|
|
223957
|
+
else if (ts3.isNamedExports(statement.exportClause))
|
|
223958
|
+
for (const item of statement.exportClause.elements) {
|
|
223959
|
+
if (!item.isTypeOnly && runtimeApis.has((item.propertyName ?? item.name).text))
|
|
223960
|
+
report(item);
|
|
223961
|
+
}
|
|
223962
|
+
}
|
|
223963
|
+
}
|
|
223964
|
+
const visit = (node) => {
|
|
223965
|
+
if (ts3.isPropertyAccessExpression(node) && ts3.isIdentifier(node.expression) && namespaces.has(node.expression.text) && runtimeApis.has(node.name.text))
|
|
223966
|
+
report(node);
|
|
223967
|
+
if (ts3.isElementAccessExpression(node) && ts3.isIdentifier(node.expression) && namespaces.has(node.expression.text) && (!ts3.isStringLiteral(node.argumentExpression) || runtimeApis.has(node.argumentExpression.text)))
|
|
223968
|
+
report(node);
|
|
223969
|
+
if (ts3.isVariableDeclaration(node) && node.initializer && ts3.isIdentifier(node.initializer) && namespaces.has(node.initializer.text))
|
|
223970
|
+
report(node);
|
|
223971
|
+
ts3.forEachChild(node, visit);
|
|
223972
|
+
};
|
|
223973
|
+
visit(source);
|
|
223974
|
+
return diagnostics;
|
|
223975
|
+
}
|
|
223849
223976
|
var DEFAULT_INCLUDE = ["**/*.module.ts", "**/*.ts"];
|
|
223850
223977
|
var ROUTE_DECORATORS = {
|
|
223851
223978
|
Get: "GET",
|
|
@@ -223885,26 +224012,26 @@ function lineOf(node) {
|
|
|
223885
224012
|
return sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1;
|
|
223886
224013
|
}
|
|
223887
224014
|
function variableName(decl) {
|
|
223888
|
-
return
|
|
224015
|
+
return ts4.isIdentifier(decl.name) ? decl.name.text : nodeText(decl.name);
|
|
223889
224016
|
}
|
|
223890
224017
|
function propertyName(name) {
|
|
223891
|
-
if (
|
|
224018
|
+
if (ts4.isIdentifier(name) || ts4.isPrivateIdentifier(name))
|
|
223892
224019
|
return name.text;
|
|
223893
|
-
if (
|
|
224020
|
+
if (ts4.isStringLiteral(name) || ts4.isNumericLiteral(name))
|
|
223894
224021
|
return name.text;
|
|
223895
224022
|
return nodeText(name);
|
|
223896
224023
|
}
|
|
223897
224024
|
function parameterName(param) {
|
|
223898
|
-
return
|
|
224025
|
+
return ts4.isIdentifier(param.name) ? param.name.text : nodeText(param.name);
|
|
223899
224026
|
}
|
|
223900
224027
|
function decoratorsOf(node) {
|
|
223901
|
-
return
|
|
224028
|
+
return ts4.canHaveDecorators(node) ? ts4.getDecorators(node) ?? [] : [];
|
|
223902
224029
|
}
|
|
223903
224030
|
function decoratorArguments(dec) {
|
|
223904
|
-
return
|
|
224031
|
+
return ts4.isCallExpression(dec.expression) ? dec.expression.arguments : [];
|
|
223905
224032
|
}
|
|
223906
224033
|
function hasMethod(cls, name) {
|
|
223907
|
-
return cls.members.some((member) => (
|
|
224034
|
+
return cls.members.some((member) => (ts4.isMethodDeclaration(member) || ts4.isGetAccessorDeclaration(member) || ts4.isSetAccessorDeclaration(member)) && member.name !== undefined && propertyName(member.name) === name);
|
|
223908
224035
|
}
|
|
223909
224036
|
function hasDestroyHook(cls) {
|
|
223910
224037
|
return hasMethod(cls, "onDestroy") || hasMethod(cls, "ngOnDestroy");
|
|
@@ -223914,7 +224041,7 @@ function descendantsOfKind(root, predicate) {
|
|
|
223914
224041
|
const visit = (node) => {
|
|
223915
224042
|
if (predicate(node))
|
|
223916
224043
|
result.push(node);
|
|
223917
|
-
|
|
224044
|
+
ts4.forEachChild(node, visit);
|
|
223918
224045
|
};
|
|
223919
224046
|
visit(root);
|
|
223920
224047
|
return result;
|
|
@@ -223923,7 +224050,7 @@ async function analyzeProject(rootDir, include, cache, changedPaths) {
|
|
|
223923
224050
|
const session = cache?.programSession ?? createIncrementalProgramSession(rootDir);
|
|
223924
224051
|
if (cache)
|
|
223925
224052
|
cache.programSession = session;
|
|
223926
|
-
const rootNames =
|
|
224053
|
+
const rootNames = ts4.sys.readDirectory(rootDir, [".ts", ".tsx"], ["node_modules", "dist"], include ?? DEFAULT_INCLUDE);
|
|
223927
224054
|
const update = session.update(rootNames, changedPaths);
|
|
223928
224055
|
const program = update.program;
|
|
223929
224056
|
const checker = program.getTypeChecker();
|
|
@@ -223947,13 +224074,16 @@ async function analyzeProject(rootDir, include, cache, changedPaths) {
|
|
|
223947
224074
|
nativeTraitFiles.set(trait.file, kinds);
|
|
223948
224075
|
}
|
|
223949
224076
|
for (const sf of sourceFiles) {
|
|
224077
|
+
if (!/\.(?:test|spec)\.[cm]?tsx?$/.test(sf.fileName)) {
|
|
224078
|
+
ctx.diagnostics.push(...scanRuntimeDi(sf, sourcePath(rootDir, sf.fileName)));
|
|
224079
|
+
}
|
|
223950
224080
|
indexFile(sf, ctx);
|
|
223951
224081
|
}
|
|
223952
224082
|
const candidates = [];
|
|
223953
224083
|
for (const sf of sourceFiles) {
|
|
223954
224084
|
const traits = nativeTraitFiles.get(sf.fileName);
|
|
223955
224085
|
if (!cache || traits?.has("module")) {
|
|
223956
|
-
for (const cls of sf.statements.filter(
|
|
224086
|
+
for (const cls of sf.statements.filter(ts4.isClassDeclaration)) {
|
|
223957
224087
|
const moduleDec = findDecorator(cls, "Module");
|
|
223958
224088
|
if (!moduleDec)
|
|
223959
224089
|
continue;
|
|
@@ -223970,14 +224100,14 @@ async function analyzeProject(rootDir, include, cache, changedPaths) {
|
|
|
223970
224100
|
}
|
|
223971
224101
|
}
|
|
223972
224102
|
if (!cache || traits?.has("defineModule") || traits?.has("defineFeatureSlice")) {
|
|
223973
|
-
for (const call of descendantsOfKind(sf,
|
|
224103
|
+
for (const call of descendantsOfKind(sf, ts4.isCallExpression)) {
|
|
223974
224104
|
if (!["defineModule", "defineFeatureSlice"].includes(nodeText(call.expression)))
|
|
223975
224105
|
continue;
|
|
223976
224106
|
const parent = call.parent;
|
|
223977
|
-
if (!parent || !
|
|
224107
|
+
if (!parent || !ts4.isVariableDeclaration(parent))
|
|
223978
224108
|
continue;
|
|
223979
224109
|
const arg = call.arguments[0];
|
|
223980
|
-
if (!arg || !
|
|
224110
|
+
if (!arg || !ts4.isObjectLiteralExpression(arg))
|
|
223981
224111
|
continue;
|
|
223982
224112
|
candidates.push({
|
|
223983
224113
|
node: parent,
|
|
@@ -224121,7 +224251,7 @@ async function analyzeProject(rootDir, include, cache, changedPaths) {
|
|
|
224121
224251
|
const controllerDec = findDecorator(classInfo.decl, "Controller");
|
|
224122
224252
|
if (controllerDec) {
|
|
224123
224253
|
const arg = decoratorArguments(controllerDec)[0];
|
|
224124
|
-
const isStandalone = arg &&
|
|
224254
|
+
const isStandalone = arg && ts4.isObjectLiteralExpression(arg) && booleanProp(arg, "standalone");
|
|
224125
224255
|
if (isStandalone) {
|
|
224126
224256
|
const ctrl = parseController(classInfo.decl, ctx);
|
|
224127
224257
|
if (ctrl)
|
|
@@ -224246,16 +224376,16 @@ function collectModuleSourceClosure(module, ctx) {
|
|
|
224246
224376
|
ownedFiles.add(relativeFile);
|
|
224247
224377
|
for (const statement of sourceFile.statements) {
|
|
224248
224378
|
let moduleName;
|
|
224249
|
-
if (
|
|
224379
|
+
if (ts4.isImportDeclaration(statement) && ts4.isStringLiteral(statement.moduleSpecifier)) {
|
|
224250
224380
|
moduleName = statement.moduleSpecifier.text;
|
|
224251
|
-
} else if (
|
|
224381
|
+
} else if (ts4.isExportDeclaration(statement) && statement.moduleSpecifier && ts4.isStringLiteral(statement.moduleSpecifier)) {
|
|
224252
224382
|
moduleName = statement.moduleSpecifier.text;
|
|
224253
|
-
} else if (
|
|
224383
|
+
} else if (ts4.isImportEqualsDeclaration(statement) && ts4.isExternalModuleReference(statement.moduleReference) && ts4.isStringLiteral(statement.moduleReference.expression)) {
|
|
224254
224384
|
moduleName = statement.moduleReference.expression.text;
|
|
224255
224385
|
}
|
|
224256
224386
|
if (!moduleName || moduleName.startsWith("node:"))
|
|
224257
224387
|
continue;
|
|
224258
|
-
const resolved =
|
|
224388
|
+
const resolved = ts4.resolveModuleName(moduleName, sourceFile.fileName, ctx.program.getCompilerOptions(), ts4.sys).resolvedModule?.resolvedFileName;
|
|
224259
224389
|
if (resolved && isProjectSourcePath(resolved, ctx.rootDir) && !enqueued.has(resolved)) {
|
|
224260
224390
|
enqueued.add(resolved);
|
|
224261
224391
|
queue.push(resolved);
|
|
@@ -224277,15 +224407,15 @@ function isProjectSourceFile(sourceFile, rootDir) {
|
|
|
224277
224407
|
return isProjectSourcePath(sourceFile.fileName, rootDir) && /\.(tsx?|mts|cts)$/.test(sourceFile.fileName);
|
|
224278
224408
|
}
|
|
224279
224409
|
function indexFile(sf, ctx) {
|
|
224280
|
-
for (const cls of sf.statements.filter(
|
|
224410
|
+
for (const cls of sf.statements.filter(ts4.isClassDeclaration)) {
|
|
224281
224411
|
const name = cls.name?.text;
|
|
224282
224412
|
if (name && !ctx.classesByName.has(name)) {
|
|
224283
224413
|
ctx.classesByName.set(name, { name, decl: cls, file: sf.fileName });
|
|
224284
224414
|
}
|
|
224285
224415
|
}
|
|
224286
|
-
for (const statement of sf.statements.filter(
|
|
224416
|
+
for (const statement of sf.statements.filter(ts4.isVariableStatement)) {
|
|
224287
224417
|
for (const decl of statement.declarationList.declarations) {
|
|
224288
|
-
if (
|
|
224418
|
+
if (ts4.isIdentifier(decl.name) && !ctx.variablesByName.has(decl.name.text)) {
|
|
224289
224419
|
ctx.variablesByName.set(decl.name.text, decl);
|
|
224290
224420
|
}
|
|
224291
224421
|
const info = parseTokenVariable(decl, sf.fileName);
|
|
@@ -224297,16 +224427,16 @@ function indexFile(sf, ctx) {
|
|
|
224297
224427
|
}
|
|
224298
224428
|
function parseTokenVariable(decl, file) {
|
|
224299
224429
|
const init = decl.initializer;
|
|
224300
|
-
if (!init || !
|
|
224430
|
+
if (!init || !ts4.isNewExpression(init))
|
|
224301
224431
|
return;
|
|
224302
224432
|
if (nodeText(init.expression) !== "InjectionToken")
|
|
224303
224433
|
return;
|
|
224304
224434
|
const [nameArg, optionsArg] = init.arguments ?? [];
|
|
224305
224435
|
const info = { name: variableName(decl), file, line: lineOf(decl) };
|
|
224306
|
-
if (nameArg &&
|
|
224436
|
+
if (nameArg && ts4.isStringLiteral(nameArg)) {
|
|
224307
224437
|
info.stringName = nameArg.text;
|
|
224308
224438
|
}
|
|
224309
|
-
if (optionsArg &&
|
|
224439
|
+
if (optionsArg && ts4.isObjectLiteralExpression(optionsArg)) {
|
|
224310
224440
|
const scope = stringLiteralProp(optionsArg, "scope");
|
|
224311
224441
|
if (scope && isScope(scope)) {
|
|
224312
224442
|
info.scope = scope;
|
|
@@ -224326,22 +224456,22 @@ function parseModule(candidate, nameByNode, ctx) {
|
|
|
224326
224456
|
const { options, className, file, line } = candidate;
|
|
224327
224457
|
const name = nameByNode.get(candidate.node) ?? className;
|
|
224328
224458
|
const featureSpec = parseFeatureSpec(getProp(options, "spec"), ctx);
|
|
224329
|
-
const tags = arrayProp(options, "tags").map((el) =>
|
|
224459
|
+
const tags = arrayProp(options, "tags").map((el) => ts4.isStringLiteral(el) ? el.text : nodeText(el).replace(/['"]/g, "")).filter(Boolean);
|
|
224330
224460
|
const aspects = parseAspectRefs(getProp(options, "aspects"), ctx, `module ${name}`);
|
|
224331
224461
|
const imports = arrayProp(options, "imports").map((el) => {
|
|
224332
224462
|
const unwrapped = unwrapForwardRef(el);
|
|
224333
|
-
const decl =
|
|
224463
|
+
const decl = ts4.isIdentifier(unwrapped) ? resolveDeclaration(unwrapped, ctx)[0] : undefined;
|
|
224334
224464
|
if (decl) {
|
|
224335
224465
|
const known = nameByNode.get(decl);
|
|
224336
224466
|
if (known)
|
|
224337
224467
|
return known;
|
|
224338
|
-
if (
|
|
224468
|
+
if (ts4.isClassDeclaration(decl)) {
|
|
224339
224469
|
const dec = findDecorator(decl, "Module");
|
|
224340
224470
|
const decOptions = dec && decoratorObjectArg(dec);
|
|
224341
224471
|
const decName = decOptions && stringLiteralProp(decOptions, "name");
|
|
224342
224472
|
return decName ?? decl.name?.text ?? nodeText(el);
|
|
224343
224473
|
}
|
|
224344
|
-
if (
|
|
224474
|
+
if (ts4.isVariableDeclaration(decl))
|
|
224345
224475
|
return variableName(decl);
|
|
224346
224476
|
}
|
|
224347
224477
|
return nodeText(el);
|
|
@@ -224355,7 +224485,7 @@ function parseModule(candidate, nameByNode, ctx) {
|
|
|
224355
224485
|
providers.push(...parsedProviders);
|
|
224356
224486
|
continue;
|
|
224357
224487
|
}
|
|
224358
|
-
if (
|
|
224488
|
+
if (ts4.isCallExpression(el)) {
|
|
224359
224489
|
const helper = nodeText(el.expression).split(".").pop() ?? nodeText(el.expression);
|
|
224360
224490
|
warn(ctx, "unsupported-provider-helper", `无法静态展开 provider helper '${helper}';请改用显式 Provider 或实现编译器支持的 helper`, sourcePath(ctx.rootDir, el.getSourceFile().fileName), lineOf(el));
|
|
224361
224491
|
continue;
|
|
@@ -224365,10 +224495,10 @@ function parseModule(candidate, nameByNode, ctx) {
|
|
|
224365
224495
|
providers.push(provider);
|
|
224366
224496
|
}
|
|
224367
224497
|
for (const el of arrayProp(options, "jobs")) {
|
|
224368
|
-
if (!
|
|
224498
|
+
if (!ts4.isIdentifier(el))
|
|
224369
224499
|
continue;
|
|
224370
224500
|
const decl = resolveDeclaration(el, ctx)[0];
|
|
224371
|
-
if (!decl || !
|
|
224501
|
+
if (!decl || !ts4.isClassDeclaration(decl))
|
|
224372
224502
|
continue;
|
|
224373
224503
|
const className = decl.name?.text ?? el.text;
|
|
224374
224504
|
const registeredProvider = providers.find((provider) => provider.token === className || provider.useClass === className);
|
|
@@ -224405,18 +224535,18 @@ function parseModule(candidate, nameByNode, ctx) {
|
|
|
224405
224535
|
const handlerClasses = [];
|
|
224406
224536
|
const seenHandlers = new Set;
|
|
224407
224537
|
const collectHandler = (expr) => {
|
|
224408
|
-
if (!
|
|
224538
|
+
if (!ts4.isIdentifier(expr))
|
|
224409
224539
|
return;
|
|
224410
224540
|
const decl = resolveDeclaration(expr, ctx)[0];
|
|
224411
|
-
if (decl &&
|
|
224541
|
+
if (decl && ts4.isClassDeclaration(decl) && !seenHandlers.has(decl.name?.text ?? "")) {
|
|
224412
224542
|
seenHandlers.add(decl.name?.text ?? "");
|
|
224413
224543
|
handlerClasses.push(decl);
|
|
224414
224544
|
}
|
|
224415
224545
|
};
|
|
224416
224546
|
for (const el of arrayProp(options, "providers")) {
|
|
224417
|
-
if (
|
|
224547
|
+
if (ts4.isIdentifier(el))
|
|
224418
224548
|
collectHandler(el);
|
|
224419
|
-
if (
|
|
224549
|
+
if (ts4.isObjectLiteralExpression(el)) {
|
|
224420
224550
|
const useClass = getProp(el, "useClass");
|
|
224421
224551
|
if (useClass)
|
|
224422
224552
|
collectHandler(useClass);
|
|
@@ -224516,17 +224646,17 @@ function parseFeatureSpec(input, ctx, seen = new Set) {
|
|
|
224516
224646
|
if (seen.has(input))
|
|
224517
224647
|
return;
|
|
224518
224648
|
seen.add(input);
|
|
224519
|
-
if (
|
|
224520
|
-
const local = input.getSourceFile().statements.flatMap((statement) =>
|
|
224649
|
+
if (ts4.isIdentifier(input)) {
|
|
224650
|
+
const local = input.getSourceFile().statements.flatMap((statement) => ts4.isVariableStatement(statement) ? [...statement.declarationList.declarations] : []);
|
|
224521
224651
|
const resolved = resolveDeclaration(input, ctx)[0];
|
|
224522
|
-
const decl = (resolved &&
|
|
224523
|
-
if (decl &&
|
|
224652
|
+
const decl = (resolved && ts4.isVariableDeclaration(resolved) ? resolved : undefined) ?? ctx.variablesByName.get(input.text) ?? local.find((candidate) => ts4.isIdentifier(candidate.name) && candidate.name.text === input.text) ?? descendantsOfKind(input.getSourceFile(), ts4.isVariableDeclaration).find((candidate) => ts4.isIdentifier(candidate.name) && candidate.name.text === input.text);
|
|
224653
|
+
if (decl && ts4.isVariableDeclaration(decl))
|
|
224524
224654
|
return parseFeatureSpec(decl.initializer, ctx, seen);
|
|
224525
224655
|
}
|
|
224526
|
-
if (
|
|
224656
|
+
if (ts4.isCallExpression(input) && nodeText(input.expression) === "defineFeatureSpec") {
|
|
224527
224657
|
return parseFeatureSpec(input.arguments[0], ctx, seen);
|
|
224528
224658
|
}
|
|
224529
|
-
if (
|
|
224659
|
+
if (ts4.isAsExpression(input) || ts4.isSatisfiesExpression(input) || ts4.isParenthesizedExpression(input)) {
|
|
224530
224660
|
return parseFeatureSpec(input.expression, ctx, seen);
|
|
224531
224661
|
}
|
|
224532
224662
|
const invalid = () => {
|
|
@@ -224539,28 +224669,28 @@ function parseFeatureSpec(input, ctx, seen = new Set) {
|
|
|
224539
224669
|
});
|
|
224540
224670
|
return;
|
|
224541
224671
|
};
|
|
224542
|
-
if (!
|
|
224672
|
+
if (!ts4.isObjectLiteralExpression(input))
|
|
224543
224673
|
return invalid();
|
|
224544
224674
|
const name = stringLiteralProp(input, "name");
|
|
224545
224675
|
const statesExpr = getProp(input, "states");
|
|
224546
224676
|
const transitionObject = getProp(input, "transitions");
|
|
224547
|
-
if (!name || !statesExpr || !
|
|
224677
|
+
if (!name || !statesExpr || !ts4.isArrayLiteralExpression(statesExpr) || statesExpr.elements.some((state) => !ts4.isStringLiteral(state)) || !transitionObject || !ts4.isObjectLiteralExpression(transitionObject) || input.properties.some((property) => !ts4.isPropertyAssignment(property))) {
|
|
224548
224678
|
return invalid();
|
|
224549
224679
|
}
|
|
224550
224680
|
const states = [];
|
|
224551
224681
|
for (const state of statesExpr.elements) {
|
|
224552
|
-
if (!
|
|
224682
|
+
if (!ts4.isStringLiteral(state))
|
|
224553
224683
|
return invalid();
|
|
224554
224684
|
states.push(state.text);
|
|
224555
224685
|
}
|
|
224556
224686
|
const transitions = [];
|
|
224557
224687
|
for (const property of transitionObject.properties) {
|
|
224558
|
-
if (!
|
|
224688
|
+
if (!ts4.isPropertyAssignment(property) || ts4.isComputedPropertyName(property.name) || !ts4.isObjectLiteralExpression(property.initializer))
|
|
224559
224689
|
return invalid();
|
|
224560
224690
|
const options = property.initializer;
|
|
224561
224691
|
const from = stringLiteralProp(options, "from");
|
|
224562
224692
|
const to = stringLiteralProp(options, "to");
|
|
224563
|
-
if (!from || !to || options.properties.some((prop) => !
|
|
224693
|
+
if (!from || !to || options.properties.some((prop) => !ts4.isPropertyAssignment(prop)) || ["permission", "command", "route", "audit"].some((key) => getProp(options, key) && !stringLiteralProp(options, key)) || ["transaction", "idempotency"].some((key) => getProp(options, key) && !commandModeProp(options, key))) {
|
|
224564
224694
|
return invalid();
|
|
224565
224695
|
}
|
|
224566
224696
|
const permission = stringLiteralProp(options, "permission");
|
|
@@ -224587,21 +224717,21 @@ function resolveStaticObjectLiteral(input, ctx, seen = new Set) {
|
|
|
224587
224717
|
if (!input || seen.has(input))
|
|
224588
224718
|
return;
|
|
224589
224719
|
seen.add(input);
|
|
224590
|
-
if (
|
|
224720
|
+
if (ts4.isAsExpression(input) || ts4.isSatisfiesExpression(input) || ts4.isParenthesizedExpression(input)) {
|
|
224591
224721
|
return resolveStaticObjectLiteral(input.expression, ctx, seen);
|
|
224592
224722
|
}
|
|
224593
|
-
if (
|
|
224594
|
-
const declaration = resolveDeclaration(input, ctx).find(
|
|
224723
|
+
if (ts4.isIdentifier(input)) {
|
|
224724
|
+
const declaration = resolveDeclaration(input, ctx).find(ts4.isVariableDeclaration);
|
|
224595
224725
|
return declaration?.initializer ? resolveStaticObjectLiteral(declaration.initializer, ctx, seen) : undefined;
|
|
224596
224726
|
}
|
|
224597
|
-
if (
|
|
224727
|
+
if (ts4.isCallExpression(input)) {
|
|
224598
224728
|
const expressionName = nodeText(input.expression);
|
|
224599
224729
|
if (expressionName === "defineRouteContract" || expressionName.endsWith(".defineRouteContract")) {
|
|
224600
224730
|
return resolveStaticObjectLiteral(input.arguments[0], ctx, seen);
|
|
224601
224731
|
}
|
|
224602
224732
|
return;
|
|
224603
224733
|
}
|
|
224604
|
-
return
|
|
224734
|
+
return ts4.isObjectLiteralExpression(input) ? input : undefined;
|
|
224605
224735
|
}
|
|
224606
224736
|
function commandModeProp(object, name) {
|
|
224607
224737
|
const value = stringLiteralProp(object, name);
|
|
@@ -224636,9 +224766,9 @@ function parseProvider(el, exportsSet, ctx) {
|
|
|
224636
224766
|
const file = sourcePath(ctx.rootDir, el.getSourceFile().fileName);
|
|
224637
224767
|
const line = lineOf(el);
|
|
224638
224768
|
const unwrappedEl = unwrapForwardRef(el);
|
|
224639
|
-
if (
|
|
224769
|
+
if (ts4.isIdentifier(unwrappedEl)) {
|
|
224640
224770
|
const decl = resolveDeclaration(unwrappedEl, ctx)[0];
|
|
224641
|
-
const cls = decl &&
|
|
224771
|
+
const cls = decl && ts4.isClassDeclaration(decl) ? decl : undefined;
|
|
224642
224772
|
const className = cls?.name?.text ?? unwrappedEl.text;
|
|
224643
224773
|
const { deps, optionalDeps, selfDeps, skipSelfDeps, hostDeps, functionalInjects, missing } = cls ? classDeps(cls, ctx) : { deps: [], optionalDeps: [], selfDeps: [], skipSelfDeps: [], hostDeps: [], functionalInjects: [], missing: false };
|
|
224644
224774
|
const injectable = cls ? parseInjectableOptions(cls, ctx) : undefined;
|
|
@@ -224665,7 +224795,7 @@ function parseProvider(el, exportsSet, ctx) {
|
|
|
224665
224795
|
...cls ? { importPath: modulePath(ctx.rootDir, cls.getSourceFile().fileName) } : {}
|
|
224666
224796
|
};
|
|
224667
224797
|
}
|
|
224668
|
-
if (!
|
|
224798
|
+
if (!ts4.isObjectLiteralExpression(el))
|
|
224669
224799
|
return;
|
|
224670
224800
|
const provideExpr = getProp(el, "provide");
|
|
224671
224801
|
if (!provideExpr)
|
|
@@ -224680,8 +224810,8 @@ function parseProvider(el, exportsSet, ctx) {
|
|
|
224680
224810
|
const useExistingExpr = getProp(el, "useExisting");
|
|
224681
224811
|
if (useClassExpr) {
|
|
224682
224812
|
const unwrappedClass = unwrapForwardRef(useClassExpr);
|
|
224683
|
-
const decl =
|
|
224684
|
-
const cls = decl &&
|
|
224813
|
+
const decl = ts4.isIdentifier(unwrappedClass) ? resolveDeclaration(unwrappedClass, ctx)[0] : undefined;
|
|
224814
|
+
const cls = decl && ts4.isClassDeclaration(decl) ? decl : undefined;
|
|
224685
224815
|
const useClass = cls?.name?.text ?? nodeText(unwrappedClass);
|
|
224686
224816
|
let deps = explicitDeps;
|
|
224687
224817
|
let optionalDeps = [];
|
|
@@ -224737,7 +224867,7 @@ function parseProvider(el, exportsSet, ctx) {
|
|
|
224737
224867
|
}
|
|
224738
224868
|
if (useValueExpr) {
|
|
224739
224869
|
validateProviderCompatibility(provideExpr, useValueExpr, "value", token, ctx, file, line);
|
|
224740
|
-
const importPath =
|
|
224870
|
+
const importPath = ts4.isIdentifier(useValueExpr) ? importPathOf(useValueExpr, ctx) : undefined;
|
|
224741
224871
|
return {
|
|
224742
224872
|
token,
|
|
224743
224873
|
tokenKind,
|
|
@@ -224753,12 +224883,12 @@ function parseProvider(el, exportsSet, ctx) {
|
|
|
224753
224883
|
};
|
|
224754
224884
|
}
|
|
224755
224885
|
if (useFactoryExpr) {
|
|
224756
|
-
const factoryName =
|
|
224886
|
+
const factoryName = ts4.isIdentifier(useFactoryExpr) ? (() => {
|
|
224757
224887
|
const decl = resolveDeclaration(useFactoryExpr, ctx)[0];
|
|
224758
|
-
return decl && (
|
|
224888
|
+
return decl && (ts4.isFunctionDeclaration(decl) || ts4.isVariableDeclaration(decl)) ? (ts4.isFunctionDeclaration(decl) ? decl.name?.text : variableName(decl)) ?? useFactoryExpr.text : useFactoryExpr.text;
|
|
224759
224889
|
})() : nodeText(useFactoryExpr);
|
|
224760
224890
|
validateProviderCompatibility(provideExpr, useFactoryExpr, "factory", token, ctx, file, line);
|
|
224761
|
-
const importPath =
|
|
224891
|
+
const importPath = ts4.isIdentifier(useFactoryExpr) ? importPathOf(useFactoryExpr, ctx) : undefined;
|
|
224762
224892
|
return {
|
|
224763
224893
|
token,
|
|
224764
224894
|
tokenKind,
|
|
@@ -224794,20 +224924,20 @@ function parseProvider(el, exportsSet, ctx) {
|
|
|
224794
224924
|
function expandProviderExpressions(expressions, ctx, seen = new Set) {
|
|
224795
224925
|
const result = [];
|
|
224796
224926
|
for (const expression of expressions) {
|
|
224797
|
-
if (
|
|
224927
|
+
if (ts4.isSpreadElement(expression)) {
|
|
224798
224928
|
result.push(...expandProviderExpressions([expression.expression], ctx, seen));
|
|
224799
224929
|
continue;
|
|
224800
224930
|
}
|
|
224801
|
-
if (
|
|
224931
|
+
if (ts4.isIdentifier(expression)) {
|
|
224802
224932
|
const declaration = resolveDeclaration(expression, ctx)[0];
|
|
224803
|
-
if (declaration &&
|
|
224933
|
+
if (declaration && ts4.isVariableDeclaration(declaration) && declaration.initializer) {
|
|
224804
224934
|
const key = `${declaration.getSourceFile().fileName}:${declaration.pos}`;
|
|
224805
224935
|
if (seen.has(key))
|
|
224806
224936
|
continue;
|
|
224807
224937
|
const initializer = declaration.initializer;
|
|
224808
|
-
if (
|
|
224938
|
+
if (ts4.isCallExpression(initializer) && isProviderHelper(initializer, "makeEnvironmentProviders")) {
|
|
224809
224939
|
const nested = initializer.arguments[0];
|
|
224810
|
-
if (nested &&
|
|
224940
|
+
if (nested && ts4.isArrayLiteralExpression(nested)) {
|
|
224811
224941
|
seen.add(key);
|
|
224812
224942
|
result.push(...expandProviderExpressions([...nested.elements], ctx, seen));
|
|
224813
224943
|
seen.delete(key);
|
|
@@ -224816,9 +224946,9 @@ function expandProviderExpressions(expressions, ctx, seen = new Set) {
|
|
|
224816
224946
|
}
|
|
224817
224947
|
}
|
|
224818
224948
|
}
|
|
224819
|
-
if (
|
|
224949
|
+
if (ts4.isCallExpression(expression) && isProviderHelper(expression, "makeEnvironmentProviders")) {
|
|
224820
224950
|
const nested = expression.arguments[0];
|
|
224821
|
-
if (nested &&
|
|
224951
|
+
if (nested && ts4.isArrayLiteralExpression(nested)) {
|
|
224822
224952
|
result.push(...expandProviderExpressions([...nested.elements], ctx, seen));
|
|
224823
224953
|
continue;
|
|
224824
224954
|
}
|
|
@@ -224831,7 +224961,7 @@ function isProviderHelper(expression, name) {
|
|
|
224831
224961
|
return nodeText(expression.expression).split(".").pop() === name;
|
|
224832
224962
|
}
|
|
224833
224963
|
function parseFunctionalProvider(expression, exportsSet, ctx) {
|
|
224834
|
-
if (!
|
|
224964
|
+
if (!ts4.isCallExpression(expression))
|
|
224835
224965
|
return;
|
|
224836
224966
|
const helper = nodeText(expression.expression).split(".").pop();
|
|
224837
224967
|
const args = expression.arguments;
|
|
@@ -224844,7 +224974,7 @@ function parseFunctionalProvider(expression, exportsSet, ctx) {
|
|
|
224844
224974
|
return [];
|
|
224845
224975
|
const { name: token, kind: tokenKind } = tokenNameOf(tokenExpr, ctx);
|
|
224846
224976
|
validateProviderCompatibility(tokenExpr, valueExpr, "value", token, ctx, file, line);
|
|
224847
|
-
const importPath =
|
|
224977
|
+
const importPath = ts4.isIdentifier(valueExpr) ? importPathOf(valueExpr, ctx) : undefined;
|
|
224848
224978
|
return [{
|
|
224849
224979
|
token,
|
|
224850
224980
|
tokenKind,
|
|
@@ -224863,7 +224993,7 @@ function parseFunctionalProvider(expression, exportsSet, ctx) {
|
|
|
224863
224993
|
if (!initializer)
|
|
224864
224994
|
return [];
|
|
224865
224995
|
const token = helper === "provideAppInitializer" ? "APP_INITIALIZER" : "ENVIRONMENT_INITIALIZER";
|
|
224866
|
-
const importPath =
|
|
224996
|
+
const importPath = ts4.isIdentifier(initializer) ? importPathOf(initializer, ctx) : undefined;
|
|
224867
224997
|
return [{
|
|
224868
224998
|
token,
|
|
224869
224999
|
tokenKind: "injection-token",
|
|
@@ -224882,7 +225012,7 @@ function parseFunctionalProvider(expression, exportsSet, ctx) {
|
|
|
224882
225012
|
const providers = [];
|
|
224883
225013
|
const routes = args[0];
|
|
224884
225014
|
if (routes) {
|
|
224885
|
-
const importPath =
|
|
225015
|
+
const importPath = ts4.isIdentifier(routes) ? importPathOf(routes, ctx) : undefined;
|
|
224886
225016
|
providers.push({
|
|
224887
225017
|
token: "ROUTE_CONFIG",
|
|
224888
225018
|
tokenKind: "injection-token",
|
|
@@ -224897,7 +225027,7 @@ function parseFunctionalProvider(expression, exportsSet, ctx) {
|
|
|
224897
225027
|
});
|
|
224898
225028
|
}
|
|
224899
225029
|
for (const feature of args.slice(1)) {
|
|
224900
|
-
if (!
|
|
225030
|
+
if (!ts4.isCallExpression(feature))
|
|
224901
225031
|
continue;
|
|
224902
225032
|
const featureName = nodeText(feature.expression).split(".").pop();
|
|
224903
225033
|
if (featureName === "withRouterConfig" && feature.arguments[0]) {
|
|
@@ -224914,8 +225044,8 @@ function parseFunctionalProvider(expression, exportsSet, ctx) {
|
|
|
224914
225044
|
});
|
|
224915
225045
|
} else if (featureName === "withTitleStrategy" && feature.arguments[0]) {
|
|
224916
225046
|
const strategy = feature.arguments[0];
|
|
224917
|
-
const isClass =
|
|
224918
|
-
const importPath =
|
|
225047
|
+
const isClass = ts4.isIdentifier(strategy) && Boolean(resolveDeclaration(strategy, ctx).find((declaration) => ts4.isClassDeclaration(declaration)));
|
|
225048
|
+
const importPath = ts4.isIdentifier(strategy) ? importPathOf(strategy, ctx) : undefined;
|
|
224919
225049
|
providers.push({
|
|
224920
225050
|
token: "TITLE_STRATEGY",
|
|
224921
225051
|
tokenKind: "injection-token",
|
|
@@ -224947,14 +225077,14 @@ function parseFunctionalProvider(expression, exportsSet, ctx) {
|
|
|
224947
225077
|
importModule: "@supacloud/app"
|
|
224948
225078
|
}];
|
|
224949
225079
|
for (const feature of args) {
|
|
224950
|
-
if (!
|
|
225080
|
+
if (!ts4.isCallExpression(feature))
|
|
224951
225081
|
continue;
|
|
224952
225082
|
const featureName = nodeText(feature.expression).split(".").pop();
|
|
224953
225083
|
if (featureName === "withInterceptors") {
|
|
224954
225084
|
for (const interceptorArg of feature.arguments) {
|
|
224955
|
-
const values =
|
|
225085
|
+
const values = ts4.isArrayLiteralExpression(interceptorArg) ? [...interceptorArg.elements] : [interceptorArg];
|
|
224956
225086
|
for (const value of values) {
|
|
224957
|
-
const importPath =
|
|
225087
|
+
const importPath = ts4.isIdentifier(value) ? importPathOf(value, ctx) : undefined;
|
|
224958
225088
|
providers.push({
|
|
224959
225089
|
token: "HTTP_INTERCEPTORS",
|
|
224960
225090
|
tokenKind: "injection-token",
|
|
@@ -225001,9 +225131,9 @@ function providerTokenValueType(expr, ctx) {
|
|
|
225001
225131
|
const typeArguments = typeArgumentsOf(type, ctx);
|
|
225002
225132
|
if (typeArguments.length > 0)
|
|
225003
225133
|
return typeArguments[0];
|
|
225004
|
-
if (
|
|
225134
|
+
if (ts4.isIdentifier(expr)) {
|
|
225005
225135
|
const declaration = resolveDeclaration(expr, ctx)[0];
|
|
225006
|
-
if (declaration &&
|
|
225136
|
+
if (declaration && ts4.isClassDeclaration(declaration)) {
|
|
225007
225137
|
return declaredClassType(declaration, ctx);
|
|
225008
225138
|
}
|
|
225009
225139
|
}
|
|
@@ -225011,9 +225141,9 @@ function providerTokenValueType(expr, ctx) {
|
|
|
225011
225141
|
}
|
|
225012
225142
|
function providerImplementationType(expr, kind, ctx) {
|
|
225013
225143
|
if (kind === "class" || kind === "existing") {
|
|
225014
|
-
if (
|
|
225144
|
+
if (ts4.isIdentifier(expr)) {
|
|
225015
225145
|
const declaration = resolveDeclaration(expr, ctx)[0];
|
|
225016
|
-
if (declaration &&
|
|
225146
|
+
if (declaration && ts4.isClassDeclaration(declaration)) {
|
|
225017
225147
|
return declaredClassType(declaration, ctx);
|
|
225018
225148
|
}
|
|
225019
225149
|
}
|
|
@@ -225023,7 +225153,7 @@ function providerImplementationType(expr, kind, ctx) {
|
|
|
225023
225153
|
}
|
|
225024
225154
|
if (kind === "factory") {
|
|
225025
225155
|
const type = ctx.checker.getTypeAtLocation(expr);
|
|
225026
|
-
const signature = ctx.checker.getSignaturesOfType(type,
|
|
225156
|
+
const signature = ctx.checker.getSignaturesOfType(type, ts4.SignatureKind.Call)[0];
|
|
225027
225157
|
return signature?.getReturnType();
|
|
225028
225158
|
}
|
|
225029
225159
|
return ctx.checker.getTypeAtLocation(expr);
|
|
@@ -225042,16 +225172,16 @@ function isTypeReference(type) {
|
|
|
225042
225172
|
return "target" in type;
|
|
225043
225173
|
}
|
|
225044
225174
|
function isUnknownOrAny(type) {
|
|
225045
|
-
return (type.flags & (
|
|
225175
|
+
return (type.flags & (ts4.TypeFlags.Any | ts4.TypeFlags.Unknown)) !== 0;
|
|
225046
225176
|
}
|
|
225047
225177
|
function parseController(input, ctx) {
|
|
225048
225178
|
let decl;
|
|
225049
|
-
if (
|
|
225179
|
+
if (ts4.isClassDeclaration(input)) {
|
|
225050
225180
|
decl = input;
|
|
225051
225181
|
} else {
|
|
225052
225182
|
const unwrapped = unwrapForwardRef(input);
|
|
225053
|
-
const resolved =
|
|
225054
|
-
if (resolved &&
|
|
225183
|
+
const resolved = ts4.isIdentifier(unwrapped) ? resolveDeclaration(unwrapped, ctx)[0] : undefined;
|
|
225184
|
+
if (resolved && ts4.isClassDeclaration(resolved)) {
|
|
225055
225185
|
decl = resolved;
|
|
225056
225186
|
}
|
|
225057
225187
|
}
|
|
@@ -225064,9 +225194,9 @@ function parseController(input, ctx) {
|
|
|
225064
225194
|
let standalone;
|
|
225065
225195
|
const pathArg = decoratorArguments(controllerDec)[0];
|
|
225066
225196
|
if (pathArg) {
|
|
225067
|
-
if (
|
|
225197
|
+
if (ts4.isStringLiteral(pathArg)) {
|
|
225068
225198
|
path = pathArg.text;
|
|
225069
|
-
} else if (
|
|
225199
|
+
} else if (ts4.isObjectLiteralExpression(pathArg)) {
|
|
225070
225200
|
const p = stringLiteralProp(pathArg, "path");
|
|
225071
225201
|
if (p)
|
|
225072
225202
|
path = p;
|
|
@@ -225089,7 +225219,7 @@ function parseController(input, ctx) {
|
|
|
225089
225219
|
}
|
|
225090
225220
|
}
|
|
225091
225221
|
}
|
|
225092
|
-
for (const method of decl.members.filter(
|
|
225222
|
+
for (const method of decl.members.filter(ts4.isMethodDeclaration)) {
|
|
225093
225223
|
for (const dec of decoratorsOf(method)) {
|
|
225094
225224
|
const name = decoratorName2(dec);
|
|
225095
225225
|
const httpMethod = name ? ROUTE_DECORATORS[name] : undefined;
|
|
@@ -225097,7 +225227,7 @@ function parseController(input, ctx) {
|
|
|
225097
225227
|
continue;
|
|
225098
225228
|
const args = decoratorArguments(dec);
|
|
225099
225229
|
const pathArg = args[0];
|
|
225100
|
-
const routePath = pathArg &&
|
|
225230
|
+
const routePath = pathArg && ts4.isStringLiteral(pathArg) ? pathArg.text : "/";
|
|
225101
225231
|
const route = {
|
|
225102
225232
|
method: httpMethod,
|
|
225103
225233
|
path: routePath,
|
|
@@ -225168,12 +225298,12 @@ function parseController(input, ctx) {
|
|
|
225168
225298
|
} else if (dName === "Headers") {
|
|
225169
225299
|
hasBindingDecorator = true;
|
|
225170
225300
|
const argument = dArgs[0];
|
|
225171
|
-
const bindingName = argument !== undefined &&
|
|
225301
|
+
const bindingName = argument !== undefined && ts4.isStringLiteral(argument) ? argument.text : undefined;
|
|
225172
225302
|
paramNode = { name: pName, kind: "headers", ...bindingName === undefined ? {} : { bindingName } };
|
|
225173
225303
|
} else if (dName === "Cookie") {
|
|
225174
225304
|
hasBindingDecorator = true;
|
|
225175
225305
|
const argument = dArgs[0];
|
|
225176
|
-
const bindingName = argument !== undefined &&
|
|
225306
|
+
const bindingName = argument !== undefined && ts4.isStringLiteral(argument) ? argument.text : undefined;
|
|
225177
225307
|
paramNode = { name: pName, kind: "cookie", ...bindingName === undefined ? {} : { bindingName } };
|
|
225178
225308
|
}
|
|
225179
225309
|
}
|
|
@@ -225235,20 +225365,20 @@ function parseController(input, ctx) {
|
|
|
225235
225365
|
}
|
|
225236
225366
|
} else if (dName === "Title") {
|
|
225237
225367
|
const tArg = mArgs[0];
|
|
225238
|
-
if (tArg &&
|
|
225368
|
+
if (tArg && ts4.isStringLiteral(tArg)) {
|
|
225239
225369
|
route.title = tArg.text;
|
|
225240
225370
|
}
|
|
225241
225371
|
} else if (dName === "Data") {
|
|
225242
225372
|
const dArg = mArgs[0];
|
|
225243
|
-
if (dArg &&
|
|
225373
|
+
if (dArg && ts4.isObjectLiteralExpression(dArg)) {
|
|
225244
225374
|
route.data = { ...route.data, ...parseObjectLiteralValues(dArg) };
|
|
225245
225375
|
}
|
|
225246
225376
|
} else if (dName === "Resolve") {
|
|
225247
225377
|
const rArg = mArgs[0];
|
|
225248
|
-
if (rArg &&
|
|
225378
|
+
if (rArg && ts4.isObjectLiteralExpression(rArg)) {
|
|
225249
225379
|
const resolvers = route.resolvers ?? {};
|
|
225250
225380
|
for (const prop of rArg.properties) {
|
|
225251
|
-
if (
|
|
225381
|
+
if (ts4.isPropertyAssignment(prop)) {
|
|
225252
225382
|
const rName = propertyName(prop.name);
|
|
225253
225383
|
const init = prop.initializer;
|
|
225254
225384
|
if (init)
|
|
@@ -225279,7 +225409,7 @@ function parseController(input, ctx) {
|
|
|
225279
225409
|
});
|
|
225280
225410
|
}
|
|
225281
225411
|
const contract = getProp(optionsObject, "contract");
|
|
225282
|
-
if (contract &&
|
|
225412
|
+
if (contract && ts4.isObjectLiteralExpression(contract)) {
|
|
225283
225413
|
route.contract = {};
|
|
225284
225414
|
for (const field of ["body", "response", "evidence"]) {
|
|
225285
225415
|
const value = stringLiteralProp(contract, field);
|
|
@@ -225297,15 +225427,15 @@ function parseController(input, ctx) {
|
|
|
225297
225427
|
}
|
|
225298
225428
|
for (const field of ["body", "params", "query", "headers", "cookie", "response"]) {
|
|
225299
225429
|
const schemaExpr = getProp(optionsObject, field);
|
|
225300
|
-
if (schemaExpr &&
|
|
225430
|
+
if (schemaExpr && ts4.isIdentifier(schemaExpr)) {
|
|
225301
225431
|
route[field] = nodeText(schemaExpr);
|
|
225302
225432
|
const importPath = importPathOf(schemaExpr, ctx);
|
|
225303
225433
|
if (importPath)
|
|
225304
225434
|
schemaImports[schemaExpr.text] = importPath;
|
|
225305
225435
|
const declaration = resolveDeclaration(schemaExpr, ctx)[0];
|
|
225306
225436
|
const typeName = ctx.checker.typeToString(ctx.checker.getTypeAtLocation(schemaExpr));
|
|
225307
|
-
const initializer = declaration &&
|
|
225308
|
-
const opaque = /\bT(?:Unknown|Any)\b/.test(typeName) || initializer &&
|
|
225437
|
+
const initializer = declaration && ts4.isVariableDeclaration(declaration) ? declaration.initializer : undefined;
|
|
225438
|
+
const opaque = /\bT(?:Unknown|Any)\b/.test(typeName) || initializer && ts4.isCallExpression(initializer) && ts4.isPropertyAccessExpression(initializer.expression) && ["Unknown", "Any"].includes(initializer.expression.name.text);
|
|
225309
225439
|
(route.schemaKinds ??= {})[field] = opaque ? "opaque" : "declared";
|
|
225310
225440
|
}
|
|
225311
225441
|
}
|
|
@@ -225314,7 +225444,7 @@ function parseController(input, ctx) {
|
|
|
225314
225444
|
const responses = {};
|
|
225315
225445
|
const selectors = new Map;
|
|
225316
225446
|
for (const property of responsesObject.properties) {
|
|
225317
|
-
if (!
|
|
225447
|
+
if (!ts4.isPropertyAssignment(property) || ts4.isComputedPropertyName(property.name))
|
|
225318
225448
|
continue;
|
|
225319
225449
|
const status = propertyName(property.name);
|
|
225320
225450
|
if (!isRouteResponseSelector(status)) {
|
|
@@ -225346,7 +225476,7 @@ function parseController(input, ctx) {
|
|
|
225346
225476
|
}
|
|
225347
225477
|
selectors.set(canonical, status);
|
|
225348
225478
|
const schemaExpr = property.initializer;
|
|
225349
|
-
if (!
|
|
225479
|
+
if (!ts4.isIdentifier(schemaExpr)) {
|
|
225350
225480
|
ctx.diagnostics.push({
|
|
225351
225481
|
severity: "error",
|
|
225352
225482
|
code: "invalid-route-response-map",
|
|
@@ -225361,8 +225491,8 @@ function parseController(input, ctx) {
|
|
|
225361
225491
|
schemaImports[schemaExpr.text] = importPath;
|
|
225362
225492
|
const declaration = resolveDeclaration(schemaExpr, ctx)[0];
|
|
225363
225493
|
const typeName = ctx.checker.typeToString(ctx.checker.getTypeAtLocation(schemaExpr));
|
|
225364
|
-
const initializer = declaration &&
|
|
225365
|
-
const opaque = /\bT(?:Unknown|Any)\b/.test(typeName) || initializer &&
|
|
225494
|
+
const initializer = declaration && ts4.isVariableDeclaration(declaration) ? declaration.initializer : undefined;
|
|
225495
|
+
const opaque = /\bT(?:Unknown|Any)\b/.test(typeName) || initializer && ts4.isCallExpression(initializer) && ts4.isPropertyAccessExpression(initializer.expression) && ["Unknown", "Any"].includes(initializer.expression.name.text);
|
|
225366
225496
|
const previousKind = route.schemaKinds?.response;
|
|
225367
225497
|
(route.schemaKinds ??= {}).response = opaque || previousKind === "opaque" ? "opaque" : "declared";
|
|
225368
225498
|
}
|
|
@@ -225370,18 +225500,18 @@ function parseController(input, ctx) {
|
|
|
225370
225500
|
route.responses = responses;
|
|
225371
225501
|
}
|
|
225372
225502
|
const commandExpr = getProp(optionsObject, "command");
|
|
225373
|
-
if (commandExpr &&
|
|
225503
|
+
if (commandExpr && ts4.isIdentifier(commandExpr)) {
|
|
225374
225504
|
const commandDecl = resolveDeclaration(commandExpr, ctx)[0];
|
|
225375
|
-
route.command = commandDecl &&
|
|
225505
|
+
route.command = commandDecl && ts4.isClassDeclaration(commandDecl) ? commandDecl.name?.text ?? commandExpr.text : commandExpr.text;
|
|
225376
225506
|
}
|
|
225377
225507
|
const guardsExpr = getProp(optionsObject, "guards");
|
|
225378
|
-
if (guardsExpr &&
|
|
225508
|
+
if (guardsExpr && ts4.isArrayLiteralExpression(guardsExpr)) {
|
|
225379
225509
|
for (const el of guardsExpr.elements) {
|
|
225380
225510
|
routeGuards.push(tokenText(el, ctx));
|
|
225381
225511
|
}
|
|
225382
225512
|
}
|
|
225383
225513
|
const canMatchExpr = getProp(optionsObject, "canMatch");
|
|
225384
|
-
if (canMatchExpr &&
|
|
225514
|
+
if (canMatchExpr && ts4.isArrayLiteralExpression(canMatchExpr)) {
|
|
225385
225515
|
const canMatchList = [];
|
|
225386
225516
|
for (const el of canMatchExpr.elements) {
|
|
225387
225517
|
canMatchList.push(tokenText(el, ctx));
|
|
@@ -225391,16 +225521,16 @@ function parseController(input, ctx) {
|
|
|
225391
225521
|
}
|
|
225392
225522
|
}
|
|
225393
225523
|
const canDeactivateExpr = getProp(optionsObject, "canDeactivate");
|
|
225394
|
-
if (canDeactivateExpr &&
|
|
225524
|
+
if (canDeactivateExpr && ts4.isArrayLiteralExpression(canDeactivateExpr)) {
|
|
225395
225525
|
for (const el of canDeactivateExpr.elements) {
|
|
225396
225526
|
routeCanDeactivate.push(tokenText(el, ctx));
|
|
225397
225527
|
}
|
|
225398
225528
|
}
|
|
225399
225529
|
const resolversExpr = getProp(optionsObject, "resolvers");
|
|
225400
|
-
if (resolversExpr &&
|
|
225530
|
+
if (resolversExpr && ts4.isObjectLiteralExpression(resolversExpr)) {
|
|
225401
225531
|
const resolvers = {};
|
|
225402
225532
|
for (const prop of resolversExpr.properties) {
|
|
225403
|
-
if (
|
|
225533
|
+
if (ts4.isPropertyAssignment(prop)) {
|
|
225404
225534
|
const rName = propertyName(prop.name);
|
|
225405
225535
|
const init = prop.initializer;
|
|
225406
225536
|
if (init)
|
|
@@ -225412,22 +225542,22 @@ function parseController(input, ctx) {
|
|
|
225412
225542
|
}
|
|
225413
225543
|
}
|
|
225414
225544
|
const redirectToExpr = getProp(optionsObject, "redirectTo");
|
|
225415
|
-
if (redirectToExpr &&
|
|
225545
|
+
if (redirectToExpr && ts4.isStringLiteral(redirectToExpr)) {
|
|
225416
225546
|
route.redirectTo = redirectToExpr.text;
|
|
225417
225547
|
}
|
|
225418
225548
|
const pathMatchExpr = getProp(optionsObject, "pathMatch");
|
|
225419
|
-
if (pathMatchExpr &&
|
|
225549
|
+
if (pathMatchExpr && ts4.isStringLiteral(pathMatchExpr)) {
|
|
225420
225550
|
const val = pathMatchExpr.text;
|
|
225421
225551
|
if (val === "full" || val === "prefix") {
|
|
225422
225552
|
route.pathMatch = val;
|
|
225423
225553
|
}
|
|
225424
225554
|
}
|
|
225425
225555
|
const titleExpr = getProp(optionsObject, "title");
|
|
225426
|
-
if (titleExpr &&
|
|
225556
|
+
if (titleExpr && ts4.isStringLiteral(titleExpr)) {
|
|
225427
225557
|
route.title = titleExpr.text;
|
|
225428
225558
|
}
|
|
225429
225559
|
const dataExpr = getProp(optionsObject, "data");
|
|
225430
|
-
if (dataExpr &&
|
|
225560
|
+
if (dataExpr && ts4.isObjectLiteralExpression(dataExpr)) {
|
|
225431
225561
|
route.data = { ...route.data, ...parseObjectLiteralValues(dataExpr) };
|
|
225432
225562
|
}
|
|
225433
225563
|
const aspects = parseAspectRefs(getProp(optionsObject, "aspects"), ctx, `route ${httpMethod} ${routePath}`);
|
|
@@ -225482,7 +225612,7 @@ function parseJobOptions(meta, owner, ctx) {
|
|
|
225482
225612
|
const expression = getProp(meta, field);
|
|
225483
225613
|
if (!expression)
|
|
225484
225614
|
continue;
|
|
225485
|
-
if (!
|
|
225615
|
+
if (!ts4.isIdentifier(expression)) {
|
|
225486
225616
|
jobOptionError(ctx, "invalid-job-schema", `${owner} 的 ${field} schema 必须是可静态解析的标识符引用,不能使用内联调用或动态表达式`, expression, "SC4019", `将 schema 提取为命名导出,例如 ${field}: ${field === "input" ? "JobInput" : "JobOutput"}。`);
|
|
225487
225617
|
continue;
|
|
225488
225618
|
}
|
|
@@ -225506,7 +225636,7 @@ function parseJobEnum(meta, field, allowed, owner, ctx, code, errorCode) {
|
|
|
225506
225636
|
const expression = getProp(meta, field);
|
|
225507
225637
|
if (!expression)
|
|
225508
225638
|
return;
|
|
225509
|
-
if (!
|
|
225639
|
+
if (!ts4.isStringLiteral(expression) || !allowed.includes(expression.text)) {
|
|
225510
225640
|
jobOptionError(ctx, code, `${owner} 的 ${field} 必须是 ${allowed.map((value) => JSON.stringify(value)).join(" 或 ")} 字符串字面量`, expression, errorCode);
|
|
225511
225641
|
return;
|
|
225512
225642
|
}
|
|
@@ -225516,7 +225646,7 @@ function parseJobInteger(meta, field, min, max, owner, ctx, code, errorCode) {
|
|
|
225516
225646
|
const expression = getProp(meta, field);
|
|
225517
225647
|
if (!expression)
|
|
225518
225648
|
return;
|
|
225519
|
-
const value =
|
|
225649
|
+
const value = ts4.isNumericLiteral(expression) ? Number(expression.text) : Number.NaN;
|
|
225520
225650
|
if (!Number.isSafeInteger(value) || value < min || value > max) {
|
|
225521
225651
|
jobOptionError(ctx, code, `${owner} 的 ${field} 必须是 ${min} 到 ${max} 之间的安全整数`, expression, errorCode);
|
|
225522
225652
|
return;
|
|
@@ -225537,8 +225667,8 @@ function jobOptionError(ctx, code, message, node, errorCode, suggestion) {
|
|
|
225537
225667
|
}
|
|
225538
225668
|
function jobSchemaKind(identifier, declaration, ctx) {
|
|
225539
225669
|
const typeName = ctx.checker.typeToString(ctx.checker.getTypeAtLocation(identifier));
|
|
225540
|
-
const initializer =
|
|
225541
|
-
const opaque = /\bT(?:Unknown|Any)\b/.test(typeName) || initializer &&
|
|
225670
|
+
const initializer = ts4.isVariableDeclaration(declaration) ? declaration.initializer : undefined;
|
|
225671
|
+
const opaque = /\bT(?:Unknown|Any)\b/.test(typeName) || initializer && ts4.isCallExpression(initializer) && ts4.isPropertyAccessExpression(initializer.expression) && ["Unknown", "Any"].includes(initializer.expression.name.text);
|
|
225542
225672
|
return opaque ? "opaque" : "declared";
|
|
225543
225673
|
}
|
|
225544
225674
|
function checkedRpc(meta, ctx) {
|
|
@@ -225560,7 +225690,7 @@ function checkedRpc(meta, ctx) {
|
|
|
225560
225690
|
}
|
|
225561
225691
|
function classDeps(cls, ctx) {
|
|
225562
225692
|
const injectable = parseInjectableOptions(cls, ctx);
|
|
225563
|
-
const ctor = cls.members.find(
|
|
225693
|
+
const ctor = cls.members.find(ts4.isConstructorDeclaration);
|
|
225564
225694
|
const deps = injectable?.deps ? [...injectable.deps] : [];
|
|
225565
225695
|
const optionalDeps = [];
|
|
225566
225696
|
const selfDeps = [];
|
|
@@ -225594,23 +225724,23 @@ function classDeps(cls, ctx) {
|
|
|
225594
225724
|
}
|
|
225595
225725
|
});
|
|
225596
225726
|
}
|
|
225597
|
-
for (const prop of cls.members.filter(
|
|
225727
|
+
for (const prop of cls.members.filter(ts4.isPropertyDeclaration)) {
|
|
225598
225728
|
const init = prop.initializer;
|
|
225599
|
-
if (init &&
|
|
225729
|
+
if (init && ts4.isCallExpression(init)) {
|
|
225600
225730
|
const callName = nodeText(init.expression).split(".").pop();
|
|
225601
225731
|
if (callName === "inject") {
|
|
225602
225732
|
const [tokenArg, optionsArg] = init.arguments;
|
|
225603
225733
|
if (tokenArg) {
|
|
225604
225734
|
const tokenName = tokenText(tokenArg, ctx);
|
|
225605
225735
|
const unwrappedToken = unwrapForwardRef(tokenArg);
|
|
225606
|
-
const known =
|
|
225736
|
+
const known = ts4.isStringLiteral(unwrappedToken) || ts4.isIdentifier(unwrappedToken) && (ctx.tokensByName.has(tokenName) || ctx.classesByName.has(tokenName));
|
|
225607
225737
|
if (!known) {
|
|
225608
225738
|
missing = true;
|
|
225609
225739
|
continue;
|
|
225610
225740
|
}
|
|
225611
225741
|
if (!deps.includes(tokenName))
|
|
225612
225742
|
deps.push(tokenName);
|
|
225613
|
-
const options = optionsArg &&
|
|
225743
|
+
const options = optionsArg && ts4.isObjectLiteralExpression(optionsArg) ? {
|
|
225614
225744
|
optional: booleanProp(optionsArg, "optional") ?? false,
|
|
225615
225745
|
self: booleanProp(optionsArg, "self") ?? false,
|
|
225616
225746
|
skipSelf: booleanProp(optionsArg, "skipSelf") ?? false,
|
|
@@ -225625,9 +225755,9 @@ function classDeps(cls, ctx) {
|
|
|
225625
225755
|
if (options.host && !hostDeps.includes(tokenName))
|
|
225626
225756
|
hostDeps.push(tokenName);
|
|
225627
225757
|
if (!functionalInjects.some((entry) => entry.token === tokenName)) {
|
|
225628
|
-
const declaration =
|
|
225758
|
+
const declaration = ts4.isIdentifier(unwrappedToken) ? resolveDeclaration(unwrappedToken, ctx)[0] : undefined;
|
|
225629
225759
|
const localFile = declaration && isProjectSourcePath(declaration.getSourceFile().fileName, ctx.rootDir) ? declaration.getSourceFile().fileName : undefined;
|
|
225630
|
-
const importModule = declaration && !localFile &&
|
|
225760
|
+
const importModule = declaration && !localFile && ts4.isIdentifier(unwrappedToken) ? importModuleOf(unwrappedToken, ctx) : undefined;
|
|
225631
225761
|
functionalInjects.push({
|
|
225632
225762
|
token: tokenName,
|
|
225633
225763
|
expression: nodeText(unwrappedToken),
|
|
@@ -225671,7 +225801,7 @@ function parseInjectableOptions(cls, ctx) {
|
|
|
225671
225801
|
}
|
|
225672
225802
|
function parseInjectParams(cls, ctx) {
|
|
225673
225803
|
const result = new Map;
|
|
225674
|
-
const ctor = cls.members.find(
|
|
225804
|
+
const ctor = cls.members.find(ts4.isConstructorDeclaration);
|
|
225675
225805
|
if (!ctor)
|
|
225676
225806
|
return result;
|
|
225677
225807
|
ctor.parameters.forEach((param, index) => {
|
|
@@ -225687,7 +225817,7 @@ function parseInjectParams(cls, ctx) {
|
|
|
225687
225817
|
}
|
|
225688
225818
|
function parseOptionalParams(cls) {
|
|
225689
225819
|
const result = new Set;
|
|
225690
|
-
const ctor = cls.members.find(
|
|
225820
|
+
const ctor = cls.members.find(ts4.isConstructorDeclaration);
|
|
225691
225821
|
if (!ctor)
|
|
225692
225822
|
return result;
|
|
225693
225823
|
ctor.parameters.forEach((param, index) => {
|
|
@@ -225702,7 +225832,7 @@ function parseOptionalParams(cls) {
|
|
|
225702
225832
|
}
|
|
225703
225833
|
function parseModifierParams(cls, modifierName) {
|
|
225704
225834
|
const result = new Set;
|
|
225705
|
-
const ctor = cls.members.find(
|
|
225835
|
+
const ctor = cls.members.find(ts4.isConstructorDeclaration);
|
|
225706
225836
|
if (!ctor)
|
|
225707
225837
|
return result;
|
|
225708
225838
|
ctor.parameters.forEach((param, index) => {
|
|
@@ -225714,13 +225844,13 @@ function parseModifierParams(cls, modifierName) {
|
|
|
225714
225844
|
return result;
|
|
225715
225845
|
}
|
|
225716
225846
|
function unwrapForwardRef(expr) {
|
|
225717
|
-
if (
|
|
225847
|
+
if (ts4.isCallExpression(expr)) {
|
|
225718
225848
|
const exprText = nodeText(expr.expression);
|
|
225719
225849
|
if (exprText === "forwardRef" || exprText.endsWith(".forwardRef")) {
|
|
225720
225850
|
const arg = expr.arguments[0];
|
|
225721
|
-
if (arg && (
|
|
225851
|
+
if (arg && (ts4.isArrowFunction(arg) || ts4.isFunctionExpression(arg))) {
|
|
225722
225852
|
const body = arg.body;
|
|
225723
|
-
if (body &&
|
|
225853
|
+
if (body && ts4.isExpression(body)) {
|
|
225724
225854
|
return unwrapForwardRef(body);
|
|
225725
225855
|
}
|
|
225726
225856
|
}
|
|
@@ -225730,13 +225860,13 @@ function unwrapForwardRef(expr) {
|
|
|
225730
225860
|
}
|
|
225731
225861
|
function tokenText(expr, ctx) {
|
|
225732
225862
|
const unwrapped = unwrapForwardRef(expr);
|
|
225733
|
-
if (
|
|
225863
|
+
if (ts4.isStringLiteral(unwrapped))
|
|
225734
225864
|
return unwrapped.text;
|
|
225735
|
-
if (
|
|
225865
|
+
if (ts4.isIdentifier(unwrapped)) {
|
|
225736
225866
|
const decl = resolveDeclaration(unwrapped, ctx)[0];
|
|
225737
|
-
if (decl &&
|
|
225867
|
+
if (decl && ts4.isClassDeclaration(decl))
|
|
225738
225868
|
return decl.name?.text ?? unwrapped.text;
|
|
225739
|
-
if (decl &&
|
|
225869
|
+
if (decl && ts4.isVariableDeclaration(decl))
|
|
225740
225870
|
return variableName(decl);
|
|
225741
225871
|
}
|
|
225742
225872
|
return nodeText(unwrapped);
|
|
@@ -225756,12 +225886,12 @@ function resolveScope(input, ctx) {
|
|
|
225756
225886
|
}
|
|
225757
225887
|
function tokenNameOf(expr, ctx) {
|
|
225758
225888
|
const unwrapped = unwrapForwardRef(expr);
|
|
225759
|
-
if (
|
|
225889
|
+
if (ts4.isIdentifier(unwrapped)) {
|
|
225760
225890
|
const decl = resolveDeclaration(unwrapped, ctx)[0];
|
|
225761
|
-
if (decl &&
|
|
225891
|
+
if (decl && ts4.isClassDeclaration(decl)) {
|
|
225762
225892
|
return { name: decl.name?.text ?? nodeText(expr), kind: "class" };
|
|
225763
225893
|
}
|
|
225764
|
-
if (decl &&
|
|
225894
|
+
if (decl && ts4.isVariableDeclaration(decl)) {
|
|
225765
225895
|
const name = variableName(decl);
|
|
225766
225896
|
return { name, kind: ctx.tokensByName.has(name) ? "injection-token" : "class" };
|
|
225767
225897
|
}
|
|
@@ -225777,10 +225907,10 @@ function resolveDeclaration(id, ctx) {
|
|
|
225777
225907
|
return [];
|
|
225778
225908
|
let declarations = symbol.declarations ?? [];
|
|
225779
225909
|
for (let guard = 0;guard < 4; guard += 1) {
|
|
225780
|
-
const isAlias = declarations.some((d) =>
|
|
225910
|
+
const isAlias = declarations.some((d) => ts4.isImportSpecifier(d) || ts4.isImportClause(d) || ts4.isNamespaceImport(d));
|
|
225781
225911
|
if (!isAlias)
|
|
225782
225912
|
break;
|
|
225783
|
-
if (!(symbol.flags &
|
|
225913
|
+
if (!(symbol.flags & ts4.SymbolFlags.Alias))
|
|
225784
225914
|
break;
|
|
225785
225915
|
const aliased = ctx.checker.getAliasedSymbol(symbol);
|
|
225786
225916
|
symbol = aliased;
|
|
@@ -225800,9 +225930,9 @@ function importModuleOf(id, ctx) {
|
|
|
225800
225930
|
for (const declaration of declarations) {
|
|
225801
225931
|
let current = declaration;
|
|
225802
225932
|
while (current) {
|
|
225803
|
-
if (
|
|
225933
|
+
if (ts4.isImportDeclaration(current)) {
|
|
225804
225934
|
const moduleSpecifier = current.moduleSpecifier;
|
|
225805
|
-
return
|
|
225935
|
+
return ts4.isStringLiteral(moduleSpecifier) ? moduleSpecifier.text : undefined;
|
|
225806
225936
|
}
|
|
225807
225937
|
current = current.parent;
|
|
225808
225938
|
}
|
|
@@ -225814,27 +225944,27 @@ function findDecorator(cls, name) {
|
|
|
225814
225944
|
}
|
|
225815
225945
|
function decoratorName2(dec) {
|
|
225816
225946
|
const expr = dec.expression;
|
|
225817
|
-
if (
|
|
225947
|
+
if (ts4.isCallExpression(expr)) {
|
|
225818
225948
|
return nodeText(expr.expression).split(".").pop();
|
|
225819
225949
|
}
|
|
225820
|
-
if (
|
|
225950
|
+
if (ts4.isIdentifier(expr))
|
|
225821
225951
|
return expr.text;
|
|
225822
225952
|
return;
|
|
225823
225953
|
}
|
|
225824
225954
|
function decoratorObjectArg(dec) {
|
|
225825
225955
|
const expr = dec.expression;
|
|
225826
|
-
if (!
|
|
225956
|
+
if (!ts4.isCallExpression(expr))
|
|
225827
225957
|
return;
|
|
225828
225958
|
const arg = expr.arguments[0];
|
|
225829
|
-
return arg &&
|
|
225959
|
+
return arg && ts4.isObjectLiteralExpression(arg) ? arg : undefined;
|
|
225830
225960
|
}
|
|
225831
225961
|
function getProp(obj, name) {
|
|
225832
|
-
const prop = obj.properties.find((item) => (
|
|
225962
|
+
const prop = obj.properties.find((item) => (ts4.isPropertyAssignment(item) || ts4.isShorthandPropertyAssignment(item)) && propertyName(item.name) === name);
|
|
225833
225963
|
if (!prop)
|
|
225834
225964
|
return;
|
|
225835
|
-
if (
|
|
225965
|
+
if (ts4.isPropertyAssignment(prop))
|
|
225836
225966
|
return prop.initializer;
|
|
225837
|
-
if (
|
|
225967
|
+
if (ts4.isShorthandPropertyAssignment(prop))
|
|
225838
225968
|
return prop.name;
|
|
225839
225969
|
return;
|
|
225840
225970
|
}
|
|
@@ -225842,10 +225972,10 @@ function toCompilerDiagnostic(diagnostic, rootDir) {
|
|
|
225842
225972
|
const file = diagnostic.file;
|
|
225843
225973
|
const position = file && diagnostic.start !== undefined ? file.getLineAndCharacterOfPosition(diagnostic.start) : undefined;
|
|
225844
225974
|
return {
|
|
225845
|
-
severity: diagnostic.category ===
|
|
225975
|
+
severity: diagnostic.category === ts4.DiagnosticCategory.Error ? "error" : "warn",
|
|
225846
225976
|
code: `typescript-${diagnostic.code}`,
|
|
225847
225977
|
errorCode: `TS${diagnostic.code}`,
|
|
225848
|
-
message:
|
|
225978
|
+
message: ts4.flattenDiagnosticMessageText(diagnostic.messageText, `
|
|
225849
225979
|
`),
|
|
225850
225980
|
...file ? { file: sourcePath(rootDir, file.fileName) } : {},
|
|
225851
225981
|
...position ? { line: position.line + 1 } : {}
|
|
@@ -225853,16 +225983,16 @@ function toCompilerDiagnostic(diagnostic, rootDir) {
|
|
|
225853
225983
|
}
|
|
225854
225984
|
function stringLiteralProp(obj, name) {
|
|
225855
225985
|
const expr = getProp(obj, name);
|
|
225856
|
-
return expr &&
|
|
225986
|
+
return expr && ts4.isStringLiteral(expr) ? expr.text : undefined;
|
|
225857
225987
|
}
|
|
225858
225988
|
function arrayProp(obj, name) {
|
|
225859
225989
|
const expr = getProp(obj, name);
|
|
225860
|
-
return expr &&
|
|
225990
|
+
return expr && ts4.isArrayLiteralExpression(expr) ? [...expr.elements] : [];
|
|
225861
225991
|
}
|
|
225862
225992
|
function parseAspectRefs(expression, ctx, owner) {
|
|
225863
225993
|
if (!expression)
|
|
225864
225994
|
return [];
|
|
225865
|
-
if (!
|
|
225995
|
+
if (!ts4.isArrayLiteralExpression(expression)) {
|
|
225866
225996
|
ctx.diagnostics.push({
|
|
225867
225997
|
severity: "error",
|
|
225868
225998
|
code: "dynamic-aspect-reference",
|
|
@@ -225877,7 +226007,7 @@ function parseAspectRefs(expression, ctx, owner) {
|
|
|
225877
226007
|
}
|
|
225878
226008
|
const refs = [];
|
|
225879
226009
|
for (const element of expression.elements) {
|
|
225880
|
-
if (
|
|
226010
|
+
if (ts4.isSpreadElement(element) || !ts4.isIdentifier(element)) {
|
|
225881
226011
|
ctx.diagnostics.push({
|
|
225882
226012
|
severity: "error",
|
|
225883
226013
|
code: "dynamic-aspect-reference",
|
|
@@ -225890,7 +226020,7 @@ function parseAspectRefs(expression, ctx, owner) {
|
|
|
225890
226020
|
});
|
|
225891
226021
|
continue;
|
|
225892
226022
|
}
|
|
225893
|
-
const declaration = resolveDeclaration(element, ctx).find((candidate) =>
|
|
226023
|
+
const declaration = resolveDeclaration(element, ctx).find((candidate) => ts4.isFunctionDeclaration(candidate) || ts4.isVariableDeclaration(candidate) && candidate.initializer !== undefined && (ts4.isArrowFunction(candidate.initializer) || ts4.isFunctionExpression(candidate.initializer)));
|
|
225894
226024
|
if (!declaration) {
|
|
225895
226025
|
ctx.diagnostics.push({
|
|
225896
226026
|
severity: "error",
|
|
@@ -225904,7 +226034,7 @@ function parseAspectRefs(expression, ctx, owner) {
|
|
|
225904
226034
|
});
|
|
225905
226035
|
continue;
|
|
225906
226036
|
}
|
|
225907
|
-
const name =
|
|
226037
|
+
const name = ts4.isFunctionDeclaration(declaration) ? declaration.name?.text : ts4.isVariableDeclaration(declaration) ? variableName(declaration) : undefined;
|
|
225908
226038
|
if (!name)
|
|
225909
226039
|
continue;
|
|
225910
226040
|
const declaredFile = declaration.getSourceFile().fileName;
|
|
@@ -225924,9 +226054,9 @@ function booleanProp(obj, name) {
|
|
|
225924
226054
|
const expr = getProp(obj, name);
|
|
225925
226055
|
if (!expr)
|
|
225926
226056
|
return;
|
|
225927
|
-
if (expr.kind ===
|
|
226057
|
+
if (expr.kind === ts4.SyntaxKind.TrueKeyword)
|
|
225928
226058
|
return true;
|
|
225929
|
-
if (expr.kind ===
|
|
226059
|
+
if (expr.kind === ts4.SyntaxKind.FalseKeyword)
|
|
225930
226060
|
return false;
|
|
225931
226061
|
return;
|
|
225932
226062
|
}
|
|
@@ -225940,15 +226070,15 @@ function parseBindingOptions(args, defaultName) {
|
|
|
225940
226070
|
let defaultValue;
|
|
225941
226071
|
const first = args[0];
|
|
225942
226072
|
const second = args[1];
|
|
225943
|
-
if (first &&
|
|
226073
|
+
if (first && ts4.isStringLiteral(first)) {
|
|
225944
226074
|
name = first.text;
|
|
225945
|
-
} else if (first &&
|
|
226075
|
+
} else if (first && ts4.isObjectLiteralExpression(first)) {
|
|
225946
226076
|
const nameProp = getProp(first, "name");
|
|
225947
|
-
if (nameProp &&
|
|
226077
|
+
if (nameProp && ts4.isStringLiteral(nameProp)) {
|
|
225948
226078
|
name = nameProp.text;
|
|
225949
226079
|
}
|
|
225950
226080
|
const trProp = getProp(first, "transform");
|
|
225951
|
-
if (trProp &&
|
|
226081
|
+
if (trProp && ts4.isStringLiteral(trProp)) {
|
|
225952
226082
|
const val = trProp.text;
|
|
225953
226083
|
if (val === "number" || val === "boolean" || val === "string") {
|
|
225954
226084
|
transform = val;
|
|
@@ -225959,9 +226089,9 @@ function parseBindingOptions(args, defaultName) {
|
|
|
225959
226089
|
defaultValue = parseLiteralValue(defProp);
|
|
225960
226090
|
}
|
|
225961
226091
|
}
|
|
225962
|
-
if (second &&
|
|
226092
|
+
if (second && ts4.isObjectLiteralExpression(second)) {
|
|
225963
226093
|
const trProp = getProp(second, "transform");
|
|
225964
|
-
if (trProp &&
|
|
226094
|
+
if (trProp && ts4.isStringLiteral(trProp)) {
|
|
225965
226095
|
const val = trProp.text;
|
|
225966
226096
|
if (val === "number" || val === "boolean" || val === "string") {
|
|
225967
226097
|
transform = val;
|
|
@@ -225975,18 +226105,18 @@ function parseBindingOptions(args, defaultName) {
|
|
|
225975
226105
|
return { name, ...transform ? { transform } : {}, default: defaultValue };
|
|
225976
226106
|
}
|
|
225977
226107
|
function parseLiteralValue(node) {
|
|
225978
|
-
if (
|
|
226108
|
+
if (ts4.isStringLiteral(node))
|
|
225979
226109
|
return node.text;
|
|
225980
|
-
if (
|
|
226110
|
+
if (ts4.isNumericLiteral(node))
|
|
225981
226111
|
return Number(node.text);
|
|
225982
|
-
if (node.kind ===
|
|
226112
|
+
if (node.kind === ts4.SyntaxKind.TrueKeyword)
|
|
225983
226113
|
return true;
|
|
225984
|
-
if (node.kind ===
|
|
226114
|
+
if (node.kind === ts4.SyntaxKind.FalseKeyword)
|
|
225985
226115
|
return false;
|
|
225986
|
-
if (
|
|
226116
|
+
if (ts4.isArrayLiteralExpression(node)) {
|
|
225987
226117
|
return node.elements.map(parseLiteralValue);
|
|
225988
226118
|
}
|
|
225989
|
-
if (
|
|
226119
|
+
if (ts4.isObjectLiteralExpression(node)) {
|
|
225990
226120
|
return parseObjectLiteralValues(node);
|
|
225991
226121
|
}
|
|
225992
226122
|
return;
|
|
@@ -225994,7 +226124,7 @@ function parseLiteralValue(node) {
|
|
|
225994
226124
|
function parseObjectLiteralValues(obj) {
|
|
225995
226125
|
const result = {};
|
|
225996
226126
|
for (const prop of obj.properties) {
|
|
225997
|
-
if (
|
|
226127
|
+
if (ts4.isPropertyAssignment(prop)) {
|
|
225998
226128
|
const name = propertyName(prop.name);
|
|
225999
226129
|
const init = prop.initializer;
|
|
226000
226130
|
if (init) {
|
|
@@ -226020,6 +226150,44 @@ function warn(ctx, code, message, file, line) {
|
|
|
226020
226150
|
});
|
|
226021
226151
|
}
|
|
226022
226152
|
init_generate();
|
|
226153
|
+
var SQL_SAFETY_DIAGNOSTIC_CODES = {
|
|
226154
|
+
"sql-result-assertion": { errorCode: "SC6007", docsUrl: "https://supacloud.dev/errors/SC6007" },
|
|
226155
|
+
"sql-raw-dynamic": { errorCode: "SC6008", docsUrl: "https://supacloud.dev/errors/SC6008" }
|
|
226156
|
+
};
|
|
226157
|
+
function scanDrizzleSql(sourceFile, checker, file, strict) {
|
|
226158
|
+
const diagnostics = [];
|
|
226159
|
+
const importedSql = (expression) => {
|
|
226160
|
+
const symbol = checker.getSymbolAtLocation(ts5.isPropertyAccessExpression(expression) ? expression.name : expression);
|
|
226161
|
+
if (!symbol)
|
|
226162
|
+
return false;
|
|
226163
|
+
const target = symbol.flags & ts5.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
226164
|
+
return target.name === "sql" && (target.declarations ?? []).some((declaration) => /(?:^|\/)node_modules\/drizzle-orm\//.test(declaration.getSourceFile().fileName.replaceAll("\\", "/")));
|
|
226165
|
+
};
|
|
226166
|
+
const report = (code, node, message) => {
|
|
226167
|
+
diagnostics.push({
|
|
226168
|
+
severity: strict ? "error" : "warn",
|
|
226169
|
+
code,
|
|
226170
|
+
...SQL_SAFETY_DIAGNOSTIC_CODES[code],
|
|
226171
|
+
message,
|
|
226172
|
+
file,
|
|
226173
|
+
line: sourceFile.getLineAndCharacterOfPosition(node.getStart()).line + 1
|
|
226174
|
+
});
|
|
226175
|
+
};
|
|
226176
|
+
const visit = (node) => {
|
|
226177
|
+
if (ts5.isTaggedTemplateExpression(node) && importedSql(node.tag) && node.typeArguments?.some((type) => type.kind !== ts5.SyntaxKind.UnknownKeyword)) {
|
|
226178
|
+
report("sql-result-assertion", node, "Drizzle sql<T> asserts a result type without checking SQL or decoding rows. Use sql<unknown> and a schema decoder at the result boundary.");
|
|
226179
|
+
}
|
|
226180
|
+
if (ts5.isCallExpression(node) && ts5.isPropertyAccessExpression(node.expression) && node.expression.name.text === "raw" && importedSql(node.expression.expression)) {
|
|
226181
|
+
const argument = node.arguments[0];
|
|
226182
|
+
if (!argument || !ts5.isStringLiteral(argument) && !ts5.isNoSubstitutionTemplateLiteral(argument)) {
|
|
226183
|
+
report("sql-raw-dynamic", node, "Dynamic sql.raw bypasses parameter binding. Interpolate values with sql templates; keep reviewed static DDL in migrations.");
|
|
226184
|
+
}
|
|
226185
|
+
}
|
|
226186
|
+
ts5.forEachChild(node, visit);
|
|
226187
|
+
};
|
|
226188
|
+
visit(sourceFile);
|
|
226189
|
+
return diagnostics;
|
|
226190
|
+
}
|
|
226023
226191
|
var DEFAULT_EXCLUDES = [
|
|
226024
226192
|
"**/*.test.ts",
|
|
226025
226193
|
"**/*.spec.ts",
|
|
@@ -226032,6 +226200,7 @@ var DEFAULT_EXCLUDES = [
|
|
|
226032
226200
|
"**/*.d.ts"
|
|
226033
226201
|
];
|
|
226034
226202
|
var TYPE_SAFETY_DIAGNOSTIC_CODES = {
|
|
226203
|
+
...SQL_SAFETY_DIAGNOSTIC_CODES,
|
|
226035
226204
|
"generated-any": { errorCode: "SC6001", docsUrl: "https://supacloud.dev/errors/SC6001" },
|
|
226036
226205
|
"source-any": { errorCode: "SC6002", docsUrl: "https://supacloud.dev/errors/SC6002" },
|
|
226037
226206
|
"source-type-assertion": { errorCode: "SC6003", docsUrl: "https://supacloud.dev/errors/SC6003" },
|
|
@@ -226044,7 +226213,7 @@ function scanGeneratedArtifacts(artifacts, strict = true) {
|
|
|
226044
226213
|
for (const [file, content] of Object.entries(artifacts)) {
|
|
226045
226214
|
if (content === undefined)
|
|
226046
226215
|
continue;
|
|
226047
|
-
const sourceFile =
|
|
226216
|
+
const sourceFile = ts6.createSourceFile(file, content, ts6.ScriptTarget.Latest, true, ts6.ScriptKind.TS);
|
|
226048
226217
|
for (const node of descendantsOfKind2(sourceFile, isAnyKeyword)) {
|
|
226049
226218
|
diagnostics.push(makeDiagnostic("generated-any", `生成产物 ${file} 包含 any;严格生成模式要求使用 unknown、具体接口或泛型约束。`, sourceFile, node, strict));
|
|
226050
226219
|
}
|
|
@@ -226053,30 +226222,30 @@ function scanGeneratedArtifacts(artifacts, strict = true) {
|
|
|
226053
226222
|
}
|
|
226054
226223
|
function scanProductionSource(options) {
|
|
226055
226224
|
const rootDir = resolve22(options.rootDir);
|
|
226056
|
-
const configPath =
|
|
226225
|
+
const configPath = ts6.findConfigFile(rootDir, ts6.sys.fileExists) ?? join32(rootDir, "tsconfig.json");
|
|
226057
226226
|
const projectConfig = existsSync22(configPath) ? readProjectConfig2(configPath) : {
|
|
226058
226227
|
options: {
|
|
226059
226228
|
strict: true,
|
|
226060
226229
|
skipLibCheck: true,
|
|
226061
|
-
target:
|
|
226062
|
-
module:
|
|
226063
|
-
moduleResolution:
|
|
226230
|
+
target: ts6.ScriptTarget.ES2022,
|
|
226231
|
+
module: ts6.ModuleKind.ESNext,
|
|
226232
|
+
moduleResolution: ts6.ModuleResolutionKind.Bundler
|
|
226064
226233
|
},
|
|
226065
226234
|
errors: []
|
|
226066
226235
|
};
|
|
226067
226236
|
const include = options.include ?? ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts"];
|
|
226068
|
-
const rootNames =
|
|
226237
|
+
const rootNames = ts6.sys.readDirectory(rootDir, [".ts", ".tsx", ".mts", ".cts"], ["node_modules", "dist"], include).filter((file) => isProductionSourcePath(rootDir, file, [...DEFAULT_EXCLUDES, ...options.exclude ?? []]));
|
|
226069
226238
|
const compilerOptions = { ...projectConfig.options, noEmit: true };
|
|
226070
|
-
const host =
|
|
226239
|
+
const host = ts6.createCompilerHost(compilerOptions);
|
|
226071
226240
|
host.getCurrentDirectory = () => dirname32(configPath);
|
|
226072
|
-
const program =
|
|
226241
|
+
const program = ts6.createProgram(rootNames, compilerOptions, host);
|
|
226073
226242
|
const outDir = options.outDir ? normalizeRelative(rootDir, options.outDir) : undefined;
|
|
226074
226243
|
const excludes = [...DEFAULT_EXCLUDES, ...options.exclude ?? []];
|
|
226075
226244
|
const sourceFiles = program.getSourceFiles().filter((sourceFile) => isProductionSource(rootDir, sourceFile, excludes, outDir));
|
|
226076
226245
|
const diagnostics = [...projectConfig.errors, ...program.getOptionsDiagnostics()].map((diagnostic) => ({
|
|
226077
226246
|
severity: "error",
|
|
226078
226247
|
code: "source-config",
|
|
226079
|
-
message:
|
|
226248
|
+
message: ts6.flattenDiagnosticMessageText(diagnostic.messageText, `
|
|
226080
226249
|
`),
|
|
226081
226250
|
file: diagnostic.file ? normalizeRelative(rootDir, diagnostic.file.fileName) : normalizeRelative(rootDir, configPath),
|
|
226082
226251
|
...diagnostic.file && diagnostic.start !== undefined ? { line: diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start).line + 1 } : {},
|
|
@@ -226093,7 +226262,7 @@ function scanProductionSource(options) {
|
|
|
226093
226262
|
diagnostics.push({
|
|
226094
226263
|
severity: "error",
|
|
226095
226264
|
code: "source-typescript",
|
|
226096
|
-
message:
|
|
226265
|
+
message: ts6.flattenDiagnosticMessageText(diagnostic.messageText, `
|
|
226097
226266
|
`),
|
|
226098
226267
|
...diagnostic.file ? { file: normalizeRelative(rootDir, diagnostic.file.fileName) } : {},
|
|
226099
226268
|
...diagnostic.file && diagnostic.start !== undefined ? { line: diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start).line + 1 } : {},
|
|
@@ -226102,9 +226271,10 @@ function scanProductionSource(options) {
|
|
|
226102
226271
|
}
|
|
226103
226272
|
for (const sourceFile of sourceFiles) {
|
|
226104
226273
|
scanSourceFile(sourceFile, checker, rootDir, diagnostics, options.strict ?? false);
|
|
226105
|
-
|
|
226106
|
-
|
|
226107
|
-
|
|
226274
|
+
diagnostics.push(...scanDrizzleSql(sourceFile, checker, normalizeRelative(rootDir, sourceFile.fileName), options.strict ?? false));
|
|
226275
|
+
const scanner = ts6.createScanner(ts6.ScriptTarget.Latest, false, sourceFile.languageVariant, sourceFile.text);
|
|
226276
|
+
for (let kind = scanner.scan();kind !== ts6.SyntaxKind.EndOfFileToken; kind = scanner.scan()) {
|
|
226277
|
+
if ((kind === ts6.SyntaxKind.SingleLineCommentTrivia || kind === ts6.SyntaxKind.MultiLineCommentTrivia) && /@ts-(?:ignore|nocheck|expect-error)\b/.test(scanner.getTokenText())) {
|
|
226108
226278
|
diagnostics.push({
|
|
226109
226279
|
severity: "error",
|
|
226110
226280
|
code: "source-type-suppression",
|
|
@@ -226124,22 +226294,22 @@ function scanSourceFile(sourceFile, checker, rootDir, diagnostics, strict) {
|
|
|
226124
226294
|
diagnostics.push(makeDiagnostic("source-any", "生产源码使用了显式 any;请改用 unknown、具体接口或泛型约束。", sourceFile, node, strict, rootDir));
|
|
226125
226295
|
}
|
|
226126
226296
|
for (const node of descendants(sourceFile)) {
|
|
226127
|
-
if (
|
|
226128
|
-
if (
|
|
226297
|
+
if (ts6.isAsExpression(node)) {
|
|
226298
|
+
if (ts6.isAsExpression(node.parent) || ts6.isTypeAssertionExpression(node.parent))
|
|
226129
226299
|
continue;
|
|
226130
226300
|
const assertedType = node.type.getText(sourceFile);
|
|
226131
226301
|
if (assertedType === "const")
|
|
226132
226302
|
continue;
|
|
226133
226303
|
diagnostics.push(makeDiagnostic("source-type-assertion", `生产源码包含类型断言 ${node.getText(sourceFile)};请优先使用类型守卫、satisfies 或显式边界解析。`, sourceFile, node, strict, rootDir));
|
|
226134
|
-
} else if (
|
|
226135
|
-
if (
|
|
226304
|
+
} else if (ts6.isTypeAssertionExpression(node)) {
|
|
226305
|
+
if (ts6.isAsExpression(node.parent) || ts6.isTypeAssertionExpression(node.parent))
|
|
226136
226306
|
continue;
|
|
226137
226307
|
diagnostics.push(makeDiagnostic("source-type-assertion", `生产源码包含类型断言 ${node.getText(sourceFile)};请优先使用类型守卫、satisfies 或显式边界解析。`, sourceFile, node, strict, rootDir));
|
|
226138
|
-
} else if (
|
|
226308
|
+
} else if (ts6.isNonNullExpression(node)) {
|
|
226139
226309
|
diagnostics.push(makeDiagnostic("source-non-null-assertion", `生产源码包含非空断言 ${node.getText(sourceFile)};请显式处理 null/undefined。`, sourceFile, node, strict, rootDir));
|
|
226140
226310
|
}
|
|
226141
226311
|
}
|
|
226142
|
-
for (const declaration of descendantsOfKind2(sourceFile,
|
|
226312
|
+
for (const declaration of descendantsOfKind2(sourceFile, ts6.isVariableDeclaration)) {
|
|
226143
226313
|
const initializer = declaration.initializer;
|
|
226144
226314
|
if (!initializer || declaration.type)
|
|
226145
226315
|
continue;
|
|
@@ -226155,11 +226325,11 @@ function scanSourceFile(sourceFile, checker, rootDir, diagnostics, strict) {
|
|
|
226155
226325
|
if (isLetDeclaration(declaration) && isLiteralSyntax(initializer) && !isLiteralType(declarationType)) {
|
|
226156
226326
|
diagnostics.push(makeDiagnostic("source-implicit-widening", `变量 ${declaration.name.getText(sourceFile)} 的字面量类型从 ${checker.typeToString(initializerType, initializer)} 隐式宽化为 ${checker.typeToString(declarationType, declaration)};请补充类型或使用 const。`, sourceFile, declaration, strict, rootDir));
|
|
226157
226327
|
}
|
|
226158
|
-
if (
|
|
226328
|
+
if (ts6.isObjectLiteralExpression(initializer) && isConstDeclaration(declaration) && initializer.getText(sourceFile).length > 0 && initializer.properties.some((property) => ts6.isPropertyAssignment(property) && property.initializer !== undefined && !ts6.isAsExpression(property.initializer) && isLiteralExpression(property.initializer))) {
|
|
226159
226329
|
diagnostics.push(makeDiagnostic("source-implicit-widening", `常量对象 ${declaration.name.getText(sourceFile)} 的字面量属性会隐式宽化;请补充对象类型或使用 as const。`, sourceFile, declaration, strict, rootDir));
|
|
226160
226330
|
}
|
|
226161
226331
|
}
|
|
226162
|
-
for (const parameter of descendantsOfKind2(sourceFile,
|
|
226332
|
+
for (const parameter of descendantsOfKind2(sourceFile, ts6.isParameter)) {
|
|
226163
226333
|
if (parameter.type)
|
|
226164
226334
|
continue;
|
|
226165
226335
|
for (const name of bindingNames(parameter.name)) {
|
|
@@ -226170,10 +226340,10 @@ function scanSourceFile(sourceFile, checker, rootDir, diagnostics, strict) {
|
|
|
226170
226340
|
}
|
|
226171
226341
|
}
|
|
226172
226342
|
function readProjectConfig2(configPath) {
|
|
226173
|
-
const config =
|
|
226343
|
+
const config = ts6.readConfigFile(configPath, (file) => readFileSync22(file, "utf8"));
|
|
226174
226344
|
if (config.error)
|
|
226175
226345
|
return { options: {}, errors: [config.error] };
|
|
226176
|
-
const parsed =
|
|
226346
|
+
const parsed = ts6.parseJsonConfigFileContent(config.config, ts6.sys, dirname32(configPath));
|
|
226177
226347
|
return { options: parsed.options, errors: parsed.errors };
|
|
226178
226348
|
}
|
|
226179
226349
|
function isProductionSource(rootDir, sourceFile, excludes, outDir) {
|
|
@@ -226193,42 +226363,42 @@ function globMatches(value, pattern) {
|
|
|
226193
226363
|
return new RegExp(`^${escaped}$`).test(value);
|
|
226194
226364
|
}
|
|
226195
226365
|
function bindingNames(name) {
|
|
226196
|
-
if (
|
|
226366
|
+
if (ts6.isIdentifier(name))
|
|
226197
226367
|
return [name];
|
|
226198
|
-
return name.elements.flatMap((element) =>
|
|
226368
|
+
return name.elements.flatMap((element) => ts6.isBindingElement(element) ? bindingNames(element.name) : []);
|
|
226199
226369
|
}
|
|
226200
226370
|
function isLiteralExpression(node) {
|
|
226201
226371
|
if (!node)
|
|
226202
226372
|
return false;
|
|
226203
226373
|
return [
|
|
226204
|
-
|
|
226205
|
-
|
|
226206
|
-
|
|
226207
|
-
|
|
226374
|
+
ts6.SyntaxKind.StringLiteral,
|
|
226375
|
+
ts6.SyntaxKind.NumericLiteral,
|
|
226376
|
+
ts6.SyntaxKind.TrueKeyword,
|
|
226377
|
+
ts6.SyntaxKind.FalseKeyword
|
|
226208
226378
|
].includes(node.kind);
|
|
226209
226379
|
}
|
|
226210
226380
|
function isLiteralSyntax(node) {
|
|
226211
|
-
return
|
|
226381
|
+
return ts6.isStringLiteral(node) || ts6.isNumericLiteral(node) || node.kind === ts6.SyntaxKind.TrueKeyword || node.kind === ts6.SyntaxKind.FalseKeyword;
|
|
226212
226382
|
}
|
|
226213
226383
|
function isLiteralType(type) {
|
|
226214
|
-
return (type.flags & (
|
|
226384
|
+
return (type.flags & (ts6.TypeFlags.StringLiteral | ts6.TypeFlags.NumberLiteral | ts6.TypeFlags.BooleanLiteral | ts6.TypeFlags.BigIntLiteral)) !== 0;
|
|
226215
226385
|
}
|
|
226216
226386
|
function isAnyType(type) {
|
|
226217
|
-
return (type.flags &
|
|
226387
|
+
return (type.flags & ts6.TypeFlags.Any) !== 0;
|
|
226218
226388
|
}
|
|
226219
226389
|
function isLetDeclaration(declaration) {
|
|
226220
|
-
return
|
|
226390
|
+
return ts6.isVariableDeclarationList(declaration.parent) && (declaration.parent.flags & ts6.NodeFlags.Let) !== 0;
|
|
226221
226391
|
}
|
|
226222
226392
|
function isConstDeclaration(declaration) {
|
|
226223
|
-
return
|
|
226393
|
+
return ts6.isVariableDeclarationList(declaration.parent) && (declaration.parent.flags & ts6.NodeFlags.Const) !== 0;
|
|
226224
226394
|
}
|
|
226225
226395
|
function descendants(root) {
|
|
226226
226396
|
const result = [];
|
|
226227
226397
|
const visit = (node) => {
|
|
226228
226398
|
result.push(node);
|
|
226229
|
-
|
|
226399
|
+
ts6.forEachChild(node, visit);
|
|
226230
226400
|
};
|
|
226231
|
-
|
|
226401
|
+
ts6.forEachChild(root, visit);
|
|
226232
226402
|
return result;
|
|
226233
226403
|
}
|
|
226234
226404
|
function descendantsOfKind2(root, predicate) {
|
|
@@ -226236,9 +226406,9 @@ function descendantsOfKind2(root, predicate) {
|
|
|
226236
226406
|
const visit = (node) => {
|
|
226237
226407
|
if (predicate(node))
|
|
226238
226408
|
result.push(node);
|
|
226239
|
-
|
|
226409
|
+
ts6.forEachChild(node, visit);
|
|
226240
226410
|
};
|
|
226241
|
-
|
|
226411
|
+
ts6.forEachChild(root, visit);
|
|
226242
226412
|
return result;
|
|
226243
226413
|
}
|
|
226244
226414
|
function makeDiagnostic(code, message, fileOrSourceFile, node, strict, rootDir) {
|
|
@@ -226259,7 +226429,7 @@ function normalizeRelative(rootDir, filePath) {
|
|
|
226259
226429
|
return relative32(rootDir, filePath).split(sep32).join("/").replace(/^\.\//, "");
|
|
226260
226430
|
}
|
|
226261
226431
|
function isAnyKeyword(node) {
|
|
226262
|
-
return node.kind ===
|
|
226432
|
+
return node.kind === ts6.SyntaxKind.AnyKeyword;
|
|
226263
226433
|
}
|
|
226264
226434
|
function inspectRouteContracts(graph) {
|
|
226265
226435
|
return graph.modules.flatMap((module) => module.controllers.flatMap((controller) => controller.routes.map((route) => {
|
|
@@ -226348,6 +226518,9 @@ async function compileProject(options) {
|
|
|
226348
226518
|
...graph.diagnostics ?? [],
|
|
226349
226519
|
...validateGraph(graph, options)
|
|
226350
226520
|
];
|
|
226521
|
+
if (diagnostics.some((item) => item.code === "runtime-injection-disallowed")) {
|
|
226522
|
+
return { diagnostics, graph, written: [] };
|
|
226523
|
+
}
|
|
226351
226524
|
if (options.strict) {
|
|
226352
226525
|
for (const diagnostic of diagnostics) {
|
|
226353
226526
|
if (diagnostic.severity === "warn")
|
|
@@ -226406,6 +226579,9 @@ async function checkProject(options) {
|
|
|
226406
226579
|
...graph.diagnostics ?? [],
|
|
226407
226580
|
...validateGraph(graph, options)
|
|
226408
226581
|
];
|
|
226582
|
+
if (diagnostics.some((item) => item.code === "runtime-injection-disallowed")) {
|
|
226583
|
+
return { diagnostics, graph, upToDate: false, mismatches: ["Runtime DI must be migrated to constructor injection."] };
|
|
226584
|
+
}
|
|
226409
226585
|
if (options.strict) {
|
|
226410
226586
|
for (const diagnostic of diagnostics) {
|
|
226411
226587
|
if (diagnostic.severity === "warn")
|
|
@@ -229546,9 +229722,9 @@ init_generate();
|
|
|
229546
229722
|
init_graphql_inputs();
|
|
229547
229723
|
var ROUTE_DECORATORS2 = new Set(["Get", "Post", "Put", "Patch", "Delete", "Head", "Options"]);
|
|
229548
229724
|
var MIGRATION_COMPILER_OPTIONS = {
|
|
229549
|
-
target:
|
|
229550
|
-
module:
|
|
229551
|
-
moduleResolution:
|
|
229725
|
+
target: ts12.ScriptTarget.ES2022,
|
|
229726
|
+
module: ts12.ModuleKind.ESNext,
|
|
229727
|
+
moduleResolution: ts12.ModuleResolutionKind.Bundler,
|
|
229552
229728
|
noEmit: true,
|
|
229553
229729
|
skipLibCheck: true
|
|
229554
229730
|
};
|
|
@@ -229638,8 +229814,8 @@ function validateGovernanceConfig(config) {
|
|
|
229638
229814
|
function resolveSupacloudConfig(config = {}, cwd = process.cwd()) {
|
|
229639
229815
|
const resolved = defineSupacloudConfig(config);
|
|
229640
229816
|
return {
|
|
229641
|
-
rootDir:
|
|
229642
|
-
outDir:
|
|
229817
|
+
rootDir: resolve14(cwd, resolved.root ?? DEFAULT_SUPACLOUD_CONFIG.root),
|
|
229818
|
+
outDir: resolve14(cwd, resolved.outDir ?? DEFAULT_SUPACLOUD_CONFIG.outDir),
|
|
229643
229819
|
include: resolved.include ?? [...DEFAULT_SUPACLOUD_CONFIG.include],
|
|
229644
229820
|
strict: resolved.strict ?? DEFAULT_SUPACLOUD_CONFIG.strict,
|
|
229645
229821
|
requireRouteContracts: resolved.requireRouteContracts ?? DEFAULT_SUPACLOUD_CONFIG.requireRouteContracts,
|
|
@@ -229657,7 +229833,7 @@ function resolveSupacloudConfig(config = {}, cwd = process.cwd()) {
|
|
|
229657
229833
|
treeShakeUnusedProviders: resolved.treeShakeUnusedProviders ?? DEFAULT_SUPACLOUD_CONFIG.treeShakeUnusedProviders,
|
|
229658
229834
|
graphql: resolved.graphql ? {
|
|
229659
229835
|
...resolved.graphql,
|
|
229660
|
-
schema:
|
|
229836
|
+
schema: resolve14(cwd, resolved.graphql.schema)
|
|
229661
229837
|
} : undefined
|
|
229662
229838
|
};
|
|
229663
229839
|
}
|
|
@@ -229678,6 +229854,7 @@ function compileOptionsFromConfig(config, cwd = process.cwd()) {
|
|
|
229678
229854
|
return resolveSupacloudConfig(config, cwd);
|
|
229679
229855
|
}
|
|
229680
229856
|
init_graphql_schema();
|
|
229857
|
+
init_database_contracts();
|
|
229681
229858
|
|
|
229682
229859
|
// src/shared/tools/app-tool-export.ts
|
|
229683
229860
|
function sanitizeToolName(name) {
|
|
@@ -229930,7 +230107,7 @@ test("partial and untagged inherited remote profiles cannot mix with selected fi
|
|
|
229930
230107
|
// ../compiler/package.json
|
|
229931
230108
|
var package_default = {
|
|
229932
230109
|
name: "@supacloud/compiler",
|
|
229933
|
-
version: "0.
|
|
230110
|
+
version: "0.22.0",
|
|
229934
230111
|
description: "Static compiler for @supacloud/app metadata: builds the application graph from AST, validates it, and generates reflection-free factory code",
|
|
229935
230112
|
type: "module",
|
|
229936
230113
|
main: "./dist/index.js",
|
|
@@ -229986,6 +230163,8 @@ var package_default = {
|
|
|
229986
230163
|
graphql: "^16"
|
|
229987
230164
|
},
|
|
229988
230165
|
devDependencies: {
|
|
230166
|
+
"@supabase/supabase-js": "2.115.0",
|
|
230167
|
+
"drizzle-orm": "1.0.0-rc.4",
|
|
229989
230168
|
"@types/bun": "^1.4.2",
|
|
229990
230169
|
typescript: "^7.0.2"
|
|
229991
230170
|
}
|
|
@@ -230057,7 +230236,7 @@ var package_default2 = {
|
|
|
230057
230236
|
// ../elysia/package.json
|
|
230058
230237
|
var package_default3 = {
|
|
230059
230238
|
name: "@supacloud/elysia",
|
|
230060
|
-
version: "0.
|
|
230239
|
+
version: "0.17.0",
|
|
230061
230240
|
description: "Elysia runtime adapter for SupaCloud compiled modules: application/request scopes, route registration and validation",
|
|
230062
230241
|
type: "module",
|
|
230063
230242
|
main: "./dist/index.js",
|
|
@@ -230072,7 +230251,8 @@ var package_default3 = {
|
|
|
230072
230251
|
},
|
|
230073
230252
|
files: [
|
|
230074
230253
|
"dist",
|
|
230075
|
-
"README.md"
|
|
230254
|
+
"README.md",
|
|
230255
|
+
"compatibility.json"
|
|
230076
230256
|
],
|
|
230077
230257
|
scripts: {
|
|
230078
230258
|
"generate:example": "bun src/generate-webhook-example.ts",
|
|
@@ -230082,6 +230262,9 @@ var package_default3 = {
|
|
|
230082
230262
|
clean: "rm -rf dist",
|
|
230083
230263
|
prepublishOnly: "bun run build",
|
|
230084
230264
|
test: "bun test",
|
|
230265
|
+
"test:conformance": "bun test src/conformance.test.ts",
|
|
230266
|
+
"test:runtime-safety": "SUPACLOUD_REQUIRE_RUNTIME_SAFETY=1 bun test src/runtime-safety.test.ts",
|
|
230267
|
+
"test:contract-upgrade": "bun test src/contract-upgrade.test.ts",
|
|
230085
230268
|
typecheck: "tsc -p tsconfig.json --noEmit",
|
|
230086
230269
|
"typecheck:test": "tsc -p tsconfig.test.json --noEmit"
|
|
230087
230270
|
},
|
|
@@ -231693,7 +231876,7 @@ function registerDbGovernanceTools(server2, options = {}) {
|
|
|
231693
231876
|
// src/shared/tools/scheduled-function-tools.ts
|
|
231694
231877
|
import { randomUUID } from "node:crypto";
|
|
231695
231878
|
import { readFileSync as readFileSync8, statSync as statSync6 } from "node:fs";
|
|
231696
|
-
import { resolve as
|
|
231879
|
+
import { resolve as resolve13 } from "node:path";
|
|
231697
231880
|
import { isDeepStrictEqual } from "node:util";
|
|
231698
231881
|
var HEADER_NAME_PATTERN = /^[!#$%&'*+.^_`|~0-9A-Za-z-]{1,128}$/;
|
|
231699
231882
|
var ENVIRONMENT_NAME_PATTERN2 = /^[A-Za-z_][A-Za-z0-9_]{0,255}$/;
|
|
@@ -231777,7 +231960,7 @@ function validScheduledFunctionCron(expression) {
|
|
|
231777
231960
|
function readScheduleBodyFile(bodyPathInput) {
|
|
231778
231961
|
if (!bodyPathInput.trim())
|
|
231779
231962
|
throw new Error("'body_file' must be a path");
|
|
231780
|
-
const bodyPath =
|
|
231963
|
+
const bodyPath = resolve13(bodyPathInput);
|
|
231781
231964
|
const bodyStat = statSync6(bodyPath);
|
|
231782
231965
|
if (!bodyStat.isFile() || bodyStat.size > MAX_BODY_FILE_BYTES) {
|
|
231783
231966
|
throw new Error("Scheduled Function body file must be a regular file no larger than 1 MiB");
|
|
@@ -234509,7 +234692,7 @@ function registerRemoteDevTools(server2, options = {}) {
|
|
|
234509
234692
|
// package.json
|
|
234510
234693
|
var package_default4 = {
|
|
234511
234694
|
name: "@supacloud/cli",
|
|
234512
|
-
version: "0.
|
|
234695
|
+
version: "0.54.0",
|
|
234513
234696
|
description: "Project-scoped CLI for SupaCloud users",
|
|
234514
234697
|
type: "module",
|
|
234515
234698
|
main: "./dist/index.js",
|
|
@@ -234542,7 +234725,7 @@ var package_default4 = {
|
|
|
234542
234725
|
},
|
|
234543
234726
|
dependencies: {
|
|
234544
234727
|
"@sinclair/typebox": "^0.34.52",
|
|
234545
|
-
"@supacloud/compiler": "^0.
|
|
234728
|
+
"@supacloud/compiler": "^0.22.0",
|
|
234546
234729
|
"@supacloud/db": "^0.2.0",
|
|
234547
234730
|
fflate: "^0.8.3"
|
|
234548
234731
|
},
|