@supacloud/compiler 0.44.0 → 0.45.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/README.md +55 -0
- package/dist/cli.js +269 -150
- package/dist/config.d.ts +2 -0
- package/dist/database-governance-runtime.d.ts +4 -0
- package/dist/database-governance-worker.d.ts +1 -0
- package/dist/database-governance-worker.js +159 -0
- package/dist/database-governance.d.ts +4 -0
- package/dist/delivery-bundle-worker.js +6 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +252 -133
- package/dist/migration-app-version.d.ts +1 -1
- package/dist/migration-elysia-version.d.ts +1 -1
- package/dist/types.d.ts +16 -0
- package/package.json +12 -7
package/dist/cli.js
CHANGED
|
@@ -4096,7 +4096,7 @@ var init_graphql_options = __esm(() => {
|
|
|
4096
4096
|
});
|
|
4097
4097
|
|
|
4098
4098
|
// src/graphql-inputs.ts
|
|
4099
|
-
import { resolve as
|
|
4099
|
+
import { resolve as resolve6 } from "node:path";
|
|
4100
4100
|
import * as ts11 from "@typescript/typescript6";
|
|
4101
4101
|
function graphqlInputPaths(options) {
|
|
4102
4102
|
if (!options.graphql)
|
|
@@ -4106,9 +4106,9 @@ function graphqlInputPaths(options) {
|
|
|
4106
4106
|
} catch {
|
|
4107
4107
|
return [];
|
|
4108
4108
|
}
|
|
4109
|
-
const root =
|
|
4110
|
-
const schema =
|
|
4111
|
-
const documents = ts11.sys.readDirectory(root, [".graphql", ".gql"], ["**/node_modules/**", "**/.git/**",
|
|
4109
|
+
const root = resolve6(options.rootDir);
|
|
4110
|
+
const schema = resolve6(root, options.graphql.schema);
|
|
4111
|
+
const documents = ts11.sys.readDirectory(root, [".graphql", ".gql"], ["**/node_modules/**", "**/.git/**", resolve6(options.outDir)], options.graphql.documents ?? ["**/*.graphql", "**/*.gql"]).map((path) => resolve6(path)).filter((path) => path !== schema);
|
|
4112
4112
|
return [schema, ...[...new Set(documents)].sort()];
|
|
4113
4113
|
}
|
|
4114
4114
|
var init_graphql_inputs = __esm(() => {
|
|
@@ -4117,9 +4117,9 @@ var init_graphql_inputs = __esm(() => {
|
|
|
4117
4117
|
|
|
4118
4118
|
// src/graphql-runtime.ts
|
|
4119
4119
|
import * as ts12 from "@typescript/typescript6";
|
|
4120
|
-
import { resolve as
|
|
4120
|
+
import { resolve as resolve7 } from "node:path";
|
|
4121
4121
|
function renderGraphqlValidators(source, operationNames, operationKinds = new Map) {
|
|
4122
|
-
const fileName =
|
|
4122
|
+
const fileName = resolve7("/__supacloud_graphql__/contracts.ts");
|
|
4123
4123
|
const options = {
|
|
4124
4124
|
strict: true,
|
|
4125
4125
|
noUncheckedIndexedAccess: true,
|
|
@@ -4135,7 +4135,7 @@ function renderGraphqlValidators(source, operationNames, operationKinds = new Ma
|
|
|
4135
4135
|
};
|
|
4136
4136
|
const host = ts12.createCompilerHost(options);
|
|
4137
4137
|
const getSourceFile = host.getSourceFile.bind(host);
|
|
4138
|
-
host.getSourceFile = (path, languageVersion, onError, shouldCreateNewSourceFile) =>
|
|
4138
|
+
host.getSourceFile = (path, languageVersion, onError, shouldCreateNewSourceFile) => resolve7(path) === fileName ? ts12.createSourceFile(path, source, languageVersion, true) : getSourceFile(path, languageVersion, onError, shouldCreateNewSourceFile);
|
|
4139
4139
|
const program = ts12.createProgram([fileName], options, host);
|
|
4140
4140
|
const diagnostics = ts12.getPreEmitDiagnostics(program);
|
|
4141
4141
|
if (diagnostics.length) {
|
|
@@ -13169,7 +13169,7 @@ function FromObject10(context, type, value) {
|
|
|
13169
13169
|
return value;
|
|
13170
13170
|
const additionalProperties = GetAdditionalProperties(type);
|
|
13171
13171
|
for (const key of Keys(value)) {
|
|
13172
|
-
if (HasPropertyKey(type.properties, key)) {
|
|
13172
|
+
if (HasPropertyKey(type.properties, key) && IsSchema(type.properties[key])) {
|
|
13173
13173
|
value[key] = FromType19(context, type.properties[key], value[key]);
|
|
13174
13174
|
continue;
|
|
13175
13175
|
}
|
|
@@ -13301,6 +13301,9 @@ function FromProperties4(properties) {
|
|
|
13301
13301
|
result[key] = FromType20(properties[key]);
|
|
13302
13302
|
return result;
|
|
13303
13303
|
}
|
|
13304
|
+
function FromRecordKey(type) {
|
|
13305
|
+
return String2({ pattern: RecordPattern(type) });
|
|
13306
|
+
}
|
|
13304
13307
|
function FromPriorityTypes(types) {
|
|
13305
13308
|
return FromTypes6(Priority(types));
|
|
13306
13309
|
}
|
|
@@ -13308,7 +13311,7 @@ function FromTypes6(types) {
|
|
|
13308
13311
|
return types.map((type) => FromType20(type));
|
|
13309
13312
|
}
|
|
13310
13313
|
function FromType20(type) {
|
|
13311
|
-
const next = IsArray2(type) ? _Array_(FromType20(type.items), ArrayOptions(type)) : IsIntersect(type) ? Intersect(FromTypes6(type.allOf)) : IsUnion(type) ? Union(FromPriorityTypes(type.anyOf)) : IsObject2(type) ? _Object_(FromProperties4(type.properties)) : IsRecord(type) ? Record(
|
|
13314
|
+
const next = IsArray2(type) ? _Array_(FromType20(type.items), ArrayOptions(type)) : IsIntersect(type) ? Intersect(FromTypes6(type.allOf)) : IsUnion(type) ? Union(FromPriorityTypes(type.anyOf)) : IsObject2(type) ? _Object_(FromProperties4(type.properties)) : IsRecord(type) ? Record(FromRecordKey(type), FromType20(RecordValue(type))) : IsTuple(type) ? Tuple(FromTypes6(type.items)) : type;
|
|
13312
13315
|
return Modifiers(type, next);
|
|
13313
13316
|
}
|
|
13314
13317
|
function UnionPrioritySort(type) {
|
|
@@ -13324,6 +13327,7 @@ var init_union_priority_sort = __esm(() => {
|
|
|
13324
13327
|
init_type3();
|
|
13325
13328
|
init_type3();
|
|
13326
13329
|
init_type3();
|
|
13330
|
+
init_type3();
|
|
13327
13331
|
});
|
|
13328
13332
|
|
|
13329
13333
|
// node_modules/typebox/build/value/clean/clean.mjs
|
|
@@ -15838,7 +15842,7 @@ var init_delivery_schema = __esm(() => {
|
|
|
15838
15842
|
import { createHash as createHash7 } from "node:crypto";
|
|
15839
15843
|
import { constants as constants2 } from "node:fs";
|
|
15840
15844
|
import { lstat, mkdir as mkdir2, open as open3, readFile as readFile3, readdir, realpath, rename as rename2, rm, writeFile as writeFile2 } from "node:fs/promises";
|
|
15841
|
-
import { dirname as dirname5, isAbsolute as isAbsolute2, join as join6, relative as relative6, resolve as
|
|
15845
|
+
import { dirname as dirname5, isAbsolute as isAbsolute2, join as join6, relative as relative6, resolve as resolve9, sep as sep6 } from "node:path";
|
|
15842
15846
|
function canonical2(value) {
|
|
15843
15847
|
return JSON.stringify(value, (_key, item) => item !== null && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) : item);
|
|
15844
15848
|
}
|
|
@@ -15901,7 +15905,7 @@ async function reserveOutput(project, requested) {
|
|
|
15901
15905
|
if (!inside(project, requested))
|
|
15902
15906
|
throw new Error("Delivery output must be inside the application project.");
|
|
15903
15907
|
const base = await realpath(project);
|
|
15904
|
-
const path =
|
|
15908
|
+
const path = resolve9(base, relative6(project, requested));
|
|
15905
15909
|
if (relative6(base, path).split(sep6).some((part) => part === ".git" || part === "node_modules")) {
|
|
15906
15910
|
throw new Error("Delivery output cannot use repository or dependency internals.");
|
|
15907
15911
|
}
|
|
@@ -16109,9 +16113,9 @@ var init_delivery_build_schema = __esm(() => {
|
|
|
16109
16113
|
|
|
16110
16114
|
// node_modules/@supacloud/delivery/src/delivery-artifact.ts
|
|
16111
16115
|
import { readdir as readdir2, realpath as realpath2 } from "node:fs/promises";
|
|
16112
|
-
import { basename, dirname as dirname6, join as join7, resolve as
|
|
16116
|
+
import { basename, dirname as dirname6, join as join7, resolve as resolve10 } from "node:path";
|
|
16113
16117
|
async function readDeliveryManifest(manifestPath) {
|
|
16114
|
-
const selected =
|
|
16118
|
+
const selected = resolve10(manifestPath);
|
|
16115
16119
|
const root = await realpath2(dirname6(selected));
|
|
16116
16120
|
const manifest = parseDeliveryBuildManifest(JSON.parse((await readBoundedOwned(root, join7(root, basename(selected)), JSON_LIMIT)).toString("utf8")));
|
|
16117
16121
|
return { root, manifest };
|
|
@@ -16263,13 +16267,13 @@ var init_delivery_context = __esm(() => {
|
|
|
16263
16267
|
// src/fixes.ts
|
|
16264
16268
|
import { createHash as createHash9, randomUUID } from "node:crypto";
|
|
16265
16269
|
import { lstat as lstat2, readFile as readFile5, realpath as realpath3, rename as rename3, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";
|
|
16266
|
-
import { dirname as dirname8, isAbsolute as isAbsolute4, relative as relative9, resolve as
|
|
16270
|
+
import { dirname as dirname8, isAbsolute as isAbsolute4, relative as relative9, resolve as resolve14, sep as sep9 } from "node:path";
|
|
16267
16271
|
import * as ts13 from "@typescript/typescript6";
|
|
16268
16272
|
async function applyDiagnosticFix(fix, options = {}) {
|
|
16269
16273
|
if (!fix || typeof fix.targetFile !== "string")
|
|
16270
16274
|
throw new Error("Invalid DiagnosticFix");
|
|
16271
16275
|
const root = await realpath3(options.rootDir ?? process.cwd());
|
|
16272
|
-
const file =
|
|
16276
|
+
const file = resolve14(root, fix.targetFile);
|
|
16273
16277
|
const stat = await lstat2(file);
|
|
16274
16278
|
const resolved = await realpath3(file);
|
|
16275
16279
|
const relativePath = relative9(root, resolved);
|
|
@@ -16444,8 +16448,8 @@ function moduleObjects(source) {
|
|
|
16444
16448
|
}
|
|
16445
16449
|
function importSymbol(source, path, symbol) {
|
|
16446
16450
|
identifier2(symbol);
|
|
16447
|
-
const current =
|
|
16448
|
-
const target =
|
|
16451
|
+
const current = resolve14(source.fileName).replace(/\.(tsx?|mts|cts)$/, "");
|
|
16452
|
+
const target = resolve14(dirname8(source.fileName), path).replace(/\.(tsx?|mts|cts)$/, "");
|
|
16449
16453
|
if (current === target)
|
|
16450
16454
|
return source.text;
|
|
16451
16455
|
const matches = source.statements.filter((item) => ts13.isImportDeclaration(item) && ts13.isStringLiteral(item.moduleSpecifier) && item.moduleSpecifier.text === path);
|
|
@@ -16656,37 +16660,67 @@ var init_application_deploy_plan = __esm(() => {
|
|
|
16656
16660
|
}, { additionalProperties: false });
|
|
16657
16661
|
});
|
|
16658
16662
|
|
|
16659
|
-
// node_modules/@supacloud/delivery/src/application-
|
|
16660
|
-
var closed6, nullableActivation,
|
|
16661
|
-
var
|
|
16663
|
+
// node_modules/@supacloud/delivery/src/application-deploy-operation.ts
|
|
16664
|
+
var closed6, sha256, nullableActivation, ApplicationDeployWebReleaseSchema, ApplicationDeployRequestSchema, ApplicationBackendReceiptSchema, ApplicationDeployResultSchema;
|
|
16665
|
+
var init_application_deploy_operation = __esm(() => {
|
|
16662
16666
|
init_build();
|
|
16663
16667
|
init_value2();
|
|
16664
16668
|
init_application_activation();
|
|
16665
16669
|
init_application_configuration();
|
|
16666
16670
|
init_application_release();
|
|
16667
16671
|
closed6 = { additionalProperties: false };
|
|
16672
|
+
sha256 = ApplicationReleaseIdSchema;
|
|
16668
16673
|
nullableActivation = Union([ApplicationActivationIdSchema, Null()]);
|
|
16669
|
-
|
|
16670
|
-
|
|
16674
|
+
ApplicationDeployWebReleaseSchema = _Object_({
|
|
16675
|
+
deployment_id: String2({ pattern: "^[A-Za-z0-9_-]{1,128}$" }),
|
|
16676
|
+
release_id: sha256
|
|
16677
|
+
}, closed6);
|
|
16678
|
+
ApplicationDeployRequestSchema = _Object_({
|
|
16679
|
+
mutation_id: ApplicationActivationIdSchema,
|
|
16680
|
+
release_id: sha256,
|
|
16671
16681
|
configuration_id: Optional(ApplicationConfigurationIdSchema),
|
|
16672
16682
|
configuration_write: Optional(ApplicationConfigurationWriteSchema),
|
|
16673
|
-
|
|
16674
|
-
|
|
16675
|
-
|
|
16683
|
+
expected_plan_sha256: Optional(sha256),
|
|
16684
|
+
approved_migration_digest: Optional(sha256),
|
|
16685
|
+
web_release: Optional(ApplicationDeployWebReleaseSchema)
|
|
16676
16686
|
}, closed6);
|
|
16677
|
-
|
|
16678
|
-
schema: Literal("supacloud.application-
|
|
16687
|
+
ApplicationBackendReceiptSchema = _Object_({
|
|
16688
|
+
schema: Literal("supacloud.application-backend-receipt.v1"),
|
|
16679
16689
|
project_ref: String2({ pattern: "^[a-z0-9-]{1,20}$" }),
|
|
16680
16690
|
application_id: ApplicationIdSchema,
|
|
16681
16691
|
environment_id: ApplicationIdSchema,
|
|
16682
|
-
release_id:
|
|
16692
|
+
release_id: sha256,
|
|
16693
|
+
manifest_sha256: sha256,
|
|
16694
|
+
mutation_id: ApplicationActivationIdSchema,
|
|
16695
|
+
plan_sha256: sha256,
|
|
16696
|
+
backup_id: Union([String2(), Null()]),
|
|
16697
|
+
before_ledger_digest: sha256,
|
|
16698
|
+
after_ledger_digest: sha256,
|
|
16699
|
+
applied_versions: _Array_(String2({ pattern: "^\\d{1,20}$" }), { uniqueItems: true }),
|
|
16700
|
+
schema_reloaded: Boolean2(),
|
|
16701
|
+
postgrest_healthy: Boolean2()
|
|
16702
|
+
}, closed6);
|
|
16703
|
+
ApplicationDeployResultSchema = _Object_({
|
|
16704
|
+
schema: Literal("supacloud.application-deploy.v1"),
|
|
16705
|
+
project_ref: String2({ pattern: "^[a-z0-9-]{1,20}$" }),
|
|
16706
|
+
application_id: ApplicationIdSchema,
|
|
16707
|
+
environment_id: ApplicationIdSchema,
|
|
16708
|
+
mutation_id: ApplicationActivationIdSchema,
|
|
16709
|
+
release_id: sha256,
|
|
16683
16710
|
configuration_id: ApplicationConfigurationIdSchema,
|
|
16684
16711
|
activation_id: ApplicationActivationIdSchema,
|
|
16685
16712
|
expected_activation_id: nullableActivation,
|
|
16686
|
-
plan_sha256:
|
|
16713
|
+
plan_sha256: sha256,
|
|
16687
16714
|
action: Union([Literal("activate"), Literal("no-op")]),
|
|
16688
16715
|
replayed: Boolean2(),
|
|
16689
|
-
execution_performed: Boolean2()
|
|
16716
|
+
execution_performed: Boolean2(),
|
|
16717
|
+
backend_receipt: ApplicationBackendReceiptSchema,
|
|
16718
|
+
web: Optional(_Object_({
|
|
16719
|
+
deployment_id: String2({ pattern: "^[A-Za-z0-9_-]{1,128}$" }),
|
|
16720
|
+
release_id: sha256,
|
|
16721
|
+
activation_id: ApplicationActivationIdSchema,
|
|
16722
|
+
replayed: Boolean2()
|
|
16723
|
+
}, closed6))
|
|
16690
16724
|
}, closed6);
|
|
16691
16725
|
});
|
|
16692
16726
|
|
|
@@ -16842,14 +16876,14 @@ var init_application_release_transfer = __esm(() => {
|
|
|
16842
16876
|
});
|
|
16843
16877
|
|
|
16844
16878
|
// node_modules/@supacloud/delivery/src/deployment-evidence.ts
|
|
16845
|
-
var closed8,
|
|
16879
|
+
var closed8, sha2562, isoDate, status, evidenceStatus, DEPLOYMENT_EVIDENCE_SCHEMA = "supacloud.deployment-evidence.v1", DatabaseProviderSchema, componentName, DeploymentComponentEvidenceSchema, DeploymentEvidenceSchema;
|
|
16846
16880
|
var init_deployment_evidence = __esm(() => {
|
|
16847
16881
|
init_build();
|
|
16848
16882
|
init_value2();
|
|
16849
16883
|
init_application_configuration();
|
|
16850
16884
|
init_application_release();
|
|
16851
16885
|
closed8 = { additionalProperties: false };
|
|
16852
|
-
|
|
16886
|
+
sha2562 = String2({ pattern: "^[a-f0-9]{64}$" });
|
|
16853
16887
|
isoDate = String2({ minLength: 20, maxLength: 40 });
|
|
16854
16888
|
status = Union([
|
|
16855
16889
|
Literal("confirmed"),
|
|
@@ -16868,7 +16902,7 @@ var init_deployment_evidence = __esm(() => {
|
|
|
16868
16902
|
topology: Union([Literal("single-node"), Literal("distributed")]),
|
|
16869
16903
|
migration: _Object_({
|
|
16870
16904
|
status,
|
|
16871
|
-
inventory_sha256: Union([
|
|
16905
|
+
inventory_sha256: Union([sha2562, Null()]),
|
|
16872
16906
|
compatibility: Union([
|
|
16873
16907
|
Literal("verified"),
|
|
16874
16908
|
Literal("not-proven"),
|
|
@@ -16916,9 +16950,9 @@ var init_deployment_evidence = __esm(() => {
|
|
|
16916
16950
|
}, closed8),
|
|
16917
16951
|
source: _Object_({
|
|
16918
16952
|
commit_sha: Union([String2({ pattern: "^[0-9a-f]{7,64}$" }), Null()]),
|
|
16919
|
-
manifest_sha256:
|
|
16953
|
+
manifest_sha256: sha2562,
|
|
16920
16954
|
contract_schema: Union([String2({ minLength: 1, maxLength: 128 }), Null()]),
|
|
16921
|
-
environment_binding_version: Union([
|
|
16955
|
+
environment_binding_version: Union([sha2562, Null()])
|
|
16922
16956
|
}, closed8),
|
|
16923
16957
|
database: DatabaseProviderSchema,
|
|
16924
16958
|
components: _Array_(DeploymentComponentEvidenceSchema, { minItems: 1, maxItems: 32 }),
|
|
@@ -16943,7 +16977,7 @@ var init_deployment_evidence = __esm(() => {
|
|
|
16943
16977
|
});
|
|
16944
16978
|
|
|
16945
16979
|
// node_modules/@supacloud/delivery/src/application-promotion.ts
|
|
16946
|
-
var closed9, projectRef2,
|
|
16980
|
+
var closed9, projectRef2, sha2563, nullableActivation2, nullableDigest, observation, blocker, ApplicationPromotionPlanSchema;
|
|
16947
16981
|
var init_application_promotion = __esm(() => {
|
|
16948
16982
|
init_build();
|
|
16949
16983
|
init_value2();
|
|
@@ -16953,9 +16987,9 @@ var init_application_promotion = __esm(() => {
|
|
|
16953
16987
|
init_application_release();
|
|
16954
16988
|
closed9 = { additionalProperties: false };
|
|
16955
16989
|
projectRef2 = String2({ pattern: "^[a-z0-9-]{1,20}$" });
|
|
16956
|
-
|
|
16990
|
+
sha2563 = ApplicationReleaseIdSchema;
|
|
16957
16991
|
nullableActivation2 = Union([ApplicationActivationIdSchema, Null()]);
|
|
16958
|
-
nullableDigest = Union([
|
|
16992
|
+
nullableDigest = Union([sha2563, Null()]);
|
|
16959
16993
|
observation = {
|
|
16960
16994
|
activation_id: nullableActivation2,
|
|
16961
16995
|
receipt_confirmed: Boolean2(),
|
|
@@ -16981,24 +17015,24 @@ var init_application_promotion = __esm(() => {
|
|
|
16981
17015
|
project_ref: projectRef2,
|
|
16982
17016
|
application_id: ApplicationIdSchema,
|
|
16983
17017
|
environment_id: ApplicationIdSchema,
|
|
16984
|
-
manifest_sha256:
|
|
16985
|
-
plan_sha256:
|
|
17018
|
+
manifest_sha256: sha2563,
|
|
17019
|
+
plan_sha256: sha2563,
|
|
16986
17020
|
source: _Object_({
|
|
16987
17021
|
project_ref: projectRef2,
|
|
16988
17022
|
environment_id: ApplicationIdSchema,
|
|
16989
|
-
release_id:
|
|
17023
|
+
release_id: sha2563,
|
|
16990
17024
|
...observation
|
|
16991
17025
|
}, closed9),
|
|
16992
17026
|
target: _Object_({
|
|
16993
|
-
candidate_release_id:
|
|
16994
|
-
current_release_id: Union([
|
|
17027
|
+
candidate_release_id: sha2563,
|
|
17028
|
+
current_release_id: Union([sha2563, Null()]),
|
|
16995
17029
|
artifact_action: Union([Literal("materialize"), Literal("reuse")]),
|
|
16996
17030
|
configuration_id: Union([ApplicationConfigurationIdSchema, Null()]),
|
|
16997
17031
|
configuration: Union([ApplicationConfigurationViewSchema, Null()]),
|
|
16998
17032
|
...observation
|
|
16999
17033
|
}, closed9),
|
|
17000
17034
|
migrations: _Object_({
|
|
17001
|
-
ledger_digest:
|
|
17035
|
+
ledger_digest: sha2563,
|
|
17002
17036
|
ledger_compatible: Boolean2(),
|
|
17003
17037
|
project_migrations_applied: Boolean2(),
|
|
17004
17038
|
pending_versions: _Array_(String2({ pattern: "^\\d{1,20}$" }), { maxItems: 4096, uniqueItems: true }),
|
|
@@ -17141,7 +17175,7 @@ var init_src = __esm(() => {
|
|
|
17141
17175
|
init_worker_execution();
|
|
17142
17176
|
init_application_activation();
|
|
17143
17177
|
init_application_deploy_plan();
|
|
17144
|
-
|
|
17178
|
+
init_application_deploy_operation();
|
|
17145
17179
|
init_application_history();
|
|
17146
17180
|
init_application_release();
|
|
17147
17181
|
init_application_preview();
|
|
@@ -17271,7 +17305,7 @@ var init_release_evidence = __esm(() => {
|
|
|
17271
17305
|
});
|
|
17272
17306
|
|
|
17273
17307
|
// src/release-evidence-cli.ts
|
|
17274
|
-
import { resolve as
|
|
17308
|
+
import { resolve as resolve23 } from "node:path";
|
|
17275
17309
|
async function runReleaseEvidenceCommand(args) {
|
|
17276
17310
|
try {
|
|
17277
17311
|
const values = new Map;
|
|
@@ -17295,7 +17329,7 @@ async function runReleaseEvidenceCommand(args) {
|
|
|
17295
17329
|
if (!manifest || !target || manifest.length > 4096 || !/^[a-z][a-z0-9-]{0,62}$/.test(target)) {
|
|
17296
17330
|
throw new ReleaseEvidenceError("RELEASE_EVIDENCE_INVALID");
|
|
17297
17331
|
}
|
|
17298
|
-
const evidence = await createReleaseEvidence(
|
|
17332
|
+
const evidence = await createReleaseEvidence(resolve23(manifest), target);
|
|
17299
17333
|
console.log(json ? JSON.stringify(evidence, null, 2) : formatReleaseEvidence(evidence));
|
|
17300
17334
|
} catch (error) {
|
|
17301
17335
|
console.error(`Error: ${error instanceof ReleaseEvidenceError ? error.code : "RELEASE_EVIDENCE_INVALID"}`);
|
|
@@ -17309,7 +17343,7 @@ var init_release_evidence_cli = __esm(() => {
|
|
|
17309
17343
|
// src/database-contracts.ts
|
|
17310
17344
|
import { createHash as createHash12 } from "node:crypto";
|
|
17311
17345
|
import { mkdir as mkdir5, readFile as readFile13 } from "node:fs/promises";
|
|
17312
|
-
import { dirname as dirname11, relative as relative12, resolve as
|
|
17346
|
+
import { dirname as dirname11, relative as relative12, resolve as resolve24 } from "node:path";
|
|
17313
17347
|
import * as ts18 from "@typescript/typescript6";
|
|
17314
17348
|
function hash3(value) {
|
|
17315
17349
|
return createHash12("sha256").update(value).digest("hex");
|
|
@@ -17337,18 +17371,18 @@ function parseDatabaseContractsOptions(value, directory) {
|
|
|
17337
17371
|
throw new TypeError("migrations must be an ordered list of SQL files");
|
|
17338
17372
|
}
|
|
17339
17373
|
return {
|
|
17340
|
-
rootDir:
|
|
17341
|
-
outDir:
|
|
17342
|
-
postgrestTypes:
|
|
17343
|
-
drizzleSchema:
|
|
17374
|
+
rootDir: resolve24(directory, field("rootDir")),
|
|
17375
|
+
outDir: resolve24(directory, field("outDir")),
|
|
17376
|
+
postgrestTypes: resolve24(directory, field("postgrestTypes")),
|
|
17377
|
+
drizzleSchema: resolve24(directory, field("drizzleSchema")),
|
|
17344
17378
|
role: field("role"),
|
|
17345
|
-
graphql: { ...graphql, schema:
|
|
17346
|
-
migrations: migrations.map((file) =>
|
|
17379
|
+
graphql: { ...graphql, schema: resolve24(directory, graphql.schema) },
|
|
17380
|
+
migrations: migrations.map((file) => resolve24(directory, file))
|
|
17347
17381
|
};
|
|
17348
17382
|
}
|
|
17349
17383
|
async function generateDatabaseContracts(options, check = false) {
|
|
17350
|
-
const rootDir =
|
|
17351
|
-
const postgrestTypes =
|
|
17384
|
+
const rootDir = resolve24(options.rootDir), outDir = resolve24(options.outDir);
|
|
17385
|
+
const postgrestTypes = resolve24(rootDir, options.postgrestTypes), drizzleSchema = resolve24(rootDir, options.drizzleSchema);
|
|
17352
17386
|
const snapshot = await readFile13(postgrestTypes, "utf8");
|
|
17353
17387
|
const syntax = ts18.createSourceFile(postgrestTypes, snapshot, ts18.ScriptTarget.Latest, true);
|
|
17354
17388
|
const database = syntax.statements.find((node) => (ts18.isTypeAliasDeclaration(node) || ts18.isInterfaceDeclaration(node)) && node.name.text === "Database" && node.modifiers?.some((modifier) => modifier.kind === ts18.SyntaxKind.ExportKeyword));
|
|
@@ -17376,7 +17410,7 @@ async function generateDatabaseContracts(options, check = false) {
|
|
|
17376
17410
|
}
|
|
17377
17411
|
const inputs = {};
|
|
17378
17412
|
const addInput = async (path) => {
|
|
17379
|
-
const absolute =
|
|
17413
|
+
const absolute = resolve24(rootDir, path);
|
|
17380
17414
|
inputs[relative12(rootDir, absolute).replaceAll("\\", "/")] = hash3(await readFile13(absolute, "utf8"));
|
|
17381
17415
|
};
|
|
17382
17416
|
await addInput(postgrestTypes);
|
|
@@ -17393,8 +17427,8 @@ async function generateDatabaseContracts(options, check = false) {
|
|
|
17393
17427
|
if (!source.isDeclarationFile && !source.fileName.includes("/node_modules/"))
|
|
17394
17428
|
await addInput(source.fileName);
|
|
17395
17429
|
}
|
|
17396
|
-
await addInput(
|
|
17397
|
-
if (new Set(options.migrations.map((path) =>
|
|
17430
|
+
await addInput(resolve24(rootDir, options.graphql.schema));
|
|
17431
|
+
if (new Set(options.migrations.map((path) => resolve24(rootDir, path))).size !== options.migrations.length) {
|
|
17398
17432
|
throw new Error("Duplicate migration in database contracts configuration");
|
|
17399
17433
|
}
|
|
17400
17434
|
for (const path of options.migrations)
|
|
@@ -17415,14 +17449,14 @@ async function generateDatabaseContracts(options, check = false) {
|
|
|
17415
17449
|
version: 1,
|
|
17416
17450
|
role: options.role,
|
|
17417
17451
|
inputs: Object.fromEntries(Object.entries(inputs).sort(([a], [b]) => a.localeCompare(b))),
|
|
17418
|
-
migrationOrder: options.migrations.map((path) => relative12(rootDir,
|
|
17452
|
+
migrationOrder: options.migrations.map((path) => relative12(rootDir, resolve24(rootDir, path)).replaceAll("\\", "/")),
|
|
17419
17453
|
outputs: Object.fromEntries(Object.entries(files).sort(([a], [b]) => a.localeCompare(b)).map(([file, text]) => [file, hash3(text)]))
|
|
17420
17454
|
};
|
|
17421
17455
|
files["database.manifest.json"] = JSON.stringify(manifest, null, 2) + `
|
|
17422
17456
|
`;
|
|
17423
17457
|
const mismatches = [];
|
|
17424
17458
|
for (const [file, content] of Object.entries(files)) {
|
|
17425
|
-
const path =
|
|
17459
|
+
const path = resolve24(outDir, file);
|
|
17426
17460
|
let current;
|
|
17427
17461
|
try {
|
|
17428
17462
|
current = await readFile13(path, "utf8");
|
|
@@ -17436,12 +17470,12 @@ async function generateDatabaseContracts(options, check = false) {
|
|
|
17436
17470
|
if (!check) {
|
|
17437
17471
|
await mkdir5(outDir, { recursive: true });
|
|
17438
17472
|
for (const [file, content] of Object.entries(files))
|
|
17439
|
-
await writeFileIfChanged(
|
|
17473
|
+
await writeFileIfChanged(resolve24(outDir, file), content);
|
|
17440
17474
|
}
|
|
17441
17475
|
return { upToDate: mismatches.length === 0, mismatches, written: check ? [] : mismatches, manifest };
|
|
17442
17476
|
}
|
|
17443
17477
|
async function runDatabaseContractsFile(path, check = false) {
|
|
17444
|
-
const absolute =
|
|
17478
|
+
const absolute = resolve24(path);
|
|
17445
17479
|
const value = JSON.parse(await readFile13(absolute, "utf8"));
|
|
17446
17480
|
return generateDatabaseContracts(parseDatabaseContractsOptions(value, dirname11(absolute)), check);
|
|
17447
17481
|
}
|
|
@@ -17453,7 +17487,7 @@ var init_database_contracts = __esm(() => {
|
|
|
17453
17487
|
|
|
17454
17488
|
// src/graphql-schema.ts
|
|
17455
17489
|
import { mkdir as mkdir6, readFile as readFile14 } from "node:fs/promises";
|
|
17456
|
-
import { dirname as dirname12, resolve as
|
|
17490
|
+
import { dirname as dirname12, resolve as resolve25 } from "node:path";
|
|
17457
17491
|
async function pullGraphqlSchema(options) {
|
|
17458
17492
|
assertGraphqlOptions({ schema: options.output });
|
|
17459
17493
|
const endpoint = new URL(options.url);
|
|
@@ -17493,7 +17527,7 @@ async function pullGraphqlSchema(options) {
|
|
|
17493
17527
|
throw new Error("GraphQL schema export failed. Verify caller grants and enable introspection only in the intended development environment.");
|
|
17494
17528
|
}
|
|
17495
17529
|
const schema = lexicographicSortSchema(buildClientSchema(data));
|
|
17496
|
-
const path =
|
|
17530
|
+
const path = resolve25(options.output);
|
|
17497
17531
|
const content = path.endsWith(".json") ? JSON.stringify(introspectionFromSchema(schema), null, 2) + `
|
|
17498
17532
|
` : `# GENERATED BY supacloud-compiler graphql-schema. DO NOT EDIT.
|
|
17499
17533
|
# Database First: change database declarations, apply migrations, then re-export for the intended role.
|
|
@@ -17521,7 +17555,7 @@ var init_graphql_schema = __esm(() => {
|
|
|
17521
17555
|
});
|
|
17522
17556
|
|
|
17523
17557
|
// src/cli.ts
|
|
17524
|
-
import { resolve as
|
|
17558
|
+
import { resolve as resolve26 } from "node:path";
|
|
17525
17559
|
import { readFile as readFile15 } from "node:fs/promises";
|
|
17526
17560
|
|
|
17527
17561
|
// src/analyze.ts
|
|
@@ -21666,6 +21700,52 @@ function validateEffectPolicies(graph, options = {}) {
|
|
|
21666
21700
|
return diagnostics;
|
|
21667
21701
|
}
|
|
21668
21702
|
|
|
21703
|
+
// src/database-governance.ts
|
|
21704
|
+
import { execFile } from "node:child_process";
|
|
21705
|
+
import { resolve as resolve5 } from "node:path";
|
|
21706
|
+
import { fileURLToPath } from "node:url";
|
|
21707
|
+
function assertDatabaseGovernance(value) {
|
|
21708
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
21709
|
+
throw new Error("Invalid databaseGovernance configuration.");
|
|
21710
|
+
const entry = value;
|
|
21711
|
+
if (entry["mode"] !== "off" && entry["mode"] !== "check" && entry["mode"] !== "enforce" || Object.keys(entry).some((key) => !["mode", "projectRoot", "moduleFile", "databaseUrl", "databaseUrlEnv", "schemas"].includes(key)) || ["projectRoot", "moduleFile", "databaseUrl", "databaseUrlEnv"].some((key) => entry[key] !== undefined && (typeof entry[key] !== "string" || !entry[key].trim())) || entry["databaseUrlEnv"] !== undefined && !/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(entry["databaseUrlEnv"])) || entry["schemas"] !== undefined && (!Array.isArray(entry["schemas"]) || !entry["schemas"].length || !entry["schemas"].every((schema) => typeof schema === "string" && schema.trim()))) {
|
|
21712
|
+
throw new Error("Invalid databaseGovernance mode, paths, connection or schemas.");
|
|
21713
|
+
}
|
|
21714
|
+
}
|
|
21715
|
+
async function checkDatabaseGovernance(rootDir, value) {
|
|
21716
|
+
if (value === undefined)
|
|
21717
|
+
return [];
|
|
21718
|
+
const failure = () => [{
|
|
21719
|
+
severity: "error",
|
|
21720
|
+
code: "database-governance",
|
|
21721
|
+
message: "Database governance could not be verified. Check configuration, installed @supacloud/db, Bun and read-only database access."
|
|
21722
|
+
}];
|
|
21723
|
+
try {
|
|
21724
|
+
assertDatabaseGovernance(value);
|
|
21725
|
+
if (value.mode === "off")
|
|
21726
|
+
return [];
|
|
21727
|
+
const options = { ...value, projectRoot: resolve5(rootDir, value.projectRoot ?? ".") };
|
|
21728
|
+
const worker = fileURLToPath(new URL(import.meta.url.endsWith(".ts") ? "./database-governance-worker.ts" : "./database-governance-worker.js", import.meta.url));
|
|
21729
|
+
const output = await new Promise((accept, reject) => {
|
|
21730
|
+
const child = execFile(process.versions.bun ? process.execPath : "bun", ["--no-env-file", worker], { timeout: 30000, killSignal: "SIGKILL", maxBuffer: 1024 * 1024 }, (error, stdout) => error ? reject(error) : accept(stdout));
|
|
21731
|
+
child.stdin?.on("error", reject);
|
|
21732
|
+
child.stdin?.end(JSON.stringify(options));
|
|
21733
|
+
});
|
|
21734
|
+
const report = JSON.parse(output);
|
|
21735
|
+
if (!report || typeof report !== "object" || !("diagnostics" in report) || !Array.isArray(report.diagnostics))
|
|
21736
|
+
return failure();
|
|
21737
|
+
const diagnostics = [];
|
|
21738
|
+
for (const item of report.diagnostics) {
|
|
21739
|
+
if (!item || typeof item !== "object" || !("code" in item) || typeof item.code !== "string" || !item.code.startsWith("database-") || !("message" in item) || typeof item.message !== "string" || !("severity" in item) || item.severity !== "error")
|
|
21740
|
+
return failure();
|
|
21741
|
+
diagnostics.push({ severity: "error", code: item.code, message: item.message });
|
|
21742
|
+
}
|
|
21743
|
+
return diagnostics;
|
|
21744
|
+
} catch {
|
|
21745
|
+
return failure();
|
|
21746
|
+
}
|
|
21747
|
+
}
|
|
21748
|
+
|
|
21669
21749
|
// src/compile.ts
|
|
21670
21750
|
function withDefaultGovernance(options) {
|
|
21671
21751
|
return options.commandCapabilities === undefined ? { ...options, commandCapabilities: {
|
|
@@ -21688,6 +21768,10 @@ async function compileProject(options) {
|
|
|
21688
21768
|
...validateClientSchemaBoundaries(graph, options),
|
|
21689
21769
|
...validateEffectPolicies(graph, options.effect)
|
|
21690
21770
|
];
|
|
21771
|
+
const databaseDiagnostics = await checkDatabaseGovernance(options.rootDir, options.databaseGovernance);
|
|
21772
|
+
diagnostics.push(...databaseDiagnostics);
|
|
21773
|
+
if (databaseDiagnostics.length)
|
|
21774
|
+
return { diagnostics, graph, written: [] };
|
|
21691
21775
|
if (diagnostics.some((item) => item.code === "runtime-injection-disallowed")) {
|
|
21692
21776
|
return { diagnostics, graph, written: [] };
|
|
21693
21777
|
}
|
|
@@ -21754,6 +21838,11 @@ async function checkProject(options) {
|
|
|
21754
21838
|
...validateClientSchemaBoundaries(graph, options),
|
|
21755
21839
|
...validateEffectPolicies(graph, options.effect)
|
|
21756
21840
|
];
|
|
21841
|
+
const databaseDiagnostics = await checkDatabaseGovernance(options.rootDir, options.databaseGovernance);
|
|
21842
|
+
diagnostics.push(...databaseDiagnostics);
|
|
21843
|
+
if (databaseDiagnostics.length) {
|
|
21844
|
+
return { diagnostics, graph, upToDate: false, mismatches: ["Database governance verification failed."] };
|
|
21845
|
+
}
|
|
21757
21846
|
if (diagnostics.some((item) => item.code === "runtime-injection-disallowed")) {
|
|
21758
21847
|
return { diagnostics, graph, upToDate: false, mismatches: ["Runtime DI must be migrated to constructor injection."] };
|
|
21759
21848
|
}
|
|
@@ -22086,12 +22175,12 @@ init_delivery_context();
|
|
|
22086
22175
|
|
|
22087
22176
|
// src/watch.ts
|
|
22088
22177
|
import { existsSync as existsSync4, watch } from "node:fs";
|
|
22089
|
-
import { dirname as dirname7, relative as relative8, resolve as
|
|
22178
|
+
import { dirname as dirname7, relative as relative8, resolve as resolve12, sep as sep8 } from "node:path";
|
|
22090
22179
|
|
|
22091
22180
|
// src/incremental.ts
|
|
22092
22181
|
import { createHash as createHash8 } from "node:crypto";
|
|
22093
22182
|
import { access as access3, readdir as readdir3, readFile as readFile4 } from "node:fs/promises";
|
|
22094
|
-
import { isAbsolute as isAbsolute3, relative as relative7, resolve as
|
|
22183
|
+
import { isAbsolute as isAbsolute3, relative as relative7, resolve as resolve11, sep as sep7 } from "node:path";
|
|
22095
22184
|
init_graphql_inputs();
|
|
22096
22185
|
function createDependencyGraphCache() {
|
|
22097
22186
|
return {
|
|
@@ -22160,11 +22249,11 @@ async function readSourceBytes(path) {
|
|
|
22160
22249
|
return readFile4(path);
|
|
22161
22250
|
}
|
|
22162
22251
|
async function updateSnapshot(previous, options, changedPaths) {
|
|
22163
|
-
const rootDir =
|
|
22164
|
-
const outDir =
|
|
22252
|
+
const rootDir = resolve11(options.rootDir);
|
|
22253
|
+
const outDir = resolve11(options.outDir);
|
|
22165
22254
|
const files = { ...previous.files };
|
|
22166
22255
|
await Promise.all(changedPaths.map(async (changedPath) => {
|
|
22167
|
-
const absolutePath = isAbsolute3(changedPath) ?
|
|
22256
|
+
const absolutePath = isAbsolute3(changedPath) ? resolve11(changedPath) : resolve11(rootDir, changedPath);
|
|
22168
22257
|
const relativeChangedPath = relative7(rootDir, absolutePath);
|
|
22169
22258
|
if (relativeChangedPath === ".." || relativeChangedPath.startsWith(`..${sep7}`))
|
|
22170
22259
|
return;
|
|
@@ -22182,8 +22271,8 @@ async function updateSnapshot(previous, options, changedPaths) {
|
|
|
22182
22271
|
return { files, optionsKey: optionsKeyOf(options) };
|
|
22183
22272
|
}
|
|
22184
22273
|
async function createSnapshot(options) {
|
|
22185
|
-
const rootDir =
|
|
22186
|
-
const outDir =
|
|
22274
|
+
const rootDir = resolve11(options.rootDir);
|
|
22275
|
+
const outDir = resolve11(options.outDir);
|
|
22187
22276
|
const paths = await listSourceFiles(rootDir, outDir);
|
|
22188
22277
|
const files = {};
|
|
22189
22278
|
const entries = await Promise.all(paths.map(async (path) => {
|
|
@@ -22206,8 +22295,8 @@ async function createSnapshot(options) {
|
|
|
22206
22295
|
}
|
|
22207
22296
|
function optionsKeyOf(options) {
|
|
22208
22297
|
return JSON.stringify({
|
|
22209
|
-
rootDir:
|
|
22210
|
-
outDir:
|
|
22298
|
+
rootDir: resolve11(options.rootDir),
|
|
22299
|
+
outDir: resolve11(options.outDir),
|
|
22211
22300
|
include: options.include,
|
|
22212
22301
|
strict: options.strict,
|
|
22213
22302
|
writeOnError: options.writeOnError,
|
|
@@ -22223,6 +22312,10 @@ function optionsKeyOf(options) {
|
|
|
22223
22312
|
openApi: options.openApi,
|
|
22224
22313
|
generatePermissions: options.generatePermissions,
|
|
22225
22314
|
typeSafety: options.typeSafety,
|
|
22315
|
+
databaseGovernance: options.databaseGovernance && {
|
|
22316
|
+
...options.databaseGovernance,
|
|
22317
|
+
databaseUrl: undefined
|
|
22318
|
+
},
|
|
22226
22319
|
effect: options.effect,
|
|
22227
22320
|
treeShakeUnusedProviders: options.treeShakeUnusedProviders,
|
|
22228
22321
|
graphql: options.graphql
|
|
@@ -22232,7 +22325,7 @@ async function listSourceFiles(rootDir, outDir) {
|
|
|
22232
22325
|
const result = [];
|
|
22233
22326
|
const visit = async (directory) => {
|
|
22234
22327
|
for (const entry of await readdir3(directory, { withFileTypes: true })) {
|
|
22235
|
-
const path =
|
|
22328
|
+
const path = resolve11(directory, entry.name);
|
|
22236
22329
|
if (entry.isDirectory()) {
|
|
22237
22330
|
if (entry.name === "node_modules" || entry.name === ".git" || path === outDir)
|
|
22238
22331
|
continue;
|
|
@@ -22367,8 +22460,8 @@ function isCompilerConfigurationPath(rootDir, changedPath) {
|
|
|
22367
22460
|
].includes(relativePath) || /^tsconfig\.[^/]+\.json$/.test(relativePath);
|
|
22368
22461
|
}
|
|
22369
22462
|
function watchProject(options) {
|
|
22370
|
-
const rootDir =
|
|
22371
|
-
const outDir =
|
|
22463
|
+
const rootDir = resolve12(options.rootDir);
|
|
22464
|
+
const outDir = resolve12(options.outDir);
|
|
22372
22465
|
const debounceMs = options.debounceMs ?? DEFAULT_DEBOUNCE_MS;
|
|
22373
22466
|
let timer;
|
|
22374
22467
|
let closed = false;
|
|
@@ -22378,7 +22471,9 @@ function watchProject(options) {
|
|
|
22378
22471
|
const pendingPaths = new Set;
|
|
22379
22472
|
let watcher;
|
|
22380
22473
|
let schemaWatcher;
|
|
22381
|
-
|
|
22474
|
+
let databaseWatcher;
|
|
22475
|
+
const databaseRoot = options.databaseGovernance && options.databaseGovernance.mode !== "off" ? resolve12(rootDir, options.databaseGovernance.projectRoot ?? ".") : undefined;
|
|
22476
|
+
const schemaPath = options.graphql ? resolve12(rootDir, options.graphql.schema) : undefined;
|
|
22382
22477
|
const incremental = createIncrementalCompiler();
|
|
22383
22478
|
let initialEvent;
|
|
22384
22479
|
let resolveReady = () => {
|
|
@@ -22405,6 +22500,7 @@ function watchProject(options) {
|
|
|
22405
22500
|
clearTimeout(timer);
|
|
22406
22501
|
watcher?.close();
|
|
22407
22502
|
schemaWatcher?.close();
|
|
22503
|
+
databaseWatcher?.close();
|
|
22408
22504
|
};
|
|
22409
22505
|
const compile = (initial, changedPaths = []) => {
|
|
22410
22506
|
if (closed && !initial)
|
|
@@ -22479,6 +22575,13 @@ function watchProject(options) {
|
|
|
22479
22575
|
startRecompile(paths);
|
|
22480
22576
|
}, debounceMs);
|
|
22481
22577
|
};
|
|
22578
|
+
const isDatabaseInput = (path) => {
|
|
22579
|
+
if (!databaseRoot)
|
|
22580
|
+
return false;
|
|
22581
|
+
const local = relative8(databaseRoot, path);
|
|
22582
|
+
const output = relative8(outDir, path);
|
|
22583
|
+
return local !== ".." && !local.startsWith(`..${sep8}`) && output !== "" && (output === ".." || output.startsWith(`..${sep8}`)) && !local.split(sep8).some((part) => ["node_modules", ".git", ".wt", ".worktrees", "dist", "output"].includes(part)) && /\.(?:sql|json|[cm]?[jt]s)$/.test(path);
|
|
22584
|
+
};
|
|
22482
22585
|
const startup = compile(true).then(() => {
|
|
22483
22586
|
if (closed) {
|
|
22484
22587
|
if (initialEvent)
|
|
@@ -22488,20 +22591,27 @@ function watchProject(options) {
|
|
|
22488
22591
|
watcher = watch(rootDir, { recursive: true }, (_eventType, filename) => {
|
|
22489
22592
|
if (!filename)
|
|
22490
22593
|
return schedule();
|
|
22491
|
-
const changedPath =
|
|
22594
|
+
const changedPath = resolve12(rootDir, filename.toString());
|
|
22492
22595
|
const relativePath = relative8(outDir, changedPath);
|
|
22493
22596
|
if (!relativePath.startsWith("..") && relativePath !== "")
|
|
22494
22597
|
return;
|
|
22495
|
-
if (/\.(tsx?|mts|cts)$/.test(changedPath) || isCompilerConfigurationPath(rootDir, changedPath) || options.graphql && (/\.(graphql|gql)$/.test(changedPath) || changedPath === schemaPath)) {
|
|
22598
|
+
if (/\.(tsx?|mts|cts)$/.test(changedPath) || isCompilerConfigurationPath(rootDir, changedPath) || isDatabaseInput(changedPath) || options.graphql && (/\.(graphql|gql)$/.test(changedPath) || changedPath === schemaPath)) {
|
|
22496
22599
|
schedule(relative8(rootDir, changedPath));
|
|
22497
22600
|
}
|
|
22498
22601
|
});
|
|
22602
|
+
if (databaseRoot && databaseRoot !== rootDir) {
|
|
22603
|
+
databaseWatcher = watch(databaseRoot, { recursive: true }, (_eventType, filename) => {
|
|
22604
|
+
const path = filename ? resolve12(databaseRoot, filename.toString()) : undefined;
|
|
22605
|
+
if (!path || isDatabaseInput(path))
|
|
22606
|
+
schedule(path);
|
|
22607
|
+
});
|
|
22608
|
+
}
|
|
22499
22609
|
if (schemaPath && relative8(rootDir, schemaPath).startsWith(`..${sep8}`)) {
|
|
22500
22610
|
let directory = dirname7(schemaPath);
|
|
22501
22611
|
while (!existsSync4(directory) && dirname7(directory) !== directory)
|
|
22502
22612
|
directory = dirname7(directory);
|
|
22503
22613
|
schemaWatcher = watch(directory, { recursive: true }, (_eventType, filename) => {
|
|
22504
|
-
if (!filename ||
|
|
22614
|
+
if (!filename || resolve12(directory, filename.toString()) === schemaPath)
|
|
22505
22615
|
schedule(schemaPath);
|
|
22506
22616
|
});
|
|
22507
22617
|
}
|
|
@@ -22526,7 +22636,7 @@ function watchProject(options) {
|
|
|
22526
22636
|
// src/config.ts
|
|
22527
22637
|
init_graphql_options();
|
|
22528
22638
|
import { existsSync as existsSync5 } from "node:fs";
|
|
22529
|
-
import { join as join8, resolve as
|
|
22639
|
+
import { join as join8, resolve as resolve13 } from "node:path";
|
|
22530
22640
|
import { pathToFileURL } from "node:url";
|
|
22531
22641
|
|
|
22532
22642
|
// src/delivery-schema.ts
|
|
@@ -22534,6 +22644,7 @@ init_delivery_schema();
|
|
|
22534
22644
|
|
|
22535
22645
|
// src/config.ts
|
|
22536
22646
|
var DEFAULT_SUPACLOUD_CONFIG = {
|
|
22647
|
+
databaseGovernance: { mode: "off" },
|
|
22537
22648
|
graphql: false,
|
|
22538
22649
|
root: "src",
|
|
22539
22650
|
outDir: "generated",
|
|
@@ -22564,6 +22675,8 @@ var DEFAULT_SUPACLOUD_CONFIG = {
|
|
|
22564
22675
|
}
|
|
22565
22676
|
};
|
|
22566
22677
|
function defineSupacloudConfig(config = {}) {
|
|
22678
|
+
if (config.databaseGovernance !== undefined)
|
|
22679
|
+
assertDatabaseGovernance(config.databaseGovernance);
|
|
22567
22680
|
if (config.delivery !== undefined)
|
|
22568
22681
|
parseDeliveryOptions(config.delivery);
|
|
22569
22682
|
if (config.graphql !== undefined && config.graphql !== false)
|
|
@@ -22663,8 +22776,8 @@ function validateGovernanceConfig(config) {
|
|
|
22663
22776
|
function resolveSupacloudConfig(config = {}, cwd = process.cwd()) {
|
|
22664
22777
|
const resolved = defineSupacloudConfig(config);
|
|
22665
22778
|
return {
|
|
22666
|
-
rootDir:
|
|
22667
|
-
outDir:
|
|
22779
|
+
rootDir: resolve13(cwd, resolved.root ?? DEFAULT_SUPACLOUD_CONFIG.root),
|
|
22780
|
+
outDir: resolve13(cwd, resolved.outDir ?? DEFAULT_SUPACLOUD_CONFIG.outDir),
|
|
22668
22781
|
include: resolved.include ?? [...DEFAULT_SUPACLOUD_CONFIG.include],
|
|
22669
22782
|
strict: resolved.strict ?? DEFAULT_SUPACLOUD_CONFIG.strict,
|
|
22670
22783
|
requireRouteContracts: resolved.requireRouteContracts ?? DEFAULT_SUPACLOUD_CONFIG.requireRouteContracts,
|
|
@@ -22676,6 +22789,12 @@ function resolveSupacloudConfig(config = {}, cwd = process.cwd()) {
|
|
|
22676
22789
|
commandCapabilities: resolved.commandCapabilities ?? DEFAULT_SUPACLOUD_CONFIG.commandCapabilities,
|
|
22677
22790
|
...resolved.moduleBoundaries ? { moduleBoundaries: resolved.moduleBoundaries } : {},
|
|
22678
22791
|
...resolved.typeSafety ? { typeSafety: resolved.typeSafety } : {},
|
|
22792
|
+
...resolved.databaseGovernance === undefined ? {} : {
|
|
22793
|
+
databaseGovernance: {
|
|
22794
|
+
...resolved.databaseGovernance,
|
|
22795
|
+
projectRoot: resolve13(cwd, resolved.databaseGovernance.projectRoot ?? ".")
|
|
22796
|
+
}
|
|
22797
|
+
},
|
|
22679
22798
|
...resolved.allowRouteCommandBindings === undefined ? {} : { allowRouteCommandBindings: resolved.allowRouteCommandBindings },
|
|
22680
22799
|
...resolved.disallowControllerDirectDb === undefined ? {} : { disallowControllerDirectDb: resolved.disallowControllerDirectDb },
|
|
22681
22800
|
...resolved.detectOrphanModules === undefined ? {} : { detectOrphanModules: resolved.detectOrphanModules },
|
|
@@ -22683,7 +22802,7 @@ function resolveSupacloudConfig(config = {}, cwd = process.cwd()) {
|
|
|
22683
22802
|
treeShakeUnusedProviders: resolved.treeShakeUnusedProviders ?? DEFAULT_SUPACLOUD_CONFIG.treeShakeUnusedProviders,
|
|
22684
22803
|
...resolved.graphql === undefined || resolved.graphql === false ? {} : { graphql: {
|
|
22685
22804
|
...resolved.graphql,
|
|
22686
|
-
schema:
|
|
22805
|
+
schema: resolve13(cwd, resolved.graphql.schema)
|
|
22687
22806
|
} }
|
|
22688
22807
|
};
|
|
22689
22808
|
}
|
|
@@ -23011,7 +23130,7 @@ function formatDeliveryPlan(result) {
|
|
|
23011
23130
|
// src/delivery-build.ts
|
|
23012
23131
|
import { mkdir as mkdir3, mkdtemp, readFile as readFile7, realpath as realpath4, rename as rename4, rm as rm2 } from "node:fs/promises";
|
|
23013
23132
|
import { readFileSync as readFileSync3 } from "node:fs";
|
|
23014
|
-
import { dirname as dirname9, join as join10, relative as relative10, resolve as
|
|
23133
|
+
import { dirname as dirname9, join as join10, relative as relative10, resolve as resolve17, sep as sep10 } from "node:path";
|
|
23015
23134
|
import * as ts16 from "@typescript/typescript6";
|
|
23016
23135
|
|
|
23017
23136
|
// src/delivery-build-schema.ts
|
|
@@ -23053,7 +23172,7 @@ function renderDeliveryTarget(graph, target, options) {
|
|
|
23053
23172
|
init_delivery_files2();
|
|
23054
23173
|
import { isBuiltin } from "node:module";
|
|
23055
23174
|
import { readFile as readFile6 } from "node:fs/promises";
|
|
23056
|
-
import { join as join9, resolve as
|
|
23175
|
+
import { join as join9, resolve as resolve15 } from "node:path";
|
|
23057
23176
|
import * as ts15 from "@typescript/typescript6";
|
|
23058
23177
|
|
|
23059
23178
|
// src/delivery-imports.ts
|
|
@@ -23230,7 +23349,7 @@ async function bundleDeliveryTarget(name, code, project, generatedDirectory, opt
|
|
|
23230
23349
|
async function bundleDeliveryTargetInProcess(name, code, project, generatedDirectory, options) {
|
|
23231
23350
|
const inputs = new Map;
|
|
23232
23351
|
const workingDirectory = process.cwd();
|
|
23233
|
-
const entry =
|
|
23352
|
+
const entry = resolve15(generatedDirectory, `delivery-${name}.ts`);
|
|
23234
23353
|
const entryPattern = new RegExp(`^${entry.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`);
|
|
23235
23354
|
const result = await Bun.build({
|
|
23236
23355
|
entrypoints: [entry],
|
|
@@ -23253,7 +23372,7 @@ async function bundleDeliveryTargetInProcess(name, code, project, generatedDirec
|
|
|
23253
23372
|
if (args.path === entry)
|
|
23254
23373
|
return { contents: code, loader: "ts" };
|
|
23255
23374
|
const bytes = await readFile6(args.path);
|
|
23256
|
-
inputs.set(
|
|
23375
|
+
inputs.set(resolve15(args.path), digest(bytes));
|
|
23257
23376
|
return { contents: staticDeliveryImports(args.path, bytes), loader: args.loader };
|
|
23258
23377
|
});
|
|
23259
23378
|
}
|
|
@@ -23263,7 +23382,7 @@ async function bundleDeliveryTargetInProcess(name, code, project, generatedDirec
|
|
|
23263
23382
|
throw new Error("Independent bundle failed or has no dependency metadata.");
|
|
23264
23383
|
const runtimeImports = new Set;
|
|
23265
23384
|
for (const [path, metadata] of Object.entries(result.metafile.inputs)) {
|
|
23266
|
-
if (
|
|
23385
|
+
if (resolve15(workingDirectory, path) !== entry && !inputs.has(resolve15(workingDirectory, path))) {
|
|
23267
23386
|
throw new Error("Bundler reported an input that was not captured by the delivery snapshot.");
|
|
23268
23387
|
}
|
|
23269
23388
|
for (const imported of metadata.imports) {
|
|
@@ -23602,14 +23721,14 @@ interface DeliveryWorkerHost {
|
|
|
23602
23721
|
|
|
23603
23722
|
// src/delivery-migrations.ts
|
|
23604
23723
|
init_delivery_files2();
|
|
23605
|
-
import { resolve as
|
|
23724
|
+
import { resolve as resolve16 } from "node:path";
|
|
23606
23725
|
async function prepareDeliveryMigrations(project, generatedRoot, declarations = []) {
|
|
23607
23726
|
const entries = [];
|
|
23608
23727
|
const files = new Map;
|
|
23609
23728
|
const inputs = new Map;
|
|
23610
23729
|
let totalBytes = 0;
|
|
23611
23730
|
for (const declaration of [...declarations].sort((a, b) => BigInt(a.version) < BigInt(b.version) ? -1 : BigInt(a.version) > BigInt(b.version) ? 1 : 0)) {
|
|
23612
|
-
const source =
|
|
23731
|
+
const source = resolve16(project, declaration.source);
|
|
23613
23732
|
if (!inside(project, source) || inside(generatedRoot, source))
|
|
23614
23733
|
throw new Error("Invalid migration source.");
|
|
23615
23734
|
const bytes = await readBoundedOwned(project, source, 1048576);
|
|
@@ -23660,7 +23779,7 @@ async function buildDeliveryProject(options, delivery) {
|
|
|
23660
23779
|
const settings = parseDeliveryOptions(delivery);
|
|
23661
23780
|
if (typeof Bun === "undefined")
|
|
23662
23781
|
throw new Error("Independent delivery builds require Bun.");
|
|
23663
|
-
const configPath = ts16.findConfigFile(
|
|
23782
|
+
const configPath = ts16.findConfigFile(resolve17(options.rootDir), ts16.sys.fileExists);
|
|
23664
23783
|
if (!configPath)
|
|
23665
23784
|
throw new Error("Independent delivery builds require a project tsconfig.json.");
|
|
23666
23785
|
const lexicalProject = dirname9(configPath);
|
|
@@ -23668,11 +23787,11 @@ async function buildDeliveryProject(options, delivery) {
|
|
|
23668
23787
|
const sourceRoot = await realpath4(options.rootDir);
|
|
23669
23788
|
if (!inside(project, sourceRoot))
|
|
23670
23789
|
throw new Error("Application sources must be inside the project.");
|
|
23671
|
-
const requested =
|
|
23790
|
+
const requested = resolve17(options.outDir, "delivery");
|
|
23672
23791
|
if (!inside(lexicalProject, requested))
|
|
23673
23792
|
throw new Error("Output must be inside the application project.");
|
|
23674
|
-
const buildRoot =
|
|
23675
|
-
const generatedRoot =
|
|
23793
|
+
const buildRoot = resolve17(project, relative10(lexicalProject, requested));
|
|
23794
|
+
const generatedRoot = resolve17(project, relative10(lexicalProject, options.outDir));
|
|
23676
23795
|
if (inside(generatedRoot, sourceRoot))
|
|
23677
23796
|
throw new Error("Output must not contain the application source root.");
|
|
23678
23797
|
const configInputs = new Map;
|
|
@@ -23680,7 +23799,7 @@ async function buildDeliveryProject(options, delivery) {
|
|
|
23680
23799
|
...ts16.sys,
|
|
23681
23800
|
readFile(path) {
|
|
23682
23801
|
const contents = readFileSync3(path, "utf8");
|
|
23683
|
-
configInputs.set(
|
|
23802
|
+
configInputs.set(resolve17(path), digest(contents));
|
|
23684
23803
|
return contents;
|
|
23685
23804
|
},
|
|
23686
23805
|
onUnRecoverableConfigFileDiagnostic() {
|
|
@@ -23718,7 +23837,7 @@ async function buildDeliveryProject(options, delivery) {
|
|
|
23718
23837
|
if (!target || (kind === "worker" ? target.kind !== "jobs" : target.kind === "jobs")) {
|
|
23719
23838
|
throw new Error("Delivery host kind does not match its target.");
|
|
23720
23839
|
}
|
|
23721
|
-
const path =
|
|
23840
|
+
const path = resolve17(sourceRoot, app.source);
|
|
23722
23841
|
if (inside(generatedRoot, path) || !/\.[cm]?ts$/.test(path))
|
|
23723
23842
|
throw new Error("Hosts require application TypeScript source.");
|
|
23724
23843
|
hosts.set(app.target, { path, kind, hash: digest(await readOwned(sourceRoot, path)) });
|
|
@@ -23845,7 +23964,7 @@ async function buildDeliveryProject(options, delivery) {
|
|
|
23845
23964
|
}));
|
|
23846
23965
|
const assetInputs = {};
|
|
23847
23966
|
for (const asset of assets.filter((asset) => asset.target === target.name)) {
|
|
23848
|
-
const path =
|
|
23967
|
+
const path = resolve17(sourceRoot, asset.source);
|
|
23849
23968
|
const bytes = await readOwned(sourceRoot, path);
|
|
23850
23969
|
const hash = digest(bytes);
|
|
23851
23970
|
const previousHash = snapshots.get(path);
|
|
@@ -23955,19 +24074,19 @@ async function buildDeliveryProject(options, delivery) {
|
|
|
23955
24074
|
|
|
23956
24075
|
// src/migrations.ts
|
|
23957
24076
|
import { rename as rename5, readFile as readFile9, writeFile as writeFile4, rm as rm3 } from "node:fs/promises";
|
|
23958
|
-
import { relative as relative11, resolve as
|
|
24077
|
+
import { relative as relative11, resolve as resolve19 } from "node:path";
|
|
23959
24078
|
import * as ts17 from "@typescript/typescript6";
|
|
23960
24079
|
|
|
23961
24080
|
// src/migration-policy.ts
|
|
23962
24081
|
import { readFile as readFile8 } from "node:fs/promises";
|
|
23963
24082
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
23964
|
-
import { resolve as
|
|
24083
|
+
import { resolve as resolve18 } from "node:path";
|
|
23965
24084
|
|
|
23966
24085
|
// src/migration-app-version.ts
|
|
23967
|
-
var MIGRATION_APP_VERSION = "0.26.
|
|
24086
|
+
var MIGRATION_APP_VERSION = "0.26.1";
|
|
23968
24087
|
|
|
23969
24088
|
// src/migration-elysia-version.ts
|
|
23970
|
-
var MIGRATION_ELYSIA_VERSION = "0.29.
|
|
24089
|
+
var MIGRATION_ELYSIA_VERSION = "0.29.2";
|
|
23971
24090
|
|
|
23972
24091
|
// src/migration-policy.ts
|
|
23973
24092
|
var cachedCompilerVersion;
|
|
@@ -23994,7 +24113,7 @@ async function checkMigrationDependencies(rootDir) {
|
|
|
23994
24113
|
const problems = [];
|
|
23995
24114
|
for (const [name, expected] of Object.entries(migrationDependencies())) {
|
|
23996
24115
|
try {
|
|
23997
|
-
const manifest = JSON.parse(await readFile8(
|
|
24116
|
+
const manifest = JSON.parse(await readFile8(resolve18(rootDir, "node_modules", name, "package.json"), "utf8"));
|
|
23998
24117
|
if (!manifest || typeof manifest !== "object" || !("name" in manifest) || manifest.name !== name || !("version" in manifest) || manifest.version !== expected) {
|
|
23999
24118
|
problems.push(`${name}: requires tested installed version ${expected}`);
|
|
24000
24119
|
}
|
|
@@ -24109,10 +24228,10 @@ function createMigrationProgram(fileNames, sourceOverrides, rootDir) {
|
|
|
24109
24228
|
const fileExists = host.fileExists.bind(host);
|
|
24110
24229
|
const readFile = host.readFile.bind(host);
|
|
24111
24230
|
const currentDirectory = host.getCurrentDirectory.bind(host);
|
|
24112
|
-
host.fileExists = (fileName) => sourceOverrides.has(
|
|
24113
|
-
host.readFile = (fileName) => sourceOverrides.get(
|
|
24231
|
+
host.fileExists = (fileName) => sourceOverrides.has(resolve19(fileName)) || fileExists(fileName);
|
|
24232
|
+
host.readFile = (fileName) => sourceOverrides.get(resolve19(fileName)) ?? readFile(fileName);
|
|
24114
24233
|
host.getSourceFile = (fileName, languageVersion, onError, shouldCreateNewSourceFile) => {
|
|
24115
|
-
const source = sourceOverrides.get(
|
|
24234
|
+
const source = sourceOverrides.get(resolve19(fileName));
|
|
24116
24235
|
return source === undefined ? getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) : ts17.createSourceFile(fileName, source, languageVersion, true);
|
|
24117
24236
|
};
|
|
24118
24237
|
host.getCurrentDirectory = () => rootDir ?? currentDirectory();
|
|
@@ -24138,7 +24257,7 @@ function planRouteResponseMigration(sourceFiles, checker, rootDir, includedFiles
|
|
|
24138
24257
|
issues.push(issue);
|
|
24139
24258
|
};
|
|
24140
24259
|
for (const sourceFile of sourceFiles) {
|
|
24141
|
-
const sourcePath =
|
|
24260
|
+
const sourcePath = resolve19(sourceFile.fileName);
|
|
24142
24261
|
if (!includedFiles.has(sourcePath))
|
|
24143
24262
|
continue;
|
|
24144
24263
|
const visit = (node) => {
|
|
@@ -24146,7 +24265,7 @@ function planRouteResponseMigration(sourceFiles, checker, rootDir, includedFiles
|
|
|
24146
24265
|
const options = node.arguments[1];
|
|
24147
24266
|
const object = options && resolveStaticObjectLiteral2(options, checker);
|
|
24148
24267
|
if (object) {
|
|
24149
|
-
const objectPath =
|
|
24268
|
+
const objectPath = resolve19(object.getSourceFile().fileName);
|
|
24150
24269
|
const properties = routeResponseProperties(object);
|
|
24151
24270
|
if (properties.response) {
|
|
24152
24271
|
if (!includedFiles.has(objectPath)) {
|
|
@@ -24189,13 +24308,13 @@ function planRouteResponseMigration(sourceFiles, checker, rootDir, includedFiles
|
|
|
24189
24308
|
line: lineOf2(sourceFile, response)
|
|
24190
24309
|
});
|
|
24191
24310
|
} else {
|
|
24192
|
-
const replacements = replacementsByFile.get(
|
|
24311
|
+
const replacements = replacementsByFile.get(resolve19(sourceFile.fileName)) ?? [];
|
|
24193
24312
|
replacements.push({
|
|
24194
24313
|
start: response.getStart(sourceFile),
|
|
24195
24314
|
end: response.getEnd(),
|
|
24196
24315
|
text: `responses: { 200: ${response.initializer.getText(sourceFile)} }`
|
|
24197
24316
|
});
|
|
24198
|
-
replacementsByFile.set(
|
|
24317
|
+
replacementsByFile.set(resolve19(sourceFile.fileName), replacements);
|
|
24199
24318
|
}
|
|
24200
24319
|
}
|
|
24201
24320
|
return { replacementsByFile, issues };
|
|
@@ -24208,7 +24327,7 @@ function applyReplacements(source, replacements) {
|
|
|
24208
24327
|
return content;
|
|
24209
24328
|
}
|
|
24210
24329
|
function migrateRouteResponse(source, fileName) {
|
|
24211
|
-
const absoluteFile =
|
|
24330
|
+
const absoluteFile = resolve19(fileName);
|
|
24212
24331
|
const sourceOverrides = new Map([[absoluteFile, source]]);
|
|
24213
24332
|
const program = createMigrationProgram([absoluteFile], sourceOverrides);
|
|
24214
24333
|
const sourceFile = program.getSourceFile(absoluteFile);
|
|
@@ -24224,7 +24343,7 @@ function migrateRouteResponse(source, fileName) {
|
|
|
24224
24343
|
}]
|
|
24225
24344
|
};
|
|
24226
24345
|
}
|
|
24227
|
-
const plan = planRouteResponseMigration([sourceFile], program.getTypeChecker(),
|
|
24346
|
+
const plan = planRouteResponseMigration([sourceFile], program.getTypeChecker(), resolve19("."), new Set([absoluteFile]));
|
|
24228
24347
|
const replacements = plan.replacementsByFile.get(absoluteFile) ?? [];
|
|
24229
24348
|
return {
|
|
24230
24349
|
changed: replacements.length > 0,
|
|
@@ -24234,7 +24353,7 @@ function migrateRouteResponse(source, fileName) {
|
|
|
24234
24353
|
};
|
|
24235
24354
|
}
|
|
24236
24355
|
function migrateRouteResponseProject(files, rootDir, sourceByPath) {
|
|
24237
|
-
const absoluteFiles = files.map((file) =>
|
|
24356
|
+
const absoluteFiles = files.map((file) => resolve19(file));
|
|
24238
24357
|
const program = createMigrationProgram(absoluteFiles, sourceByPath, rootDir);
|
|
24239
24358
|
const sourceFiles = absoluteFiles.map((file) => program.getSourceFile(file)).filter((file) => file !== undefined);
|
|
24240
24359
|
const plan = planRouteResponseMigration(sourceFiles, program.getTypeChecker(), rootDir, new Set(absoluteFiles));
|
|
@@ -24247,11 +24366,11 @@ function migrateRouteResponseProject(files, rootDir, sourceByPath) {
|
|
|
24247
24366
|
changed: replacements.length > 0,
|
|
24248
24367
|
content: applyReplacements(source, replacements),
|
|
24249
24368
|
replacements: replacements.length,
|
|
24250
|
-
issues: plan.issues.filter((issue) =>
|
|
24369
|
+
issues: plan.issues.filter((issue) => resolve19(rootDir, issue.file) === file)
|
|
24251
24370
|
});
|
|
24252
24371
|
}
|
|
24253
24372
|
for (const issue of plan.issues) {
|
|
24254
|
-
const path =
|
|
24373
|
+
const path = resolve19(rootDir, issue.file);
|
|
24255
24374
|
if (!results.has(path) && sourceByPath.has(path)) {
|
|
24256
24375
|
results.set(path, {
|
|
24257
24376
|
changed: false,
|
|
@@ -24289,7 +24408,7 @@ async function writeAtomically(path, content) {
|
|
|
24289
24408
|
}
|
|
24290
24409
|
}
|
|
24291
24410
|
async function migrateProject(options) {
|
|
24292
|
-
const rootDir =
|
|
24411
|
+
const rootDir = resolve19(options.rootDir);
|
|
24293
24412
|
let migrations = SUPACLOUD_MIGRATIONS;
|
|
24294
24413
|
const preflightIssues = [];
|
|
24295
24414
|
if (options.fromVersion !== undefined || options.toVersion !== undefined) {
|
|
@@ -24345,7 +24464,7 @@ async function migrateProject(options) {
|
|
|
24345
24464
|
}
|
|
24346
24465
|
};
|
|
24347
24466
|
for (const filePath of files) {
|
|
24348
|
-
sourceByPath.set(
|
|
24467
|
+
sourceByPath.set(resolve19(filePath), await readFile9(filePath, "utf8"));
|
|
24349
24468
|
}
|
|
24350
24469
|
const originalSources = new Map(sourceByPath);
|
|
24351
24470
|
const writtenFiles = new Set;
|
|
@@ -24354,7 +24473,7 @@ async function migrateProject(options) {
|
|
|
24354
24473
|
if (projectResults)
|
|
24355
24474
|
appendIssues(projectResults.issues);
|
|
24356
24475
|
for (const filePath of files) {
|
|
24357
|
-
const absoluteFile =
|
|
24476
|
+
const absoluteFile = resolve19(filePath);
|
|
24358
24477
|
const file = relative11(rootDir, absoluteFile) || absoluteFile;
|
|
24359
24478
|
const before = sourceByPath.get(absoluteFile);
|
|
24360
24479
|
if (before === undefined)
|
|
@@ -24416,11 +24535,11 @@ async function migrateProject(options) {
|
|
|
24416
24535
|
// src/migration-assess.ts
|
|
24417
24536
|
import { createHash as createHash11 } from "node:crypto";
|
|
24418
24537
|
import { readFile as readFile11 } from "node:fs/promises";
|
|
24419
|
-
import { join as join11, resolve as
|
|
24538
|
+
import { join as join11, resolve as resolve21 } from "node:path";
|
|
24420
24539
|
|
|
24421
24540
|
// src/openapi-tools.ts
|
|
24422
24541
|
import { mkdir as mkdir4, readFile as readFile10, rename as rename6, unlink as unlink3, writeFile as writeFile5 } from "node:fs/promises";
|
|
24423
|
-
import { dirname as dirname10, resolve as
|
|
24542
|
+
import { dirname as dirname10, resolve as resolve20 } from "node:path";
|
|
24424
24543
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
24425
24544
|
|
|
24426
24545
|
class OpenApiDocumentError extends Error {
|
|
@@ -24811,7 +24930,7 @@ function serializeOpenApiJson(document, space = 2) {
|
|
|
24811
24930
|
}
|
|
24812
24931
|
async function readOpenApiJson(path) {
|
|
24813
24932
|
try {
|
|
24814
|
-
const value = JSON.parse(await readFile10(
|
|
24933
|
+
const value = JSON.parse(await readFile10(resolve20(path), "utf8"));
|
|
24815
24934
|
return parseOpenApiDocument(value);
|
|
24816
24935
|
} catch (error) {
|
|
24817
24936
|
if (error instanceof OpenApiDocumentError)
|
|
@@ -24820,7 +24939,7 @@ async function readOpenApiJson(path) {
|
|
|
24820
24939
|
}
|
|
24821
24940
|
}
|
|
24822
24941
|
async function writeOpenApiJson(document, outputPath, space = 2) {
|
|
24823
|
-
const path =
|
|
24942
|
+
const path = resolve20(outputPath);
|
|
24824
24943
|
const content = serializeOpenApiJson(document, space);
|
|
24825
24944
|
await mkdir4(dirname10(path), { recursive: true });
|
|
24826
24945
|
try {
|
|
@@ -24841,7 +24960,7 @@ async function writeOpenApiJson(document, outputPath, space = 2) {
|
|
|
24841
24960
|
}
|
|
24842
24961
|
async function loadGeneratedOpenApiDocument(modulePath) {
|
|
24843
24962
|
try {
|
|
24844
|
-
const moduleUrl = pathToFileURL2(
|
|
24963
|
+
const moduleUrl = pathToFileURL2(resolve20(modulePath));
|
|
24845
24964
|
moduleUrl.searchParams.set("supacloud-openapi-export", "1");
|
|
24846
24965
|
const loaded = await import(moduleUrl.href);
|
|
24847
24966
|
if (!isRecord(loaded))
|
|
@@ -24937,18 +25056,18 @@ function isRecord2(value) {
|
|
|
24937
25056
|
function arrayLength(value) {
|
|
24938
25057
|
return Array.isArray(value) ? value.length : undefined;
|
|
24939
25058
|
}
|
|
24940
|
-
async function
|
|
25059
|
+
async function sha2564(path) {
|
|
24941
25060
|
return createHash11("sha256").update(await readFile11(path)).digest("hex");
|
|
24942
25061
|
}
|
|
24943
25062
|
function overallStatus(findings) {
|
|
24944
25063
|
return findings.reduce((current, finding) => STATUS_PRIORITY[finding.status] > STATUS_PRIORITY[current] ? finding.status : current, "compatible");
|
|
24945
25064
|
}
|
|
24946
25065
|
async function assessMigration(options) {
|
|
24947
|
-
const projectDir =
|
|
25066
|
+
const projectDir = resolve21(options.projectDir);
|
|
24948
25067
|
const compile = {
|
|
24949
25068
|
...options.compile,
|
|
24950
|
-
rootDir:
|
|
24951
|
-
outDir:
|
|
25069
|
+
rootDir: resolve21(options.compile.rootDir),
|
|
25070
|
+
outDir: resolve21(options.compile.outDir)
|
|
24952
25071
|
};
|
|
24953
25072
|
const findings = [];
|
|
24954
25073
|
const dependencyProblems = await checkMigrationDependencies(projectDir);
|
|
@@ -25014,7 +25133,7 @@ async function assessMigration(options) {
|
|
|
25014
25133
|
contractsManifest = {
|
|
25015
25134
|
path: contractsManifestPath,
|
|
25016
25135
|
present: true,
|
|
25017
|
-
sha256: await
|
|
25136
|
+
sha256: await sha2564(contractsManifestPath),
|
|
25018
25137
|
version: 1,
|
|
25019
25138
|
...commands === undefined ? {} : { commands },
|
|
25020
25139
|
...routes === undefined ? {} : { routes },
|
|
@@ -25031,15 +25150,15 @@ async function assessMigration(options) {
|
|
|
25031
25150
|
}
|
|
25032
25151
|
let openApi;
|
|
25033
25152
|
if (options.baselineOpenApiPath && options.currentOpenApiPath) {
|
|
25034
|
-
const baselinePath =
|
|
25035
|
-
const currentPath =
|
|
25153
|
+
const baselinePath = resolve21(projectDir, options.baselineOpenApiPath);
|
|
25154
|
+
const currentPath = resolve21(projectDir, options.currentOpenApiPath);
|
|
25036
25155
|
try {
|
|
25037
25156
|
const diff = diffOpenApiDocuments(await readOpenApiJson(baselinePath), await readOpenApiJson(currentPath));
|
|
25038
25157
|
openApi = {
|
|
25039
25158
|
baselinePath,
|
|
25040
|
-
baselineSha256: await
|
|
25159
|
+
baselineSha256: await sha2564(baselinePath),
|
|
25041
25160
|
currentPath,
|
|
25042
|
-
currentSha256: await
|
|
25161
|
+
currentSha256: await sha2564(currentPath),
|
|
25043
25162
|
diff
|
|
25044
25163
|
};
|
|
25045
25164
|
if (!diff.ok) {
|
|
@@ -25115,7 +25234,7 @@ function formatMigrationAssessment(result) {
|
|
|
25115
25234
|
// src/graphql-governance.ts
|
|
25116
25235
|
init_graphql_schema_hashes();
|
|
25117
25236
|
import { readFile as readFile12 } from "node:fs/promises";
|
|
25118
|
-
import { resolve as
|
|
25237
|
+
import { resolve as resolve22 } from "node:path";
|
|
25119
25238
|
import {
|
|
25120
25239
|
buildClientSchema as buildClientSchema2,
|
|
25121
25240
|
buildSchema as buildSchema2,
|
|
@@ -25135,7 +25254,7 @@ function schemaFromSource(source, path = "schema.graphql") {
|
|
|
25135
25254
|
return buildSchema2(source);
|
|
25136
25255
|
}
|
|
25137
25256
|
async function readGraphqlSchema(path) {
|
|
25138
|
-
const absolute =
|
|
25257
|
+
const absolute = resolve22(path);
|
|
25139
25258
|
const source = await readFile12(absolute, "utf8");
|
|
25140
25259
|
const hashes = graphqlSchemaHashes(source);
|
|
25141
25260
|
return { path: absolute, source, schema: schemaFromSource(source, absolute), ...hashes };
|
|
@@ -25495,11 +25614,11 @@ async function runGraphqlGovernanceCommand(args) {
|
|
|
25495
25614
|
if (!schemaPath || documentPaths.length === 0)
|
|
25496
25615
|
throw new Error("graphql compatibility requires --schema and at least one --documents");
|
|
25497
25616
|
const schema = await readGraphqlSchema(schemaPath);
|
|
25498
|
-
const documents = await Promise.all(documentPaths.map(async (path) => ({ path, source: await readFile15(
|
|
25617
|
+
const documents = await Promise.all(documentPaths.map(async (path) => ({ path, source: await readFile15(resolve26(path), "utf8") })));
|
|
25499
25618
|
let policy = {};
|
|
25500
25619
|
const policyPath = one("--policy");
|
|
25501
25620
|
if (policyPath)
|
|
25502
|
-
policy = JSON.parse(await readFile15(
|
|
25621
|
+
policy = JSON.parse(await readFile15(resolve26(policyPath), "utf8"));
|
|
25503
25622
|
const report = checkGraphqlCompatibility(schema.schema, documents, policy);
|
|
25504
25623
|
const result = {
|
|
25505
25624
|
ok: report.ok,
|
|
@@ -25535,7 +25654,7 @@ async function runGraphqlGovernanceCommand(args) {
|
|
|
25535
25654
|
throw new Error("--role must use name=schema");
|
|
25536
25655
|
const role = value.slice(0, separator);
|
|
25537
25656
|
const path = value.slice(separator + 1);
|
|
25538
|
-
return { role, path, source: await readFile15(
|
|
25657
|
+
return { role, path, source: await readFile15(resolve26(path), "utf8") };
|
|
25539
25658
|
}));
|
|
25540
25659
|
const result = createRoleSnapshotReport(roles);
|
|
25541
25660
|
console.log(JSON.stringify(result, null, 2));
|
|
@@ -25805,7 +25924,7 @@ async function run() {
|
|
|
25805
25924
|
throw new Error("Build context requires a manifest, target, subject, events, request ID and --json");
|
|
25806
25925
|
}
|
|
25807
25926
|
try {
|
|
25808
|
-
const pack = await createDeliveryExecutionContextPack(contextManifest, contextTarget, query, await readExecutionMetadata(
|
|
25927
|
+
const pack = await createDeliveryExecutionContextPack(contextManifest, contextTarget, query, await readExecutionMetadata(resolve26(executionEventsPath)), executionRequestId);
|
|
25809
25928
|
console.log(JSON.stringify(pack, null, 2));
|
|
25810
25929
|
} catch (error) {
|
|
25811
25930
|
console.log(JSON.stringify({
|
|
@@ -25824,7 +25943,7 @@ async function run() {
|
|
|
25824
25943
|
const currentPath = openApiDiffPaths[1];
|
|
25825
25944
|
if (!basePath || !currentPath)
|
|
25826
25945
|
throw new Error("openapi-diff requires two JSON file paths");
|
|
25827
|
-
const result = diffOpenApiDocuments(await readOpenApiJson(
|
|
25946
|
+
const result = diffOpenApiDocuments(await readOpenApiJson(resolve26(process.cwd(), basePath)), await readOpenApiJson(resolve26(process.cwd(), currentPath)));
|
|
25828
25947
|
console.log(json ? JSON.stringify(result, null, 2) : formatOpenApiDiff(result));
|
|
25829
25948
|
if (!result.ok)
|
|
25830
25949
|
process.exitCode = 1;
|
|
@@ -25839,8 +25958,8 @@ async function run() {
|
|
|
25839
25958
|
if (!modulePath || !outputPath)
|
|
25840
25959
|
throw new Error("openapi-export requires an OpenAPI module and output path");
|
|
25841
25960
|
const result = await exportGeneratedOpenApiJson({
|
|
25842
|
-
modulePath:
|
|
25843
|
-
outputPath:
|
|
25961
|
+
modulePath: resolve26(process.cwd(), modulePath),
|
|
25962
|
+
outputPath: resolve26(process.cwd(), outputPath),
|
|
25844
25963
|
...openApiExportSpace === undefined ? {} : { space: openApiExportSpace }
|
|
25845
25964
|
});
|
|
25846
25965
|
console.log(json ? JSON.stringify({ ok: true, ...result }, null, 2) : result.written ? `OpenAPI JSON written: ${result.path}` : `OpenAPI JSON matches: ${result.path}`);
|
|
@@ -25848,7 +25967,7 @@ async function run() {
|
|
|
25848
25967
|
}
|
|
25849
25968
|
if (command === "migrate") {
|
|
25850
25969
|
const result = await migrateProject({
|
|
25851
|
-
rootDir: rootDir ?
|
|
25970
|
+
rootDir: rootDir ? resolve26(process.cwd(), rootDir) : process.cwd(),
|
|
25852
25971
|
write: !dryRun,
|
|
25853
25972
|
...fromVersion === undefined ? {} : { fromVersion },
|
|
25854
25973
|
...toVersion === undefined ? {} : { toVersion }
|
|
@@ -25886,8 +26005,8 @@ async function run() {
|
|
|
25886
26005
|
if (checkSchema && command !== "graphql-schema")
|
|
25887
26006
|
throw new Error("--check is only supported by graphql-schema");
|
|
25888
26007
|
const defaults = resolveSupacloudConfig(loadedConfig, process.cwd());
|
|
25889
|
-
const resolvedRoot = rootDir ?
|
|
25890
|
-
const resolvedOut = outDir ?
|
|
26008
|
+
const resolvedRoot = rootDir ? resolve26(process.cwd(), rootDir) : defaults.rootDir;
|
|
26009
|
+
const resolvedOut = outDir ? resolve26(process.cwd(), outDir) : defaults.outDir;
|
|
25891
26010
|
const configured = compileOptionsFromConfig({
|
|
25892
26011
|
...loadedConfig,
|
|
25893
26012
|
root: resolvedRoot,
|
|
@@ -25906,7 +26025,7 @@ async function run() {
|
|
|
25906
26025
|
let delivery = loadedConfig.delivery;
|
|
25907
26026
|
if (deliveryPath !== undefined) {
|
|
25908
26027
|
try {
|
|
25909
|
-
delivery = JSON.parse(await readFile15(
|
|
26028
|
+
delivery = JSON.parse(await readFile15(resolve26(process.cwd(), deliveryPath), "utf8"));
|
|
25910
26029
|
} catch {
|
|
25911
26030
|
throw new DeliveryConfigurationError;
|
|
25912
26031
|
}
|
|
@@ -25964,7 +26083,7 @@ ${item.suggestion ?? ""}`).join(`
|
|
|
25964
26083
|
} else if (command === "fix") {
|
|
25965
26084
|
if (!query)
|
|
25966
26085
|
throw new Error("fix requires a JSON file containing one DiagnosticFix");
|
|
25967
|
-
const input = JSON.parse(await readFile15(
|
|
26086
|
+
const input = JSON.parse(await readFile15(resolve26(process.cwd(), query), "utf8"));
|
|
25968
26087
|
const envelope = input && typeof input === "object" && "fix" in input;
|
|
25969
26088
|
if (envelope && (typeof input.expectedSourceHash !== "string" || !/^[a-f0-9]{64}$/.test(input.expectedSourceHash))) {
|
|
25970
26089
|
throw new Error("Editor fix requires the source hash from its validated preview");
|
|
@@ -26105,7 +26224,7 @@ Source change detected; compiling...`);
|
|
|
26105
26224
|
process.exitCode = 1;
|
|
26106
26225
|
return;
|
|
26107
26226
|
}
|
|
26108
|
-
const file =
|
|
26227
|
+
const file = resolve26(rootDir ? resolve26(process.cwd(), rootDir) : process.cwd(), bindingsFile ?? "supacloud.environments.json");
|
|
26109
26228
|
try {
|
|
26110
26229
|
const document = await readEnvironmentBindingsFile(file);
|
|
26111
26230
|
const graph = await analyzeProject(resolvedRoot);
|
|
@@ -26140,7 +26259,7 @@ Source change detected; compiling...`);
|
|
|
26140
26259
|
try {
|
|
26141
26260
|
const result = await checkProject(compileDefaults);
|
|
26142
26261
|
if (executionEventsPath && executionRequestId) {
|
|
26143
|
-
const pack = createExecutionContextPack({ ...result.graph, diagnostics: result.diagnostics }, query, await readExecutionMetadata(
|
|
26262
|
+
const pack = createExecutionContextPack({ ...result.graph, diagnostics: result.diagnostics }, query, await readExecutionMetadata(resolve26(process.cwd(), executionEventsPath)), executionRequestId);
|
|
26144
26263
|
console.log(JSON.stringify(pack, null, 2));
|
|
26145
26264
|
return;
|
|
26146
26265
|
}
|