@gaganref/confect-alchemy 10.6.0-fork.25 → 10.6.0-fork.27
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/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/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,CAAC,8BAA8B;CAChC,aAAa;CACb,aAAa;AACf,CAAC,CAAC,CAAC;CACD,IAAa,UAAU;EACrB,MAAM,MAAM,KAAK;EACjB,MAAM,OAAO,K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O,MAAM,MAAM;MACnB,KAAK,SAAS;KAChB,CAAC;KACD,IACE,QAAQ,KAAA,KACR,IAAI,SAAS,YACb,IAAI,iBAAiB,aAAa,QAClC,IAAI,MAAM,YAAY,SAAS,OAAO,WAAW,QACjD,IAAI,MAAM,WAAW,OAAO,UAC5B,IAAI,MAAM,uBAAuB,OAAO,oBACxC;MACA,IAAI,OAAO,aAAa,IAAI,KAAK,cAAc,MAC7C,OAAO,eAAe,MAAM;MAC9B,OAAO,OAAO,QACZ,sBAAsB,OAAO,OAAO,IAAI,SAAS,IAAI,WACvD;MACA;KACF;IACF;GACF;GACA,OAAO,eAAe,MAAM;GAC5B,OAAO,OACJ,mBAAmB,OAAO,WAAW,MAAM;IAC1C,QAAQ,OAAO;IACf,oBAAoB,OAAO;GAC7B,CAAC,CAAC,CACD,KAAK,OAAO,SAAS,wBAAwB,OAAO,IAAI,CAAC;EAC9D,CAAC;CACH;AACF,CAAC;AAED,MAAa,QAAQ,SAAS,OAAO,cAAc,QAAQ;AAE3D,IAAa,+BAAb,cAAkD,OAAO,YAGvD,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC;CACtC,IAAa,UAAU;EACrB,OAAO;CACT;AACF;AAEA,MAAa,gBAAgB,OAAO,QAAQ;CAC1C,iBAAiB,OAAO,KAAK,6BAA6B,KAAK,CAAC,CAAC,CAAC;CAClE,cAAc,OAAO;AACvB,CAAuD;AAEvD,MAAa,aAAa,SAAS,OAAO,cAAc,aAAa"}
|
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"}
|
|
@@ -8,6 +8,7 @@ declare const LifecycleStateError_base: Schema.Class<LifecycleStateError, Schema
|
|
|
8
8
|
export declare class LifecycleStateError extends LifecycleStateError_base {
|
|
9
9
|
}
|
|
10
10
|
export declare const checkpointCreate: (fqn: string, instanceId: string, props: object, output?: object | undefined) => Effect.Effect<undefined, LifecycleStateError | import("alchemy/State/State").StateStoreError, never>;
|
|
11
|
+
export declare const checkpointUpdate: (fqn: string, instanceId: string, output: object) => Effect.Effect<undefined, LifecycleStateError | import("alchemy/State/State").StateStoreError, never>;
|
|
11
12
|
export declare const shouldAdopt: (fqn: string) => Effect.Effect<boolean, never, never>;
|
|
12
13
|
export {};
|
|
13
14
|
//# sourceMappingURL=Lifecycle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Lifecycle.d.ts","sources":["../../src/internal/Lifecycle.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;;;;oBAIpB,OAAO,MAAM;;AAFjC,qBAAa,mBAAoB,SAAQ,wBAGS;CAAG;AAErD,eAAO,MAAM,gBAAgB,uLAyB5B,CAAC;AAEF,eAAO,MAAM,WAAW,uDAYtB,CAAC"}
|
|
1
|
+
{"version":3,"file":"Lifecycle.d.ts","sources":["../../src/internal/Lifecycle.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;;;;oBAIpB,OAAO,MAAM;;AAFjC,qBAAa,mBAAoB,SAAQ,wBAGS;CAAG;AAErD,eAAO,MAAM,gBAAgB,uLAyB5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,2JAkB5B,CAAC;AAEF,eAAO,MAAM,WAAW,uDAYtB,CAAC"}
|
|
@@ -30,6 +30,28 @@ const checkpointCreate = Effect.fn("Lifecycle.checkpointCreate")(function* (fqn,
|
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
32
|
});
|
|
33
|
+
const checkpointUpdate = Effect.fn("Lifecycle.checkpointUpdate")(function* (fqn, instanceId, output) {
|
|
34
|
+
const stack = yield* Effect.serviceOption(Stack);
|
|
35
|
+
if (Option.isNone(stack)) return;
|
|
36
|
+
const state = yield* Effect.serviceOption(State);
|
|
37
|
+
if (Option.isNone(state)) return yield* LifecycleStateError.make({ fqn });
|
|
38
|
+
const store = yield* state.value;
|
|
39
|
+
const key = {
|
|
40
|
+
stack: stack.value.name,
|
|
41
|
+
stage: stack.value.stage,
|
|
42
|
+
fqn
|
|
43
|
+
};
|
|
44
|
+
const row = yield* store.get(key);
|
|
45
|
+
if (row === void 0 || row.kind === "action" || row.instanceId !== instanceId) return yield* LifecycleStateError.make({ fqn });
|
|
46
|
+
if (row.status !== "updating") return;
|
|
47
|
+
yield* store.set({
|
|
48
|
+
...key,
|
|
49
|
+
value: {
|
|
50
|
+
...row,
|
|
51
|
+
attr: output
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
33
55
|
const shouldAdopt = Effect.fn("Lifecycle.shouldAdopt")(function* (fqn) {
|
|
34
56
|
const stack = yield* Effect.serviceOption(Stack);
|
|
35
57
|
const resourcePolicy = Option.isSome(stack) ? stack.value.resources[fqn]?.Adopt : void 0;
|
|
@@ -39,6 +61,6 @@ const shouldAdopt = Effect.fn("Lifecycle.shouldAdopt")(function* (fqn) {
|
|
|
39
61
|
const context = yield* Effect.serviceOption(AlchemyContext);
|
|
40
62
|
return Option.isSome(context) && context.value.adopt;
|
|
41
63
|
});
|
|
42
|
-
export { LifecycleStateError, checkpointCreate, shouldAdopt };
|
|
64
|
+
export { LifecycleStateError, checkpointCreate, checkpointUpdate, shouldAdopt };
|
|
43
65
|
|
|
44
66
|
//# sourceMappingURL=Lifecycle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Lifecycle.js","names":[],"sources":["../../src/internal/Lifecycle.ts"],"sourcesContent":["import { AdoptPolicy } from \"alchemy/AdoptPolicy\";\nimport { AlchemyContext } from \"alchemy/AlchemyContext\";\nimport { Stack } from \"alchemy/Stack\";\nimport { State } from \"alchemy/State/State\";\nimport * as Effect from \"effect/Effect\";\nimport * as Option from \"effect/Option\";\nimport * as Schema from \"effect/Schema\";\n\nexport class LifecycleStateError extends Schema.TaggedError<\n LifecycleStateError,\n { readonly brand: unique symbol }\n>()(\"LifecycleStateError\", { fqn: Schema.String }) {}\n\nexport const checkpointCreate = Effect.fn(\"Lifecycle.checkpointCreate\")(\n function* (fqn: string, instanceId: string, props: object, output?: object) {\n const stack = yield* Effect.serviceOption(Stack);\n if (Option.isNone(stack)) return;\n const state = yield* Effect.serviceOption(State);\n if (Option.isNone(state)) return yield* LifecycleStateError.make({ fqn });\n const store = yield* state.value;\n const key = { stack: stack.value.name, stage: stack.value.stage, fqn };\n const row = yield* store.get(key);\n if (\n row === undefined ||\n row.kind === \"action\" ||\n row.instanceId !== instanceId\n )\n return yield* LifecycleStateError.make({ fqn });\n if (row.status !== \"creating\" && row.status !== \"replacing\") return;\n yield* store.set({\n ...key,\n value: {\n ...row,\n props,\n ...(output === undefined ? {} : { attr: output }),\n },\n });\n },\n);\n\nexport const shouldAdopt = Effect.fn(\"Lifecycle.shouldAdopt\")(function* (\n fqn: string,\n) {\n const stack = yield* Effect.serviceOption(Stack);\n const resourcePolicy = Option.isSome(stack)\n ? stack.value.resources[fqn]?.Adopt\n : undefined;\n if (resourcePolicy !== undefined) return resourcePolicy;\n const policy = yield* Effect.serviceOption(AdoptPolicy);\n if (Option.isSome(policy)) return policy.value;\n const context = yield* Effect.serviceOption(AlchemyContext);\n return Option.isSome(context) && context.value.adopt;\n});\n"],"mappings":";;;;;;;;AAQA,IAAa,sBAAb,cA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AO,KAAK,QAAQ,MAAM;AACjD,CAAC"}
|
|
1
|
+
{"version":3,"file":"Lifecycle.js","names":[],"sources":["../../src/internal/Lifecycle.ts"],"sourcesContent":["import { AdoptPolicy } from \"alchemy/AdoptPolicy\";\nimport { AlchemyContext } from \"alchemy/AlchemyContext\";\nimport { Stack } from \"alchemy/Stack\";\nimport { State } from \"alchemy/State/State\";\nimport * as Effect from \"effect/Effect\";\nimport * as Option from \"effect/Option\";\nimport * as Schema from \"effect/Schema\";\n\nexport class LifecycleStateError extends Schema.TaggedError<\n LifecycleStateError,\n { readonly brand: unique symbol }\n>()(\"LifecycleStateError\", { fqn: Schema.String }) {}\n\nexport const checkpointCreate = Effect.fn(\"Lifecycle.checkpointCreate\")(\n function* (fqn: string, instanceId: string, props: object, output?: object) {\n const stack = yield* Effect.serviceOption(Stack);\n if (Option.isNone(stack)) return;\n const state = yield* Effect.serviceOption(State);\n if (Option.isNone(state)) return yield* LifecycleStateError.make({ fqn });\n const store = yield* state.value;\n const key = { stack: stack.value.name, stage: stack.value.stage, fqn };\n const row = yield* store.get(key);\n if (\n row === undefined ||\n row.kind === \"action\" ||\n row.instanceId !== instanceId\n )\n return yield* LifecycleStateError.make({ fqn });\n if (row.status !== \"creating\" && row.status !== \"replacing\") return;\n yield* store.set({\n ...key,\n value: {\n ...row,\n props,\n ...(output === undefined ? {} : { attr: output }),\n },\n });\n },\n);\n\nexport const checkpointUpdate = Effect.fn(\"Lifecycle.checkpointUpdate\")(\n function* (fqn: string, instanceId: string, output: object) {\n const stack = yield* Effect.serviceOption(Stack);\n if (Option.isNone(stack)) return;\n const state = yield* Effect.serviceOption(State);\n if (Option.isNone(state)) return yield* LifecycleStateError.make({ fqn });\n const store = yield* state.value;\n const key = { stack: stack.value.name, stage: stack.value.stage, fqn };\n const row = yield* store.get(key);\n if (\n row === undefined ||\n row.kind === \"action\" ||\n row.instanceId !== instanceId\n )\n return yield* LifecycleStateError.make({ fqn });\n if (row.status !== \"updating\") return;\n yield* store.set({ ...key, value: { ...row, attr: output } });\n },\n);\n\nexport const shouldAdopt = Effect.fn(\"Lifecycle.shouldAdopt\")(function* (\n fqn: string,\n) {\n const stack = yield* Effect.serviceOption(Stack);\n const resourcePolicy = Option.isSome(stack)\n ? stack.value.resources[fqn]?.Adopt\n : undefined;\n if (resourcePolicy !== undefined) return resourcePolicy;\n const policy = yield* Effect.serviceOption(AdoptPolicy);\n if (Option.isSome(policy)) return policy.value;\n const context = yield* Effect.serviceOption(AlchemyContext);\n return Option.isSome(context) && context.value.adopt;\n});\n"],"mappings":";;;;;;;;AAQA,IAAa,sBAAb,cAAyC,OAAO,YAG9C,CAAC,CAAC,uBAAuB,EAAE,KAAK,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AAEpD,MAAa,mBAAmB,OAAO,GAAG,4BAA4B,CAAC,CACrE,WAAW,KAAa,YAAoB,OAAe,QAAiB;CAC1E,MAAM,QAAQ,OAAO,OAAO,cAAc,KAAK;CAC/C,IAAI,OAAO,OAAO,KAAK,GAAG;CAC1B,MAAM,QAAQ,OAAO,OAAO,cAAc,KAAK;CAC/C,IAAI,OAAO,OAAO,KAAK,GAAG,OAAO,OAAO,oBAAoB,KAAK,EAAE,IAAI,CAAC;CACxE,MAAM,QAAQ,OAAO,MAAM;CAC3B,MAAM,MAAM;EAAE,OAAO,MAAM,MAAM;EAAM,OAAO,MAAM,MAAM;EAAO;CAAI;CACrE,MAAM,MAAM,OAAO,MAAM,IAAI,GAAG;CAChC,IACE,QAAQ,KAAA,KACR,IAAI,SAAS,YACb,IAAI,eAAe,YAEnB,OAAO,OAAO,oBAAoB,KAAK,EAAE,IAAI,CAAC;CAChD,IAAI,IAAI,WAAW,cAAc,IAAI,WAAW,aAAa;CAC7D,OAAO,MAAM,IAAI;EACf,GAAG;EACH,OAAO;GACL,GAAG;GACH;GACA,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,OAAO;EACjD;CACF,CAAC;AACH,CACF;AAEA,MAAa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
"version": "10.6.0-fork.27",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@convex-dev/platform": "^0.1.10"
|
|
6
6
|
},
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@confect/cli": "npm:@gaganref/confect-cli@10.6.0-fork.
|
|
9
|
-
"@confect/core": "npm:@gaganref/confect-core@10.6.0-fork.
|
|
8
|
+
"@confect/cli": "npm:@gaganref/confect-cli@10.6.0-fork.27",
|
|
9
|
+
"@confect/core": "npm:@gaganref/confect-core@10.6.0-fork.27",
|
|
10
10
|
"alchemy": ">=2.0.0-beta.85 <2.0.0",
|
|
11
11
|
"convex": "^1.32.0",
|
|
12
12
|
"effect": "~4.1.4"
|
package/src/Convex.ts
CHANGED
package/src/ConvexClient.ts
CHANGED
|
@@ -67,6 +67,23 @@ export type EnvironmentVariables = Readonly<
|
|
|
67
67
|
>
|
|
68
68
|
>;
|
|
69
69
|
|
|
70
|
+
export type CustomDomain = ManagementApi.PlatformCustomDomainResponse;
|
|
71
|
+
export type CustomDomainInput = ManagementApi.PlatformDeleteCustomDomainArgs;
|
|
72
|
+
export type CanonicalUrls = DeploymentApi.GetCanonicalUrlsResponse;
|
|
73
|
+
export type UpdateCanonicalUrlInput = DeploymentApi.UpdateCanonicalUrlRequest;
|
|
74
|
+
|
|
75
|
+
const CustomDomainSchema = Schema.Struct({
|
|
76
|
+
deploymentName: Schema.String,
|
|
77
|
+
domain: Schema.String,
|
|
78
|
+
requestDestination: Schema.Literals(["convexCloud", "convexSite"]),
|
|
79
|
+
creationTime: Schema.Finite,
|
|
80
|
+
verificationTime: Schema.Finite.pipe(Schema.NullOr, Schema.optionalKey),
|
|
81
|
+
}) satisfies Schema.Schema<CustomDomain>;
|
|
82
|
+
|
|
83
|
+
const CanonicalUrlsSchema = Schema.Struct({
|
|
84
|
+
convexCloudUrl: Schema.String,
|
|
85
|
+
convexSiteUrl: Schema.String,
|
|
86
|
+
}) satisfies Schema.Schema<CanonicalUrls>;
|
|
70
87
|
export type CreateLogStreamInput = LogStream.RedactInput<
|
|
71
88
|
LogStream.ReadonlyDeep<DeploymentApi.CreateLogStreamArgs>
|
|
72
89
|
>;
|
|
@@ -526,6 +543,62 @@ const make = Effect.fn("ConvexClient.make")(function* (options?: {
|
|
|
526
543
|
});
|
|
527
544
|
return result.value;
|
|
528
545
|
}),
|
|
546
|
+
listCustomDomains: Effect.fn("ConvexClient.listCustomDomains")(function* (
|
|
547
|
+
name: string,
|
|
548
|
+
) {
|
|
549
|
+
const result = yield* management(
|
|
550
|
+
"listCustomDomains",
|
|
551
|
+
"GET",
|
|
552
|
+
`/deployments/${encodeURIComponent(name)}/custom_domains`,
|
|
553
|
+
Schema.Struct({ domains: Schema.Array(CustomDomainSchema) }),
|
|
554
|
+
);
|
|
555
|
+
return result.domains;
|
|
556
|
+
}),
|
|
557
|
+
createCustomDomain: Effect.fn("ConvexClient.createCustomDomain")(
|
|
558
|
+
(name: string, input: CustomDomainInput) =>
|
|
559
|
+
managementVoid(
|
|
560
|
+
"createCustomDomain",
|
|
561
|
+
"POST",
|
|
562
|
+
`/deployments/${encodeURIComponent(name)}/create_custom_domain`,
|
|
563
|
+
input,
|
|
564
|
+
),
|
|
565
|
+
),
|
|
566
|
+
deleteCustomDomain: Effect.fn("ConvexClient.deleteCustomDomain")(
|
|
567
|
+
(name: string, input: CustomDomainInput) =>
|
|
568
|
+
managementVoid(
|
|
569
|
+
"deleteCustomDomain",
|
|
570
|
+
"POST",
|
|
571
|
+
`/deployments/${encodeURIComponent(name)}/delete_custom_domain`,
|
|
572
|
+
input,
|
|
573
|
+
),
|
|
574
|
+
),
|
|
575
|
+
getCanonicalUrls: Effect.fn("ConvexClient.getCanonicalUrls")(function* (
|
|
576
|
+
url: string,
|
|
577
|
+
) {
|
|
578
|
+
const origin = yield* deploymentUrl("getCanonicalUrls", url);
|
|
579
|
+
const authorization = yield* deploymentAuthorization;
|
|
580
|
+
const response = yield* send(
|
|
581
|
+
"getCanonicalUrls",
|
|
582
|
+
"GET",
|
|
583
|
+
`${origin}/get_canonical_urls`,
|
|
584
|
+
authorization,
|
|
585
|
+
);
|
|
586
|
+
return yield* decode("getCanonicalUrls", response, CanonicalUrlsSchema);
|
|
587
|
+
}),
|
|
588
|
+
updateCanonicalUrl: Effect.fn("ConvexClient.updateCanonicalUrl")(function* (
|
|
589
|
+
url: string,
|
|
590
|
+
input: UpdateCanonicalUrlInput,
|
|
591
|
+
) {
|
|
592
|
+
const origin = yield* deploymentUrl("updateCanonicalUrl", url);
|
|
593
|
+
const authorization = yield* deploymentAuthorization;
|
|
594
|
+
yield* send(
|
|
595
|
+
"updateCanonicalUrl",
|
|
596
|
+
"POST",
|
|
597
|
+
`${origin}/update_canonical_url`,
|
|
598
|
+
authorization,
|
|
599
|
+
input,
|
|
600
|
+
);
|
|
601
|
+
}),
|
|
529
602
|
listUsageLimits: Effect.fn("ConvexClient.listUsageLimits")(function* (
|
|
530
603
|
url: string,
|
|
531
604
|
) {
|