@gaganref/confect-alchemy 10.6.0-fork.16 → 10.6.0-fork.18
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/ConvexClient.d.ts +1 -1
- package/dist/ConvexClient.d.ts.map +1 -1
- package/dist/ConvexClient.js.map +1 -1
- package/dist/Deployment.d.ts +21 -2
- package/dist/Deployment.d.ts.map +1 -1
- package/dist/Deployment.js +24 -8
- package/dist/Deployment.js.map +1 -1
- package/package.json +3 -3
- package/src/ConvexClient.ts +1 -1
- package/src/Deployment.ts +47 -5
package/dist/ConvexClient.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export type DeployKey = Omit<ManagementApi.PlatformDeployKeyResponse, "allowedAc
|
|
|
15
15
|
};
|
|
16
16
|
export type CreateProjectInput = Pick<ManagementApi.PlatformCreateProjectArgs, "projectName">;
|
|
17
17
|
export type UpdateProjectInput = Pick<ManagementApi.PlatformUpdateProjectArgs, "name">;
|
|
18
|
-
export type CreateDeploymentInput = Pick<ManagementApi.PlatformCreateDeploymentArgs, "type" | "region" | "class"> & {
|
|
18
|
+
export type CreateDeploymentInput = Pick<ManagementApi.PlatformCreateDeploymentArgs, "type" | "region" | "class" | "expiresAt"> & {
|
|
19
19
|
readonly reference: string;
|
|
20
20
|
};
|
|
21
21
|
export type UpdateDeploymentInput = Pick<ManagementApi.PlatformUpdateDeploymentArgs, "reference" | "expiresAt" | "sendLogsToClient" | "class">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConvexClient.d.ts","sources":["../src/ConvexClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,aAAa,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,KAAK,aAAa,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,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i from \"@convex-dev/platform/deploymentApi\";\nimport type * as ManagementApi from \"@convex-dev/platform/managementApi\";\nimport type { ProviderMode } from \"alchemy/ProviderMode\";\nimport * as Config from \"effect/Config\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Redacted from \"effect/Redacted\";\nimport * as Schema from \"effect/Schema\";\nimport * as FetchHttpClient from \"effect/http/FetchHttpClient\";\nimport * as HttpClient from \"effect/http/HttpClient\";\nimport * as HttpClientRequest from \"effect/http/HttpClientRequest\";\nimport type * as HttpClientResponse from \"effect/http/HttpClientResponse\";\nimport * as Loopback from \"./internal/Loopback.js\";\nimport * as String from \"effect/String\";\nimport { pipe } from \"effect/Function\";\nimport * as Array from \"effect/Array\";\nimport * as Rec from \"effect/Record\";\n\nexport type Project = ManagementApi.ProjectResponse;\nexport type CreatedProject = ManagementApi.PlatformCreateProjectResponse;\nexport type Deployment = ManagementApi.PlatformDeploymentResponse;\nexport type DeployKey = Omit<\n ManagementApi.PlatformDeployKeyResponse,\n \"allowedActions\"\n> & {\n readonly allowedActions: readonly string[];\n};\nexport type CreateProjectInput = Pick<\n ManagementApi.PlatformCreateProjectArgs,\n \"projectName\"\n>;\nexport type UpdateProjectInput = Pick<\n ManagementApi.PlatformUpdateProjectArgs,\n \"name\"\n>;\nexport type CreateDeploymentInput = Pick<\n ManagementApi.PlatformCreateDeploymentArgs,\n \"type\" | \"region\" | \"class\"\n> & { readonly reference: string };\nexport type UpdateDeploymentInput = Pick<\n ManagementApi.PlatformUpdateDeploymentArgs,\n \"reference\" | \"expiresAt\" | \"sendLogsToClient\" | \"class\"\n>;\nexport type CreateDeployKeyInput = ManagementApi.PlatformCreateDeployKeyArgs;\nexport type CreatedDeployKey = {\n readonly deployKey: Redacted.Redacted<\n ManagementApi.PlatformCreateDeployKeyResponse[\"deployKey\"]\n >;\n};\nexport type EnvironmentVariableChange = Omit<\n DeploymentApi.UpdateEnvVarRequest,\n \"value\"\n> & {\n readonly value?:\n | Exclude<DeploymentApi.UpdateEnvVarRequest[\"value\"], undefined>\n | Redacted.Redacted<string>;\n};\nexport type EnvironmentVariables = Readonly<\n Record<\n string,\n Redacted.Redacted<\n DeploymentApi.ListEnvVarsResponse[\"environmentVariables\"][string]\n >\n >\n>;\n\nconst errorFields = {\n operation: Schema.String,\n status: Schema.optionalKey(Schema.Finite),\n code: Schema.Literals([\n \"HttpError\",\n \"TransportError\",\n \"InvalidResponse\",\n \"InvalidRequest\",\n \"InvalidPagination\",\n \"InvalidConfiguration\",\n ]),\n};\n\nexport class ConvexApiError extends Schema.TaggedError<\n ConvexApiError,\n { readonly brand: unique symbol }\n>()(\"ConvexApiError\", errorFields) {}\n\nexport class ConvexNotFound extends Schema.TaggedError<\n ConvexNotFound,\n { readonly brand: unique symbol }\n>()(\"ConvexNotFound\", errorFields) {}\n\nexport class ConvexConflict extends Schema.TaggedError<\n ConvexConflict,\n { readonly brand: unique symbol }\n>()(\"ConvexConflict\", errorFields) {}\n\n/**\n * A function the deployment ran failed, with the message Convex reports.\n */\nexport class ConvexFunctionError extends Schema.TaggedError<\n ConvexFunctionError,\n { readonly brand: unique symbol }\n>()(\"ConvexFunctionError\", {\n functionPath: Schema.String,\n errorMessage: Schema.String,\n}) {}\n\nconst FunctionResponse = Schema.Union([\n Schema.Struct({ status: Schema.Literal(\"success\"), value: Schema.Unknown }),\n Schema.Struct({\n status: Schema.Literal(\"error\"),\n errorMessage: Schema.String,\n }),\n]);\n\nexport type ConvexClientError =\n | ConvexApiError\n | ConvexNotFound\n | ConvexConflict;\n\nconst ProjectSchema = Schema.Struct({\n id: Schema.Finite,\n name: Schema.String,\n slug: Schema.String,\n teamId: Schema.Finite,\n teamSlug: Schema.String,\n createTime: Schema.Finite,\n prodDeploymentName: Schema.String.pipe(Schema.NullOr, Schema.optionalKey),\n devDeploymentName: Schema.String.pipe(Schema.NullOr, Schema.optionalKey),\n}) satisfies Schema.Schema<Project>;\n\nconst CreatedProjectSchema = Schema.Struct({\n id: Schema.Finite,\n projectId: Schema.Finite,\n slug: Schema.String,\n deploymentName: Schema.String.pipe(Schema.NullOr, Schema.optionalKey),\n deploymentUrl: Schema.String.pipe(Schema.NullOr, Schema.optionalKey),\n}) satisfies Schema.Schema<CreatedProject>;\n\nconst deploymentFields = {\n name: Schema.String,\n createTime: Schema.Finite,\n deploymentType: Schema.Literals([\"dev\", \"prod\", \"preview\", \"custom\"]),\n projectId: Schema.Finite,\n previewIdentifier: Schema.String.pipe(Schema.NullOr, Schema.optionalKey),\n};\n\nconst DeploymentSchema = Schema.Union([\n Schema.Struct({\n ...deploymentFields,\n kind: Schema.Literal(\"cloud\"),\n id: Schema.Finite,\n lastDeployTime: Schema.Finite.pipe(Schema.NullOr, Schema.optionalKey),\n creator: Schema.Finite.pipe(Schema.NullOr, Schema.optionalKey),\n region: Schema.Literals([\n \"aws-us-east-1\",\n \"aws-eu-west-1\",\n \"aws-ap-southeast-2\",\n \"aws-ca-central-1\",\n ]),\n isDefault: Schema.Boolean,\n reference: Schema.String,\n dashboardEditConfirmation: Schema.Boolean.pipe(\n Schema.NullOr,\n Schema.optionalKey,\n ),\n deploymentUrl: Schema.String,\n expiresAt: Schema.Finite.pipe(Schema.NullOr, Schema.optionalKey),\n class: Schema.String,\n sendLogsToClient: Schema.Boolean.pipe(Schema.NullOr, Schema.optionalKey),\n }),\n Schema.Struct({\n ...deploymentFields,\n kind: Schema.Literal(\"local\"),\n creator: Schema.Finite,\n port: Schema.Finite,\n deviceName: Schema.String,\n isActive: Schema.Boolean,\n }),\n]) satisfies Schema.Schema<Deployment>;\n\nconst DeployKeySchema = Schema.Struct({\n id: Schema.Finite,\n name: Schema.String,\n creationTime: Schema.Finite,\n lastUsedTime: Schema.Finite.pipe(Schema.NullOr, Schema.optionalKey),\n expiresAt: Schema.Finite.pipe(Schema.NullOr, Schema.optionalKey),\n creator: Schema.Finite.pipe(Schema.NullOr, Schema.optionalKey),\n managedBy: Schema.Union([\n Schema.Literal(\"vercel\"),\n Schema.Struct({ oauthApp: Schema.String }),\n ]).pipe(Schema.NullOr, Schema.optionalKey),\n allowedActions: Schema.Array(Schema.String),\n}) satisfies Schema.Schema<DeployKey>;\n\nconst ProjectsPageSchema = Schema.Struct({\n items: Schema.Array(ProjectSchema),\n pagination: Schema.Struct({\n hasMore: Schema.Boolean,\n nextCursor: Schema.String.pipe(Schema.NullOr, Schema.optionalKey),\n }),\n});\n\nconst make = Effect.fn(\"ConvexClient.make\")(function* (options?: {\n readonly token?: Redacted.Redacted<string>;\n readonly mode?: ProviderMode;\n}) {\n const http = yield* HttpClient.HttpClient;\n const managementAuthorization = Effect.gen(function* () {\n const token =\n options?.token ??\n (yield* Config.Redacted(\"CONVEX_ACCESS_TOKEN\").pipe(\n Effect.mapError(() =>\n ConvexApiError.make({\n operation: \"configure\",\n code: \"InvalidConfiguration\",\n }),\n ),\n ));\n return Redacted.make(`Bearer ${Redacted.value(token)}`);\n });\n const baseUrl = \"https://api.convex.dev/v1\";\n\n const send = Effect.fn(\"ConvexClient.request\")(function* (\n operation: string,\n method: \"GET\" | \"POST\" | \"PATCH\",\n url: string,\n authorization: Redacted.Redacted<string>,\n body?: unknown,\n ) {\n let request = HttpClientRequest.make(method)(url).pipe(\n HttpClientRequest.setHeader(\n \"authorization\",\n Redacted.value(authorization),\n ),\n HttpClientRequest.acceptJson,\n );\n if (body !== undefined) {\n request = yield* HttpClientRequest.bodyJson(request, body).pipe(\n Effect.mapError(() =>\n ConvexApiError.make({ operation, code: \"InvalidRequest\" }),\n ),\n );\n }\n const response = yield* http.execute(request).pipe(\n Effect.provideService(FetchHttpClient.RequestInit, {\n redirect: \"manual\",\n }),\n Effect.mapError(() =>\n ConvexApiError.make({ operation, code: \"TransportError\" }),\n ),\n );\n if (response.status === 404) {\n return yield* ConvexNotFound.make({\n operation,\n status: 404,\n code: \"HttpError\",\n });\n }\n if (response.status === 409) {\n return yield* ConvexConflict.make({\n operation,\n status: 409,\n code: \"HttpError\",\n });\n }\n if (response.status < 200 || response.status >= 300) {\n return yield* ConvexApiError.make({\n operation,\n status: response.status,\n code: \"HttpError\",\n });\n }\n return response;\n });\n\n const decode = Effect.fn(\"ConvexClient.decode\")(function* <A>(\n operation: string,\n response: HttpClientResponse.HttpClientResponse,\n schema: Schema.Decoder<A>,\n ) {\n const invalidResponse = () =>\n ConvexApiError.make({\n operation,\n status: response.status,\n code: \"InvalidResponse\",\n });\n const body = yield* response.json.pipe(Effect.mapError(invalidResponse));\n return yield* Schema.decodeEffect(schema)(body).pipe(\n Effect.mapError(invalidResponse),\n );\n });\n\n const management = Effect.fn(\"ConvexClient.management\")(function* <A>(\n operation: string,\n method: \"GET\" | \"POST\" | \"PATCH\",\n path: string,\n schema: Schema.Decoder<A>,\n body?: unknown,\n ) {\n const managementAuthorizationValue = yield* managementAuthorization;\n const response = yield* send(\n operation,\n method,\n `${baseUrl}${path}`,\n managementAuthorizationValue,\n body,\n );\n return yield* decode(operation, response, schema);\n });\n\n const managementVoid = Effect.fn(\"ConvexClient.managementVoid\")(function* (\n operation: string,\n method: \"POST\" | \"PATCH\",\n path: string,\n body?: unknown,\n ) {\n const managementAuthorizationValue = yield* managementAuthorization;\n yield* send(\n operation,\n method,\n `${baseUrl}${path}`,\n managementAuthorizationValue,\n body,\n );\n });\n\n const deploymentUrl = Effect.fn(\"ConvexClient.deploymentUrl\")(function* (\n operation: string,\n url: string,\n ) {\n const invalidUrl = () =>\n ConvexApiError.make({ operation, code: \"InvalidRequest\" });\n if (options?.mode === \"local\") {\n if (!Loopback.isOrigin(url)) return yield* invalidUrl();\n return `${url}/api/v1`;\n }\n const parsed = yield* Effect.try({\n try: () => new URL(url),\n catch: invalidUrl,\n });\n if (\n parsed.protocol !== \"https:\" ||\n parsed.username !== \"\" ||\n parsed.password !== \"\" ||\n parsed.port !== \"\" ||\n parsed.search !== \"\" ||\n parsed.hash !== \"\" ||\n parsed.pathname !== \"/\" ||\n !/^[a-z0-9-]+(?:\\.(?:eu-west-1|ap-southeast-2|ca-central-1))?\\.convex\\.cloud$/.test(\n parsed.hostname,\n ) ||\n pipe(url, String.replace(/\\/$/, \"\")) !== parsed.origin\n ) {\n return yield* invalidUrl();\n }\n return `${parsed.origin}/api/v1`;\n });\n\n return {\n /**\n * Run a deployment function with admin authority, internal ones and ones\n * inside a component included.\n */\n runFunction: Effect.fn(\"ConvexClient.runFunction\")(function* (\n url: string,\n key: Redacted.Redacted<string>,\n functionPath: string,\n args: unknown,\n componentPath?: string,\n ) {\n const operation = \"runFunction\";\n const deploymentUrlResult = yield* deploymentUrl(operation, url);\n const origin = pipe(\n deploymentUrlResult,\n String.replace(/\\/api\\/v1$/, \"\"),\n );\n const request = yield* HttpClientRequest.post(\n `${origin}/api/function`,\n ).pipe(\n HttpClientRequest.setHeader(\n \"authorization\",\n `Convex ${Redacted.value(key)}`,\n ),\n HttpClientRequest.acceptJson,\n HttpClientRequest.bodyJson({\n path: functionPath,\n args,\n format: \"json\",\n ...(componentPath === undefined ? {} : { componentPath }),\n }),\n Effect.mapError(() =>\n ConvexApiError.make({ operation, code: \"InvalidRequest\" }),\n ),\n );\n const response = yield* http.execute(request).pipe(\n Effect.provideService(FetchHttpClient.RequestInit, {\n redirect: \"manual\",\n }),\n Effect.mapError(() =>\n ConvexApiError.make({ operation, code: \"TransportError\" }),\n ),\n );\n // Convex answers a function that threw with 560 and its message.\n if (response.status !== 200 && response.status !== 560)\n return yield* ConvexApiError.make({\n operation,\n status: response.status,\n code: \"HttpError\",\n });\n const result = yield* decode(operation, response, FunctionResponse);\n if (result.status === \"error\")\n return yield* ConvexFunctionError.make({\n functionPath,\n errorMessage: result.errorMessage,\n });\n return result.value;\n }),\n listProjects: Effect.fn(\"ConvexClient.listProjects\")(function* (\n teamId: number,\n ) {\n const projects: Project[] = [];\n const seenCursors = new Set<string>();\n let cursor: string | undefined;\n while (true) {\n const page = yield* management(\n \"listProjects\",\n \"GET\",\n `/teams/${teamId}/projects${cursor === undefined ? \"\" : `?cursor=${encodeURIComponent(cursor)}`}`,\n ProjectsPageSchema,\n );\n projects.push(...page.items);\n if (!page.pagination.hasMore) return projects;\n const nextCursor = page.pagination.nextCursor;\n if (\n nextCursor === undefined ||\n nextCursor === null ||\n nextCursor === \"\" ||\n seenCursors.has(nextCursor)\n ) {\n return yield* ConvexApiError.make({\n operation: \"listProjects\",\n code: \"InvalidPagination\",\n });\n }\n seenCursors.add(nextCursor);\n cursor = nextCursor;\n }\n }),\n getProject: Effect.fn(\"ConvexClient.getProject\")((projectId: number) =>\n management(\"getProject\", \"GET\", `/projects/${projectId}`, ProjectSchema),\n ),\n createProject: Effect.fn(\"ConvexClient.createProject\")(\n (teamId: number, input: CreateProjectInput) =>\n management(\n \"createProject\",\n \"POST\",\n `/teams/${teamId}/create_project`,\n CreatedProjectSchema,\n input,\n ),\n ),\n updateProject: Effect.fn(\"ConvexClient.updateProject\")(\n (projectId: number, input: UpdateProjectInput) =>\n management(\n \"updateProject\",\n \"PATCH\",\n `/projects/${projectId}`,\n ProjectSchema,\n input,\n ),\n ),\n deleteProject: Effect.fn(\"ConvexClient.deleteProject\")(\n (projectId: number) =>\n managementVoid(\n \"deleteProject\",\n \"POST\",\n `/projects/${projectId}/delete`,\n ),\n ),\n listDeployments: Effect.fn(\"ConvexClient.listDeployments\")(\n (projectId: number) =>\n management(\n \"listDeployments\",\n \"GET\",\n `/projects/${projectId}/list_deployments`,\n Schema.Array(DeploymentSchema),\n ),\n ),\n getDeployment: Effect.fn(\"ConvexClient.getDeployment\")((name: string) =>\n management(\n \"getDeployment\",\n \"GET\",\n `/deployments/${encodeURIComponent(name)}`,\n DeploymentSchema,\n ),\n ),\n createDeployment: Effect.fn(\"ConvexClient.createDeployment\")(\n (projectId: number, input: CreateDeploymentInput) =>\n management(\n \"createDeployment\",\n \"POST\",\n `/projects/${projectId}/create_deployment`,\n DeploymentSchema,\n input,\n ),\n ),\n updateDeployment: Effect.fn(\"ConvexClient.updateDeployment\")(\n (name: string, input: UpdateDeploymentInput) =>\n managementVoid(\n \"updateDeployment\",\n \"PATCH\",\n `/deployments/${encodeURIComponent(name)}`,\n input,\n ),\n ),\n deleteDeployment: Effect.fn(\"ConvexClient.deleteDeployment\")(\n (name: string) =>\n managementVoid(\n \"deleteDeployment\",\n \"POST\",\n `/deployments/${encodeURIComponent(name)}/delete`,\n ),\n ),\n createDeployKey: Effect.fn(\"ConvexClient.createDeployKey\")(function* (\n name: string,\n input: CreateDeployKeyInput,\n ): Effect.fn.Return<CreatedDeployKey, ConvexClientError> {\n const response = yield* management(\n \"createDeployKey\",\n \"POST\",\n `/deployments/${encodeURIComponent(name)}/create_deploy_key`,\n Schema.Struct({ deployKey: Schema.String }),\n input,\n );\n return { deployKey: Redacted.make(response.deployKey) };\n }),\n listDeployKeys: Effect.fn(\"ConvexClient.listDeployKeys\")((name: string) =>\n management(\n \"listDeployKeys\",\n \"GET\",\n `/deployments/${encodeURIComponent(name)}/list_deploy_keys`,\n Schema.Array(DeployKeySchema),\n ),\n ),\n deleteDeployKey: Effect.fn(\"ConvexClient.deleteDeployKey\")(\n (name: string, id: string | Redacted.Redacted<string>) =>\n managementVoid(\n \"deleteDeployKey\",\n \"POST\",\n `/deployments/${encodeURIComponent(name)}/delete_deploy_key`,\n {\n id: Redacted.isRedacted(id) ? Redacted.value(id) : id,\n } satisfies ManagementApi.PlatformDeleteDeployKeyArgs,\n ),\n ),\n listEnvironmentVariables: Effect.fn(\n \"ConvexClient.listEnvironmentVariables\",\n )(function* (\n url: string,\n key: Redacted.Redacted<string>,\n ): Effect.fn.Return<EnvironmentVariables, ConvexClientError> {\n const response = yield* send(\n \"listEnvironmentVariables\",\n \"GET\",\n `${yield* deploymentUrl(\"listEnvironmentVariables\", url)}/list_environment_variables`,\n Redacted.make(`Convex ${Redacted.value(key)}`),\n );\n const result = yield* decode(\n \"listEnvironmentVariables\",\n response,\n Schema.Struct({\n environmentVariables: Schema.Record(Schema.String, Schema.String),\n }),\n );\n return Rec.fromEntries(\n Array.map(\n Rec.toEntries(result.environmentVariables),\n ([name, value]) => [name, Redacted.make(value)],\n ),\n );\n }),\n updateEnvironmentVariables: Effect.fn(\n \"ConvexClient.updateEnvironmentVariables\",\n )(function* (\n url: string,\n key: Redacted.Redacted<string>,\n changes: readonly EnvironmentVariableChange[],\n ) {\n yield* send(\n \"updateEnvironmentVariables\",\n \"POST\",\n `${yield* deploymentUrl(\"updateEnvironmentVariables\", url)}/update_environment_variables`,\n Redacted.make(`Convex ${Redacted.value(key)}`),\n {\n changes: Array.map(changes, ({ name, value }) => ({\n name,\n ...(value === undefined\n ? {}\n : {\n value: Redacted.isRedacted(value)\n ? Redacted.value(value)\n : value,\n }),\n })),\n } satisfies {\n readonly changes: Readonly<\n DeploymentApi.UpdateEnvVarsRequest[\"changes\"]\n >;\n },\n );\n }),\n };\n});\n\nexport class ConvexClient extends Context.Service<\n ConvexClient,\n Effect.Success<ReturnType<typeof make>>\n>()(\"@confect/alchemy/ConvexClient\") {}\n\n/**\n * `mode: \"local\"` sends deployment requests only to a loopback backend over\n * HTTP; the default accepts only Convex cloud HTTPS origins.\n *\n * @stability unstable\n */\nexport const layer = (options?: {\n readonly token?: Redacted.Redacted<string>;\n readonly mode?: ProviderMode;\n}) =>\n Layer.effect(ConvexClient, make(options).pipe(Effect.map(ConvexClient.of)));\n"],"mappings":";;;;;;;;;;;;;;;AAmEA,MAAM,cAAc;CAClB,WAAW,OAAO;CAClB,QAAQ,OAAO,YAAY,OAAO,MAAM;CACxC,MAAM,OAAO,SAAS;EACpB;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;AACH;AAEA,IAAa,iBAAb,cAAoC,OAAO,YAGzC,CAAC,CAAC,kBAAkB,WAAW,CAAC,CAAC,CAAC;AAEpC,IAAa,iBAAb,cAAoC,OAAO,YAGzC,CAAC,CAAC,kBAAkB,WAAW,CAAC,CAAC,CAAC;AAEpC,IAAa,iBAAb,cAAoC,OAAO,YAGzC,CAAC,CAAC,kBAAkB,WAAW,CAAC,CAA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,UAAU,SAAS,MAAM,GAAG,GAAG,GAC7C,EACE,SAAS,MAAM,IAAI,UAAU,EAAE,MAAM,aAAa;IAChD;IACA,GAAI,UAAU,KAAA,IACV,CAAC,IACD,EACE,OAAO,SAAS,WAAW,KAAK,IAC5B,SAAS,MAAM,KAAK,IACpB,MACN;GACN,EAAE,EACJ,CAKF;EACF,CAAC;CACH;AACF,CAAC;AAED,IAAa,eAAb,cAAkC,QAAQ,QAGxC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC;;;;;;;AAQtC,MAAa,SAAS,YAIpB,MAAM,OAAO,cAAc,KAAK,OAAO,CAAC,CAAC,KAAK,OAAO,IAAI,aAAa,EAAE,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"ConvexClient.js","names":["Loopback.isOrigin"],"sources":["../src/ConvexClient.ts"],"sourcesContent":["import type * as DeploymentApi from \"@convex-dev/platform/deploymentApi\";\nimport type * as ManagementApi from \"@convex-dev/platform/managementApi\";\nimport type { ProviderMode } from \"alchemy/ProviderMode\";\nimport * as Config from \"effect/Config\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Redacted from \"effect/Redacted\";\nimport * as Schema from \"effect/Schema\";\nimport * as FetchHttpClient from \"effect/http/FetchHttpClient\";\nimport * as HttpClient from \"effect/http/HttpClient\";\nimport * as HttpClientRequest from \"effect/http/HttpClientRequest\";\nimport type * as HttpClientResponse from \"effect/http/HttpClientResponse\";\nimport * as Loopback from \"./internal/Loopback.js\";\nimport * as String from \"effect/String\";\nimport { pipe } from \"effect/Function\";\nimport * as Array from \"effect/Array\";\nimport * as Rec from \"effect/Record\";\n\nexport type Project = ManagementApi.ProjectResponse;\nexport type CreatedProject = ManagementApi.PlatformCreateProjectResponse;\nexport type Deployment = ManagementApi.PlatformDeploymentResponse;\nexport type DeployKey = Omit<\n ManagementApi.PlatformDeployKeyResponse,\n \"allowedActions\"\n> & {\n readonly allowedActions: readonly string[];\n};\nexport type CreateProjectInput = Pick<\n ManagementApi.PlatformCreateProjectArgs,\n \"projectName\"\n>;\nexport type UpdateProjectInput = Pick<\n ManagementApi.PlatformUpdateProjectArgs,\n \"name\"\n>;\nexport type CreateDeploymentInput = Pick<\n ManagementApi.PlatformCreateDeploymentArgs,\n \"type\" | \"region\" | \"class\" | \"expiresAt\"\n> & { readonly reference: string };\nexport type UpdateDeploymentInput = Pick<\n ManagementApi.PlatformUpdateDeploymentArgs,\n \"reference\" | \"expiresAt\" | \"sendLogsToClient\" | \"class\"\n>;\nexport type CreateDeployKeyInput = ManagementApi.PlatformCreateDeployKeyArgs;\nexport type CreatedDeployKey = {\n readonly deployKey: Redacted.Redacted<\n ManagementApi.PlatformCreateDeployKeyResponse[\"deployKey\"]\n >;\n};\nexport type EnvironmentVariableChange = Omit<\n DeploymentApi.UpdateEnvVarRequest,\n \"value\"\n> & {\n readonly value?:\n | Exclude<DeploymentApi.UpdateEnvVarRequest[\"value\"], undefined>\n | Redacted.Redacted<string>;\n};\nexport type EnvironmentVariables = Readonly<\n Record<\n string,\n Redacted.Redacted<\n DeploymentApi.ListEnvVarsResponse[\"environmentVariables\"][string]\n >\n >\n>;\n\nconst errorFields = {\n operation: Schema.String,\n status: Schema.optionalKey(Schema.Finite),\n code: Schema.Literals([\n \"HttpError\",\n \"TransportError\",\n \"InvalidResponse\",\n \"InvalidRequest\",\n \"InvalidPagination\",\n \"InvalidConfiguration\",\n ]),\n};\n\nexport class ConvexApiError extends Schema.TaggedError<\n ConvexApiError,\n { readonly brand: unique symbol }\n>()(\"ConvexApiError\", errorFields) {}\n\nexport class ConvexNotFound extends Schema.TaggedError<\n ConvexNotFound,\n { readonly brand: unique symbol }\n>()(\"ConvexNotFound\", errorFields) {}\n\nexport class ConvexConflict extends Schema.TaggedError<\n ConvexConflict,\n { readonly brand: unique symbol }\n>()(\"ConvexConflict\", errorFields) {}\n\n/**\n * A function the deployment ran failed, with the message Convex reports.\n */\nexport class ConvexFunctionError extends Schema.TaggedError<\n ConvexFunctionError,\n { readonly brand: unique symbol }\n>()(\"ConvexFunctionError\", {\n functionPath: Schema.String,\n errorMessage: Schema.String,\n}) {}\n\nconst FunctionResponse = Schema.Union([\n Schema.Struct({ status: Schema.Literal(\"success\"), value: Schema.Unknown }),\n Schema.Struct({\n status: Schema.Literal(\"error\"),\n errorMessage: Schema.String,\n }),\n]);\n\nexport type ConvexClientError =\n | ConvexApiError\n | ConvexNotFound\n | ConvexConflict;\n\nconst ProjectSchema = Schema.Struct({\n id: Schema.Finite,\n name: Schema.String,\n slug: Schema.String,\n teamId: Schema.Finite,\n teamSlug: Schema.String,\n createTime: Schema.Finite,\n prodDeploymentName: Schema.String.pipe(Schema.NullOr, Schema.optionalKey),\n devDeploymentName: Schema.String.pipe(Schema.NullOr, Schema.optionalKey),\n}) satisfies Schema.Schema<Project>;\n\nconst CreatedProjectSchema = Schema.Struct({\n id: Schema.Finite,\n projectId: Schema.Finite,\n slug: Schema.String,\n deploymentName: Schema.String.pipe(Schema.NullOr, Schema.optionalKey),\n deploymentUrl: Schema.String.pipe(Schema.NullOr, Schema.optionalKey),\n}) satisfies Schema.Schema<CreatedProject>;\n\nconst deploymentFields = {\n name: Schema.String,\n createTime: Schema.Finite,\n deploymentType: Schema.Literals([\"dev\", \"prod\", \"preview\", \"custom\"]),\n projectId: Schema.Finite,\n previewIdentifier: Schema.String.pipe(Schema.NullOr, Schema.optionalKey),\n};\n\nconst DeploymentSchema = Schema.Union([\n Schema.Struct({\n ...deploymentFields,\n kind: Schema.Literal(\"cloud\"),\n id: Schema.Finite,\n lastDeployTime: Schema.Finite.pipe(Schema.NullOr, Schema.optionalKey),\n creator: Schema.Finite.pipe(Schema.NullOr, Schema.optionalKey),\n region: Schema.Literals([\n \"aws-us-east-1\",\n \"aws-eu-west-1\",\n \"aws-ap-southeast-2\",\n \"aws-ca-central-1\",\n ]),\n isDefault: Schema.Boolean,\n reference: Schema.String,\n dashboardEditConfirmation: Schema.Boolean.pipe(\n Schema.NullOr,\n Schema.optionalKey,\n ),\n deploymentUrl: Schema.String,\n expiresAt: Schema.Finite.pipe(Schema.NullOr, Schema.optionalKey),\n class: Schema.String,\n sendLogsToClient: Schema.Boolean.pipe(Schema.NullOr, Schema.optionalKey),\n }),\n Schema.Struct({\n ...deploymentFields,\n kind: Schema.Literal(\"local\"),\n creator: Schema.Finite,\n port: Schema.Finite,\n deviceName: Schema.String,\n isActive: Schema.Boolean,\n }),\n]) satisfies Schema.Schema<Deployment>;\n\nconst DeployKeySchema = Schema.Struct({\n id: Schema.Finite,\n name: Schema.String,\n creationTime: Schema.Finite,\n lastUsedTime: Schema.Finite.pipe(Schema.NullOr, Schema.optionalKey),\n expiresAt: Schema.Finite.pipe(Schema.NullOr, Schema.optionalKey),\n creator: Schema.Finite.pipe(Schema.NullOr, Schema.optionalKey),\n managedBy: Schema.Union([\n Schema.Literal(\"vercel\"),\n Schema.Struct({ oauthApp: Schema.String }),\n ]).pipe(Schema.NullOr, Schema.optionalKey),\n allowedActions: Schema.Array(Schema.String),\n}) satisfies Schema.Schema<DeployKey>;\n\nconst ProjectsPageSchema = Schema.Struct({\n items: Schema.Array(ProjectSchema),\n pagination: Schema.Struct({\n hasMore: Schema.Boolean,\n nextCursor: Schema.String.pipe(Schema.NullOr, Schema.optionalKey),\n }),\n});\n\nconst make = Effect.fn(\"ConvexClient.make\")(function* (options?: {\n readonly token?: Redacted.Redacted<string>;\n readonly mode?: ProviderMode;\n}) {\n const http = yield* HttpClient.HttpClient;\n const managementAuthorization = Effect.gen(function* () {\n const token =\n options?.token ??\n (yield* Config.Redacted(\"CONVEX_ACCESS_TOKEN\").pipe(\n Effect.mapError(() =>\n ConvexApiError.make({\n operation: \"configure\",\n code: \"InvalidConfiguration\",\n }),\n ),\n ));\n return Redacted.make(`Bearer ${Redacted.value(token)}`);\n });\n const baseUrl = \"https://api.convex.dev/v1\";\n\n const send = Effect.fn(\"ConvexClient.request\")(function* (\n operation: string,\n method: \"GET\" | \"POST\" | \"PATCH\",\n url: string,\n authorization: Redacted.Redacted<string>,\n body?: unknown,\n ) {\n let request = HttpClientRequest.make(method)(url).pipe(\n HttpClientRequest.setHeader(\n \"authorization\",\n Redacted.value(authorization),\n ),\n HttpClientRequest.acceptJson,\n );\n if (body !== undefined) {\n request = yield* HttpClientRequest.bodyJson(request, body).pipe(\n Effect.mapError(() =>\n ConvexApiError.make({ operation, code: \"InvalidRequest\" }),\n ),\n );\n }\n const response = yield* http.execute(request).pipe(\n Effect.provideService(FetchHttpClient.RequestInit, {\n redirect: \"manual\",\n }),\n Effect.mapError(() =>\n ConvexApiError.make({ operation, code: \"TransportError\" }),\n ),\n );\n if (response.status === 404) {\n return yield* ConvexNotFound.make({\n operation,\n status: 404,\n code: \"HttpError\",\n });\n }\n if (response.status === 409) {\n return yield* ConvexConflict.make({\n operation,\n status: 409,\n code: \"HttpError\",\n });\n }\n if (response.status < 200 || response.status >= 300) {\n return yield* ConvexApiError.make({\n operation,\n status: response.status,\n code: \"HttpError\",\n });\n }\n return response;\n });\n\n const decode = Effect.fn(\"ConvexClient.decode\")(function* <A>(\n operation: string,\n response: HttpClientResponse.HttpClientResponse,\n schema: Schema.Decoder<A>,\n ) {\n const invalidResponse = () =>\n ConvexApiError.make({\n operation,\n status: response.status,\n code: \"InvalidResponse\",\n });\n const body = yield* response.json.pipe(Effect.mapError(invalidResponse));\n return yield* Schema.decodeEffect(schema)(body).pipe(\n Effect.mapError(invalidResponse),\n );\n });\n\n const management = Effect.fn(\"ConvexClient.management\")(function* <A>(\n operation: string,\n method: \"GET\" | \"POST\" | \"PATCH\",\n path: string,\n schema: Schema.Decoder<A>,\n body?: unknown,\n ) {\n const managementAuthorizationValue = yield* managementAuthorization;\n const response = yield* send(\n operation,\n method,\n `${baseUrl}${path}`,\n managementAuthorizationValue,\n body,\n );\n return yield* decode(operation, response, schema);\n });\n\n const managementVoid = Effect.fn(\"ConvexClient.managementVoid\")(function* (\n operation: string,\n method: \"POST\" | \"PATCH\",\n path: string,\n body?: unknown,\n ) {\n const managementAuthorizationValue = yield* managementAuthorization;\n yield* send(\n operation,\n method,\n `${baseUrl}${path}`,\n managementAuthorizationValue,\n body,\n );\n });\n\n const deploymentUrl = Effect.fn(\"ConvexClient.deploymentUrl\")(function* (\n operation: string,\n url: string,\n ) {\n const invalidUrl = () =>\n ConvexApiError.make({ operation, code: \"InvalidRequest\" });\n if (options?.mode === \"local\") {\n if (!Loopback.isOrigin(url)) return yield* invalidUrl();\n return `${url}/api/v1`;\n }\n const parsed = yield* Effect.try({\n try: () => new URL(url),\n catch: invalidUrl,\n });\n if (\n parsed.protocol !== \"https:\" ||\n parsed.username !== \"\" ||\n parsed.password !== \"\" ||\n parsed.port !== \"\" ||\n parsed.search !== \"\" ||\n parsed.hash !== \"\" ||\n parsed.pathname !== \"/\" ||\n !/^[a-z0-9-]+(?:\\.(?:eu-west-1|ap-southeast-2|ca-central-1))?\\.convex\\.cloud$/.test(\n parsed.hostname,\n ) ||\n pipe(url, String.replace(/\\/$/, \"\")) !== parsed.origin\n ) {\n return yield* invalidUrl();\n }\n return `${parsed.origin}/api/v1`;\n });\n\n return {\n /**\n * Run a deployment function with admin authority, internal ones and ones\n * inside a component included.\n */\n runFunction: Effect.fn(\"ConvexClient.runFunction\")(function* (\n url: string,\n key: Redacted.Redacted<string>,\n functionPath: string,\n args: unknown,\n componentPath?: string,\n ) {\n const operation = \"runFunction\";\n const deploymentUrlResult = yield* deploymentUrl(operation, url);\n const origin = pipe(\n deploymentUrlResult,\n String.replace(/\\/api\\/v1$/, \"\"),\n );\n const request = yield* HttpClientRequest.post(\n `${origin}/api/function`,\n ).pipe(\n HttpClientRequest.setHeader(\n \"authorization\",\n `Convex ${Redacted.value(key)}`,\n ),\n HttpClientRequest.acceptJson,\n HttpClientRequest.bodyJson({\n path: functionPath,\n args,\n format: \"json\",\n ...(componentPath === undefined ? {} : { componentPath }),\n }),\n Effect.mapError(() =>\n ConvexApiError.make({ operation, code: \"InvalidRequest\" }),\n ),\n );\n const response = yield* http.execute(request).pipe(\n Effect.provideService(FetchHttpClient.RequestInit, {\n redirect: \"manual\",\n }),\n Effect.mapError(() =>\n ConvexApiError.make({ operation, code: \"TransportError\" }),\n ),\n );\n // Convex answers a function that threw with 560 and its message.\n if (response.status !== 200 && response.status !== 560)\n return yield* ConvexApiError.make({\n operation,\n status: response.status,\n code: \"HttpError\",\n });\n const result = yield* decode(operation, response, FunctionResponse);\n if (result.status === \"error\")\n return yield* ConvexFunctionError.make({\n functionPath,\n errorMessage: result.errorMessage,\n });\n return result.value;\n }),\n listProjects: Effect.fn(\"ConvexClient.listProjects\")(function* (\n teamId: number,\n ) {\n const projects: Project[] = [];\n const seenCursors = new Set<string>();\n let cursor: string | undefined;\n while (true) {\n const page = yield* management(\n \"listProjects\",\n \"GET\",\n `/teams/${teamId}/projects${cursor === undefined ? \"\" : `?cursor=${encodeURIComponent(cursor)}`}`,\n ProjectsPageSchema,\n );\n projects.push(...page.items);\n if (!page.pagination.hasMore) return projects;\n const nextCursor = page.pagination.nextCursor;\n if (\n nextCursor === undefined ||\n nextCursor === null ||\n nextCursor === \"\" ||\n seenCursors.has(nextCursor)\n ) {\n return yield* ConvexApiError.make({\n operation: \"listProjects\",\n code: \"InvalidPagination\",\n });\n }\n seenCursors.add(nextCursor);\n cursor = nextCursor;\n }\n }),\n getProject: Effect.fn(\"ConvexClient.getProject\")((projectId: number) =>\n management(\"getProject\", \"GET\", `/projects/${projectId}`, ProjectSchema),\n ),\n createProject: Effect.fn(\"ConvexClient.createProject\")(\n (teamId: number, input: CreateProjectInput) =>\n management(\n \"createProject\",\n \"POST\",\n `/teams/${teamId}/create_project`,\n CreatedProjectSchema,\n input,\n ),\n ),\n updateProject: Effect.fn(\"ConvexClient.updateProject\")(\n (projectId: number, input: UpdateProjectInput) =>\n management(\n \"updateProject\",\n \"PATCH\",\n `/projects/${projectId}`,\n ProjectSchema,\n input,\n ),\n ),\n deleteProject: Effect.fn(\"ConvexClient.deleteProject\")(\n (projectId: number) =>\n managementVoid(\n \"deleteProject\",\n \"POST\",\n `/projects/${projectId}/delete`,\n ),\n ),\n listDeployments: Effect.fn(\"ConvexClient.listDeployments\")(\n (projectId: number) =>\n management(\n \"listDeployments\",\n \"GET\",\n `/projects/${projectId}/list_deployments`,\n Schema.Array(DeploymentSchema),\n ),\n ),\n getDeployment: Effect.fn(\"ConvexClient.getDeployment\")((name: string) =>\n management(\n \"getDeployment\",\n \"GET\",\n `/deployments/${encodeURIComponent(name)}`,\n DeploymentSchema,\n ),\n ),\n createDeployment: Effect.fn(\"ConvexClient.createDeployment\")(\n (projectId: number, input: CreateDeploymentInput) =>\n management(\n \"createDeployment\",\n \"POST\",\n `/projects/${projectId}/create_deployment`,\n DeploymentSchema,\n input,\n ),\n ),\n updateDeployment: Effect.fn(\"ConvexClient.updateDeployment\")(\n (name: string, input: UpdateDeploymentInput) =>\n managementVoid(\n \"updateDeployment\",\n \"PATCH\",\n `/deployments/${encodeURIComponent(name)}`,\n input,\n ),\n ),\n deleteDeployment: Effect.fn(\"ConvexClient.deleteDeployment\")(\n (name: string) =>\n managementVoid(\n \"deleteDeployment\",\n \"POST\",\n `/deployments/${encodeURIComponent(name)}/delete`,\n ),\n ),\n createDeployKey: Effect.fn(\"ConvexClient.createDeployKey\")(function* (\n name: string,\n input: CreateDeployKeyInput,\n ): Effect.fn.Return<CreatedDeployKey, ConvexClientError> {\n const response = yield* management(\n \"createDeployKey\",\n \"POST\",\n `/deployments/${encodeURIComponent(name)}/create_deploy_key`,\n Schema.Struct({ deployKey: Schema.String }),\n input,\n );\n return { deployKey: Redacted.make(response.deployKey) };\n }),\n listDeployKeys: Effect.fn(\"ConvexClient.listDeployKeys\")((name: string) =>\n management(\n \"listDeployKeys\",\n \"GET\",\n `/deployments/${encodeURIComponent(name)}/list_deploy_keys`,\n Schema.Array(DeployKeySchema),\n ),\n ),\n deleteDeployKey: Effect.fn(\"ConvexClient.deleteDeployKey\")(\n (name: string, id: string | Redacted.Redacted<string>) =>\n managementVoid(\n \"deleteDeployKey\",\n \"POST\",\n `/deployments/${encodeURIComponent(name)}/delete_deploy_key`,\n {\n id: Redacted.isRedacted(id) ? Redacted.value(id) : id,\n } satisfies ManagementApi.PlatformDeleteDeployKeyArgs,\n ),\n ),\n listEnvironmentVariables: Effect.fn(\n \"ConvexClient.listEnvironmentVariables\",\n )(function* (\n url: string,\n key: Redacted.Redacted<string>,\n ): Effect.fn.Return<EnvironmentVariables, ConvexClientError> {\n const response = yield* send(\n \"listEnvironmentVariables\",\n \"GET\",\n `${yield* deploymentUrl(\"listEnvironmentVariables\", url)}/list_environment_variables`,\n Redacted.make(`Convex ${Redacted.value(key)}`),\n );\n const result = yield* decode(\n \"listEnvironmentVariables\",\n response,\n Schema.Struct({\n environmentVariables: Schema.Record(Schema.String, Schema.String),\n }),\n );\n return Rec.fromEntries(\n Array.map(\n Rec.toEntries(result.environmentVariables),\n ([name, value]) => [name, Redacted.make(value)],\n ),\n );\n }),\n updateEnvironmentVariables: Effect.fn(\n \"ConvexClient.updateEnvironmentVariables\",\n )(function* (\n url: string,\n key: Redacted.Redacted<string>,\n changes: readonly EnvironmentVariableChange[],\n ) {\n yield* send(\n \"updateEnvironmentVariables\",\n \"POST\",\n `${yield* deploymentUrl(\"updateEnvironmentVariables\", url)}/update_environment_variables`,\n Redacted.make(`Convex ${Redacted.value(key)}`),\n {\n changes: Array.map(changes, ({ name, value }) => ({\n name,\n ...(value === undefined\n ? {}\n : {\n value: Redacted.isRedacted(value)\n ? Redacted.value(value)\n : value,\n }),\n })),\n } satisfies {\n readonly changes: Readonly<\n DeploymentApi.UpdateEnvVarsRequest[\"changes\"]\n >;\n },\n );\n }),\n };\n});\n\nexport class ConvexClient extends Context.Service<\n ConvexClient,\n Effect.Success<ReturnType<typeof make>>\n>()(\"@confect/alchemy/ConvexClient\") {}\n\n/**\n * `mode: \"local\"` sends deployment requests only to a loopback backend over\n * HTTP; the default accepts only Convex cloud HTTPS origins.\n *\n * @stability unstable\n */\nexport const layer = (options?: {\n readonly token?: Redacted.Redacted<string>;\n readonly mode?: ProviderMode;\n}) =>\n Layer.effect(ConvexClient, make(options).pipe(Effect.map(ConvexClient.of)));\n"],"mappings":";;;;;;;;;;;;;;;AAmEA,MAAM,cAAc;CAClB,WAAW,OAAO;CAClB,QAAQ,OAAO,YAAY,OAAO,MAAM;CACxC,MAAM,OAAO,SAAS;EACpB;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;AACH;AAEA,IAAa,iBAAb,cAAoC,OAAO,YAGzC,CAAC,CAAC,kBAAkB,WAAW,CAAC,CAAC,CAAC;AAEpC,IAAa,iBAAb,cAAoC,OAAO,YAGzC,CAAC,CAAC,kBAAkB,WAAW,CAAC,CAAC,CAAC;AAEpC,IAAa,iBAAb,cAAoC,OAAO,YAGzC,CAAC,CAAC,kBAAkB,WAAW,CAAC,CAAC,CAAC;;;;AAKpC,IAAa,sBAAb,cAAyC,OAAO,YAG9C,CAAC,CAAC,uBAAuB;CACzB,cAAc,OAAO;CACrB,cAAc,OAAO;AACvB,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAM,mBAAmB,OAAO,MAAM,CACpC,OAAO,OAAO;CAAE,QAAQ,OAAO,QAAQ,SAAS;CAAG,OAAO,OAAO;AAAQ,CAAC,GAC1E,OAAO,OAAO;CACZ,QAAQ,OAAO,QAAQ,OAAO;CAC9B,cAAc,OAAO;AACvB,CAAC,CACH,CAAC;AAOD,MAAM,gBAAgB,OAAO,OAAO;CAClC,IAAI,OAAO;CACX,MAAM,OAAO;CACb,MAAM,OAAO;CACb,QAAQ,OAAO;CACf,UAAU,OAAO;CACjB,YAAY,OAAO;CACnB,oBAAoB,OAAO,OAAO,KAAK,OAAO,QAAQ,OAAO,WAAW;CACxE,mBAAmB,OAAO,OAAO,KAAK,OAAO,QAAQ,OAAO,WAAW;AACzE,CAAC;AAED,MAAM,uBAAuB,OAAO,OAAO;CACzC,IAAI,OAAO;CACX,WAAW,OAAO;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AC2D;GAC3D,MAAM,WAAW,OAAO,KACtB,4BACA,OACA,GAAG,OAAO,cAAc,4BAA4B,GAAG,EAAE,8BACzD,SAAS,KAAK,UAAU,SAAS,MAAM,GAAG,GAAG,CAC/C;GACA,MAAM,SAAS,OAAO,OACpB,4BACA,UACA,OAAO,OAAO,EACZ,sBAAsB,OAAO,OAAO,OAAO,QAAQ,OAAO,MAAM,EAClE,CAAC,CACH;GACA,OAAO,IAAI,YACT,MAAM,IACJ,IAAI,UAAU,OAAO,oBAAoB,IACxC,CAAC,MAAM,WAAW,CAAC,MAAM,SAAS,KAAK,KAAK,CAAC,CAChD,CACF;EACF,CAAC;EACD,4BAA4B,OAAO,GACjC,yCACF,CAAC,CAAC,WACA,KACA,KACA,SACA;GACA,OAAO,KACL,8BACA,QACA,GAAG,OAAO,cAAc,8BAA8B,GAAG,EAAE,gCAC3D,SAAS,KAAK,UAAU,SAAS,MAAM,GAAG,GAAG,GAC7C,EACE,SAAS,MAAM,IAAI,UAAU,EAAE,MAAM,aAAa;IAChD;IACA,GAAI,UAAU,KAAA,IACV,CAAC,IACD,EACE,OAAO,SAAS,WAAW,KAAK,IAC5B,SAAS,MAAM,KAAK,IACpB,MACN;GACN,EAAE,EACJ,CAKF;EACF,CAAC;CACH;AACF,CAAC;AAED,IAAa,eAAb,cAAkC,QAAQ,QAGxC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC;;;;;;;AAQtC,MAAa,SAAS,YAIpB,MAAM,OAAO,cAAc,KAAK,OAAO,CAAC,CAAC,KAAK,OAAO,IAAI,aAAa,EAAE,CAAC,CAAC"}
|
package/dist/Deployment.d.ts
CHANGED
|
@@ -13,6 +13,11 @@ export interface DeploymentProps {
|
|
|
13
13
|
readonly reference?: string;
|
|
14
14
|
readonly region?: RegionName;
|
|
15
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;
|
|
16
21
|
}
|
|
17
22
|
export interface DeploymentAttributes {
|
|
18
23
|
readonly projectId: number;
|
|
@@ -28,6 +33,10 @@ export interface DeploymentAttributes {
|
|
|
28
33
|
* Always set in the cloud; local deployments do not have a cloud class.
|
|
29
34
|
*/
|
|
30
35
|
readonly class?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Cloud expiry in milliseconds since the Unix epoch, or null when unset.
|
|
38
|
+
*/
|
|
39
|
+
readonly expiresAt?: number | null;
|
|
31
40
|
}
|
|
32
41
|
export type Deployment = Resource<"Convex.Deployment", DeploymentProps, DeploymentAttributes, never, Providers>;
|
|
33
42
|
export declare const Deployment: import("alchemy").ResourceClass<Deployment>;
|
|
@@ -56,6 +65,14 @@ declare const AmbiguousDeployment_base: Schema.Class<AmbiguousDeployment, Schema
|
|
|
56
65
|
}>;
|
|
57
66
|
export declare class AmbiguousDeployment extends AmbiguousDeployment_base {
|
|
58
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
|
+
}
|
|
59
76
|
export declare const provider: Effect.Effect<{
|
|
60
77
|
diff: (args_0: {
|
|
61
78
|
id: string;
|
|
@@ -68,7 +85,7 @@ export declare const provider: Effect.Effect<{
|
|
|
68
85
|
output: DeploymentAttributes | undefined;
|
|
69
86
|
}) => Effect.Effect<{
|
|
70
87
|
action: "update";
|
|
71
|
-
} | 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>;
|
|
72
89
|
read: (args_0: {
|
|
73
90
|
id: string;
|
|
74
91
|
fqn: string;
|
|
@@ -84,6 +101,7 @@ export declare const provider: Effect.Effect<{
|
|
|
84
101
|
url: string;
|
|
85
102
|
region: "aws-ap-southeast-2" | "aws-ca-central-1" | "aws-eu-west-1" | "aws-us-east-1";
|
|
86
103
|
class: string;
|
|
104
|
+
expiresAt: number | null;
|
|
87
105
|
} | undefined, AmbiguousDeployment | import("./ConvexClient.js").ConvexApiError | import("./ConvexClient.js").ConvexConflict | import("./ConvexClient.js").ConvexNotFound | UnsupportedLocalDeployment, never>;
|
|
88
106
|
reconcile: (args_0: {
|
|
89
107
|
id: string;
|
|
@@ -102,7 +120,8 @@ export declare const provider: Effect.Effect<{
|
|
|
102
120
|
url: string;
|
|
103
121
|
region: "aws-ap-southeast-2" | "aws-ca-central-1" | "aws-eu-west-1" | "aws-us-east-1";
|
|
104
122
|
class: string;
|
|
105
|
-
|
|
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>;
|
|
106
125
|
delete: (args_0: {
|
|
107
126
|
id: string;
|
|
108
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,EACpB,eAAe,EAEf,UAAU,EACX,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,kBAAk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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA0KnB,CAAC;AAOH;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,sYAqDtB,CAAC;AAEF,eAAO,MAAM,KAAK,kFAAwC,CAAC"}
|
package/dist/Deployment.js
CHANGED
|
@@ -25,6 +25,14 @@ var AmbiguousDeployment = class extends Schema.TaggedError()("AmbiguousDeploymen
|
|
|
25
25
|
projectId: Schema.Finite,
|
|
26
26
|
reference: Schema.String
|
|
27
27
|
}) {};
|
|
28
|
+
var InvalidDeploymentExpiry = class extends Schema.TaggedError()("InvalidDeploymentExpiry", { requested: Schema.String }) {
|
|
29
|
+
get message() {
|
|
30
|
+
return "Deployment expiresAt must be a safe integer timestamp in milliseconds, or null to clear the expiry.";
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const validateExpiry = Effect.fn("Deployment.validateExpiry")(function* ({ expiresAt }) {
|
|
34
|
+
if (expiresAt != null && !Number.isSafeInteger(expiresAt)) return yield* InvalidDeploymentExpiry.make({ requested: String(expiresAt) });
|
|
35
|
+
});
|
|
28
36
|
const provider = Effect.gen(function* () {
|
|
29
37
|
const client = yield* ConvexClient;
|
|
30
38
|
const attributes = Effect.fn("Deployment.attributes")(function* (deployment) {
|
|
@@ -36,7 +44,8 @@ const provider = Effect.gen(function* () {
|
|
|
36
44
|
type: deployment.deploymentType,
|
|
37
45
|
url: deployment.deploymentUrl,
|
|
38
46
|
region: deployment.region,
|
|
39
|
-
class: deployment.class
|
|
47
|
+
class: deployment.class,
|
|
48
|
+
expiresAt: deployment.expiresAt ?? null
|
|
40
49
|
};
|
|
41
50
|
});
|
|
42
51
|
const find = Effect.fn("Deployment.find")(function* (projectId, reference) {
|
|
@@ -62,13 +71,16 @@ const provider = Effect.gen(function* () {
|
|
|
62
71
|
});
|
|
63
72
|
return {
|
|
64
73
|
diff: Effect.fn("Deployment.diff")(function* ({ news, output }) {
|
|
65
|
-
if (!isResolved(news)
|
|
74
|
+
if (!isResolved(news)) return;
|
|
75
|
+
yield* validateExpiry(news);
|
|
76
|
+
if (output === void 0) return;
|
|
77
|
+
const expiresAt = news.expiresAt;
|
|
66
78
|
yield* validate(output, news);
|
|
67
79
|
const deployment = yield* client.getDeployment(output.name).pipe(Effect.catchTag("ConvexNotFound", () => Effect.void));
|
|
68
80
|
if (deployment === void 0) return { action: "update" };
|
|
69
81
|
const current = yield* attributes(deployment);
|
|
70
82
|
yield* validate(current, news);
|
|
71
|
-
if ((news.reference ?? output.reference) !== current.reference || news.class !== void 0 && news.class !== current.class) return { action: "update" };
|
|
83
|
+
if ((news.reference ?? output.reference) !== current.reference || news.class !== void 0 && news.class !== current.class || expiresAt !== void 0 && expiresAt !== (current.expiresAt ?? null)) return { action: "update" };
|
|
72
84
|
}),
|
|
73
85
|
read: Effect.fn("Deployment.read")(function* ({ fqn, instanceId, olds, output }) {
|
|
74
86
|
if (output !== void 0) {
|
|
@@ -80,10 +92,12 @@ const provider = Effect.gen(function* () {
|
|
|
80
92
|
return deployment !== void 0 ? yield* Effect.map(attributes(deployment), Unowned) : void 0;
|
|
81
93
|
}),
|
|
82
94
|
reconcile: Effect.fn("Deployment.reconcile")(function* ({ fqn, instanceId, news, output }) {
|
|
95
|
+
yield* validateExpiry(news);
|
|
83
96
|
if (output === void 0) yield* checkpointCreate(fqn, instanceId, news);
|
|
84
97
|
if (output !== void 0) yield* validate(output, news);
|
|
85
98
|
let deployment = output !== void 0 ? yield* client.getDeployment(output.name).pipe(Effect.catchTag("ConvexNotFound", () => Effect.void)) : void 0;
|
|
86
99
|
const reference = news.reference ?? output?.reference ?? (yield* resourceName("deployment", fqn, instanceId));
|
|
100
|
+
const expiresAt = news.expiresAt;
|
|
87
101
|
if (deployment === void 0) {
|
|
88
102
|
const existing = yield* find(news.projectId, reference);
|
|
89
103
|
if (existing !== void 0 && !(yield* shouldAdopt(fqn))) return yield* new OwnedBySomeoneElse({
|
|
@@ -100,12 +114,13 @@ const provider = Effect.gen(function* () {
|
|
|
100
114
|
type: news.type,
|
|
101
115
|
reference,
|
|
102
116
|
...news.region === void 0 ? {} : { region: news.region },
|
|
103
|
-
...news.class === void 0 ? {} : { class: news.class }
|
|
117
|
+
...news.class === void 0 ? {} : { class: news.class },
|
|
118
|
+
...expiresAt === void 0 ? {} : { expiresAt }
|
|
104
119
|
});
|
|
105
120
|
}
|
|
106
121
|
const current = yield* attributes(deployment);
|
|
107
122
|
yield* validate(current, news);
|
|
108
|
-
if (current.reference !== reference || news.class !== void 0 && news.class !== current.class) {
|
|
123
|
+
if (current.reference !== reference || news.class !== void 0 && news.class !== current.class || expiresAt !== void 0 && expiresAt !== (current.expiresAt ?? null)) {
|
|
109
124
|
if (current.reference !== reference) {
|
|
110
125
|
const existing = yield* find(news.projectId, reference);
|
|
111
126
|
if (existing !== void 0 && existing.name !== current.name) return yield* new OwnedBySomeoneElse({
|
|
@@ -116,7 +131,8 @@ const provider = Effect.gen(function* () {
|
|
|
116
131
|
}
|
|
117
132
|
yield* client.updateDeployment(current.name, {
|
|
118
133
|
reference,
|
|
119
|
-
...news.class === void 0 || news.class === current.class ? {} : { class: news.class }
|
|
134
|
+
...news.class === void 0 || news.class === current.class ? {} : { class: news.class },
|
|
135
|
+
...expiresAt === void 0 || expiresAt === (current.expiresAt ?? null) ? {} : { expiresAt }
|
|
120
136
|
});
|
|
121
137
|
deployment = yield* client.getDeployment(current.name);
|
|
122
138
|
}
|
|
@@ -141,7 +157,7 @@ const localLayer = LocalProvider.make(Deployment, new URL(`./internal/LocalSidec
|
|
|
141
157
|
const directory = yield* dataDirectories;
|
|
142
158
|
return {
|
|
143
159
|
resolveConfig: Effect.fn("Deployment.localConfig")(function* ({ fqn, instanceId, news }) {
|
|
144
|
-
const { class: _class, ...props } = news;
|
|
160
|
+
const { class: _class, expiresAt: _expiresAt, ...props } = news;
|
|
145
161
|
return {
|
|
146
162
|
name: yield* resourceName("deployment", fqn, instanceId),
|
|
147
163
|
props
|
|
@@ -166,6 +182,6 @@ const localLayer = LocalProvider.make(Deployment, new URL(`./internal/LocalSidec
|
|
|
166
182
|
};
|
|
167
183
|
}));
|
|
168
184
|
const layer = Provider.effect(Deployment, provider);
|
|
169
|
-
export { AmbiguousDeployment, Deployment, DeploymentIdentityChange, UnsupportedLocalDeployment, layer, localLayer, provider };
|
|
185
|
+
export { AmbiguousDeployment, Deployment, DeploymentIdentityChange, InvalidDeploymentExpiry, UnsupportedLocalDeployment, layer, localLayer, provider };
|
|
170
186
|
|
|
171
187
|
//# sourceMappingURL=Deployment.js.map
|
package/dist/Deployment.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Deployment.js","names":[],"sources":["../src/Deployment.ts"],"sourcesContent":["import type {\n CreateDeploymentType,\n DeploymentClass,\n PlatformDeploymentResponse,\n RegionName,\n} from \"@convex-dev/platform/managementApi\";\nimport { OwnedBySomeoneElse, Unowned } from \"alchemy/AdoptPolicy\";\nimport { isResolved } from \"alchemy/Diff\";\nimport * as LocalProvider from \"alchemy/Local/LocalProvider\";\nimport * as Provider from \"alchemy/Provider\";\nimport { Resource } from \"alchemy/Resource\";\nimport { moduleExtension } from \"alchemy/Util/Node\";\nimport * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Schema from \"effect/Schema\";\n\nimport { ConvexClient } from \"./ConvexClient.js\";\nimport type { Providers } from \"./Providers.js\";\nimport { resourceName } from \"./internal/ResourceIdentity.js\";\nimport { checkpointCreate, shouldAdopt } from \"./internal/Lifecycle.js\";\nimport { boot, dataDirectories, remove } from \"./internal/LocalBackend.js\";\nimport * as Array from \"effect/Array\";\n\nexport interface DeploymentProps {\n readonly projectId: number;\n readonly type: CreateDeploymentType;\n readonly reference?: string;\n readonly region?: RegionName;\n readonly class?: DeploymentClass;\n}\n\nexport interface DeploymentAttributes {\n readonly projectId: number;\n readonly name: string;\n readonly reference: string;\n readonly type: CreateDeploymentType;\n readonly url: string;\n /**\n * Always set in the cloud; a local deployment echoes the requested region.\n */\n readonly region?: RegionName;\n /**\n * Always set in the cloud; local deployments do not have a cloud class.\n */\n readonly class?: string;\n}\n\nexport type Deployment = Resource<\n \"Convex.Deployment\",\n DeploymentProps,\n DeploymentAttributes,\n never,\n Providers\n>;\nexport const Deployment = Resource<Deployment>(\"Convex.Deployment\", {\n defaultRemovalPolicy: \"retain\",\n});\n\nexport class DeploymentIdentityChange extends Schema.TaggedError<\n DeploymentIdentityChange,\n { readonly brand: unique symbol }\n>()(\"DeploymentIdentityChange\", {\n deploymentName: Schema.String,\n field: Schema.String,\n current: Schema.String,\n requested: Schema.String,\n}) {}\n\nexport class UnsupportedLocalDeployment extends Schema.TaggedError<\n UnsupportedLocalDeployment,\n { readonly brand: unique symbol }\n>()(\"UnsupportedLocalDeployment\", { deploymentName: Schema.String }) {}\n\nexport class AmbiguousDeployment extends Schema.TaggedError<\n AmbiguousDeployment,\n { readonly brand: unique symbol }\n>()(\"AmbiguousDeployment\", {\n projectId: Schema.Finite,\n reference: Schema.String,\n}) {}\n\nexport const provider = Effect.gen(function* () {\n const client = yield* ConvexClient;\n const attributes = Effect.fn(\"Deployment.attributes\")(function* (\n deployment: PlatformDeploymentResponse,\n ) {\n if (deployment.kind !== \"cloud\")\n return yield* UnsupportedLocalDeployment.make({\n deploymentName: deployment.name,\n });\n return {\n projectId: deployment.projectId,\n name: deployment.name,\n reference: deployment.reference,\n type: deployment.deploymentType,\n url: deployment.deploymentUrl,\n region: deployment.region,\n class: deployment.class,\n } satisfies DeploymentAttributes;\n });\n const find = Effect.fn(\"Deployment.find\")(function* (\n projectId: number,\n reference: string,\n ) {\n const deployments = yield* client.listDeployments(projectId);\n const matches = Array.filter(\n deployments,\n (deployment) =>\n deployment.kind === \"cloud\" && deployment.reference === reference,\n );\n if (matches.length > 1)\n return yield* AmbiguousDeployment.make({ projectId, reference });\n return matches[0];\n });\n const validate = Effect.fn(\"Deployment.validate\")(function* (\n current: DeploymentAttributes,\n news: DeploymentProps,\n ) {\n for (const field of [\"projectId\", \"type\", \"region\"] as const) {\n if (news[field] !== undefined && current[field] !== news[field])\n return yield* DeploymentIdentityChange.make({\n deploymentName: current.name,\n field,\n current: String(current[field]),\n requested: String(news[field]),\n });\n }\n });\n return {\n diff: Effect.fn(\"Deployment.diff\")(function* ({ news, output }) {\n if (!isResolved(news) || output === undefined) return;\n yield* validate(output, news);\n const deployment = yield* client\n .getDeployment(output.name)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void));\n if (deployment === undefined) return { action: \"update\" };\n const current = yield* attributes(deployment);\n yield* validate(current, news);\n if (\n (news.reference ?? output.reference) !== current.reference ||\n (news.class !== undefined && news.class !== current.class)\n )\n return { action: \"update\" };\n }),\n read: Effect.fn(\"Deployment.read\")(function* ({\n fqn,\n instanceId,\n olds,\n output,\n }) {\n if (output !== undefined) {\n const deployment = yield* client\n .getDeployment(output.name)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void));\n return deployment !== undefined\n ? yield* attributes(deployment)\n : undefined;\n }\n if (olds.projectId === undefined) return;\n const deployment = yield* find(\n olds.projectId,\n olds.reference ?? (yield* resourceName(\"deployment\", fqn, instanceId)),\n );\n return deployment !== undefined\n ? yield* Effect.map(attributes(deployment), Unowned)\n : undefined;\n }),\n reconcile: Effect.fn(\"Deployment.reconcile\")(function* ({\n fqn,\n instanceId,\n news,\n output,\n }) {\n if (output === undefined) yield* checkpointCreate(fqn, instanceId, news);\n if (output !== undefined) yield* validate(output, news);\n let deployment =\n output !== undefined\n ? yield* client\n .getDeployment(output.name)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void))\n : undefined;\n const reference =\n news.reference ??\n output?.reference ??\n (yield* resourceName(\"deployment\", fqn, instanceId));\n if (deployment === undefined) {\n const existing = yield* find(news.projectId, reference);\n if (existing !== undefined && !(yield* shouldAdopt(fqn)))\n return yield* new OwnedBySomeoneElse({\n message: \"An existing deployment requires explicit adoption.\",\n resourceType: Deployment.Type,\n physicalName: reference,\n });\n if (existing !== undefined) {\n const adopted = yield* attributes(existing);\n yield* validate(adopted, news);\n yield* checkpointCreate(fqn, instanceId, news, adopted);\n deployment = existing;\n } else {\n deployment = yield* client.createDeployment(news.projectId, {\n type: news.type,\n reference,\n ...(news.region === undefined ? {} : { region: news.region }),\n ...(news.class === undefined ? {} : { class: news.class }),\n });\n }\n }\n const current = yield* attributes(deployment);\n yield* validate(current, news);\n if (\n current.reference !== reference ||\n (news.class !== undefined && news.class !== current.class)\n ) {\n if (current.reference !== reference) {\n const existing = yield* find(news.projectId, reference);\n if (existing !== undefined && existing.name !== current.name)\n return yield* new OwnedBySomeoneElse({\n message: \"The requested deployment reference is already in use.\",\n resourceType: Deployment.Type,\n physicalName: reference,\n });\n }\n yield* client.updateDeployment(current.name, {\n reference,\n ...(news.class === undefined || news.class === current.class\n ? {}\n : { class: news.class }),\n });\n deployment = yield* client.getDeployment(current.name);\n }\n return yield* attributes(deployment);\n }),\n delete: Effect.fn(\"Deployment.delete\")(function* ({ output }) {\n yield* client\n .deleteDeployment(output.name)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void));\n }),\n } satisfies Provider.ProviderServiceInput<Deployment>;\n});\n\ninterface LocalConfig {\n readonly name: string;\n readonly props: Omit<DeploymentProps, \"class\">;\n}\n\n/**\n * Under `alchemy dev` a deployment is a local Convex backend this provider\n * owns. Alchemy's dev sidecar hosts it, so the backend keeps running across\n * reloads of the stack and stops when the dev session ends. Its data lives in\n * `.alchemy/convex/<stack>/<stage>/<name>` and is removed only when the\n * deployment is destroyed.\n *\n * @stability unstable\n */\nexport const localLayer = LocalProvider.make(\n Deployment,\n new URL(\n `./internal/LocalSidecar${moduleExtension(import.meta.url)}`,\n import.meta.url,\n ).href,\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const directory = yield* dataDirectories;\n return {\n resolveConfig: Effect.fn(\"Deployment.localConfig\")(function* ({\n fqn,\n instanceId,\n news,\n }) {\n const { class: _class, ...props } = news;\n return {\n name: yield* resourceName(\"deployment\", fqn, instanceId),\n props,\n } satisfies LocalConfig;\n }),\n start: Effect.fn(\"Deployment.localStart\")(function* ({\n config,\n invalidate,\n }) {\n const backend = yield* boot(config.name, directory(config.name));\n yield* backend.exited.pipe(\n Effect.andThen(invalidate),\n Effect.forkScoped,\n );\n return {\n projectId: config.props.projectId,\n name: config.name,\n reference: config.props.reference ?? config.name,\n type: config.props.type,\n url: backend.url,\n ...(config.props.region === undefined\n ? {}\n : { region: config.props.region }),\n } satisfies DeploymentAttributes;\n }),\n stop: Effect.fn(\"Deployment.localStop\")(function* ({ fqn, instanceId }) {\n const name = yield* resourceName(\"deployment\", fqn, instanceId);\n yield* remove(name, directory(name)).pipe(\n Effect.provideService(FileSystem.FileSystem, fs),\n );\n }),\n } satisfies LocalProvider.LocalProviderSpec<\n Deployment,\n LocalConfig,\n Effect.Services<ReturnType<typeof boot>>\n >;\n }),\n);\n\nexport const layer = Provider.effect(Deployment, provider);\n"],"mappings":";;;;;;;;;;;;;;;AAsDA,MAAa,aAAa,SAAqB,qBAAqB,EAClE,sBAAsB,SACxB,CAAC;AAED,IAAa,2BAAb,cAA8C,OAAO,YAGnD,CAAC,CAAC,4BAA4B;CAC9B,gBAAgB,OAAO;CACvB,OAAO,OAAO;CACd,SAAS,OAAO;CAChB,WAAW,OAAO;AACpB,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,6BAAb,cAAgD,OAAO,YAGrD,CAAC,CAAC,8BAA8B,EAAE,gBAAgB,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AAEtE,IAAa,sBAAb,cAAyC,OAAO,YAG9C,CAAC,CAAC,uBAAuB;CACzB,WAAW,OAAO;CAClB,WAAW,OAAO;AACpB,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAa,WAAW,OAAO,IAAI,aAAa;CAC9C,MAAM,SAAS,OAAO;CACtB,MAAM,aAAa,OAAO,GAAG,uBAAuB,CAAC,CAAC,WACpD,YACA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;;;;;;;;;;AAgBD,MAAa,aAAa,cAAc,KACtC,YACA,IAAI,IACF,0BAA0B,gBAAgB,YAAY,GAAG,KACzD,YAAY,GACd,CAAC,CAAC,MACF,OAAO,IAAI,aAAa;CACtB,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,YAAY,OAAO;CACzB,OAAO;EACL,eAAe,OAAO,GAAG,wBAAwB,CAAC,CAAC,WAAW,EAC5D,KACA,YACA,QACC;GACD,MAAM,EAAE,OAAO,QAAQ,GAAG,UAAU;GACpC,OAAO;IACL,MAAM,OAAO,aAAa,cAAc,KAAK,UAAU;IACvD;GACF;EACF,CAAC;EACD,OAAO,OAAO,GAAG,uBAAuB,CAAC,CAAC,WAAW,EACnD,QACA,cACC;GACD,MAAM,UAAU,OAAO,KAAK,OAAO,MAAM,UAAU,OAAO,IAAI,CAAC;GAC/D,OAAO,QAAQ,OAAO,KACpB,OAAO,QAAQ,UAAU,GACzB,OAAO,UACT;GACA,OAAO;IACL,WAAW,OAAO,MAAM;IACxB,MAAM,OAAO;IACb,WAAW,OAAO,MAAM,aAAa,OAAO;IAC5C,MAAM,OAAO,MAAM;IACnB,KAAK,QAAQ;IACb,GAAI,OAAO,MAAM,WAAW,KAAA,IACxB,CAAC,IACD,EAAE,QAAQ,OAAO,MAAM,OAAO;GACpC;EACF,CAAC;EACD,MAAM,OAAO,GAAG,sBAAsB,CAAC,CAAC,WAAW,EAAE,KAAK,cAAc;GACtE,MAAM,OAAO,OAAO,aAAa,cAAc,KAAK,UAAU;GAC9D,OAAO,OAAO,MAAM,UAAU,IAAI,CAAC,CAAC,CAAC,KACnC,OAAO,eAAe,WAAW,YAAY,EAAE,CACjD;EACF,CAAC;CACH;AAKF,CAAC,CACH;AAEA,MAAa,QAAQ,SAAS,OAAO,YAAY,QAAQ"}
|
|
1
|
+
{"version":3,"file":"Deployment.js","names":[],"sources":["../src/Deployment.ts"],"sourcesContent":["import type {\n CreateDeploymentType,\n DeploymentClass,\n PlatformDeploymentResponse,\n RegionName,\n} from \"@convex-dev/platform/managementApi\";\nimport { OwnedBySomeoneElse, Unowned } from \"alchemy/AdoptPolicy\";\nimport { isResolved } from \"alchemy/Diff\";\nimport * as LocalProvider from \"alchemy/Local/LocalProvider\";\nimport * as Provider from \"alchemy/Provider\";\nimport { Resource } from \"alchemy/Resource\";\nimport { moduleExtension } from \"alchemy/Util/Node\";\nimport * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Schema from \"effect/Schema\";\n\nimport { ConvexClient } from \"./ConvexClient.js\";\nimport type { Providers } from \"./Providers.js\";\nimport { resourceName } from \"./internal/ResourceIdentity.js\";\nimport { checkpointCreate, shouldAdopt } from \"./internal/Lifecycle.js\";\nimport { boot, dataDirectories, remove } from \"./internal/LocalBackend.js\";\nimport * as Array from \"effect/Array\";\n\nexport interface DeploymentProps {\n readonly projectId: number;\n readonly type: CreateDeploymentType;\n readonly reference?: string;\n readonly region?: RegionName;\n readonly class?: DeploymentClass;\n /**\n * Safe integer milliseconds since the Unix epoch. Omit to preserve the\n * current cloud expiry; only null clears it.\n */\n readonly expiresAt?: number | null;\n}\n\nexport interface DeploymentAttributes {\n readonly projectId: number;\n readonly name: string;\n readonly reference: string;\n readonly type: CreateDeploymentType;\n readonly url: string;\n /**\n * Always set in the cloud; a local deployment echoes the requested region.\n */\n readonly region?: RegionName;\n /**\n * Always set in the cloud; local deployments do not have a cloud class.\n */\n readonly class?: string;\n /**\n * Cloud expiry in milliseconds since the Unix epoch, or null when unset.\n */\n readonly expiresAt?: number | null;\n}\n\nexport type Deployment = Resource<\n \"Convex.Deployment\",\n DeploymentProps,\n DeploymentAttributes,\n never,\n Providers\n>;\nexport const Deployment = Resource<Deployment>(\"Convex.Deployment\", {\n defaultRemovalPolicy: \"retain\",\n});\n\nexport class DeploymentIdentityChange extends Schema.TaggedError<\n DeploymentIdentityChange,\n { readonly brand: unique symbol }\n>()(\"DeploymentIdentityChange\", {\n deploymentName: Schema.String,\n field: Schema.String,\n current: Schema.String,\n requested: Schema.String,\n}) {}\n\nexport class UnsupportedLocalDeployment extends Schema.TaggedError<\n UnsupportedLocalDeployment,\n { readonly brand: unique symbol }\n>()(\"UnsupportedLocalDeployment\", { deploymentName: Schema.String }) {}\n\nexport class AmbiguousDeployment extends Schema.TaggedError<\n AmbiguousDeployment,\n { readonly brand: unique symbol }\n>()(\"AmbiguousDeployment\", {\n projectId: Schema.Finite,\n reference: Schema.String,\n}) {}\n\nexport class InvalidDeploymentExpiry extends Schema.TaggedError<\n InvalidDeploymentExpiry,\n { readonly brand: unique symbol }\n>()(\"InvalidDeploymentExpiry\", {\n requested: Schema.String,\n}) {\n override get message() {\n return \"Deployment expiresAt must be a safe integer timestamp in milliseconds, or null to clear the expiry.\";\n }\n}\n\nconst validateExpiry = Effect.fn(\"Deployment.validateExpiry\")(function* ({\n expiresAt,\n}: DeploymentProps) {\n if (expiresAt != null && !Number.isSafeInteger(expiresAt))\n return yield* InvalidDeploymentExpiry.make({\n requested: String(expiresAt),\n });\n});\n\nexport const provider = Effect.gen(function* () {\n const client = yield* ConvexClient;\n const attributes = Effect.fn(\"Deployment.attributes\")(function* (\n deployment: PlatformDeploymentResponse,\n ) {\n if (deployment.kind !== \"cloud\")\n return yield* UnsupportedLocalDeployment.make({\n deploymentName: deployment.name,\n });\n return {\n projectId: deployment.projectId,\n name: deployment.name,\n reference: deployment.reference,\n type: deployment.deploymentType,\n url: deployment.deploymentUrl,\n region: deployment.region,\n class: deployment.class,\n expiresAt: deployment.expiresAt ?? null,\n } satisfies DeploymentAttributes;\n });\n const find = Effect.fn(\"Deployment.find\")(function* (\n projectId: number,\n reference: string,\n ) {\n const deployments = yield* client.listDeployments(projectId);\n const matches = Array.filter(\n deployments,\n (deployment) =>\n deployment.kind === \"cloud\" && deployment.reference === reference,\n );\n if (matches.length > 1)\n return yield* AmbiguousDeployment.make({ projectId, reference });\n return matches[0];\n });\n const validate = Effect.fn(\"Deployment.validate\")(function* (\n current: DeploymentAttributes,\n news: DeploymentProps,\n ) {\n for (const field of [\"projectId\", \"type\", \"region\"] as const) {\n if (news[field] !== undefined && current[field] !== news[field])\n return yield* DeploymentIdentityChange.make({\n deploymentName: current.name,\n field,\n current: String(current[field]),\n requested: String(news[field]),\n });\n }\n });\n return {\n diff: Effect.fn(\"Deployment.diff\")(function* ({ news, output }) {\n if (!isResolved(news)) return;\n yield* validateExpiry(news);\n if (output === undefined) return;\n const expiresAt = news.expiresAt;\n yield* validate(output, news);\n const deployment = yield* client\n .getDeployment(output.name)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void));\n if (deployment === undefined) return { action: \"update\" };\n const current = yield* attributes(deployment);\n yield* validate(current, news);\n if (\n (news.reference ?? output.reference) !== current.reference ||\n (news.class !== undefined && news.class !== current.class) ||\n (expiresAt !== undefined && expiresAt !== (current.expiresAt ?? null))\n )\n return { action: \"update\" };\n }),\n read: Effect.fn(\"Deployment.read\")(function* ({\n fqn,\n instanceId,\n olds,\n output,\n }) {\n if (output !== undefined) {\n const deployment = yield* client\n .getDeployment(output.name)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void));\n return deployment !== undefined\n ? yield* attributes(deployment)\n : undefined;\n }\n if (olds.projectId === undefined) return;\n const deployment = yield* find(\n olds.projectId,\n olds.reference ?? (yield* resourceName(\"deployment\", fqn, instanceId)),\n );\n return deployment !== undefined\n ? yield* Effect.map(attributes(deployment), Unowned)\n : undefined;\n }),\n reconcile: Effect.fn(\"Deployment.reconcile\")(function* ({\n fqn,\n instanceId,\n news,\n output,\n }) {\n yield* validateExpiry(news);\n if (output === undefined) yield* checkpointCreate(fqn, instanceId, news);\n if (output !== undefined) yield* validate(output, news);\n let deployment =\n output !== undefined\n ? yield* client\n .getDeployment(output.name)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void))\n : undefined;\n const reference =\n news.reference ??\n output?.reference ??\n (yield* resourceName(\"deployment\", fqn, instanceId));\n const expiresAt = news.expiresAt;\n if (deployment === undefined) {\n const existing = yield* find(news.projectId, reference);\n if (existing !== undefined && !(yield* shouldAdopt(fqn)))\n return yield* new OwnedBySomeoneElse({\n message: \"An existing deployment requires explicit adoption.\",\n resourceType: Deployment.Type,\n physicalName: reference,\n });\n if (existing !== undefined) {\n const adopted = yield* attributes(existing);\n yield* validate(adopted, news);\n yield* checkpointCreate(fqn, instanceId, news, adopted);\n deployment = existing;\n } else {\n deployment = yield* client.createDeployment(news.projectId, {\n type: news.type,\n reference,\n ...(news.region === undefined ? {} : { region: news.region }),\n ...(news.class === undefined ? {} : { class: news.class }),\n ...(expiresAt === undefined ? {} : { expiresAt }),\n });\n }\n }\n const current = yield* attributes(deployment);\n yield* validate(current, news);\n if (\n current.reference !== reference ||\n (news.class !== undefined && news.class !== current.class) ||\n (expiresAt !== undefined && expiresAt !== (current.expiresAt ?? null))\n ) {\n if (current.reference !== reference) {\n const existing = yield* find(news.projectId, reference);\n if (existing !== undefined && existing.name !== current.name)\n return yield* new OwnedBySomeoneElse({\n message: \"The requested deployment reference is already in use.\",\n resourceType: Deployment.Type,\n physicalName: reference,\n });\n }\n yield* client.updateDeployment(current.name, {\n reference,\n ...(news.class === undefined || news.class === current.class\n ? {}\n : { class: news.class }),\n ...(expiresAt === undefined ||\n expiresAt === (current.expiresAt ?? null)\n ? {}\n : { expiresAt }),\n });\n deployment = yield* client.getDeployment(current.name);\n }\n return yield* attributes(deployment);\n }),\n delete: Effect.fn(\"Deployment.delete\")(function* ({ output }) {\n yield* client\n .deleteDeployment(output.name)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void));\n }),\n } satisfies Provider.ProviderServiceInput<Deployment>;\n});\n\ninterface LocalConfig {\n readonly name: string;\n readonly props: Omit<DeploymentProps, \"class\" | \"expiresAt\">;\n}\n\n/**\n * Under `alchemy dev` a deployment is a local Convex backend this provider\n * owns. Alchemy's dev sidecar hosts it, so the backend keeps running across\n * reloads of the stack and stops when the dev session ends. Its data lives in\n * `.alchemy/convex/<stack>/<stage>/<name>` and is removed only when the\n * deployment is destroyed.\n *\n * @stability unstable\n */\nexport const localLayer = LocalProvider.make(\n Deployment,\n new URL(\n `./internal/LocalSidecar${moduleExtension(import.meta.url)}`,\n import.meta.url,\n ).href,\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const directory = yield* dataDirectories;\n return {\n resolveConfig: Effect.fn(\"Deployment.localConfig\")(function* ({\n fqn,\n instanceId,\n news,\n }) {\n const { class: _class, expiresAt: _expiresAt, ...props } = news;\n return {\n name: yield* resourceName(\"deployment\", fqn, instanceId),\n props,\n } satisfies LocalConfig;\n }),\n start: Effect.fn(\"Deployment.localStart\")(function* ({\n config,\n invalidate,\n }) {\n const backend = yield* boot(config.name, directory(config.name));\n yield* backend.exited.pipe(\n Effect.andThen(invalidate),\n Effect.forkScoped,\n );\n return {\n projectId: config.props.projectId,\n name: config.name,\n reference: config.props.reference ?? config.name,\n type: config.props.type,\n url: backend.url,\n ...(config.props.region === undefined\n ? {}\n : { region: config.props.region }),\n } satisfies DeploymentAttributes;\n }),\n stop: Effect.fn(\"Deployment.localStop\")(function* ({ fqn, instanceId }) {\n const name = yield* resourceName(\"deployment\", fqn, instanceId);\n yield* remove(name, directory(name)).pipe(\n Effect.provideService(FileSystem.FileSystem, fs),\n );\n }),\n } satisfies LocalProvider.LocalProviderSpec<\n Deployment,\n LocalConfig,\n Effect.Services<ReturnType<typeof boot>>\n >;\n }),\n);\n\nexport const layer = Provider.effect(Deployment, provider);\n"],"mappings":";;;;;;;;;;;;;;;AA+DA,MAAa,aAAa,SAAqB,qBAAqB,EAClE,sBAAsB,SACxB,CAAC;AAED,IAAa,2BAAb,cAA8C,OAAO,YAGnD,CAAC,CAAC,4BAA4B;CAC9B,gBAAgB,OAAO;CACvB,OAAO,OAAO;CACd,SAAS,OAAO;CAChB,WAAW,OAAO;AACpB,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,6BAAb,cAAgD,OAAO,YAGrD,CAAC,CA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AG,wBAAwB,CAAC,CAAC,WAAW,EAC5D,KACA,YACA,QACC;GACD,MAAM,EAAE,OAAO,QAAQ,WAAW,YAAY,GAAG,UAAU;GAC3D,OAAO;IACL,MAAM,OAAO,aAAa,cAAc,KAAK,UAAU;IACvD;GACF;EACF,CAAC;EACD,OAAO,OAAO,GAAG,uBAAuB,CAAC,CAAC,WAAW,EACnD,QACA,cACC;GACD,MAAM,UAAU,OAAO,KAAK,OAAO,MAAM,UAAU,OAAO,IAAI,CAAC;GAC/D,OAAO,QAAQ,OAAO,KACpB,OAAO,QAAQ,UAAU,GACzB,OAAO,UACT;GACA,OAAO;IACL,WAAW,OAAO,MAAM;IACxB,MAAM,OAAO;IACb,WAAW,OAAO,MAAM,aAAa,OAAO;IAC5C,MAAM,OAAO,MAAM;IACnB,KAAK,QAAQ;IACb,GAAI,OAAO,MAAM,WAAW,KAAA,IACxB,CAAC,IACD,EAAE,QAAQ,OAAO,MAAM,OAAO;GACpC;EACF,CAAC;EACD,MAAM,OAAO,GAAG,sBAAsB,CAAC,CAAC,WAAW,EAAE,KAAK,cAAc;GACtE,MAAM,OAAO,OAAO,aAAa,cAAc,KAAK,UAAU;GAC9D,OAAO,OAAO,MAAM,UAAU,IAAI,CAAC,CAAC,CAAC,KACnC,OAAO,eAAe,WAAW,YAAY,EAAE,CACjD;EACF,CAAC;CACH;AAKF,CAAC,CACH;AAEA,MAAa,QAAQ,SAAS,OAAO,YAAY,QAAQ"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gaganref/confect-alchemy",
|
|
3
|
-
"version": "10.6.0-fork.
|
|
3
|
+
"version": "10.6.0-fork.18",
|
|
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.18",
|
|
9
|
+
"@confect/core": "npm:@gaganref/confect-core@10.6.0-fork.18",
|
|
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/ConvexClient.ts
CHANGED
|
@@ -36,7 +36,7 @@ export type UpdateProjectInput = Pick<
|
|
|
36
36
|
>;
|
|
37
37
|
export type CreateDeploymentInput = Pick<
|
|
38
38
|
ManagementApi.PlatformCreateDeploymentArgs,
|
|
39
|
-
"type" | "region" | "class"
|
|
39
|
+
"type" | "region" | "class" | "expiresAt"
|
|
40
40
|
> & { readonly reference: string };
|
|
41
41
|
export type UpdateDeploymentInput = Pick<
|
|
42
42
|
ManagementApi.PlatformUpdateDeploymentArgs,
|
package/src/Deployment.ts
CHANGED
|
@@ -27,6 +27,11 @@ export interface DeploymentProps {
|
|
|
27
27
|
readonly reference?: string;
|
|
28
28
|
readonly region?: RegionName;
|
|
29
29
|
readonly class?: DeploymentClass;
|
|
30
|
+
/**
|
|
31
|
+
* Safe integer milliseconds since the Unix epoch. Omit to preserve the
|
|
32
|
+
* current cloud expiry; only null clears it.
|
|
33
|
+
*/
|
|
34
|
+
readonly expiresAt?: number | null;
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
export interface DeploymentAttributes {
|
|
@@ -43,6 +48,10 @@ export interface DeploymentAttributes {
|
|
|
43
48
|
* Always set in the cloud; local deployments do not have a cloud class.
|
|
44
49
|
*/
|
|
45
50
|
readonly class?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Cloud expiry in milliseconds since the Unix epoch, or null when unset.
|
|
53
|
+
*/
|
|
54
|
+
readonly expiresAt?: number | null;
|
|
46
55
|
}
|
|
47
56
|
|
|
48
57
|
export type Deployment = Resource<
|
|
@@ -79,6 +88,26 @@ export class AmbiguousDeployment extends Schema.TaggedError<
|
|
|
79
88
|
reference: Schema.String,
|
|
80
89
|
}) {}
|
|
81
90
|
|
|
91
|
+
export class InvalidDeploymentExpiry extends Schema.TaggedError<
|
|
92
|
+
InvalidDeploymentExpiry,
|
|
93
|
+
{ readonly brand: unique symbol }
|
|
94
|
+
>()("InvalidDeploymentExpiry", {
|
|
95
|
+
requested: Schema.String,
|
|
96
|
+
}) {
|
|
97
|
+
override get message() {
|
|
98
|
+
return "Deployment expiresAt must be a safe integer timestamp in milliseconds, or null to clear the expiry.";
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const validateExpiry = Effect.fn("Deployment.validateExpiry")(function* ({
|
|
103
|
+
expiresAt,
|
|
104
|
+
}: DeploymentProps) {
|
|
105
|
+
if (expiresAt != null && !Number.isSafeInteger(expiresAt))
|
|
106
|
+
return yield* InvalidDeploymentExpiry.make({
|
|
107
|
+
requested: String(expiresAt),
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
82
111
|
export const provider = Effect.gen(function* () {
|
|
83
112
|
const client = yield* ConvexClient;
|
|
84
113
|
const attributes = Effect.fn("Deployment.attributes")(function* (
|
|
@@ -96,6 +125,7 @@ export const provider = Effect.gen(function* () {
|
|
|
96
125
|
url: deployment.deploymentUrl,
|
|
97
126
|
region: deployment.region,
|
|
98
127
|
class: deployment.class,
|
|
128
|
+
expiresAt: deployment.expiresAt ?? null,
|
|
99
129
|
} satisfies DeploymentAttributes;
|
|
100
130
|
});
|
|
101
131
|
const find = Effect.fn("Deployment.find")(function* (
|
|
@@ -128,7 +158,10 @@ export const provider = Effect.gen(function* () {
|
|
|
128
158
|
});
|
|
129
159
|
return {
|
|
130
160
|
diff: Effect.fn("Deployment.diff")(function* ({ news, output }) {
|
|
131
|
-
if (!isResolved(news)
|
|
161
|
+
if (!isResolved(news)) return;
|
|
162
|
+
yield* validateExpiry(news);
|
|
163
|
+
if (output === undefined) return;
|
|
164
|
+
const expiresAt = news.expiresAt;
|
|
132
165
|
yield* validate(output, news);
|
|
133
166
|
const deployment = yield* client
|
|
134
167
|
.getDeployment(output.name)
|
|
@@ -138,7 +171,8 @@ export const provider = Effect.gen(function* () {
|
|
|
138
171
|
yield* validate(current, news);
|
|
139
172
|
if (
|
|
140
173
|
(news.reference ?? output.reference) !== current.reference ||
|
|
141
|
-
(news.class !== undefined && news.class !== current.class)
|
|
174
|
+
(news.class !== undefined && news.class !== current.class) ||
|
|
175
|
+
(expiresAt !== undefined && expiresAt !== (current.expiresAt ?? null))
|
|
142
176
|
)
|
|
143
177
|
return { action: "update" };
|
|
144
178
|
}),
|
|
@@ -171,6 +205,7 @@ export const provider = Effect.gen(function* () {
|
|
|
171
205
|
news,
|
|
172
206
|
output,
|
|
173
207
|
}) {
|
|
208
|
+
yield* validateExpiry(news);
|
|
174
209
|
if (output === undefined) yield* checkpointCreate(fqn, instanceId, news);
|
|
175
210
|
if (output !== undefined) yield* validate(output, news);
|
|
176
211
|
let deployment =
|
|
@@ -183,6 +218,7 @@ export const provider = Effect.gen(function* () {
|
|
|
183
218
|
news.reference ??
|
|
184
219
|
output?.reference ??
|
|
185
220
|
(yield* resourceName("deployment", fqn, instanceId));
|
|
221
|
+
const expiresAt = news.expiresAt;
|
|
186
222
|
if (deployment === undefined) {
|
|
187
223
|
const existing = yield* find(news.projectId, reference);
|
|
188
224
|
if (existing !== undefined && !(yield* shouldAdopt(fqn)))
|
|
@@ -202,6 +238,7 @@ export const provider = Effect.gen(function* () {
|
|
|
202
238
|
reference,
|
|
203
239
|
...(news.region === undefined ? {} : { region: news.region }),
|
|
204
240
|
...(news.class === undefined ? {} : { class: news.class }),
|
|
241
|
+
...(expiresAt === undefined ? {} : { expiresAt }),
|
|
205
242
|
});
|
|
206
243
|
}
|
|
207
244
|
}
|
|
@@ -209,7 +246,8 @@ export const provider = Effect.gen(function* () {
|
|
|
209
246
|
yield* validate(current, news);
|
|
210
247
|
if (
|
|
211
248
|
current.reference !== reference ||
|
|
212
|
-
(news.class !== undefined && news.class !== current.class)
|
|
249
|
+
(news.class !== undefined && news.class !== current.class) ||
|
|
250
|
+
(expiresAt !== undefined && expiresAt !== (current.expiresAt ?? null))
|
|
213
251
|
) {
|
|
214
252
|
if (current.reference !== reference) {
|
|
215
253
|
const existing = yield* find(news.projectId, reference);
|
|
@@ -225,6 +263,10 @@ export const provider = Effect.gen(function* () {
|
|
|
225
263
|
...(news.class === undefined || news.class === current.class
|
|
226
264
|
? {}
|
|
227
265
|
: { class: news.class }),
|
|
266
|
+
...(expiresAt === undefined ||
|
|
267
|
+
expiresAt === (current.expiresAt ?? null)
|
|
268
|
+
? {}
|
|
269
|
+
: { expiresAt }),
|
|
228
270
|
});
|
|
229
271
|
deployment = yield* client.getDeployment(current.name);
|
|
230
272
|
}
|
|
@@ -240,7 +282,7 @@ export const provider = Effect.gen(function* () {
|
|
|
240
282
|
|
|
241
283
|
interface LocalConfig {
|
|
242
284
|
readonly name: string;
|
|
243
|
-
readonly props: Omit<DeploymentProps, "class">;
|
|
285
|
+
readonly props: Omit<DeploymentProps, "class" | "expiresAt">;
|
|
244
286
|
}
|
|
245
287
|
|
|
246
288
|
/**
|
|
@@ -267,7 +309,7 @@ export const localLayer = LocalProvider.make(
|
|
|
267
309
|
instanceId,
|
|
268
310
|
news,
|
|
269
311
|
}) {
|
|
270
|
-
const { class: _class, ...props } = news;
|
|
312
|
+
const { class: _class, expiresAt: _expiresAt, ...props } = news;
|
|
271
313
|
return {
|
|
272
314
|
name: yield* resourceName("deployment", fqn, instanceId),
|
|
273
315
|
props,
|