@samebase/alchemy-convex 0.1.0 → 0.3.0

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 (54) hide show
  1. package/README.md +246 -55
  2. package/lib/index.d.ts +510 -9
  3. package/lib/index.d.ts.map +1 -1
  4. package/lib/index.js +1411 -10
  5. package/lib/index.js.map +1 -1
  6. package/package.json +8 -5
  7. package/src/Adoption.ts +30 -0
  8. package/src/Code.ts +463 -0
  9. package/src/DefaultEnvironmentVariable.ts +127 -29
  10. package/src/Deploy.ts +47 -35
  11. package/src/DeployKey.ts +221 -60
  12. package/src/Deployment.ts +409 -0
  13. package/src/EnvironmentVariable.ts +204 -44
  14. package/src/ManagementApi.ts +57 -1
  15. package/src/PreviewDeployKey.ts +65 -38
  16. package/src/Project.ts +236 -52
  17. package/src/Providers.ts +9 -1
  18. package/src/index.ts +29 -1
  19. package/lib/Credentials.d.ts +0 -39
  20. package/lib/Credentials.d.ts.map +0 -1
  21. package/lib/Credentials.js +0 -49
  22. package/lib/Credentials.js.map +0 -1
  23. package/lib/DefaultEnvironmentVariable.d.ts +0 -58
  24. package/lib/DefaultEnvironmentVariable.d.ts.map +0 -1
  25. package/lib/DefaultEnvironmentVariable.js +0 -93
  26. package/lib/DefaultEnvironmentVariable.js.map +0 -1
  27. package/lib/Deploy.d.ts +0 -62
  28. package/lib/Deploy.d.ts.map +0 -1
  29. package/lib/Deploy.js +0 -92
  30. package/lib/Deploy.js.map +0 -1
  31. package/lib/DeployKey.d.ts +0 -48
  32. package/lib/DeployKey.d.ts.map +0 -1
  33. package/lib/DeployKey.js +0 -104
  34. package/lib/DeployKey.js.map +0 -1
  35. package/lib/EnvironmentVariable.d.ts +0 -37
  36. package/lib/EnvironmentVariable.d.ts.map +0 -1
  37. package/lib/EnvironmentVariable.js +0 -65
  38. package/lib/EnvironmentVariable.js.map +0 -1
  39. package/lib/ManagementApi.d.ts +0 -50
  40. package/lib/ManagementApi.d.ts.map +0 -1
  41. package/lib/ManagementApi.js +0 -103
  42. package/lib/ManagementApi.js.map +0 -1
  43. package/lib/PreviewDeployKey.d.ts +0 -34
  44. package/lib/PreviewDeployKey.d.ts.map +0 -1
  45. package/lib/PreviewDeployKey.js +0 -78
  46. package/lib/PreviewDeployKey.js.map +0 -1
  47. package/lib/Project.d.ts +0 -29
  48. package/lib/Project.d.ts.map +0 -1
  49. package/lib/Project.js +0 -114
  50. package/lib/Project.js.map +0 -1
  51. package/lib/Providers.d.ts +0 -13
  52. package/lib/Providers.d.ts.map +0 -1
  53. package/lib/Providers.js +0 -30
  54. package/lib/Providers.js.map +0 -1
@@ -1,93 +0,0 @@
1
- // Convex.DefaultEnvironmentVariable: a project default environment variable
2
- // for one deployment type. Convex sets it on each new deployment of that type,
3
- // such as auth keys that every pull request preview deployment needs.
4
- //
5
- // Defaults live on the Management API and authenticate with the team
6
- // credential, not with a deploy key. Setting a default and removing it are the
7
- // same call: update_default_environment_variables with `value: null` removes
8
- // the default, and removing an absent default also answers 200.
9
- import { Resource } from "alchemy";
10
- import { isResolved } from "alchemy/Diff";
11
- import * as Provider from "alchemy/Provider";
12
- import * as Effect from "effect/Effect";
13
- import * as Redacted from "effect/Redacted";
14
- import * as Schema from "effect/Schema";
15
- import { absentAsUndefined, ManagementApi } from "./ManagementApi.js";
16
- /**
17
- * Attributes when the listing has `name` for `deploymentType`. An unfiltered
18
- * listing merges the deployment types that share one value into one row, so
19
- * the match checks membership in `deploymentTypes`.
20
- */
21
- export const findDefault = (list, projectId, name, deploymentType) => list.items.some((item) => item.name === name && item.deploymentTypes.includes(deploymentType))
22
- ? { projectId, name, deploymentType }
23
- : undefined;
24
- /**
25
- * Lists the defaults named `name` for `deploymentType`. Convex filters on
26
- * both, so the listing has at most one row and needs no pagination.
27
- */
28
- export const listDefaults = (api, projectId, name, deploymentType) => api
29
- .request("list default environment variables", (client) => client.GET("/projects/{project_id}/list_default_environment_variables", {
30
- params: { path: { project_id: projectId }, query: { name, deploymentType } },
31
- }))
32
- .pipe(Effect.map((body) => Schema.decodeUnknownSync(DefaultEnvironmentVariableList)(body)));
33
- /**
34
- * Sets one default, or removes it when `value` is null. Convex answers 200
35
- * with an empty body, so this reads no response data.
36
- */
37
- export const updateDefault = (api, projectId, name, deploymentType, value) => api.requestVoid("update default environment variables", (client) => client.POST("/projects/{project_id}/update_default_environment_variables", {
38
- params: { path: { project_id: projectId } },
39
- body: {
40
- changes: [
41
- {
42
- name,
43
- deploymentType,
44
- value: Redacted.isRedacted(value) ? Redacted.value(value) : value,
45
- },
46
- ],
47
- },
48
- }));
49
- /**
50
- * GET /projects/{project_id}/list_default_environment_variables. Only the
51
- * fields the provider uses: the row's `value` is the secret in plain text.
52
- */
53
- export const DefaultEnvironmentVariableList = Schema.Struct({
54
- items: Schema.Array(Schema.Struct({ name: Schema.String, deploymentTypes: Schema.Array(Schema.String) })),
55
- });
56
- export const DefaultEnvironmentVariable = Resource("Convex.DefaultEnvironmentVariable");
57
- export const DefaultEnvironmentVariableProvider = () => Provider.effect(DefaultEnvironmentVariable, Effect.gen(function* () {
58
- const api = yield* ManagementApi;
59
- return {
60
- stables: ["projectId", "name", "deploymentType"],
61
- diff: ({ olds, news }) => {
62
- if (!isResolved(news))
63
- return Effect.succeed(undefined);
64
- // Otherwise undefined: the engine updates when any prop changed and
65
- // compares a Redacted value by content.
66
- return Effect.succeed(olds.projectId !== news.projectId ||
67
- olds.name !== news.name ||
68
- olds.deploymentType !== news.deploymentType
69
- ? { action: "replace" }
70
- : undefined);
71
- },
72
- read: Effect.fn(function* ({ olds }) {
73
- // 404 ProjectNotFound: the project no longer exists, so neither does the default.
74
- const list = yield* absentAsUndefined(listDefaults(api, olds.projectId, olds.name, olds.deploymentType));
75
- if (list === undefined)
76
- return undefined;
77
- return findDefault(list, olds.projectId, olds.name, olds.deploymentType);
78
- }),
79
- reconcile: Effect.fn(function* ({ news }) {
80
- yield* updateDefault(api, news.projectId, news.name, news.deploymentType, news.value);
81
- return {
82
- projectId: news.projectId,
83
- name: news.name,
84
- deploymentType: news.deploymentType,
85
- };
86
- }),
87
- delete: Effect.fn(function* ({ output }) {
88
- // Removing an absent default succeeds; 404 ProjectNotFound means the project is gone.
89
- yield* absentAsUndefined(updateDefault(api, output.projectId, output.name, output.deploymentType, null));
90
- }),
91
- };
92
- }));
93
- //# sourceMappingURL=DefaultEnvironmentVariable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DefaultEnvironmentVariable.js","sourceRoot":"","sources":["../src/DefaultEnvironmentVariable.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,+EAA+E;AAC/E,sEAAsE;AACtE,EAAE;AACF,qEAAqE;AACrE,+EAA+E;AAC/E,6EAA6E;AAC7E,gEAAgE;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAA6B,MAAM,oBAAoB,CAAC;AAMjG;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,IAAgD,EAChD,SAAiB,EACjB,IAAY,EACZ,cAA8B,EACoB,EAAE,CACpD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IAC5F,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,cAAc,EAAE;IACrC,CAAC,CAAC,SAAS,CAAC;AAEhB;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CA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AS,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAC3E,CAAC,CAAC;QAEF,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE;YACtC,KAAK,CAAC,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YACtF,OAAO;gBACL,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,cAAc,EAAE,IAAI,CAAC,cAAc;aACpC,CAAC;QACJ,CAAC,CAAC;QAEF,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE;YACrC,sFAAsF;YACtF,KAAK,CAAC,CAAC,iBAAiB,CACtB,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,cAAc,EAAE,IAAI,CAAC,CAC/E,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;AACJ,CAAC,CAAC,CACH,CAAC"}
package/lib/Deploy.d.ts DELETED
@@ -1,62 +0,0 @@
1
- import { Resource } from "alchemy";
2
- import { CommandExecutor, type CommandRunProps } from "alchemy/Command";
3
- import { type MemoOptions } from "alchemy/Command/Memo";
4
- import * as Provider from "alchemy/Provider";
5
- import type * as Redacted from "effect/Redacted";
6
- import type { Providers } from "./Providers.ts";
7
- export interface DeployProps extends Pick<CommandRunProps, "cwd" | "env" | "timeout"> {
8
- /**
9
- * Deploy key that selects the target deployment: a production, development,
10
- * project, or preview deploy key. The CLI receives it as `CONVEX_DEPLOY_KEY`,
11
- * and Alchemy removes its value from the logged output.
12
- */
13
- readonly deployKey: Redacted.Redacted<string>;
14
- /**
15
- * Preview deployment name for a preview deploy key. The CLI reuses an
16
- * existing preview deployment with this name.
17
- */
18
- readonly previewName?: string;
19
- /**
20
- * Like {@link previewName}, but the CLI deletes and recreates an existing
21
- * preview deployment with this name, so every run gets a new URL.
22
- */
23
- readonly previewCreate?: string;
24
- /**
25
- * Function to run after the push, such as `init:seed`. The CLI runs it only
26
- * when the push created a new preview deployment.
27
- */
28
- readonly previewRun?: string;
29
- /**
30
- * More `convex deploy` flags, added after the preview flags. Alchemy splits
31
- * the command on whitespace, so an argument cannot contain whitespace: use
32
- * `--typecheck=disable`, not `--typecheck disable` as one argument.
33
- */
34
- readonly extraArgs?: readonly string[];
35
- /**
36
- * Files hashed to skip an unchanged push. By default every non-gitignored
37
- * file under `cwd` and the nearest lockfile. Use
38
- * `{ include: ["convex/**"], lockfile: true }` to ignore frontend changes,
39
- * or `false` to push on every deploy.
40
- * @default true
41
- */
42
- readonly memo?: MemoOptions | boolean;
43
- }
44
- export interface DeployAttributes {
45
- /** Client URL of the deployment that received the push, such as `https://happy-otter-123.convex.cloud`. */
46
- readonly url: string;
47
- /** First label of the URL host, such as `happy-otter-123`. */
48
- readonly deploymentName: string;
49
- /** Hash of the memoized input files after the push, or `undefined` when `memo` is `false`. */
50
- readonly hash: string | undefined;
51
- }
52
- export type Deploy = Resource<"Convex.Deploy", DeployProps, DeployAttributes, never, Providers>;
53
- export declare const Deploy: import("alchemy").ResourceClass<Deploy>;
54
- /** Reads the deployment URL from `convex deploy` output. ANSI escape codes are removed first. */
55
- export declare const parseDeployOutput: (text: string) => {
56
- url: string;
57
- deploymentName: string;
58
- } | undefined;
59
- /** The `convex deploy` argv, starting with `npx`. */
60
- export declare const deployArgs: (props: Pick<DeployProps, "previewName" | "previewCreate" | "previewRun" | "extraArgs">) => readonly string[];
61
- export declare const DeployProvider: () => import("effect/Layer").Layer<Provider.Provider<Deploy>, never, import("effect/FileSystem").FileSystem | import("effect/Path").Path | CommandExecutor>;
62
- //# sourceMappingURL=Deploy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,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K,EAAE,SAAS,CAAC,CAAC;AAChG,eAAO,MAAM,MAAM,yCAAoC,CAAC;AAWxD,iGAAiG;AACjG,eAAO,MAAM,iBAAiB,GAC5B,MAAM,MAAM,KACX;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GAAG,SAK5C,CAAC;AAEF,qDAAqD;AACrD,eAAO,MAAM,UAAU,GACrB,OAAO,IAAI,CAAC,WAAW,EAAE,aAAa,GAAG,eAAe,GAAG,YAAY,GAAG,WAAW,CAAC,KACrF,SAAS,MAAM,EAQjB,CAAC;AAKF,eAAO,MAAM,cAAc,6JAqExB,CAAC"}
package/lib/Deploy.js DELETED
@@ -1,92 +0,0 @@
1
- // Convex.Deploy: pushes the functions in a `convex/` directory with
2
- // `npx convex deploy` and exposes the deployment URL for a frontend build.
3
- //
4
- // The deployment itself belongs to the project, so delete leaves the last
5
- // pushed functions running. The URL comes from the CLI's own output because
6
- // the deploy key, not this resource, decides which deployment receives the push.
7
- import { stripVTControlCharacters } from "node:util";
8
- import { Resource } from "alchemy";
9
- import { CommandExecutor } from "alchemy/Command";
10
- import { hashDirectory } from "alchemy/Command/Memo";
11
- import { havePropsChanged, isResolved } from "alchemy/Diff";
12
- import * as Provider from "alchemy/Provider";
13
- import * as Effect from "effect/Effect";
14
- export const Deploy = Resource("Convex.Deploy");
15
- /**
16
- * The CLI prints this line with `logFinishedStep` after the push succeeds, to
17
- * stderr (convex 1.45 `cli/lib/deploy2.js` for existing deployments,
18
- * `cli/deploy.js` for preview deployments). The host is
19
- * `<deployment>.convex.cloud` or `<deployment>.<region>.convex.cloud`.
20
- */
21
- const DEPLOYED_LINE = /Deployed Convex functions to (https:\/\/([a-z0-9]+(?:-[a-z0-9]+)*)(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)?\.convex\.cloud)\/?(?=\s|$)/m;
22
- /** Reads the deployment URL from `convex deploy` output. ANSI escape codes are removed first. */
23
- export const parseDeployOutput = (text) => {
24
- const match = DEPLOYED_LINE.exec(stripVTControlCharacters(text));
25
- const url = match?.[1];
26
- const deploymentName = match?.[2];
27
- return url === undefined || deploymentName === undefined ? undefined : { url, deploymentName };
28
- };
29
- /** The `convex deploy` argv, starting with `npx`. */
30
- export const deployArgs = (props) => [
31
- "npx",
32
- "convex",
33
- "deploy",
34
- ...(props.previewName === undefined ? [] : ["--preview-name", props.previewName]),
35
- ...(props.previewCreate === undefined ? [] : ["--preview-create", props.previewCreate]),
36
- ...(props.previewRun === undefined ? [] : ["--preview-run", props.previewRun]),
37
- ...(props.extraArgs ?? []),
38
- ];
39
- /** Number of output lines quoted when the CLI exits 0 without the deployed line. */
40
- const OUTPUT_TAIL_LINES = 20;
41
- export const DeployProvider = () => Provider.effect(Deploy, Effect.gen(function* () {
42
- const { run } = yield* CommandExecutor;
43
- const hashOf = (props) => props.memo === false
44
- ? Effect.succeed(undefined)
45
- : hashDirectory({
46
- ...(props.cwd === undefined ? {} : { cwd: props.cwd }),
47
- memo: props.memo === true || props.memo === undefined ? {} : props.memo,
48
- });
49
- return {
50
- // No `stables`: the same deploy key can push to a different URL. A
51
- // project deploy key follows the project's default production
52
- // deployment, and a preview deployment can expire or be recreated
53
- // under the same name.
54
- diff: Effect.fn(function* ({ olds, news, output }) {
55
- if (!isResolved(news))
56
- return undefined;
57
- if (output === undefined || output.hash === undefined || havePropsChanged(olds, news)) {
58
- return { action: "update" };
59
- }
60
- return { action: (yield* hashOf(news)) === output.hash ? "noop" : "update" };
61
- }),
62
- reconcile: Effect.fn(function* ({ news, session }) {
63
- const args = deployArgs(news);
64
- const spaced = args.find((arg) => /\s/.test(arg));
65
- if (spaced !== undefined) {
66
- return yield* Effect.die(new Error(`Convex.Deploy argument "${spaced}" contains whitespace; Alchemy splits commands on whitespace`));
67
- }
68
- // A push is idempotent: the CLI uploads the full function set every time.
69
- const { stdout, stderr } = yield* run({
70
- command: args.join(" "),
71
- ...(news.cwd === undefined ? {} : { cwd: news.cwd }),
72
- ...(news.timeout === undefined ? {} : { timeout: news.timeout }),
73
- env: { ...news.env, CONVEX_DEPLOY_KEY: news.deployKey },
74
- }, session);
75
- // `run` returns output with the deploy key already replaced.
76
- const output = `${stdout}\n${stderr}`;
77
- const deployed = parseDeployOutput(output);
78
- if (deployed === undefined) {
79
- const tail = stripVTControlCharacters(output)
80
- .split(/\r?\n|\r/)
81
- .filter((line) => line.trim() !== "")
82
- .slice(-OUTPUT_TAIL_LINES)
83
- .join("\n");
84
- return yield* Effect.die(new Error(`npx convex deploy exited 0 but printed no "Deployed Convex functions to <url>" line. Last output:\n${tail}`));
85
- }
86
- return { ...deployed, hash: yield* hashOf(news) };
87
- }),
88
- // The deployment belongs to the project; its functions stay deployed.
89
- delete: () => Effect.void,
90
- };
91
- }));
92
- //# sourceMappingURL=Deploy.js.map
package/lib/Deploy.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"Deploy.js","sourceRoot":"","sources":["../src/Deploy.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,2EAA2E;AAC3E,EAAE;AACF,0EAA0E;AAC1E,4EAA4E;AAC5E,iFAAiF;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,eAAe,EAAwB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAoB,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAoDxC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAS,eAAe,CAAC,CAAC;AAExD;;;;;GAKG;AACH,MAAM,aAAa,GACjB,+HAA+H,CAAC;AAElI,iGAAiG;AACjG,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC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;qBACzB,IAAI,CAAC,IAAI,CAAC,CAAC;gBACd,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CACtB,IAAI,KAAK,CACP,sGAAsG,IAAI,EAAE,CAC7G,CACF,CAAC;YACJ,CAAC;YACD,OAAO,EAAE,GAAG,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QACpD,CAAC,CAAC;QAEF,sEAAsE;QACtE,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI;KAC1B,CAAC;AACJ,CAAC,CAAC,CACH,CAAC"}
@@ -1,48 +0,0 @@
1
- import { Resource } from "alchemy";
2
- import * as Provider from "alchemy/Provider";
3
- import * as Redacted from "effect/Redacted";
4
- import * as Schema from "effect/Schema";
5
- import type { components } from "@convex-dev/platform/managementApi";
6
- import { ManagementApi } from "./ManagementApi.ts";
7
- import type { Providers } from "./Providers.ts";
8
- /** Actions a deploy key can be limited to, from the generated schema. */
9
- export type DeployKeyAction = NonNullable<components["schemas"]["PlatformCreateDeployKeyArgs"]["allowedActions"]>[number];
10
- /**
11
- * The listed key that a create call for `name` just made. The newest match
12
- * wins: an earlier attempt that failed before Alchemy saved state can leave
13
- * another key with the same requested name, and its secret is lost.
14
- */
15
- export declare const selectCreatedKey: (entries: ReadonlyArray<typeof ListedKey.Type>, name: string) => typeof ListedKey.Type | undefined;
16
- /** One row of list_deploy_keys and list_preview_deploy_keys. Only the fields the providers use. */
17
- export declare const ListedKey: Schema.Struct<{
18
- readonly name: Schema.String;
19
- readonly creationTime: Schema.Number;
20
- }>;
21
- /** GET /deployments/{deployment_name}/list_deploy_keys */
22
- export declare const DeployKeyList: Schema.$Array<Schema.Struct<{
23
- readonly name: Schema.String;
24
- readonly creationTime: Schema.Number;
25
- }>>;
26
- /** POST /deployments/{deployment_name}/create_deploy_key */
27
- export declare const CreatedDeployKey: Schema.Struct<{
28
- readonly deployKey: Schema.String;
29
- }>;
30
- export interface DeployKeyProps {
31
- /** Deployment name, such as `project.prodDeploymentName`. */
32
- readonly deployment: string;
33
- /** Requested key name. Convex appends a short id to make it unique. */
34
- readonly name: string;
35
- /** Limits the key to these actions. Convex grants every deployment action when omitted. */
36
- readonly allowedActions?: readonly DeployKeyAction[];
37
- }
38
- export interface DeployKeyAttributes {
39
- /** The name Convex lists the key under, such as "my-key (0e71106d)". */
40
- readonly uniqueName: string;
41
- readonly deployment: string;
42
- /** The secret, such as `prod:<deployment>|<token>`. Convex returns it only at creation. */
43
- readonly deployKey: Redacted.Redacted<string>;
44
- }
45
- export type DeployKey = Resource<"Convex.DeployKey", DeployKeyProps, DeployKeyAttributes, never, Providers>;
46
- export declare const DeployKey: import("alchemy").ResourceClass<DeployKey>;
47
- export declare const DeployKeyProvider: () => import("effect/Layer").Layer<Provider.Provider<DeployKey>, never, ManagementApi>;
48
- //# sourceMappingURL=DeployKey.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DeployKey.d.ts","sourceRoot":"","sources":["../src/DeployKey.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAE7C,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAqB,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,yEAAyE;AACzE,MAAM,MAAM,eAAe,GAAG,WAAW,CACvC,UAAU,CAAC,SAAS,CAAC,CAAC,6BAA6B,CAAC,CAAC,gBAAgB,CAAC,CACvE,CAAC,MAAM,CAAC,CAAC;AAYV;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAC3B,SAAS,aAAa,CAAC,OAAO,SAAS,CAAC,IAAI,CAAC,EAC7C,MAAM,MAAM,KACX,OAAO,SAAS,CAAC,IAAI,GAAG,SAOtB,CAAC;AAEN,mGAAmG;AACnG,eAAO,MAAM,SAAS;;;EAGpB,CAAC;AAEH,0DAA0D;AAC1D,eAAO,MAAM,aAAa;;;GAA0B,CAAC;AAErD,4DAA4D;AAC5D,eAAO,MAAM,gBAAgB;;EAA8C,CAAC;AAE5E,MAAM,WAAW,cAAc;IAC7B,6DAA6D;IAC7D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,uEAAuE;IACvE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2FAA2F;IAC3F,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;CACtD;AAED,MAAM,WAAW,mBAAmB;IAClC,wEAAwE;IACxE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,2FAA2F;IAC3F,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;CAC/C;AAED,MAAM,MAAM,SAAS,GAAG,QAAQ,CAC9B,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,KAAK,EACL,SAAS,CACV,CAAC;AACF,eAAO,MAAM,SAAS,4CAA0C,CAAC;AAEjE,eAAO,MAAM,iBAAiB,wFAkF3B,CAAC"}
package/lib/DeployKey.js DELETED
@@ -1,104 +0,0 @@
1
- // Convex.DeployKey: a deploy key for one deployment, such as the key
2
- // `npx convex deploy` reads from CONVEX_DEPLOY_KEY.
3
- //
4
- // Convex returns the secret only once, from create_deploy_key. The listing
5
- // shows each key under a unique name, the requested name plus a short id
6
- // suffix such as "my-key (0e71106d)", and delete_deploy_key accepts that
7
- // unique name. A key cannot be changed after creation, so every property
8
- // change is a replacement.
9
- import { Resource } from "alchemy";
10
- import { havePropsChanged, isResolved } from "alchemy/Diff";
11
- import * as Provider from "alchemy/Provider";
12
- import * as Effect from "effect/Effect";
13
- import * as Redacted from "effect/Redacted";
14
- import * as Schema from "effect/Schema";
15
- import { absentAsUndefined, ManagementApi } from "./ManagementApi.js";
16
- /**
17
- * True when `listedName` is how Convex lists a key created as `name`: the
18
- * requested name, a space, and one parenthesized id without spaces. The id
19
- * check keeps `my-key` from matching a key created as `my-key (old)`.
20
- */
21
- const isListedAs = (listedName, name) => {
22
- const prefix = `${name} (`;
23
- return listedName.startsWith(prefix) && /^[^\s()]+\)$/.test(listedName.slice(prefix.length));
24
- };
25
- /**
26
- * The listed key that a create call for `name` just made. The newest match
27
- * wins: an earlier attempt that failed before Alchemy saved state can leave
28
- * another key with the same requested name, and its secret is lost.
29
- */
30
- export const selectCreatedKey = (entries, name) => entries
31
- .filter((entry) => isListedAs(entry.name, name))
32
- .reduce((newest, entry) => newest === undefined || entry.creationTime > newest.creationTime ? entry : newest, undefined);
33
- /** One row of list_deploy_keys and list_preview_deploy_keys. Only the fields the providers use. */
34
- export const ListedKey = Schema.Struct({
35
- name: Schema.String,
36
- creationTime: Schema.Number,
37
- });
38
- /** GET /deployments/{deployment_name}/list_deploy_keys */
39
- export const DeployKeyList = Schema.Array(ListedKey);
40
- /** POST /deployments/{deployment_name}/create_deploy_key */
41
- export const CreatedDeployKey = Schema.Struct({ deployKey: Schema.String });
42
- export const DeployKey = Resource("Convex.DeployKey");
43
- export const DeployKeyProvider = () => Provider.effect(DeployKey, Effect.gen(function* () {
44
- const api = yield* ManagementApi;
45
- const listKeys = (deployment) => api
46
- .request("list deploy keys", (client) => client.GET("/deployments/{deployment_name}/list_deploy_keys", {
47
- params: { path: { deployment_name: deployment } },
48
- }))
49
- .pipe(Effect.map((body) => Schema.decodeUnknownSync(DeployKeyList)(body)));
50
- return {
51
- stables: ["uniqueName", "deployment"],
52
- diff: ({ olds, news, output }) => {
53
- if (!isResolved(news))
54
- return Effect.succeed(undefined);
55
- // State written without the secret cannot hand a key to dependents,
56
- // and Convex cannot return it again, so only a new key helps.
57
- return Effect.succeed((output !== undefined && output.deployKey === undefined) || havePropsChanged(olds, news)
58
- ? { action: "replace" }
59
- : { action: "noop" });
60
- },
61
- read: Effect.fn(function* ({ output }) {
62
- // A key that is not in state has no known secret, so it is never adopted.
63
- if (output === undefined)
64
- return undefined;
65
- const entries = yield* absentAsUndefined(listKeys(output.deployment));
66
- return entries?.some((entry) => entry.name === output.uniqueName) ? output : undefined;
67
- }),
68
- reconcile: Effect.fn(function* ({ news, output }) {
69
- if (output !== undefined) {
70
- // The secret cannot be read back. A key that still exists keeps the one in state.
71
- const entries = yield* listKeys(news.deployment);
72
- if (entries.some((entry) => entry.name === output.uniqueName))
73
- return output;
74
- }
75
- const created = yield* api.request("create deploy key", (client) => client.POST("/deployments/{deployment_name}/create_deploy_key", {
76
- params: { path: { deployment_name: news.deployment } },
77
- body: {
78
- name: news.name,
79
- ...(news.allowedActions === undefined
80
- ? {}
81
- : { allowedActions: [...news.allowedActions] }),
82
- },
83
- }));
84
- const { deployKey } = Schema.decodeUnknownSync(CreatedDeployKey)(created);
85
- const listed = selectCreatedKey(yield* listKeys(news.deployment), news.name);
86
- if (listed === undefined) {
87
- return yield* Effect.die(new Error(`Convex created deploy key "${news.name}" on ${news.deployment} but does not list it`));
88
- }
89
- return {
90
- uniqueName: listed.name,
91
- deployment: news.deployment,
92
- deployKey: Redacted.make(deployKey),
93
- };
94
- }),
95
- delete: Effect.fn(function* ({ output }) {
96
- // 404 DeployKeyNotFound: an earlier attempt or someone else deleted it.
97
- yield* absentAsUndefined(api.requestVoid("delete deploy key", (client) => client.POST("/deployments/{deployment_name}/delete_deploy_key", {
98
- params: { path: { deployment_name: output.deployment } },
99
- body: { id: output.uniqueName },
100
- })));
101
- }),
102
- };
103
- }));
104
- //# sourceMappingURL=DeployKey.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DeployKey.js","sourceRoot":"","sources":["../src/DeployKey.ts"],"names":[],"mappings":"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E,IAAI,EAAE,EAAE,eAAe,EAAE,MAAM,CAAC,UAAU,EAAE,EAAE;gBACxD,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,UAAU,EAAE;aAChC,CAAC,CACH,CACF,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;AACJ,CAAC,CAAC,CACH,CAAC"}
@@ -1,37 +0,0 @@
1
- import { Resource } from "alchemy";
2
- import * as Provider from "alchemy/Provider";
3
- import * as Effect from "effect/Effect";
4
- import * as Redacted from "effect/Redacted";
5
- import * as Schema from "effect/Schema";
6
- import { ManagementApi } from "./ManagementApi.ts";
7
- import type { Providers } from "./Providers.ts";
8
- /**
9
- * Attributes when the listing has `name`. Own keys only: a valid variable
10
- * name such as `toString` must not match the object prototype.
11
- */
12
- export declare const findVariable: (list: typeof EnvironmentVariableList.Type, deployment: string, name: string) => EnvironmentVariableAttributes | undefined;
13
- /**
14
- * Sets one variable, or removes it when `value` is null. The deployment
15
- * answers 200 with an empty body, so this reads no response data.
16
- */
17
- export declare const updateVariable: (deployment: string, deployKey: Redacted.Redacted<string>, name: string, value: string | Redacted.Redacted<string> | null) => Effect.Effect<void, import("./ManagementApi.ts").ConvexApiError, never>;
18
- /** GET https://<deployment>.convex.cloud/api/v1/list_environment_variables */
19
- export declare const EnvironmentVariableList: Schema.Struct<{
20
- readonly environmentVariables: Schema.$Record<Schema.String, Schema.String>;
21
- }>;
22
- export interface EnvironmentVariableProps {
23
- /** Deployment name, or its URL for deployments outside US East. */
24
- readonly deployment: string;
25
- /** Deploy key for `deployment`, such as `deployKey.deployKey`. */
26
- readonly deployKey: Redacted.Redacted<string>;
27
- readonly name: string;
28
- readonly value: string | Redacted.Redacted<string>;
29
- }
30
- export interface EnvironmentVariableAttributes {
31
- readonly deployment: string;
32
- readonly name: string;
33
- }
34
- export type EnvironmentVariable = Resource<"Convex.EnvironmentVariable", EnvironmentVariableProps, EnvironmentVariableAttributes, never, Providers>;
35
- export declare const EnvironmentVariable: import("alchemy").ResourceClass<EnvironmentVariable>;
36
- export declare const EnvironmentVariableProvider: () => import("effect/Layer").Layer<Provider.Provider<EnvironmentVariable>, never, ManagementApi>;
37
- //# sourceMappingURL=EnvironmentVariable.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EnvironmentVariable.d.ts","sourceRoot":"","sources":["../src/EnvironmentVariable.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAqB,aAAa,EAAc,MAAM,oBAAoB,CAAC;AAClF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,YAAY,GACvB,MAAM,OAAO,uBAAuB,CAAC,IAAI,EACzC,YAAY,MAAM,EAClB,MAAM,MAAM,KACX,6BAA6B,GAAG,SACgD,CAAC;AAEpF;;;GAGG;AACH,eAAO,MAAM,cAAc,GACzB,YAAY,MAAM,EAClB,WAAW,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EACpC,MAAM,MAAM,EACZ,OAAO,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,4EAW/C,CAAC;AAEJ,8EAA8E;AAC9E,eAAO,MAAM,uBAAuB;;EAElC,CAAC;AAEH,MAAM,WAAW,wBAAwB;IACvC,mEAAmE;IACnE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,kEAAkE;IAClE,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CACxC,4BAA4B,EAC5B,wBAAwB,EACxB,6BAA6B,EAC7B,KAAK,EACL,SAAS,CACV,CAAC;AACF,eAAO,MAAM,mBAAmB,sDAA8D,CAAC;AAE/F,eAAO,MAAM,2BAA2B,kGAmDrC,CAAC"}
@@ -1,65 +0,0 @@
1
- // Convex.EnvironmentVariable: one environment variable on one deployment.
2
- //
3
- // Environment variables live on the deployment API
4
- // (https://<deployment>.convex.cloud/api/v1), which authenticates with a
5
- // deploy key, not with the Management API token. Setting a variable and
6
- // removing it are the same call: update_environment_variables with
7
- // `value: null` removes the variable.
8
- import { createDeploymentClient } from "@convex-dev/platform";
9
- import { Resource } from "alchemy";
10
- import { isResolved } from "alchemy/Diff";
11
- import * as Provider from "alchemy/Provider";
12
- import * as Effect from "effect/Effect";
13
- import * as Redacted from "effect/Redacted";
14
- import * as Schema from "effect/Schema";
15
- import { absentAsUndefined, ManagementApi, settleVoid } from "./ManagementApi.js";
16
- /**
17
- * Attributes when the listing has `name`. Own keys only: a valid variable
18
- * name such as `toString` must not match the object prototype.
19
- */
20
- export const findVariable = (list, deployment, name) => Object.hasOwn(list.environmentVariables, name) ? { deployment, name } : undefined;
21
- /**
22
- * Sets one variable, or removes it when `value` is null. The deployment
23
- * answers 200 with an empty body, so this reads no response data.
24
- */
25
- export const updateVariable = (deployment, deployKey, name, value) => settleVoid("update environment variables", () => createDeploymentClient(deployment, Redacted.value(deployKey)).POST("/update_environment_variables", {
26
- body: {
27
- changes: [{ name, value: Redacted.isRedacted(value) ? Redacted.value(value) : value }],
28
- },
29
- }));
30
- /** GET https://<deployment>.convex.cloud/api/v1/list_environment_variables */
31
- export const EnvironmentVariableList = Schema.Struct({
32
- environmentVariables: Schema.Record(Schema.String, Schema.String),
33
- });
34
- export const EnvironmentVariable = Resource("Convex.EnvironmentVariable");
35
- export const EnvironmentVariableProvider = () => Provider.effect(EnvironmentVariable, Effect.gen(function* () {
36
- const api = yield* ManagementApi;
37
- return {
38
- stables: ["deployment", "name"],
39
- diff: ({ olds, news }) => {
40
- if (!isResolved(news))
41
- return Effect.succeed(undefined);
42
- // Otherwise undefined: the engine updates when any prop changed and
43
- // compares Redacted values, such as the value and the deploy key, by content.
44
- return Effect.succeed(olds.deployment !== news.deployment || olds.name !== news.name
45
- ? { action: "replace" }
46
- : undefined);
47
- },
48
- read: Effect.fn(function* ({ olds }) {
49
- // 404: the deployment no longer exists, so neither does the variable.
50
- const body = yield* absentAsUndefined(api.deploymentRequest("list environment variables", olds.deployment, olds.deployKey, (client) => client.GET("/list_environment_variables")));
51
- if (body === undefined)
52
- return undefined;
53
- return findVariable(Schema.decodeUnknownSync(EnvironmentVariableList)(body), olds.deployment, olds.name);
54
- }),
55
- reconcile: Effect.fn(function* ({ news }) {
56
- yield* updateVariable(news.deployment, news.deployKey, news.name, news.value);
57
- return { deployment: news.deployment, name: news.name };
58
- }),
59
- delete: Effect.fn(function* ({ olds, output }) {
60
- // Removing an absent variable succeeds; 404 means the deployment is gone.
61
- yield* absentAsUndefined(updateVariable(output.deployment, olds.deployKey, output.name, null));
62
- }),
63
- };
64
- }));
65
- //# sourceMappingURL=EnvironmentVariable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EnvironmentVariable.js","sourceRoot":"","sources":["../src/EnvironmentVariable.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,EAAE;AACF,mDAAmD;AACnD,yEAAyE;AACzE,wEAAwE;AACxE,mEAAmE;AACnE,sCAAsC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,C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AC,UAAU,EACf,IAAI,CAAC,IAAI,CACV,CAAC;QACJ,CAAC,CAAC;QAEF,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE;YACtC,KAAK,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YAC9E,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;QAC1D,CAAC,CAAC;QAEF,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;YAC3C,0EAA0E;YAC1E,KAAK,CAAC,CAAC,iBAAiB,CACtB,cAAc,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CACrE,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;AACJ,CAAC,CAAC,CACH,CAAC"}
@@ -1,50 +0,0 @@
1
- import { createDeploymentClient, createManagementClient } from "@convex-dev/platform";
2
- import * as Context from "effect/Context";
3
- import * as Effect from "effect/Effect";
4
- import * as Layer from "effect/Layer";
5
- import * as Redacted from "effect/Redacted";
6
- import * as Schema from "effect/Schema";
7
- import { Credentials } from "./Credentials.ts";
8
- export type ManagementClient = ReturnType<typeof createManagementClient>;
9
- export type DeploymentClient = ReturnType<typeof createDeploymentClient>;
10
- /** Shape of every openapi-fetch result we consume. */
11
- export interface FetchResult<T> {
12
- readonly data?: T;
13
- readonly error?: unknown;
14
- readonly response: Response;
15
- }
16
- declare const ConvexApiError_base: Schema.Class<ConvexApiError, Schema.TaggedStruct<"ConvexApiError", {
17
- readonly operation: Schema.String;
18
- readonly status: Schema.Number;
19
- readonly code: Schema.optionalKey<Schema.String>;
20
- readonly message: Schema.String;
21
- }>, import("effect/Cause").YieldableError>;
22
- /**
23
- * One error for every control-plane and deployment call. Resources branch on
24
- * `status` (404 means absent for read and delete), so the class is load
25
- * bearing, not decorative.
26
- */
27
- export declare class ConvexApiError extends ConvexApiError_base {
28
- }
29
- export interface ManagementApiService {
30
- /** Run one management call with the resolved credentials. */
31
- readonly request: <T>(operation: string, run: (client: ManagementClient) => Promise<FetchResult<T>>) => Effect.Effect<T, ConvexApiError>;
32
- /** Run one management call whose success response has no body. */
33
- readonly requestVoid: (operation: string, run: (client: ManagementClient) => Promise<FetchResult<unknown>>) => Effect.Effect<void, ConvexApiError>;
34
- /** Run one deployment-scoped call authenticated with a deploy key. */
35
- readonly deploymentRequest: <T>(operation: string, deploymentUrlOrName: string, deployKey: Redacted.Redacted<string>, run: (client: DeploymentClient) => Promise<FetchResult<T>>) => Effect.Effect<T, ConvexApiError>;
36
- /** Team id for a slug or numeric id. */
37
- readonly resolveTeamId: (team: string | number) => Effect.Effect<number, ConvexApiError>;
38
- }
39
- declare const ManagementApi_base: Context.ServiceClass<ManagementApi, "@samebase/alchemy-convex/ManagementApi", ManagementApiService>;
40
- export declare class ManagementApi extends ManagementApi_base {
41
- }
42
- /** Reads `data` or fails with the HTTP status and the API's own code and message. */
43
- export declare const settle: <T>(operation: string, run: () => Promise<FetchResult<T>>) => Effect.Effect<T, ConvexApiError>;
44
- /** For endpoints that answer with an empty body, such as delete calls. */
45
- export declare const settleVoid: (operation: string, run: () => Promise<FetchResult<unknown>>) => Effect.Effect<void, ConvexApiError>;
46
- /** Turns a 404 into `undefined` so read and delete stay idempotent. */
47
- export declare const absentAsUndefined: <A, R>(effect: Effect.Effect<A, ConvexApiError, R>) => Effect.Effect<A | undefined, ConvexApiError, R>;
48
- export declare const ManagementApiLive: () => Layer.Layer<ManagementApi, never, Credentials>;
49
- export {};
50
- //# sourceMappingURL=ManagementApi.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ManagementApi.d.ts","sourceRoot":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