@gaganref/confect-alchemy 10.3.1-fork.96 → 10.6.0-fork.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/Backend.d.ts.map +1 -1
- package/dist/Backend.js +2 -3
- package/dist/Backend.js.map +1 -1
- package/dist/Code.d.ts +16 -3
- package/dist/Code.d.ts.map +1 -1
- package/dist/Code.js +13 -3
- package/dist/Code.js.map +1 -1
- package/dist/Confect.d.ts.map +1 -1
- package/dist/Confect.js +1 -2
- package/dist/Convex.d.ts.map +1 -1
- package/dist/Convex.js +3 -4
- package/dist/ConvexClient.d.ts +14 -4
- package/dist/ConvexClient.d.ts.map +1 -1
- package/dist/ConvexClient.js +44 -36
- package/dist/ConvexClient.js.map +1 -1
- package/dist/DeployKey.d.ts +22 -12
- package/dist/DeployKey.d.ts.map +1 -1
- package/dist/DeployKey.js +41 -29
- package/dist/DeployKey.js.map +1 -1
- package/dist/Deployment.d.ts +19 -10
- package/dist/Deployment.d.ts.map +1 -1
- package/dist/Deployment.js +22 -19
- package/dist/Deployment.js.map +1 -1
- package/dist/EnvironmentVariables.d.ts +23 -31
- package/dist/EnvironmentVariables.d.ts.map +1 -1
- package/dist/EnvironmentVariables.js +21 -20
- package/dist/EnvironmentVariables.js.map +1 -1
- package/dist/Project.d.ts +15 -10
- package/dist/Project.d.ts.map +1 -1
- package/dist/Project.js +23 -22
- package/dist/Project.js.map +1 -1
- package/dist/Providers.d.ts +3 -1
- package/dist/Providers.d.ts.map +1 -1
- package/dist/Providers.js +19 -18
- package/dist/Providers.js.map +1 -1
- package/dist/_virtual/_rolldown/runtime.js +5 -6
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/CodeDeployment.d.ts +6 -1
- package/dist/internal/CodeDeployment.d.ts.map +1 -1
- package/dist/internal/CodeDeployment.js +10 -8
- package/dist/internal/CodeDeployment.js.map +1 -1
- package/dist/internal/CommandRunner.d.ts +6 -1
- package/dist/internal/CommandRunner.d.ts.map +1 -1
- package/dist/internal/CommandRunner.js +11 -9
- package/dist/internal/CommandRunner.js.map +1 -1
- package/dist/internal/FileLock.d.ts +7 -3
- package/dist/internal/FileLock.d.ts.map +1 -1
- package/dist/internal/FileLock.js +10 -8
- package/dist/internal/FileLock.js.map +1 -1
- package/dist/internal/Lifecycle.d.ts +3 -1
- package/dist/internal/Lifecycle.d.ts.map +1 -1
- package/dist/internal/Lifecycle.js +3 -4
- package/dist/internal/Lifecycle.js.map +1 -1
- package/dist/internal/LocalBackend.d.ts +7 -3
- package/dist/internal/LocalBackend.d.ts.map +1 -1
- package/dist/internal/LocalBackend.js +26 -18
- package/dist/internal/LocalBackend.js.map +1 -1
- package/dist/internal/LocalSidecar.d.ts +4 -1
- package/dist/internal/LocalSidecar.d.ts.map +1 -1
- package/dist/internal/LocalSidecar.js +4 -2
- package/dist/internal/LocalSidecar.js.map +1 -1
- package/dist/internal/Loopback.d.ts.map +1 -1
- package/dist/internal/Loopback.js +1 -2
- package/dist/internal/MountInit.d.ts +5 -1
- package/dist/internal/MountInit.d.ts.map +1 -1
- package/dist/internal/MountInit.js +5 -4
- package/dist/internal/MountInit.js.map +1 -1
- package/dist/internal/PushLock.d.ts +7 -3
- package/dist/internal/PushLock.d.ts.map +1 -1
- package/dist/internal/PushLock.js +7 -6
- package/dist/internal/PushLock.js.map +1 -1
- package/dist/internal/ResourceIdentity.d.ts.map +1 -1
- package/dist/internal/ResourceIdentity.js +5 -3
- package/dist/internal/ResourceIdentity.js.map +1 -1
- package/dist/internal/UserCache.d.ts +2 -0
- package/dist/internal/UserCache.d.ts.map +1 -1
- package/dist/internal/UserCache.js +5 -4
- package/dist/internal/UserCache.js.map +1 -1
- package/dist/internal/Zip.d.ts +5 -1
- package/dist/internal/Zip.d.ts.map +1 -1
- package/dist/internal/Zip.js +9 -8
- package/dist/internal/Zip.js.map +1 -1
- package/package.json +5 -5
- package/src/Backend.ts +7 -6
- package/src/Code.ts +11 -0
- package/src/ConvexClient.ts +87 -74
- package/src/DeployKey.ts +73 -44
- package/src/Deployment.ts +50 -37
- package/src/EnvironmentVariables.ts +30 -27
- package/src/Project.ts +42 -41
- package/src/Providers.ts +2 -0
- package/src/index.ts +3 -0
- package/src/internal/CodeDeployment.ts +17 -11
- package/src/internal/CommandRunner.ts +27 -26
- package/src/internal/FileLock.ts +15 -12
- package/src/internal/Lifecycle.ts +11 -7
- package/src/internal/LocalBackend.ts +45 -39
- package/src/internal/LocalSidecar.ts +3 -0
- package/src/internal/MountInit.ts +8 -6
- package/src/internal/PushLock.ts +13 -11
- package/src/internal/ResourceIdentity.ts +12 -5
- package/src/internal/UserCache.ts +13 -4
- package/src/internal/Zip.ts +13 -8
|
@@ -3,7 +3,7 @@ import * as Effect from "effect/Effect";
|
|
|
3
3
|
import * as FileSystem from "effect/FileSystem";
|
|
4
4
|
import * as Path from "effect/Path";
|
|
5
5
|
import * as Schema from "effect/Schema";
|
|
6
|
-
|
|
6
|
+
// src/internal/MountInit.ts
|
|
7
7
|
var MountInitFailed = class extends Schema.TaggedError()("MountInitFailed", {
|
|
8
8
|
mount: Schema.String,
|
|
9
9
|
detail: Schema.String
|
|
@@ -42,9 +42,11 @@ const hasDeployModule = Effect.fn("MountInit.hasDeployModule")(function* (cwd) {
|
|
|
42
42
|
* path, one at a time, and visit a nested component's own steps after its
|
|
43
43
|
* `init`. The first failing mount stops the run. Each `init` is its own
|
|
44
44
|
* transaction, so earlier mounts stay applied and a rerun converges.
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
45
47
|
*/
|
|
46
48
|
const run = Effect.fn("MountInit.run")(function* (url, key, cwd) {
|
|
47
|
-
const failed = (mount) => (error) =>
|
|
49
|
+
const failed = (mount) => (error) => MountInitFailed.make({
|
|
48
50
|
mount,
|
|
49
51
|
detail: Schema.is(ConvexFunctionError)(error) ? error.errorMessage : error._tag
|
|
50
52
|
});
|
|
@@ -54,7 +56,7 @@ const run = Effect.fn("MountInit.run")(function* (url, key, cwd) {
|
|
|
54
56
|
const steps = yield* client.runFunction(url, key, STEPS, {}, prefix).pipe(Effect.flatMap(Schema.decodeUnknownEffect(Steps)), Effect.mapError(failed(prefix ?? STEPS)));
|
|
55
57
|
for (const step of steps) {
|
|
56
58
|
const mount = prefix === void 0 ? step.componentPath : `${prefix}/${step.componentPath}`;
|
|
57
|
-
if ("failure" in step) return yield*
|
|
59
|
+
if ("failure" in step) return yield* MountInitFailed.make({
|
|
58
60
|
mount,
|
|
59
61
|
detail: step.failure
|
|
60
62
|
});
|
|
@@ -64,7 +66,6 @@ const run = Effect.fn("MountInit.run")(function* (url, key, cwd) {
|
|
|
64
66
|
});
|
|
65
67
|
yield* visit(void 0);
|
|
66
68
|
});
|
|
67
|
-
//#endregion
|
|
68
69
|
export { MountInitFailed, run };
|
|
69
70
|
|
|
70
71
|
//# sourceMappingURL=MountInit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MountInit.js","names":[],"sources":["../../src/internal/MountInit.ts"],"sourcesContent":["import * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport type * as Redacted from \"effect/Redacted\";\nimport * as Schema from \"effect/Schema\";\nimport { ConvexClient, ConvexFunctionError } from \"../ConvexClient.js\";\n\nexport class MountInitFailed extends Schema.TaggedError
|
|
1
|
+
{"version":3,"file":"MountInit.js","names":[],"sources":["../../src/internal/MountInit.ts"],"sourcesContent":["import * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport type * as Redacted from \"effect/Redacted\";\nimport * as Schema from \"effect/Schema\";\nimport { ConvexClient, ConvexFunctionError } from \"../ConvexClient.js\";\n\nexport class MountInitFailed extends Schema.TaggedError<\n MountInitFailed,\n { readonly brand: unique symbol }\n>()(\"MountInitFailed\", { mount: Schema.String, detail: Schema.String }) {\n override get message() {\n return `${this.mount}: init failed; earlier mounts are applied, and the next push retries`;\n }\n}\n\nconst Steps = Schema.Array(\n Schema.Union([\n Schema.Struct({\n componentPath: Schema.String,\n nested: Schema.Boolean,\n init: Schema.NullOr(\n Schema.Struct({ functionName: Schema.String, args: Schema.Unknown }),\n ),\n }),\n Schema.Struct({ componentPath: Schema.String, failure: Schema.String }),\n ]),\n);\n\nconst STEPS = \"confectDeploy:steps\";\n\nconst ConvexJson = Schema.fromJsonString(\n Schema.Struct({ functions: Schema.optional(Schema.String) }),\n);\n\n/**\n * Whether codegen wrote `confectDeploy.ts` into the backend's Convex directory,\n * which `convex.json` may move.\n */\nconst hasDeployModule = Effect.fn(\"MountInit.hasDeployModule\")(function* (\n cwd: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const config = path.join(cwd, \"convex.json\");\n const functions = (yield* fs.exists(config))\n ? ((yield* fs\n .readFileString(config)\n .pipe(Effect.flatMap(Schema.decodeEffect(ConvexJson)))).functions ??\n \"convex\")\n : \"convex\";\n return yield* fs.exists(path.join(cwd, functions, \"confectDeploy.ts\"));\n});\n\n/**\n * Run every mount's `init` against a pushed deployment: ask the backend's\n * deploy module for its steps, then run each mount's `init` at its component\n * path, one at a time, and visit a nested component's own steps after its\n * `init`. The first failing mount stops the run. Each `init` is its own\n * transaction, so earlier mounts stay applied and a rerun converges.\n *\n * @internal\n */\nexport const run = Effect.fn(\"MountInit.run\")(function* (\n url: string,\n key: Redacted.Redacted<string>,\n cwd: string,\n) {\n const failed =\n (mount: string) =>\n (error: { readonly _tag: string }): MountInitFailed =>\n MountInitFailed.make({\n mount,\n detail: Schema.is(ConvexFunctionError)(error)\n ? error.errorMessage\n : error._tag,\n });\n if (!(yield* hasDeployModule(cwd).pipe(Effect.mapError(failed(STEPS)))))\n return;\n const client = yield* ConvexClient;\n const visit = (\n prefix: string | undefined,\n ): Effect.Effect<void, MountInitFailed> =>\n Effect.gen(function* () {\n const steps = yield* client\n .runFunction(url, key, STEPS, {}, prefix)\n .pipe(\n Effect.flatMap(Schema.decodeUnknownEffect(Steps)),\n Effect.mapError(failed(prefix ?? STEPS)),\n );\n for (const step of steps) {\n const mount =\n prefix === undefined\n ? step.componentPath\n : `${prefix}/${step.componentPath}`;\n if (\"failure\" in step)\n return yield* MountInitFailed.make({ mount, detail: step.failure });\n if (step.init !== null)\n yield* client\n .runFunction(\n url,\n key,\n step.init.functionName,\n step.init.args,\n mount,\n )\n .pipe(Effect.mapError(failed(mount)));\n if (step.nested) yield* visit(mount);\n }\n });\n yield* visit(undefined);\n});\n"],"mappings":";;;;;;AAOA,IAAa,kBAAb,cAAqC,OAAO,YAG1C,CAAC,CAAC,mBAAmB;CAAE,OAAO,OAAO;CAAQ,QAAQ,OAAO;AAAO,CAAC,CAAC,CAAC;CACtE,IAAa,UAAU;EACrB,OAAO,GAAG,KAAK,MAAM;CACvB;AACF;AAEA,MAAM,QAAQ,OAAO,MACnB,OAAO,MAAM,CACX,OAAO,OAAO;CACZ,eAAe,OAAO;CACtB,QAAQ,OAAO;CACf,MAAM,OAAO,OACX,OAAO,OAAO;EAAE,cAAc,OAAO;EAAQ,MAAM,OAAO;CAAQ,CAAC,CACrE;AACF,CAAC,GACD,OAAO,OAAO;CAAE,eAAe,OAAO;CAAQ,SAAS,OAAO;AAAO,CAAC,CACxE,CAAC,CACH;AAEA,MAAM,QAAQ;AAEd,MAAM,aAAa,OAAO,eACxB,OAAO,OAAO,EAAE,WAAW,OAAO,SAAS,OAAO,MAAM,EAAE,CAAC,CAC7D;;;;;AAMA,MAAM,kBAAkB,OAAO,GAAG,2BAA2B,CAAC,CAAC,WAC7D,KACA;CACA,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,SAAS,KAAK,KAAK,KAAK,aAAa;CAC3C,MAAM,aAAa,OAAO,GAAG,OAAO,MAAM,MACpC,OAAO,GACN,eAAe,MAAM,CAAC,CACtB,KAAK,OAAO,QAAQ,OAAO,aAAa,UAAU,CAAC,CAAC,EAAA,CAAG,aAC1D,WACA;CACJ,OAAO,OAAO,GAAG,OAAO,KAAK,KAAK,KAAK,WAAW,kBAAkB,CAAC;AACvE,CAAC;;;;;;;;;;AAWD,MAAa,MAAM,OAAO,GAAG,eAAe,CAAC,CAAC,WAC5C,KACA,KACA,KACA;CACA,MAAM,UACH,WACA,UACC,gBAAgB,KAAK;EACnB;EACA,QAAQ,OAAO,GAAG,mBAAmB,CAAC,CAAC,KAAK,IACxC,MAAM,eACN,MAAM;CACZ,CAAC;CACL,IAAI,EAAE,OAAO,gBAAgB,GAAG,CAAC,CAAC,KAAK,OAAO,SAAS,OAAO,KAAK,CAAC,CAAC,IACnE;CACF,MAAM,SAAS,OAAO;CACtB,MAAM,SACJ,WAEA,OAAO,IAAI,aAAa;EACtB,MAAM,QAAQ,OAAO,OAClB,YAAY,KAAK,KAAK,OAAO,CAAC,GAAG,MAAM,CAAC,CACxC,KACC,OAAO,QAAQ,OAAO,oBAAoB,KAAK,CAAC,GAChD,OAAO,SAAS,OAAO,UAAU,KAAK,CAAC,CACzC;EACF,KAAK,MAAM,QAAQ,OAAO;GACxB,MAAM,QACJ,WAAW,KAAA,IACP,KAAK,gBACL,GAAG,OAAO,GAAG,KAAK;GACxB,IAAI,aAAa,MACf,OAAO,OAAO,gBAAgB,KAAK;IAAE;IAAO,QAAQ,KAAK;GAAQ,CAAC;GACpE,IAAI,KAAK,SAAS,MAChB,OAAO,OACJ,YACC,KACA,KACA,KAAK,KAAK,cACV,KAAK,KAAK,MACV,KACF,CAAC,CACA,KAAK,OAAO,SAAS,OAAO,KAAK,CAAC,CAAC;GACxC,IAAI,KAAK,QAAQ,OAAO,MAAM,KAAK;EACrC;CACF,CAAC;CACH,OAAO,MAAM,KAAA,CAAS;AACxB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Context from "effect/Context";
|
|
2
|
-
import * as
|
|
2
|
+
import * as SecureRandom from "effect/crypto/SecureRandom";
|
|
3
3
|
import * as Duration from "effect/Duration";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
5
|
import * as FileSystem from "effect/FileSystem";
|
|
@@ -9,7 +9,9 @@ import * as Schema from "effect/Schema";
|
|
|
9
9
|
declare const PushLockError_base: Schema.Class<PushLockError, Schema.TaggedStruct<"PushLockError", {
|
|
10
10
|
readonly deploymentName: Schema.String;
|
|
11
11
|
readonly reason: Schema.Literals<readonly ["configuration", "timeout", "filesystem"]>;
|
|
12
|
-
}>, import("effect/Cause").YieldableError
|
|
12
|
+
}>, import("effect/Cause").YieldableError & {
|
|
13
|
+
readonly brand: unique symbol;
|
|
14
|
+
}>;
|
|
13
15
|
export declare class PushLockError extends PushLockError_base {
|
|
14
16
|
get message(): string;
|
|
15
17
|
}
|
|
@@ -28,9 +30,11 @@ export declare class PushLock extends PushLock_base {
|
|
|
28
30
|
* `confect/alchemy/locks/<deployment>.lock`, so every checkout on the machine
|
|
29
31
|
* shares it. A lock left by a process that exited is taken over; a holder that
|
|
30
32
|
* never releases ends in a typed timeout.
|
|
33
|
+
*
|
|
34
|
+
* @internal
|
|
31
35
|
*/
|
|
32
36
|
export declare const layer: (options?: {
|
|
33
37
|
readonly timeout?: Duration.Input;
|
|
34
|
-
}) => Layer.Layer<PushLock, never,
|
|
38
|
+
}) => Layer.Layer<PushLock, never, FileSystem.FileSystem | Path.Path | SecureRandom.SecureRandom>;
|
|
35
39
|
export {};
|
|
36
40
|
//# sourceMappingURL=PushLock.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PushLock.d.ts","
|
|
1
|
+
{"version":3,"file":"PushLock.d.ts","sources":["../../src/internal/PushLock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,YAAY,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;;;;;oBAOpB,OAAO,MAAM;;AAFjC,qBAAa,aAAc,SAAQ,kBAMjC;IACA,IAAa,OAAO,WASnB;CACF;;uBAUsB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EACzB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC3B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,aAAa,EAAE,CAAC,CAAC;;AAX/C;;;;GAIG;AACH,qBAAa,QAAS,SAAQ,aAQW;CAAG;AAE5C;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,aAAc;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAA;CAAE,gGA6ClE,CAAC"}
|
|
@@ -7,10 +7,10 @@ import * as Path from "effect/Path";
|
|
|
7
7
|
import * as Context from "effect/Context";
|
|
8
8
|
import * as Schema from "effect/Schema";
|
|
9
9
|
import * as Option from "effect/Option";
|
|
10
|
-
import * as
|
|
10
|
+
import * as SecureRandom from "effect/crypto/SecureRandom";
|
|
11
11
|
import * as Duration from "effect/Duration";
|
|
12
12
|
import * as Scope from "effect/Scope";
|
|
13
|
-
|
|
13
|
+
// src/internal/PushLock.ts
|
|
14
14
|
var PushLockError = class extends Schema.TaggedError()("PushLockError", {
|
|
15
15
|
deploymentName: Schema.String,
|
|
16
16
|
reason: Schema.Literals([
|
|
@@ -38,24 +38,25 @@ var PushLock = class extends Context.Service()("@confect/alchemy/internal/PushLo
|
|
|
38
38
|
* `confect/alchemy/locks/<deployment>.lock`, so every checkout on the machine
|
|
39
39
|
* shares it. A lock left by a process that exited is taken over; a holder that
|
|
40
40
|
* never releases ends in a typed timeout.
|
|
41
|
+
*
|
|
42
|
+
* @internal
|
|
41
43
|
*/
|
|
42
44
|
const layer = (options) => Layer.effect(PushLock, Effect.gen(function* () {
|
|
43
45
|
const fs = yield* FileSystem.FileSystem;
|
|
44
46
|
const path = yield* Path.Path;
|
|
45
|
-
const
|
|
47
|
+
const random = yield* SecureRandom.SecureRandom;
|
|
46
48
|
const timeout = options?.timeout ?? Duration.minutes(10);
|
|
47
49
|
const lock = Effect.fn("PushLock.lock")(function* (deploymentName, scope) {
|
|
48
|
-
const failed = (reason) =>
|
|
50
|
+
const failed = (reason) => PushLockError.make({
|
|
49
51
|
deploymentName,
|
|
50
52
|
reason
|
|
51
53
|
});
|
|
52
54
|
const cache = yield* userCache.pipe(Effect.mapError(() => failed("configuration")));
|
|
53
55
|
if (Option.isNone(cache)) return yield* failed("configuration");
|
|
54
56
|
yield* acquire(path.join(cache.value, "confect", "alchemy", "locks", `${deploymentName}.lock`), timeout).pipe(Scope.provide(scope), Effect.mapError((error) => failed(error.reason === "timeout" ? "timeout" : "filesystem")));
|
|
55
|
-
}, Effect.provideService(FileSystem.FileSystem, fs), Effect.provideService(Path.Path, path), Effect.provideService(
|
|
57
|
+
}, Effect.provideService(FileSystem.FileSystem, fs), Effect.provideService(Path.Path, path), Effect.provideService(SecureRandom.SecureRandom, random));
|
|
56
58
|
return PushLock.of({ withLock: (deploymentName, effect) => Effect.acquireUseRelease(Scope.make(), (scope) => lock(deploymentName, scope).pipe(Effect.andThen(effect)), (scope, exit) => Scope.close(scope, exit)) });
|
|
57
59
|
}));
|
|
58
|
-
//#endregion
|
|
59
60
|
export { PushLock, PushLockError, layer };
|
|
60
61
|
|
|
61
62
|
//# sourceMappingURL=PushLock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PushLock.js","names":["FileLock.acquire"],"sources":["../../src/internal/PushLock.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as
|
|
1
|
+
{"version":3,"file":"PushLock.js","names":["FileLock.acquire"],"sources":["../../src/internal/PushLock.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as SecureRandom from \"effect/crypto/SecureRandom\";\nimport * as Duration from \"effect/Duration\";\nimport * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Layer from \"effect/Layer\";\nimport * as Option from \"effect/Option\";\nimport * as Path from \"effect/Path\";\nimport * as Schema from \"effect/Schema\";\nimport * as Scope from \"effect/Scope\";\nimport * as FileLock from \"./FileLock.js\";\nimport { userCache } from \"./UserCache.js\";\n\nexport class PushLockError extends Schema.TaggedError<\n PushLockError,\n { readonly brand: unique symbol }\n>()(\"PushLockError\", {\n deploymentName: Schema.String,\n reason: Schema.Literals([\"configuration\", \"timeout\", \"filesystem\"]),\n}) {\n override get message() {\n switch (this.reason) {\n case \"configuration\":\n return `Push lock for ${this.deploymentName} needs a home directory to keep its lock file in`;\n case \"timeout\":\n return `Timed out waiting for another push to ${this.deploymentName} to release its push lock`;\n case \"filesystem\":\n return `Push lock for ${this.deploymentName} could not read or write its lock file`;\n }\n }\n}\n\n/**\n * Serialises pushes per deployment. Overlapping `convex deploy` runs against\n * one deployment race on `wait_for_schema`, so every push holds the lock for\n * its whole duration, whichever stack, checkout, or process it comes from.\n */\nexport class PushLock extends Context.Service<\n PushLock,\n {\n readonly withLock: <A, E, R>(\n deploymentName: string,\n effect: Effect.Effect<A, E, R>,\n ) => Effect.Effect<A, E | PushLockError, R>;\n }\n>()(\"@confect/alchemy/internal/PushLock\") {}\n\n/**\n * One lock file per deployment under the user's cache,\n * `confect/alchemy/locks/<deployment>.lock`, so every checkout on the machine\n * shares it. A lock left by a process that exited is taken over; a holder that\n * never releases ends in a typed timeout.\n *\n * @internal\n */\nexport const layer = (options?: { readonly timeout?: Duration.Input }) =>\n Layer.effect(\n PushLock,\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const random = yield* SecureRandom.SecureRandom;\n const timeout = options?.timeout ?? Duration.minutes(10);\n const lock = Effect.fn(\"PushLock.lock\")(\n function* (deploymentName: string, scope: Scope.Scope) {\n const failed = (reason: PushLockError[\"reason\"]) =>\n PushLockError.make({ deploymentName, reason });\n const cache = yield* userCache.pipe(\n Effect.mapError(() => failed(\"configuration\")),\n );\n if (Option.isNone(cache)) return yield* failed(\"configuration\");\n yield* FileLock.acquire(\n path.join(\n cache.value,\n \"confect\",\n \"alchemy\",\n \"locks\",\n `${deploymentName}.lock`,\n ),\n timeout,\n ).pipe(\n Scope.provide(scope),\n Effect.mapError((error) =>\n failed(error.reason === \"timeout\" ? \"timeout\" : \"filesystem\"),\n ),\n );\n },\n Effect.provideService(FileSystem.FileSystem, fs),\n Effect.provideService(Path.Path, path),\n Effect.provideService(SecureRandom.SecureRandom, random),\n );\n return PushLock.of({\n withLock: (deploymentName, effect) =>\n Effect.acquireUseRelease(\n Scope.make(),\n (scope) => lock(deploymentName, scope).pipe(Effect.andThen(effect)),\n (scope, exit) => Scope.close(scope, exit),\n ),\n });\n }),\n );\n"],"mappings":";;;;;;;;;;;;;AAaA,IAAa,gBAAb,cAAmC,OAAO,YAGxC,CAAC,CAAC,iBAAiB;CACnB,gBAAgB,OAAO;CACvB,QAAQ,OAAO,SAAS;EAAC;EAAiB;EAAW;CAAY,CAAC;AACpE,CAAC,CAAC,CAAC;CACD,IAAa,UAAU;EACrB,QAAQ,KAAK,QAAb;GACE,KAAK,iBACH,OAAO,iBAAiB,KAAK,eAAe;GAC9C,KAAK,WACH,OAAO,yCAAyC,KAAK,eAAe;GACtE,KAAK,cACH,OAAO,iBAAiB,KAAK,eAAe;EAChD;CACF;AACF;;;;;;AAOA,IAAa,WAAb,cAA8B,QAAQ,QAQpC,CAAC,CAAC,oCAAoC,CAAC,CAAC,CAAC;;;;;;;;;AAU3C,MAAa,SAAS,YACpB,MAAM,OACJ,UACA,OAAO,IAAI,aAAa;CACtB,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,SAAS,OAAO,aAAa;CACnC,MAAM,UAAU,SAAS,WAAW,SAAS,QAAQ,EAAE;CACvD,MAAM,OAAO,OAAO,GAAG,eAAe,CAAC,CACrC,WAAW,gBAAwB,OAAoB;EACrD,MAAM,UAAU,WACd,cAAc,KAAK;GAAE;GAAgB;EAAO,CAAC;EAC/C,MAAM,QAAQ,OAAO,UAAU,KAC7B,OAAO,eAAe,OAAO,eAAe,CAAC,CAC/C;EACA,IAAI,OAAO,OAAO,KAAK,GAAG,OAAO,OAAO,OAAO,eAAe;EAC9D,OAAOA,QACL,KAAK,KACH,MAAM,OACN,WACA,WACA,SACA,GAAG,eAAe,MACpB,GACA,OACF,CAAC,CAAC,KACA,MAAM,QAAQ,KAAK,GACnB,OAAO,UAAU,UACf,OAAO,MAAM,WAAW,YAAY,YAAY,YAAY,CAC9D,CACF;CACF,GACA,OAAO,eAAe,WAAW,YAAY,EAAE,GAC/C,OAAO,eAAe,KAAK,MAAM,IAAI,GACrC,OAAO,eAAe,aAAa,cAAc,MAAM,CACzD;CACA,OAAO,SAAS,GAAG,EACjB,WAAW,gBAAgB,WACzB,OAAO,kBACL,MAAM,KAAK,IACV,UAAU,KAAK,gBAAgB,KAAK,CAAC,CAAC,KAAK,OAAO,QAAQ,MAAM,CAAC,IACjE,OAAO,SAAS,MAAM,MAAM,OAAO,IAAI,CAC1C,EACJ,CAAC;AACH,CAAC,CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceIdentity.d.ts","
|
|
1
|
+
{"version":3,"file":"ResourceIdentity.d.ts","sources":["../../src/internal/ResourceIdentity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAKxC,eAAO,MAAM,YAAY,wFAqBvB,CAAC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
|
-
|
|
2
|
+
import * as String from "effect/String";
|
|
3
|
+
import { pipe } from "effect/Function";
|
|
4
|
+
import * as Arr from "effect/Array";
|
|
5
|
+
// src/internal/ResourceIdentity.ts
|
|
3
6
|
const resourceName = Effect.fn("ResourceIdentity.name")(function* (kind, fqn, instanceId) {
|
|
4
7
|
const hash = yield* Effect.promise(() => crypto.subtle.digest("SHA-256", new TextEncoder().encode(`${fqn}:${instanceId}`)));
|
|
5
|
-
return `confect-${kind}-${Array.from(new Uint8Array(hash), (byte) => byte.toString(16).padStart(2, "0"))
|
|
8
|
+
return `confect-${kind}-${pipe(Arr.join(Array.from(new Uint8Array(hash), (byte) => pipe(byte.toString(16), String.padStart(2, "0"))), ""), String.slice(0, 24))}`;
|
|
6
9
|
});
|
|
7
|
-
//#endregion
|
|
8
10
|
export { resourceName };
|
|
9
11
|
|
|
10
12
|
//# sourceMappingURL=ResourceIdentity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceIdentity.js","names":[],"sources":["../../src/internal/ResourceIdentity.ts"],"sourcesContent":["import * as Effect from \"effect/Effect\";\n\nexport const resourceName = Effect.fn(\"ResourceIdentity.name\")(function* (\n kind: string,\n fqn: string,\n instanceId: string,\n) {\n const hash = yield* Effect.promise(() =>\n crypto.subtle.digest(\n \"SHA-256\",\n new TextEncoder().encode(`${fqn}:${instanceId}`),\n ),\n );\n const suffix = Array.from(new Uint8Array(hash), (byte) =>\n
|
|
1
|
+
{"version":3,"file":"ResourceIdentity.js","names":[],"sources":["../../src/internal/ResourceIdentity.ts"],"sourcesContent":["import * as Effect from \"effect/Effect\";\nimport * as String from \"effect/String\";\nimport { pipe } from \"effect/Function\";\nimport * as Arr from \"effect/Array\";\n\nexport const resourceName = Effect.fn(\"ResourceIdentity.name\")(function* (\n kind: string,\n fqn: string,\n instanceId: string,\n) {\n const hash = yield* Effect.promise(() =>\n crypto.subtle.digest(\n \"SHA-256\",\n new TextEncoder().encode(`${fqn}:${instanceId}`),\n ),\n );\n const suffix = pipe(\n Arr.join(\n Array.from(new Uint8Array(hash), (byte) =>\n pipe(byte.toString(16), String.padStart(2, \"0\")),\n ),\n \"\",\n ),\n String.slice(0, 24),\n );\n return `confect-${kind}-${suffix}`;\n});\n"],"mappings":";;;;;AAKA,MAAa,eAAe,OAAO,GAAG,uBAAuB,CAAC,CAAC,WAC7D,MACA,KACA,YACA;CACA,MAAM,OAAO,OAAO,OAAO,cACzB,OAAO,OAAO,OACZ,WACA,IAAI,YAAY,CAAC,CAAC,OAAO,GAAG,IAAI,GAAG,YAAY,CACjD,CACF;CAUA,OAAO,WAAW,KAAK,GATR,KACb,IAAI,KACF,MAAM,KAAK,IAAI,WAAW,IAAI,IAAI,SAChC,KAAK,KAAK,SAAS,EAAE,GAAG,OAAO,SAAS,GAAG,GAAG,CAAC,CACjD,GACA,EACF,GACA,OAAO,MAAM,GAAG,EAAE,CAEW;AACjC,CAAC"}
|
|
@@ -7,6 +7,8 @@ import * as Path from "effect/Path";
|
|
|
7
7
|
* POSIX and `%LOCALAPPDATA%` on Windows. Shared by every checkout on the
|
|
8
8
|
* machine, so binaries are downloaded once and push locks are seen by every
|
|
9
9
|
* stack. None when no absolute directory can be derived.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
10
12
|
*/
|
|
11
13
|
export declare const userCache: Effect.Effect<Option.None<string> | Option.Some<string>, Config.ConfigError, Path.Path>;
|
|
12
14
|
//# sourceMappingURL=UserCache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserCache.d.ts","
|
|
1
|
+
{"version":3,"file":"UserCache.d.ts","sources":["../../src/internal/UserCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,yFAoBpB,CAAC"}
|
|
@@ -2,12 +2,14 @@ import * as Effect from "effect/Effect";
|
|
|
2
2
|
import * as Path from "effect/Path";
|
|
3
3
|
import * as Config from "effect/Config";
|
|
4
4
|
import * as Option from "effect/Option";
|
|
5
|
-
|
|
5
|
+
// src/internal/UserCache.ts
|
|
6
6
|
/**
|
|
7
7
|
* The user's cache directory, as the Convex CLI resolves it: `~/.cache` on
|
|
8
8
|
* POSIX and `%LOCALAPPDATA%` on Windows. Shared by every checkout on the
|
|
9
9
|
* machine, so binaries are downloaded once and push locks are seen by every
|
|
10
10
|
* stack. None when no absolute directory can be derived.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
11
13
|
*/
|
|
12
14
|
const userCache = Effect.gen(function* () {
|
|
13
15
|
const path = yield* Path.Path;
|
|
@@ -16,10 +18,9 @@ const userCache = Effect.gen(function* () {
|
|
|
16
18
|
LOCALAPPDATA: Config.String("LOCALAPPDATA").pipe(Config.withDefault("")),
|
|
17
19
|
USERPROFILE: Config.String("USERPROFILE").pipe(Config.withDefault(""))
|
|
18
20
|
});
|
|
19
|
-
const root = process.platform === "win32" ? LOCALAPPDATA
|
|
20
|
-
return root && path.isAbsolute(root) ? Option.some(root) : Option.none();
|
|
21
|
+
const root = process.platform === "win32" ? LOCALAPPDATA !== "" ? LOCALAPPDATA : USERPROFILE === "" ? "" : path.join(USERPROFILE, "AppData", "Local") : HOME === "" ? "" : path.join(HOME, ".cache");
|
|
22
|
+
return root !== "" && path.isAbsolute(root) ? Option.some(root) : Option.none();
|
|
21
23
|
});
|
|
22
|
-
//#endregion
|
|
23
24
|
export { userCache };
|
|
24
25
|
|
|
25
26
|
//# sourceMappingURL=UserCache.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserCache.js","names":[],"sources":["../../src/internal/UserCache.ts"],"sourcesContent":["import * as Config from \"effect/Config\";\nimport * as Effect from \"effect/Effect\";\nimport * as Option from \"effect/Option\";\nimport * as Path from \"effect/Path\";\n\n/**\n * The user's cache directory, as the Convex CLI resolves it: `~/.cache` on\n * POSIX and `%LOCALAPPDATA%` on Windows. Shared by every checkout on the\n * machine, so binaries are downloaded once and push locks are seen by every\n * stack. None when no absolute directory can be derived.\n */\nexport const userCache = Effect.gen(function* () {\n const path = yield* Path.Path;\n const { HOME, LOCALAPPDATA, USERPROFILE } = yield* Config.all({\n HOME: Config.String(\"HOME\").pipe(Config.withDefault(\"\")),\n LOCALAPPDATA: Config.String(\"LOCALAPPDATA\").pipe(Config.withDefault(\"\")),\n USERPROFILE: Config.String(\"USERPROFILE\").pipe(Config.withDefault(\"\")),\n });\n const root =\n process.platform === \"win32\"\n ? LOCALAPPDATA
|
|
1
|
+
{"version":3,"file":"UserCache.js","names":[],"sources":["../../src/internal/UserCache.ts"],"sourcesContent":["import * as Config from \"effect/Config\";\nimport * as Effect from \"effect/Effect\";\nimport * as Option from \"effect/Option\";\nimport * as Path from \"effect/Path\";\n\n/**\n * The user's cache directory, as the Convex CLI resolves it: `~/.cache` on\n * POSIX and `%LOCALAPPDATA%` on Windows. Shared by every checkout on the\n * machine, so binaries are downloaded once and push locks are seen by every\n * stack. None when no absolute directory can be derived.\n *\n * @internal\n */\nexport const userCache = Effect.gen(function* () {\n const path = yield* Path.Path;\n const { HOME, LOCALAPPDATA, USERPROFILE } = yield* Config.all({\n HOME: Config.String(\"HOME\").pipe(Config.withDefault(\"\")),\n LOCALAPPDATA: Config.String(\"LOCALAPPDATA\").pipe(Config.withDefault(\"\")),\n USERPROFILE: Config.String(\"USERPROFILE\").pipe(Config.withDefault(\"\")),\n });\n const root =\n process.platform === \"win32\"\n ? LOCALAPPDATA !== \"\"\n ? LOCALAPPDATA\n : USERPROFILE === \"\"\n ? \"\"\n : path.join(USERPROFILE, \"AppData\", \"Local\")\n : HOME === \"\"\n ? \"\"\n : path.join(HOME, \".cache\");\n return root !== \"\" && path.isAbsolute(root)\n ? Option.some(root)\n : Option.none();\n});\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAa,YAAY,OAAO,IAAI,aAAa;CAC/C,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,EAAE,MAAM,cAAc,gBAAgB,OAAO,OAAO,IAAI;EAC5D,MAAM,OAAO,OAAO,MAAM,CAAC,CAAC,KAAK,OAAO,YAAY,EAAE,CAAC;EACvD,cAAc,OAAO,OAAO,cAAc,CAAC,CAAC,KAAK,OAAO,YAAY,EAAE,CAAC;EACvE,aAAa,OAAO,OAAO,aAAa,CAAC,CAAC,KAAK,OAAO,YAAY,EAAE,CAAC;CACvE,CAAC;CACD,MAAM,OACJ,QAAQ,aAAa,UACjB,iBAAiB,KACf,eACA,gBAAgB,KACd,KACA,KAAK,KAAK,aAAa,WAAW,OAAO,IAC7C,SAAS,KACP,KACA,KAAK,KAAK,MAAM,QAAQ;CAChC,OAAO,SAAS,MAAM,KAAK,WAAW,IAAI,IACtC,OAAO,KAAK,IAAI,IAChB,OAAO,KAAK;AAClB,CAAC"}
|
package/dist/internal/Zip.d.ts
CHANGED
|
@@ -3,12 +3,16 @@ import * as FileSystem from "effect/FileSystem";
|
|
|
3
3
|
import * as Schema from "effect/Schema";
|
|
4
4
|
declare const ZipError_base: Schema.Class<ZipError, Schema.TaggedStruct<"ZipError", {
|
|
5
5
|
readonly reason: Schema.Literals<readonly ["format", "entry", "io"]>;
|
|
6
|
-
}>, import("effect/Cause").YieldableError
|
|
6
|
+
}>, import("effect/Cause").YieldableError & {
|
|
7
|
+
readonly brand: unique symbol;
|
|
8
|
+
}>;
|
|
7
9
|
export declare class ZipError extends ZipError_base {
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
12
|
* Extract one entry of a zip archive. Convex publishes the local backend as a
|
|
11
13
|
* single-file zip, stored or deflated.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
12
16
|
*/
|
|
13
17
|
export declare const extract: (archive: string, name: string, destination: string) => Effect.Effect<void, ZipError, FileSystem.FileSystem>;
|
|
14
18
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Zip.d.ts","
|
|
1
|
+
{"version":3,"file":"Zip.d.ts","sources":["../../src/internal/Zip.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;;;;oBAIpB,OAAO,MAAM;;AAFjC,qBAAa,QAAS,SAAQ,aAK5B;CAAG;AA2EL;;;;;GAKG;AACH,eAAO,MAAM,OAAO,8GAoBlB,CAAC"}
|
package/dist/internal/Zip.js
CHANGED
|
@@ -3,13 +3,13 @@ import * as FileSystem from "effect/FileSystem";
|
|
|
3
3
|
import * as Schema from "effect/Schema";
|
|
4
4
|
import * as Result from "effect/Result";
|
|
5
5
|
import { inflateRaw } from "node:zlib";
|
|
6
|
-
|
|
6
|
+
// src/internal/Zip.ts
|
|
7
7
|
var ZipError = class extends Schema.TaggedError()("ZipError", { reason: Schema.Literals([
|
|
8
8
|
"format",
|
|
9
9
|
"entry",
|
|
10
10
|
"io"
|
|
11
11
|
]) }) {};
|
|
12
|
-
const format = () => Result.fail(
|
|
12
|
+
const format = () => Result.fail(ZipError.make({ reason: "format" }));
|
|
13
13
|
/**
|
|
14
14
|
* Locate one entry's compressed bytes through the archive's central directory.
|
|
15
15
|
* No Zip64: a single-file release far under 4 GiB never needs it.
|
|
@@ -42,24 +42,25 @@ const locate = (archive, name) => {
|
|
|
42
42
|
}
|
|
43
43
|
offset += 46 + nameLength + bytes.readUInt16LE(offset + 30) + bytes.readUInt16LE(offset + 32);
|
|
44
44
|
}
|
|
45
|
-
return Result.fail(
|
|
45
|
+
return Result.fail(ZipError.make({ reason: "entry" }));
|
|
46
46
|
};
|
|
47
47
|
const inflate = (data) => Effect.callback((resume) => {
|
|
48
|
-
inflateRaw(data, (error, output) => resume(error ? Effect.fail(
|
|
48
|
+
inflateRaw(data, (error, output) => resume(error !== null ? Effect.fail(ZipError.make({ reason: "format" })) : Effect.succeed(output)));
|
|
49
49
|
});
|
|
50
50
|
/**
|
|
51
51
|
* Extract one entry of a zip archive. Convex publishes the local backend as a
|
|
52
52
|
* single-file zip, stored or deflated.
|
|
53
|
+
*
|
|
54
|
+
* @internal
|
|
53
55
|
*/
|
|
54
56
|
const extract = Effect.fn("Zip.extract")(function* (archive, name, destination) {
|
|
55
57
|
const fs = yield* FileSystem.FileSystem;
|
|
56
|
-
const bytes = yield* fs.readFile(archive).pipe(Effect.mapError(() =>
|
|
58
|
+
const bytes = yield* fs.readFile(archive).pipe(Effect.mapError(() => ZipError.make({ reason: "io" })));
|
|
57
59
|
const entry = yield* Effect.fromResult(locate(bytes, name));
|
|
58
60
|
const data = bytes.subarray(entry.start, entry.end);
|
|
59
|
-
const content = entry.method === 8 ? yield* inflate(data) : entry.method === 0 ? data : yield*
|
|
60
|
-
yield* fs.writeFile(destination, content, { mode: 493 }).pipe(Effect.mapError(() =>
|
|
61
|
+
const content = entry.method === 8 ? yield* inflate(data) : entry.method === 0 ? data : yield* ZipError.make({ reason: "format" });
|
|
62
|
+
yield* fs.writeFile(destination, content, { mode: 493 }).pipe(Effect.mapError(() => ZipError.make({ reason: "io" })));
|
|
61
63
|
});
|
|
62
|
-
//#endregion
|
|
63
64
|
export { ZipError, extract };
|
|
64
65
|
|
|
65
66
|
//# sourceMappingURL=Zip.js.map
|
package/dist/internal/Zip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Zip.js","names":[],"sources":["../../src/internal/Zip.ts"],"sourcesContent":["import { inflateRaw } from \"node:zlib\";\nimport * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\n\nexport class ZipError extends Schema.TaggedError
|
|
1
|
+
{"version":3,"file":"Zip.js","names":[],"sources":["../../src/internal/Zip.ts"],"sourcesContent":["import { inflateRaw } from \"node:zlib\";\nimport * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\n\nexport class ZipError extends Schema.TaggedError<\n ZipError,\n { readonly brand: unique symbol }\n>()(\"ZipError\", {\n reason: Schema.Literals([\"format\", \"entry\", \"io\"]),\n}) {}\n\ninterface Entry {\n readonly method: number;\n readonly start: number;\n readonly end: number;\n}\n\nconst format = () => Result.fail(ZipError.make({ reason: \"format\" }));\n\n/**\n * Locate one entry's compressed bytes through the archive's central directory.\n * No Zip64: a single-file release far under 4 GiB never needs it.\n */\nconst locate = (\n archive: Uint8Array,\n name: string,\n): Result.Result<Entry, ZipError> => {\n const bytes = Buffer.from(archive.buffer, archive.byteOffset, archive.length);\n const end = bytes.lastIndexOf(Buffer.from([0x50, 0x4b, 0x05, 0x06]));\n if (end < 0 || end + 22 > bytes.length) return format();\n const directoryEnd =\n bytes.readUInt32LE(end + 16) + bytes.readUInt32LE(end + 12);\n if (directoryEnd > bytes.length) return format();\n for (\n let offset = bytes.readUInt32LE(end + 16);\n offset + 46 <= directoryEnd;\n ) {\n if (bytes.readUInt32LE(offset) !== 0x02014b50) return format();\n const nameLength = bytes.readUInt16LE(offset + 28);\n const entryName = bytes.toString(\n \"utf8\",\n offset + 46,\n offset + 46 + nameLength,\n );\n if (entryName === name) {\n const size = bytes.readUInt32LE(offset + 20);\n const header = bytes.readUInt32LE(offset + 42);\n if (\n header + 30 > bytes.length ||\n bytes.readUInt32LE(header) !== 0x04034b50\n )\n return format();\n const start =\n header +\n 30 +\n bytes.readUInt16LE(header + 26) +\n bytes.readUInt16LE(header + 28);\n if (start + size > bytes.length) return format();\n return Result.succeed({\n method: bytes.readUInt16LE(offset + 10),\n start,\n end: start + size,\n });\n }\n offset +=\n 46 +\n nameLength +\n bytes.readUInt16LE(offset + 30) +\n bytes.readUInt16LE(offset + 32);\n }\n return Result.fail(ZipError.make({ reason: \"entry\" }));\n};\n\nconst inflate = (data: Uint8Array) =>\n Effect.callback<Uint8Array, ZipError>((resume) => {\n inflateRaw(data, (error, output) =>\n resume(\n error !== null\n ? Effect.fail(ZipError.make({ reason: \"format\" }))\n : Effect.succeed(output),\n ),\n );\n });\n\n/**\n * Extract one entry of a zip archive. Convex publishes the local backend as a\n * single-file zip, stored or deflated.\n *\n * @internal\n */\nexport const extract = Effect.fn(\"Zip.extract\")(function* (\n archive: string,\n name: string,\n destination: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const bytes = yield* fs\n .readFile(archive)\n .pipe(Effect.mapError(() => ZipError.make({ reason: \"io\" })));\n const entry = yield* Effect.fromResult(locate(bytes, name));\n const data = bytes.subarray(entry.start, entry.end);\n const content =\n entry.method === 8\n ? yield* inflate(data)\n : entry.method === 0\n ? data\n : yield* ZipError.make({ reason: \"format\" });\n yield* fs\n .writeFile(destination, content, { mode: 0o755 })\n .pipe(Effect.mapError(() => ZipError.make({ reason: \"io\" })));\n});\n"],"mappings":";;;;;;AAMA,IAAa,WAAb,cAA8B,OAAO,YAGnC,CAAC,CAAC,YAAY,EACd,QAAQ,OAAO,SAAS;CAAC;CAAU;CAAS;AAAI,CAAC,EACnD,CAAC,CAAC,CAAC,CAAC;AAQJ,MAAM,eAAe,OAAO,KAAK,SAAS,KAAK,EAAE,QAAQ,SAAS,CAAC,CAAC;;;;;AAMpE,MAAM,UACJ,SACA,SACmC;CACnC,MAAM,QAAQ,OAAO,KAAK,QAAQ,QAAQ,QAAQ,YAAY,QAAQ,MAAM;CAC5E,MAAM,MAAM,MAAM,YAAY,OAAO,KAAK;EAAC;EAAM;EAAM;EAAM;CAAI,CAAC,CAAC;CACnE,IAAI,MAAM,KAAK,MAAM,KAAK,MAAM,QAAQ,OAAO,OAAO;CACtD,MAAM,eACJ,MAAM,aAAa,MAAM,EAAE,IAAI,MAAM,aAAa,MAAM,EAAE;CAC5D,IAAI,eAAe,MAAM,QAAQ,OAAO,OAAO;CAC/C,KACE,IAAI,SAAS,MAAM,aAAa,MAAM,EAAE,GACxC,SAAS,MAAM,eACf;EACA,IAAI,MAAM,aAAa,MAAM,MAAM,UAAY,OAAO,OAAO;EAC7D,MAAM,aAAa,MAAM,aAAa,SAAS,EAAE;EAMjD,IALkB,MAAM,SACtB,QACA,SAAS,IACT,SAAS,KAAK,UAEJ,MAAM,MAAM;GACtB,MAAM,OAAO,MAAM,aAAa,SAAS,EAAE;GAC3C,MAAM,SAAS,MAAM,aAAa,SAAS,EAAE;GAC7C,IACE,SAAS,KAAK,MAAM,UACpB,MAAM,aAAa,MAAM,MAAM,UAE/B,OAAO,OAAO;GAChB,MAAM,QACJ,SACA,KACA,MAAM,aAAa,SAAS,EAAE,IAC9B,MAAM,aAAa,SAAS,EAAE;GAChC,IAAI,QAAQ,OAAO,MAAM,QAAQ,OAAO,OAAO;GAC/C,OAAO,OAAO,QAAQ;IACpB,QAAQ,MAAM,aAAa,SAAS,EAAE;IACtC;IACA,KAAK,QAAQ;GACf,CAAC;EACH;EACA,UACE,KACA,aACA,MAAM,aAAa,SAAS,EAAE,IAC9B,MAAM,aAAa,SAAS,EAAE;CAClC;CACA,OAAO,OAAO,KAAK,SAAS,KAAK,EAAE,QAAQ,QAAQ,CAAC,CAAC;AACvD;AAEA,MAAM,WAAW,SACf,OAAO,UAAgC,WAAW;CAChD,WAAW,OAAO,OAAO,WACvB,OACE,UAAU,OACN,OAAO,KAAK,SAAS,KAAK,EAAE,QAAQ,SAAS,CAAC,CAAC,IAC/C,OAAO,QAAQ,MAAM,CAC3B,CACF;AACF,CAAC;;;;;;;AAQH,MAAa,UAAU,OAAO,GAAG,aAAa,CAAC,CAAC,WAC9C,SACA,MACA,aACA;CACA,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,QAAQ,OAAO,GAClB,SAAS,OAAO,CAAC,CACjB,KAAK,OAAO,eAAe,SAAS,KAAK,EAAE,QAAQ,KAAK,CAAC,CAAC,CAAC;CAC9D,MAAM,QAAQ,OAAO,OAAO,WAAW,OAAO,OAAO,IAAI,CAAC;CAC1D,MAAM,OAAO,MAAM,SAAS,MAAM,OAAO,MAAM,GAAG;CAClD,MAAM,UACJ,MAAM,WAAW,IACb,OAAO,QAAQ,IAAI,IACnB,MAAM,WAAW,IACf,OACA,OAAO,SAAS,KAAK,EAAE,QAAQ,SAAS,CAAC;CACjD,OAAO,GACJ,UAAU,aAAa,SAAS,EAAE,MAAM,IAAM,CAAC,CAAC,CAChD,KAAK,OAAO,eAAe,SAAS,KAAK,EAAE,QAAQ,KAAK,CAAC,CAAC,CAAC;AAChE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gaganref/confect-alchemy",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.6.0-fork.1",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@convex-dev/platform": "^0.1.10"
|
|
6
6
|
},
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@confect/cli": "npm:@gaganref/confect-cli@10.
|
|
9
|
-
"@confect/core": "npm:@gaganref/confect-core@10.
|
|
10
|
-
"alchemy": "2.0.0-beta.
|
|
8
|
+
"@confect/cli": "npm:@gaganref/confect-cli@10.6.0-fork.1",
|
|
9
|
+
"@confect/core": "npm:@gaganref/confect-core@10.6.0-fork.1",
|
|
10
|
+
"alchemy": "2.0.0-beta.86",
|
|
11
11
|
"convex": "^1.32.0",
|
|
12
|
-
"effect": "
|
|
12
|
+
"effect": "~4.1.4"
|
|
13
13
|
},
|
|
14
14
|
"description": "Alchemy resources for deploying Convex and Confect applications",
|
|
15
15
|
"author": "RJ Dellecese",
|
package/src/Backend.ts
CHANGED
|
@@ -85,12 +85,13 @@ const backend = (
|
|
|
85
85
|
const code = yield* Code("Code", {
|
|
86
86
|
deployment: {
|
|
87
87
|
name: props.deployment.name,
|
|
88
|
-
url:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
url:
|
|
89
|
+
environment !== undefined
|
|
90
|
+
? Output.map(
|
|
91
|
+
Output.all(environment.variables, environment.url),
|
|
92
|
+
([, url]) => url,
|
|
93
|
+
)
|
|
94
|
+
: props.deployment.url,
|
|
94
95
|
},
|
|
95
96
|
deployKey: props.deployKey,
|
|
96
97
|
...(props.cwd === undefined ? {} : { cwd: props.cwd }),
|
package/src/Code.ts
CHANGED
|
@@ -59,13 +59,24 @@ const make = (mode: ProviderMode) =>
|
|
|
59
59
|
} satisfies Provider.ProviderServiceInput<Code>;
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* @stability unstable
|
|
64
|
+
*/
|
|
62
65
|
export const provider = make("live");
|
|
63
66
|
/**
|
|
64
67
|
* Under `alchemy dev`, pushes go to the local backend's self-hosted target.
|
|
68
|
+
*
|
|
69
|
+
* @stability unstable
|
|
65
70
|
*/
|
|
66
71
|
export const localProvider = make("local");
|
|
67
72
|
|
|
73
|
+
/**
|
|
74
|
+
* @stability unstable
|
|
75
|
+
*/
|
|
68
76
|
export const layer = Provider.effect(Code, provider);
|
|
77
|
+
/**
|
|
78
|
+
* @stability unstable
|
|
79
|
+
*/
|
|
69
80
|
export const localLayer = Provider.effect(Code, localProvider).pipe(
|
|
70
81
|
Layer.provide(
|
|
71
82
|
ConvexClientLayer({ mode: "local" }).pipe(
|