alchemy 2.0.0-beta.66 → 2.0.0-beta.67
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/bin/exec.js +145 -43
- package/bin/exec.js.map +1 -1
- package/lib/Cli/commands/_shared.d.ts.map +1 -1
- package/lib/Cli/commands/_shared.js +2 -1
- package/lib/Cli/commands/_shared.js.map +1 -1
- package/lib/Cloudflare/D1/Database.d.ts +1 -1
- package/lib/Cloudflare/D1/Database.d.ts.map +1 -1
- package/lib/Cloudflare/D1/Database.js +3 -3
- package/lib/Cloudflare/D1/Database.js.map +1 -1
- package/lib/Cloudflare/DNS/Record.d.ts +3 -1
- package/lib/Cloudflare/DNS/Record.d.ts.map +1 -1
- package/lib/Cloudflare/DNS/Record.js +23 -4
- package/lib/Cloudflare/DNS/Record.js.map +1 -1
- package/lib/Prisma/App.d.ts +16 -3
- package/lib/Prisma/App.d.ts.map +1 -1
- package/lib/Prisma/App.js +16 -3
- package/lib/Prisma/App.js.map +1 -1
- package/lib/Prisma/Branch.d.ts +21 -0
- package/lib/Prisma/Branch.d.ts.map +1 -1
- package/lib/Prisma/Branch.js +20 -0
- package/lib/Prisma/Branch.js.map +1 -1
- package/lib/Prisma/Compute.d.ts +6 -4
- package/lib/Prisma/Compute.d.ts.map +1 -1
- package/lib/Prisma/Compute.js +6 -4
- package/lib/Prisma/Compute.js.map +1 -1
- package/lib/Prisma/Connect.d.ts +23 -0
- package/lib/Prisma/Connect.d.ts.map +1 -1
- package/lib/Prisma/Connect.js.map +1 -1
- package/lib/Prisma/Connection.d.ts +23 -6
- package/lib/Prisma/Connection.d.ts.map +1 -1
- package/lib/Prisma/Connection.js +19 -5
- package/lib/Prisma/Connection.js.map +1 -1
- package/lib/Prisma/CustomDomain.d.ts +11 -1
- package/lib/Prisma/CustomDomain.d.ts.map +1 -1
- package/lib/Prisma/CustomDomain.js +9 -0
- package/lib/Prisma/CustomDomain.js.map +1 -1
- package/lib/Prisma/Database.d.ts +18 -4
- package/lib/Prisma/Database.d.ts.map +1 -1
- package/lib/Prisma/Database.js +15 -2
- package/lib/Prisma/Database.js.map +1 -1
- package/lib/Prisma/Deployment.d.ts +8 -2
- package/lib/Prisma/Deployment.d.ts.map +1 -1
- package/lib/Prisma/Deployment.js +6 -1
- package/lib/Prisma/Deployment.js.map +1 -1
- package/lib/Prisma/EnvironmentVariable.d.ts +20 -4
- package/lib/Prisma/EnvironmentVariable.d.ts.map +1 -1
- package/lib/Prisma/EnvironmentVariable.js +20 -4
- package/lib/Prisma/EnvironmentVariable.js.map +1 -1
- package/lib/Prisma/Postgres.d.ts +3 -2
- package/lib/Prisma/Postgres.d.ts.map +1 -1
- package/lib/Prisma/Postgres.js +3 -2
- package/lib/Prisma/Postgres.js.map +1 -1
- package/lib/Prisma/Project.d.ts +8 -2
- package/lib/Prisma/Project.d.ts.map +1 -1
- package/lib/Prisma/Project.js +5 -0
- package/lib/Prisma/Project.js.map +1 -1
- package/lib/Prisma/Providers.d.ts +5 -3
- package/lib/Prisma/Providers.d.ts.map +1 -1
- package/lib/Prisma/Providers.js +31 -7
- package/lib/Prisma/Providers.js.map +1 -1
- package/lib/Prisma/SourceRepository.d.ts +24 -1
- package/lib/Prisma/SourceRepository.d.ts.map +1 -1
- package/lib/Prisma/SourceRepository.js +18 -0
- package/lib/Prisma/SourceRepository.js.map +1 -1
- package/package.json +1 -1
- package/src/Cli/commands/_shared.ts +2 -0
- package/src/Cloudflare/D1/Database.ts +18 -3
- package/src/Cloudflare/DNS/Record.ts +30 -4
- package/src/Prisma/App.ts +16 -3
- package/src/Prisma/Branch.ts +21 -0
- package/src/Prisma/Compute.ts +6 -4
- package/src/Prisma/Connect.ts +23 -0
- package/src/Prisma/Connection.ts +23 -6
- package/src/Prisma/CustomDomain.ts +11 -1
- package/src/Prisma/Database.ts +18 -4
- package/src/Prisma/Deployment.ts +8 -2
- package/src/Prisma/EnvironmentVariable.ts +20 -4
- package/src/Prisma/Postgres.ts +3 -2
- package/src/Prisma/Project.ts +8 -2
- package/src/Prisma/Providers.ts +67 -7
- package/src/Prisma/SourceRepository.ts +24 -1
package/bin/exec.js
CHANGED
|
@@ -709,7 +709,7 @@ var init_Output = __esm({ "lib/Output.js": (() => {
|
|
|
709
709
|
return `stackRef(${this.stack}${this.stage ? `, { stage: ${this.stage} }` : ""})`;
|
|
710
710
|
}
|
|
711
711
|
};
|
|
712
|
-
stackRef = (stack, options$
|
|
712
|
+
stackRef = (stack, options$7 = {}) => Effect.succeed(new StackRefExpr(stack, options$7.stage));
|
|
713
713
|
MissingSourceError = class extends Data.TaggedError("MissingSourceError") {};
|
|
714
714
|
InvalidReferenceError = class extends Data.TaggedError("InvalidReferenceError") {};
|
|
715
715
|
evaluate = (expr, upstream$1) => Effect.gen(function* () {
|
|
@@ -874,9 +874,9 @@ var init_PlatformServices = __esm({ "lib/Util/PlatformServices.js": (() => {
|
|
|
874
874
|
return Layer.merge(NodeServices.layer, NodeSocket.layerWebSocketConstructor);
|
|
875
875
|
}
|
|
876
876
|
});
|
|
877
|
-
runMain = (effect, options$
|
|
878
|
-
if (isBun) import("@effect/platform-bun/BunRuntime").then((BunRuntime) => BunRuntime.runMain(effect, options$
|
|
879
|
-
else import("@effect/platform-node/NodeRuntime").then((NodeRuntime) => NodeRuntime.runMain(effect, options$
|
|
877
|
+
runMain = (effect, options$7) => {
|
|
878
|
+
if (isBun) import("@effect/platform-bun/BunRuntime").then((BunRuntime) => BunRuntime.runMain(effect, options$7));
|
|
879
|
+
else import("@effect/platform-node/NodeRuntime").then((NodeRuntime) => NodeRuntime.runMain(effect, options$7));
|
|
880
880
|
};
|
|
881
881
|
}) });
|
|
882
882
|
|
|
@@ -891,31 +891,31 @@ var init_Stack = __esm({ "lib/Stack.js": (() => {
|
|
|
891
891
|
init_effect();
|
|
892
892
|
init_FileLogger();
|
|
893
893
|
init_PlatformServices();
|
|
894
|
-
Stack = Object.assign(taggedFunction(EffectContext.Service()("Stack"), (stackName, options$
|
|
894
|
+
Stack = Object.assign(taggedFunction(EffectContext.Service()("Stack"), (stackName, options$7, eff) => {
|
|
895
895
|
if (!stackName) return (stackName$1) => Object.assign(stackRef(stackName$1).pipe(effectClass), {
|
|
896
896
|
stackName: stackName$1,
|
|
897
897
|
stage: createStageProxy(stackName$1),
|
|
898
|
-
state: options$
|
|
899
|
-
providers: options$
|
|
900
|
-
make: (options$
|
|
898
|
+
state: options$7?.state,
|
|
899
|
+
providers: options$7?.providers,
|
|
900
|
+
make: (options$8, eff$1) => Stack(stackName$1, options$8, eff$1)
|
|
901
901
|
});
|
|
902
902
|
return eff.pipe(make$2({
|
|
903
903
|
name: stackName,
|
|
904
|
-
...options$
|
|
904
|
+
...options$7
|
|
905
905
|
}), (eff$1) => Object.assign(eff$1, {
|
|
906
906
|
stackName,
|
|
907
907
|
stage: createStageProxy(stackName),
|
|
908
|
-
state: options$
|
|
909
|
-
providers: options$
|
|
908
|
+
state: options$7?.state,
|
|
909
|
+
providers: options$7?.providers
|
|
910
910
|
}));
|
|
911
911
|
}));
|
|
912
912
|
createStageProxy = (stackName) => new Proxy({}, { get: (_, stage$1) => stackRef(stackName, { stage: stage$1 }) });
|
|
913
913
|
StackName = Stack.use((stack) => Effect.succeed(stack.name));
|
|
914
|
-
make$2 = (options$
|
|
915
|
-
if (options$
|
|
916
|
-
if (options$
|
|
917
|
-
return options$
|
|
918
|
-
name: options$
|
|
914
|
+
make$2 = (options$7) => (effect) => Effect.scope.pipe(Effect.flatMap((scope) => {
|
|
915
|
+
if (options$7.state == null) return Effect.die(/* @__PURE__ */ new Error(`Stack "${options$7.name}" is missing a state store. Add a \`state\` layer to the stack options, e.g.:\n Alchemy.Stack("${options$7.name}", {\n providers: Cloudflare.providers(),\n state: Cloudflare.state(), // <-- required\n }, ...)\nSee https://alchemy.run/state-store for available state stores.`));
|
|
916
|
+
if (options$7.providers == null) return Effect.die(/* @__PURE__ */ new Error(`Stack "${options$7.name}" is missing a providers layer. Add a \`providers\` layer to the stack options, e.g.:\n Alchemy.Stack("${options$7.name}", {\n providers: Cloudflare.providers(), // <-- required\n state: Cloudflare.state(),\n }, ...)`));
|
|
917
|
+
return options$7.providers.pipe(Layer.provideMerge(options$7.state), Layer.provideMerge(Layer.effect(Stack, Stage.pipe(Effect.map((stage$1) => options$7.stack ?? {
|
|
918
|
+
name: options$7.name,
|
|
919
919
|
stage: stage$1,
|
|
920
920
|
resources: {},
|
|
921
921
|
bindings: {},
|
|
@@ -1338,7 +1338,7 @@ init_Provider();
|
|
|
1338
1338
|
init_ProviderMode();
|
|
1339
1339
|
init_Resource();
|
|
1340
1340
|
init_sha256();
|
|
1341
|
-
const make = (stack, options$
|
|
1341
|
+
const make = (stack, options$7 = {}) => Effect.gen(function* () {
|
|
1342
1342
|
const state = yield* yield* State;
|
|
1343
1343
|
const resources = Object.values(stack.resources);
|
|
1344
1344
|
const actions = Object.values(stack.actions ?? {});
|
|
@@ -1422,7 +1422,7 @@ const make = (stack, options$6 = {}) => Effect.gen(function* () {
|
|
|
1422
1422
|
if (havePropsChanged(oldProps, props)) return withStables(oldState?.attr);
|
|
1423
1423
|
} else if (diff.action === "update") return withStables(oldState?.attr);
|
|
1424
1424
|
else if (diff.action === "replace") return resourceExpr;
|
|
1425
|
-
if (options$
|
|
1425
|
+
if (options$7.force) return withStables(oldState?.attr);
|
|
1426
1426
|
if (oldState.status === "created" || oldState.status === "updated" || oldState.status === "replaced") return oldState?.attr;
|
|
1427
1427
|
else return resourceExpr;
|
|
1428
1428
|
}));
|
|
@@ -1626,7 +1626,7 @@ const make = (stack, options$6 = {}) => Effect.gen(function* () {
|
|
|
1626
1626
|
news,
|
|
1627
1627
|
oldBindings,
|
|
1628
1628
|
newBindings
|
|
1629
|
-
}).pipe(providePlanScope(fqn, oldState.instanceId))).pipe(Effect.map((diff$1) => diff$1 ?? { action: havePropsChanged(oldProps, news) || bindingDiffs.some((b) => b.action !== "noop") ? "update" : "noop" }), Effect.map((diff$1) => options$
|
|
1629
|
+
}).pipe(providePlanScope(fqn, oldState.instanceId))).pipe(Effect.map((diff$1) => diff$1 ?? { action: havePropsChanged(oldProps, news) || bindingDiffs.some((b) => b.action !== "noop") ? "update" : "noop" }), Effect.map((diff$1) => options$7.force && diff$1.action === "noop" ? { action: "update" } : diff$1), Effect.map((diff$1) => forceUpdateAfterAdoption && diff$1.action === "noop" ? { action: "update" } : diff$1));
|
|
1630
1630
|
if (oldState.status === "creating") if (diff.action === "noop") return Node({
|
|
1631
1631
|
action: "create",
|
|
1632
1632
|
props: news,
|
|
@@ -1736,7 +1736,7 @@ const make = (stack, options$6 = {}) => Effect.gen(function* () {
|
|
|
1736
1736
|
forced: false
|
|
1737
1737
|
}];
|
|
1738
1738
|
const prior = oldState;
|
|
1739
|
-
if (prior?.status === "ran" && prior.inputHash === inputHash && !options$
|
|
1739
|
+
if (prior?.status === "ran" && prior.inputHash === inputHash && !options$7.force) return [fqn, {
|
|
1740
1740
|
kind: "action",
|
|
1741
1741
|
action: "noop",
|
|
1742
1742
|
def: action,
|
|
@@ -1750,7 +1750,7 @@ const make = (stack, options$6 = {}) => Effect.gen(function* () {
|
|
|
1750
1750
|
input: action.Input,
|
|
1751
1751
|
state: prior,
|
|
1752
1752
|
downstream,
|
|
1753
|
-
forced: !!options$
|
|
1753
|
+
forced: !!options$7.force
|
|
1754
1754
|
}];
|
|
1755
1755
|
})), { concurrency: "unbounded" }));
|
|
1756
1756
|
const cycleMembers = combinedCycleMembers;
|
|
@@ -1877,7 +1877,7 @@ const make = (stack, options$6 = {}) => Effect.gen(function* () {
|
|
|
1877
1877
|
"alchemy.stack": stack.name,
|
|
1878
1878
|
"alchemy.stage": stack.stage,
|
|
1879
1879
|
"alchemy.resources.count": Object.keys(stack.resources).length,
|
|
1880
|
-
"alchemy.force": !!options$
|
|
1880
|
+
"alchemy.force": !!options$7.force
|
|
1881
1881
|
} }));
|
|
1882
1882
|
/**
|
|
1883
1883
|
* Build the plan that destroys every resource of `(stack.name, stack.stage)`.
|
|
@@ -3048,7 +3048,7 @@ const fromEnvironment = Layer.effect(Region.Region, Effect.gen(function* () {
|
|
|
3048
3048
|
init_AuthProvider();
|
|
3049
3049
|
init_Credentials();
|
|
3050
3050
|
const AWS_AUTH_PROVIDER_NAME = "AWS";
|
|
3051
|
-
const options$
|
|
3051
|
+
const options$6 = [
|
|
3052
3052
|
{
|
|
3053
3053
|
value: "sso",
|
|
3054
3054
|
label: "SSO",
|
|
@@ -3123,7 +3123,7 @@ const AwsAuth = AuthProviderLayer()(AWS_AUTH_PROVIDER_NAME, Effect.gen(function*
|
|
|
3123
3123
|
});
|
|
3124
3124
|
const configureInteractive = (profileName) => select({
|
|
3125
3125
|
message: "AWS authentication method",
|
|
3126
|
-
options: options$
|
|
3126
|
+
options: options$6
|
|
3127
3127
|
}).pipe(Effect.flatMap((method) => Match.value(method).pipe(Match.when("env", () => Effect.succeed({ method: "env" })), Match.when("sso", () => Effect.gen(function* () {
|
|
3128
3128
|
const config = {
|
|
3129
3129
|
method: "sso",
|
|
@@ -3270,7 +3270,7 @@ const clearDistilledSsoCache = (ssoProfile) => Effect.gen(function* () {
|
|
|
3270
3270
|
init_AuthProvider();
|
|
3271
3271
|
init_Credentials();
|
|
3272
3272
|
const STORAGE_KEY = "axiom-stored";
|
|
3273
|
-
const options$
|
|
3273
|
+
const options$5 = [{
|
|
3274
3274
|
value: "env",
|
|
3275
3275
|
label: "Environment Variables",
|
|
3276
3276
|
hint: "AXIOM_TOKEN (or AXIOM_API_KEY) + optional AXIOM_ORG_ID, AXIOM_URL"
|
|
@@ -3350,7 +3350,7 @@ const AxiomAuth = AuthProviderLayer()(AXIOM_AUTH_PROVIDER_NAME, Effect.gen(funct
|
|
|
3350
3350
|
});
|
|
3351
3351
|
const configureInteractive = (profileName) => select({
|
|
3352
3352
|
message: "Axiom authentication method",
|
|
3353
|
-
options: options$
|
|
3353
|
+
options: options$5
|
|
3354
3354
|
}).pipe(Effect.flatMap((method) => Match.value(method).pipe(Match.when("env", () => Effect.succeed({ method: "env" })), Match.when("stored", () => loginStored(profileName)), Match.exhaustive)));
|
|
3355
3355
|
const configureCredentials = (profileName, ctx) => Effect.gen(function* () {
|
|
3356
3356
|
if (ctx.ci) return { method: "env" };
|
|
@@ -3693,7 +3693,7 @@ function callbackPromise$1(authorization, signal) {
|
|
|
3693
3693
|
//#region lib/Cloudflare/Auth/AuthProvider.js
|
|
3694
3694
|
init_AuthProvider();
|
|
3695
3695
|
init_Credentials();
|
|
3696
|
-
const options$
|
|
3696
|
+
const options$4 = [
|
|
3697
3697
|
{
|
|
3698
3698
|
value: "oauth",
|
|
3699
3699
|
label: "OAuth",
|
|
@@ -3854,7 +3854,7 @@ const CloudflareAuth = AuthProviderLayer()(CLOUDFLARE_AUTH_PROVIDER_NAME, Effect
|
|
|
3854
3854
|
});
|
|
3855
3855
|
const configureInteractive = (profileName) => select({
|
|
3856
3856
|
message: "Cloudflare authentication method",
|
|
3857
|
-
options: options$
|
|
3857
|
+
options: options$4
|
|
3858
3858
|
}).pipe(Effect.flatMap((method) => Match.value(method).pipe(Match.when("env", () => Effect.succeed({ method: "env" })), Match.when("oauth", () => configureOAuth(profileName)), Match.when("stored", () => loginStored(profileName)), Match.exhaustive)));
|
|
3859
3859
|
const configureCredentials = (profileName, ctx) => Effect.gen(function* () {
|
|
3860
3860
|
const config = ctx.ci ? { method: "env" } : yield* configureInteractive(profileName);
|
|
@@ -4130,7 +4130,7 @@ const resolveGitHubBaseUrlFromEnv = Effect.gen(function* () {
|
|
|
4130
4130
|
//#region lib/GitHub/AuthProvider.js
|
|
4131
4131
|
init_AuthProvider();
|
|
4132
4132
|
init_Credentials();
|
|
4133
|
-
const options$
|
|
4133
|
+
const options$3 = [
|
|
4134
4134
|
{
|
|
4135
4135
|
value: "gh-cli",
|
|
4136
4136
|
label: "GitHub CLI",
|
|
@@ -4231,7 +4231,7 @@ const makeGitHubAuth = (authOptions) => AuthProviderLayer()(GITHUB_AUTH_PROVIDER
|
|
|
4231
4231
|
const configureInteractive = (profileName) => Effect.gen(function* () {
|
|
4232
4232
|
const method = yield* select({
|
|
4233
4233
|
message: "GitHub authentication method",
|
|
4234
|
-
options: options$
|
|
4234
|
+
options: options$3
|
|
4235
4235
|
});
|
|
4236
4236
|
const baseUrl = fixed !== void 0 ? void 0 : yield* promptBaseUrl;
|
|
4237
4237
|
const verifyHost = fixed !== void 0 ? fixed.baseUrl : baseUrl;
|
|
@@ -4307,7 +4307,7 @@ init_AuthProvider();
|
|
|
4307
4307
|
init_Credentials();
|
|
4308
4308
|
init_Profile();
|
|
4309
4309
|
const NEON_AUTH_PROVIDER_NAME = "Neon";
|
|
4310
|
-
const options$
|
|
4310
|
+
const options$2 = [{
|
|
4311
4311
|
value: "env",
|
|
4312
4312
|
label: "Environment Variable",
|
|
4313
4313
|
hint: "NEON_API_KEY"
|
|
@@ -4337,7 +4337,7 @@ const NeonAuth = AuthProviderLayer()(NEON_AUTH_PROVIDER_NAME, Effect.gen(functio
|
|
|
4337
4337
|
});
|
|
4338
4338
|
const configureInteractive = (profileName) => select({
|
|
4339
4339
|
message: "Neon authentication method",
|
|
4340
|
-
options: options$
|
|
4340
|
+
options: options$2
|
|
4341
4341
|
}).pipe(Effect.flatMap((method) => Match.value(method).pipe(Match.when("env", () => Effect.succeed({ method: "env" })), Match.when("stored", () => loginStored(profileName)), Match.exhaustive)));
|
|
4342
4342
|
const configureCredentials = (profileName, ctx) => Effect.gen(function* () {
|
|
4343
4343
|
if (ctx.ci) return { method: "env" };
|
|
@@ -4680,7 +4680,7 @@ const selectOrganization = (accessToken) => Effect.gen(function* () {
|
|
|
4680
4680
|
}))
|
|
4681
4681
|
}).pipe(retryOnce);
|
|
4682
4682
|
}).pipe((e) => withOAuthCredentials(accessToken, e));
|
|
4683
|
-
const options = [
|
|
4683
|
+
const options$1 = [
|
|
4684
4684
|
{
|
|
4685
4685
|
value: "env",
|
|
4686
4686
|
label: "Environment Variables",
|
|
@@ -4762,7 +4762,7 @@ const PlanetscaleAuth = AuthProviderLayer()(PLANETSCALE_AUTH_PROVIDER_NAME, Effe
|
|
|
4762
4762
|
});
|
|
4763
4763
|
const configureInteractive = (profileName) => select({
|
|
4764
4764
|
message: "Planetscale authentication method",
|
|
4765
|
-
options
|
|
4765
|
+
options: options$1
|
|
4766
4766
|
}).pipe(Effect.flatMap((method) => Match.value(method).pipe(Match.when("env", () => Effect.succeed({ method: "env" })), Match.when("oauth", () => configureOAuth(profileName)), Match.when("stored", () => loginStored(profileName)), Match.exhaustive)));
|
|
4767
4767
|
const configureCredentials = (profileName, ctx) => Effect.gen(function* () {
|
|
4768
4768
|
if (ctx.ci) return { method: "env" };
|
|
@@ -4847,6 +4847,108 @@ const PlanetscaleAuth = AuthProviderLayer()(PLANETSCALE_AUTH_PROVIDER_NAME, Effe
|
|
|
4847
4847
|
};
|
|
4848
4848
|
}));
|
|
4849
4849
|
|
|
4850
|
+
//#endregion
|
|
4851
|
+
//#region lib/Prisma/AuthProvider.js
|
|
4852
|
+
init_AuthProvider();
|
|
4853
|
+
init_Credentials();
|
|
4854
|
+
init_Profile();
|
|
4855
|
+
const PRISMA_AUTH_PROVIDER_NAME = "Prisma";
|
|
4856
|
+
const PRISMA_SERVICE_TOKEN_ENV = "PRISMA_SERVICE_TOKEN";
|
|
4857
|
+
const PRISMA_API_TOKEN_ENV = "PRISMA_API_TOKEN";
|
|
4858
|
+
const options = [{
|
|
4859
|
+
value: "env",
|
|
4860
|
+
label: "Environment Variable",
|
|
4861
|
+
hint: `${PRISMA_SERVICE_TOKEN_ENV} or ${PRISMA_API_TOKEN_ENV}`
|
|
4862
|
+
}, {
|
|
4863
|
+
value: "stored",
|
|
4864
|
+
label: "Service Token",
|
|
4865
|
+
hint: "enter interactively, stored in ~/.alchemy/credentials"
|
|
4866
|
+
}];
|
|
4867
|
+
const nonEmptyToken = (token) => token !== void 0 && Redacted.value(token).trim().length > 0;
|
|
4868
|
+
const validStoredCredentials = (credentials) => credentials?.type === "serviceToken" && credentials.serviceToken.trim().length > 0;
|
|
4869
|
+
const trimToken = (token) => Redacted.make(Redacted.value(token).trim());
|
|
4870
|
+
const readEnvServiceToken = Effect.fnUntraced(function* () {
|
|
4871
|
+
const serviceToken = yield* getEnvRedacted(PRISMA_SERVICE_TOKEN_ENV);
|
|
4872
|
+
if (nonEmptyToken(serviceToken)) return {
|
|
4873
|
+
serviceToken: trimToken(serviceToken),
|
|
4874
|
+
envName: PRISMA_SERVICE_TOKEN_ENV
|
|
4875
|
+
};
|
|
4876
|
+
const apiToken = yield* getEnvRedacted(PRISMA_API_TOKEN_ENV);
|
|
4877
|
+
if (nonEmptyToken(apiToken)) return {
|
|
4878
|
+
serviceToken: trimToken(apiToken),
|
|
4879
|
+
envName: PRISMA_API_TOKEN_ENV
|
|
4880
|
+
};
|
|
4881
|
+
});
|
|
4882
|
+
/**
|
|
4883
|
+
* Layer that registers the Prisma Management API auth provider.
|
|
4884
|
+
*/
|
|
4885
|
+
const PrismaAuth = AuthProviderLayer()(PRISMA_AUTH_PROVIDER_NAME, Effect.gen(function* () {
|
|
4886
|
+
const profiles = yield* AlchemyProfile;
|
|
4887
|
+
const store = yield* CredentialsStore;
|
|
4888
|
+
const loginStored = Effect.fnUntraced(function* (profileName) {
|
|
4889
|
+
const serviceToken = yield* password({
|
|
4890
|
+
message: "Prisma Service Token",
|
|
4891
|
+
validate: (v) => v.trim().length === 0 ? "Required" : void 0
|
|
4892
|
+
}).pipe(retryOnce);
|
|
4893
|
+
yield* store.write(profileName, "prisma-stored", {
|
|
4894
|
+
type: "serviceToken",
|
|
4895
|
+
serviceToken: serviceToken.trim()
|
|
4896
|
+
});
|
|
4897
|
+
yield* success("Prisma: credentials saved.");
|
|
4898
|
+
return { method: "stored" };
|
|
4899
|
+
});
|
|
4900
|
+
const configureInteractive = (profileName) => select({
|
|
4901
|
+
message: "Prisma authentication method",
|
|
4902
|
+
options
|
|
4903
|
+
}).pipe(Effect.flatMap((method) => Match.value(method).pipe(Match.when("env", () => Effect.succeed({ method: "env" })), Match.when("stored", () => loginStored(profileName)), Match.exhaustive)));
|
|
4904
|
+
const configure = (profileName, ctx) => Effect.gen(function* () {
|
|
4905
|
+
if (ctx.ci) return { method: "env" };
|
|
4906
|
+
return yield* configureInteractive(profileName);
|
|
4907
|
+
}).pipe(Effect.mapError((e) => new AuthError({
|
|
4908
|
+
message: "failed to configure credentials",
|
|
4909
|
+
cause: e
|
|
4910
|
+
})));
|
|
4911
|
+
const read = (profileName, config) => Match.value(config).pipe(Match.when({ method: "env" }, Effect.fnUntraced(function* () {
|
|
4912
|
+
const envToken = yield* readEnvServiceToken();
|
|
4913
|
+
if (!envToken) return yield* new AuthError({ message: `Prisma env credentials not found. Set ${PRISMA_SERVICE_TOKEN_ENV} or ${PRISMA_API_TOKEN_ENV}.` });
|
|
4914
|
+
return {
|
|
4915
|
+
type: "serviceToken",
|
|
4916
|
+
serviceToken: envToken.serviceToken,
|
|
4917
|
+
source: {
|
|
4918
|
+
type: "env",
|
|
4919
|
+
details: envToken.envName
|
|
4920
|
+
}
|
|
4921
|
+
};
|
|
4922
|
+
})), Match.when({ method: "stored" }, () => store.read(profileName, "prisma-stored").pipe(Effect.flatMap((creds) => !validStoredCredentials(creds) ? Effect.fail(new AuthError({ message: creds == null ? "Prisma stored credentials not found. Run: alchemy login --configure" : "Prisma stored credentials are invalid. Run: alchemy login --configure" })) : Effect.succeed({
|
|
4923
|
+
type: "serviceToken",
|
|
4924
|
+
serviceToken: Redacted.make(creds.serviceToken.trim()),
|
|
4925
|
+
source: { type: "stored" }
|
|
4926
|
+
})))), Match.exhaustive);
|
|
4927
|
+
const login = (profileName, config) => Match.value(config).pipe(Match.when({ method: "env" }, () => readEnvServiceToken().pipe(Effect.flatMap((envToken) => envToken ? Effect.void : Effect.gen(function* () {
|
|
4928
|
+
const next = yield* configureInteractive(profileName);
|
|
4929
|
+
const existing = yield* profiles.getProfile(profileName);
|
|
4930
|
+
yield* profiles.setProfile(profileName, {
|
|
4931
|
+
...existing,
|
|
4932
|
+
[PRISMA_AUTH_PROVIDER_NAME]: next
|
|
4933
|
+
});
|
|
4934
|
+
})))), Match.when({ method: "stored" }, () => store.read(profileName, "prisma-stored").pipe(Effect.flatMap((creds) => validStoredCredentials(creds) ? Effect.void : loginStored(profileName)))), Match.exhaustive).pipe(Effect.mapError((e) => new AuthError({
|
|
4935
|
+
message: "login failed",
|
|
4936
|
+
cause: e
|
|
4937
|
+
})));
|
|
4938
|
+
const logout = (profileName, config) => Match.value(config).pipe(Match.when({ method: "env" }, () => Effect.void), Match.when({ method: "stored" }, () => store.delete(profileName, "prisma-stored").pipe(Effect.andThen(success("Prisma: stored credentials removed")))), Match.exhaustive);
|
|
4939
|
+
const prettyPrint = (profileName, config) => read(profileName, config).pipe(Effect.tap((creds) => {
|
|
4940
|
+
const source = creds.source.details ? `${creds.source.type} - ${creds.source.details}` : creds.source.type;
|
|
4941
|
+
return Effect.all([Console.log(` serviceToken: ${displayRedacted(creds.serviceToken, 9)}`), Console.log(` source: ${source}`)]);
|
|
4942
|
+
}), Effect.catch((e) => Console.error(` Failed to retrieve credentials: ${e}`)));
|
|
4943
|
+
return {
|
|
4944
|
+
configure,
|
|
4945
|
+
login,
|
|
4946
|
+
logout,
|
|
4947
|
+
prettyPrint,
|
|
4948
|
+
read
|
|
4949
|
+
};
|
|
4950
|
+
}));
|
|
4951
|
+
|
|
4850
4952
|
//#endregion
|
|
4851
4953
|
//#region lib/Cli/commands/_shared.js
|
|
4852
4954
|
init_AuthProvider();
|
|
@@ -4962,13 +5064,13 @@ const placeholderStack = (name) => ({
|
|
|
4962
5064
|
* entrypoint is fatal (login / nuke let it propagate) or best-effort
|
|
4963
5065
|
* (profile show wraps the call in `Effect.catchCause`).
|
|
4964
5066
|
*/
|
|
4965
|
-
const buildStackProviders = Effect.fn("buildStackProviders")(function* (options$
|
|
4966
|
-
const authProviders = options$
|
|
4967
|
-
const stackEffect = yield* importStack(options$
|
|
4968
|
-
const configProvider = withProfileOverride(yield* loadConfigProvider(options$
|
|
5067
|
+
const buildStackProviders = Effect.fn("buildStackProviders")(function* (options$7) {
|
|
5068
|
+
const authProviders = options$7.registry ?? {};
|
|
5069
|
+
const stackEffect = yield* importStack(options$7.main);
|
|
5070
|
+
const configProvider = withProfileOverride(yield* loadConfigProvider(options$7.envFile), options$7.profile);
|
|
4969
5071
|
return {
|
|
4970
5072
|
authProviders,
|
|
4971
|
-
context: yield* Layer.build((stackEffect.providers ?? Layer.empty).pipe(Layer.provideMerge(stackEffect.state ?? Layer.empty), Layer.provideMerge(Layer.mergeAll(Layer.succeed(AuthProviders, authProviders), ConfigProvider.layer(configProvider), options$
|
|
5073
|
+
context: yield* Layer.build((stackEffect.providers ?? Layer.empty).pipe(Layer.provideMerge(stackEffect.state ?? Layer.empty), Layer.provideMerge(Layer.mergeAll(Layer.succeed(AuthProviders, authProviders), ConfigProvider.layer(configProvider), options$7.logger ?? Logger.layer([fileLogger("out")], { mergeWithExisting: true }), Layer.succeed(Stage, "placeholder"), Layer.succeed(Stack, placeholderStack(stackEffect.stackName)), options$7.extra ?? Layer.empty)))),
|
|
4972
5074
|
stackEffect
|
|
4973
5075
|
};
|
|
4974
5076
|
});
|
|
@@ -4978,14 +5080,14 @@ const buildStackProviders = Effect.fn("buildStackProviders")(function* (options$
|
|
|
4978
5080
|
* `alchemy profile show` can pretty-print any provider a profile mentions,
|
|
4979
5081
|
* even one the current stack doesn't wire up.
|
|
4980
5082
|
*/
|
|
4981
|
-
const builtinAuth = Layer.mergeAll(AwsAuth, AxiomAuth, CloudflareAuth, GitHubAuth, NeonAuth, PlanetscaleAuth);
|
|
5083
|
+
const builtinAuth = Layer.mergeAll(AwsAuth, AxiomAuth, CloudflareAuth, GitHubAuth, NeonAuth, PlanetscaleAuth, PrismaAuth);
|
|
4982
5084
|
/**
|
|
4983
5085
|
* Build {@link builtinAuth} against `registry` so every built-in auth
|
|
4984
5086
|
* provider registers itself, without importing any stack entrypoint.
|
|
4985
5087
|
*/
|
|
4986
|
-
const buildBuiltinAuthProviders = Effect.fn("buildBuiltinAuthProviders")(function* (options$
|
|
4987
|
-
const authProviders = options$
|
|
4988
|
-
yield* Layer.build(Layer.provide(builtinAuth, Layer.mergeAll(Layer.succeed(AuthProviders, authProviders), ConfigProvider.layer(withProfileOverride(yield* loadConfigProvider(options$
|
|
5088
|
+
const buildBuiltinAuthProviders = Effect.fn("buildBuiltinAuthProviders")(function* (options$7) {
|
|
5089
|
+
const authProviders = options$7.registry ?? {};
|
|
5090
|
+
yield* Layer.build(Layer.provide(builtinAuth, Layer.mergeAll(Layer.succeed(AuthProviders, authProviders), ConfigProvider.layer(withProfileOverride(yield* loadConfigProvider(options$7.envFile), options$7.profile)), Logger.layer([fileLogger("out")], { mergeWithExisting: true }))));
|
|
4989
5091
|
return authProviders;
|
|
4990
5092
|
});
|
|
4991
5093
|
|