@gaganref/confect-alchemy 10.6.0-fork.21 → 10.6.0-fork.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EnvironmentVariables.d.ts +76 -21
- package/dist/EnvironmentVariables.d.ts.map +1 -1
- package/dist/EnvironmentVariables.js +188 -12
- package/dist/EnvironmentVariables.js.map +1 -1
- package/dist/internal/LocalBackend.d.ts +2 -0
- package/dist/internal/LocalBackend.d.ts.map +1 -1
- package/dist/internal/LocalBackend.js +2 -0
- package/dist/internal/LocalBackend.js.map +1 -1
- package/dist/internal/PushLock.d.ts +1 -0
- package/dist/internal/PushLock.d.ts.map +1 -1
- package/dist/internal/PushLock.js +3 -2
- package/dist/internal/PushLock.js.map +1 -1
- package/package.json +3 -3
- package/src/EnvironmentVariables.ts +481 -16
- package/src/internal/LocalBackend.ts +2 -0
- package/src/internal/PushLock.ts +4 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { OwnedBySomeoneElse } from "alchemy/AdoptPolicy";
|
|
2
|
+
import type { Input } from "alchemy/Input";
|
|
2
3
|
import * as Provider from "alchemy/Provider";
|
|
3
|
-
import { Resource } from "alchemy/Resource";
|
|
4
|
+
import { Resource, type ResourceClass } from "alchemy/Resource";
|
|
5
|
+
import * as Duration from "effect/Duration";
|
|
6
|
+
import { PushLockError } from "./internal/PushLock.js";
|
|
4
7
|
import * as Effect from "effect/Effect";
|
|
5
8
|
import * as Layer from "effect/Layer";
|
|
6
9
|
import * as Redacted from "effect/Redacted";
|
|
@@ -8,6 +11,34 @@ import * as Schema from "effect/Schema";
|
|
|
8
11
|
import * as ConvexClient from "./ConvexClient.js";
|
|
9
12
|
import type { Providers } from "./Providers.js";
|
|
10
13
|
export interface EnvironmentVariablesProps {
|
|
14
|
+
/**
|
|
15
|
+
* Refuse live owned values that differ from both the last write and the
|
|
16
|
+
* desired value. Defaults to `overwrite`.
|
|
17
|
+
*/
|
|
18
|
+
readonly driftPolicy?: "overwrite" | "error";
|
|
19
|
+
/**
|
|
20
|
+
* Adopt unowned desired names only when their live values match. Defaults to
|
|
21
|
+
* false.
|
|
22
|
+
*/
|
|
23
|
+
readonly adoptMatching?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Refuse live names that are neither owned nor desired. Defaults to `ignore`.
|
|
26
|
+
*/
|
|
27
|
+
readonly unownedPolicy?: "ignore" | "error";
|
|
28
|
+
/**
|
|
29
|
+
* Share the deployment push lock for checks and writes. Absent by default.
|
|
30
|
+
*/
|
|
31
|
+
readonly lock?: {
|
|
32
|
+
readonly deploymentName: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Retry write conflicts only, with 1 to 10 attempts and a delay of 1 to 10000
|
|
36
|
+
* ms. Absent means one attempt.
|
|
37
|
+
*/
|
|
38
|
+
readonly retry?: {
|
|
39
|
+
readonly maxAttempts: number;
|
|
40
|
+
readonly delay: Duration.Input;
|
|
41
|
+
};
|
|
11
42
|
readonly url: string;
|
|
12
43
|
readonly deployKey: Redacted.Redacted<string>;
|
|
13
44
|
readonly variables: Readonly<Record<string, string | Redacted.Redacted<string>>>;
|
|
@@ -20,7 +51,7 @@ export interface EnvironmentVariablesAttributes {
|
|
|
20
51
|
readonly originals: Readonly<Record<string, Redacted.Redacted<string>>>;
|
|
21
52
|
}
|
|
22
53
|
export type EnvironmentVariables = Resource<"Convex.EnvironmentVariables", EnvironmentVariablesProps, EnvironmentVariablesAttributes, never, Providers>;
|
|
23
|
-
export declare const EnvironmentVariables:
|
|
54
|
+
export declare const EnvironmentVariables: ResourceClass<EnvironmentVariables>;
|
|
24
55
|
declare const EnvironmentTargetChange_base: Schema.Class<EnvironmentTargetChange, Schema.TaggedStruct<"EnvironmentTargetChange", {
|
|
25
56
|
readonly url: Schema.String;
|
|
26
57
|
}>, import("effect/Cause").YieldableError & {
|
|
@@ -28,20 +59,44 @@ declare const EnvironmentTargetChange_base: Schema.Class<EnvironmentTargetChange
|
|
|
28
59
|
}>;
|
|
29
60
|
export declare class EnvironmentTargetChange extends EnvironmentTargetChange_base {
|
|
30
61
|
}
|
|
62
|
+
declare const EnvironmentVariableDrift_base: Schema.Class<EnvironmentVariableDrift, Schema.TaggedStruct<"EnvironmentVariableDrift", {
|
|
63
|
+
readonly variableName: Schema.String;
|
|
64
|
+
}>, import("effect/Cause").YieldableError & {
|
|
65
|
+
readonly brand: unique symbol;
|
|
66
|
+
}>;
|
|
67
|
+
export declare class EnvironmentVariableDrift extends EnvironmentVariableDrift_base {
|
|
68
|
+
get message(): string;
|
|
69
|
+
}
|
|
70
|
+
declare const EnvironmentVariableUnowned_base: Schema.Class<EnvironmentVariableUnowned, Schema.TaggedStruct<"EnvironmentVariableUnowned", {
|
|
71
|
+
readonly variableName: Schema.String;
|
|
72
|
+
}>, import("effect/Cause").YieldableError & {
|
|
73
|
+
readonly brand: unique symbol;
|
|
74
|
+
}>;
|
|
75
|
+
export declare class EnvironmentVariableUnowned extends EnvironmentVariableUnowned_base {
|
|
76
|
+
get message(): string;
|
|
77
|
+
}
|
|
78
|
+
declare const EnvironmentVariablesInvalidOption_base: Schema.Class<EnvironmentVariablesInvalidOption, Schema.TaggedStruct<"EnvironmentVariablesInvalidOption", {
|
|
79
|
+
readonly option: Schema.Literals<readonly ["maxAttempts", "delay", "deploymentName"]>;
|
|
80
|
+
}>, import("effect/Cause").YieldableError & {
|
|
81
|
+
readonly brand: unique symbol;
|
|
82
|
+
}>;
|
|
83
|
+
export declare class EnvironmentVariablesInvalidOption extends EnvironmentVariablesInvalidOption_base {
|
|
84
|
+
get message(): "Environment lock deploymentName must contain lowercase letters or digits separated by single hyphens" | "Environment retry delay must be from 1 to 10000 milliseconds" | "Environment retry maxAttempts must be an integer from 1 to 10";
|
|
85
|
+
}
|
|
31
86
|
export declare const provider: Effect.Effect<{
|
|
32
|
-
diff: (
|
|
87
|
+
diff: (input: {
|
|
33
88
|
id: string;
|
|
34
89
|
fqn: string;
|
|
35
90
|
instanceId: string;
|
|
36
91
|
olds: EnvironmentVariablesProps;
|
|
37
|
-
news:
|
|
92
|
+
news: Input<EnvironmentVariablesProps>;
|
|
38
93
|
oldBindings: import("alchemy").ResourceBinding<never>[];
|
|
39
|
-
newBindings:
|
|
94
|
+
newBindings: Input<import("alchemy").ResourceBinding<never>[]>;
|
|
40
95
|
output: EnvironmentVariablesAttributes | undefined;
|
|
41
96
|
}) => Effect.Effect<{
|
|
42
97
|
action: "update";
|
|
43
|
-
} | undefined, EnvironmentTargetChange | ConvexClient.ConvexClientError, never>;
|
|
44
|
-
read: (
|
|
98
|
+
} | undefined, EnvironmentTargetChange | EnvironmentVariableDrift | EnvironmentVariableUnowned | EnvironmentVariablesInvalidOption | OwnedBySomeoneElse | PushLockError | ConvexClient.ConvexClientError, never>;
|
|
99
|
+
read: (input: {
|
|
45
100
|
id: string;
|
|
46
101
|
fqn: string;
|
|
47
102
|
instanceId: string;
|
|
@@ -54,8 +109,8 @@ export declare const provider: Effect.Effect<{
|
|
|
54
109
|
originals: Readonly<Record<string, Redacted.Redacted<string>>>;
|
|
55
110
|
deployKey: Redacted.Redacted<string>;
|
|
56
111
|
variables: Record<string, Redacted.Redacted<string>>;
|
|
57
|
-
} | undefined, ConvexClient.ConvexClientError, never>;
|
|
58
|
-
reconcile: (
|
|
112
|
+
} | undefined, EnvironmentVariableDrift | EnvironmentVariableUnowned | EnvironmentVariablesInvalidOption | OwnedBySomeoneElse | PushLockError | ConvexClient.ConvexClientError, never>;
|
|
113
|
+
reconcile: (input: {
|
|
59
114
|
id: string;
|
|
60
115
|
fqn: string;
|
|
61
116
|
instanceId: string;
|
|
@@ -70,8 +125,8 @@ export declare const provider: Effect.Effect<{
|
|
|
70
125
|
ownedNames: string[];
|
|
71
126
|
variables: Record<string, Redacted.Redacted<string>>;
|
|
72
127
|
originals: Record<string, Redacted.Redacted<string>>;
|
|
73
|
-
}, ConvexClient.ConvexApiError | ConvexClient.ConvexConflict | ConvexClient.ConvexNotFound | EnvironmentTargetChange | import("./internal/Lifecycle.js").LifecycleStateError | OwnedBySomeoneElse | import("alchemy/State/State").StateStoreError, never>;
|
|
74
|
-
delete: (
|
|
128
|
+
}, ConvexClient.ConvexApiError | ConvexClient.ConvexConflict | ConvexClient.ConvexNotFound | EnvironmentTargetChange | EnvironmentVariableDrift | EnvironmentVariableUnowned | EnvironmentVariablesInvalidOption | import("./internal/Lifecycle.js").LifecycleStateError | OwnedBySomeoneElse | PushLockError | import("alchemy/State/State").StateStoreError, never>;
|
|
129
|
+
delete: (input: {
|
|
75
130
|
id: string;
|
|
76
131
|
fqn: string;
|
|
77
132
|
instanceId: string;
|
|
@@ -80,7 +135,7 @@ export declare const provider: Effect.Effect<{
|
|
|
80
135
|
session: import("alchemy/Report").ScopedPlanStatusSession;
|
|
81
136
|
bindings: import("alchemy").ResourceBinding<never>[];
|
|
82
137
|
force?: boolean;
|
|
83
|
-
}) => Effect.Effect<void, ConvexClient.ConvexApiError | ConvexClient.ConvexConflict, never>;
|
|
138
|
+
}) => Effect.Effect<void, ConvexClient.ConvexApiError | ConvexClient.ConvexConflict | EnvironmentVariableDrift | EnvironmentVariableUnowned | EnvironmentVariablesInvalidOption | PushLockError, never>;
|
|
84
139
|
}, never, ConvexClient.ConvexClient>;
|
|
85
140
|
/**
|
|
86
141
|
* Under `alchemy dev` variables are managed on the local backend. A backend
|
|
@@ -88,19 +143,19 @@ export declare const provider: Effect.Effect<{
|
|
|
88
143
|
* them is skipped rather than failing the apply.
|
|
89
144
|
*/
|
|
90
145
|
export declare const localProvider: Effect.Effect<{
|
|
91
|
-
diff: (
|
|
146
|
+
diff: (input: {
|
|
92
147
|
id: string;
|
|
93
148
|
fqn: string;
|
|
94
149
|
instanceId: string;
|
|
95
150
|
olds: EnvironmentVariablesProps;
|
|
96
|
-
news:
|
|
151
|
+
news: Input<EnvironmentVariablesProps>;
|
|
97
152
|
oldBindings: import("alchemy").ResourceBinding<never>[];
|
|
98
|
-
newBindings:
|
|
153
|
+
newBindings: Input<import("alchemy").ResourceBinding<never>[]>;
|
|
99
154
|
output: EnvironmentVariablesAttributes | undefined;
|
|
100
155
|
}) => Effect.Effect<{
|
|
101
156
|
action: "update";
|
|
102
|
-
} | undefined, EnvironmentTargetChange | ConvexClient.ConvexClientError, never>;
|
|
103
|
-
read: (
|
|
157
|
+
} | undefined, EnvironmentTargetChange | EnvironmentVariableDrift | EnvironmentVariableUnowned | EnvironmentVariablesInvalidOption | OwnedBySomeoneElse | PushLockError | ConvexClient.ConvexClientError, never>;
|
|
158
|
+
read: (input: {
|
|
104
159
|
id: string;
|
|
105
160
|
fqn: string;
|
|
106
161
|
instanceId: string;
|
|
@@ -113,8 +168,8 @@ export declare const localProvider: Effect.Effect<{
|
|
|
113
168
|
originals: Readonly<Record<string, Redacted.Redacted<string>>>;
|
|
114
169
|
deployKey: Redacted.Redacted<string>;
|
|
115
170
|
variables: Record<string, Redacted.Redacted<string>>;
|
|
116
|
-
} | undefined, ConvexClient.ConvexClientError, never>;
|
|
117
|
-
reconcile: (
|
|
171
|
+
} | undefined, EnvironmentVariableDrift | EnvironmentVariableUnowned | EnvironmentVariablesInvalidOption | OwnedBySomeoneElse | PushLockError | ConvexClient.ConvexClientError, never>;
|
|
172
|
+
reconcile: (input: {
|
|
118
173
|
id: string;
|
|
119
174
|
fqn: string;
|
|
120
175
|
instanceId: string;
|
|
@@ -129,7 +184,7 @@ export declare const localProvider: Effect.Effect<{
|
|
|
129
184
|
ownedNames: string[];
|
|
130
185
|
variables: Record<string, Redacted.Redacted<string>>;
|
|
131
186
|
originals: Record<string, Redacted.Redacted<string>>;
|
|
132
|
-
}, ConvexClient.ConvexApiError | ConvexClient.ConvexConflict | ConvexClient.ConvexNotFound | EnvironmentTargetChange | import("./internal/Lifecycle.js").LifecycleStateError | OwnedBySomeoneElse | import("alchemy/State/State").StateStoreError, never>;
|
|
187
|
+
}, ConvexClient.ConvexApiError | ConvexClient.ConvexConflict | ConvexClient.ConvexNotFound | EnvironmentTargetChange | EnvironmentVariableDrift | EnvironmentVariableUnowned | EnvironmentVariablesInvalidOption | import("./internal/Lifecycle.js").LifecycleStateError | OwnedBySomeoneElse | PushLockError | import("alchemy/State/State").StateStoreError, never>;
|
|
133
188
|
delete: (input: {
|
|
134
189
|
id: string;
|
|
135
190
|
fqn: string;
|
|
@@ -139,7 +194,7 @@ export declare const localProvider: Effect.Effect<{
|
|
|
139
194
|
session: import("alchemy/Report").ScopedPlanStatusSession;
|
|
140
195
|
bindings: import("alchemy").ResourceBinding<never>[];
|
|
141
196
|
force?: boolean;
|
|
142
|
-
}) => Effect.Effect<void, ConvexClient.ConvexApiError | ConvexClient.ConvexConflict | Provider.ProviderError, never>;
|
|
197
|
+
}) => Effect.Effect<void, ConvexClient.ConvexApiError | ConvexClient.ConvexConflict | EnvironmentVariableDrift | EnvironmentVariableUnowned | EnvironmentVariablesInvalidOption | Provider.ProviderError | PushLockError, never>;
|
|
143
198
|
}, never, ConvexClient.ConvexClient>;
|
|
144
199
|
export declare const layer: Layer.Layer<Provider.Provider<EnvironmentVariables>, never, ConvexClient.ConvexClient>;
|
|
145
200
|
export declare const localLayer: Layer.Layer<Provider.Provider<EnvironmentVariables>, never, never>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnvironmentVariables.d.ts","sources":["../src/EnvironmentVariables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAW,MAAM,qBAAqB,CAAC;AAElE,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,
|
|
1
|
+
{"version":3,"file":"EnvironmentVariables.d.ts","sources":["../src/EnvironmentVariables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAW,MAAM,qBAAqB,CAAC;AAElE,OAAO,KAAK,EAAE,KAAK,EAAc,MAAM,eAAe,CAAC;AAEvD,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EACL,QAAQ,EACR,KAAK,aAAa,EA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;;;;;;;;;aArnBV,MAAM;oBAEC,aAAa,CAAC,MAAM,CAAC;mBAEtB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCAgoBxE,CAAC;AAEF,eAAO,MAAM,KAAK,wFAAkD,CAAC;AACrE,eAAO,MAAM,UAAU,oEAStB,CAAC"}
|
|
@@ -1,26 +1,175 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PushLock, PushLockError } from "./internal/PushLock.js";
|
|
2
|
+
import { ConvexApiError, ConvexClient, layer as layer$1 } from "./ConvexClient.js";
|
|
2
3
|
import { checkpointCreate, shouldAdopt } from "./internal/Lifecycle.js";
|
|
4
|
+
import * as Output from "alchemy/Output";
|
|
3
5
|
import * as Effect from "effect/Effect";
|
|
4
6
|
import * as Provider from "alchemy/Provider";
|
|
5
7
|
import { Resource } from "alchemy/Resource";
|
|
6
8
|
import * as Layer from "effect/Layer";
|
|
7
9
|
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
10
|
+
import * as Config from "effect/Config";
|
|
8
11
|
import * as Redacted from "effect/Redacted";
|
|
9
12
|
import * as Schema from "effect/Schema";
|
|
13
|
+
import * as Option from "effect/Option";
|
|
10
14
|
import * as Arr from "effect/Array";
|
|
11
15
|
import * as Rec from "effect/Record";
|
|
16
|
+
import * as Result from "effect/Result";
|
|
17
|
+
import * as Duration from "effect/Duration";
|
|
18
|
+
import * as Predicate from "effect/Predicate";
|
|
19
|
+
import * as Schedule from "effect/Schedule";
|
|
12
20
|
import { OwnedBySomeoneElse, Unowned } from "alchemy/AdoptPolicy";
|
|
13
21
|
import { isResolved } from "alchemy/Diff";
|
|
22
|
+
import * as Effectable from "effect/Effectable";
|
|
14
23
|
// src/EnvironmentVariables.ts
|
|
15
|
-
const
|
|
24
|
+
const environmentVariables = Resource("Convex.EnvironmentVariables");
|
|
25
|
+
const EnvironmentVariables = Object.assign(new Proxy(environmentVariables, { apply: (target, _this, args) => {
|
|
26
|
+
if (args.length === 1) return Object.assign(EnvironmentVariables, args[0]);
|
|
27
|
+
const [id, props] = args;
|
|
28
|
+
return target(id, (Effect.isEffect(props) ? props : Effect.succeed(props)).pipe(Effect.flatMap((options) => Effect.fromResult(validateSafety(options)).pipe(Effect.orDie, Effect.as({
|
|
29
|
+
...options,
|
|
30
|
+
...options.retry === void 0 ? {} : { retry: checkedRetry(options.retry) },
|
|
31
|
+
...options.lock === void 0 ? {} : { lock: checkedLock(options.lock) }
|
|
32
|
+
})))));
|
|
33
|
+
} }), Effectable.Prototype({
|
|
34
|
+
label: "Resource<Convex.EnvironmentVariables>",
|
|
35
|
+
evaluate: () => Effect.succeed(EnvironmentVariables)
|
|
36
|
+
}));
|
|
16
37
|
var EnvironmentTargetChange = class extends Schema.TaggedError()("EnvironmentTargetChange", { url: Schema.String }) {};
|
|
38
|
+
var EnvironmentVariableDrift = class extends Schema.TaggedError()("EnvironmentVariableDrift", { variableName: Schema.String }) {
|
|
39
|
+
get message() {
|
|
40
|
+
return `Environment variable ${this.variableName} differs from its last managed value`;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var EnvironmentVariableUnowned = class extends Schema.TaggedError()("EnvironmentVariableUnowned", { variableName: Schema.String }) {
|
|
44
|
+
get message() {
|
|
45
|
+
return `Environment variable ${this.variableName} is neither owned nor desired`;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var EnvironmentVariablesInvalidOption = class extends Schema.TaggedError()("EnvironmentVariablesInvalidOption", { option: Schema.Literals([
|
|
49
|
+
"maxAttempts",
|
|
50
|
+
"delay",
|
|
51
|
+
"deploymentName"
|
|
52
|
+
]) }) {
|
|
53
|
+
get message() {
|
|
54
|
+
switch (this.option) {
|
|
55
|
+
case "maxAttempts": return "Environment retry maxAttempts must be an integer from 1 to 10";
|
|
56
|
+
case "delay": return "Environment retry delay must be from 1 to 10000 milliseconds";
|
|
57
|
+
case "deploymentName": return "Environment lock deploymentName must contain lowercase letters or digits separated by single hyphens";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const validateMaxAttempts = (maxAttempts) => Number.isInteger(maxAttempts) && maxAttempts >= 1 && maxAttempts <= 10 ? Result.succeed(void 0) : Result.fail(EnvironmentVariablesInvalidOption.make({ option: "maxAttempts" }));
|
|
62
|
+
const validateDelay = (delay) => {
|
|
63
|
+
const parsed = Duration.fromInput(delay);
|
|
64
|
+
return Option.isSome(parsed) && Duration.toMillis(parsed.value) >= 1 && Duration.toMillis(parsed.value) <= 1e4 ? Result.succeed(parsed.value) : Result.fail(EnvironmentVariablesInvalidOption.make({ option: "delay" }));
|
|
65
|
+
};
|
|
66
|
+
const validateDeploymentName = (deploymentName) => /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(deploymentName) ? Result.succeed(void 0) : Result.fail(EnvironmentVariablesInvalidOption.make({ option: "deploymentName" }));
|
|
67
|
+
const validateSafety = (options) => Result.gen(function* () {
|
|
68
|
+
let duration;
|
|
69
|
+
if ("retry" in options && options.retry !== void 0 && "maxAttempts" in options.retry && "delay" in options.retry) {
|
|
70
|
+
if (isResolved(options.retry.maxAttempts)) yield* validateMaxAttempts(options.retry.maxAttempts);
|
|
71
|
+
if (isResolved(options.retry.delay)) duration = yield* validateDelay(options.retry.delay);
|
|
72
|
+
}
|
|
73
|
+
if ("lock" in options && options.lock !== void 0 && "deploymentName" in options.lock && isResolved(options.lock.deploymentName)) yield* validateDeploymentName(options.lock.deploymentName);
|
|
74
|
+
return duration;
|
|
75
|
+
});
|
|
76
|
+
const checkedInput = (input, validate) => {
|
|
77
|
+
const check = (value) => Effect.fromResult(validate(value)).pipe(Effect.orDie, Effect.as(value));
|
|
78
|
+
if (Config.isConfig(input)) return input.pipe(Config.mapEffect(check));
|
|
79
|
+
return input;
|
|
80
|
+
};
|
|
81
|
+
const checkedRetry = (input) => {
|
|
82
|
+
if ("maxAttempts" in input && "delay" in input) return {
|
|
83
|
+
...input,
|
|
84
|
+
maxAttempts: checkedInput(input.maxAttempts, validateMaxAttempts),
|
|
85
|
+
delay: checkedInput(input.delay, validateDelay)
|
|
86
|
+
};
|
|
87
|
+
return checkedInput(input, (retry) => validateSafety({ retry }));
|
|
88
|
+
};
|
|
89
|
+
const checkedLock = (input) => {
|
|
90
|
+
if ("deploymentName" in input) return {
|
|
91
|
+
...input,
|
|
92
|
+
deploymentName: checkedInput(input.deploymentName, validateDeploymentName)
|
|
93
|
+
};
|
|
94
|
+
return checkedInput(input, (lock) => validateSafety({ lock }));
|
|
95
|
+
};
|
|
96
|
+
const ownershipConflict = (variableName) => new OwnedBySomeoneElse({
|
|
97
|
+
message: "An existing environment variable requires explicit adoption in a separate resource.",
|
|
98
|
+
resourceType: EnvironmentVariables.Type,
|
|
99
|
+
physicalName: variableName
|
|
100
|
+
});
|
|
101
|
+
const optionsForDiff = (olds, news) => {
|
|
102
|
+
if (!("variables" in news)) return {
|
|
103
|
+
...olds,
|
|
104
|
+
desiredNames: void 0,
|
|
105
|
+
desiredVariables: void 0
|
|
106
|
+
};
|
|
107
|
+
return {
|
|
108
|
+
driftPolicy: isResolved(news.driftPolicy) ? news.driftPolicy : olds.driftPolicy,
|
|
109
|
+
adoptMatching: isResolved(news.adoptMatching) ? news.adoptMatching : olds.adoptMatching,
|
|
110
|
+
unownedPolicy: isResolved(news.unownedPolicy) ? news.unownedPolicy : olds.unownedPolicy,
|
|
111
|
+
lock: isResolved(news.lock) ? news.lock : olds.lock,
|
|
112
|
+
retry: isResolved(news.retry) ? news.retry : olds.retry,
|
|
113
|
+
desiredVariables: news.variables,
|
|
114
|
+
desiredNames: !Output.isExpr(news.variables) && !Effect.isEffect(news.variables) && Predicate.isReadonlyObject(news.variables) ? Rec.keys(news.variables) : void 0
|
|
115
|
+
};
|
|
116
|
+
};
|
|
17
117
|
const provider = Effect.gen(function* () {
|
|
18
118
|
const client = yield* ConvexClient;
|
|
119
|
+
const lock = yield* Effect.serviceOption(PushLock);
|
|
120
|
+
const withSafety = Effect.fn("EnvironmentVariables.withSafety")(function* (options, effect) {
|
|
121
|
+
const duration = yield* Effect.fromResult(validateSafety(options));
|
|
122
|
+
let attempt = effect;
|
|
123
|
+
if (options.retry !== void 0 && duration !== void 0) {
|
|
124
|
+
const { maxAttempts } = options.retry;
|
|
125
|
+
attempt = effect.pipe(Effect.retry({
|
|
126
|
+
times: maxAttempts - 1,
|
|
127
|
+
schedule: Schedule.spaced(duration),
|
|
128
|
+
while: (error) => Schema.is(ConvexApiError)(error) && error.serverCode === "OptimisticConcurrencyControlFailure"
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
if (options.lock === void 0) return yield* attempt;
|
|
132
|
+
if (Option.isNone(lock)) return yield* PushLockError.make({
|
|
133
|
+
deploymentName: options.lock.deploymentName,
|
|
134
|
+
reason: "configuration",
|
|
135
|
+
missing: "PushLock"
|
|
136
|
+
});
|
|
137
|
+
return yield* lock.value.withLock(options.lock.deploymentName, attempt);
|
|
138
|
+
});
|
|
19
139
|
const redacted = (value) => typeof value === "string" ? Redacted.make(value) : value;
|
|
20
140
|
const valueAt = (variables, name) => Rec.has(variables, name) ? variables[name] : void 0;
|
|
21
141
|
const select = (variables, names) => Rec.fromEntries(Arr.flatMap(names, (name) => !Rec.has(variables, name) ? [] : [[name, variables[name]]]));
|
|
22
|
-
|
|
23
|
-
|
|
142
|
+
const checkDrift = (policy, output, observed, desired) => {
|
|
143
|
+
if (policy !== "error" || output === void 0) return Effect.void;
|
|
144
|
+
const desiredVariables = Predicate.isReadonlyObject(desired) && !Output.isExpr(desired) && !Effect.isEffect(desired) ? desired : void 0;
|
|
145
|
+
for (const name of output.ownedNames) {
|
|
146
|
+
const previous = valueAt(output.variables, name);
|
|
147
|
+
const current = valueAt(observed, name);
|
|
148
|
+
const wanted = desiredVariables?.[name];
|
|
149
|
+
if (current !== void 0 && (desiredVariables === void 0 || wanted !== void 0 && !isResolved(wanted))) continue;
|
|
150
|
+
if (current !== void 0 && (typeof wanted === "string" || Redacted.isRedacted(wanted)) && Redacted.value(current) === (typeof wanted === "string" ? wanted : Redacted.value(wanted))) continue;
|
|
151
|
+
if (previous === void 0 && current === void 0) continue;
|
|
152
|
+
if (previous === void 0 || current === void 0 || Redacted.value(previous) !== Redacted.value(current)) return Effect.fail(EnvironmentVariableDrift.make({ variableName: name }));
|
|
153
|
+
}
|
|
154
|
+
return Effect.void;
|
|
155
|
+
};
|
|
156
|
+
const checkUnowned = (policy, output, desiredNames, observed) => {
|
|
157
|
+
if (policy !== "error" || desiredNames === void 0) return Effect.void;
|
|
158
|
+
for (const name of Rec.keys(observed)) if (output?.ownedNames.includes(name) !== true && !desiredNames.includes(name)) return Effect.fail(EnvironmentVariableUnowned.make({ variableName: name }));
|
|
159
|
+
return Effect.void;
|
|
160
|
+
};
|
|
161
|
+
const service = {
|
|
162
|
+
diff: Effect.fn("EnvironmentVariables.diff")(function* ({ olds, news, output }) {
|
|
163
|
+
const options = optionsForDiff(olds, news);
|
|
164
|
+
if (output !== void 0 && (options.driftPolicy === "error" || options.unownedPolicy === "error" || options.adoptMatching === true)) {
|
|
165
|
+
const observed = yield* client.listEnvironmentVariables(output.url, output.deployKey);
|
|
166
|
+
yield* checkDrift(options.driftPolicy, output, observed, options.desiredVariables);
|
|
167
|
+
if (options.adoptMatching === true && Predicate.isReadonlyObject(options.desiredVariables) && !Output.isExpr(options.desiredVariables) && !Effect.isEffect(options.desiredVariables)) for (const [name, wanted] of Rec.toEntries(options.desiredVariables)) {
|
|
168
|
+
const current = valueAt(observed, name);
|
|
169
|
+
if (!output.ownedNames.includes(name) && current !== void 0 && (typeof wanted === "string" || Redacted.isRedacted(wanted)) && Redacted.value(current) !== (typeof wanted === "string" ? wanted : Redacted.value(wanted))) return yield* ownershipConflict(name);
|
|
170
|
+
}
|
|
171
|
+
yield* checkUnowned(options.unownedPolicy, output, options.desiredNames, observed);
|
|
172
|
+
}
|
|
24
173
|
if (!isResolved(news) || output === void 0) return;
|
|
25
174
|
if (news.url !== output.url) return yield* EnvironmentTargetChange.make({ url: output.url });
|
|
26
175
|
const names = Rec.keys(news.variables);
|
|
@@ -35,6 +184,8 @@ const provider = Effect.gen(function* () {
|
|
|
35
184
|
const url = output?.url ?? olds.url;
|
|
36
185
|
if (url === void 0 || olds.deployKey === void 0) return;
|
|
37
186
|
const observed = yield* client.listEnvironmentVariables(url, olds.deployKey);
|
|
187
|
+
yield* checkDrift(olds.driftPolicy, output, observed, olds.variables);
|
|
188
|
+
yield* checkUnowned(olds.unownedPolicy, output, Rec.keys(olds.variables), observed);
|
|
38
189
|
const ownedNames = output?.ownedNames ?? Rec.keys(olds.variables);
|
|
39
190
|
const variables = select(observed, ownedNames);
|
|
40
191
|
if (output !== void 0) return {
|
|
@@ -43,6 +194,10 @@ const provider = Effect.gen(function* () {
|
|
|
43
194
|
variables
|
|
44
195
|
};
|
|
45
196
|
if (Rec.keys(variables).length === 0) return void 0;
|
|
197
|
+
if (olds.adoptMatching === true) {
|
|
198
|
+
for (const [name, value] of Rec.toEntries(variables)) if (Redacted.value(value) !== Redacted.value(redacted(olds.variables[name]))) return yield* ownershipConflict(name);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
46
201
|
return Unowned({
|
|
47
202
|
url,
|
|
48
203
|
deployKey: olds.deployKey,
|
|
@@ -55,8 +210,10 @@ const provider = Effect.gen(function* () {
|
|
|
55
210
|
if (output === void 0) yield* checkpointCreate(fqn, instanceId, news);
|
|
56
211
|
if (output !== void 0 && output.url !== news.url) return yield* EnvironmentTargetChange.make({ url: output.url });
|
|
57
212
|
const observed = yield* client.listEnvironmentVariables(news.url, news.deployKey);
|
|
213
|
+
yield* checkDrift(news.driftPolicy, output, observed, news.variables);
|
|
214
|
+
yield* checkUnowned(news.unownedPolicy, output, Rec.keys(news.variables), observed);
|
|
58
215
|
const ownedNames = Rec.keys(news.variables);
|
|
59
|
-
if (output === void 0 && (yield* shouldAdopt(fqn))) {
|
|
216
|
+
if (output === void 0 && news.adoptMatching !== true && (yield* shouldAdopt(fqn))) {
|
|
60
217
|
const variables = select(observed, ownedNames);
|
|
61
218
|
output = {
|
|
62
219
|
url: news.url,
|
|
@@ -68,10 +225,21 @@ const provider = Effect.gen(function* () {
|
|
|
68
225
|
yield* checkpointCreate(fqn, instanceId, news, output);
|
|
69
226
|
}
|
|
70
227
|
const previousNames = output?.ownedNames ?? [];
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
228
|
+
let originals = output?.originals ?? {};
|
|
229
|
+
for (const name of ownedNames) {
|
|
230
|
+
const current = valueAt(observed, name);
|
|
231
|
+
if (previousNames.includes(name) || current === void 0) continue;
|
|
232
|
+
if (news.adoptMatching === true && Redacted.value(current) === Redacted.value(redacted(news.variables[name]))) {
|
|
233
|
+
originals = Rec.set(originals, name, current);
|
|
234
|
+
yield* Effect.logInfo(`Adopted environment variable ${name}`);
|
|
235
|
+
} else return yield* ownershipConflict(name);
|
|
236
|
+
}
|
|
237
|
+
if (output === void 0 && news.adoptMatching === true) yield* checkpointCreate(fqn, instanceId, news, {
|
|
238
|
+
url: news.url,
|
|
239
|
+
deployKey: news.deployKey,
|
|
240
|
+
ownedNames,
|
|
241
|
+
variables: select(observed, ownedNames),
|
|
242
|
+
originals
|
|
75
243
|
});
|
|
76
244
|
const desired = Rec.fromEntries(Arr.map(Rec.toEntries(news.variables), ([name, value]) => [name, redacted(value)]));
|
|
77
245
|
const changes = [];
|
|
@@ -99,12 +267,14 @@ const provider = Effect.gen(function* () {
|
|
|
99
267
|
deployKey: news.deployKey,
|
|
100
268
|
ownedNames,
|
|
101
269
|
variables: desired,
|
|
102
|
-
originals: select(
|
|
270
|
+
originals: select(originals, ownedNames)
|
|
103
271
|
};
|
|
104
272
|
}),
|
|
105
|
-
delete: Effect.fn("EnvironmentVariables.delete")(function* ({ output }) {
|
|
273
|
+
delete: Effect.fn("EnvironmentVariables.delete")(function* ({ olds, output }) {
|
|
106
274
|
const observed = yield* client.listEnvironmentVariables(output.url, output.deployKey).pipe(Effect.catchTag("ConvexNotFound", () => Effect.void));
|
|
107
275
|
if (observed === void 0) return;
|
|
276
|
+
yield* checkDrift(olds.driftPolicy, output, observed, {});
|
|
277
|
+
yield* checkUnowned(olds.unownedPolicy, output, Rec.keys(olds.variables), observed);
|
|
108
278
|
const changes = [];
|
|
109
279
|
for (const name of output.ownedNames) {
|
|
110
280
|
const original = valueAt(output.originals, name);
|
|
@@ -119,6 +289,12 @@ const provider = Effect.gen(function* () {
|
|
|
119
289
|
if (changes.length > 0) yield* client.updateEnvironmentVariables(output.url, output.deployKey, changes).pipe(Effect.catchTag("ConvexNotFound", () => Effect.void));
|
|
120
290
|
})
|
|
121
291
|
};
|
|
292
|
+
return {
|
|
293
|
+
diff: (input) => withSafety(optionsForDiff(input.olds, input.news), service.diff(input)),
|
|
294
|
+
read: (input) => withSafety(input.olds, service.read(input)),
|
|
295
|
+
reconcile: (input) => withSafety(input.news, service.reconcile(input)),
|
|
296
|
+
delete: (input) => withSafety(input.olds, service.delete(input))
|
|
297
|
+
};
|
|
122
298
|
});
|
|
123
299
|
/**
|
|
124
300
|
* Under `alchemy dev` variables are managed on the local backend. A backend
|
|
@@ -131,6 +307,6 @@ const localProvider = Effect.map(provider, (service) => ({
|
|
|
131
307
|
}));
|
|
132
308
|
const layer = Provider.effect(EnvironmentVariables, provider);
|
|
133
309
|
const localLayer = Provider.effect(EnvironmentVariables, localProvider).pipe(Layer.provide(layer$1({ mode: "local" }).pipe(Layer.provide(FetchHttpClient.layer))));
|
|
134
|
-
export { EnvironmentTargetChange, EnvironmentVariables, layer, localLayer, localProvider, provider };
|
|
310
|
+
export { EnvironmentTargetChange, EnvironmentVariableDrift, EnvironmentVariableUnowned, EnvironmentVariables, EnvironmentVariablesInvalidOption, layer, localLayer, localProvider, provider };
|
|
135
311
|
|
|
136
312
|
//# sourceMappingURL=EnvironmentVariables.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnvironmentVariables.js","names":["ConvexClient.ConvexClient","ConvexClient.layer"],"sources":["../src/EnvironmentVariables.ts"],"sourcesContent":["import { OwnedBySomeoneElse, Unowned } from \"alchemy/AdoptPolicy\";\nimport { isResolved } from \"alchemy/Diff\";\nimport * as Provider from \"alchemy/Provider\";\nimport { Resource } from \"alchemy/Resource\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as FetchHttpClient from \"effect/http/FetchHttpClient\";\nimport * as Redacted from \"effect/Redacted\";\nimport * as Schema from \"effect/Schema\";\n\nimport * as ConvexClient from \"./ConvexClient.js\";\nimport type { Providers } from \"./Providers.js\";\nimport { checkpointCreate, shouldAdopt } from \"./internal/Lifecycle.js\";\nimport * as Arr from \"effect/Array\";\nimport * as Rec from \"effect/Record\";\n\nexport interface EnvironmentVariablesProps {\n readonly url: string;\n readonly deployKey: Redacted.Redacted<string>;\n readonly variables: Readonly<\n Record<string, string | Redacted.Redacted<string>>\n >;\n}\n\nexport interface EnvironmentVariablesAttributes {\n readonly url: string;\n readonly deployKey: Redacted.Redacted<string>;\n readonly ownedNames: ReadonlyArray<string>;\n readonly variables: Readonly<Record<string, Redacted.Redacted<string>>>;\n readonly originals: Readonly<Record<string, Redacted.Redacted<string>>>;\n}\n\nexport type EnvironmentVariables = Resource<\n \"Convex.EnvironmentVariables\",\n EnvironmentVariablesProps,\n EnvironmentVariablesAttributes,\n never,\n Providers\n>;\nexport const EnvironmentVariables = Resource<EnvironmentVariables>(\n \"Convex.EnvironmentVariables\",\n);\n\nexport class EnvironmentTargetChange extends Schema.TaggedError<\n EnvironmentTargetChange,\n { readonly brand: unique symbol }\n>()(\"EnvironmentTargetChange\", { url: Schema.String }) {}\n\nexport const provider = Effect.gen(function* () {\n const client = yield* ConvexClient.ConvexClient;\n const redacted = (value: string | Redacted.Redacted<string>) =>\n typeof value === \"string\" ? Redacted.make(value) : value;\n const valueAt = (\n variables: Readonly<Record<string, Redacted.Redacted<string>>>,\n name: string,\n ) => (Rec.has(variables, name) ? variables[name] : undefined);\n const select = (\n variables: Readonly<Record<string, Redacted.Redacted<string>>>,\n names: ReadonlyArray<string>,\n ) =>\n Rec.fromEntries(\n Arr.flatMap(names, (name) =>\n !Rec.has(variables, name) ? [] : [[name, variables[name]]],\n ),\n );\n return {\n diff: Effect.fn(\"EnvironmentVariables.diff\")(function* ({ news, output }) {\n if (!isResolved(news) || output === undefined) return;\n if (news.url !== output.url)\n return yield* EnvironmentTargetChange.make({\n url: output.url,\n });\n const names = Rec.keys(news.variables);\n if (\n names.length !== output.ownedNames.length ||\n Arr.some(names, (name) => !output.ownedNames.includes(name))\n )\n return { action: \"update\" };\n const variables = yield* client.listEnvironmentVariables(\n news.url,\n news.deployKey,\n );\n for (const [name, value] of Rec.toEntries(news.variables)) {\n const observed = valueAt(variables, name);\n if (\n observed === undefined ||\n Redacted.value(observed) !== Redacted.value(redacted(value))\n )\n return { action: \"update\" };\n }\n }),\n read: Effect.fn(\"EnvironmentVariables.read\")(function* ({ olds, output }) {\n const url = output?.url ?? olds.url;\n if (url === undefined || olds.deployKey === undefined) return;\n const observed = yield* client.listEnvironmentVariables(\n url,\n olds.deployKey,\n );\n const ownedNames = output?.ownedNames ?? Rec.keys(olds.variables);\n const variables = select(observed, ownedNames);\n if (output !== undefined)\n return { ...output, deployKey: olds.deployKey, variables };\n if (Rec.keys(variables).length === 0) return undefined;\n return Unowned({\n url,\n deployKey: olds.deployKey,\n ownedNames,\n variables,\n originals: variables,\n });\n }),\n reconcile: Effect.fn(\"EnvironmentVariables.reconcile\")(function* ({\n fqn,\n instanceId,\n news,\n output,\n }) {\n if (output === undefined) yield* checkpointCreate(fqn, instanceId, news);\n if (output !== undefined && output.url !== news.url)\n return yield* EnvironmentTargetChange.make({\n url: output.url,\n });\n const observed = yield* client.listEnvironmentVariables(\n news.url,\n news.deployKey,\n );\n const ownedNames = Rec.keys(news.variables);\n if (output === undefined && (yield* shouldAdopt(fqn))) {\n const variables = select(observed, ownedNames);\n output = {\n url: news.url,\n deployKey: news.deployKey,\n ownedNames,\n variables,\n originals: variables,\n };\n yield* checkpointCreate(fqn, instanceId, news, output);\n }\n const previousNames = output?.ownedNames ?? [];\n for (const name of ownedNames) {\n if (\n !previousNames.includes(name) &&\n valueAt(observed, name) !== undefined\n )\n return yield* new OwnedBySomeoneElse({\n message:\n \"An existing environment variable requires explicit adoption in a separate resource.\",\n resourceType: EnvironmentVariables.Type,\n physicalName: name,\n });\n }\n const desired = Rec.fromEntries(\n Arr.map(Rec.toEntries(news.variables), ([name, value]) => [\n name,\n redacted(value),\n ]),\n );\n const changes: Array<{\n name: string;\n value?: Redacted.Redacted<string>;\n }> = [];\n for (const [name, value] of Rec.toEntries(desired)) {\n const current = valueAt(observed, name);\n if (\n current === undefined ||\n Redacted.value(current) !== Redacted.value(value)\n )\n changes.push({ name, value });\n }\n for (const name of previousNames) {\n if (Rec.has(desired, name)) continue;\n const original =\n output !== undefined ? valueAt(output.originals, name) : undefined;\n const current = valueAt(observed, name);\n if (original !== undefined) {\n if (\n current === undefined ||\n Redacted.value(current) !== Redacted.value(original)\n )\n changes.push({ name, value: original });\n } else if (current !== undefined) changes.push({ name });\n }\n if (changes.length > 0)\n yield* client.updateEnvironmentVariables(\n news.url,\n news.deployKey,\n changes,\n );\n return {\n url: news.url,\n deployKey: news.deployKey,\n ownedNames,\n variables: desired,\n originals: select(output?.originals ?? {}, ownedNames),\n };\n }),\n delete: Effect.fn(\"EnvironmentVariables.delete\")(function* ({ output }) {\n const observed = yield* client\n .listEnvironmentVariables(output.url, output.deployKey)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void));\n if (observed === undefined) return;\n const changes: Array<{\n name: string;\n value?: Redacted.Redacted<string>;\n }> = [];\n for (const name of output.ownedNames) {\n const original = valueAt(output.originals, name);\n const current = valueAt(observed, name);\n if (original !== undefined) {\n if (\n current === undefined ||\n Redacted.value(current) !== Redacted.value(original)\n )\n changes.push({ name, value: original });\n } else if (current !== undefined) changes.push({ name });\n }\n if (changes.length > 0)\n yield* client\n .updateEnvironmentVariables(output.url, output.deployKey, changes)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void));\n }),\n } satisfies Provider.ProviderServiceInput<EnvironmentVariables>;\n});\n\n/**\n * Under `alchemy dev` variables are managed on the local backend. A backend\n * that is not running keeps its variables in its retained data, so removing\n * them is skipped rather than failing the apply.\n */\nexport const localProvider = Effect.map(\n provider,\n (service) =>\n ({\n ...service,\n delete: (input) =>\n service.delete(input).pipe(\n Effect.catchIf(\n (error) =>\n error._tag === \"ConvexApiError\" &&\n error.code === \"TransportError\",\n () => Effect.void,\n ),\n ),\n }) satisfies Provider.ProviderServiceInput<EnvironmentVariables>,\n);\n\nexport const layer = Provider.effect(EnvironmentVariables, provider);\nexport const localLayer = Provider.effect(\n EnvironmentVariables,\n localProvider,\n).pipe(\n Layer.provide(\n ConvexClient.layer({ mode: \"local\" }).pipe(\n Layer.provide(FetchHttpClient.layer),\n ),\n ),\n);\n"],"mappings":";;;;;;;;;;;;;;AAuCA,MAAa,uBAAuB,SAClC,6BACF;AAEA,IAAa,0BAAb,cAA6C,OAAO,YAGlD,CAAC,CAAC,2BAA2B,EAAE,KAAK,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AAExD,MAAa,WAAW,OAAO,IAAI,aAAa;CAC9C,MAAM,SAAS,OAAOA;CACtB,MAAM,YAAY,UAChB,OAAO,UAAU,WAAW,SAAS,KAAK,KAAK,IAAI;CACrD,MAAM,WACJ,WACA,SACI,IAAI,IAAI,WAAW,IAAI,IAAI,UAAU,QAAQ,KAAA;CACnD,MAAM,UACJ,WACA,UAEA,IAAI,YACF,IAAI,QAAQ,QAAQ,SAClB,CAAC,IAAI,IAAI,WAAW,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,UAAU,KAAK,CAAC,CAC3D,CACF;CACF,OAAO;EACL,MAAM,OAAO,GAAG,2BAA2B,CAAC,C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;;;;;;AAOD,MAAa,gBAAgB,OAAO,IAClC,WACC,aACE;CACC,GAAG;CACH,SAAS,UACP,QAAQ,OAAO,KAAK,CAAC,CAAC,KACpB,OAAO,SACJ,UACC,MAAM,SAAS,oBACf,MAAM,SAAS,wBACX,OAAO,IACf,CACF;AACJ,EACJ;AAEA,MAAa,QAAQ,SAAS,OAAO,sBAAsB,QAAQ;AACnE,MAAa,aAAa,SAAS,OACjC,sBACA,aACF,CAAC,CAAC,KACA,MAAM,QACJC,QAAmB,EAAE,MAAM,QAAQ,CAAC,CAAC,CAAC,KACpC,MAAM,QAAQ,gBAAgB,KAAK,CACrC,CACF,CACF"}
|
|
1
|
+
{"version":3,"file":"EnvironmentVariables.js","names":["ConvexClient.ConvexClient","ConvexClient.ConvexApiError","ConvexClient.layer"],"sources":["../src/EnvironmentVariables.ts"],"sourcesContent":["import { OwnedBySomeoneElse, Unowned } from \"alchemy/AdoptPolicy\";\nimport { isResolved } from \"alchemy/Diff\";\nimport type { Input, InputProps } from \"alchemy/Input\";\nimport * as Output from \"alchemy/Output\";\nimport * as Provider from \"alchemy/Provider\";\nimport {\n Resource,\n type ResourceClass,\n type ResourceConstructor,\n} from \"alchemy/Resource\";\nimport * as Effectable from \"effect/Effectable\";\nimport * as Config from \"effect/Config\";\nimport * as Result from \"effect/Result\";\nimport * as Duration from \"effect/Duration\";\nimport * as Option from \"effect/Option\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Schedule from \"effect/Schedule\";\nimport { PushLock, PushLockError } from \"./internal/PushLock.js\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as FetchHttpClient from \"effect/http/FetchHttpClient\";\nimport * as Redacted from \"effect/Redacted\";\nimport * as Schema from \"effect/Schema\";\n\nimport * as ConvexClient from \"./ConvexClient.js\";\nimport type { Providers } from \"./Providers.js\";\nimport { checkpointCreate, shouldAdopt } from \"./internal/Lifecycle.js\";\nimport * as Arr from \"effect/Array\";\nimport * as Rec from \"effect/Record\";\n\nexport interface EnvironmentVariablesProps {\n /**\n * Refuse live owned values that differ from both the last write and the\n * desired value. Defaults to `overwrite`.\n */\n readonly driftPolicy?: \"overwrite\" | \"error\";\n /**\n * Adopt unowned desired names only when their live values match. Defaults to\n * false.\n */\n readonly adoptMatching?: boolean;\n /**\n * Refuse live names that are neither owned nor desired. Defaults to `ignore`.\n */\n readonly unownedPolicy?: \"ignore\" | \"error\";\n /**\n * Share the deployment push lock for checks and writes. Absent by default.\n */\n readonly lock?: { readonly deploymentName: string };\n /**\n * Retry write conflicts only, with 1 to 10 attempts and a delay of 1 to 10000\n * ms. Absent means one attempt.\n */\n readonly retry?: {\n readonly maxAttempts: number;\n readonly delay: Duration.Input;\n };\n readonly url: string;\n readonly deployKey: Redacted.Redacted<string>;\n readonly variables: Readonly<\n Record<string, string | Redacted.Redacted<string>>\n >;\n}\n\nexport interface EnvironmentVariablesAttributes {\n readonly url: string;\n readonly deployKey: Redacted.Redacted<string>;\n readonly ownedNames: ReadonlyArray<string>;\n readonly variables: Readonly<Record<string, Redacted.Redacted<string>>>;\n readonly originals: Readonly<Record<string, Redacted.Redacted<string>>>;\n}\n\nexport type EnvironmentVariables = Resource<\n \"Convex.EnvironmentVariables\",\n EnvironmentVariablesProps,\n EnvironmentVariablesAttributes,\n never,\n Providers\n>;\nconst environmentVariables = Resource<EnvironmentVariables>(\n \"Convex.EnvironmentVariables\",\n);\n\n// Alchemy skips provider reads for fresh resources with unresolved inputs.\nexport const EnvironmentVariables: ResourceClass<EnvironmentVariables> =\n Object.assign(\n new Proxy(environmentVariables, {\n apply: <PropsReq>(\n target: ResourceClass<EnvironmentVariables>,\n _this: unknown,\n args:\n | [methods: object]\n | [\n id: string,\n props:\n | InputProps<EnvironmentVariablesProps>\n | Effect.Effect<\n InputProps<EnvironmentVariablesProps>,\n never,\n PropsReq\n >,\n ],\n ) => {\n if (args.length === 1)\n return Object.assign(EnvironmentVariables, args[0]);\n const [id, props] = args;\n return target(\n id,\n (Effect.isEffect(props) ? props : Effect.succeed(props)).pipe(\n Effect.flatMap((options) =>\n Effect.fromResult(validateSafety(options)).pipe(\n Effect.orDie,\n Effect.as({\n ...options,\n ...(options.retry === undefined\n ? {}\n : { retry: checkedRetry(options.retry) }),\n ...(options.lock === undefined\n ? {}\n : { lock: checkedLock(options.lock) }),\n }),\n ),\n ),\n ),\n );\n },\n }),\n Effectable.Prototype<\n Effect.Effect<ResourceConstructor<EnvironmentVariables>>\n >({\n label: \"Resource<Convex.EnvironmentVariables>\",\n evaluate: () => Effect.succeed(EnvironmentVariables),\n }),\n );\n\nexport class EnvironmentTargetChange extends Schema.TaggedError<\n EnvironmentTargetChange,\n { readonly brand: unique symbol }\n>()(\"EnvironmentTargetChange\", { url: Schema.String }) {}\n\nexport class EnvironmentVariableDrift extends Schema.TaggedError<\n EnvironmentVariableDrift,\n { readonly brand: unique symbol }\n>()(\"EnvironmentVariableDrift\", { variableName: Schema.String }) {\n override get message() {\n return `Environment variable ${this.variableName} differs from its last managed value`;\n }\n}\n\nexport class EnvironmentVariableUnowned extends Schema.TaggedError<\n EnvironmentVariableUnowned,\n { readonly brand: unique symbol }\n>()(\"EnvironmentVariableUnowned\", { variableName: Schema.String }) {\n override get message() {\n return `Environment variable ${this.variableName} is neither owned nor desired`;\n }\n}\n\nexport class EnvironmentVariablesInvalidOption extends Schema.TaggedError<\n EnvironmentVariablesInvalidOption,\n { readonly brand: unique symbol }\n>()(\"EnvironmentVariablesInvalidOption\", {\n option: Schema.Literals([\"maxAttempts\", \"delay\", \"deploymentName\"]),\n}) {\n override get message() {\n switch (this.option) {\n case \"maxAttempts\":\n return \"Environment retry maxAttempts must be an integer from 1 to 10\";\n case \"delay\":\n return \"Environment retry delay must be from 1 to 10000 milliseconds\";\n case \"deploymentName\":\n return \"Environment lock deploymentName must contain lowercase letters or digits separated by single hyphens\";\n }\n }\n}\n\ntype SafetyOptions = {\n readonly retry?: EnvironmentVariablesProps[\"retry\"];\n readonly lock?: EnvironmentVariablesProps[\"lock\"];\n};\n\nconst validateMaxAttempts = (\n maxAttempts: number,\n): Result.Result<void, EnvironmentVariablesInvalidOption> =>\n Number.isInteger(maxAttempts) && maxAttempts >= 1 && maxAttempts <= 10\n ? Result.succeed(undefined)\n : Result.fail(\n EnvironmentVariablesInvalidOption.make({ option: \"maxAttempts\" }),\n );\n\nconst validateDelay = (\n delay: Duration.Input,\n): Result.Result<Duration.Duration, EnvironmentVariablesInvalidOption> => {\n const parsed = Duration.fromInput(delay);\n return Option.isSome(parsed) &&\n Duration.toMillis(parsed.value) >= 1 &&\n Duration.toMillis(parsed.value) <= 10000\n ? Result.succeed(parsed.value)\n : Result.fail(EnvironmentVariablesInvalidOption.make({ option: \"delay\" }));\n};\n\nconst validateDeploymentName = (\n deploymentName: string,\n): Result.Result<void, EnvironmentVariablesInvalidOption> =>\n /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(deploymentName)\n ? Result.succeed(undefined)\n : Result.fail(\n EnvironmentVariablesInvalidOption.make({ option: \"deploymentName\" }),\n );\n\nconst validateSafety = (\n options: Input<SafetyOptions>,\n): Result.Result<\n Duration.Duration | undefined,\n EnvironmentVariablesInvalidOption\n> =>\n Result.gen(function* () {\n let duration: Duration.Duration | undefined;\n if (\n \"retry\" in options &&\n options.retry !== undefined &&\n \"maxAttempts\" in options.retry &&\n \"delay\" in options.retry\n ) {\n if (isResolved(options.retry.maxAttempts))\n yield* validateMaxAttempts(options.retry.maxAttempts);\n if (isResolved(options.retry.delay))\n duration = yield* validateDelay(options.retry.delay);\n }\n if (\n \"lock\" in options &&\n options.lock !== undefined &&\n \"deploymentName\" in options.lock &&\n isResolved(options.lock.deploymentName)\n )\n yield* validateDeploymentName(options.lock.deploymentName);\n return duration;\n });\n\nconst checkedInput = <A>(\n input: Exclude<Input<A>, undefined>,\n validate: (\n value: A,\n ) => Result.Result<unknown, EnvironmentVariablesInvalidOption>,\n): Exclude<Input<A>, undefined> => {\n const check = (value: A) =>\n Effect.fromResult(validate(value)).pipe(Effect.orDie, Effect.as(value));\n if (Config.isConfig(input)) return input.pipe(Config.mapEffect(check));\n return input;\n};\n\nconst checkedRetry = (\n input: Exclude<Input<SafetyOptions[\"retry\"]>, undefined>,\n): Exclude<Input<SafetyOptions[\"retry\"]>, undefined> => {\n if (\"maxAttempts\" in input && \"delay\" in input)\n return {\n ...input,\n maxAttempts: checkedInput(input.maxAttempts, validateMaxAttempts),\n delay: checkedInput(input.delay, validateDelay),\n };\n return checkedInput(input, (retry) => validateSafety({ retry }));\n};\n\nconst checkedLock = (\n input: Exclude<Input<SafetyOptions[\"lock\"]>, undefined>,\n): Exclude<Input<SafetyOptions[\"lock\"]>, undefined> => {\n if (\"deploymentName\" in input)\n return {\n ...input,\n deploymentName: checkedInput(\n input.deploymentName,\n validateDeploymentName,\n ),\n };\n return checkedInput(input, (lock) => validateSafety({ lock }));\n};\n\nconst ownershipConflict = (variableName: string) =>\n new OwnedBySomeoneElse({\n message:\n \"An existing environment variable requires explicit adoption in a separate resource.\",\n resourceType: EnvironmentVariables.Type,\n physicalName: variableName,\n });\n\nconst optionsForDiff = (\n olds: EnvironmentVariablesProps,\n news: Input<EnvironmentVariablesProps>,\n) => {\n if (!(\"variables\" in news))\n return { ...olds, desiredNames: undefined, desiredVariables: undefined };\n return {\n driftPolicy: isResolved(news.driftPolicy)\n ? news.driftPolicy\n : olds.driftPolicy,\n adoptMatching: isResolved(news.adoptMatching)\n ? news.adoptMatching\n : olds.adoptMatching,\n unownedPolicy: isResolved(news.unownedPolicy)\n ? news.unownedPolicy\n : olds.unownedPolicy,\n lock: isResolved(news.lock) ? news.lock : olds.lock,\n retry: isResolved(news.retry) ? news.retry : olds.retry,\n desiredVariables: news.variables,\n desiredNames:\n !Output.isExpr(news.variables) &&\n !Effect.isEffect(news.variables) &&\n Predicate.isReadonlyObject(news.variables)\n ? Rec.keys<string, unknown>(news.variables)\n : undefined,\n };\n};\n\nexport const provider = Effect.gen(function* () {\n const client = yield* ConvexClient.ConvexClient;\n const lock = yield* Effect.serviceOption(PushLock);\n const withSafety = Effect.fn(\"EnvironmentVariables.withSafety\")(function* <\n A,\n E,\n R,\n >(\n options: {\n readonly lock?: EnvironmentVariablesProps[\"lock\"];\n readonly retry?: EnvironmentVariablesProps[\"retry\"];\n },\n effect: Effect.Effect<A, E, R>,\n ) {\n const duration = yield* Effect.fromResult(validateSafety(options));\n let attempt = effect;\n if (options.retry !== undefined && duration !== undefined) {\n const { maxAttempts } = options.retry;\n attempt = effect.pipe(\n Effect.retry({\n times: maxAttempts - 1,\n schedule: Schedule.spaced(duration),\n while: (error) =>\n Schema.is(ConvexClient.ConvexApiError)(error) &&\n error.serverCode === \"OptimisticConcurrencyControlFailure\",\n }),\n );\n }\n if (options.lock === undefined) return yield* attempt;\n if (Option.isNone(lock))\n return yield* PushLockError.make({\n deploymentName: options.lock.deploymentName,\n reason: \"configuration\",\n missing: \"PushLock\",\n });\n return yield* lock.value.withLock(options.lock.deploymentName, attempt);\n });\n const redacted = (value: string | Redacted.Redacted<string>) =>\n typeof value === \"string\" ? Redacted.make(value) : value;\n const valueAt = (\n variables: Readonly<Record<string, Redacted.Redacted<string>>>,\n name: string,\n ) => (Rec.has(variables, name) ? variables[name] : undefined);\n const select = (\n variables: Readonly<Record<string, Redacted.Redacted<string>>>,\n names: ReadonlyArray<string>,\n ) =>\n Rec.fromEntries(\n Arr.flatMap(names, (name) =>\n !Rec.has(variables, name) ? [] : [[name, variables[name]]],\n ),\n );\n const checkDrift = (\n policy: EnvironmentVariablesProps[\"driftPolicy\"],\n output: EnvironmentVariablesAttributes | undefined,\n observed: ConvexClient.EnvironmentVariables,\n desired: Input<EnvironmentVariablesProps[\"variables\"]> | undefined,\n ) => {\n if (policy !== \"error\" || output === undefined) return Effect.void;\n const desiredVariables =\n Predicate.isReadonlyObject(desired) &&\n !Output.isExpr(desired) &&\n !Effect.isEffect(desired)\n ? desired\n : undefined;\n for (const name of output.ownedNames) {\n const previous = valueAt(output.variables, name);\n const current = valueAt(observed, name);\n const wanted = desiredVariables?.[name];\n if (\n current !== undefined &&\n (desiredVariables === undefined ||\n (wanted !== undefined && !isResolved(wanted)))\n )\n continue;\n if (\n current !== undefined &&\n (typeof wanted === \"string\" || Redacted.isRedacted(wanted)) &&\n Redacted.value(current) ===\n (typeof wanted === \"string\" ? wanted : Redacted.value(wanted))\n )\n continue;\n if (previous === undefined && current === undefined) continue;\n if (\n previous === undefined ||\n current === undefined ||\n Redacted.value(previous) !== Redacted.value(current)\n )\n return Effect.fail(\n EnvironmentVariableDrift.make({ variableName: name }),\n );\n }\n return Effect.void;\n };\n const checkUnowned = (\n policy: EnvironmentVariablesProps[\"unownedPolicy\"],\n output: EnvironmentVariablesAttributes | undefined,\n desiredNames: ReadonlyArray<string> | undefined,\n observed: ConvexClient.EnvironmentVariables,\n ) => {\n if (policy !== \"error\" || desiredNames === undefined) return Effect.void;\n for (const name of Rec.keys(observed)) {\n if (\n output?.ownedNames.includes(name) !== true &&\n !desiredNames.includes(name)\n )\n return Effect.fail(\n EnvironmentVariableUnowned.make({ variableName: name }),\n );\n }\n return Effect.void;\n };\n const service = {\n diff: Effect.fn(\"EnvironmentVariables.diff\")(function* ({\n olds,\n news,\n output,\n }) {\n const options = optionsForDiff(olds, news);\n if (\n output !== undefined &&\n (options.driftPolicy === \"error\" ||\n options.unownedPolicy === \"error\" ||\n options.adoptMatching === true)\n ) {\n const observed = yield* client.listEnvironmentVariables(\n output.url,\n output.deployKey,\n );\n yield* checkDrift(\n options.driftPolicy,\n output,\n observed,\n options.desiredVariables,\n );\n if (\n options.adoptMatching === true &&\n Predicate.isReadonlyObject(options.desiredVariables) &&\n !Output.isExpr(options.desiredVariables) &&\n !Effect.isEffect(options.desiredVariables)\n ) {\n for (const [name, wanted] of Rec.toEntries(\n options.desiredVariables,\n )) {\n const current = valueAt(observed, name);\n if (\n !output.ownedNames.includes(name) &&\n current !== undefined &&\n (typeof wanted === \"string\" || Redacted.isRedacted(wanted)) &&\n Redacted.value(current) !==\n (typeof wanted === \"string\" ? wanted : Redacted.value(wanted))\n )\n return yield* ownershipConflict(name);\n }\n }\n yield* checkUnowned(\n options.unownedPolicy,\n output,\n options.desiredNames,\n observed,\n );\n }\n if (!isResolved(news) || output === undefined) return;\n if (news.url !== output.url)\n return yield* EnvironmentTargetChange.make({\n url: output.url,\n });\n const names = Rec.keys(news.variables);\n if (\n names.length !== output.ownedNames.length ||\n Arr.some(names, (name) => !output.ownedNames.includes(name))\n )\n return { action: \"update\" };\n const variables = yield* client.listEnvironmentVariables(\n news.url,\n news.deployKey,\n );\n for (const [name, value] of Rec.toEntries(news.variables)) {\n const observed = valueAt(variables, name);\n if (\n observed === undefined ||\n Redacted.value(observed) !== Redacted.value(redacted(value))\n )\n return { action: \"update\" };\n }\n }),\n read: Effect.fn(\"EnvironmentVariables.read\")(function* ({ olds, output }) {\n const url = output?.url ?? olds.url;\n if (url === undefined || olds.deployKey === undefined) return;\n const observed = yield* client.listEnvironmentVariables(\n url,\n olds.deployKey,\n );\n yield* checkDrift(olds.driftPolicy, output, observed, olds.variables);\n yield* checkUnowned(\n olds.unownedPolicy,\n output,\n Rec.keys(olds.variables),\n observed,\n );\n const ownedNames = output?.ownedNames ?? Rec.keys(olds.variables);\n const variables = select(observed, ownedNames);\n if (output !== undefined)\n return { ...output, deployKey: olds.deployKey, variables };\n if (Rec.keys(variables).length === 0) return undefined;\n if (olds.adoptMatching === true) {\n for (const [name, value] of Rec.toEntries(variables)) {\n if (\n Redacted.value(value) !==\n Redacted.value(redacted(olds.variables[name]))\n )\n return yield* ownershipConflict(name);\n }\n return undefined;\n }\n return Unowned({\n url,\n deployKey: olds.deployKey,\n ownedNames,\n variables,\n originals: variables,\n });\n }),\n reconcile: Effect.fn(\"EnvironmentVariables.reconcile\")(function* ({\n fqn,\n instanceId,\n news,\n output,\n }) {\n if (output === undefined) yield* checkpointCreate(fqn, instanceId, news);\n if (output !== undefined && output.url !== news.url)\n return yield* EnvironmentTargetChange.make({\n url: output.url,\n });\n const observed = yield* client.listEnvironmentVariables(\n news.url,\n news.deployKey,\n );\n yield* checkDrift(news.driftPolicy, output, observed, news.variables);\n yield* checkUnowned(\n news.unownedPolicy,\n output,\n Rec.keys(news.variables),\n observed,\n );\n const ownedNames = Rec.keys(news.variables);\n if (\n output === undefined &&\n news.adoptMatching !== true &&\n (yield* shouldAdopt(fqn))\n ) {\n const variables = select(observed, ownedNames);\n output = {\n url: news.url,\n deployKey: news.deployKey,\n ownedNames,\n variables,\n originals: variables,\n };\n yield* checkpointCreate(fqn, instanceId, news, output);\n }\n const previousNames = output?.ownedNames ?? [];\n let originals = output?.originals ?? {};\n for (const name of ownedNames) {\n const current = valueAt(observed, name);\n if (previousNames.includes(name) || current === undefined) continue;\n if (\n news.adoptMatching === true &&\n Redacted.value(current) ===\n Redacted.value(redacted(news.variables[name]))\n ) {\n originals = Rec.set(originals, name, current);\n yield* Effect.logInfo(`Adopted environment variable ${name}`);\n } else {\n return yield* ownershipConflict(name);\n }\n }\n if (output === undefined && news.adoptMatching === true) {\n yield* checkpointCreate(fqn, instanceId, news, {\n url: news.url,\n deployKey: news.deployKey,\n ownedNames,\n variables: select(observed, ownedNames),\n originals,\n } satisfies EnvironmentVariablesAttributes);\n }\n const desired = Rec.fromEntries(\n Arr.map(Rec.toEntries(news.variables), ([name, value]) => [\n name,\n redacted(value),\n ]),\n );\n const changes: Array<{\n name: string;\n value?: Redacted.Redacted<string>;\n }> = [];\n for (const [name, value] of Rec.toEntries(desired)) {\n const current = valueAt(observed, name);\n if (\n current === undefined ||\n Redacted.value(current) !== Redacted.value(value)\n )\n changes.push({ name, value });\n }\n for (const name of previousNames) {\n if (Rec.has(desired, name)) continue;\n const original =\n output !== undefined ? valueAt(output.originals, name) : undefined;\n const current = valueAt(observed, name);\n if (original !== undefined) {\n if (\n current === undefined ||\n Redacted.value(current) !== Redacted.value(original)\n )\n changes.push({ name, value: original });\n } else if (current !== undefined) changes.push({ name });\n }\n if (changes.length > 0)\n yield* client.updateEnvironmentVariables(\n news.url,\n news.deployKey,\n changes,\n );\n return {\n url: news.url,\n deployKey: news.deployKey,\n ownedNames,\n variables: desired,\n originals: select(originals, ownedNames),\n };\n }),\n delete: Effect.fn(\"EnvironmentVariables.delete\")(function* ({\n olds,\n output,\n }) {\n const observed = yield* client\n .listEnvironmentVariables(output.url, output.deployKey)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void));\n if (observed === undefined) return;\n yield* checkDrift(olds.driftPolicy, output, observed, {});\n yield* checkUnowned(\n olds.unownedPolicy,\n output,\n Rec.keys(olds.variables),\n observed,\n );\n const changes: Array<{\n name: string;\n value?: Redacted.Redacted<string>;\n }> = [];\n for (const name of output.ownedNames) {\n const original = valueAt(output.originals, name);\n const current = valueAt(observed, name);\n if (original !== undefined) {\n if (\n current === undefined ||\n Redacted.value(current) !== Redacted.value(original)\n )\n changes.push({ name, value: original });\n } else if (current !== undefined) changes.push({ name });\n }\n if (changes.length > 0)\n yield* client\n .updateEnvironmentVariables(output.url, output.deployKey, changes)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void));\n }),\n } satisfies Provider.ProviderServiceInput<EnvironmentVariables>;\n return {\n diff: (input) =>\n withSafety(optionsForDiff(input.olds, input.news), service.diff(input)),\n read: (input) => withSafety(input.olds, service.read(input)),\n reconcile: (input) => withSafety(input.news, service.reconcile(input)),\n delete: (input) => withSafety(input.olds, service.delete(input)),\n } satisfies Provider.ProviderServiceInput<EnvironmentVariables>;\n});\n\n/**\n * Under `alchemy dev` variables are managed on the local backend. A backend\n * that is not running keeps its variables in its retained data, so removing\n * them is skipped rather than failing the apply.\n */\nexport const localProvider = Effect.map(\n provider,\n (service) =>\n ({\n ...service,\n delete: (input) =>\n service.delete(input).pipe(\n Effect.catchIf(\n (error) =>\n error._tag === \"ConvexApiError\" &&\n error.code === \"TransportError\",\n () => Effect.void,\n ),\n ),\n }) satisfies Provider.ProviderServiceInput<EnvironmentVariables>,\n);\n\nexport const layer = Provider.effect(EnvironmentVariables, provider);\nexport const localLayer = Provider.effect(\n EnvironmentVariables,\n localProvider,\n).pipe(\n Layer.provide(\n ConvexClient.layer({ mode: \"local\" }).pipe(\n Layer.provide(FetchHttpClient.layer),\n ),\n ),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA+EA,MAAM,uBAAuB,SAC3B,6BACF;AAGA,MAAa,uBACX,OAAO,OACL,IAAI,MAAM,sBAAsB,EAC9B,QACE,QACA,OACA,SAYG;CACH,IAAI,KAAK,WAAW,GAClB,OAAO,OAAO,OAAO,sBAAsB,KAAK,EAAE;CACpD,MAAM,CAAC,IAAI,SAAS;CACpB,OAAO,OACL,KACC,OAAO,SAAS,KAAK,IAAI,QAAQ,OAAO,QAAQ,KAAK,EAAA,CAAG,KACvD,OAAO,SAAS,YACd,OAAO,WAAW,eAAe,OAAO,CAAC,CAAC,CAAC,KACzC,OAAO,OACP,OAAO,GAAG;EACR,GAAG;EACH,GAAI,QAAQ,UAAU,KAAA,IAClB,CAAC,IACD,EAAE,OAAO,aAAa,QAAQ,KAAK,EAAE;EACzC,GAAI,QAAQ,SAAS,KAAA,IACjB,CAAC,IACD,EAAE,MAAM,YAAY,QAAQ,IAAI,EAAE;CACxC,CAAC,CACH,CACF,CACF,CACF;AACF,EACF,CAAC,GACD,WAAW,UAET;CACA,OAAO;CACP,gBAAgB,OAAO,QAAQ,oBAAoB;AACrD,CAAC,CACH;AAEF,IAAa,0BAAb,cAA6C,OAAO,YAGlD,CAAC,CAAC,2BAA2B,EAAE,KAAK,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AAExD,IAAa,2BAAb,cAA8C,OAAO,YAGnD,CAAC,CAAC,4BAA4B,EAAE,cAAc,OAAO,OAAO,CAAC,CAAC,CAAC;CAC/D,IAAa,UAAU;EACrB,OAAO,wBAAwB,KAAK,aAAa;CACnD;AACF;AAEA,IAAa,6BAAb,cAAgD,OAAO,YAGrD,CAAC,CAAC,8BAA8B,EAAE,cAAc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end {
|
|
|
44
44
|
export declare const dataDirectories: Effect.Effect<(deploymentName: string) => string, never, Path.Path | Stack>;
|
|
45
45
|
/**
|
|
46
46
|
* The admin key of a local deployment, for its deploy key resource.
|
|
47
|
+
*
|
|
48
|
+
* @stability unstable
|
|
47
49
|
*/
|
|
48
50
|
export declare const adminKey: (deploymentName: string, directory: string) => Effect.Effect<Redacted.Redacted<string>, LocalBackendError, FileSystem.FileSystem | Path.Path>;
|
|
49
51
|
export declare const remove: (deploymentName: string, directory: string) => Effect.Effect<void, LocalBackendError, FileSystem.FileSystem>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalBackend.d.ts","sources":["../../src/internal/LocalBackend.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,KAAK,YAAY,MAAM,4BAA4B,CAAC;AAE3D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAgB,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAUnE;;;;GAIG;AACH,eAAO,MAAM,cAAc,mCAAmC,CAAC;;;;;;oBAI3C,OAAO,MAAM;;AAFjC,qBAAa,iBAAkB,SAAQ,sBAiBrC;IACA,IAAa,OAAO,WAsBnB;CACF;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,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;;GAIG;AACH,eAAO,MAAM,QAAQ,+IAWnB,CAAC;AAEH,eAAO,MAAM,MAAM,8GAYjB,CAAC;AA0CH;;;;;;;;;GASG;AACH,eAAO,MAAM,IAAI;;;;;oKA8Nf,CAAC"}
|
|
@@ -123,6 +123,8 @@ const readIdentity = Effect.fn("LocalBackend.readIdentity")(function* (deploymen
|
|
|
123
123
|
});
|
|
124
124
|
/**
|
|
125
125
|
* The admin key of a local deployment, for its deploy key resource.
|
|
126
|
+
*
|
|
127
|
+
* @stability unstable
|
|
126
128
|
*/
|
|
127
129
|
const adminKey = Effect.fn("LocalBackend.adminKey")(function* (deploymentName, directory) {
|
|
128
130
|
const identity = yield* readIdentity(deploymentName, directory);
|