@gaganref/confect-alchemy 10.6.0-fork.26 → 10.6.0-fork.28
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/Convex.d.ts +1 -0
- package/dist/Convex.d.ts.map +1 -1
- package/dist/Convex.js +3 -1
- package/dist/Convex.js.map +1 -1
- package/dist/ConvexClient.d.ts +27 -0
- package/dist/ConvexClient.d.ts.map +1 -1
- package/dist/ConvexClient.js +27 -0
- package/dist/ConvexClient.js.map +1 -1
- package/dist/CustomDomain.d.ts +156 -0
- package/dist/CustomDomain.d.ts.map +1 -0
- package/dist/CustomDomain.js +255 -0
- package/dist/CustomDomain.js.map +1 -0
- package/dist/EnvironmentVariables.d.ts.map +1 -1
- package/dist/EnvironmentVariables.js +1 -0
- package/dist/EnvironmentVariables.js.map +1 -1
- package/dist/Providers.d.ts.map +1 -1
- package/dist/Providers.js +25 -20
- package/dist/Providers.js.map +1 -1
- package/dist/internal/Lifecycle.d.ts +1 -0
- package/dist/internal/Lifecycle.d.ts.map +1 -1
- package/dist/internal/Lifecycle.js +23 -1
- package/dist/internal/Lifecycle.js.map +1 -1
- package/package.json +3 -3
- package/src/Convex.ts +6 -0
- package/src/ConvexClient.ts +73 -0
- package/src/CustomDomain.ts +453 -0
- package/src/EnvironmentVariables.ts +6 -0
- package/src/Providers.ts +6 -0
- package/src/internal/Lifecycle.ts +20 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { ConvexClient } from "./ConvexClient.js";
|
|
2
|
+
import { checkpointCreate, checkpointUpdate, shouldAdopt } from "./internal/Lifecycle.js";
|
|
3
|
+
import * as Output from "alchemy/Output";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Provider from "alchemy/Provider";
|
|
6
|
+
import { Resource } from "alchemy/Resource";
|
|
7
|
+
import * as Schema from "effect/Schema";
|
|
8
|
+
import * as Option from "effect/Option";
|
|
9
|
+
import * as Array from "effect/Array";
|
|
10
|
+
import * as Record from "effect/Record";
|
|
11
|
+
import { OwnedBySomeoneElse, Unowned } from "alchemy/AdoptPolicy";
|
|
12
|
+
import { isResolved } from "alchemy/Diff";
|
|
13
|
+
import { Stack } from "alchemy/Stack";
|
|
14
|
+
import { State } from "alchemy/State/State";
|
|
15
|
+
import * as Semaphore from "effect/Semaphore";
|
|
16
|
+
// src/CustomDomain.ts
|
|
17
|
+
const CustomDomain = Resource("Convex.CustomDomain");
|
|
18
|
+
var CustomDomainNotVisible = class extends Schema.TaggedError()("CustomDomainNotVisible", {
|
|
19
|
+
deploymentName: Schema.String,
|
|
20
|
+
domain: Schema.String
|
|
21
|
+
}) {};
|
|
22
|
+
const identitySchema = Schema.Struct({
|
|
23
|
+
deploymentName: Schema.String,
|
|
24
|
+
domain: Schema.String,
|
|
25
|
+
requestDestination: Schema.Literals(["convexCloud", "convexSite"])
|
|
26
|
+
});
|
|
27
|
+
const identity = (props) => ({
|
|
28
|
+
deploymentName: props.deployment.name,
|
|
29
|
+
domain: props.domain,
|
|
30
|
+
requestDestination: props.requestDestination
|
|
31
|
+
});
|
|
32
|
+
var CustomDomainIdentityChange = class extends Schema.TaggedError()("CustomDomainIdentityChange", {
|
|
33
|
+
oldIdentity: identitySchema,
|
|
34
|
+
newIdentity: identitySchema
|
|
35
|
+
}) {
|
|
36
|
+
get message() {
|
|
37
|
+
const old = this.oldIdentity;
|
|
38
|
+
const next = this.newIdentity;
|
|
39
|
+
return `Cannot change custom domain identity from ${old.deploymentName}/${old.domain}/${old.requestDestination} to ${next.deploymentName}/${next.domain}/${next.requestDestination}. Declare a second Convex.CustomDomain with canonical: false, deploy and configure DNS, then move canonical: true after verification and remove the old resource. For the same hostname, remove it from the old deployment before declaring it on the new one.`;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var ConflictingCanonicalDomains = class extends Schema.TaggedError()("ConflictingCanonicalDomains", {
|
|
43
|
+
deploymentName: Schema.String,
|
|
44
|
+
requestDestination: Schema.String,
|
|
45
|
+
domains: Schema.Array(Schema.String)
|
|
46
|
+
}) {
|
|
47
|
+
get message() {
|
|
48
|
+
return `Declare only one canonical custom domain for ${this.deploymentName}/${this.requestDestination}.`;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const validateCanonicalOwner = Effect.fn("CustomDomain.validateCanonicalOwner")(function* (fqn, props) {
|
|
52
|
+
const stack = yield* Effect.serviceOption(Stack);
|
|
53
|
+
if (Option.isNone(stack)) return;
|
|
54
|
+
const declared = stack.value.resources[fqn];
|
|
55
|
+
if (declared === void 0 || isResolved(declared.Props.canonical) && declared.Props.canonical !== true) return;
|
|
56
|
+
if (props.canonical !== true || props.deployment === void 0 || props.requestDestination === void 0 || props.domain === void 0) return;
|
|
57
|
+
for (const resource of Record.values(stack.value.resources)) {
|
|
58
|
+
if (resource.Type !== CustomDomain.Type || resource.FQN === fqn) continue;
|
|
59
|
+
let other = resource.Props;
|
|
60
|
+
if (!isResolved(other)) {
|
|
61
|
+
const state = yield* Effect.serviceOption(State);
|
|
62
|
+
if (Option.isNone(state)) continue;
|
|
63
|
+
const store = yield* state.value;
|
|
64
|
+
const entries = yield* Effect.forEach(Record.keys(Output.upstreamAny(other)), Effect.fnUntraced(function* (source) {
|
|
65
|
+
const row = yield* store.get({
|
|
66
|
+
stack: stack.value.name,
|
|
67
|
+
stage: stack.value.stage,
|
|
68
|
+
fqn: source
|
|
69
|
+
});
|
|
70
|
+
return row === void 0 || row.kind === "action" || row.attr === void 0 ? void 0 : [source, row.attr];
|
|
71
|
+
}));
|
|
72
|
+
const upstream = Record.fromEntries(Array.filter(entries, (entry) => entry !== void 0));
|
|
73
|
+
other = yield* Output.evaluateAvailable(other, upstream).pipe(Effect.provideService(State, state.value));
|
|
74
|
+
}
|
|
75
|
+
if (isResolved(other) && other.canonical === true && other.deployment.name === props.deployment.name && other.requestDestination === props.requestDestination) return yield* ConflictingCanonicalDomains.make({
|
|
76
|
+
deploymentName: props.deployment.name,
|
|
77
|
+
requestDestination: props.requestDestination,
|
|
78
|
+
domains: [props.domain, other.domain]
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
const sameIdentity = (current, props) => current.deployment.name === props.deployment.name && current.domain === props.domain && current.requestDestination === props.requestDestination;
|
|
83
|
+
const validateIdentity = Effect.fn("CustomDomain.validateIdentity")(function* (current, props) {
|
|
84
|
+
if (!sameIdentity(current, props)) return yield* CustomDomainIdentityChange.make({
|
|
85
|
+
oldIdentity: identity(current),
|
|
86
|
+
newIdentity: identity(props)
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
const canonicalUrl = (urls, destination) => destination === "convexCloud" ? urls.convexCloudUrl : urls.convexSiteUrl;
|
|
90
|
+
const provider = Effect.gen(function* () {
|
|
91
|
+
const client = yield* ConvexClient;
|
|
92
|
+
const canonicalLocks = /* @__PURE__ */ new Map();
|
|
93
|
+
const withCanonicalLock = (deployment, destination, effect) => Effect.suspend(() => {
|
|
94
|
+
const key = `${deployment.name}/${destination}`;
|
|
95
|
+
let lock = canonicalLocks.get(key);
|
|
96
|
+
if (lock === void 0) {
|
|
97
|
+
lock = Semaphore.makeUnsafe(1);
|
|
98
|
+
canonicalLocks.set(key, lock);
|
|
99
|
+
}
|
|
100
|
+
return lock.withPermit(effect);
|
|
101
|
+
});
|
|
102
|
+
const find = Effect.fn("CustomDomain.find")(function* (props) {
|
|
103
|
+
const domains = yield* client.listCustomDomains(props.deployment.name).pipe(Effect.catchTag("ConvexNotFound", () => Effect.succeed([])));
|
|
104
|
+
return Option.getOrUndefined(Array.findFirst(domains, (domain) => domain.domain === props.domain && domain.requestDestination === props.requestDestination));
|
|
105
|
+
});
|
|
106
|
+
const resetCanonical = (output) => withCanonicalLock(output.deployment, output.requestDestination, Effect.gen(function* () {
|
|
107
|
+
const urls = yield* client.getCanonicalUrls(output.deployment.url).pipe(Effect.catchTag("ConvexNotFound", () => Effect.undefined));
|
|
108
|
+
if (urls !== void 0 && canonicalUrl(urls, output.requestDestination) === output.url) yield* client.updateCanonicalUrl(output.deployment.url, { requestDestination: output.requestDestination }).pipe(Effect.catchTag("ConvexNotFound", () => Effect.void));
|
|
109
|
+
}));
|
|
110
|
+
return {
|
|
111
|
+
diff: Effect.fn("CustomDomain.diff")(function* ({ fqn, news, output }) {
|
|
112
|
+
if (!isResolved(news)) return;
|
|
113
|
+
if (output !== void 0) yield* validateIdentity(output, news);
|
|
114
|
+
yield* validateCanonicalOwner(fqn, news);
|
|
115
|
+
if (output === void 0) return;
|
|
116
|
+
const current = yield* find(news);
|
|
117
|
+
if (output.deployment.url !== news.deployment.url || current === void 0 || (current.verificationTime ?? null) !== output.verificationTime || output.canonical !== (news.canonical ?? false)) return { action: "update" };
|
|
118
|
+
const urls = yield* client.getCanonicalUrls(news.deployment.url);
|
|
119
|
+
if (canonicalUrl(urls, news.requestDestination) !== output.canonicalUrl || news.canonical === true && current.verificationTime != null && canonicalUrl(urls, news.requestDestination) !== `https://${news.domain}`) return { action: "update" };
|
|
120
|
+
}),
|
|
121
|
+
read: Effect.fn("CustomDomain.read")(function* ({ fqn, olds, output }) {
|
|
122
|
+
if (output === void 0) {
|
|
123
|
+
yield* validateCanonicalOwner(fqn, olds);
|
|
124
|
+
if (olds.deployment === void 0 || olds.domain === void 0 || olds.requestDestination === void 0) return;
|
|
125
|
+
const current = yield* find({
|
|
126
|
+
deployment: olds.deployment,
|
|
127
|
+
domain: olds.domain,
|
|
128
|
+
requestDestination: olds.requestDestination
|
|
129
|
+
});
|
|
130
|
+
if (current === void 0) return;
|
|
131
|
+
const urls = yield* client.getCanonicalUrls(olds.deployment.url);
|
|
132
|
+
const attributes = {
|
|
133
|
+
deployment: olds.deployment,
|
|
134
|
+
domain: current.domain,
|
|
135
|
+
requestDestination: current.requestDestination,
|
|
136
|
+
canonical: olds.canonical ?? false,
|
|
137
|
+
verificationTime: current.verificationTime ?? null,
|
|
138
|
+
url: `https://${current.domain}`,
|
|
139
|
+
canonicalUrl: canonicalUrl(urls, current.requestDestination)
|
|
140
|
+
};
|
|
141
|
+
return Unowned(attributes);
|
|
142
|
+
}
|
|
143
|
+
const current = yield* find(output);
|
|
144
|
+
if (current === void 0 && !output.canonical) return;
|
|
145
|
+
const urls = yield* client.getCanonicalUrls(output.deployment.url).pipe(Effect.catchTag("ConvexNotFound", () => Effect.void));
|
|
146
|
+
if (urls === void 0) return;
|
|
147
|
+
return {
|
|
148
|
+
...output,
|
|
149
|
+
verificationTime: current?.verificationTime ?? null,
|
|
150
|
+
canonicalUrl: canonicalUrl(urls, output.requestDestination)
|
|
151
|
+
};
|
|
152
|
+
}),
|
|
153
|
+
reconcile: Effect.fn("CustomDomain.reconcile")(function* ({ fqn, instanceId, news, output }) {
|
|
154
|
+
if (output !== void 0) yield* validateIdentity(output, news);
|
|
155
|
+
yield* validateCanonicalOwner(fqn, news);
|
|
156
|
+
if (output === void 0) yield* checkpointCreate(fqn, instanceId, news);
|
|
157
|
+
let current = yield* find(news);
|
|
158
|
+
if (current !== void 0 && output === void 0 && !(yield* shouldAdopt(fqn))) return yield* new OwnedBySomeoneElse({
|
|
159
|
+
message: `Custom domain ${news.domain} requires explicit adoption. Re-run with --adopt or adopt(true) to take it over.`,
|
|
160
|
+
resourceType: CustomDomain.Type,
|
|
161
|
+
physicalName: news.domain
|
|
162
|
+
});
|
|
163
|
+
const url = `https://${news.domain}`;
|
|
164
|
+
const canonical = news.canonical ?? false;
|
|
165
|
+
const attributes = {
|
|
166
|
+
deployment: news.deployment,
|
|
167
|
+
domain: news.domain,
|
|
168
|
+
requestDestination: news.requestDestination,
|
|
169
|
+
canonical: canonical || (output?.canonical ?? false),
|
|
170
|
+
verificationTime: current?.verificationTime ?? null,
|
|
171
|
+
url,
|
|
172
|
+
canonicalUrl: output?.canonicalUrl ?? url
|
|
173
|
+
};
|
|
174
|
+
if (current === void 0) {
|
|
175
|
+
yield* client.createCustomDomain(news.deployment.name, {
|
|
176
|
+
domain: news.domain,
|
|
177
|
+
requestDestination: news.requestDestination
|
|
178
|
+
});
|
|
179
|
+
yield* checkpointCreate(fqn, instanceId, news, attributes);
|
|
180
|
+
current = yield* find(news);
|
|
181
|
+
}
|
|
182
|
+
if (current === void 0) return yield* CustomDomainNotVisible.make({
|
|
183
|
+
deploymentName: news.deployment.name,
|
|
184
|
+
domain: news.domain
|
|
185
|
+
});
|
|
186
|
+
yield* checkpointCreate(fqn, instanceId, news, attributes);
|
|
187
|
+
if (output !== void 0 && canonical && !output.canonical) yield* checkpointUpdate(fqn, instanceId, {
|
|
188
|
+
...output,
|
|
189
|
+
canonical: true
|
|
190
|
+
});
|
|
191
|
+
const urls = yield* withCanonicalLock(news.deployment, news.requestDestination, Effect.gen(function* () {
|
|
192
|
+
let currentUrls = yield* client.getCanonicalUrls(news.deployment.url);
|
|
193
|
+
if (canonical && current.verificationTime == null) yield* Effect.logInfo(`Canonical URL for ${news.domain} is pending verification.`);
|
|
194
|
+
else if (canonical && canonicalUrl(currentUrls, news.requestDestination) !== url) {
|
|
195
|
+
yield* client.updateCanonicalUrl(news.deployment.url, {
|
|
196
|
+
requestDestination: news.requestDestination,
|
|
197
|
+
url
|
|
198
|
+
});
|
|
199
|
+
currentUrls = yield* client.getCanonicalUrls(news.deployment.url);
|
|
200
|
+
} else if (!canonical && output?.canonical === true && canonicalUrl(currentUrls, news.requestDestination) === url) {
|
|
201
|
+
yield* client.updateCanonicalUrl(news.deployment.url, { requestDestination: news.requestDestination });
|
|
202
|
+
currentUrls = yield* client.getCanonicalUrls(news.deployment.url);
|
|
203
|
+
}
|
|
204
|
+
return currentUrls;
|
|
205
|
+
}));
|
|
206
|
+
const result = {
|
|
207
|
+
...attributes,
|
|
208
|
+
canonical,
|
|
209
|
+
verificationTime: current.verificationTime ?? null,
|
|
210
|
+
canonicalUrl: canonicalUrl(urls, news.requestDestination)
|
|
211
|
+
};
|
|
212
|
+
yield* checkpointCreate(fqn, instanceId, news, result);
|
|
213
|
+
return result;
|
|
214
|
+
}),
|
|
215
|
+
delete: Effect.fn("CustomDomain.delete")(function* ({ fqn, output }) {
|
|
216
|
+
const stack = yield* Effect.serviceOption(Stack);
|
|
217
|
+
const state = yield* Effect.serviceOption(State);
|
|
218
|
+
if (Option.isSome(stack) && Option.isSome(state)) {
|
|
219
|
+
const store = yield* state.value;
|
|
220
|
+
for (const resource of Record.values(stack.value.resources)) {
|
|
221
|
+
if (resource.Type !== CustomDomain.Type || resource.FQN === fqn) continue;
|
|
222
|
+
const row = yield* store.get({
|
|
223
|
+
stack: stack.value.name,
|
|
224
|
+
stage: stack.value.stage,
|
|
225
|
+
fqn: resource.FQN
|
|
226
|
+
});
|
|
227
|
+
if (row !== void 0 && row.kind !== "action" && row.resourceType === CustomDomain.Type && row.attr?.deployment?.name === output.deployment.name && row.attr?.domain === output.domain && row.attr?.requestDestination === output.requestDestination) {
|
|
228
|
+
if (output.canonical && row.attr.canonical !== true) yield* resetCanonical(output);
|
|
229
|
+
yield* Effect.logInfo(`Skipping delete of ${output.domain}; ${resource.FQN} keeps it.`);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
yield* resetCanonical(output);
|
|
235
|
+
yield* client.deleteCustomDomain(output.deployment.name, {
|
|
236
|
+
domain: output.domain,
|
|
237
|
+
requestDestination: output.requestDestination
|
|
238
|
+
}).pipe(Effect.catchTag("ConvexNotFound", () => Effect.void));
|
|
239
|
+
})
|
|
240
|
+
};
|
|
241
|
+
});
|
|
242
|
+
const layer = Provider.effect(CustomDomain, provider);
|
|
243
|
+
var UnsupportedLocalCustomDomain = class extends Schema.TaggedError()("UnsupportedLocalCustomDomain", {}) {
|
|
244
|
+
get message() {
|
|
245
|
+
return "Declare Convex.CustomDomain only for cloud stages.";
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
const localProvider = Effect.succeed({
|
|
249
|
+
reconcile: () => Effect.fail(UnsupportedLocalCustomDomain.make({})),
|
|
250
|
+
delete: () => Effect.void
|
|
251
|
+
});
|
|
252
|
+
const localLayer = Provider.effect(CustomDomain, localProvider);
|
|
253
|
+
export { ConflictingCanonicalDomains, CustomDomain, CustomDomainIdentityChange, CustomDomainNotVisible, UnsupportedLocalCustomDomain, layer, localLayer, localProvider, provider };
|
|
254
|
+
|
|
255
|
+
//# sourceMappingURL=CustomDomain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomDomain.js","names":[],"sources":["../src/CustomDomain.ts"],"sourcesContent":["import type { RequestDestination } from \"@convex-dev/platform/managementApi\";\nimport { OwnedBySomeoneElse, Unowned } from \"alchemy/AdoptPolicy\";\nimport { isResolved } from \"alchemy/Diff\";\nimport type { Input } from \"alchemy/Input\";\nimport * as Output from \"alchemy/Output\";\nimport { State } from \"alchemy/State/State\";\nimport * as Provider from \"alchemy/Provider\";\nimport { Stack } from \"alchemy/Stack\";\nimport { Resource } from \"alchemy/Resource\";\nimport * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport * as Option from \"effect/Option\";\nimport * as Record from \"effect/Record\";\nimport * as Schema from \"effect/Schema\";\nimport * as Semaphore from \"effect/Semaphore\";\n\nimport { ConvexClient, type CanonicalUrls } from \"./ConvexClient.js\";\nimport type { Providers } from \"./Providers.js\";\nimport {\n checkpointCreate,\n checkpointUpdate,\n shouldAdopt,\n} from \"./internal/Lifecycle.js\";\n\nexport interface CustomDomainProps {\n readonly deployment: { readonly name: string; readonly url: string };\n readonly domain: string;\n readonly requestDestination: RequestDestination;\n /**\n * Set the canonical URL after verification. Turning it off resets the default\n * only while this domain is still canonical.\n */\n readonly canonical?: boolean;\n}\n\nexport interface CustomDomainAttributes {\n readonly deployment: { readonly name: string; readonly url: string };\n readonly domain: string;\n readonly requestDestination: RequestDestination;\n readonly canonical: boolean;\n readonly verificationTime: number | null;\n /**\n * The HTTPS address of this custom domain, including before verification.\n */\n readonly url: string;\n /**\n * The canonical URL observed when this resource last changed.\n */\n readonly canonicalUrl: string;\n}\n\nexport type CustomDomain = Resource<\n \"Convex.CustomDomain\",\n CustomDomainProps,\n CustomDomainAttributes,\n never,\n Providers\n>;\nexport const CustomDomain = Resource<CustomDomain>(\"Convex.CustomDomain\");\n\nexport class CustomDomainNotVisible extends Schema.TaggedError<\n CustomDomainNotVisible,\n { readonly brand: unique symbol }\n>()(\"CustomDomainNotVisible\", {\n deploymentName: Schema.String,\n domain: Schema.String,\n}) {}\n\nconst identitySchema = Schema.Struct({\n deploymentName: Schema.String,\n domain: Schema.String,\n requestDestination: Schema.Literals([\"convexCloud\", \"convexSite\"]),\n});\n\nconst identity = (props: CustomDomainProps) => ({\n deploymentName: props.deployment.name,\n domain: props.domain,\n requestDestination: props.requestDestination,\n});\n\nexport class CustomDomainIdentityChange extends Schema.TaggedError<\n CustomDomainIdentityChange,\n { readonly brand: unique symbol }\n>()(\"CustomDomainIdentityChange\", {\n oldIdentity: identitySchema,\n newIdentity: identitySchema,\n}) {\n override get message() {\n const old = this.oldIdentity;\n const next = this.newIdentity;\n return `Cannot change custom domain identity from ${old.deploymentName}/${old.domain}/${old.requestDestination} to ${next.deploymentName}/${next.domain}/${next.requestDestination}. Declare a second Convex.CustomDomain with canonical: false, deploy and configure DNS, then move canonical: true after verification and remove the old resource. For the same hostname, remove it from the old deployment before declaring it on the new one.`;\n }\n}\n\nexport class ConflictingCanonicalDomains extends Schema.TaggedError<\n ConflictingCanonicalDomains,\n { readonly brand: unique symbol }\n>()(\"ConflictingCanonicalDomains\", {\n deploymentName: Schema.String,\n requestDestination: Schema.String,\n domains: Schema.Array(Schema.String),\n}) {\n override get message() {\n return `Declare only one canonical custom domain for ${this.deploymentName}/${this.requestDestination}.`;\n }\n}\n\nconst validateCanonicalOwner = Effect.fn(\"CustomDomain.validateCanonicalOwner\")(\n function* (fqn: string, props: Partial<CustomDomainProps>) {\n const stack = yield* Effect.serviceOption(Stack);\n if (Option.isNone(stack)) return;\n const declared = stack.value.resources[fqn];\n if (\n declared === undefined ||\n (isResolved(declared.Props.canonical) &&\n declared.Props.canonical !== true)\n )\n return;\n if (\n props.canonical !== true ||\n props.deployment === undefined ||\n props.requestDestination === undefined ||\n props.domain === undefined\n )\n return;\n for (const resource of Record.values(stack.value.resources)) {\n if (resource.Type !== CustomDomain.Type || resource.FQN === fqn) continue;\n let other: Input<CustomDomainProps> = resource.Props;\n if (!isResolved(other)) {\n const state = yield* Effect.serviceOption(State);\n if (Option.isNone(state)) continue;\n const store = yield* state.value;\n const entries = yield* Effect.forEach(\n Record.keys(Output.upstreamAny(other)),\n Effect.fnUntraced(function* (source) {\n const row = yield* store.get({\n stack: stack.value.name,\n stage: stack.value.stage,\n fqn: source,\n });\n return row === undefined ||\n row.kind === \"action\" ||\n row.attr === undefined\n ? undefined\n : ([source, row.attr] as const);\n }),\n );\n const upstream = Record.fromEntries(\n Array.filter(entries, (entry) => entry !== undefined),\n );\n other = yield* Output.evaluateAvailable(other, upstream).pipe(\n Effect.provideService(State, state.value),\n );\n }\n if (\n isResolved(other) &&\n other.canonical === true &&\n other.deployment.name === props.deployment.name &&\n other.requestDestination === props.requestDestination\n )\n return yield* ConflictingCanonicalDomains.make({\n deploymentName: props.deployment.name,\n requestDestination: props.requestDestination,\n domains: [props.domain, other.domain],\n });\n }\n },\n);\n\nconst sameIdentity = (\n current: CustomDomainAttributes,\n props: CustomDomainProps,\n) =>\n current.deployment.name === props.deployment.name &&\n current.domain === props.domain &&\n current.requestDestination === props.requestDestination;\n\nconst validateIdentity = Effect.fn(\"CustomDomain.validateIdentity\")(function* (\n current: CustomDomainAttributes,\n props: CustomDomainProps,\n) {\n if (!sameIdentity(current, props))\n return yield* CustomDomainIdentityChange.make({\n oldIdentity: identity(current),\n newIdentity: identity(props),\n });\n});\n\nconst canonicalUrl = (urls: CanonicalUrls, destination: RequestDestination) =>\n destination === \"convexCloud\" ? urls.convexCloudUrl : urls.convexSiteUrl;\n\nexport const provider = Effect.gen(function* () {\n const client = yield* ConvexClient;\n const canonicalLocks = new Map<string, Semaphore.Semaphore>();\n const withCanonicalLock = <A, E, R>(\n deployment: CustomDomainProps[\"deployment\"],\n destination: RequestDestination,\n effect: Effect.Effect<A, E, R>,\n ) =>\n Effect.suspend(() => {\n const key = `${deployment.name}/${destination}`;\n let lock = canonicalLocks.get(key);\n if (lock === undefined) {\n lock = Semaphore.makeUnsafe(1);\n canonicalLocks.set(key, lock);\n }\n return lock.withPermit(effect);\n });\n const find = Effect.fn(\"CustomDomain.find\")(function* (\n props: CustomDomainProps,\n ) {\n const domains = yield* client\n .listCustomDomains(props.deployment.name)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.succeed([])));\n return Option.getOrUndefined(\n Array.findFirst(\n domains,\n (domain) =>\n domain.domain === props.domain &&\n domain.requestDestination === props.requestDestination,\n ),\n );\n });\n const resetCanonical = (output: CustomDomainAttributes) =>\n withCanonicalLock(\n output.deployment,\n output.requestDestination,\n Effect.gen(function* () {\n const urls = yield* client\n .getCanonicalUrls(output.deployment.url)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.undefined));\n if (\n urls !== undefined &&\n canonicalUrl(urls, output.requestDestination) === output.url\n )\n yield* client\n .updateCanonicalUrl(output.deployment.url, {\n requestDestination: output.requestDestination,\n })\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void));\n }),\n );\n return {\n diff: Effect.fn(\"CustomDomain.diff\")(function* ({ fqn, news, output }) {\n if (!isResolved(news)) return;\n if (output !== undefined) yield* validateIdentity(output, news);\n yield* validateCanonicalOwner(fqn, news);\n if (output === undefined) return;\n const current = yield* find(news);\n if (\n output.deployment.url !== news.deployment.url ||\n current === undefined ||\n (current.verificationTime ?? null) !== output.verificationTime ||\n output.canonical !== (news.canonical ?? false)\n )\n return { action: \"update\" };\n const urls = yield* client.getCanonicalUrls(news.deployment.url);\n if (\n canonicalUrl(urls, news.requestDestination) !== output.canonicalUrl ||\n (news.canonical === true &&\n current.verificationTime != null &&\n canonicalUrl(urls, news.requestDestination) !==\n `https://${news.domain}`)\n )\n return { action: \"update\" };\n }),\n read: Effect.fn(\"CustomDomain.read\")(function* ({ fqn, olds, output }) {\n if (output === undefined) {\n yield* validateCanonicalOwner(fqn, olds);\n if (\n olds.deployment === undefined ||\n olds.domain === undefined ||\n olds.requestDestination === undefined\n )\n return;\n const current = yield* find({\n deployment: olds.deployment,\n domain: olds.domain,\n requestDestination: olds.requestDestination,\n });\n if (current === undefined) return;\n const urls = yield* client.getCanonicalUrls(olds.deployment.url);\n const attributes = {\n deployment: olds.deployment,\n domain: current.domain,\n requestDestination: current.requestDestination,\n canonical: olds.canonical ?? false,\n verificationTime: current.verificationTime ?? null,\n url: `https://${current.domain}`,\n canonicalUrl: canonicalUrl(urls, current.requestDestination),\n };\n return Unowned(attributes);\n }\n const current = yield* find(output);\n if (current === undefined && !output.canonical) return;\n const urls = yield* client\n .getCanonicalUrls(output.deployment.url)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void));\n if (urls === undefined) return;\n return {\n ...output,\n verificationTime: current?.verificationTime ?? null,\n canonicalUrl: canonicalUrl(urls, output.requestDestination),\n };\n }),\n reconcile: Effect.fn(\"CustomDomain.reconcile\")(function* ({\n fqn,\n instanceId,\n news,\n output,\n }) {\n if (output !== undefined) yield* validateIdentity(output, news);\n yield* validateCanonicalOwner(fqn, news);\n if (output === undefined) yield* checkpointCreate(fqn, instanceId, news);\n let current = yield* find(news);\n if (\n current !== undefined &&\n output === undefined &&\n !(yield* shouldAdopt(fqn))\n )\n return yield* new OwnedBySomeoneElse({\n message: `Custom domain ${news.domain} requires explicit adoption. Re-run with --adopt or adopt(true) to take it over.`,\n resourceType: CustomDomain.Type,\n physicalName: news.domain,\n });\n const url = `https://${news.domain}`;\n const canonical = news.canonical ?? false;\n const attributes = {\n deployment: news.deployment,\n domain: news.domain,\n requestDestination: news.requestDestination,\n canonical: canonical || (output?.canonical ?? false),\n verificationTime: current?.verificationTime ?? null,\n url,\n canonicalUrl: output?.canonicalUrl ?? url,\n };\n if (current === undefined) {\n yield* client.createCustomDomain(news.deployment.name, {\n domain: news.domain,\n requestDestination: news.requestDestination,\n });\n yield* checkpointCreate(fqn, instanceId, news, attributes);\n current = yield* find(news);\n }\n if (current === undefined)\n return yield* CustomDomainNotVisible.make({\n deploymentName: news.deployment.name,\n domain: news.domain,\n });\n yield* checkpointCreate(fqn, instanceId, news, attributes);\n if (output !== undefined && canonical && !output.canonical)\n yield* checkpointUpdate(fqn, instanceId, {\n ...output,\n canonical: true,\n });\n const urls = yield* withCanonicalLock(\n news.deployment,\n news.requestDestination,\n Effect.gen(function* () {\n let currentUrls = yield* client.getCanonicalUrls(news.deployment.url);\n if (canonical && current.verificationTime == null) {\n yield* Effect.logInfo(\n `Canonical URL for ${news.domain} is pending verification.`,\n );\n } else if (\n canonical &&\n canonicalUrl(currentUrls, news.requestDestination) !== url\n ) {\n yield* client.updateCanonicalUrl(news.deployment.url, {\n requestDestination: news.requestDestination,\n url,\n });\n currentUrls = yield* client.getCanonicalUrls(news.deployment.url);\n } else if (\n !canonical &&\n output?.canonical === true &&\n canonicalUrl(currentUrls, news.requestDestination) === url\n ) {\n yield* client.updateCanonicalUrl(news.deployment.url, {\n requestDestination: news.requestDestination,\n });\n currentUrls = yield* client.getCanonicalUrls(news.deployment.url);\n }\n return currentUrls;\n }),\n );\n const result = {\n ...attributes,\n canonical,\n verificationTime: current.verificationTime ?? null,\n canonicalUrl: canonicalUrl(urls, news.requestDestination),\n };\n yield* checkpointCreate(fqn, instanceId, news, result);\n return result;\n }),\n delete: Effect.fn(\"CustomDomain.delete\")(function* ({ fqn, output }) {\n const stack = yield* Effect.serviceOption(Stack);\n const state = yield* Effect.serviceOption(State);\n if (Option.isSome(stack) && Option.isSome(state)) {\n const store = yield* state.value;\n for (const resource of Record.values(stack.value.resources)) {\n if (resource.Type !== CustomDomain.Type || resource.FQN === fqn)\n continue;\n const row = yield* store.get({\n stack: stack.value.name,\n stage: stack.value.stage,\n fqn: resource.FQN,\n });\n if (\n row !== undefined &&\n row.kind !== \"action\" &&\n row.resourceType === CustomDomain.Type &&\n row.attr?.deployment?.name === output.deployment.name &&\n row.attr?.domain === output.domain &&\n row.attr?.requestDestination === output.requestDestination\n ) {\n if (output.canonical && row.attr.canonical !== true)\n yield* resetCanonical(output);\n yield* Effect.logInfo(\n `Skipping delete of ${output.domain}; ${resource.FQN} keeps it.`,\n );\n return;\n }\n }\n }\n yield* resetCanonical(output);\n yield* client\n .deleteCustomDomain(output.deployment.name, {\n domain: output.domain,\n requestDestination: output.requestDestination,\n })\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void));\n }),\n } satisfies Provider.ProviderServiceInput<CustomDomain>;\n});\n\nexport const layer = Provider.effect(CustomDomain, provider);\n\nexport class UnsupportedLocalCustomDomain extends Schema.TaggedError<\n UnsupportedLocalCustomDomain,\n { readonly brand: unique symbol }\n>()(\"UnsupportedLocalCustomDomain\", {}) {\n override get message() {\n return \"Declare Convex.CustomDomain only for cloud stages.\";\n }\n}\n\nexport const localProvider = Effect.succeed({\n reconcile: () => Effect.fail(UnsupportedLocalCustomDomain.make({})),\n delete: () => Effect.void,\n} satisfies Provider.ProviderServiceInput<CustomDomain>);\n\nexport const localLayer = Provider.effect(CustomDomain, localProvider);\n"],"mappings":";;;;;;;;;;;;;;;;AA0DA,MAAa,eAAe,SAAuB,qBAAqB;AAExE,IAAa,yBAAb,cAA4C,OAAO,YAGjD,CAAC,CAAC,0BAA0B;CAC5B,gBAAgB,OAAO;CACvB,QAAQ,OAAO;AACjB,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAM,iBAAiB,OAAO,OAAO;CACnC,gBAAgB,OAAO;CACvB,QAAQ,OAAO;CACf,oBAAoB,OAAO,SAAS,CAAC,eAAe,YAAY,CAAC;AACnE,CAAC;AAED,MAAM,YAAY,WAA8B;CAC9C,gBAAgB,MAAM,WAAW;CACjC,QAAQ,MAAM;CACd,oBAAoB,MAAM;AAC5B;AAEA,IAAa,6BAAb,cAAgD,OAAO,YAGrD,CAAC,C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ACA,IAAa,OAAO,8OASnB;CACF;AA2ID,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;aAxPL,MAAM;oBAEC,aAAa,CAAC,MAAM,CAAC;mBAEtB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCAgnBvE,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;aA3nBV,MAAM;oBAEC,aAAa,CAAC,MAAM,CAAC;mBAEtB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCAsoBxE,CAAC;AAEF,eAAO,MAAM,KAAK,wFAAkD,CAAC;AACrE,eAAO,MAAM,UAAU,oEAStB,CAAC"}
|
|
@@ -146,6 +146,7 @@ const provider = Effect.gen(function* () {
|
|
|
146
146
|
const previous = valueAt(output.variables, name);
|
|
147
147
|
const current = valueAt(observed, name);
|
|
148
148
|
const wanted = desiredVariables?.[name];
|
|
149
|
+
if (current === void 0 && desiredVariables !== void 0 && !Rec.has(desiredVariables, name)) continue;
|
|
149
150
|
if (current !== void 0 && (desiredVariables === void 0 || wanted !== void 0 && !isResolved(wanted))) continue;
|
|
150
151
|
if (current !== void 0 && (typeof wanted === "string" || Redacted.isRedacted(wanted)) && Redacted.value(current) === (typeof wanted === "string" ? wanted : Redacted.value(wanted))) continue;
|
|
151
152
|
if (previous === void 0 && current === void 0) continue;
|
|
@@ -1 +1 @@
|
|
|
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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ACxE,OAAO,UAAU,WAAW,MAAM,MAAM,QAAQ,KAAK,KAAK,CAAC;EAC3D,YAAY,UAAU,WAAW,MAAM,MAAM,QAAQ,UAAU,KAAK,CAAC;EACrE,SAAS,UAAU,WAAW,MAAM,MAAM,QAAQ,OAAO,KAAK,CAAC;CACjE;AACF,CAAC;;;;;;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 !Rec.has(desiredVariables, name)\n )\n continue;\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,O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,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"}
|
package/dist/Providers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Providers.d.ts","sources":["../src/Providers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;;
|
|
1
|
+
{"version":3,"file":"Providers.d.ts","sources":["../src/Providers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;;AActC,qBAAa,SAAU,SAAQ,cAE9B;CAAG;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,aAAc;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;CAC5C,qXAuDE,CAAC"}
|
package/dist/Providers.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Code, layer, localLayer } from "./Code.js";
|
|
2
|
-
import { layer as layer$1 } from "./
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { layer as layer$8 } from "./
|
|
10
|
-
import { layer as layer$9 } from "./internal/
|
|
2
|
+
import { CustomDomain, layer as layer$1, localLayer as localLayer$1 } from "./CustomDomain.js";
|
|
3
|
+
import { layer as layer$2 } from "./ConvexClient.js";
|
|
4
|
+
import { Deployment, layer as layer$3, localLayer as localLayer$2 } from "./Deployment.js";
|
|
5
|
+
import { DeployKey, layer as layer$4, localLayer as localLayer$3 } from "./DeployKey.js";
|
|
6
|
+
import { EnvironmentVariables, layer as layer$5, localLayer as localLayer$4 } from "./EnvironmentVariables.js";
|
|
7
|
+
import { Project, layer as layer$6, localLayer as localLayer$5 } from "./Project.js";
|
|
8
|
+
import { LogStream, layer as layer$7, localLayer as localLayer$6 } from "./LogStream.js";
|
|
9
|
+
import { UsageLimit, layer as layer$8, localLayer as localLayer$7 } from "./UsageLimit.js";
|
|
10
|
+
import { layer as layer$9 } from "./internal/CommandRunner.js";
|
|
11
|
+
import { layer as layer$10 } from "./internal/PushLock.js";
|
|
11
12
|
import * as Provider from "alchemy/Provider";
|
|
12
13
|
import * as Layer from "effect/Layer";
|
|
13
14
|
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
@@ -28,30 +29,34 @@ const providers = (options) => Layer.effect(Providers, Provider.collection([
|
|
|
28
29
|
DeployKey,
|
|
29
30
|
EnvironmentVariables,
|
|
30
31
|
Code,
|
|
32
|
+
CustomDomain,
|
|
31
33
|
LogStream,
|
|
32
34
|
UsageLimit
|
|
33
35
|
])).pipe(Layer.provide(Layer.mergeAll(ProviderLayer.dual(Project, {
|
|
34
|
-
live: () => layer$
|
|
35
|
-
local: () => localLayer$
|
|
36
|
+
live: () => layer$6,
|
|
37
|
+
local: () => localLayer$5
|
|
36
38
|
}), ProviderLayer.dual(Deployment, {
|
|
37
|
-
live: () => layer$2,
|
|
38
|
-
local: () => localLayer$1
|
|
39
|
-
}), ProviderLayer.dual(DeployKey, {
|
|
40
39
|
live: () => layer$3,
|
|
41
40
|
local: () => localLayer$2
|
|
42
|
-
}), ProviderLayer.dual(
|
|
41
|
+
}), ProviderLayer.dual(DeployKey, {
|
|
43
42
|
live: () => layer$4,
|
|
44
43
|
local: () => localLayer$3
|
|
44
|
+
}), ProviderLayer.dual(EnvironmentVariables, {
|
|
45
|
+
live: () => layer$5,
|
|
46
|
+
local: () => localLayer$4
|
|
47
|
+
}), ProviderLayer.dual(CustomDomain, {
|
|
48
|
+
live: () => layer$1,
|
|
49
|
+
local: () => localLayer$1
|
|
45
50
|
}), ProviderLayer.dual(UsageLimit, {
|
|
46
|
-
live: () => layer$
|
|
47
|
-
local: () => localLayer$
|
|
51
|
+
live: () => layer$8,
|
|
52
|
+
local: () => localLayer$7
|
|
48
53
|
}), ProviderLayer.dual(Code, {
|
|
49
54
|
live: () => layer,
|
|
50
55
|
local: () => localLayer
|
|
51
56
|
}), ProviderLayer.dual(LogStream, {
|
|
52
|
-
live: () => layer$
|
|
53
|
-
local: () => localLayer$
|
|
54
|
-
}))), Layer.provide(layer$
|
|
57
|
+
live: () => layer$7,
|
|
58
|
+
local: () => localLayer$6
|
|
59
|
+
}))), Layer.provide(layer$2(options).pipe(Layer.provide(FetchHttpClient.layer))), Layer.provide(layer$9), Layer.provide(layer$10()));
|
|
55
60
|
export { Providers, providers };
|
|
56
61
|
|
|
57
62
|
//# sourceMappingURL=Providers.js.map
|
package/dist/Providers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Providers.js","names":["Project.Project","Deployment.Deployment","DeployKey.DeployKey","EnvironmentVariables.EnvironmentVariables","Code.Code","LogStream.LogStream","UsageLimit.UsageLimit","Project.layer","Project.localLayer","Deployment.layer","Deployment.localLayer","DeployKey.layer","DeployKey.localLayer","EnvironmentVariables.layer","EnvironmentVariables.localLayer","UsageLimit.layer","UsageLimit.localLayer","Code.layer","Code.localLayer","LogStream.layer","LogStream.localLayer","ConvexClient.layer","CommandRunner.layer","PushLock.layer"],"sources":["../src/Providers.ts"],"sourcesContent":["import * as ProviderLayer from \"alchemy/Local/ProviderLayer\";\nimport * as Provider from \"alchemy/Provider\";\nimport type * as Redacted from \"effect/Redacted\";\nimport * as Layer from \"effect/Layer\";\nimport * as FetchHttpClient from \"effect/http/FetchHttpClient\";\nimport * as Code from \"./Code.js\";\nimport * as ConvexClient from \"./ConvexClient.js\";\nimport * as Deployment from \"./Deployment.js\";\nimport * as DeployKey from \"./DeployKey.js\";\nimport * as EnvironmentVariables from \"./EnvironmentVariables.js\";\nimport * as Project from \"./Project.js\";\nimport * as LogStream from \"./LogStream.js\";\nimport * as UsageLimit from \"./UsageLimit.js\";\nimport * as CommandRunner from \"./internal/CommandRunner.js\";\nimport * as PushLock from \"./internal/PushLock.js\";\n\nexport class Providers extends Provider.ProviderCollection<Providers>()(\n \"@confect/alchemy/Providers\",\n) {}\n\n/**\n * Register Convex resources without eagerly resolving management credentials.\n * `alchemy deploy` resolves each resource to its cloud provider; `alchemy dev`\n * resolves the same resources to local providers backed by a local Convex\n * backend, so one stack definition serves both.\n *\n * @stability unstable\n */\nexport const providers = (options?: {\n readonly token?: Redacted.Redacted<string>;\n}) =>\n Layer.effect(\n Providers,\n Provider.collection([\n Project.Project,\n Deployment.Deployment,\n DeployKey.DeployKey,\n EnvironmentVariables.EnvironmentVariables,\n Code.Code,\n LogStream.LogStream,\n UsageLimit.UsageLimit,\n ]),\n ).pipe(\n Layer.provide(\n Layer.mergeAll(\n ProviderLayer.dual(Project.Project, {\n live: () => Project.layer,\n local: () => Project.localLayer,\n }),\n ProviderLayer.dual(Deployment.Deployment, {\n live: () => Deployment.layer,\n local: () => Deployment.localLayer,\n }),\n ProviderLayer.dual(DeployKey.DeployKey, {\n live: () => DeployKey.layer,\n local: () => DeployKey.localLayer,\n }),\n ProviderLayer.dual(EnvironmentVariables.EnvironmentVariables, {\n live: () => EnvironmentVariables.layer,\n local: () => EnvironmentVariables.localLayer,\n }),\n ProviderLayer.dual(UsageLimit.UsageLimit, {\n live: () => UsageLimit.layer,\n local: () => UsageLimit.localLayer,\n }),\n ProviderLayer.dual(Code.Code, {\n live: () => Code.layer,\n local: () => Code.localLayer,\n }),\n ProviderLayer.dual(LogStream.LogStream, {\n live: () => LogStream.layer,\n local: () => LogStream.localLayer,\n }),\n ),\n ),\n Layer.provide(\n ConvexClient.layer(options).pipe(Layer.provide(FetchHttpClient.layer)),\n ),\n Layer.provide(CommandRunner.layer),\n Layer.provide(PushLock.layer()),\n );\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Providers.js","names":["Project.Project","Deployment.Deployment","DeployKey.DeployKey","EnvironmentVariables.EnvironmentVariables","Code.Code","CustomDomain.CustomDomain","LogStream.LogStream","UsageLimit.UsageLimit","Project.layer","Project.localLayer","Deployment.layer","Deployment.localLayer","DeployKey.layer","DeployKey.localLayer","EnvironmentVariables.layer","EnvironmentVariables.localLayer","CustomDomain.layer","CustomDomain.localLayer","UsageLimit.layer","UsageLimit.localLayer","Code.layer","Code.localLayer","LogStream.layer","LogStream.localLayer","ConvexClient.layer","CommandRunner.layer","PushLock.layer"],"sources":["../src/Providers.ts"],"sourcesContent":["import * as ProviderLayer from \"alchemy/Local/ProviderLayer\";\nimport * as Provider from \"alchemy/Provider\";\nimport type * as Redacted from \"effect/Redacted\";\nimport * as Layer from \"effect/Layer\";\nimport * as FetchHttpClient from \"effect/http/FetchHttpClient\";\nimport * as Code from \"./Code.js\";\nimport * as CustomDomain from \"./CustomDomain.js\";\nimport * as ConvexClient from \"./ConvexClient.js\";\nimport * as Deployment from \"./Deployment.js\";\nimport * as DeployKey from \"./DeployKey.js\";\nimport * as EnvironmentVariables from \"./EnvironmentVariables.js\";\nimport * as Project from \"./Project.js\";\nimport * as LogStream from \"./LogStream.js\";\nimport * as UsageLimit from \"./UsageLimit.js\";\nimport * as CommandRunner from \"./internal/CommandRunner.js\";\nimport * as PushLock from \"./internal/PushLock.js\";\n\nexport class Providers extends Provider.ProviderCollection<Providers>()(\n \"@confect/alchemy/Providers\",\n) {}\n\n/**\n * Register Convex resources without eagerly resolving management credentials.\n * `alchemy deploy` resolves each resource to its cloud provider; `alchemy dev`\n * resolves the same resources to local providers backed by a local Convex\n * backend, so one stack definition serves both.\n *\n * @stability unstable\n */\nexport const providers = (options?: {\n readonly token?: Redacted.Redacted<string>;\n}) =>\n Layer.effect(\n Providers,\n Provider.collection([\n Project.Project,\n Deployment.Deployment,\n DeployKey.DeployKey,\n EnvironmentVariables.EnvironmentVariables,\n Code.Code,\n CustomDomain.CustomDomain,\n LogStream.LogStream,\n UsageLimit.UsageLimit,\n ]),\n ).pipe(\n Layer.provide(\n Layer.mergeAll(\n ProviderLayer.dual(Project.Project, {\n live: () => Project.layer,\n local: () => Project.localLayer,\n }),\n ProviderLayer.dual(Deployment.Deployment, {\n live: () => Deployment.layer,\n local: () => Deployment.localLayer,\n }),\n ProviderLayer.dual(DeployKey.DeployKey, {\n live: () => DeployKey.layer,\n local: () => DeployKey.localLayer,\n }),\n ProviderLayer.dual(EnvironmentVariables.EnvironmentVariables, {\n live: () => EnvironmentVariables.layer,\n local: () => EnvironmentVariables.localLayer,\n }),\n ProviderLayer.dual(CustomDomain.CustomDomain, {\n live: () => CustomDomain.layer,\n local: () => CustomDomain.localLayer,\n }),\n ProviderLayer.dual(UsageLimit.UsageLimit, {\n live: () => UsageLimit.layer,\n local: () => UsageLimit.localLayer,\n }),\n ProviderLayer.dual(Code.Code, {\n live: () => Code.layer,\n local: () => Code.localLayer,\n }),\n ProviderLayer.dual(LogStream.LogStream, {\n live: () => LogStream.layer,\n local: () => LogStream.localLayer,\n }),\n ),\n ),\n Layer.provide(\n ConvexClient.layer(options).pipe(Layer.provide(FetchHttpClient.layer)),\n ),\n Layer.provide(CommandRunner.layer),\n Layer.provide(PushLock.layer()),\n );\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,IAAa,YAAb,cAA+B,SAAS,mBAA8B,CAAC,CACrE,4BACF,CAAC,CAAC,CAAC;;;;;;;;;AAUH,MAAa,aAAa,YAGxB,MAAM,OACJ,WACA,SAAS,WAAW;CAClBA;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;CACAC;AACF,CAAC,CACH,CAAC,CAAC,KACA,MAAM,QACJ,MAAM,SACJ,cAAc,KAAKP,SAAiB;CAClC,YAAYQ;CACZ,aAAaC;AACf,CAAC,GACD,cAAc,KAAKR,YAAuB;CACxC,YAAYS;CACZ,aAAaC;AACf,CAAC,GACD,cAAc,KAAKT,WAAqB;CACtC,YAAYU;CACZ,aAAaC;AACf,CAAC,GACD,cAAc,KAAKV,sBAA2C;CAC5D,YAAYW;CACZ,aAAaC;AACf,CAAC,GACD,cAAc,KAAKV,cAA2B;CAC5C,YAAYW;CACZ,aAAaC;AACf,CAAC,GACD,cAAc,KAAKV,YAAuB;CACxC,YAAYW;CACZ,aAAaC;AACf,CAAC,GACD,cAAc,KAAKf,MAAW;CAC5B,YAAYgB;CACZ,aAAaC;AACf,CAAC,GACD,cAAc,KAAKf,WAAqB;CACtC,YAAYgB;CACZ,aAAaC;AACf,CAAC,CACH,CACF,GACA,MAAM,QACJC,QAAmB,OAAO,CAAC,CAAC,KAAK,MAAM,QAAQ,gBAAgB,KAAK,CAAC,CACvE,GACA,MAAM,QAAQC,OAAmB,GACjC,MAAM,QAAQC,SAAe,CAAC,CAChC"}
|