@gaganref/confect-alchemy 10.6.0-fork.3 → 10.6.0-fork.31
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 +4 -5
- package/dist/internal/MountInit.d.ts.map +1 -1
- package/dist/internal/MountInit.js +17 -36
- 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 +24 -65
- package/src/internal/PushLock.ts +4 -1
package/src/ConvexClient.ts
CHANGED
|
@@ -7,11 +7,13 @@ import * as Effect from "effect/Effect";
|
|
|
7
7
|
import * as Layer from "effect/Layer";
|
|
8
8
|
import * as Redacted from "effect/Redacted";
|
|
9
9
|
import * as Schema from "effect/Schema";
|
|
10
|
+
import * as Stream from "effect/Stream";
|
|
10
11
|
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
11
12
|
import * as HttpClient from "effect/http/HttpClient";
|
|
12
13
|
import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
13
14
|
import type * as HttpClientResponse from "effect/http/HttpClientResponse";
|
|
14
15
|
import * as Loopback from "./internal/Loopback.js";
|
|
16
|
+
import * as LogStream from "./internal/LogStream.js";
|
|
15
17
|
import * as String from "effect/String";
|
|
16
18
|
import { pipe } from "effect/Function";
|
|
17
19
|
import * as Array from "effect/Array";
|
|
@@ -36,11 +38,11 @@ export type UpdateProjectInput = Pick<
|
|
|
36
38
|
>;
|
|
37
39
|
export type CreateDeploymentInput = Pick<
|
|
38
40
|
ManagementApi.PlatformCreateDeploymentArgs,
|
|
39
|
-
"type" | "region" | "class"
|
|
41
|
+
"type" | "region" | "class" | "expiresAt"
|
|
40
42
|
> & { readonly reference: string };
|
|
41
43
|
export type UpdateDeploymentInput = Pick<
|
|
42
44
|
ManagementApi.PlatformUpdateDeploymentArgs,
|
|
43
|
-
"reference" | "expiresAt" | "sendLogsToClient"
|
|
45
|
+
"reference" | "expiresAt" | "sendLogsToClient" | "class"
|
|
44
46
|
>;
|
|
45
47
|
export type CreateDeployKeyInput = ManagementApi.PlatformCreateDeployKeyArgs;
|
|
46
48
|
export type CreatedDeployKey = {
|
|
@@ -65,9 +67,63 @@ export type EnvironmentVariables = Readonly<
|
|
|
65
67
|
>
|
|
66
68
|
>;
|
|
67
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>;
|
|
87
|
+
export type CreateLogStreamInput = LogStream.RedactInput<
|
|
88
|
+
LogStream.ReadonlyDeep<DeploymentApi.CreateLogStreamArgs>
|
|
89
|
+
>;
|
|
90
|
+
export type UpdateLogStreamInput = LogStream.RedactInput<
|
|
91
|
+
LogStream.ReadonlyDeep<DeploymentApi.UpdateLogStreamArgs>
|
|
92
|
+
>;
|
|
93
|
+
export type LogStreamConfig = Redacted.Redacted<typeof LogStream.Config.Type>;
|
|
94
|
+
export type CreatedLogStream = Redacted.Redacted<typeof LogStream.Created.Type>;
|
|
95
|
+
|
|
96
|
+
const logStreamBody = (input: Readonly<Record<string, unknown>>) =>
|
|
97
|
+
Rec.map(input, (value) =>
|
|
98
|
+
Redacted.isRedacted(value) ? Redacted.value(value) : value,
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
export type UsageLimit = DeploymentApi.UsageLimitConfigResponse;
|
|
102
|
+
export type UsageLimitInput = DeploymentApi.UsageLimitConfigRequest;
|
|
103
|
+
|
|
104
|
+
const UsageLimitSchema = Schema.Struct({
|
|
105
|
+
id: Schema.String,
|
|
106
|
+
metric: Schema.Literals([
|
|
107
|
+
"functionCalls",
|
|
108
|
+
"databaseIoGb",
|
|
109
|
+
"dataEgressGb",
|
|
110
|
+
"searchQueryGb",
|
|
111
|
+
"queryMutationComputeGbHours",
|
|
112
|
+
"actionComputeConvexGbHours",
|
|
113
|
+
"actionComputeNodeJsGbHours",
|
|
114
|
+
"actionComputeCpuGbHours",
|
|
115
|
+
"aiGatewayCostDollars",
|
|
116
|
+
]),
|
|
117
|
+
window: Schema.Literals(["day", "month"]),
|
|
118
|
+
limitType: Schema.Literals(["warning", "disable"]),
|
|
119
|
+
limit: Schema.Finite,
|
|
120
|
+
enabled: Schema.Boolean,
|
|
121
|
+
}) satisfies Schema.Schema<UsageLimit>;
|
|
122
|
+
|
|
68
123
|
const errorFields = {
|
|
69
124
|
operation: Schema.String,
|
|
70
125
|
status: Schema.optionalKey(Schema.Finite),
|
|
126
|
+
serverCode: Schema.optionalKey(Schema.String),
|
|
71
127
|
code: Schema.Literals([
|
|
72
128
|
"HttpError",
|
|
73
129
|
"TransportError",
|
|
@@ -78,20 +134,45 @@ const errorFields = {
|
|
|
78
134
|
]),
|
|
79
135
|
};
|
|
80
136
|
|
|
137
|
+
const errorMessage = (error: {
|
|
138
|
+
readonly operation: string;
|
|
139
|
+
readonly status?: number;
|
|
140
|
+
readonly code: string;
|
|
141
|
+
readonly serverCode?: string;
|
|
142
|
+
}) => {
|
|
143
|
+
const classification =
|
|
144
|
+
error.status === undefined ? error.code : `${error.status}, ${error.code}`;
|
|
145
|
+
const serverCode =
|
|
146
|
+
error.serverCode === undefined ? "" : `, ${error.serverCode}`;
|
|
147
|
+
return `${error.operation} failed (${classification}${serverCode})`;
|
|
148
|
+
};
|
|
149
|
+
|
|
81
150
|
export class ConvexApiError extends Schema.TaggedError<
|
|
82
151
|
ConvexApiError,
|
|
83
152
|
{ readonly brand: unique symbol }
|
|
84
|
-
>()("ConvexApiError", errorFields) {
|
|
153
|
+
>()("ConvexApiError", errorFields) {
|
|
154
|
+
override get message() {
|
|
155
|
+
return errorMessage(this);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
85
158
|
|
|
86
159
|
export class ConvexNotFound extends Schema.TaggedError<
|
|
87
160
|
ConvexNotFound,
|
|
88
161
|
{ readonly brand: unique symbol }
|
|
89
|
-
>()("ConvexNotFound", errorFields) {
|
|
162
|
+
>()("ConvexNotFound", errorFields) {
|
|
163
|
+
override get message() {
|
|
164
|
+
return errorMessage(this);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
90
167
|
|
|
91
168
|
export class ConvexConflict extends Schema.TaggedError<
|
|
92
169
|
ConvexConflict,
|
|
93
170
|
{ readonly brand: unique symbol }
|
|
94
|
-
>()("ConvexConflict", errorFields) {
|
|
171
|
+
>()("ConvexConflict", errorFields) {
|
|
172
|
+
override get message() {
|
|
173
|
+
return errorMessage(this);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
95
176
|
|
|
96
177
|
/**
|
|
97
178
|
* A function the deployment ran failed, with the message Convex reports.
|
|
@@ -200,6 +281,59 @@ const ProjectsPageSchema = Schema.Struct({
|
|
|
200
281
|
}),
|
|
201
282
|
});
|
|
202
283
|
|
|
284
|
+
// Retain at most 8 KiB before parsing an error body. Stop the stream on overflow.
|
|
285
|
+
const maxErrorBodyBytes = 8 * 1024;
|
|
286
|
+
const httpFailure = Effect.fn("ConvexClient.httpFailure")(function* (
|
|
287
|
+
operation: string,
|
|
288
|
+
response: HttpClientResponse.HttpClientResponse,
|
|
289
|
+
credentials: readonly Redacted.Redacted<string>[],
|
|
290
|
+
) {
|
|
291
|
+
const fallback = ConvexApiError.make({
|
|
292
|
+
operation,
|
|
293
|
+
status: response.status,
|
|
294
|
+
code: "HttpError",
|
|
295
|
+
});
|
|
296
|
+
const serverCode = yield* response.stream.pipe(
|
|
297
|
+
Stream.mapAccum(
|
|
298
|
+
() => 0,
|
|
299
|
+
(size, bytes) => {
|
|
300
|
+
const total = size + bytes.byteLength;
|
|
301
|
+
return [total, [{ size: total, bytes }]] as const;
|
|
302
|
+
},
|
|
303
|
+
),
|
|
304
|
+
Stream.mapEffect(({ size, bytes }) =>
|
|
305
|
+
size > maxErrorBodyBytes ? Effect.fail(fallback) : Effect.succeed(bytes),
|
|
306
|
+
),
|
|
307
|
+
Stream.mkArrayBuffer,
|
|
308
|
+
Effect.timeout("5 seconds"),
|
|
309
|
+
Effect.map((bytes) => new TextDecoder().decode(bytes)),
|
|
310
|
+
Effect.flatMap(
|
|
311
|
+
Schema.decodeEffect(
|
|
312
|
+
Schema.fromJsonString(Schema.Struct({ code: Schema.String })),
|
|
313
|
+
),
|
|
314
|
+
),
|
|
315
|
+
Effect.map(({ code }) =>
|
|
316
|
+
/^[A-Za-z][A-Za-z0-9]{0,63}$/.test(code) &&
|
|
317
|
+
!Array.some(
|
|
318
|
+
credentials,
|
|
319
|
+
(credential) => code === Redacted.value(credential),
|
|
320
|
+
)
|
|
321
|
+
? code
|
|
322
|
+
: undefined,
|
|
323
|
+
),
|
|
324
|
+
Effect.orElseSucceed(() => undefined),
|
|
325
|
+
);
|
|
326
|
+
const fields = {
|
|
327
|
+
operation,
|
|
328
|
+
status: response.status,
|
|
329
|
+
code: "HttpError" as const,
|
|
330
|
+
...(serverCode === undefined ? {} : { serverCode }),
|
|
331
|
+
};
|
|
332
|
+
if (response.status === 404) return yield* ConvexNotFound.make(fields);
|
|
333
|
+
if (response.status === 409) return yield* ConvexConflict.make(fields);
|
|
334
|
+
return yield* ConvexApiError.make(fields);
|
|
335
|
+
});
|
|
336
|
+
|
|
203
337
|
const make = Effect.fn("ConvexClient.make")(function* (options?: {
|
|
204
338
|
readonly token?: Redacted.Redacted<string>;
|
|
205
339
|
readonly mode?: ProviderMode;
|
|
@@ -218,6 +352,16 @@ const make = Effect.fn("ConvexClient.make")(function* (options?: {
|
|
|
218
352
|
));
|
|
219
353
|
return Redacted.make(`Bearer ${Redacted.value(token)}`);
|
|
220
354
|
});
|
|
355
|
+
const deploymentAuthorization = managementAuthorization.pipe(
|
|
356
|
+
Effect.map((authorization) =>
|
|
357
|
+
pipe(
|
|
358
|
+
authorization,
|
|
359
|
+
Redacted.value,
|
|
360
|
+
String.replace(/^Bearer /, "Convex "),
|
|
361
|
+
Redacted.make,
|
|
362
|
+
),
|
|
363
|
+
),
|
|
364
|
+
);
|
|
221
365
|
const baseUrl = "https://api.convex.dev/v1";
|
|
222
366
|
|
|
223
367
|
const send = Effect.fn("ConvexClient.request")(function* (
|
|
@@ -249,27 +393,15 @@ const make = Effect.fn("ConvexClient.make")(function* (options?: {
|
|
|
249
393
|
ConvexApiError.make({ operation, code: "TransportError" }),
|
|
250
394
|
),
|
|
251
395
|
);
|
|
252
|
-
if (response.status
|
|
253
|
-
return yield*
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
operation,
|
|
262
|
-
status: 409,
|
|
263
|
-
code: "HttpError",
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
if (response.status < 200 || response.status >= 300) {
|
|
267
|
-
return yield* ConvexApiError.make({
|
|
268
|
-
operation,
|
|
269
|
-
status: response.status,
|
|
270
|
-
code: "HttpError",
|
|
271
|
-
});
|
|
272
|
-
}
|
|
396
|
+
if (response.status < 200 || response.status >= 300)
|
|
397
|
+
return yield* httpFailure(operation, response, [
|
|
398
|
+
pipe(
|
|
399
|
+
authorization,
|
|
400
|
+
Redacted.value,
|
|
401
|
+
String.replace(/^(?:Bearer|Convex) /, ""),
|
|
402
|
+
Redacted.make,
|
|
403
|
+
),
|
|
404
|
+
]);
|
|
273
405
|
return response;
|
|
274
406
|
});
|
|
275
407
|
|
|
@@ -402,11 +534,7 @@ const make = Effect.fn("ConvexClient.make")(function* (options?: {
|
|
|
402
534
|
);
|
|
403
535
|
// Convex answers a function that threw with 560 and its message.
|
|
404
536
|
if (response.status !== 200 && response.status !== 560)
|
|
405
|
-
return yield*
|
|
406
|
-
operation,
|
|
407
|
-
status: response.status,
|
|
408
|
-
code: "HttpError",
|
|
409
|
-
});
|
|
537
|
+
return yield* httpFailure(operation, response, [key]);
|
|
410
538
|
const result = yield* decode(operation, response, FunctionResponse);
|
|
411
539
|
if (result.status === "error")
|
|
412
540
|
return yield* ConvexFunctionError.make({
|
|
@@ -415,6 +543,134 @@ const make = Effect.fn("ConvexClient.make")(function* (options?: {
|
|
|
415
543
|
});
|
|
416
544
|
return result.value;
|
|
417
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
|
+
}),
|
|
602
|
+
listUsageLimits: Effect.fn("ConvexClient.listUsageLimits")(function* (
|
|
603
|
+
url: string,
|
|
604
|
+
) {
|
|
605
|
+
const origin = yield* deploymentUrl("listUsageLimits", url);
|
|
606
|
+
const authorization = yield* deploymentAuthorization;
|
|
607
|
+
const response = yield* send(
|
|
608
|
+
"listUsageLimits",
|
|
609
|
+
"GET",
|
|
610
|
+
`${origin}/list_usage_limits`,
|
|
611
|
+
authorization,
|
|
612
|
+
);
|
|
613
|
+
const result = yield* decode(
|
|
614
|
+
"listUsageLimits",
|
|
615
|
+
response,
|
|
616
|
+
Schema.Struct({ usageLimits: Schema.Array(UsageLimitSchema) }),
|
|
617
|
+
);
|
|
618
|
+
return result.usageLimits;
|
|
619
|
+
}),
|
|
620
|
+
createUsageLimit: Effect.fn("ConvexClient.createUsageLimit")(function* (
|
|
621
|
+
url: string,
|
|
622
|
+
input: UsageLimitInput,
|
|
623
|
+
) {
|
|
624
|
+
const origin = yield* deploymentUrl("createUsageLimit", url);
|
|
625
|
+
const authorization = yield* deploymentAuthorization;
|
|
626
|
+
const response = yield* send(
|
|
627
|
+
"createUsageLimit",
|
|
628
|
+
"POST",
|
|
629
|
+
`${origin}/create_usage_limit`,
|
|
630
|
+
authorization,
|
|
631
|
+
input,
|
|
632
|
+
);
|
|
633
|
+
const result = yield* decode(
|
|
634
|
+
"createUsageLimit",
|
|
635
|
+
response,
|
|
636
|
+
Schema.Struct({ usageLimit: UsageLimitSchema }),
|
|
637
|
+
);
|
|
638
|
+
return result.usageLimit;
|
|
639
|
+
}),
|
|
640
|
+
updateUsageLimit: Effect.fn("ConvexClient.updateUsageLimit")(function* (
|
|
641
|
+
url: string,
|
|
642
|
+
id: string,
|
|
643
|
+
input: UsageLimitInput,
|
|
644
|
+
) {
|
|
645
|
+
const origin = yield* deploymentUrl("updateUsageLimit", url);
|
|
646
|
+
const authorization = yield* deploymentAuthorization;
|
|
647
|
+
const response = yield* send(
|
|
648
|
+
"updateUsageLimit",
|
|
649
|
+
"POST",
|
|
650
|
+
`${origin}/update_usage_limit/${encodeURIComponent(id)}`,
|
|
651
|
+
authorization,
|
|
652
|
+
input,
|
|
653
|
+
);
|
|
654
|
+
const result = yield* decode(
|
|
655
|
+
"updateUsageLimit",
|
|
656
|
+
response,
|
|
657
|
+
Schema.Struct({ usageLimit: UsageLimitSchema }),
|
|
658
|
+
);
|
|
659
|
+
return result.usageLimit;
|
|
660
|
+
}),
|
|
661
|
+
deleteUsageLimit: Effect.fn("ConvexClient.deleteUsageLimit")(function* (
|
|
662
|
+
url: string,
|
|
663
|
+
id: string,
|
|
664
|
+
) {
|
|
665
|
+
const origin = yield* deploymentUrl("deleteUsageLimit", url);
|
|
666
|
+
const authorization = yield* deploymentAuthorization;
|
|
667
|
+
yield* send(
|
|
668
|
+
"deleteUsageLimit",
|
|
669
|
+
"POST",
|
|
670
|
+
`${origin}/delete_usage_limit/${encodeURIComponent(id)}`,
|
|
671
|
+
authorization,
|
|
672
|
+
);
|
|
673
|
+
}),
|
|
418
674
|
listProjects: Effect.fn("ConvexClient.listProjects")(function* (
|
|
419
675
|
teamId: number,
|
|
420
676
|
) {
|
|
@@ -553,6 +809,83 @@ const make = Effect.fn("ConvexClient.make")(function* (options?: {
|
|
|
553
809
|
} satisfies ManagementApi.PlatformDeleteDeployKeyArgs,
|
|
554
810
|
),
|
|
555
811
|
),
|
|
812
|
+
createLogStream: Effect.fn("ConvexClient.createLogStream")(function* (
|
|
813
|
+
url: string,
|
|
814
|
+
key: Redacted.Redacted<string>,
|
|
815
|
+
input: CreateLogStreamInput,
|
|
816
|
+
) {
|
|
817
|
+
const operation = "createLogStream";
|
|
818
|
+
const response = yield* send(
|
|
819
|
+
operation,
|
|
820
|
+
"POST",
|
|
821
|
+
`${yield* deploymentUrl(operation, url)}/create_log_stream`,
|
|
822
|
+
Redacted.make(`Convex ${Redacted.value(key)}`),
|
|
823
|
+
logStreamBody(input),
|
|
824
|
+
);
|
|
825
|
+
const created = yield* decode(operation, response, LogStream.Created);
|
|
826
|
+
return Redacted.make(created);
|
|
827
|
+
}),
|
|
828
|
+
getLogStream: Effect.fn("ConvexClient.getLogStream")(function* (
|
|
829
|
+
url: string,
|
|
830
|
+
key: Redacted.Redacted<string>,
|
|
831
|
+
id: string,
|
|
832
|
+
): Effect.fn.Return<LogStreamConfig, ConvexClientError> {
|
|
833
|
+
const operation = "getLogStream";
|
|
834
|
+
const response = yield* send(
|
|
835
|
+
operation,
|
|
836
|
+
"GET",
|
|
837
|
+
`${yield* deploymentUrl(operation, url)}/get_log_stream/${encodeURIComponent(id)}`,
|
|
838
|
+
Redacted.make(`Convex ${Redacted.value(key)}`),
|
|
839
|
+
);
|
|
840
|
+
const config = yield* decode(operation, response, LogStream.Config);
|
|
841
|
+
return Redacted.make(config);
|
|
842
|
+
}),
|
|
843
|
+
listLogStreams: Effect.fn("ConvexClient.listLogStreams")(function* (
|
|
844
|
+
url: string,
|
|
845
|
+
key: Redacted.Redacted<string>,
|
|
846
|
+
): Effect.fn.Return<LogStreamConfig[], ConvexClientError> {
|
|
847
|
+
const operation = "listLogStreams";
|
|
848
|
+
const response = yield* send(
|
|
849
|
+
operation,
|
|
850
|
+
"GET",
|
|
851
|
+
`${yield* deploymentUrl(operation, url)}/list_log_streams`,
|
|
852
|
+
Redacted.make(`Convex ${Redacted.value(key)}`),
|
|
853
|
+
);
|
|
854
|
+
const streams = yield* decode(
|
|
855
|
+
operation,
|
|
856
|
+
response,
|
|
857
|
+
Schema.Array(LogStream.Config),
|
|
858
|
+
);
|
|
859
|
+
return Array.map(streams, (stream) => Redacted.make(stream));
|
|
860
|
+
}),
|
|
861
|
+
updateLogStream: Effect.fn("ConvexClient.updateLogStream")(function* (
|
|
862
|
+
url: string,
|
|
863
|
+
key: Redacted.Redacted<string>,
|
|
864
|
+
id: string,
|
|
865
|
+
input: UpdateLogStreamInput,
|
|
866
|
+
) {
|
|
867
|
+
const operation = "updateLogStream";
|
|
868
|
+
yield* send(
|
|
869
|
+
operation,
|
|
870
|
+
"POST",
|
|
871
|
+
`${yield* deploymentUrl(operation, url)}/update_log_stream/${encodeURIComponent(id)}`,
|
|
872
|
+
Redacted.make(`Convex ${Redacted.value(key)}`),
|
|
873
|
+
logStreamBody(input),
|
|
874
|
+
);
|
|
875
|
+
}),
|
|
876
|
+
deleteLogStream: Effect.fn("ConvexClient.deleteLogStream")(function* (
|
|
877
|
+
url: string,
|
|
878
|
+
key: Redacted.Redacted<string>,
|
|
879
|
+
id: string,
|
|
880
|
+
) {
|
|
881
|
+
const operation = "deleteLogStream";
|
|
882
|
+
yield* send(
|
|
883
|
+
operation,
|
|
884
|
+
"POST",
|
|
885
|
+
`${yield* deploymentUrl(operation, url)}/delete_log_stream/${encodeURIComponent(id)}`,
|
|
886
|
+
Redacted.make(`Convex ${Redacted.value(key)}`),
|
|
887
|
+
);
|
|
888
|
+
}),
|
|
556
889
|
listEnvironmentVariables: Effect.fn(
|
|
557
890
|
"ConvexClient.listEnvironmentVariables",
|
|
558
891
|
)(function* (
|