@gaganref/confect-alchemy 10.3.1-fork.2 → 10.3.1-fork.20

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 (51) hide show
  1. package/dist/Backend.d.ts +3 -3
  2. package/dist/Backend.d.ts.map +1 -1
  3. package/dist/Backend.js.map +1 -1
  4. package/dist/Code.d.ts +5 -5
  5. package/dist/Code.d.ts.map +1 -1
  6. package/dist/Code.js.map +1 -1
  7. package/dist/Confect.d.ts +1 -1
  8. package/dist/Confect.d.ts.map +1 -1
  9. package/dist/Confect.js.map +1 -1
  10. package/dist/Convex.d.ts +6 -6
  11. package/dist/Convex.d.ts.map +1 -1
  12. package/dist/Convex.js.map +1 -1
  13. package/dist/ConvexClient.js.map +1 -1
  14. package/dist/DeployKey.d.ts +7 -7
  15. package/dist/DeployKey.d.ts.map +1 -1
  16. package/dist/DeployKey.js.map +1 -1
  17. package/dist/Deployment.d.ts +6 -6
  18. package/dist/Deployment.d.ts.map +1 -1
  19. package/dist/Deployment.js.map +1 -1
  20. package/dist/EnvironmentVariables.d.ts +4 -4
  21. package/dist/EnvironmentVariables.d.ts.map +1 -1
  22. package/dist/EnvironmentVariables.js.map +1 -1
  23. package/dist/Project.d.ts +6 -6
  24. package/dist/Project.d.ts.map +1 -1
  25. package/dist/Project.js.map +1 -1
  26. package/dist/Providers.js.map +1 -1
  27. package/dist/index.d.ts +2 -2
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/internal/CodeDeployment.d.ts +4 -4
  30. package/dist/internal/CodeDeployment.d.ts.map +1 -1
  31. package/dist/internal/CodeDeployment.js.map +1 -1
  32. package/dist/internal/LocalBackend.js.map +1 -1
  33. package/dist/internal/LocalSidecar.d.ts +1 -1
  34. package/dist/internal/LocalSidecar.js.map +1 -1
  35. package/dist/internal/PushLock.js.map +1 -1
  36. package/package.json +3 -3
  37. package/src/Backend.ts +2 -2
  38. package/src/Code.ts +7 -4
  39. package/src/Confect.ts +1 -1
  40. package/src/Convex.ts +10 -6
  41. package/src/ConvexClient.ts +1 -1
  42. package/src/DeployKey.ts +5 -5
  43. package/src/Deployment.ts +5 -5
  44. package/src/EnvironmentVariables.ts +3 -3
  45. package/src/Project.ts +4 -4
  46. package/src/Providers.ts +8 -8
  47. package/src/index.ts +2 -2
  48. package/src/internal/CodeDeployment.ts +4 -4
  49. package/src/internal/LocalBackend.ts +5 -5
  50. package/src/internal/LocalSidecar.ts +1 -1
  51. package/src/internal/PushLock.ts +2 -2
package/dist/Backend.d.ts CHANGED
@@ -3,8 +3,8 @@ import type { Input } from "alchemy/Input";
3
3
  import * as Output from "alchemy/Output";
4
4
  import * as Effect from "effect/Effect";
5
5
  import type * as Redacted from "effect/Redacted";
6
- import { Code } from "./Code";
7
- import { EnvironmentVariables } from "./EnvironmentVariables";
6
+ import { Code } from "./Code.js";
7
+ import { EnvironmentVariables } from "./EnvironmentVariables.js";
8
8
  interface CommonProps {
9
9
  readonly deployment: {
10
10
  readonly name: Input<string>;
@@ -40,6 +40,6 @@ declare const backend: (id: string, props: CommonProps & {
40
40
  environment: EnvironmentVariables | undefined;
41
41
  name: Output.Output<string, never>;
42
42
  url: Output.Output<string, never>;
43
- }, never, import("./Providers").Providers>;
43
+ }, never, import("./Providers.js").Providers>;
44
44
  export {};
45
45
  //# sourceMappingURL=Backend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Backend.d.ts","sourceRoot":"","sources":["../src/Backend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO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,CAAC;IAC1B,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CACrB,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAC1D,CAAC;CACH,CAAC,CAAC;AAEX;;GAEG;AACH,wBAAgB,OAAO,CACrB,KAAK,CAAC,CAAC,SAAS,QAAQ,CAAC,QAAQ,EACjC,KAAK,CAAC,CAAC,SAAS,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAEjE,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG;IACvB,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,GACd,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;CAC7D,GACA,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAC9B,wBAAgB,OAAO,CACrB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,YAAY,GAClB,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAY9B,QAAA,MAAM,OAAO,OACP,MAAM,SACH,WAAW,GAAG;IACnB,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CACrB,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAC1D,CAAC;CACH;;;;;6CA6BA,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Backend.js","names":[],"sources":["../src/Backend.ts"],"sourcesContent":["import type * as Manifest from \"@confect/core/Manifest\";\nimport type { Input } from \"alchemy/Input\";\nimport * as Namespace from \"alchemy/Namespace\";\nimport * as Output from \"alchemy/Output\";\nimport * as Effect from \"effect/Effect\";\nimport type * as Redacted from \"effect/Redacted\";\nimport { Code } from \"./Code\";\nimport { EnvironmentVariables } from \"./EnvironmentVariables\";\n\ninterface CommonProps {\n readonly deployment: {\n readonly name: Input<string>;\n readonly url: Input<string>;\n };\n readonly deployKey: Input<Redacted.Redacted<string>>;\n readonly cwd?: string;\n}\n\ntype Environment<M extends Manifest.Manifest> = {\n readonly [K in keyof Manifest.Values<M>]: Input<\n Exclude<Manifest.Values<M>[K], undefined>\n >;\n};\n\nexport type BackendProps<M extends Manifest.Manifest | undefined = undefined> =\n CommonProps &\n (M extends Manifest.Manifest\n ? { readonly manifest: M } & ({} extends Manifest.Values<M>\n ? { readonly env?: Environment<NoInfer<M>> }\n : { readonly env: Environment<NoInfer<M>> })\n : {\n readonly manifest?: never;\n readonly env?: Readonly<\n Record<string, Input<string | Redacted.Redacted<string>>>\n >;\n });\n\n/**\n * Deploy a declared backend with env typed by its generated manifest.\n */\nexport function Backend<\n const M extends Manifest.Manifest,\n const E extends Environment<NoInfer<M>> = Environment<NoInfer<M>>,\n>(\n id: string,\n props: BackendProps<M> & {\n readonly env?: E &\n Readonly<Record<Exclude<keyof E, keyof M[\"env\"]>, never>>;\n },\n): ReturnType<typeof backend>;\nexport function Backend(\n id: string,\n props: BackendProps,\n): ReturnType<typeof backend>;\nexport function Backend(\n id: string,\n props: CommonProps & {\n readonly env?: Readonly<\n Record<string, Input<string | Redacted.Redacted<string>>>\n >;\n },\n): ReturnType<typeof backend> {\n return backend(id, props);\n}\n\nconst backend = (\n id: string,\n props: CommonProps & {\n readonly env?: Readonly<\n Record<string, Input<string | Redacted.Redacted<string>>>\n >;\n },\n) =>\n Namespace.push(\n id,\n Effect.gen(function* () {\n const environment =\n props.env === undefined\n ? undefined\n : yield* EnvironmentVariables(\"Environment\", {\n url: props.deployment.url,\n deployKey: props.deployKey,\n variables: props.env,\n });\n const code = yield* Code(\"Code\", {\n deployment: {\n name: props.deployment.name,\n url: environment\n ? Output.map(\n Output.all(environment.variables, environment.url),\n ([, url]) => url,\n )\n : props.deployment.url,\n },\n deployKey: props.deployKey,\n ...(props.cwd === undefined ? {} : { cwd: props.cwd }),\n prepare: { command: \"confect\", args: [\"codegen\"] },\n });\n return { code, environment, name: code.name, url: code.url };\n }),\n );\n"],"mappings":";;;;;;AAsDA,SAAgB,QACd,IACA,OAK4B;CAC5B,OAAO,QAAQ,IAAI,KAAK;AAC1B;AAEA,MAAM,WACJ,IACA,UAMA,UAAU,KACR,IACA,OAAO,IAAI,aAAa;CACtB,MAAM,cACJ,MAAM,QAAQ,KAAA,IACV,KAAA,IACA,OAAO,qBAAqB,eAAe;EACzC,KAAK,MAAM,WAAW;EACtB,WAAW,MAAM;EACjB,WAAW,MAAM;CACnB,CAAC;CACP,MAAM,OAAO,OAAO,KAAK,QAAQ;EAC/B,YAAY;GACV,MAAM,MAAM,WAAW;GACvB,KAAK,cACD,OAAO,IACL,OAAO,IAAI,YAAY,WAAW,YAAY,GAAG,IAChD,GAAG,SAAS,GACf,IACA,MAAM,WAAW;EACvB;EACA,WAAW,MAAM;EACjB,GAAI,MAAM,QAAQ,KAAA,IAAY,CAAC,IAAI,EAAE,KAAK,MAAM,IAAI;EACpD,SAAS;GAAE,SAAS;GAAW,MAAM,CAAC,SAAS;EAAE;CACnD,CAAC;CACD,OAAO;EAAE;EAAM;EAAa,MAAM,KAAK;EAAM,KAAK,KAAK;CAAI;AAC7D,CAAC,CACH"}
1
+ {"version":3,"file":"Backend.js","names":[],"sources":["../src/Backend.ts"],"sourcesContent":["import type * as Manifest from \"@confect/core/Manifest\";\nimport type { Input } from \"alchemy/Input\";\nimport * as Namespace from \"alchemy/Namespace\";\nimport * as Output from \"alchemy/Output\";\nimport * as Effect from \"effect/Effect\";\nimport type * as Redacted from \"effect/Redacted\";\nimport { Code } from \"./Code.js\";\nimport { EnvironmentVariables } from \"./EnvironmentVariables.js\";\n\ninterface CommonProps {\n readonly deployment: {\n readonly name: Input<string>;\n readonly url: Input<string>;\n };\n readonly deployKey: Input<Redacted.Redacted<string>>;\n readonly cwd?: string;\n}\n\ntype Environment<M extends Manifest.Manifest> = {\n readonly [K in keyof Manifest.Values<M>]: Input<\n Exclude<Manifest.Values<M>[K], undefined>\n >;\n};\n\nexport type BackendProps<M extends Manifest.Manifest | undefined = undefined> =\n CommonProps &\n (M extends Manifest.Manifest\n ? { readonly manifest: M } & ({} extends Manifest.Values<M>\n ? { readonly env?: Environment<NoInfer<M>> }\n : { readonly env: Environment<NoInfer<M>> })\n : {\n readonly manifest?: never;\n readonly env?: Readonly<\n Record<string, Input<string | Redacted.Redacted<string>>>\n >;\n });\n\n/**\n * Deploy a declared backend with env typed by its generated manifest.\n */\nexport function Backend<\n const M extends Manifest.Manifest,\n const E extends Environment<NoInfer<M>> = Environment<NoInfer<M>>,\n>(\n id: string,\n props: BackendProps<M> & {\n readonly env?: E &\n Readonly<Record<Exclude<keyof E, keyof M[\"env\"]>, never>>;\n },\n): ReturnType<typeof backend>;\nexport function Backend(\n id: string,\n props: BackendProps,\n): ReturnType<typeof backend>;\nexport function Backend(\n id: string,\n props: CommonProps & {\n readonly env?: Readonly<\n Record<string, Input<string | Redacted.Redacted<string>>>\n >;\n },\n): ReturnType<typeof backend> {\n return backend(id, props);\n}\n\nconst backend = (\n id: string,\n props: CommonProps & {\n readonly env?: Readonly<\n Record<string, Input<string | Redacted.Redacted<string>>>\n >;\n },\n) =>\n Namespace.push(\n id,\n Effect.gen(function* () {\n const environment =\n props.env === undefined\n ? undefined\n : yield* EnvironmentVariables(\"Environment\", {\n url: props.deployment.url,\n deployKey: props.deployKey,\n variables: props.env,\n });\n const code = yield* Code(\"Code\", {\n deployment: {\n name: props.deployment.name,\n url: environment\n ? Output.map(\n Output.all(environment.variables, environment.url),\n ([, url]) => url,\n )\n : props.deployment.url,\n },\n deployKey: props.deployKey,\n ...(props.cwd === undefined ? {} : { cwd: props.cwd }),\n prepare: { command: \"confect\", args: [\"codegen\"] },\n });\n return { code, environment, name: code.name, url: code.url };\n }),\n );\n"],"mappings":";;;;;;AAsDA,SAAgB,QACd,IACA,OAK4B;CAC5B,OAAO,QAAQ,IAAI,KAAK;AAC1B;AAEA,MAAM,WACJ,IACA,UAMA,UAAU,KACR,IACA,OAAO,IAAI,aAAa;CACtB,MAAM,cACJ,MAAM,QAAQ,KAAA,IACV,KAAA,IACA,OAAO,qBAAqB,eAAe;EACzC,KAAK,MAAM,WAAW;EACtB,WAAW,MAAM;EACjB,WAAW,MAAM;CACnB,CAAC;CACP,MAAM,OAAO,OAAO,KAAK,QAAQ;EAC/B,YAAY;GACV,MAAM,MAAM,WAAW;GACvB,KAAK,cACD,OAAO,IACL,OAAO,IAAI,YAAY,WAAW,YAAY,GAAG,IAChD,GAAG,SAAS,GACf,IACA,MAAM,WAAW;EACvB;EACA,WAAW,MAAM;EACjB,GAAI,MAAM,QAAQ,KAAA,IAAY,CAAC,IAAI,EAAE,KAAK,MAAM,IAAI;EACpD,SAAS;GAAE,SAAS;GAAW,MAAM,CAAC,SAAS;EAAE;CACnD,CAAC;CACD,OAAO;EAAE;EAAM;EAAa,MAAM,KAAK;EAAM,KAAK,KAAK;CAAI;AAC7D,CAAC,CACH"}
package/dist/Code.d.ts CHANGED
@@ -2,9 +2,9 @@ import * as Provider from "alchemy/Provider";
2
2
  import { Resource } from "alchemy/Resource";
3
3
  import * as Effect from "effect/Effect";
4
4
  import type * as Redacted from "effect/Redacted";
5
- import type { Providers } from "./Providers";
6
- import { CommandRunner, type PrepareCommand } from "./internal/CommandRunner";
7
- import { PushLock } from "./internal/PushLock";
5
+ import type { Providers } from "./Providers.js";
6
+ import { CommandRunner, type PrepareCommand } from "./internal/CommandRunner.js";
7
+ import { PushLock } from "./internal/PushLock.js";
8
8
  export interface CodeProps {
9
9
  readonly deployment: {
10
10
  readonly name: string;
@@ -43,7 +43,7 @@ export declare const provider: Effect.Effect<{
43
43
  }) => Effect.Effect<{
44
44
  name: string;
45
45
  url: string;
46
- }, import("./internal/CommandRunner").CommandError | import("./internal/CodeDeployment").InvalidDeploymentTarget | import("./internal/PushLock").PushLockError, never>;
46
+ }, import("./internal/CommandRunner.js").CommandError | import("./internal/CodeDeployment.js").InvalidDeploymentTarget | import("./internal/PushLock.js").PushLockError, never>;
47
47
  delete: () => Effect.Effect<void, never, never>;
48
48
  }, never, CommandRunner | PushLock>;
49
49
  /**
@@ -72,7 +72,7 @@ export declare const localProvider: Effect.Effect<{
72
72
  }) => Effect.Effect<{
73
73
  name: string;
74
74
  url: string;
75
- }, import("./internal/CommandRunner").CommandError | import("./internal/CodeDeployment").InvalidDeploymentTarget | import("./internal/PushLock").PushLockError, never>;
75
+ }, import("./internal/CommandRunner.js").CommandError | import("./internal/CodeDeployment.js").InvalidDeploymentTarget | import("./internal/PushLock.js").PushLockError, never>;
76
76
  delete: () => Effect.Effect<void, never, never>;
77
77
  }, never, CommandRunner | PushLock>;
78
78
  export declare const layer: import("effect/Layer").Layer<Provider.Provider<Code>, never, CommandRunner | PushLock>;
@@ -1 +1 @@
1
- {"version":3,"file":"Code.d.ts","sourceRoot":"","sources":["../src/Code.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,UAAU,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACrE,QAAQ,CAAC,SAAS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C;IACrE,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;CACnC;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,IAAI,GAAG,QAAQ,CACzB,aAAa,EACb,SAAS,EACT,cAAc,EACd,KAAK,EACL,SAAS,CACV,CAAC;AACF,eAAO,MAAM,IAAI,gDAAgC,CAAC;AAkBlD,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;mCAAe,CAAC;AACrC;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;mCAAgB,CAAC;AAE3C,eAAO,MAAM,KAAK,wFAAkC,CAAC;AACrD,eAAO,MAAM,UAAU,wFAAuC,CAAC"}
package/dist/Code.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Code.js","names":[],"sources":["../src/Code.ts"],"sourcesContent":["import * as Provider from \"alchemy/Provider\";\nimport type { ProviderMode } from \"alchemy/ProviderMode\";\nimport { Resource } from \"alchemy/Resource\";\nimport * as Effect from \"effect/Effect\";\nimport type * as Redacted from \"effect/Redacted\";\nimport type { Providers } from \"./Providers\";\nimport { deploy } from \"./internal/CodeDeployment\";\nimport { CommandRunner, type PrepareCommand } from \"./internal/CommandRunner\";\nimport { PushLock } from \"./internal/PushLock\";\n\nexport interface CodeProps {\n readonly deployment: { readonly name: string; readonly url: string };\n readonly deployKey: Redacted.Redacted<string>;\n readonly cwd?: string;\n readonly prepare?: PrepareCommand;\n}\n\nexport interface CodeAttributes {\n readonly name: string;\n readonly url: string;\n}\n\nexport type Code = Resource<\n \"Convex.Code\",\n CodeProps,\n CodeAttributes,\n never,\n Providers\n>;\nexport const Code = Resource<Code>(\"Convex.Code\");\n\nconst make = (mode: ProviderMode) =>\n Effect.gen(function* () {\n const runner = yield* CommandRunner;\n const lock = yield* PushLock;\n return {\n read: ({ output }) => Effect.succeed(output),\n diff: () => Effect.succeed({ action: \"update\" }),\n reconcile: ({ news }) =>\n deploy(news, mode).pipe(\n Effect.provideService(CommandRunner, runner),\n Effect.provideService(PushLock, lock),\n ),\n delete: () => Effect.void,\n } satisfies Provider.ProviderServiceInput<Code>;\n });\n\nexport const provider = make(\"live\");\n/**\n * Under `alchemy dev`, pushes go to the local backend's self-hosted target.\n */\nexport const localProvider = make(\"local\");\n\nexport const layer = Provider.effect(Code, provider);\nexport const localLayer = Provider.effect(Code, localProvider);\n"],"mappings":";;;;;;;AA6BA,MAAa,OAAO,SAAe,aAAa;AAEhD,MAAM,QAAQ,SACZ,OAAO,IAAI,aAAa;CACtB,MAAM,SAAS,OAAO;CACtB,MAAM,OAAO,OAAO;CACpB,OAAO;EACL,OAAO,EAAE,aAAa,OAAO,QAAQ,MAAM;EAC3C,YAAY,OAAO,QAAQ,EAAE,QAAQ,SAAS,CAAC;EAC/C,YAAY,EAAE,WACZ,OAAO,MAAM,IAAI,CAAC,CAAC,KACjB,OAAO,eAAe,eAAe,MAAM,GAC3C,OAAO,eAAe,UAAU,IAAI,CACtC;EACF,cAAc,OAAO;CACvB;AACF,CAAC;AAEH,MAAa,WAAW,KAAK,MAAM;;;;AAInC,MAAa,gBAAgB,KAAK,OAAO;AAEzC,MAAa,QAAQ,SAAS,OAAO,MAAM,QAAQ;AACnD,MAAa,aAAa,SAAS,OAAO,MAAM,aAAa"}
1
+ {"version":3,"file":"Code.js","names":[],"sources":["../src/Code.ts"],"sourcesContent":["import * as Provider from \"alchemy/Provider\";\nimport type { ProviderMode } from \"alchemy/ProviderMode\";\nimport { Resource } from \"alchemy/Resource\";\nimport * as Effect from \"effect/Effect\";\nimport type * as Redacted from \"effect/Redacted\";\nimport type { Providers } from \"./Providers.js\";\nimport { deploy } from \"./internal/CodeDeployment.js\";\nimport {\n CommandRunner,\n type PrepareCommand,\n} from \"./internal/CommandRunner.js\";\nimport { PushLock } from \"./internal/PushLock.js\";\n\nexport interface CodeProps {\n readonly deployment: { readonly name: string; readonly url: string };\n readonly deployKey: Redacted.Redacted<string>;\n readonly cwd?: string;\n readonly prepare?: PrepareCommand;\n}\n\nexport interface CodeAttributes {\n readonly name: string;\n readonly url: string;\n}\n\nexport type Code = Resource<\n \"Convex.Code\",\n CodeProps,\n CodeAttributes,\n never,\n Providers\n>;\nexport const Code = Resource<Code>(\"Convex.Code\");\n\nconst make = (mode: ProviderMode) =>\n Effect.gen(function* () {\n const runner = yield* CommandRunner;\n const lock = yield* PushLock;\n return {\n read: ({ output }) => Effect.succeed(output),\n diff: () => Effect.succeed({ action: \"update\" }),\n reconcile: ({ news }) =>\n deploy(news, mode).pipe(\n Effect.provideService(CommandRunner, runner),\n Effect.provideService(PushLock, lock),\n ),\n delete: () => Effect.void,\n } satisfies Provider.ProviderServiceInput<Code>;\n });\n\nexport const provider = make(\"live\");\n/**\n * Under `alchemy dev`, pushes go to the local backend's self-hosted target.\n */\nexport const localProvider = make(\"local\");\n\nexport const layer = Provider.effect(Code, provider);\nexport const localLayer = Provider.effect(Code, localProvider);\n"],"mappings":";;;;;;;AAgCA,MAAa,OAAO,SAAe,aAAa;AAEhD,MAAM,QAAQ,SACZ,OAAO,IAAI,aAAa;CACtB,MAAM,SAAS,OAAO;CACtB,MAAM,OAAO,OAAO;CACpB,OAAO;EACL,OAAO,EAAE,aAAa,OAAO,QAAQ,MAAM;EAC3C,YAAY,OAAO,QAAQ,EAAE,QAAQ,SAAS,CAAC;EAC/C,YAAY,EAAE,WACZ,OAAO,MAAM,IAAI,CAAC,CAAC,KACjB,OAAO,eAAe,eAAe,MAAM,GAC3C,OAAO,eAAe,UAAU,IAAI,CACtC;EACF,cAAc,OAAO;CACvB;AACF,CAAC;AAEH,MAAa,WAAW,KAAK,MAAM;;;;AAInC,MAAa,gBAAgB,KAAK,OAAO;AAEzC,MAAa,QAAQ,SAAS,OAAO,MAAM,QAAQ;AACnD,MAAa,aAAa,SAAS,OAAO,MAAM,aAAa"}
package/dist/Confect.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { Backend, type BackendProps } from "./Backend";
1
+ export { Backend, type BackendProps } from "./Backend.js";
2
2
  //# sourceMappingURL=Confect.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Confect.d.ts","sourceRoot":"","sources":["../src/Confect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"Confect.d.ts","sourceRoot":"","sources":["../src/Confect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Confect.js","names":[],"sources":["../src/Confect.ts"],"sourcesContent":["export { Backend, type BackendProps } from \"./Backend\";\n"],"mappings":""}
1
+ {"version":3,"file":"Confect.js","names":[],"sources":["../src/Confect.ts"],"sourcesContent":["export { Backend, type BackendProps } from \"./Backend.js\";\n"],"mappings":""}
package/dist/Convex.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { Project, type ProjectProps, type ProjectAttributes } from "./Project";
2
- export { Deployment, type DeploymentProps, type DeploymentAttributes, } from "./Deployment";
3
- export { DeployKey, type DeployKeyProps, type DeployKeyAttributes, } from "./DeployKey";
4
- export { EnvironmentVariables, type EnvironmentVariablesProps, type EnvironmentVariablesAttributes, } from "./EnvironmentVariables";
5
- export { Code, type CodeProps, type CodeAttributes } from "./Code";
6
- export { providers, Providers } from "./Providers";
1
+ export { Project, type ProjectProps, type ProjectAttributes, } from "./Project.js";
2
+ export { Deployment, type DeploymentProps, type DeploymentAttributes, } from "./Deployment.js";
3
+ export { DeployKey, type DeployKeyProps, type DeployKeyAttributes, } from "./DeployKey.js";
4
+ export { EnvironmentVariables, type EnvironmentVariablesProps, type EnvironmentVariablesAttributes, } from "./EnvironmentVariables.js";
5
+ export { Code, type CodeProps, type CodeAttributes } from "./Code.js";
6
+ export { providers, Providers } from "./Providers.js";
7
7
  //# sourceMappingURL=Convex.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Convex.d.ts","sourceRoot":"","sources":["../src/Convex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC/E,OAAO,EACL,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,oBAAoB,GAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,SAAS,EACT,KAAK,cAAc,EACnB,KAAK,mBAAmB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,8BAA8B,GACpC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"Convex.d.ts","sourceRoot":"","sources":["../src/Convex.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,KAAK,YAAY,EACjB,KAAK,iBAAiB,GACvB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,oBAAoB,GAC1B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,SAAS,EACT,KAAK,cAAc,EACnB,KAAK,mBAAmB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,8BAA8B,GACpC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Convex.js","names":[],"sources":["../src/Convex.ts"],"sourcesContent":["export { Project, type ProjectProps, type ProjectAttributes } from \"./Project\";\nexport {\n Deployment,\n type DeploymentProps,\n type DeploymentAttributes,\n} from \"./Deployment\";\nexport {\n DeployKey,\n type DeployKeyProps,\n type DeployKeyAttributes,\n} from \"./DeployKey\";\nexport {\n EnvironmentVariables,\n type EnvironmentVariablesProps,\n type EnvironmentVariablesAttributes,\n} from \"./EnvironmentVariables\";\nexport { Code, type CodeProps, type CodeAttributes } from \"./Code\";\nexport { providers, Providers } from \"./Providers\";\n"],"mappings":""}
1
+ {"version":3,"file":"Convex.js","names":[],"sources":["../src/Convex.ts"],"sourcesContent":["export {\n Project,\n type ProjectProps,\n type ProjectAttributes,\n} from \"./Project.js\";\nexport {\n Deployment,\n type DeploymentProps,\n type DeploymentAttributes,\n} from \"./Deployment.js\";\nexport {\n DeployKey,\n type DeployKeyProps,\n type DeployKeyAttributes,\n} from \"./DeployKey.js\";\nexport {\n EnvironmentVariables,\n type EnvironmentVariablesProps,\n type EnvironmentVariablesAttributes,\n} from \"./EnvironmentVariables.js\";\nexport { Code, type CodeProps, type CodeAttributes } from \"./Code.js\";\nexport { providers, Providers } from \"./Providers.js\";\n"],"mappings":""}
@@ -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\";\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\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 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(ConvexClient, make(options).pipe(Effect.map(ConvexClient.of)));\n"],"mappings":";;;;;;;;;;;AA+DA,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,YAA4B,CAAC,CACtE,kBACA,WACF,CAAC,CAAC,CAAC;AAEH,IAAa,iBAAb,cAAoC,OAAO,YAA4B,CAAC,CACtE,kBACA,WACF,CAAC,CAAC,CAAC;AAEH,IAAa,iBAAb,cAAoC,OAAO,YAA4B,CAAC,CACtE,kBACA,WACF,CAAC,CAAC,CAAC;AAOH,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,YAAY,OAAO,OAAO,OAAO,MAAM,CAAC;CACnE,mBAAmB,OAAO,YAAY,OAAO,OAAO,OAAO,MAAM,CAAC;AACpE,CAAC;AAED,MAAM,uBAAuB,OAAO,OAAO;CACzC,IAAI,OAAO;CACX,WAAW,OAAO;CAClB,MAAM,OAAO;CACb,gBAAgB,OAAO,YAAY,OAAO,OAAO,OAAO,MAAM,CAAC;CAC/D,eAAe,OAAO,YAAY,OAAO,OAAO,OAAO,MAAM,CAAC;AAChE,CAAC;AAED,MAAM,mBAAmB;CACvB,MAAM,OAAO;CACb,YA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,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,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\";\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\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 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(ConvexClient, make(options).pipe(Effect.map(ConvexClient.of)));\n"],"mappings":";;;;;;;;;;;AA+DA,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,YAA4B,CAAC,CACtE,kBACA,WACF,CAAC,CAAC,CAAC;AAEH,IAAa,iBAAb,cAAoC,OAAO,YAA4B,CAAC,CACtE,kBACA,WACF,CAAC,CAAC,CAAC;AAEH,IAAa,iBAAb,cAAoC,OAAO,YAA4B,CAAC,CACtE,kBACA,WACF,CAAC,CAAC,CAAC;AAOH,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,YAAY,OAAO,OAAO,OAAO,MAAM,CAAC;CACnE,mBAAmB,OAAO,YAAY,OAAO,OAAO,OAAO,MAAM,CAAC;AACpE,CAAC;AAED,MAAM,uBAAuB,OAAO,OAAO;CACzC,IAAI,OAAO;CACX,WAAW,OAAO;CAClB,MAAM,OAAO;CACb,gBAAgB,OAAO,YAAY,OAAO,OAAO,OAAO,MAAM,CAAC;CAC/D,eAAe,OAAO,YAAY,OAAO,OAAO,OAAO,MAAM,CAAC;AAChE,CAAC;AAED,MAAM,mBAAmB;CACvB,MAAM,OAA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AAG,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,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"}
@@ -6,8 +6,8 @@ import * as FileSystem from "effect/FileSystem";
6
6
  import * as Path from "effect/Path";
7
7
  import * as Redacted from "effect/Redacted";
8
8
  import * as Schema from "effect/Schema";
9
- import { ConvexClient } from "./ConvexClient";
10
- import type { Providers } from "./Providers";
9
+ import { ConvexClient } from "./ConvexClient.js";
10
+ import type { Providers } from "./Providers.js";
11
11
  export interface DeployKeyProps {
12
12
  readonly deploymentName: string;
13
13
  readonly name?: string;
@@ -46,7 +46,7 @@ export declare const provider: Effect.Effect<{
46
46
  oldBindings: import("alchemy/Resource").ResourceBinding<never>[];
47
47
  newBindings: import("alchemy/Input").Input<import("alchemy/Resource").ResourceBinding<never>[]>;
48
48
  output: DeployKeyAttributes | undefined;
49
- }) => Effect.Effect<undefined, import("./ConvexClient").ConvexApiError | import("./ConvexClient").ConvexConflict | import("./ConvexClient").ConvexNotFound | DeployKeyChangeRequiresNewResource | DeployKeyRecoveryRequired, never>;
49
+ }) => Effect.Effect<undefined, import("./ConvexClient.js").ConvexApiError | import("./ConvexClient.js").ConvexConflict | import("./ConvexClient.js").ConvexNotFound | DeployKeyChangeRequiresNewResource | DeployKeyRecoveryRequired, never>;
50
50
  read: (args_0: {
51
51
  id: string;
52
52
  fqn: string;
@@ -59,7 +59,7 @@ export declare const provider: Effect.Effect<{
59
59
  name: string;
60
60
  deployKey: Redacted.Redacted<string>;
61
61
  allowedActions: readonly string[];
62
- } | undefined, import("./ConvexClient").ConvexApiError | import("./ConvexClient").ConvexConflict | import("./ConvexClient").ConvexNotFound | DeployKeyRecoveryRequired, never>;
62
+ } | undefined, import("./ConvexClient.js").ConvexApiError | import("./ConvexClient.js").ConvexConflict | import("./ConvexClient.js").ConvexNotFound | DeployKeyRecoveryRequired, never>;
63
63
  reconcile: (args_0: {
64
64
  id: string;
65
65
  fqn: string;
@@ -75,7 +75,7 @@ export declare const provider: Effect.Effect<{
75
75
  name: string;
76
76
  deployKey: Redacted.Redacted<string>;
77
77
  allowedActions: readonly string[];
78
- }, DeployKeyChangeRequiresNewResource | DeployKeyRecoveryRequired | import("./internal/Lifecycle").LifecycleStateError | import("alchemy/State/State").StateStoreError | import("./ConvexClient").ConvexClientError, never>;
78
+ }, DeployKeyChangeRequiresNewResource | DeployKeyRecoveryRequired | import("./internal/Lifecycle.js").LifecycleStateError | import("alchemy/State/State").StateStoreError | import("./ConvexClient.js").ConvexClientError, never>;
79
79
  delete: (args_0: {
80
80
  id: string;
81
81
  fqn: string;
@@ -85,7 +85,7 @@ export declare const provider: Effect.Effect<{
85
85
  session: import("alchemy/Report").ScopedPlanStatusSession;
86
86
  bindings: import("alchemy/Resource").ResourceBinding<never>[];
87
87
  force?: boolean;
88
- }) => Effect.Effect<void, import("./ConvexClient").ConvexApiError | import("./ConvexClient").ConvexConflict, never>;
88
+ }) => Effect.Effect<void, import("./ConvexClient.js").ConvexApiError | import("./ConvexClient.js").ConvexConflict, never>;
89
89
  }, never, ConvexClient>;
90
90
  /**
91
91
  * Under `alchemy dev` the deploy key is the admin key the local deployment
@@ -111,7 +111,7 @@ export declare const localProvider: Effect.Effect<{
111
111
  name: string;
112
112
  deployKey: Redacted.Redacted<string>;
113
113
  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
- }, import("./internal/LocalBackend").LocalBackendError, never>;
114
+ }, import("./internal/LocalBackend.js").LocalBackendError, never>;
115
115
  delete: () => Effect.Effect<void, never, never>;
116
116
  }, never, FileSystem.FileSystem | Path.Path | import("alchemy/Stack").Stack>;
117
117
  export declare const layer: import("effect/Layer").Layer<Provider.Provider<DeployKey>, never, ConvexClient>;
@@ -1 +1 @@
1
- {"version":3,"file":"DeployKey.d.ts","sourceRoot":"","sources":["../src/DeployKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAEtF,OAAO,KAAK,QAAQ,MAAM,kBAAkB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AM,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,qDAA0C,CAAC;;;;;;AAEjE,qBAAa,yBAA0B,SAAQ,8BAO9C;CAAG;;;;;;AAEJ,qBAAa,kCAAmC,SAAQ,uCAGvD;CAAG;AAEJ,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;wBA9BM,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;;;;;;;;;;;;;uBA4L7C,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;4EA6BxB,CAAC;AAEH,eAAO,MAAM,KAAK,iFAAuC,CAAC;AAC1D,eAAO,MAAM,UAAU,sIAA4C,CAAC"}
@@ -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\";\nimport type { Providers } from \"./Providers\";\nimport { resourceName } from \"./internal/ResourceIdentity\";\nimport { checkpointCreate } from \"./internal/Lifecycle\";\nimport { adminKey, dataDirectories } from \"./internal/LocalBackend\";\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,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CAAC;CACH;AACF,CAAC;;;;;;AAOD,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;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\";\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,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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;AACxD,MAAa,aAAa,SAAS,OAAO,WAAW,aAAa"}
@@ -5,8 +5,8 @@ import { Resource } from "alchemy/Resource";
5
5
  import * as Effect from "effect/Effect";
6
6
  import * as FileSystem from "effect/FileSystem";
7
7
  import * as Schema from "effect/Schema";
8
- import { ConvexClient } from "./ConvexClient";
9
- import type { Providers } from "./Providers";
8
+ import { ConvexClient } from "./ConvexClient.js";
9
+ import type { Providers } from "./Providers.js";
10
10
  export interface DeploymentProps {
11
11
  readonly projectId: number;
12
12
  readonly type: CreateDeploymentType;
@@ -57,7 +57,7 @@ export declare const provider: Effect.Effect<{
57
57
  output: DeploymentAttributes | undefined;
58
58
  }) => Effect.Effect<{
59
59
  action: "update";
60
- } | undefined, import("./ConvexClient").ConvexApiError | import("./ConvexClient").ConvexConflict | DeploymentIdentityChange | UnsupportedLocalDeployment, never>;
60
+ } | undefined, import("./ConvexClient.js").ConvexApiError | import("./ConvexClient.js").ConvexConflict | DeploymentIdentityChange | UnsupportedLocalDeployment, never>;
61
61
  read: (args_0: {
62
62
  id: string;
63
63
  fqn: string;
@@ -71,7 +71,7 @@ export declare const provider: Effect.Effect<{
71
71
  type: "custom" | "dev" | "preview" | "prod";
72
72
  url: string;
73
73
  region: "aws-ap-southeast-2" | "aws-ca-central-1" | "aws-eu-west-1" | "aws-us-east-1";
74
- } | undefined, AmbiguousDeployment | import("./ConvexClient").ConvexApiError | import("./ConvexClient").ConvexConflict | import("./ConvexClient").ConvexNotFound | UnsupportedLocalDeployment, never>;
74
+ } | undefined, AmbiguousDeployment | import("./ConvexClient.js").ConvexApiError | import("./ConvexClient.js").ConvexConflict | import("./ConvexClient.js").ConvexNotFound | UnsupportedLocalDeployment, never>;
75
75
  reconcile: (args_0: {
76
76
  id: string;
77
77
  fqn: string;
@@ -88,7 +88,7 @@ export declare const provider: Effect.Effect<{
88
88
  type: "custom" | "dev" | "preview" | "prod";
89
89
  url: string;
90
90
  region: "aws-ap-southeast-2" | "aws-ca-central-1" | "aws-eu-west-1" | "aws-us-east-1";
91
- }, AmbiguousDeployment | import("./ConvexClient").ConvexApiError | import("./ConvexClient").ConvexConflict | import("./ConvexClient").ConvexNotFound | DeploymentIdentityChange | import("./internal/Lifecycle").LifecycleStateError | OwnedBySomeoneElse | import("alchemy/State/State").StateStoreError | UnsupportedLocalDeployment, never>;
91
+ }, AmbiguousDeployment | import("./ConvexClient.js").ConvexApiError | import("./ConvexClient.js").ConvexConflict | import("./ConvexClient.js").ConvexNotFound | DeploymentIdentityChange | import("./internal/Lifecycle.js").LifecycleStateError | OwnedBySomeoneElse | import("alchemy/State/State").StateStoreError | UnsupportedLocalDeployment, never>;
92
92
  delete: (args_0: {
93
93
  id: string;
94
94
  fqn: string;
@@ -98,7 +98,7 @@ export declare const provider: Effect.Effect<{
98
98
  session: import("alchemy/Report").ScopedPlanStatusSession;
99
99
  bindings: import("alchemy/Resource").ResourceBinding<never>[];
100
100
  force?: boolean;
101
- }) => Effect.Effect<void, import("./ConvexClient").ConvexApiError | import("./ConvexClient").ConvexConflict, never>;
101
+ }) => Effect.Effect<void, import("./ConvexClient.js").ConvexApiError | import("./ConvexClient.js").ConvexConflict, never>;
102
102
  }, never, ConvexClient>;
103
103
  /**
104
104
  * Under `alchemy dev` a deployment is a local Convex backend this provider
@@ -1 +1 @@
1
- {"version":3,"file":"Deployment.d.ts","sourceRoot":"","sources":["../src/Deployment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,UAAU,EACX,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAW,MAAM,qBAAqB,CAAC;AAGlE,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAK7C,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;CAC9B;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACpC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;CAC9B;AAED,MAAM,MAAM,UAAU,GAAG,QAAQ,CAC/B,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,KA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CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACpC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;CAC9B;AAED,MAAM,MAAM,UAAU,GAAG,QAAQ,CAC/B,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,KAAK,EACL,SAAS,CACV,CAAC;AACF,eAAO,MAAM,UAAU,sDAErB,CAAC;;;;;;;AAEH,qBAAa,wBAAyB,SAAQ,6BAQ7C;CAAG;;;;AAEJ,qBAAa,0BAA2B,SAAQ,+BAG/C;CAAG;;;;;AAEJ,qBAAa,mBAAoB,SAAQ,wBAGxC;CAAG;AAEJ,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAyInB,CAAC;AAOH;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,wYAoDtB,CAAC;AAEF,eAAO,MAAM,KAAK,kFAAwC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Deployment.js","names":[],"sources":["../src/Deployment.ts"],"sourcesContent":["import type {\n CreateDeploymentType,\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\";\nimport type { Providers } from \"./Providers\";\nimport { resourceName } from \"./internal/ResourceIdentity\";\nimport { checkpointCreate, shouldAdopt } from \"./internal/Lifecycle\";\nimport { boot, dataDirectories, remove } from \"./internal/LocalBackend\";\n\nexport interface DeploymentProps {\n readonly projectId: number;\n readonly type: CreateDeploymentType;\n readonly reference?: string;\n readonly region?: RegionName;\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\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<DeploymentIdentityChange>()(\n \"DeploymentIdentityChange\",\n {\n deploymentName: Schema.String,\n field: Schema.String,\n current: Schema.String,\n requested: Schema.String,\n },\n) {}\n\nexport class UnsupportedLocalDeployment extends Schema.TaggedError<UnsupportedLocalDeployment>()(\n \"UnsupportedLocalDeployment\",\n { deploymentName: Schema.String },\n) {}\n\nexport class AmbiguousDeployment extends Schema.TaggedError<AmbiguousDeployment>()(\n \"AmbiguousDeployment\",\n { projectId: Schema.Finite, 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* new UnsupportedLocalDeployment({\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 } satisfies DeploymentAttributes;\n });\n const find = Effect.fn(\"Deployment.find\")(function* (\n projectId: number,\n reference: string,\n ) {\n const matches = (yield* client.listDeployments(projectId)).filter(\n (deployment) =>\n deployment.kind === \"cloud\" && deployment.reference === reference,\n );\n if (matches.length > 1)\n return yield* new AmbiguousDeployment({ 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* new DeploymentIdentityChange({\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) 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) return { action: \"update\" };\n const current = yield* attributes(deployment);\n yield* validate(current, news);\n if ((news.reference ?? output.reference) !== current.reference)\n return { action: \"update\" };\n }),\n read: Effect.fn(\"Deployment.read\")(function* ({\n fqn,\n instanceId,\n olds,\n output,\n }) {\n if (output) {\n const deployment = yield* client\n .getDeployment(output.name)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void));\n return deployment ? yield* attributes(deployment) : 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 ? Unowned(yield* attributes(deployment)) : undefined;\n }),\n reconcile: Effect.fn(\"Deployment.reconcile\")(function* ({\n fqn,\n instanceId,\n news,\n output,\n }) {\n if (!output) yield* checkpointCreate(fqn, instanceId, news);\n if (output) yield* validate(output, news);\n let deployment = output\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) {\n const existing = yield* find(news.projectId, reference);\n if (existing && !(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) {\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 });\n }\n }\n const current = yield* attributes(deployment);\n yield* validate(current, news);\n if (current.reference !== reference) {\n const existing = yield* find(news.projectId, reference);\n if (existing && 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 yield* client.updateDeployment(current.name, {\n reference,\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: DeploymentProps;\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 */\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 return {\n name: yield* resourceName(\"deployment\", fqn, instanceId),\n props: news,\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+CA,MAAa,aAAa,SAAqB,qBAAqB,EAClE,sBAAsB,SACxB,CAAC;AAED,IAAa,2BAAb,cAA8C,OAAO,YAAsC,CAAC,CAC1F,4BACA;CACE,gBAAgB,OAAO;CACvB,OAAO,OAAO;CACd,SAAS,OAAO;CAChB,WAAW,OAAO;AACpB,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,6BAAb,cAAgD,OAAO,YAAwC,CAAC,CAC9F,8BACA,EAAE,gBAAgB,OAAO,OAAO,CAClC,CAAC,CAAC,CAAC;AAEH,IAAa,sBAAb,cAAyC,OAAO,YAAiC,CAAC,CAChF,uBACA;CAAE,WAAW,OAAO;CAAQ,WAAW,OAAO;AAAO,CACvD,CAAC,CAAC,CAAC;AAEH,MAAa,WAAW,OAAO,IAAI,aAAa;CAC9C,MAAM,SAAS,OAAO;CACtB,MAAM,aAAa,OAAO,GAAG,uBAAuB,CAAC,CAAC,WACpD,YACA;EACA,IAAI,WAAW,SAAS,SACtB,OAAO,OAAO,IAAI,2BAA2B,EAC3C,gBAAgB,WAAW,KAC7B,CAAC;EACH,OAAO;GACL,WAAW,WAAW;GACtB,MAAM,WAAW;G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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 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\";\n\nexport interface DeploymentProps {\n readonly projectId: number;\n readonly type: CreateDeploymentType;\n readonly reference?: string;\n readonly region?: RegionName;\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\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<DeploymentIdentityChange>()(\n \"DeploymentIdentityChange\",\n {\n deploymentName: Schema.String,\n field: Schema.String,\n current: Schema.String,\n requested: Schema.String,\n },\n) {}\n\nexport class UnsupportedLocalDeployment extends Schema.TaggedError<UnsupportedLocalDeployment>()(\n \"UnsupportedLocalDeployment\",\n { deploymentName: Schema.String },\n) {}\n\nexport class AmbiguousDeployment extends Schema.TaggedError<AmbiguousDeployment>()(\n \"AmbiguousDeployment\",\n { projectId: Schema.Finite, 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* new UnsupportedLocalDeployment({\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 } satisfies DeploymentAttributes;\n });\n const find = Effect.fn(\"Deployment.find\")(function* (\n projectId: number,\n reference: string,\n ) {\n const matches = (yield* client.listDeployments(projectId)).filter(\n (deployment) =>\n deployment.kind === \"cloud\" && deployment.reference === reference,\n );\n if (matches.length > 1)\n return yield* new AmbiguousDeployment({ 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* new DeploymentIdentityChange({\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) 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) return { action: \"update\" };\n const current = yield* attributes(deployment);\n yield* validate(current, news);\n if ((news.reference ?? output.reference) !== current.reference)\n return { action: \"update\" };\n }),\n read: Effect.fn(\"Deployment.read\")(function* ({\n fqn,\n instanceId,\n olds,\n output,\n }) {\n if (output) {\n const deployment = yield* client\n .getDeployment(output.name)\n .pipe(Effect.catchTag(\"ConvexNotFound\", () => Effect.void));\n return deployment ? yield* attributes(deployment) : 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 ? Unowned(yield* attributes(deployment)) : undefined;\n }),\n reconcile: Effect.fn(\"Deployment.reconcile\")(function* ({\n fqn,\n instanceId,\n news,\n output,\n }) {\n if (!output) yield* checkpointCreate(fqn, instanceId, news);\n if (output) yield* validate(output, news);\n let deployment = output\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) {\n const existing = yield* find(news.projectId, reference);\n if (existing && !(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) {\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 });\n }\n }\n const current = yield* attributes(deployment);\n yield* validate(current, news);\n if (current.reference !== reference) {\n const existing = yield* find(news.projectId, reference);\n if (existing && 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 yield* client.updateDeployment(current.name, {\n reference,\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: DeploymentProps;\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 */\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 return {\n name: yield* resourceName(\"deployment\", fqn, instanceId),\n props: news,\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+CA,MAAa,aAAa,SAAqB,qBAAqB,EAClE,sBAAsB,SACxB,CAAC;AAED,IAAa,2BAAb,cAA8C,OAAO,YAAsC,CAAC,CAC1F,4BACA;CACE,gBAAgB,OAAO;CACvB,OAAO,OAAO;CACd,SAAS,OAAO;CAChB,WAAW,OAAO;AACpB,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,6BAAb,cAAgD,OAAO,YAAwC,CAAC,CAC9F,8BACA,EAAE,gBAAgB,OAAO,OAAO,CAClC,CAAC,CAAC,CAAC;AAEH,IAAa,sBAAb,cAAyC,OAAO,YAAiC,CAAC,CAChF,uBACA;CAAE,WAAW,OAAO;CAAQ,WAAW,OAAO;AAAO,CACvD,CAAC,CAAC,CAAC;AAEH,MAAa,WAAW,OAAO,IAAI,aAAa;CAC9C,MAAM,SAAS,OAAO;CACtB,MAAM,aAAa,OAAO,GAAG,uBAAuB,CAAC,CAAC,WACpD,YACA;EACA,IAAI,WAAW,SAAS,SACtB,OAAO,OAAO,IAAI,2BAA2B,EAC3C,gBAAgB,WAAW,KAC7B,CAAC;EACH,OAAO;GACL,WAAW,WAAW;GACtB,MAAM,WAAW;GACjB,WAAW,WAAW;GACtB,MAAM,WAAW;GACjB,KAAK,WAAW;GAChB,QAAQ,WAAW;EACrB;CACF,CAAC;CACD,MAAM,OAAO,OAAO,GAAG,iBAAiB,CAAC,CAAC,WACxC,WACA,WACA;EACA,MAAM,WAAW,OAAO,OAAO,gBAAgB,SAAS,EAAA,CAAG,QACxD,eACC,WAAW,SAAS,WAAW,WAAW,cAAc,SAC5D;EACA,IAAI,QAAQ,SAAS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c,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"}
@@ -5,8 +5,8 @@ import * as Effect from "effect/Effect";
5
5
  import * as Layer from "effect/Layer";
6
6
  import * as Redacted from "effect/Redacted";
7
7
  import * as Schema from "effect/Schema";
8
- import * as ConvexClient from "./ConvexClient";
9
- import type { Providers } from "./Providers";
8
+ import * as ConvexClient from "./ConvexClient.js";
9
+ import type { Providers } from "./Providers.js";
10
10
  export interface EnvironmentVariablesProps {
11
11
  readonly url: string;
12
12
  readonly deployKey: Redacted.Redacted<string>;
@@ -73,7 +73,7 @@ export declare const provider: Effect.Effect<{
73
73
  originals: {
74
74
  [k: string]: Redacted.Redacted<string>;
75
75
  };
76
- }, ConvexClient.ConvexApiError | ConvexClient.ConvexConflict | ConvexClient.ConvexNotFound | EnvironmentTargetChange | import("./internal/Lifecycle").LifecycleStateError | OwnedBySomeoneElse | import("alchemy/State/State").StateStoreError, never>;
76
+ }, ConvexClient.ConvexApiError | ConvexClient.ConvexConflict | ConvexClient.ConvexNotFound | EnvironmentTargetChange | import("./internal/Lifecycle.js").LifecycleStateError | OwnedBySomeoneElse | import("alchemy/State/State").StateStoreError, never>;
77
77
  delete: (args_0: {
78
78
  id: string;
79
79
  fqn: string;
@@ -137,7 +137,7 @@ export declare const localProvider: Effect.Effect<{
137
137
  originals: {
138
138
  [k: string]: Redacted.Redacted<string>;
139
139
  };
140
- }, ConvexClient.ConvexApiError | ConvexClient.ConvexConflict | ConvexClient.ConvexNotFound | EnvironmentTargetChange | import("./internal/Lifecycle").LifecycleStateError | OwnedBySomeoneElse | import("alchemy/State/State").StateStoreError, never>;
140
+ }, ConvexClient.ConvexApiError | ConvexClient.ConvexConflict | ConvexClient.ConvexNotFound | EnvironmentTargetChange | import("./internal/Lifecycle.js").LifecycleStateError | OwnedBySomeoneElse | import("alchemy/State/State").StateStoreError, never>;
141
141
  delete: (input: {
142
142
  id: string;
143
143
  fqn: string;