@gaganref/confect-alchemy 10.3.1-fork.95 → 10.6.0-fork.1

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.
Files changed (106) hide show
  1. package/README.md +1 -1
  2. package/dist/Backend.d.ts.map +1 -1
  3. package/dist/Backend.js +2 -3
  4. package/dist/Backend.js.map +1 -1
  5. package/dist/Code.d.ts +16 -3
  6. package/dist/Code.d.ts.map +1 -1
  7. package/dist/Code.js +13 -3
  8. package/dist/Code.js.map +1 -1
  9. package/dist/Confect.d.ts.map +1 -1
  10. package/dist/Confect.js +1 -2
  11. package/dist/Convex.d.ts.map +1 -1
  12. package/dist/Convex.js +3 -4
  13. package/dist/ConvexClient.d.ts +14 -4
  14. package/dist/ConvexClient.d.ts.map +1 -1
  15. package/dist/ConvexClient.js +44 -36
  16. package/dist/ConvexClient.js.map +1 -1
  17. package/dist/DeployKey.d.ts +22 -12
  18. package/dist/DeployKey.d.ts.map +1 -1
  19. package/dist/DeployKey.js +41 -29
  20. package/dist/DeployKey.js.map +1 -1
  21. package/dist/Deployment.d.ts +19 -10
  22. package/dist/Deployment.d.ts.map +1 -1
  23. package/dist/Deployment.js +22 -19
  24. package/dist/Deployment.js.map +1 -1
  25. package/dist/EnvironmentVariables.d.ts +23 -31
  26. package/dist/EnvironmentVariables.d.ts.map +1 -1
  27. package/dist/EnvironmentVariables.js +21 -20
  28. package/dist/EnvironmentVariables.js.map +1 -1
  29. package/dist/Project.d.ts +15 -10
  30. package/dist/Project.d.ts.map +1 -1
  31. package/dist/Project.js +23 -22
  32. package/dist/Project.js.map +1 -1
  33. package/dist/Providers.d.ts +3 -1
  34. package/dist/Providers.d.ts.map +1 -1
  35. package/dist/Providers.js +19 -18
  36. package/dist/Providers.js.map +1 -1
  37. package/dist/_virtual/_rolldown/runtime.js +5 -6
  38. package/dist/index.d.ts +3 -0
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +1 -1
  41. package/dist/internal/CodeDeployment.d.ts +6 -1
  42. package/dist/internal/CodeDeployment.d.ts.map +1 -1
  43. package/dist/internal/CodeDeployment.js +10 -8
  44. package/dist/internal/CodeDeployment.js.map +1 -1
  45. package/dist/internal/CommandRunner.d.ts +6 -1
  46. package/dist/internal/CommandRunner.d.ts.map +1 -1
  47. package/dist/internal/CommandRunner.js +11 -9
  48. package/dist/internal/CommandRunner.js.map +1 -1
  49. package/dist/internal/FileLock.d.ts +7 -3
  50. package/dist/internal/FileLock.d.ts.map +1 -1
  51. package/dist/internal/FileLock.js +10 -8
  52. package/dist/internal/FileLock.js.map +1 -1
  53. package/dist/internal/Lifecycle.d.ts +3 -1
  54. package/dist/internal/Lifecycle.d.ts.map +1 -1
  55. package/dist/internal/Lifecycle.js +3 -4
  56. package/dist/internal/Lifecycle.js.map +1 -1
  57. package/dist/internal/LocalBackend.d.ts +7 -3
  58. package/dist/internal/LocalBackend.d.ts.map +1 -1
  59. package/dist/internal/LocalBackend.js +26 -18
  60. package/dist/internal/LocalBackend.js.map +1 -1
  61. package/dist/internal/LocalSidecar.d.ts +4 -1
  62. package/dist/internal/LocalSidecar.d.ts.map +1 -1
  63. package/dist/internal/LocalSidecar.js +4 -2
  64. package/dist/internal/LocalSidecar.js.map +1 -1
  65. package/dist/internal/Loopback.d.ts.map +1 -1
  66. package/dist/internal/Loopback.js +1 -2
  67. package/dist/internal/MountInit.d.ts +5 -1
  68. package/dist/internal/MountInit.d.ts.map +1 -1
  69. package/dist/internal/MountInit.js +5 -4
  70. package/dist/internal/MountInit.js.map +1 -1
  71. package/dist/internal/PushLock.d.ts +7 -3
  72. package/dist/internal/PushLock.d.ts.map +1 -1
  73. package/dist/internal/PushLock.js +7 -6
  74. package/dist/internal/PushLock.js.map +1 -1
  75. package/dist/internal/ResourceIdentity.d.ts.map +1 -1
  76. package/dist/internal/ResourceIdentity.js +5 -3
  77. package/dist/internal/ResourceIdentity.js.map +1 -1
  78. package/dist/internal/UserCache.d.ts +2 -0
  79. package/dist/internal/UserCache.d.ts.map +1 -1
  80. package/dist/internal/UserCache.js +5 -4
  81. package/dist/internal/UserCache.js.map +1 -1
  82. package/dist/internal/Zip.d.ts +5 -1
  83. package/dist/internal/Zip.d.ts.map +1 -1
  84. package/dist/internal/Zip.js +9 -8
  85. package/dist/internal/Zip.js.map +1 -1
  86. package/package.json +5 -5
  87. package/src/Backend.ts +7 -6
  88. package/src/Code.ts +11 -0
  89. package/src/ConvexClient.ts +87 -74
  90. package/src/DeployKey.ts +73 -44
  91. package/src/Deployment.ts +50 -37
  92. package/src/EnvironmentVariables.ts +30 -27
  93. package/src/Project.ts +42 -41
  94. package/src/Providers.ts +2 -0
  95. package/src/index.ts +3 -0
  96. package/src/internal/CodeDeployment.ts +17 -11
  97. package/src/internal/CommandRunner.ts +27 -26
  98. package/src/internal/FileLock.ts +15 -12
  99. package/src/internal/Lifecycle.ts +11 -7
  100. package/src/internal/LocalBackend.ts +45 -39
  101. package/src/internal/LocalSidecar.ts +3 -0
  102. package/src/internal/MountInit.ts +8 -6
  103. package/src/internal/PushLock.ts +13 -11
  104. package/src/internal/ResourceIdentity.ts +12 -5
  105. package/src/internal/UserCache.ts +13 -4
  106. package/src/internal/Zip.ts +13 -8
@@ -1 +1 @@
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\";\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\"\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<ConvexApiError>()(\n \"ConvexApiError\",\n errorFields,\n) {}\n\nexport class ConvexNotFound extends Schema.TaggedError<ConvexNotFound>()(\n \"ConvexNotFound\",\n errorFields,\n) {}\n\nexport class ConvexConflict extends Schema.TaggedError<ConvexConflict>()(\n \"ConvexConflict\",\n errorFields,\n) {}\n\n/**\n * A function the deployment ran failed, with the message Convex reports.\n */\nexport class ConvexFunctionError extends Schema.TaggedError<ConvexFunctionError>()(\n \"ConvexFunctionError\",\n { functionPath: Schema.String, 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.optionalKey(Schema.NullOr(Schema.String)),\n devDeploymentName: Schema.optionalKey(Schema.NullOr(Schema.String)),\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.optionalKey(Schema.NullOr(Schema.String)),\n deploymentUrl: Schema.optionalKey(Schema.NullOr(Schema.String)),\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.optionalKey(Schema.NullOr(Schema.String)),\n};\n\nconst DeploymentSchema = Schema.Union([\n Schema.Struct({\n ...deploymentFields,\n kind: Schema.Literal(\"cloud\"),\n id: Schema.Finite,\n lastDeployTime: Schema.optionalKey(Schema.NullOr(Schema.Finite)),\n creator: Schema.optionalKey(Schema.NullOr(Schema.Finite)),\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.optionalKey(\n Schema.NullOr(Schema.Boolean),\n ),\n deploymentUrl: Schema.String,\n expiresAt: Schema.optionalKey(Schema.NullOr(Schema.Finite)),\n class: Schema.String,\n sendLogsToClient: Schema.optionalKey(Schema.NullOr(Schema.Boolean)),\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.optionalKey(Schema.NullOr(Schema.Finite)),\n expiresAt: Schema.optionalKey(Schema.NullOr(Schema.Finite)),\n creator: Schema.optionalKey(Schema.NullOr(Schema.Finite)),\n managedBy: Schema.optionalKey(\n Schema.NullOr(\n Schema.Union([\n Schema.Literal(\"vercel\"),\n Schema.Struct({ oauthApp: Schema.String }),\n ]),\n ),\n ),\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.optionalKey(Schema.NullOr(Schema.String)),\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 () =>\n new ConvexApiError({\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 () => new ConvexApiError({ 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 () => new ConvexApiError({ operation, code: \"TransportError\" }),\n ),\n );\n if (response.status === 404) {\n return yield* new ConvexNotFound({\n operation,\n status: 404,\n code: \"HttpError\",\n });\n }\n if (response.status === 409) {\n return yield* new ConvexConflict({\n operation,\n status: 409,\n code: \"HttpError\",\n });\n }\n if (response.status < 200 || response.status >= 300) {\n return yield* new ConvexApiError({\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 new ConvexApiError({\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 response = yield* send(\n operation,\n method,\n `${baseUrl}${path}`,\n yield* managementAuthorization,\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 yield* send(\n operation,\n method,\n `${baseUrl}${path}`,\n yield* managementAuthorization,\n body,\n );\n });\n\n const deploymentUrl = Effect.fn(\"ConvexClient.deploymentUrl\")(function* (\n operation: string,\n url: string,\n ) {\n const invalidUrl = () =>\n new ConvexApiError({ 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 url.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 origin = (yield* deploymentUrl(operation, url)).replace(\n /\\/api\\/v1$/,\n \"\",\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 () => new ConvexApiError({ 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 () => new ConvexApiError({ 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* new ConvexApiError({\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* new ConvexFunctionError({\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 (!nextCursor || seenCursors.has(nextCursor)) {\n return yield* new ConvexApiError({\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 Object.fromEntries(\n Object.entries(result.environmentVariables).map(([name, value]) => [\n name,\n 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: changes.map(({ 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 */\nexport const layer = (options?: {\n readonly token?: Redacted.Redacted<string>;\n readonly mode?: ProviderMode;\n}) =>\n Layer.effect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H;GACA,OAAO,OAAO,YACZ,OAAO,QAAQ,OAAO,oBAAoB,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW,CACjE,MACA,SAAS,KAAK,KAAK,CACrB,CAAC,CACH;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,QAAQ,KAAK,EAAE,MAAM,aAAa;IACzC;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;;;;;AAMtC,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\"\n> & { readonly reference: string };\nexport type UpdateDeploymentInput = Pick<\n ManagementApi.PlatformUpdateDeploymentArgs,\n \"reference\" | \"expiresAt\" | \"sendLogsToClient\"\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,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EAAE,CAAC,CAAC"}
@@ -21,19 +21,23 @@ export interface DeployKeyAttributes {
21
21
  readonly allowedActions: ReadonlyArray<string>;
22
22
  }
23
23
  export type DeployKey = Resource<"Convex.DeployKey", DeployKeyProps, DeployKeyAttributes, never, Providers>;
24
- export declare const DeployKey: import("alchemy/Resource").ResourceClass<DeployKey>;
24
+ export declare const DeployKey: import("alchemy").ResourceClass<DeployKey>;
25
25
  declare const DeployKeyRecoveryRequired_base: Schema.Class<DeployKeyRecoveryRequired, Schema.TaggedStruct<"DeployKeyRecoveryRequired", {
26
26
  readonly deploymentName: Schema.String;
27
- readonly name: Schema.String;
27
+ readonly keyName: Schema.String;
28
28
  readonly keyIds: Schema.$Array<Schema.Finite>;
29
- }>, import("effect/Cause").YieldableError>;
29
+ }>, import("effect/Cause").YieldableError & {
30
+ readonly brand: unique symbol;
31
+ }>;
30
32
  export declare class DeployKeyRecoveryRequired extends DeployKeyRecoveryRequired_base {
31
33
  }
32
34
  declare const DeployKeyChangeRequiresNewResource_base: Schema.Class<DeployKeyChangeRequiresNewResource, Schema.TaggedStruct<"DeployKeyChangeRequiresNewResource", {
33
35
  readonly deploymentName: Schema.String;
34
36
  readonly keyId: Schema.Finite;
35
37
  readonly field: Schema.String;
36
- }>, import("effect/Cause").YieldableError>;
38
+ }>, import("effect/Cause").YieldableError & {
39
+ readonly brand: unique symbol;
40
+ }>;
37
41
  export declare class DeployKeyChangeRequiresNewResource extends DeployKeyChangeRequiresNewResource_base {
38
42
  }
39
43
  export declare const provider: Effect.Effect<{
@@ -42,9 +46,9 @@ export declare const provider: Effect.Effect<{
42
46
  fqn: string;
43
47
  instanceId: string;
44
48
  olds: DeployKeyProps;
45
- news: import("alchemy/Input").Input<DeployKeyProps>;
46
- oldBindings: import("alchemy/Resource").ResourceBinding<never>[];
47
- newBindings: import("alchemy/Input").Input<import("alchemy/Resource").ResourceBinding<never>[]>;
49
+ news: import("alchemy").Input<DeployKeyProps>;
50
+ oldBindings: import("alchemy").ResourceBinding<never>[];
51
+ newBindings: import("alchemy").Input<import("alchemy").ResourceBinding<never>[]>;
48
52
  output: DeployKeyAttributes | undefined;
49
53
  }) => Effect.Effect<undefined, import("./ConvexClient.js").ConvexApiError | import("./ConvexClient.js").ConvexConflict | import("./ConvexClient.js").ConvexNotFound | DeployKeyChangeRequiresNewResource | DeployKeyRecoveryRequired, never>;
50
54
  read: (args_0: {
@@ -53,6 +57,7 @@ export declare const provider: Effect.Effect<{
53
57
  instanceId: string;
54
58
  olds: DeployKeyProps;
55
59
  output: DeployKeyAttributes | undefined;
60
+ previous?: DeployKeyAttributes;
56
61
  }) => Effect.Effect<{
57
62
  deploymentName: string;
58
63
  keyId: number;
@@ -68,7 +73,7 @@ export declare const provider: Effect.Effect<{
68
73
  olds: DeployKeyProps | undefined;
69
74
  output: DeployKeyAttributes | undefined;
70
75
  session: import("alchemy/Report").ScopedPlanStatusSession;
71
- bindings: import("alchemy/Resource").ResourceBinding<never>[];
76
+ bindings: import("alchemy").ResourceBinding<never>[];
72
77
  }) => Effect.Effect<{
73
78
  deploymentName: string;
74
79
  keyId: number;
@@ -83,7 +88,7 @@ export declare const provider: Effect.Effect<{
83
88
  olds: DeployKeyProps;
84
89
  output: DeployKeyAttributes;
85
90
  session: import("alchemy/Report").ScopedPlanStatusSession;
86
- bindings: import("alchemy/Resource").ResourceBinding<never>[];
91
+ bindings: import("alchemy").ResourceBinding<never>[];
87
92
  force?: boolean;
88
93
  }) => Effect.Effect<void, import("./ConvexClient.js").ConvexApiError | import("./ConvexClient.js").ConvexConflict, never>;
89
94
  }, never, ConvexClient>;
@@ -91,6 +96,8 @@ export declare const provider: Effect.Effect<{
91
96
  * Under `alchemy dev` the deploy key is the admin key the local deployment
92
97
  * generated. It is read on every apply, so a recreated backend's new key
93
98
  * replaces the old one.
99
+ *
100
+ * @stability unstable
94
101
  */
95
102
  export declare const localProvider: Effect.Effect<{
96
103
  diff: () => Effect.Effect<{
@@ -104,7 +111,7 @@ export declare const localProvider: Effect.Effect<{
104
111
  olds: DeployKeyProps | undefined;
105
112
  output: DeployKeyAttributes | undefined;
106
113
  session: import("alchemy/Report").ScopedPlanStatusSession;
107
- bindings: import("alchemy/Resource").ResourceBinding<never>[];
114
+ bindings: import("alchemy").ResourceBinding<never>[];
108
115
  }) => Effect.Effect<{
109
116
  deploymentName: string;
110
117
  keyId: number;
@@ -113,8 +120,11 @@ export declare const localProvider: Effect.Effect<{
113
120
  allowedActions: readonly ("deployment:aiGateway:use" | "deployment:auditLog:view" | "deployment:backups:create" | "deployment:backups:delete" | "deployment:backups:download" | "deployment:backups:import" | "deployment:backups:view" | "deployment:data:view" | "deployment:data:write" | "deployment:deploy" | "deployment:env:view" | "deployment:env:write" | "deployment:functions:actAsUser" | "deployment:functions:runInternalActions" | "deployment:functions:runInternalMutations" | "deployment:functions:runInternalQueries" | "deployment:functions:runTestQuery" | "deployment:integrations:view" | "deployment:integrations:write" | "deployment:logs:view" | "deployment:metrics:view" | "deployment:pause" | "deployment:unpause" | "deployment:usage:view" | "deployment:usageLimits:view" | "deployment:usageLimits:write")[];
114
121
  }, import("./internal/LocalBackend.js").LocalBackendError, never>;
115
122
  delete: () => Effect.Effect<void, never, never>;
116
- }, never, FileSystem.FileSystem | Path.Path | import("alchemy/Stack").Stack>;
123
+ }, never, FileSystem.FileSystem | Path.Path | import("alchemy").Stack>;
117
124
  export declare const layer: import("effect/Layer").Layer<Provider.Provider<DeployKey>, never, ConvexClient>;
118
- export declare const localLayer: import("effect/Layer").Layer<Provider.Provider<DeployKey>, never, FileSystem.FileSystem | Path.Path | import("alchemy/Stack").Stack>;
125
+ /**
126
+ * @stability unstable
127
+ */
128
+ export declare const localLayer: import("effect/Layer").Layer<Provider.Provider<DeployKey>, never, FileSystem.FileSystem | Path.Path | import("alchemy").Stack>;
119
129
  export {};
120
130
  //# sourceMappingURL=DeployKey.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DeployKey.d.ts","sourceRoot":"","sources":["../src/DeployKey.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AAC,CAAC,CAAC,MAAM,CAAC,CACnE,CAAC;CACH;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9C,QAAQ,CAAC,cAAc,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAChD;AAED,MAAM,MAAM,SAAS,GAAG,QAAQ,CAC9B,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,KAAK,EACL,SAAS,CACV,CAAC;AACF,eAAO,MAAM,SAAS,4CAA0C,CAAC;;;;;;oBAI7C,OAAO,MAAM;;AAFjC,qBAAa,yBAA0B,SAAQ,8BAO7C;CAAG;;;;;;oBAIe,OAAO,MAAM;;AAFjC,qBAAa,kCAAmC,SAAQ,uCAOtD;CAAG;AAEL,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;wBAlCM,MAAM;eACf,MAAM;cACP,MAAM;mBACD,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;;;;;;;;;;;;;wBAHpB,MAAM;eACf,MAAM;cACP,MAAM;mBACD,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;;;;;;;;;;;;;uBAgN7C,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;sEA6BxB,CAAC;AAEH,eAAO,MAAM,KAAK,iFAAuC,CAAC;AAC1D;;GAEG;AACH,eAAO,MAAM,UAAU,gIAA4C,CAAC"}
package/dist/DeployKey.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ConvexClient } from "./ConvexClient.js";
2
- import { checkpointCreate } from "./internal/Lifecycle.js";
3
2
  import { resourceName } from "./internal/ResourceIdentity.js";
3
+ import { checkpointCreate } from "./internal/Lifecycle.js";
4
4
  import { adminKey, dataDirectories } from "./internal/LocalBackend.js";
5
5
  import * as Effect from "effect/Effect";
6
6
  import * as Provider from "alchemy/Provider";
@@ -9,12 +9,16 @@ import * as FileSystem from "effect/FileSystem";
9
9
  import * as Path from "effect/Path";
10
10
  import * as Redacted from "effect/Redacted";
11
11
  import * as Schema from "effect/Schema";
12
+ import * as Option from "effect/Option";
13
+ import * as String from "effect/String";
14
+ import { pipe } from "effect/Function";
15
+ import * as Array from "effect/Array";
12
16
  import { isResolved } from "alchemy/Diff";
13
- //#region src/DeployKey.ts
17
+ // src/DeployKey.ts
14
18
  const DeployKey = Resource("Convex.DeployKey");
15
19
  var DeployKeyRecoveryRequired = class extends Schema.TaggedError()("DeployKeyRecoveryRequired", {
16
20
  deploymentName: Schema.String,
17
- name: Schema.String,
21
+ keyName: Schema.String,
18
22
  keyIds: Schema.Array(Schema.Finite)
19
23
  }) {};
20
24
  var DeployKeyChangeRequiresNewResource = class extends Schema.TaggedError()("DeployKeyChangeRequiresNewResource", {
@@ -24,29 +28,30 @@ var DeployKeyChangeRequiresNewResource = class extends Schema.TaggedError()("Dep
24
28
  }) {};
25
29
  const provider = Effect.gen(function* () {
26
30
  const client = yield* ConvexClient;
27
- const hasName = (keyName, name) => keyName === name || keyName.startsWith(`${name} (`) && /^[0-9a-f]{8}\)$/.test(keyName.slice(name.length + 2));
28
- const recover = (deploymentName, name, keyIds) => new DeployKeyRecoveryRequired({
31
+ const hasName = (keyName, name) => keyName === name || pipe(keyName, String.startsWith(`${name} (`)) && /^[0-9a-f]{8}\)$/.test(pipe(keyName, String.slice(name.length + 2)));
32
+ const recover = (deploymentName, name, keyIds) => DeployKeyRecoveryRequired.make({
29
33
  deploymentName,
30
- name,
34
+ keyName: name,
31
35
  keyIds
32
36
  });
33
37
  return {
34
38
  diff: Effect.fn("DeployKey.diff")(function* ({ news, output }) {
35
- if (!isResolved(news) || !output) return;
36
- for (const field of ["deploymentName", "name"]) if (news[field] !== void 0 && news[field] !== output[field]) return yield* new DeployKeyChangeRequiresNewResource({
39
+ if (!isResolved(news) || output === void 0) return;
40
+ for (const field of ["deploymentName", "name"]) if (news[field] !== void 0 && news[field] !== output[field]) return yield* DeployKeyChangeRequiresNewResource.make({
37
41
  deploymentName: output.deploymentName,
38
42
  keyId: output.keyId,
39
43
  field
40
44
  });
41
- const key = (yield* client.listDeployKeys(output.deploymentName)).find((candidate) => candidate.id === output.keyId);
42
- if (!key || !Redacted.isRedacted(output.deployKey)) return yield* recover(output.deploymentName, output.name, [output.keyId]);
43
- if (!hasName(key.name, news.name ?? output.name)) return yield* new DeployKeyChangeRequiresNewResource({
45
+ const keys = yield* client.listDeployKeys(output.deploymentName);
46
+ const key = Option.getOrUndefined(Array.findFirst(keys, (candidate) => candidate.id === output.keyId));
47
+ if (key === void 0 || !Redacted.isRedacted(output.deployKey)) return yield* recover(output.deploymentName, output.name, [output.keyId]);
48
+ if (!hasName(key.name, news.name ?? output.name)) return yield* DeployKeyChangeRequiresNewResource.make({
44
49
  deploymentName: output.deploymentName,
45
50
  keyId: output.keyId,
46
51
  field: "name"
47
52
  });
48
53
  const allowedActions = news.allowedActions ?? output.allowedActions;
49
- if (new Set(allowedActions).size !== new Set(key.allowedActions).size || allowedActions.some((action) => !key.allowedActions.includes(action))) return yield* new DeployKeyChangeRequiresNewResource({
54
+ if (new Set(allowedActions).size !== new Set(key.allowedActions).size || Array.some(allowedActions, (action) => !key.allowedActions.includes(action))) return yield* DeployKeyChangeRequiresNewResource.make({
50
55
  deploymentName: output.deploymentName,
51
56
  keyId: output.keyId,
52
57
  field: "allowedActions"
@@ -57,36 +62,37 @@ const provider = Effect.gen(function* () {
57
62
  if (deploymentName === void 0) return;
58
63
  const name = output?.name ?? olds.name ?? (yield* resourceName("key", fqn, instanceId));
59
64
  const keys = yield* client.listDeployKeys(deploymentName);
60
- if (output) {
61
- const key = keys.find((candidate) => candidate.id === output.keyId);
62
- if (!key) return yield* recover(deploymentName, name, [output.keyId]);
65
+ if (output !== void 0) {
66
+ const key = Option.getOrUndefined(Array.findFirst(keys, (candidate) => candidate.id === output.keyId));
67
+ if (key === void 0) return yield* recover(deploymentName, name, [output.keyId]);
63
68
  if (!Redacted.isRedacted(output.deployKey)) return yield* recover(deploymentName, name, [key.id]);
64
69
  return {
65
70
  ...output,
66
71
  allowedActions: key.allowedActions
67
72
  };
68
73
  }
69
- const matches = keys.filter((key) => hasName(key.name, name));
70
- if (matches.length > 0) return yield* recover(deploymentName, name, matches.map((candidate) => candidate.id));
74
+ const matches = Array.filter(keys, (key) => hasName(key.name, name));
75
+ if (matches.length > 0) return yield* recover(deploymentName, name, Array.map(matches, (candidate) => candidate.id));
71
76
  }),
72
77
  reconcile: Effect.fn("DeployKey.reconcile")(function* ({ fqn, instanceId, news, output }) {
73
- if (!output) yield* checkpointCreate(fqn, instanceId, news);
78
+ if (output === void 0) yield* checkpointCreate(fqn, instanceId, news);
74
79
  const name = news.name ?? output?.name ?? (yield* resourceName("key", fqn, instanceId));
75
- if (output) {
76
- for (const field of ["deploymentName", "name"]) if (news[field] !== void 0 && news[field] !== output[field]) return yield* new DeployKeyChangeRequiresNewResource({
80
+ if (output !== void 0) {
81
+ for (const field of ["deploymentName", "name"]) if (news[field] !== void 0 && news[field] !== output[field]) return yield* DeployKeyChangeRequiresNewResource.make({
77
82
  deploymentName: output.deploymentName,
78
83
  keyId: output.keyId,
79
84
  field
80
85
  });
81
- const key = (yield* client.listDeployKeys(output.deploymentName)).find((candidate) => candidate.id === output.keyId);
82
- if (!key || !Redacted.isRedacted(output.deployKey)) return yield* recover(output.deploymentName, name, [output.keyId]);
83
- if (!hasName(key.name, name)) return yield* new DeployKeyChangeRequiresNewResource({
86
+ const keys = yield* client.listDeployKeys(output.deploymentName);
87
+ const key = Option.getOrUndefined(Array.findFirst(keys, (candidate) => candidate.id === output.keyId));
88
+ if (key === void 0 || !Redacted.isRedacted(output.deployKey)) return yield* recover(output.deploymentName, name, [output.keyId]);
89
+ if (!hasName(key.name, name)) return yield* DeployKeyChangeRequiresNewResource.make({
84
90
  deploymentName: output.deploymentName,
85
91
  keyId: output.keyId,
86
92
  field: "name"
87
93
  });
88
94
  const allowedActions = news.allowedActions ?? output.allowedActions;
89
- if (new Set(allowedActions).size !== new Set(key.allowedActions).size || allowedActions.some((action) => !key.allowedActions.includes(action))) return yield* new DeployKeyChangeRequiresNewResource({
95
+ if (new Set(allowedActions).size !== new Set(key.allowedActions).size || Array.some(allowedActions, (action) => !key.allowedActions.includes(action))) return yield* DeployKeyChangeRequiresNewResource.make({
90
96
  deploymentName: output.deploymentName,
91
97
  keyId: output.keyId,
92
98
  field: "allowedActions"
@@ -96,15 +102,17 @@ const provider = Effect.gen(function* () {
96
102
  allowedActions: key.allowedActions
97
103
  };
98
104
  }
99
- const existing = (yield* client.listDeployKeys(news.deploymentName)).filter((key) => hasName(key.name, name));
100
- if (existing.length > 0) return yield* recover(news.deploymentName, name, existing.map((key) => key.id));
105
+ const deployKeys = yield* client.listDeployKeys(news.deploymentName);
106
+ const existing = Array.filter(deployKeys, (key) => hasName(key.name, name));
107
+ if (existing.length > 0) return yield* recover(news.deploymentName, name, Array.map(existing, (key) => key.id));
101
108
  const created = yield* client.createDeployKey(news.deploymentName, {
102
109
  name,
103
110
  ...news.allowedActions === void 0 ? {} : { allowedActions: [...news.allowedActions] }
104
111
  });
105
- const matches = (yield* client.listDeployKeys(news.deploymentName)).filter((key) => hasName(key.name, name));
112
+ const deployKeys2 = yield* client.listDeployKeys(news.deploymentName);
113
+ const matches = Array.filter(deployKeys2, (key) => hasName(key.name, name));
106
114
  const key = matches[0];
107
- if (matches.length !== 1 || !key) return yield* recover(news.deploymentName, name, matches.map((candidate) => candidate.id));
115
+ if (matches.length !== 1 || key === void 0) return yield* recover(news.deploymentName, name, Array.map(matches, (candidate) => candidate.id));
108
116
  return {
109
117
  deploymentName: news.deploymentName,
110
118
  keyId: key.id,
@@ -122,6 +130,8 @@ const provider = Effect.gen(function* () {
122
130
  * Under `alchemy dev` the deploy key is the admin key the local deployment
123
131
  * generated. It is read on every apply, so a recreated backend's new key
124
132
  * replaces the old one.
133
+ *
134
+ * @stability unstable
125
135
  */
126
136
  const localProvider = Effect.gen(function* () {
127
137
  const fs = yield* FileSystem.FileSystem;
@@ -144,8 +154,10 @@ const localProvider = Effect.gen(function* () {
144
154
  };
145
155
  });
146
156
  const layer = Provider.effect(DeployKey, provider);
157
+ /**
158
+ * @stability unstable
159
+ */
147
160
  const localLayer = Provider.effect(DeployKey, localProvider);
148
- //#endregion
149
161
  export { DeployKey, DeployKeyChangeRequiresNewResource, DeployKeyRecoveryRequired, layer, localLayer, localProvider, provider };
150
162
 
151
163
  //# sourceMappingURL=DeployKey.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DeployKey.js","names":[],"sources":["../src/DeployKey.ts"],"sourcesContent":["import type { PlatformCreateDeployKeyArgs } from \"@convex-dev/platform/managementApi\";\nimport { isResolved } from \"alchemy/Diff\";\nimport * as Provider from \"alchemy/Provider\";\nimport { Resource } from \"alchemy/Resource\";\nimport * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport * as Redacted from \"effect/Redacted\";\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 } from \"./internal/Lifecycle.js\";\nimport { adminKey, dataDirectories } from \"./internal/LocalBackend.js\";\n\nexport interface DeployKeyProps {\n readonly deploymentName: string;\n readonly name?: string;\n readonly allowedActions?: ReadonlyArray<\n NonNullable<PlatformCreateDeployKeyArgs[\"allowedActions\"]>[number]\n >;\n}\n\nexport interface DeployKeyAttributes {\n readonly deploymentName: string;\n readonly keyId: number;\n readonly name: string;\n readonly deployKey: Redacted.Redacted<string>;\n readonly allowedActions: ReadonlyArray<string>;\n}\n\nexport type DeployKey = Resource<\n \"Convex.DeployKey\",\n DeployKeyProps,\n DeployKeyAttributes,\n never,\n Providers\n>;\nexport const DeployKey = Resource<DeployKey>(\"Convex.DeployKey\");\n\nexport class DeployKeyRecoveryRequired extends Schema.TaggedError<DeployKeyRecoveryRequired>()(\n \"DeployKeyRecoveryRequired\",\n {\n deploymentName: Schema.String,\n name: Schema.String,\n keyIds: Schema.Array(Schema.Finite),\n },\n) {}\n\nexport class DeployKeyChangeRequiresNewResource extends Schema.TaggedError<DeployKeyChangeRequiresNewResource>()(\n \"DeployKeyChangeRequiresNewResource\",\n { deploymentName: Schema.String, keyId: Schema.Finite, field: Schema.String },\n) {}\n\nexport const provider = Effect.gen(function* () {\n const client = yield* ConvexClient;\n const hasName = (keyName: string, name: string) =>\n keyName === name ||\n (keyName.startsWith(`${name} (`) &&\n /^[0-9a-f]{8}\\)$/.test(keyName.slice(name.length + 2)));\n const recover = (\n deploymentName: string,\n name: string,\n keyIds: ReadonlyArray<number>,\n ) => new DeployKeyRecoveryRequired({ deploymentName, name, keyIds });\n return {\n diff: Effect.fn(\"DeployKey.diff\")(function* ({ news, output }) {\n if (!isResolved(news) || !output) return;\n for (const field of [\"deploymentName\", \"name\"] as const) {\n if (news[field] !== undefined && news[field] !== output[field])\n return yield* new DeployKeyChangeRequiresNewResource({\n deploymentName: output.deploymentName,\n keyId: output.keyId,\n field,\n });\n }\n const keys = yield* client.listDeployKeys(output.deploymentName);\n const key = keys.find((candidate) => candidate.id === output.keyId);\n if (!key || !Redacted.isRedacted(output.deployKey))\n return yield* recover(output.deploymentName, output.name, [\n output.keyId,\n ]);\n if (!hasName(key.name, news.name ?? output.name))\n return yield* new DeployKeyChangeRequiresNewResource({\n deploymentName: output.deploymentName,\n keyId: output.keyId,\n field: \"name\",\n });\n const allowedActions = news.allowedActions ?? output.allowedActions;\n if (\n new Set(allowedActions).size !== new Set(key.allowedActions).size ||\n allowedActions.some((action) => !key.allowedActions.includes(action))\n )\n return yield* new DeployKeyChangeRequiresNewResource({\n deploymentName: output.deploymentName,\n keyId: output.keyId,\n field: \"allowedActions\",\n });\n }),\n read: Effect.fn(\"DeployKey.read\")(function* ({\n fqn,\n instanceId,\n olds,\n output,\n }) {\n const deploymentName = output?.deploymentName ?? olds.deploymentName;\n if (deploymentName === undefined) return;\n const name =\n output?.name ??\n olds.name ??\n (yield* resourceName(\"key\", fqn, instanceId));\n const keys = yield* client.listDeployKeys(deploymentName);\n if (output) {\n const key = keys.find((candidate) => candidate.id === output.keyId);\n if (!key) return yield* recover(deploymentName, name, [output.keyId]);\n if (!Redacted.isRedacted(output.deployKey))\n return yield* recover(deploymentName, name, [key.id]);\n return {\n ...output,\n allowedActions: key.allowedActions,\n };\n }\n const matches = keys.filter((key) => hasName(key.name, name));\n if (matches.length > 0)\n return yield* recover(\n deploymentName,\n name,\n matches.map((candidate) => candidate.id),\n );\n return undefined;\n }),\n reconcile: Effect.fn(\"DeployKey.reconcile\")(function* ({\n fqn,\n instanceId,\n news,\n output,\n }) {\n if (!output) yield* checkpointCreate(fqn, instanceId, news);\n const name =\n news.name ??\n output?.name ??\n (yield* resourceName(\"key\", fqn, instanceId));\n if (output) {\n for (const field of [\"deploymentName\", \"name\"] as const) {\n if (news[field] !== undefined && news[field] !== output[field])\n return yield* new DeployKeyChangeRequiresNewResource({\n deploymentName: output.deploymentName,\n keyId: output.keyId,\n field,\n });\n }\n const keys = yield* client.listDeployKeys(output.deploymentName);\n const key = keys.find((candidate) => candidate.id === output.keyId);\n if (!key || !Redacted.isRedacted(output.deployKey))\n return yield* recover(output.deploymentName, name, [output.keyId]);\n if (!hasName(key.name, name))\n return yield* new DeployKeyChangeRequiresNewResource({\n deploymentName: output.deploymentName,\n keyId: output.keyId,\n field: \"name\",\n });\n const allowedActions = news.allowedActions ?? output.allowedActions;\n if (\n new Set(allowedActions).size !== new Set(key.allowedActions).size ||\n allowedActions.some((action) => !key.allowedActions.includes(action))\n )\n return yield* new DeployKeyChangeRequiresNewResource({\n deploymentName: output.deploymentName,\n keyId: output.keyId,\n field: \"allowedActions\",\n });\n return {\n ...output,\n allowedActions: key.allowedActions,\n };\n }\n const existing = (yield* client.listDeployKeys(\n news.deploymentName,\n )).filter((key) => hasName(key.name, name));\n if (existing.length > 0)\n return yield* recover(\n news.deploymentName,\n name,\n existing.map((key) => key.id),\n );\n const created = yield* client.createDeployKey(news.deploymentName, {\n name,\n ...(news.allowedActions === undefined\n ? {}\n : { allowedActions: [...news.allowedActions] }),\n });\n const matches = (yield* client.listDeployKeys(\n news.deploymentName,\n )).filter((key) => hasName(key.name, name));\n const key = matches[0];\n if (matches.length !== 1 || !key)\n return yield* recover(\n news.deploymentName,\n name,\n matches.map((candidate) => candidate.id),\n );\n return {\n deploymentName: news.deploymentName,\n keyId: key.id,\n name,\n deployKey: created.deployKey,\n allowedActions: key.allowedActions,\n };\n }),\n delete: Effect.fn(\"DeployKey.delete\")(function* ({ output }) {\n yield* client\n .deleteDeployKey(output.deploymentName, output.deployKey)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void));\n }),\n } satisfies Provider.ProviderServiceInput<DeployKey>;\n});\n\n/**\n * Under `alchemy dev` the deploy key is the admin key the local deployment\n * generated. It is read on every apply, so a recreated backend's new key\n * replaces the old one.\n */\nexport const localProvider = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const directory = yield* dataDirectories;\n return {\n diff: () => Effect.succeed({ action: \"update\" }),\n reconcile: Effect.fn(\"DeployKey.localReconcile\")(function* ({\n fqn,\n instanceId,\n news,\n }) {\n const name = news.name ?? (yield* resourceName(\"key\", fqn, instanceId));\n const deployKey = yield* adminKey(\n news.deploymentName,\n directory(news.deploymentName),\n ).pipe(\n Effect.provideService(FileSystem.FileSystem, fs),\n Effect.provideService(Path.Path, path),\n );\n return {\n deploymentName: news.deploymentName,\n keyId: 0,\n name,\n deployKey,\n allowedActions: news.allowedActions ?? [],\n } satisfies DeployKeyAttributes;\n }),\n delete: () => Effect.void,\n } satisfies Provider.ProviderServiceInput<DeployKey>;\n});\n\nexport const layer = Provider.effect(DeployKey, provider);\nexport const localLayer = Provider.effect(DeployKey, localProvider);\n"],"mappings":";;;;;;;;;;;;;AAuCA,MAAa,YAAY,SAAoB,kBAAkB;AAE/D,IAAa,4BAAb,cAA+C,OAAO,YAAuC,CAAC,CAC5F,6BACA;CACE,gBAAgB,OAAO;CACvB,MAAM,OAAO;CACb,QAAQ,OAAO,MAAM,OAAO,MAAM;AACpC,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,qCAAb,cAAwD,OAAO,YAAgD,CAAC,CAC9G,sCACA;CAAE,gBAAgB,OAAO;CAAQ,OAAO,OAAO;CAAQ,OAAO,OAAO;AAAO,CAC9E,CAAC,CAAC,CAAC;AAEH,MAAa,WAAW,OAAO,IAAI,aAAa;CAC9C,MAAM,SAAS,OAAO;CACtB,MAAM,WAAW,SAAiB,SAChC,YAAY,QACX,QAAQ,WAAW,GAAG,KAAK,GAAG,KAC7B,kBAAkB,KAAK,QAAQ,MAAM,KAAK,SAAS,CAAC,CAAC;CACzD,MAAM,WACJ,gBACA,MACA,WACG,IAAI,0BAA0B;EAAE;EAAgB;EAAM;CAAO,CAAC;CACnE,OAAO;EACL,MAAM,OAAO,GAAG,gBAAgB,CAAC,CAAC,WAAW,EAAE,MAAM,UAAU;GAC7D,IAAI,CAAC,WAAW,IAAI,KAAK,CAAC,QAAQ;GAClC,KAAK,MAAM,SAAS,CAAC,kBAAkB,MAAM,GAC3C,IAAI,KAAK,WAAW,KAAA,KAAa,KAAK,WAAW,OAAO,QACtD,OAAO,OAAO,IAAI,mCAAmC;IACnD,gBAAgB,OAAO;IACvB,OAAO,OAAO;IACd;GACF,CAAC;GAGL,MAAM,OAAM,OADQ,OAAO,eAAe,OAAO,cAAc,EAAA,CAC9C,MAAM,cAAc,UAAU,OAAO,OAAO,KAAK;GAClE,IAAI,CAAC,OAAO,CAAC,SAAS,WAAW,OAAO,SAAS,GAC/C,OAAO,OAAO,QAAQ,OAAO,gB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WAAW,YAAY,EAAE,GAC/C,OAAO,eAAe,KAAK,MAAM,IAAI,CACvC;GACA,OAAO;IACL,gBAAgB,KAAK;IACrB,OAAO;IACP;IACA;IACA,gBAAgB,KAAK,kBAAkB,CAAC;GAC1C;EACF,CAAC;EACD,cAAc,OAAO;CACvB;AACF,CAAC;AAED,MAAa,QAAQ,SAAS,OAAO,WAAW,QAAQ;AACxD,MAAa,aAAa,SAAS,OAAO,WAAW,aAAa"}
1
+ {"version":3,"file":"DeployKey.js","names":[],"sources":["../src/DeployKey.ts"],"sourcesContent":["import type { PlatformCreateDeployKeyArgs } from \"@convex-dev/platform/managementApi\";\nimport { isResolved } from \"alchemy/Diff\";\nimport * as Provider from \"alchemy/Provider\";\nimport { Resource } from \"alchemy/Resource\";\nimport * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport * as Redacted from \"effect/Redacted\";\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 } from \"./internal/Lifecycle.js\";\nimport { adminKey, dataDirectories } from \"./internal/LocalBackend.js\";\nimport * as String from \"effect/String\";\nimport { pipe } from \"effect/Function\";\nimport * as Option from \"effect/Option\";\nimport * as Array from \"effect/Array\";\n\nexport interface DeployKeyProps {\n readonly deploymentName: string;\n readonly name?: string;\n readonly allowedActions?: ReadonlyArray<\n NonNullable<PlatformCreateDeployKeyArgs[\"allowedActions\"]>[number]\n >;\n}\n\nexport interface DeployKeyAttributes {\n readonly deploymentName: string;\n readonly keyId: number;\n readonly name: string;\n readonly deployKey: Redacted.Redacted<string>;\n readonly allowedActions: ReadonlyArray<string>;\n}\n\nexport type DeployKey = Resource<\n \"Convex.DeployKey\",\n DeployKeyProps,\n DeployKeyAttributes,\n never,\n Providers\n>;\nexport const DeployKey = Resource<DeployKey>(\"Convex.DeployKey\");\n\nexport class DeployKeyRecoveryRequired extends Schema.TaggedError<\n DeployKeyRecoveryRequired,\n { readonly brand: unique symbol }\n>()(\"DeployKeyRecoveryRequired\", {\n deploymentName: Schema.String,\n keyName: Schema.String,\n keyIds: Schema.Array(Schema.Finite),\n}) {}\n\nexport class DeployKeyChangeRequiresNewResource extends Schema.TaggedError<\n DeployKeyChangeRequiresNewResource,\n { readonly brand: unique symbol }\n>()(\"DeployKeyChangeRequiresNewResource\", {\n deploymentName: Schema.String,\n keyId: Schema.Finite,\n field: Schema.String,\n}) {}\n\nexport const provider = Effect.gen(function* () {\n const client = yield* ConvexClient;\n const hasName = (keyName: string, name: string) =>\n keyName === name ||\n (pipe(keyName, String.startsWith(`${name} (`)) &&\n /^[0-9a-f]{8}\\)$/.test(pipe(keyName, String.slice(name.length + 2))));\n const recover = (\n deploymentName: string,\n name: string,\n keyIds: ReadonlyArray<number>,\n ) =>\n DeployKeyRecoveryRequired.make({ deploymentName, keyName: name, keyIds });\n return {\n diff: Effect.fn(\"DeployKey.diff\")(function* ({ news, output }) {\n if (!isResolved(news) || output === undefined) return;\n for (const field of [\"deploymentName\", \"name\"] as const) {\n if (news[field] !== undefined && news[field] !== output[field])\n return yield* DeployKeyChangeRequiresNewResource.make({\n deploymentName: output.deploymentName,\n keyId: output.keyId,\n field,\n });\n }\n const keys = yield* client.listDeployKeys(output.deploymentName);\n const key = Option.getOrUndefined(\n Array.findFirst(keys, (candidate) => candidate.id === output.keyId),\n );\n if (key === undefined || !Redacted.isRedacted(output.deployKey))\n return yield* recover(output.deploymentName, output.name, [\n output.keyId,\n ]);\n if (!hasName(key.name, news.name ?? output.name))\n return yield* DeployKeyChangeRequiresNewResource.make({\n deploymentName: output.deploymentName,\n keyId: output.keyId,\n field: \"name\",\n });\n const allowedActions = news.allowedActions ?? output.allowedActions;\n if (\n new Set(allowedActions).size !== new Set(key.allowedActions).size ||\n Array.some(\n allowedActions,\n (action) => !key.allowedActions.includes(action),\n )\n )\n return yield* DeployKeyChangeRequiresNewResource.make({\n deploymentName: output.deploymentName,\n keyId: output.keyId,\n field: \"allowedActions\",\n });\n }),\n read: Effect.fn(\"DeployKey.read\")(function* ({\n fqn,\n instanceId,\n olds,\n output,\n }) {\n const deploymentName = output?.deploymentName ?? olds.deploymentName;\n if (deploymentName === undefined) return;\n const name =\n output?.name ??\n olds.name ??\n (yield* resourceName(\"key\", fqn, instanceId));\n const keys = yield* client.listDeployKeys(deploymentName);\n if (output !== undefined) {\n const key = Option.getOrUndefined(\n Array.findFirst(keys, (candidate) => candidate.id === output.keyId),\n );\n if (key === undefined)\n return yield* recover(deploymentName, name, [output.keyId]);\n if (!Redacted.isRedacted(output.deployKey))\n return yield* recover(deploymentName, name, [key.id]);\n return {\n ...output,\n allowedActions: key.allowedActions,\n };\n }\n const matches = Array.filter(keys, (key) => hasName(key.name, name));\n if (matches.length > 0)\n return yield* recover(\n deploymentName,\n name,\n Array.map(matches, (candidate) => candidate.id),\n );\n return undefined;\n }),\n reconcile: Effect.fn(\"DeployKey.reconcile\")(function* ({\n fqn,\n instanceId,\n news,\n output,\n }) {\n if (output === undefined) yield* checkpointCreate(fqn, instanceId, news);\n const name =\n news.name ??\n output?.name ??\n (yield* resourceName(\"key\", fqn, instanceId));\n if (output !== undefined) {\n for (const field of [\"deploymentName\", \"name\"] as const) {\n if (news[field] !== undefined && news[field] !== output[field])\n return yield* DeployKeyChangeRequiresNewResource.make({\n deploymentName: output.deploymentName,\n keyId: output.keyId,\n field,\n });\n }\n const keys = yield* client.listDeployKeys(output.deploymentName);\n const key = Option.getOrUndefined(\n Array.findFirst(keys, (candidate) => candidate.id === output.keyId),\n );\n if (key === undefined || !Redacted.isRedacted(output.deployKey))\n return yield* recover(output.deploymentName, name, [output.keyId]);\n if (!hasName(key.name, name))\n return yield* DeployKeyChangeRequiresNewResource.make({\n deploymentName: output.deploymentName,\n keyId: output.keyId,\n field: \"name\",\n });\n const allowedActions = news.allowedActions ?? output.allowedActions;\n if (\n new Set(allowedActions).size !== new Set(key.allowedActions).size ||\n Array.some(\n allowedActions,\n (action) => !key.allowedActions.includes(action),\n )\n )\n return yield* DeployKeyChangeRequiresNewResource.make({\n deploymentName: output.deploymentName,\n keyId: output.keyId,\n field: \"allowedActions\",\n });\n return {\n ...output,\n allowedActions: key.allowedActions,\n };\n }\n const deployKeys = yield* client.listDeployKeys(news.deploymentName);\n const existing = Array.filter(deployKeys, (key) =>\n hasName(key.name, name),\n );\n if (existing.length > 0)\n return yield* recover(\n news.deploymentName,\n name,\n Array.map(existing, (key) => key.id),\n );\n const created = yield* client.createDeployKey(news.deploymentName, {\n name,\n ...(news.allowedActions === undefined\n ? {}\n : { allowedActions: [...news.allowedActions] }),\n });\n const deployKeys2 = yield* client.listDeployKeys(news.deploymentName);\n const matches = Array.filter(deployKeys2, (key) =>\n hasName(key.name, name),\n );\n const key = matches[0];\n if (matches.length !== 1 || key === undefined)\n return yield* recover(\n news.deploymentName,\n name,\n Array.map(matches, (candidate) => candidate.id),\n );\n return {\n deploymentName: news.deploymentName,\n keyId: key.id,\n name,\n deployKey: created.deployKey,\n allowedActions: key.allowedActions,\n };\n }),\n delete: Effect.fn(\"DeployKey.delete\")(function* ({ output }) {\n yield* client\n .deleteDeployKey(output.deploymentName, output.deployKey)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void));\n }),\n } satisfies Provider.ProviderServiceInput<DeployKey>;\n});\n\n/**\n * Under `alchemy dev` the deploy key is the admin key the local deployment\n * generated. It is read on every apply, so a recreated backend's new key\n * replaces the old one.\n *\n * @stability unstable\n */\nexport const localProvider = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const directory = yield* dataDirectories;\n return {\n diff: () => Effect.succeed({ action: \"update\" }),\n reconcile: Effect.fn(\"DeployKey.localReconcile\")(function* ({\n fqn,\n instanceId,\n news,\n }) {\n const name = news.name ?? (yield* resourceName(\"key\", fqn, instanceId));\n const deployKey = yield* adminKey(\n news.deploymentName,\n directory(news.deploymentName),\n ).pipe(\n Effect.provideService(FileSystem.FileSystem, fs),\n Effect.provideService(Path.Path, path),\n );\n return {\n deploymentName: news.deploymentName,\n keyId: 0,\n name,\n deployKey,\n allowedActions: news.allowedActions ?? [],\n } satisfies DeployKeyAttributes;\n }),\n delete: () => Effect.void,\n } satisfies Provider.ProviderServiceInput<DeployKey>;\n});\n\nexport const layer = Provider.effect(DeployKey, provider);\n/**\n * @stability unstable\n */\nexport const localLayer = Provider.effect(DeployKey, localProvider);\n"],"mappings":";;;;;;;;;;;;;;;;;AA2CA,MAAa,YAAY,SAAoB,kBAAkB;AAE/D,IAAa,4BAAb,cAA+C,OAAO,YAGpD,CAAC,CAAC,6BAA6B;CAC/B,gBAAgB,OAAO;CACvB,SAAS,OAAO;CAChB,QAAQ,OAAO,MAAM,OAAO,MAAM;AACpC,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,qCAAb,cAAwD,OAAO,YAG7D,CAAC,CAAC,sCAAsC;CACxC,gBAAgB,OAAO;CACvB,OAAO,OAAO;CACd,OAAO,OAAO;AAChB,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAa,WAAW,OAAO,IAAI,aAAa;CAC9C,MAAM,SAAS,OAAO;CACtB,MAAM,WAAW,SAAiB,SAChC,YAAY,QACX,KAAK,SAAS,OAAO,WAAW,GAAG,KAAK,GAAG,CAAC,KAC3C,kBAAkB,KAAK,KAAK,SAAS,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC;CACvE,MAAM,WACJ,gBACA,MACA,WAEA,0BAA0B,KAAK;EAAE;EAAgB,SAAS;EAAM;CAAO,CAAC;CAC1E,OAAO;EACL,MAAM,OAAO,GAAG,gBAAgB,CAAC,CAAC,WAAW,EAAE,MAAM,UAAU;GAC7D,IAAI,CAAC,WAAW,IAAI,KAAK,WAAW,KAAA,GAAW;GAC/C,KAAK,MAAM,SAAS,CAAC,kBAAkB,MAAM,GAC3C,IAAI,KAAK,WAAW,KAAA,KAA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D,KAAK,OAAO,SAAS,wBAAwB,OAAO,IAAI,CAAC;EAC9D,CAAC;CACH;AACF,CAAC;;;;;;;;AASD,MAAa,gBAAgB,OAAO,IAAI,aAAa;CACnD,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,YAAY,OAAO;CACzB,OAAO;EACL,YAAY,OAAO,QAAQ,EAAE,QAAQ,SAAS,CAAC;EAC/C,WAAW,OAAO,GAAG,0BAA0B,CAAC,CAAC,WAAW,EAC1D,KACA,YACA,QACC;GACD,MAAM,OAAO,KAAK,SAAS,OAAO,aAAa,OAAO,KAAK,UAAU;GACrE,MAAM,YAAY,OAAO,SACvB,KAAK,gBACL,UAAU,KAAK,cAAc,CAC/B,CAAC,CAAC,KACA,OAAO,eAAe,WAAW,YAAY,EAAE,GAC/C,OAAO,eAAe,KAAK,MAAM,IAAI,CACvC;GACA,OAAO;IACL,gBAAgB,KAAK;IACrB,OAAO;IACP;IACA;IACA,gBAAgB,KAAK,kBAAkB,CAAC;GAC1C;EACF,CAAC;EACD,cAAc,OAAO;CACvB;AACF,CAAC;AAED,MAAa,QAAQ,SAAS,OAAO,WAAW,QAAQ;;;;AAIxD,MAAa,aAAa,SAAS,OAAO,WAAW,aAAa"}
@@ -25,24 +25,30 @@ export interface DeploymentAttributes {
25
25
  readonly region?: RegionName;
26
26
  }
27
27
  export type Deployment = Resource<"Convex.Deployment", DeploymentProps, DeploymentAttributes, never, Providers>;
28
- export declare const Deployment: import("alchemy/Resource").ResourceClass<Deployment>;
28
+ export declare const Deployment: import("alchemy").ResourceClass<Deployment>;
29
29
  declare const DeploymentIdentityChange_base: Schema.Class<DeploymentIdentityChange, Schema.TaggedStruct<"DeploymentIdentityChange", {
30
30
  readonly deploymentName: Schema.String;
31
31
  readonly field: Schema.String;
32
32
  readonly current: Schema.String;
33
33
  readonly requested: Schema.String;
34
- }>, import("effect/Cause").YieldableError>;
34
+ }>, import("effect/Cause").YieldableError & {
35
+ readonly brand: unique symbol;
36
+ }>;
35
37
  export declare class DeploymentIdentityChange extends DeploymentIdentityChange_base {
36
38
  }
37
39
  declare const UnsupportedLocalDeployment_base: Schema.Class<UnsupportedLocalDeployment, Schema.TaggedStruct<"UnsupportedLocalDeployment", {
38
40
  readonly deploymentName: Schema.String;
39
- }>, import("effect/Cause").YieldableError>;
41
+ }>, import("effect/Cause").YieldableError & {
42
+ readonly brand: unique symbol;
43
+ }>;
40
44
  export declare class UnsupportedLocalDeployment extends UnsupportedLocalDeployment_base {
41
45
  }
42
46
  declare const AmbiguousDeployment_base: Schema.Class<AmbiguousDeployment, Schema.TaggedStruct<"AmbiguousDeployment", {
43
47
  readonly projectId: Schema.Finite;
44
48
  readonly reference: Schema.String;
45
- }>, import("effect/Cause").YieldableError>;
49
+ }>, import("effect/Cause").YieldableError & {
50
+ readonly brand: unique symbol;
51
+ }>;
46
52
  export declare class AmbiguousDeployment extends AmbiguousDeployment_base {
47
53
  }
48
54
  export declare const provider: Effect.Effect<{
@@ -51,9 +57,9 @@ export declare const provider: Effect.Effect<{
51
57
  fqn: string;
52
58
  instanceId: string;
53
59
  olds: DeploymentProps;
54
- news: import("alchemy/Input").Input<DeploymentProps>;
55
- oldBindings: import("alchemy/Resource").ResourceBinding<never>[];
56
- newBindings: import("alchemy/Input").Input<import("alchemy/Resource").ResourceBinding<never>[]>;
60
+ news: import("alchemy").Input<DeploymentProps>;
61
+ oldBindings: import("alchemy").ResourceBinding<never>[];
62
+ newBindings: import("alchemy").Input<import("alchemy").ResourceBinding<never>[]>;
57
63
  output: DeploymentAttributes | undefined;
58
64
  }) => Effect.Effect<{
59
65
  action: "update";
@@ -64,6 +70,7 @@ export declare const provider: Effect.Effect<{
64
70
  instanceId: string;
65
71
  olds: DeploymentProps;
66
72
  output: DeploymentAttributes | undefined;
73
+ previous?: DeploymentAttributes;
67
74
  }) => Effect.Effect<{
68
75
  projectId: number;
69
76
  name: string;
@@ -80,7 +87,7 @@ export declare const provider: Effect.Effect<{
80
87
  olds: DeploymentProps | undefined;
81
88
  output: DeploymentAttributes | undefined;
82
89
  session: import("alchemy/Report").ScopedPlanStatusSession;
83
- bindings: import("alchemy/Resource").ResourceBinding<never>[];
90
+ bindings: import("alchemy").ResourceBinding<never>[];
84
91
  }) => Effect.Effect<{
85
92
  projectId: number;
86
93
  name: string;
@@ -96,7 +103,7 @@ export declare const provider: Effect.Effect<{
96
103
  olds: DeploymentProps;
97
104
  output: DeploymentAttributes;
98
105
  session: import("alchemy/Report").ScopedPlanStatusSession;
99
- bindings: import("alchemy/Resource").ResourceBinding<never>[];
106
+ bindings: import("alchemy").ResourceBinding<never>[];
100
107
  force?: boolean;
101
108
  }) => Effect.Effect<void, import("./ConvexClient.js").ConvexApiError | import("./ConvexClient.js").ConvexConflict, never>;
102
109
  }, never, ConvexClient>;
@@ -106,8 +113,10 @@ export declare const provider: Effect.Effect<{
106
113
  * reloads of the stack and stops when the dev session ends. Its data lives in
107
114
  * `.alchemy/convex/<stack>/<stage>/<name>` and is removed only when the
108
115
  * deployment is destroyed.
116
+ *
117
+ * @stability unstable
109
118
  */
110
- export declare const localLayer: import("effect/Layer").Layer<Provider.Provider<Deployment>, never, import("alchemy/AlchemyContext").AlchemyContext | import("alchemy/Artifacts").ArtifactStore | import("effect/process/ChildProcessSpawner").ChildProcessSpawner | import("effect/Crypto").Crypto | FileSystem.FileSystem | import("effect/http/HttpClient").HttpClient | import("effect/Path").Path | import("alchemy/Stack").Stack>;
119
+ export declare const localLayer: import("effect/Layer").Layer<Provider.Provider<Deployment>, never, import("alchemy").AlchemyContext | import("alchemy/Artifacts").ArtifactStore | import("effect/process/ChildProcessSpawner").ChildProcessSpawner | FileSystem.FileSystem | import("effect/http/HttpClient").HttpClient | import("effect/Path").Path | import("effect/crypto/SecureRandom").SecureRandom | import("alchemy").Stack>;
111
120
  export declare const layer: import("effect/Layer").Layer<Provider.Provider<Deployment>, never, ConvexClient>;
112
121
  export {};
113
122
  //# sourceMappingURL=Deployment.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