@gaganref/confect-alchemy 10.6.0-fork.3 → 10.6.0-fork.30
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/Backend.d.ts +64 -5
- package/dist/Backend.d.ts.map +1 -1
- package/dist/Backend.js +187 -3
- package/dist/Backend.js.map +1 -1
- package/dist/Code.d.ts +14 -2
- package/dist/Code.d.ts.map +1 -1
- package/dist/Code.js +2 -2
- package/dist/Code.js.map +1 -1
- package/dist/Confect.d.ts +1 -1
- package/dist/Confect.d.ts.map +1 -1
- package/dist/Confect.js +8 -3
- package/dist/Confect.js.map +1 -1
- package/dist/Convex.d.ts +4 -1
- package/dist/Convex.d.ts.map +1 -1
- package/dist/Convex.js +10 -1
- package/dist/Convex.js.map +1 -1
- package/dist/ConvexClient.d.ts +92 -3
- package/dist/ConvexClient.d.ts.map +1 -1
- package/dist/ConvexClient.js +149 -27
- 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/DeployKey.js +3 -3
- package/dist/Deployment.d.ts +29 -3
- package/dist/Deployment.d.ts.map +1 -1
- package/dist/Deployment.js +39 -15
- package/dist/Deployment.js.map +1 -1
- package/dist/EnvironmentVariables.d.ts +76 -21
- package/dist/EnvironmentVariables.d.ts.map +1 -1
- package/dist/EnvironmentVariables.js +203 -19
- package/dist/EnvironmentVariables.js.map +1 -1
- package/dist/LogStream.d.ts +134 -0
- package/dist/LogStream.d.ts.map +1 -0
- package/dist/LogStream.js +324 -0
- package/dist/LogStream.js.map +1 -0
- package/dist/Project.js +2 -2
- package/dist/Providers.d.ts.map +1 -1
- package/dist/Providers.js +30 -15
- package/dist/Providers.js.map +1 -1
- package/dist/UsageLimit.d.ts +140 -0
- package/dist/UsageLimit.d.ts.map +1 -0
- package/dist/UsageLimit.js +145 -0
- package/dist/UsageLimit.js.map +1 -0
- package/dist/internal/CodeDeployment.d.ts +28 -1
- package/dist/internal/CodeDeployment.d.ts.map +1 -1
- package/dist/internal/CodeDeployment.js +85 -2
- package/dist/internal/CodeDeployment.js.map +1 -1
- package/dist/internal/CommandRunner.d.ts +4 -0
- package/dist/internal/CommandRunner.d.ts.map +1 -1
- package/dist/internal/CommandRunner.js +92 -6
- package/dist/internal/CommandRunner.js.map +1 -1
- package/dist/internal/FileLock.js +1 -1
- package/dist/internal/FunctionsDirectory.d.ts +12 -0
- package/dist/internal/FunctionsDirectory.d.ts.map +1 -0
- package/dist/internal/FunctionsDirectory.js +22 -0
- package/dist/internal/FunctionsDirectory.js.map +1 -0
- package/dist/internal/Lifecycle.d.ts +1 -0
- package/dist/internal/Lifecycle.d.ts.map +1 -1
- package/dist/internal/Lifecycle.js +24 -2
- package/dist/internal/Lifecycle.js.map +1 -1
- package/dist/internal/LocalBackend.d.ts +9 -0
- package/dist/internal/LocalBackend.d.ts.map +1 -1
- package/dist/internal/LocalBackend.js +14 -5
- package/dist/internal/LocalBackend.js.map +1 -1
- package/dist/internal/LogStream.d.ts +115 -0
- package/dist/internal/LogStream.d.ts.map +1 -0
- package/dist/internal/LogStream.js +123 -0
- package/dist/internal/LogStream.js.map +1 -0
- package/dist/internal/MountInit.d.ts.map +1 -1
- package/dist/internal/MountInit.js +4 -6
- package/dist/internal/MountInit.js.map +1 -1
- package/dist/internal/PushLock.d.ts +1 -0
- package/dist/internal/PushLock.d.ts.map +1 -1
- package/dist/internal/PushLock.js +4 -3
- package/dist/internal/PushLock.js.map +1 -1
- package/dist/internal/ResourceIdentity.js +1 -1
- package/dist/internal/Zip.js +1 -1
- package/package.json +4 -4
- package/src/Backend.ts +422 -12
- package/src/Code.ts +13 -0
- package/src/Confect.ts +7 -1
- package/src/Convex.ts +24 -1
- package/src/ConvexClient.ts +364 -31
- package/src/CustomDomain.ts +453 -0
- package/src/Deployment.ts +74 -12
- package/src/EnvironmentVariables.ts +505 -19
- package/src/LogStream.ts +662 -0
- package/src/Providers.ts +18 -0
- package/src/UsageLimit.ts +253 -0
- package/src/internal/CodeDeployment.ts +115 -0
- package/src/internal/CommandRunner.ts +182 -1
- package/src/internal/FunctionsDirectory.ts +27 -0
- package/src/internal/Lifecycle.ts +21 -1
- package/src/internal/LocalBackend.ts +9 -0
- package/src/internal/LogStream.ts +154 -0
- package/src/internal/MountInit.ts +3 -13
- package/src/internal/PushLock.ts +4 -1
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import type { RequestDestination } from "@convex-dev/platform/managementApi";
|
|
2
|
+
import { OwnedBySomeoneElse } from "alchemy/AdoptPolicy";
|
|
3
|
+
import type { Input } from "alchemy/Input";
|
|
4
|
+
import * as Output from "alchemy/Output";
|
|
5
|
+
import * as Provider from "alchemy/Provider";
|
|
6
|
+
import { Resource } from "alchemy/Resource";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Schema from "effect/Schema";
|
|
9
|
+
import { ConvexClient } from "./ConvexClient.js";
|
|
10
|
+
import type { Providers } from "./Providers.js";
|
|
11
|
+
export interface CustomDomainProps {
|
|
12
|
+
readonly deployment: {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly url: string;
|
|
15
|
+
};
|
|
16
|
+
readonly domain: string;
|
|
17
|
+
readonly requestDestination: RequestDestination;
|
|
18
|
+
/**
|
|
19
|
+
* Set the canonical URL after verification. Turning it off resets the default
|
|
20
|
+
* only while this domain is still canonical.
|
|
21
|
+
*/
|
|
22
|
+
readonly canonical?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface CustomDomainAttributes {
|
|
25
|
+
readonly deployment: {
|
|
26
|
+
readonly name: string;
|
|
27
|
+
readonly url: string;
|
|
28
|
+
};
|
|
29
|
+
readonly domain: string;
|
|
30
|
+
readonly requestDestination: RequestDestination;
|
|
31
|
+
readonly canonical: boolean;
|
|
32
|
+
readonly verificationTime: number | null;
|
|
33
|
+
/**
|
|
34
|
+
* The HTTPS address of this custom domain, including before verification.
|
|
35
|
+
*/
|
|
36
|
+
readonly url: string;
|
|
37
|
+
/**
|
|
38
|
+
* The canonical URL observed when this resource last changed.
|
|
39
|
+
*/
|
|
40
|
+
readonly canonicalUrl: string;
|
|
41
|
+
}
|
|
42
|
+
export type CustomDomain = Resource<"Convex.CustomDomain", CustomDomainProps, CustomDomainAttributes, never, Providers>;
|
|
43
|
+
export declare const CustomDomain: import("alchemy").ResourceClass<CustomDomain>;
|
|
44
|
+
declare const CustomDomainNotVisible_base: Schema.Class<CustomDomainNotVisible, Schema.TaggedStruct<"CustomDomainNotVisible", {
|
|
45
|
+
readonly deploymentName: Schema.String;
|
|
46
|
+
readonly domain: Schema.String;
|
|
47
|
+
}>, import("effect/Cause").YieldableError & {
|
|
48
|
+
readonly brand: unique symbol;
|
|
49
|
+
}>;
|
|
50
|
+
export declare class CustomDomainNotVisible extends CustomDomainNotVisible_base {
|
|
51
|
+
}
|
|
52
|
+
declare const CustomDomainIdentityChange_base: Schema.Class<CustomDomainIdentityChange, Schema.TaggedStruct<"CustomDomainIdentityChange", {
|
|
53
|
+
readonly oldIdentity: Schema.Struct<{
|
|
54
|
+
readonly deploymentName: Schema.String;
|
|
55
|
+
readonly domain: Schema.String;
|
|
56
|
+
readonly requestDestination: Schema.Literals<readonly ["convexCloud", "convexSite"]>;
|
|
57
|
+
}>;
|
|
58
|
+
readonly newIdentity: Schema.Struct<{
|
|
59
|
+
readonly deploymentName: Schema.String;
|
|
60
|
+
readonly domain: Schema.String;
|
|
61
|
+
readonly requestDestination: Schema.Literals<readonly ["convexCloud", "convexSite"]>;
|
|
62
|
+
}>;
|
|
63
|
+
}>, import("effect/Cause").YieldableError & {
|
|
64
|
+
readonly brand: unique symbol;
|
|
65
|
+
}>;
|
|
66
|
+
export declare class CustomDomainIdentityChange extends CustomDomainIdentityChange_base {
|
|
67
|
+
get message(): string;
|
|
68
|
+
}
|
|
69
|
+
declare const ConflictingCanonicalDomains_base: Schema.Class<ConflictingCanonicalDomains, Schema.TaggedStruct<"ConflictingCanonicalDomains", {
|
|
70
|
+
readonly deploymentName: Schema.String;
|
|
71
|
+
readonly requestDestination: Schema.String;
|
|
72
|
+
readonly domains: Schema.$Array<Schema.String>;
|
|
73
|
+
}>, import("effect/Cause").YieldableError & {
|
|
74
|
+
readonly brand: unique symbol;
|
|
75
|
+
}>;
|
|
76
|
+
export declare class ConflictingCanonicalDomains extends ConflictingCanonicalDomains_base {
|
|
77
|
+
get message(): string;
|
|
78
|
+
}
|
|
79
|
+
export declare const provider: Effect.Effect<{
|
|
80
|
+
diff: (args_0: {
|
|
81
|
+
id: string;
|
|
82
|
+
fqn: string;
|
|
83
|
+
instanceId: string;
|
|
84
|
+
olds: CustomDomainProps;
|
|
85
|
+
news: Input<CustomDomainProps>;
|
|
86
|
+
oldBindings: import("alchemy").ResourceBinding<never>[];
|
|
87
|
+
newBindings: Input<import("alchemy").ResourceBinding<never>[]>;
|
|
88
|
+
output: CustomDomainAttributes | undefined;
|
|
89
|
+
}) => Effect.Effect<{
|
|
90
|
+
action: "update";
|
|
91
|
+
} | undefined, import("effect/Config").ConfigError | ConflictingCanonicalDomains | import("./ConvexClient.js").ConvexApiError | import("./ConvexClient.js").ConvexConflict | import("./ConvexClient.js").ConvexNotFound | CustomDomainIdentityChange | Output.InvalidReferenceError | Output.MissingSourceError | import("alchemy/State/State").StateStoreError, never>;
|
|
92
|
+
read: (args_0: {
|
|
93
|
+
id: string;
|
|
94
|
+
fqn: string;
|
|
95
|
+
instanceId: string;
|
|
96
|
+
olds: CustomDomainProps;
|
|
97
|
+
output: CustomDomainAttributes | undefined;
|
|
98
|
+
previous?: CustomDomainAttributes;
|
|
99
|
+
}) => Effect.Effect<{
|
|
100
|
+
deployment: {
|
|
101
|
+
readonly name: string;
|
|
102
|
+
readonly url: string;
|
|
103
|
+
};
|
|
104
|
+
domain: string;
|
|
105
|
+
requestDestination: "convexCloud" | "convexSite";
|
|
106
|
+
canonical: boolean;
|
|
107
|
+
verificationTime: number | null;
|
|
108
|
+
url: string;
|
|
109
|
+
canonicalUrl: string;
|
|
110
|
+
} | undefined, import("effect/Config").ConfigError | ConflictingCanonicalDomains | import("./ConvexClient.js").ConvexApiError | import("./ConvexClient.js").ConvexConflict | import("./ConvexClient.js").ConvexNotFound | Output.InvalidReferenceError | Output.MissingSourceError | import("alchemy/State/State").StateStoreError, never>;
|
|
111
|
+
reconcile: (args_0: {
|
|
112
|
+
id: string;
|
|
113
|
+
fqn: string;
|
|
114
|
+
instanceId: string;
|
|
115
|
+
news: CustomDomainProps;
|
|
116
|
+
olds: CustomDomainProps | undefined;
|
|
117
|
+
output: CustomDomainAttributes | undefined;
|
|
118
|
+
session: import("alchemy/Report").ScopedPlanStatusSession;
|
|
119
|
+
bindings: import("alchemy").ResourceBinding<never>[];
|
|
120
|
+
}) => Effect.Effect<{
|
|
121
|
+
deployment: {
|
|
122
|
+
readonly name: string;
|
|
123
|
+
readonly url: string;
|
|
124
|
+
};
|
|
125
|
+
domain: string;
|
|
126
|
+
requestDestination: "convexCloud" | "convexSite";
|
|
127
|
+
url: string;
|
|
128
|
+
canonical: boolean;
|
|
129
|
+
verificationTime: number | null;
|
|
130
|
+
canonicalUrl: string;
|
|
131
|
+
}, import("effect/Config").ConfigError | ConflictingCanonicalDomains | import("./ConvexClient.js").ConvexApiError | import("./ConvexClient.js").ConvexConflict | import("./ConvexClient.js").ConvexNotFound | CustomDomainIdentityChange | CustomDomainNotVisible | Output.InvalidReferenceError | import("./internal/Lifecycle.js").LifecycleStateError | Output.MissingSourceError | OwnedBySomeoneElse | import("alchemy/State/State").StateStoreError, never>;
|
|
132
|
+
delete: (args_0: {
|
|
133
|
+
id: string;
|
|
134
|
+
fqn: string;
|
|
135
|
+
instanceId: string;
|
|
136
|
+
olds: CustomDomainProps;
|
|
137
|
+
output: CustomDomainAttributes;
|
|
138
|
+
session: import("alchemy/Report").ScopedPlanStatusSession;
|
|
139
|
+
bindings: import("alchemy").ResourceBinding<never>[];
|
|
140
|
+
force?: boolean;
|
|
141
|
+
}) => Effect.Effect<void, import("./ConvexClient.js").ConvexApiError | import("./ConvexClient.js").ConvexConflict | import("alchemy/State/State").StateStoreError, never>;
|
|
142
|
+
}, never, ConvexClient>;
|
|
143
|
+
export declare const layer: import("effect/Layer").Layer<Provider.Provider<CustomDomain>, never, ConvexClient>;
|
|
144
|
+
declare const UnsupportedLocalCustomDomain_base: Schema.Class<UnsupportedLocalCustomDomain, Schema.TaggedStruct<"UnsupportedLocalCustomDomain", {}>, import("effect/Cause").YieldableError & {
|
|
145
|
+
readonly brand: unique symbol;
|
|
146
|
+
}>;
|
|
147
|
+
export declare class UnsupportedLocalCustomDomain extends UnsupportedLocalCustomDomain_base {
|
|
148
|
+
get message(): string;
|
|
149
|
+
}
|
|
150
|
+
export declare const localProvider: Effect.Effect<{
|
|
151
|
+
reconcile: () => Effect.Effect<never, UnsupportedLocalCustomDomain, never>;
|
|
152
|
+
delete: () => Effect.Effect<void, never, never>;
|
|
153
|
+
}, never, never>;
|
|
154
|
+
export declare const localLayer: import("effect/Layer").Layer<Provider.Provider<CustomDomain>, never, never>;
|
|
155
|
+
export {};
|
|
156
|
+
//# sourceMappingURL=CustomDomain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomDomain.d.ts","sources":["../src/CustomDomain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAW,MAAM,qBAAqB,CAAC;AAElE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAEzC,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO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OAAO,WAInB;CACF;;;;;;oBAImB,OAAO,MAAM;;AAFjC,qBAAa,2BAA4B,SAAQ,gCAO/C;IACA,IAAa,OAAO,WAEnB;CACF;AAsFD,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;2BAtKmB,MAAM;0BAAgB,MAAM;;;;;;;;;;;;;;;;;;;;2BAA5B,MAAM;0BAAgB,MAAM;;;;;;;;;;;;;;;;;;;uBAyZlE,CAAC;AAEH,eAAO,MAAM,KAAK,oFAA0C,CAAC;;oBAIzC,OAAO,MAAM;;AAFjC,qBAAa,4BAA6B,SAAQ,iCAGX;IACrC,IAAa,OAAO,WAEnB;CACF;AAED,eAAO,MAAM,aAAa;;;gBAG8B,CAAC;AAEzD,eAAO,MAAM,UAAU,6EAA+C,CAAC"}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { ConvexClient } from "./ConvexClient.js";
|
|
2
|
+
import { checkpointCreate, checkpointUpdate, shouldAdopt } from "./internal/Lifecycle.js";
|
|
3
|
+
import * as Array from "effect/Array";
|
|
4
|
+
import * as Output from "alchemy/Output";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Record from "effect/Record";
|
|
7
|
+
import * as Schema from "effect/Schema";
|
|
8
|
+
import * as Provider from "alchemy/Provider";
|
|
9
|
+
import { Resource } from "alchemy/Resource";
|
|
10
|
+
import * as Option from "effect/Option";
|
|
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,KAAK;EAClB,OAAO,6CAA6C,IAAI,eAAe,GAAG,IAAI,OAAO,GAAG,IAAI,mBAAmB,MAAM,KAAK,eAAe,GAAG,KAAK,OAAO,GAAG,KAAK,mBAAmB;CACrL;AACF;AAEA,IAAa,8BAAb,cAAiD,OAAO,YAGtD,CAAC,CAAC,+BAA+B;CACjC,gBAAgB,OAAO;CACvB,oBAAoB,OAAO;CAC3B,SAAS,OAAO,MAAM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C,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/DeployKey.js
CHANGED
|
@@ -2,17 +2,17 @@ import { ConvexClient } from "./ConvexClient.js";
|
|
|
2
2
|
import { resourceName } from "./internal/ResourceIdentity.js";
|
|
3
3
|
import { checkpointCreate } from "./internal/Lifecycle.js";
|
|
4
4
|
import { adminKey, dataDirectories } from "./internal/LocalBackend.js";
|
|
5
|
+
import * as Array from "effect/Array";
|
|
5
6
|
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as Redacted from "effect/Redacted";
|
|
8
|
+
import * as Schema from "effect/Schema";
|
|
6
9
|
import * as Provider from "alchemy/Provider";
|
|
7
10
|
import { Resource } from "alchemy/Resource";
|
|
8
11
|
import * as FileSystem from "effect/FileSystem";
|
|
9
12
|
import * as Path from "effect/Path";
|
|
10
|
-
import * as Redacted from "effect/Redacted";
|
|
11
|
-
import * as Schema from "effect/Schema";
|
|
12
13
|
import * as Option from "effect/Option";
|
|
13
14
|
import * as String from "effect/String";
|
|
14
15
|
import { pipe } from "effect/Function";
|
|
15
|
-
import * as Array from "effect/Array";
|
|
16
16
|
import { isResolved } from "alchemy/Diff";
|
|
17
17
|
// src/DeployKey.ts
|
|
18
18
|
const DeployKey = Resource("Convex.DeployKey");
|
package/dist/Deployment.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CreateDeploymentType, RegionName } from "@convex-dev/platform/managementApi";
|
|
1
|
+
import type { CreateDeploymentType, DeploymentClass, RegionName } from "@convex-dev/platform/managementApi";
|
|
2
2
|
import { OwnedBySomeoneElse } from "alchemy/AdoptPolicy";
|
|
3
3
|
import * as Provider from "alchemy/Provider";
|
|
4
4
|
import { Resource } from "alchemy/Resource";
|
|
@@ -12,6 +12,12 @@ export interface DeploymentProps {
|
|
|
12
12
|
readonly type: CreateDeploymentType;
|
|
13
13
|
readonly reference?: string;
|
|
14
14
|
readonly region?: RegionName;
|
|
15
|
+
readonly class?: DeploymentClass;
|
|
16
|
+
/**
|
|
17
|
+
* Safe integer milliseconds since the Unix epoch. Omit to preserve the
|
|
18
|
+
* current cloud expiry; only null clears it.
|
|
19
|
+
*/
|
|
20
|
+
readonly expiresAt?: number | null;
|
|
15
21
|
}
|
|
16
22
|
export interface DeploymentAttributes {
|
|
17
23
|
readonly projectId: number;
|
|
@@ -23,6 +29,14 @@ export interface DeploymentAttributes {
|
|
|
23
29
|
* Always set in the cloud; a local deployment echoes the requested region.
|
|
24
30
|
*/
|
|
25
31
|
readonly region?: RegionName;
|
|
32
|
+
/**
|
|
33
|
+
* Always set in the cloud; local deployments do not have a cloud class.
|
|
34
|
+
*/
|
|
35
|
+
readonly class?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Cloud expiry in milliseconds since the Unix epoch, or null when unset.
|
|
38
|
+
*/
|
|
39
|
+
readonly expiresAt?: number | null;
|
|
26
40
|
}
|
|
27
41
|
export type Deployment = Resource<"Convex.Deployment", DeploymentProps, DeploymentAttributes, never, Providers>;
|
|
28
42
|
export declare const Deployment: import("alchemy").ResourceClass<Deployment>;
|
|
@@ -51,6 +65,14 @@ declare const AmbiguousDeployment_base: Schema.Class<AmbiguousDeployment, Schema
|
|
|
51
65
|
}>;
|
|
52
66
|
export declare class AmbiguousDeployment extends AmbiguousDeployment_base {
|
|
53
67
|
}
|
|
68
|
+
declare const InvalidDeploymentExpiry_base: Schema.Class<InvalidDeploymentExpiry, Schema.TaggedStruct<"InvalidDeploymentExpiry", {
|
|
69
|
+
readonly requested: Schema.String;
|
|
70
|
+
}>, import("effect/Cause").YieldableError & {
|
|
71
|
+
readonly brand: unique symbol;
|
|
72
|
+
}>;
|
|
73
|
+
export declare class InvalidDeploymentExpiry extends InvalidDeploymentExpiry_base {
|
|
74
|
+
get message(): string;
|
|
75
|
+
}
|
|
54
76
|
export declare const provider: Effect.Effect<{
|
|
55
77
|
diff: (args_0: {
|
|
56
78
|
id: string;
|
|
@@ -63,7 +85,7 @@ export declare const provider: Effect.Effect<{
|
|
|
63
85
|
output: DeploymentAttributes | undefined;
|
|
64
86
|
}) => Effect.Effect<{
|
|
65
87
|
action: "update";
|
|
66
|
-
} | undefined, import("./ConvexClient.js").ConvexApiError | import("./ConvexClient.js").ConvexConflict | DeploymentIdentityChange | UnsupportedLocalDeployment, never>;
|
|
88
|
+
} | undefined, import("./ConvexClient.js").ConvexApiError | import("./ConvexClient.js").ConvexConflict | DeploymentIdentityChange | InvalidDeploymentExpiry | UnsupportedLocalDeployment, never>;
|
|
67
89
|
read: (args_0: {
|
|
68
90
|
id: string;
|
|
69
91
|
fqn: string;
|
|
@@ -78,6 +100,8 @@ export declare const provider: Effect.Effect<{
|
|
|
78
100
|
type: "custom" | "dev" | "preview" | "prod";
|
|
79
101
|
url: string;
|
|
80
102
|
region: "aws-ap-southeast-2" | "aws-ca-central-1" | "aws-eu-west-1" | "aws-us-east-1";
|
|
103
|
+
class: string;
|
|
104
|
+
expiresAt: number | null;
|
|
81
105
|
} | undefined, AmbiguousDeployment | import("./ConvexClient.js").ConvexApiError | import("./ConvexClient.js").ConvexConflict | import("./ConvexClient.js").ConvexNotFound | UnsupportedLocalDeployment, never>;
|
|
82
106
|
reconcile: (args_0: {
|
|
83
107
|
id: string;
|
|
@@ -95,7 +119,9 @@ export declare const provider: Effect.Effect<{
|
|
|
95
119
|
type: "custom" | "dev" | "preview" | "prod";
|
|
96
120
|
url: string;
|
|
97
121
|
region: "aws-ap-southeast-2" | "aws-ca-central-1" | "aws-eu-west-1" | "aws-us-east-1";
|
|
98
|
-
|
|
122
|
+
class: string;
|
|
123
|
+
expiresAt: number | null;
|
|
124
|
+
}, AmbiguousDeployment | import("./ConvexClient.js").ConvexApiError | import("./ConvexClient.js").ConvexConflict | import("./ConvexClient.js").ConvexNotFound | DeploymentIdentityChange | InvalidDeploymentExpiry | import("./internal/Lifecycle.js").LifecycleStateError | OwnedBySomeoneElse | import("alchemy/State/State").StateStoreError | UnsupportedLocalDeployment, never>;
|
|
99
125
|
delete: (args_0: {
|
|
100
126
|
id: string;
|
|
101
127
|
fqn: string;
|
package/dist/Deployment.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Deployment.d.ts","sources":["../src/Deployment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,
|
|
1
|
+
{"version":3,"file":"Deployment.d.ts","sources":["../src/Deployment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EAEf,UAAU,EACX,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAW,MAAM,qBAAqB,CAAC;AAGlE,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,MAAM,MAAM,eAAe,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