diff --git a/deno.json b/deno.json index 6f87873166..a853cb50d5 100644 --- a/deno.json +++ b/deno.json @@ -1,13 +1,8 @@ { "$schema": "https://raw.githubusercontent.com/denoland/deno/refs/heads/main/cli/schemas/config-file.v1.json", "nodeModulesDir": "manual", - "unstable": [ - "bare-node-builtins", - "node-globals" - ], - "workspace": [ - "./packages/*" - ], + "unstable": ["bare-node-builtins", "node-globals"], + "workspace": ["./packages/*"], "exclude": [ "**/*.mjs", "**/*.cjs", @@ -22,8 +17,10 @@ "scratchpad/", "packages/*/dtslint/", "packages/*/benchmark/", + "packages/effect/test/cluster/", "packages/platform-bun/", "packages/platform-node/", - "packages/platform-node-shared/" + "packages/platform-node-shared/", + "packages/sql" ] } diff --git a/flake.nix b/flake.nix index 0ed529d49f..01607f362b 100644 --- a/flake.nix +++ b/flake.nix @@ -2,26 +2,23 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; }; - outputs = - { nixpkgs, ... }: - let - forAllSystems = - function: - nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed ( - system: function nixpkgs.legacyPackages.${system} - ); - in - { - formatter = forAllSystems (pkgs: pkgs.alejandra); - devShells = forAllSystems (pkgs: { - default = pkgs.mkShell { - packages = with pkgs; [ - bun - deno - corepack - nodejs_24 - ]; - }; - }); - }; + outputs = {nixpkgs, ...}: let + forAllSystems = function: + nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed ( + system: function nixpkgs.legacyPackages.${system} + ); + in { + formatter = forAllSystems (pkgs: pkgs.alejandra); + devShells = forAllSystems (pkgs: { + default = pkgs.mkShell { + packages = with pkgs; [ + bun + deno + corepack + nodejs_24 + python3 + ]; + }; + }); + }; } diff --git a/package.json b/package.json index 4d16352c7d..5ba54c2aef 100644 --- a/package.json +++ b/package.json @@ -37,62 +37,64 @@ "#dist/effect/*": "./packages/effect/dist/*.js" }, "devDependencies": { - "@babel/cli": "^7.28.0", - "@babel/core": "^7.28.0", + "@babel/cli": "^7.28.3", + "@babel/core": "^7.28.3", "@babel/plugin-transform-export-namespace-from": "^7.24.7", "@babel/plugin-transform-modules-commonjs": "^7.24.8", "@changesets/changelog-github": "^0.5.0", - "@changesets/cli": "^2.29.5", + "@changesets/cli": "^2.29.6", "@edge-runtime/vm": "^5.0.0", "@effect/build-utils": "^0.8.9", "@effect/docgen": "https://pkg.pr.new/Effect-TS/docgen/@effect/docgen@49e99a2", "@effect/eslint-plugin": "^0.3.2", - "@effect/language-service": "^0.28.3", + "@effect/language-service": "^0.36.0", "@effect/vitest": "workspace:^", - "@eslint/js": "^9.31.0", + "@eslint/js": "^9.34.0", "@rollup/plugin-node-resolve": "^16.0.1", "@rollup/plugin-replace": "^6.0.2", "@rollup/plugin-terser": "^0.4.4", "@types/jscodeshift": "^17.3.0", - "@types/node": "^24.1.0", + "@types/node": "^24.3.0", "@vitest/browser": "^3.2.4", "@vitest/coverage-v8": "^3.2.4", "@vitest/expect": "^3.2.4", "@vitest/web-worker": "^3.2.4", "ast-types": "^0.14.2", "babel-plugin-annotate-pure-calls": "^0.5.0", - "eslint": "^9.31.0", + "eslint": "^9.34.0", "eslint-import-resolver-typescript": "^4.4.4", "eslint-plugin-import-x": "^4.16.1", "eslint-plugin-local-rules": "^3.0.2", "eslint-plugin-simple-import-sort": "^12.1.1", "eslint-plugin-sort-destructure-keys": "^2.0.0", "glob": "^11.0.3", - "i18next": "^25.3.2", + "i18next": "^25.4.2", "jscodeshift": "^17.1.2", "madge": "^8.0.0", - "playwright": "^1.54.1", + "playwright": "^1.55.0", "prettier": "^3.6.2", "rimraf": "^6.0.1", - "rollup": "^4.45.1", - "rollup-plugin-bundle-stats": "^4.21.0", + "rollup": "^4.48.1", + "rollup-plugin-bundle-stats": "^4.21.3", "rollup-plugin-esbuild": "^6.2.1", "rollup-plugin-visualizer": "^6.0.3", "terser": "^5.43.1", "ts-patch": "^3.3.0", "tstyche": "4.3.0", - "tsx": "^4.20.3", - "typescript": "^5.8.3", - "typescript-eslint": "^8.38.0", - "vite": "^7.0.5", + "tsx": "^4.20.5", + "typescript": "^5.9.2", + "typescript-eslint": "^8.41.0", + "vite": "^7.1.3", + "vite-tsconfig-paths": "^5.1.4", "vitest": "^3.2.4", "vitest-websocket-mock": "^0.5.0", - "zod": "^4.0.7" + "zod": "^4.1.3" }, "pnpm": { "patchedDependencies": { "@changesets/get-github-info@0.6.0": "patches/@changesets__get-github-info@0.6.0.patch", - "@changesets/assemble-release-plan": "patches/@changesets__assemble-release-plan.patch" + "@changesets/assemble-release-plan": "patches/@changesets__assemble-release-plan.patch", + "@op-engineering/op-sqlite": "patches/@op-engineering__op-sqlite.patch" }, "ignoredBuiltDependencies": [ "cpu-features", diff --git a/packages/effect/package.json b/packages/effect/package.json index 0583d0acfb..e65e7bbc77 100644 --- a/packages/effect/package.json +++ b/packages/effect/package.json @@ -52,13 +52,18 @@ "./time": "./src/time/index.ts", "./transactions": "./src/transactions/index.ts", "./types": "./src/types/index.ts", + "./unstable/cluster": "./src/unstable/cluster/index.ts", "./unstable/http": "./src/unstable/http/index.ts", "./unstable/httpapi": "./src/unstable/httpapi/index.ts", + "./unstable/reactivity": "./src/unstable/reactivity/index.ts", "./unstable/rpc": "./src/unstable/rpc/index.ts", + "./unstable/schema": "./src/unstable/schema/index.ts", "./unstable/socket": "./src/unstable/socket/index.ts", + "./unstable/sql": "./src/unstable/sql/index.ts", "./unstable/observability": "./src/unstable/observability/index.ts", "./*": "./src/*.ts", "./internal/*": null, + "./unstable/cluster/internal/*": null, "./*/index": null }, "files": [ @@ -96,10 +101,14 @@ "./time": "./dist/time/index.js", "./transactions": "./dist/transactions/index.js", "./types": "./dist/types/index.js", + "./unstable/cluster": "./dist/unstable/cluster/index.js", "./unstable/http": "./dist/unstable/http/index.js", "./unstable/httpapi": "./dist/unstable/httpapi/index.js", + "./unstable/reactivity": "./dist/unstable/reactivity/index.js", "./unstable/rpc": "./dist/unstable/rpc/index.js", + "./unstable/schema": "./dist/unstable/schema/index.js", "./unstable/socket": "./dist/unstable/socket/index.js", + "./unstable/sql": "./dist/unstable/sql/index.js", "./unstable/observability": "./dist/unstable/observability/index.js", "./*": "./dist/*.js", "./internal/*": null, @@ -115,12 +124,12 @@ "coverage": "vitest --coverage" }, "devDependencies": { - "@types/node": "^24.0.14", + "@types/node": "^24.3.0", "ajv": "^8.17.1", "arktype": "^2.1.20", "ast-types": "^0.14.2", "immer": "^10.1.1", - "tinybench": "^4.0.1", + "tinybench": "^5.0.1", "valibot": "^1.1.0" }, "dependencies": { @@ -128,6 +137,7 @@ "fast-check": "^4.2.0", "find-my-way-ts": "^0.1.6", "msgpackr": "^1.11.5", - "multipasta": "^0.2.7" + "multipasta": "^0.2.7", + "uuid": "^11.1.0" } } diff --git a/packages/effect/src/Effect.ts b/packages/effect/src/Effect.ts index a92831ec5f..42dcc87a77 100644 --- a/packages/effect/src/Effect.ts +++ b/packages/effect/src/Effect.ts @@ -3637,6 +3637,28 @@ export const delay: { */ export const sleep: (duration: Duration.DurationInput) => Effect = internal.sleep +/** + * Executes an effect and measures the time it takes to complete. + * + * **Details** + * + * This function wraps the provided effect and returns a new effect that, when + * executed, performs the original effect and calculates its execution duration. + * + * The result of the new effect includes both the execution time (as a + * `Duration`) and the original effect's result. This is useful for monitoring + * performance or gaining insights into the time taken by specific operations. + * + * The original effect's behavior (success, failure, or interruption) remains + * unchanged, and the timing information is provided alongside the result in a + * tuple. + * + * @since 2.0.0 + * @category Delays & Timeouts + */ +export const timed: (self: Effect) => Effect<[duration: Duration.Duration, result: A], E, R> = + internal.timed + // ----------------------------------------------------------------------------- // Racing // ----------------------------------------------------------------------------- @@ -4292,6 +4314,60 @@ export const matchEffect: { ): Effect } = internal.matchEffect +// ----------------------------------------------------------------------------- +// Condition checking +// ----------------------------------------------------------------------------- + +/** + * Checks if an effect has failed. + * + * **Details** + * + * This function evaluates whether an effect has resulted in a failure. It + * returns a boolean value wrapped in an effect, with `true` indicating the + * effect failed and `false` otherwise. + * + * The resulting effect cannot fail (`never` in the error channel) but retains + * the context of the original effect. + * + * **Example** + * + * ```ts + * import { Effect } from "effect" + * + * const failure = Effect.fail("Uh oh!") + * + * console.log(Effect.runSync(Effect.isFailure(failure))) + * // Output: true + * + * const defect = Effect.die("BOOM!") + * + * Effect.runSync(Effect.isFailure(defect)) + * // throws: BOOM! + * ``` + * + * @since 2.0.0 + * @category Condition Checking + */ +export const isFailure: (self: Effect) => Effect = internal.isFailure + +/** + * Checks if an effect has succeeded. + * + * **Details** + * + * This function evaluates whether an effect has resulted in a success. It + * returns a boolean value wrapped in an effect, with `true` indicating the + * effect succeeded and `false` otherwise. + * + * The resulting effect cannot fail (`never` in the error channel) but retains + * the context of the original effect. + * + * @since 2.0.0 + * @category Condition Checking + */ +export const isSuccess: (self: Effect) => Effect = internal.isSuccess + // ----------------------------------------------------------------------------- // Environment // ----------------------------------------------------------------------------- @@ -5676,6 +5752,8 @@ export const interruptibleMask: ( * ``` */ export interface Semaphore { + /** when a permit is available, run the effect and release the permits when finished */ + withPermit(self: Effect): Effect /** when the given amount of permits are available, run the effect and release the permits when finished */ withPermits( permits: number @@ -6108,6 +6186,66 @@ export const repeatOrElse: { ): Effect } = internalSchedule.repeatOrElse +/** + * Replicates the given effect `n` times. + * + * **Details** + * + * This function takes an effect and replicates it a specified number of times + * (`n`). The result is an array of `n` effects, each of which is identical to + * the original effect. + * + * @since 2.0.0 + */ +export const replicate: { + (n: number): (self: Effect) => Array> + (self: Effect, n: number): Array> +} = internal.replicate + +/** + * Performs this effect the specified number of times and collects the results. + * + * **Details** + * + * This function repeats an effect multiple times and collects the results into + * an array. You specify how many times to execute the effect, and it runs that + * many times, either in sequence or concurrently depending on the provided + * options. + * + * **Options** + * + * If the `discard` option is set to `true`, the intermediate results are not + * collected, and the final result of the operation is `void`. + * + * The function also allows you to customize how the effects are handled by + * specifying options such as concurrency, batching, and how finalizers behave. + * These options provide flexibility in running the effects concurrently or + * adjusting other execution details. + * + * @since 2.0.0 + * @category Collecting + */ +export const replicateEffect: { + ( + n: number, + options?: { readonly concurrency?: Concurrency | undefined; readonly discard?: false | undefined } + ): (self: Effect) => Effect, E, R> + ( + n: number, + options: { readonly concurrency?: Concurrency | undefined; readonly discard: true } + ): (self: Effect) => Effect + ( + self: Effect, + n: number, + options?: { readonly concurrency?: Concurrency | undefined; readonly discard?: false | undefined } + ): Effect, E, R> + ( + self: Effect, + n: number, + options: { readonly concurrency?: Concurrency | undefined; readonly discard: true } + ): Effect +} = internal.replicateEffect + /** * Repeats an effect based on a specified schedule. * diff --git a/packages/effect/src/Layer.ts b/packages/effect/src/Layer.ts index dd5f97aa5a..a6b8c0740c 100644 --- a/packages/effect/src/Layer.ts +++ b/packages/effect/src/Layer.ts @@ -1373,6 +1373,36 @@ export const catchCause: { ) as any )) +/** + * Updates a service in the context with a new implementation. + * + * **Details** + * + * This function modifies the existing implementation of a service in the + * context. It retrieves the current service, applies the provided + * transformation function `f`, and replaces the old service with the + * transformed one. + * + * **When to Use** + * + * This is useful for adapting or extending a service's behavior during the + * creation of a layer. + * + * @since 3.13.0 + * @category utils + */ +export const updateService: { + (key: ServiceMap.Key, f: (a: A) => A): (layer: Layer) => Layer + (layer: Layer, key: ServiceMap.Key, f: (a: A) => A): Layer +} = dual( + 3, + (layer: Layer, key: ServiceMap.Key, f: (a: A) => A): Layer => + provide( + layer, + effect(key)(internalEffect.map(key.asEffect(), f)) + ) +) + /** * Creates a fresh version of this layer that will not be shared. * diff --git a/packages/effect/src/Pool.ts b/packages/effect/src/Pool.ts new file mode 100644 index 0000000000..05ae49e9f5 --- /dev/null +++ b/packages/effect/src/Pool.ts @@ -0,0 +1,550 @@ +/** + * @since 2.0.0 + */ +import type * as Cause from "./Cause.ts" +import * as Iterable from "./collections/Iterable.ts" +import { hasProperty } from "./data/Predicate.ts" +import * as Effect from "./Effect.ts" +import type * as Exit from "./Exit.ts" +import * as Fiber from "./Fiber.ts" +import { dual, identity } from "./Function.ts" +import { type Pipeable, pipeArguments } from "./interfaces/Pipeable.ts" +import * as Queue from "./Queue.ts" +import { UnhandledLogLevel } from "./References.ts" +import * as Scope from "./Scope.ts" +import * as ServiceMap from "./ServiceMap.ts" +import { Clock } from "./time/Clock.ts" +import * as Duration from "./time/Duration.ts" + +/** + * @since 2.0.0 + * @category symbols + */ +export const TypeId: TypeId = "~effect/Pool" + +/** + * @since 2.0.0 + * @category symbols + */ +export type TypeId = "~effect/Pool" + +/** + * A `Pool` is a pool of items of type `A`, each of which may be + * associated with the acquisition and release of resources. An attempt to get + * an item `A` from a pool may fail with an error of type `E`. + * + * @since 2.0.0 + * @category models + */ +export interface Pool extends Pipeable { + readonly [TypeId]: TypeId + readonly config: Config + readonly state: State +} + +/** + * @since 4.0.0 + * @category models + */ +export interface Config { + readonly acquire: Effect.Effect + readonly concurrency: number + readonly minSize: number + readonly maxSize: number + readonly strategy: Strategy + readonly targetUtilization: number +} + +/** + * @since 4.0.0 + * @category models + */ +export interface State { + readonly scope: Scope.Scope + isShuttingDown: boolean + readonly semaphore: Effect.Semaphore + readonly resizeSemaphore: Effect.Semaphore + readonly items: Set> + readonly available: Set> + readonly availableLatch: Effect.Latch + readonly invalidated: Set> + waiters: number +} + +/** + * @since 4.0.0 + * @category models + */ +export interface PoolItem { + readonly exit: Exit.Exit + finalizer: Effect.Effect + refCount: number + disableReclaim: boolean +} + +/** + * @since 4.0.0 + * @category models + */ +export interface Strategy { + readonly run: (pool: Pool) => Effect.Effect + readonly onAcquire: (item: PoolItem) => Effect.Effect + readonly reclaim: (pool: Pool) => Effect.Effect | undefined> +} + +/** + * Returns `true` if the specified value is a `Pool`, `false` otherwise. + * + * @since 2.0.0 + * @category refinements + */ +export const isPool = (u: unknown): u is Pool => hasProperty(u, TypeId) + +/** + * Makes a new pool of the specified fixed size. The pool is returned in a + * `Scope`, which governs the lifetime of the pool. When the pool is shutdown + * because the `Scope` is closed, the individual items allocated by the pool + * will be released in some unspecified order. + * + * By setting the `concurrency` parameter, you can control the level of concurrent + * access per pool item. By default, the number of permits is set to `1`. + * + * `targetUtilization` determines when to create new pool items. It is a value + * between 0 and 1, where 1 means only create new pool items when all the existing + * items are fully utilized. + * + * A `targetUtilization` of 0.5 will create new pool items when the existing items are + * 50% utilized. + * + * @since 2.0.0 + * @category constructors + */ +export const make = (options: { + readonly acquire: Effect.Effect + readonly size: number + readonly concurrency?: number | undefined + readonly targetUtilization?: number | undefined +}): Effect.Effect, never, R | Scope.Scope> => + makeWithStrategy({ ...options, min: options.size, max: options.size, strategy: strategyNoop() }) + +/** + * Makes a new pool with the specified minimum and maximum sizes and time to + * live before a pool whose excess items are not being used will be shrunk + * down to the minimum size. The pool is returned in a `Scope`, which governs + * the lifetime of the pool. When the pool is shutdown because the `Scope` is + * used, the individual items allocated by the pool will be released in some + * unspecified order. + * + * By setting the `concurrency` parameter, you can control the level of concurrent + * access per pool item. By default, the number of permits is set to `1`. + * + * `targetUtilization` determines when to create new pool items. It is a value + * between 0 and 1, where 1 means only create new pool items when all the existing + * items are fully utilized. + * + * A `targetUtilization` of 0.5 will create new pool items when the existing items are + * 50% utilized. + * + * The `timeToLiveStrategy` determines how items are invalidated. If set to + * "creation", then items are invalidated based on their creation time. If set + * to "usage", then items are invalidated based on pool usage. + * + * By default, the `timeToLiveStrategy` is set to "usage". + * + * ```ts skip-type-checking + * import { createConnection } from "mysql2"; + * import { Duration, Effect, Pool } from "effect" + * + * const acquireDBConnection = Effect.acquireRelease( + * Effect.sync(() => createConnection('mysql://...')), + * (connection) => Effect.sync(() => connection.end(() => {})), + * ) + * + * const connectionPool = Effect.flatMap( + * Pool.makeWithTTL({ + * acquire: acquireDBConnection, + * min: 10, + * max: 20, + * timeToLive: Duration.seconds(60) + * }), + * (pool) => pool.get + * ) + * ``` + * + * @since 2.0.0 + * @category constructors + */ +export const makeWithTTL = (options: { + readonly acquire: Effect.Effect + readonly min: number + readonly max: number + readonly concurrency?: number | undefined + readonly targetUtilization?: number | undefined + readonly timeToLive: Duration.DurationInput + readonly timeToLiveStrategy?: "creation" | "usage" | undefined +}): Effect.Effect, never, R | Scope.Scope> => + Effect.flatMap( + options.timeToLiveStrategy === "creation" ? + strategyCreationTTL(options.timeToLive) : + strategyUsageTTL(options.timeToLive), + (strategy) => makeWithStrategy({ ...options, strategy }) + ) + +/** + * @since 4.0.0 + * @category constructors + */ +export const makeWithStrategy = (options: { + readonly acquire: Effect.Effect + readonly min: number + readonly max: number + readonly concurrency?: number | undefined + readonly targetUtilization?: number | undefined + readonly strategy: Strategy +}): Effect.Effect, never, Scope.Scope | R> => + Effect.uninterruptibleMask(Effect.fnUntraced(function*(restore) { + const services = yield* Effect.services() + const scope = ServiceMap.get(services, Scope.Scope) + const acquire = Effect.updateServices( + options.acquire, + (input) => ServiceMap.merge(services, input) + ) as Effect.Effect + const concurrency = options.concurrency ?? 1 + + const config: Config = { + acquire, + concurrency, + minSize: options.min, + maxSize: options.max, + strategy: options.strategy, + targetUtilization: Math.min(Math.max(options.targetUtilization ?? 1, 0.1), 1) + } + const state: State = { + scope, + isShuttingDown: false, + semaphore: Effect.unsafeMakeSemaphore(concurrency * options.max), + resizeSemaphore: Effect.unsafeMakeSemaphore(1), + items: new Set(), + available: new Set(), + availableLatch: Effect.unsafeMakeLatch(false), + invalidated: new Set(), + waiters: 0 + } + const self: Pool = { + [TypeId]: TypeId, + config, + state, + pipe() { + return pipeArguments(this, arguments) + } + } + yield* Scope.addFinalizer(scope, shutdown(self)) + yield* Effect.tap( + Effect.forkDaemon(restore(resize(self))), + (fiber) => Scope.addFinalizer(scope, Fiber.interrupt(fiber)) + ) + yield* Effect.tap( + Effect.forkDaemon(restore(options.strategy.run(self))), + (fiber) => Scope.addFinalizer(scope, Fiber.interrupt(fiber)) + ) + return self + })) + +const shutdown = Effect.fnUntraced(function*(self: Pool) { + if (self.state.isShuttingDown) return + self.state.isShuttingDown = true + const size = self.state.items.size + const semaphore = Effect.unsafeMakeSemaphore(size) + for (const item of self.state.items) { + if (item.refCount > 0) { + item.finalizer = Effect.tap(item.finalizer, semaphore.release(1)) + self.state.invalidated.add(item) + yield* semaphore.take(1) + } else { + self.state.items.delete(item) + self.state.available.delete(item) + self.state.invalidated.delete(item) + yield* item.finalizer + } + } + yield* semaphore.releaseAll + self.state.availableLatch.unsafeOpen() + yield* semaphore.take(size) +}) + +/** + * Retrieves an item from the pool in a scoped effect. Note that if + * acquisition fails, then the returned effect will fail for that same reason. + * Retrying a failed acquisition attempt will repeat the acquisition attempt. + * + * @since 2.0.0 + * @category getters + */ +export const get = (self: Pool): Effect.Effect => + Effect.suspend(() => { + if (self.state.isShuttingDown) { + return Effect.interrupt + } + return Effect.flatMap(getPoolItem(self), (item) => item.exit) + }) + +const getPoolItem = (self: Pool): Effect.Effect, never, Scope.Scope> => + Effect.uninterruptibleMask((restore) => + restore(self.state.semaphore.take(1)).pipe( + Effect.flatMap(() => Effect.scope), + Effect.flatMap((scope) => + getPoolItemInner(self).pipe( + Effect.ensuring(Effect.sync(() => self.state.waiters--)), + Effect.tap((item) => { + if (item.exit._tag === "Failure") { + self.state.items.delete(item) + self.state.invalidated.delete(item) + self.state.available.delete(item) + return self.state.semaphore.release(1) + } + item.refCount++ + self.state.available.delete(item) + if (item.refCount < self.config.concurrency) { + self.state.available.add(item) + } + return Scope.addFinalizerExit(scope, () => + Effect.flatMap( + Effect.suspend(() => { + item.refCount-- + if (self.state.invalidated.has(item)) { + return invalidatePoolItem(self, item) + } + self.state.available.add(item) + return Effect.void + }), + () => self.state.semaphore.release(1) + )) + }), + Effect.onInterrupt(() => self.state.semaphore.release(1)) + ) + ) + ) + ) + +const getPoolItemInner = Effect.fnUntraced(function*( + self: Pool +) { + self.state.waiters++ + if (self.state.isShuttingDown) { + return yield* Effect.interrupt + } else if (targetSize(self) > activeSize(self)) { + while (true) { + yield* self.state.resizeSemaphore.withPermitsIfAvailable(1)( + Effect.forkIn(Effect.interruptible(resize(self)), self.state.scope) + ) + if (self.state.isShuttingDown) { + return yield* Effect.interrupt + } else if (self.state.available.size > 0) { + return Iterable.unsafeHead(self.state.available) + } + self.state.availableLatch.unsafeClose() + yield* self.state.availableLatch.await + } + } + return Iterable.unsafeHead(self.state.available) +}) + +/** + * Invalidates the specified item. This will cause the pool to eventually + * reallocate the item, although this reallocation may occur lazily rather + * than eagerly. + * + * @since 2.0.0 + * @category combinators + */ +export const invalidate: { + (item: A): (self: Pool) => Effect.Effect + (self: Pool, item: A): Effect.Effect +} = dual(2, (self: Pool, item: A): Effect.Effect => + Effect.suspend(() => { + if (self.state.isShuttingDown) return Effect.void + for (const poolItem of self.state.items) { + if (poolItem.exit._tag === "Success" && poolItem.exit.value === item) { + poolItem.disableReclaim = true + return Effect.uninterruptible(invalidatePoolItem(self, poolItem)) + } + } + return Effect.void + })) + +const invalidatePoolItem = (self: Pool, poolItem: PoolItem): Effect.Effect => + Effect.suspend(() => { + if (!self.state.items.has(poolItem)) { + return Effect.void + } else if (poolItem.refCount === 0) { + self.state.items.delete(poolItem) + self.state.available.delete(poolItem) + self.state.invalidated.delete(poolItem) + return Effect.asVoid(Effect.flatMap( + poolItem.finalizer, + () => Effect.forkIn(Effect.interruptible(resize(self)), self.state.scope) + )) + } + self.state.invalidated.add(poolItem) + self.state.available.delete(poolItem) + return Effect.void + }) + +const resize = (self: Pool): Effect.Effect => + self.state.resizeSemaphore.withPermits(1)(resizeLoop(self)) + +const resizeLoop = (self: Pool): Effect.Effect => + Effect.suspend(() => { + const active = activeSize(self) + const target = targetSize(self) + if (active >= target) { + return Effect.void + } + const toAcquire = target - active + return self.config.strategy.reclaim(self).pipe( + Effect.flatMap((item) => item ? Effect.succeed(item) : allocate(self)), + Effect.replicateEffect(toAcquire, { concurrency: toAcquire }), + Effect.tap(self.state.availableLatch.open), + Effect.flatMap((items) => items.some((_) => _.exit._tag === "Failure") ? Effect.void : resizeLoop(self)) + ) + }) + +const allocate = (self: Pool): Effect.Effect> => + Effect.acquireUseRelease( + Scope.make(), + (scope) => + self.config.acquire.pipe( + Scope.provide(scope), + Effect.exit, + Effect.flatMap((exit) => { + const item: PoolItem = { + exit, + finalizer: Effect.catchCause(scope.close(exit), reportUnhandledError), + refCount: 0, + disableReclaim: false + } + self.state.items.add(item) + self.state.available.add(item) + return Effect.as( + exit._tag === "Success" + ? self.config.strategy.onAcquire(item) + : Effect.flatMap(item.finalizer, () => self.config.strategy.onAcquire(item)), + item + ) + }) + ), + (scope, exit) => exit._tag === "Failure" ? scope.close(exit) : Effect.void + ) + +const currentUsage = (self: Pool) => { + let count = self.state.waiters + for (const item of self.state.items) { + count += item.refCount + } + return count +} + +const targetSize = (self: Pool) => { + if (self.state.isShuttingDown) return 0 + const utilization = currentUsage(self) / self.config.targetUtilization + const target = Math.ceil(utilization / self.config.concurrency) + return Math.min(Math.max(self.config.minSize, target), self.config.maxSize) +} + +const activeSize = (self: Pool) => { + return self.state.items.size - self.state.invalidated.size +} + +// ----------------------------------------------------------------------------- +// Strategy +// ----------------------------------------------------------------------------- + +const strategyNoop = (): Strategy => ({ + run: (_) => Effect.void, + onAcquire: (_) => Effect.void, + reclaim: (_) => Effect.succeed(undefined) +}) + +const strategyCreationTTL = Effect.fnUntraced(function*(ttl: Duration.DurationInput) { + const clock = yield* Clock + const queue = yield* Queue.unbounded>() + const ttlMillis = Duration.toMillis(ttl) + const creationTimes = new WeakMap, number>() + return identity>({ + run: (pool) => { + const process = (item: PoolItem): Effect.Effect => + Effect.suspend(() => { + if (!pool.state.items.has(item) || pool.state.invalidated.has(item)) { + return Effect.void + } + const now = clock.unsafeCurrentTimeMillis() + const created = creationTimes.get(item)! + const remaining = ttlMillis - (now - created) + return remaining > 0 + ? Effect.delay(process(item), remaining) + : invalidatePoolItem(pool, item) + }) + return Queue.take(queue).pipe( + Effect.tap(process), + Effect.forever({ autoYield: false }) + ) + }, + onAcquire: (item) => + Effect.suspend(() => { + creationTimes.set(item, clock.unsafeCurrentTimeMillis()) + return Queue.offer(queue, item) + }), + reclaim: (_) => Effect.succeed(undefined) + }) +}) + +const strategyUsageTTL = Effect.fnUntraced(function*(ttl: Duration.DurationInput) { + const queue = yield* Queue.unbounded>() + return identity>({ + run: (pool) => { + const process: Effect.Effect = Effect.suspend(() => { + const excess = activeSize(pool) - targetSize(pool) + if (excess <= 0) return Effect.void + return Queue.take(queue).pipe( + Effect.tap((item) => invalidatePoolItem(pool, item)), + Effect.flatMap(() => process) + ) + }) + return process.pipe( + Effect.delay(ttl), + Effect.forever({ autoYield: false }) + ) + }, + onAcquire: (item) => Queue.offer(queue, item), + reclaim(pool) { + return Effect.suspend((): Effect.Effect | undefined> => { + if (pool.state.invalidated.size === 0) { + return Effect.succeed(undefined) + } + const item = Iterable.head( + Iterable.filter(pool.state.invalidated, (item) => !item.disableReclaim) + ) + if (item._tag === "None") { + return Effect.succeed(undefined) + } + pool.state.invalidated.delete(item.value) + if (item.value.refCount < pool.config.concurrency) { + pool.state.available.add(item.value) + } + return Effect.as(Queue.offer(queue, item.value), item.value) + }) + } + }) +}) + +const reportUnhandledError = (cause: Cause.Cause) => + Effect.withFiber((fiber) => { + const unhandledLogLevel = fiber.getRef(UnhandledLogLevel) + if (unhandledLogLevel._tag === "Some") { + return Effect.logWithLevel(unhandledLogLevel.value)( + "Unhandled error in pool finalizer", + cause + ) + } + return Effect.void + }) diff --git a/packages/effect/src/Queue.ts b/packages/effect/src/Queue.ts index 269093ff92..4019828f2d 100644 --- a/packages/effect/src/Queue.ts +++ b/packages/effect/src/Queue.ts @@ -1335,6 +1335,12 @@ import * as Option from "effect/data/Option" */ export const size = (self: Dequeue): Effect => internalEffect.sync(() => unsafeSize(self)) +/** + * @category size + * @since 4.0.0 + */ +export const isFull = (self: Dequeue): Effect => internalEffect.sync(() => unsafeIsFull(self)) + /** * Check the size of the queue synchronously. * @@ -1378,6 +1384,12 @@ import * as Option from "effect/data/Option" */ export const unsafeSize = (self: Dequeue): number => self.state._tag === "Done" ? 0 : self.messages.length +/** + * @category size + * @since 4.0.0 + */ +export const unsafeIsFull = (self: Dequeue): boolean => unsafeSize(self) === self.capacity + /** * Convert a Queue to a Dequeue, allowing only read operations. * diff --git a/packages/effect/src/RcMap.ts b/packages/effect/src/RcMap.ts index a4a22ba09a..cc565a484c 100644 --- a/packages/effect/src/RcMap.ts +++ b/packages/effect/src/RcMap.ts @@ -543,6 +543,22 @@ export const invalidate: { }, Effect.uninterruptible) ) +/** + * @since 3.17.7 + * @category combinators + */ +export const has: { + (key: K): (self: RcMap) => Effect.Effect + (self: RcMap, key: K): Effect.Effect +} = dual( + 2, + (self: RcMap, key: K) => + Effect.sync(() => { + if (self.state._tag === "Closed") return false + return MutableHashMap.has(self.state.map, key) + }) +) + /** * Extends the idle time for a resource in the RcMap. If the RcMap has an * `idleTimeToLive` configured, calling `touch` will reset the expiration diff --git a/packages/effect/src/Ref.ts b/packages/effect/src/Ref.ts index 866d4a438a..2c61b77b22 100644 --- a/packages/effect/src/Ref.ts +++ b/packages/effect/src/Ref.ts @@ -35,20 +35,10 @@ import { dual, identity } from "./Function.ts" import { PipeInspectableProto } from "./internal/core.ts" import * as MutableRef from "./MutableRef.ts" import type { Invariant } from "./types/Types.ts" -import type * as Unify from "./types/Unify.ts" /** * The type identifier for Ref values. * - * @example - * ```ts - * import { Ref } from "effect" - * - * // Check if a value is a Ref by using the TypeId - * const myRef = Ref.unsafeMake(42) - * console.log(myRef[Ref.TypeId]) // { _A: [Function: identity] } - * ``` - * * @since 2.0.0 * @category symbols */ @@ -57,16 +47,6 @@ export const TypeId: TypeId = "~effect/Ref" /** * The type-level identifier for Ref values. * - * @example - * ```ts - * import { Ref } from "effect" - * - * // The TypeId is used internally for type checking - * const checkTypeId = (id: Ref.TypeId) => { - * console.log(id) // "~effect/Ref" - * } - * ``` - * * @since 2.0.0 * @category symbols */ @@ -106,61 +86,6 @@ export type TypeId = "~effect/Ref" */ export interface Ref extends Ref.Variance { readonly ref: MutableRef.MutableRef - readonly [Unify.typeSymbol]?: unknown - readonly [Unify.unifySymbol]?: RefUnify - readonly [Unify.ignoreSymbol]?: RefUnifyIgnore -} - -/** - * Unification interface for Ref types, used internally by the type system. - * - * @example - * ```ts - * import { Effect } from "effect" - * import { Ref } from "effect" - * - * // This interface is used internally for type unification - * // Users typically don't need to interact with it directly - * const program = Effect.gen(function*() { - * const ref = yield* Ref.make(42) - * - * // The unification system automatically handles type inference - * const value = yield* Ref.get(ref) // TypeScript infers number - * console.log(value) - * }) - * ``` - * - * @category models - * @since 3.8.0 - */ -export interface RefUnify extends Effect.EffectUnify { - Ref?: () => Extract> -} - -/** - * Unification ignore interface for Ref types, used internally by the type system. - * - * @example - * ```ts - * import { Effect } from "effect" - * import { Ref } from "effect" - * - * // This interface is used internally to control type unification - * // Users typically don't need to interact with it directly - * const program = Effect.gen(function*() { - * const ref = yield* Ref.make("hello") - * - * // Type system ignores certain unification patterns automatically - * const result = yield* Ref.get(ref) - * console.log(result) // "hello" - * }) - * ``` - * - * @category models - * @since 3.8.0 - */ -export interface RefUnifyIgnore extends Effect.EffectUnifyIgnore { - Effect?: true } /** @@ -562,10 +487,9 @@ import * as Option from "effect/data/Option" * // Only modify if value is greater than 3 * const result1 = yield* Ref.modifySome( * counter, - * "no change", // fallback value * n => n > 3 - * ? Option.some([`incremented ${n}`, n + 10]) - * : Option.none() + * ? [`incremented ${n}`, Option.some(n + 10)] + * : ["no change", Option.none()] * ) * * console.log(result1) // "incremented 5" @@ -576,10 +500,9 @@ import * as Option from "effect/data/Option" * // Try to modify with a condition that fails * const result2 = yield* Ref.modifySome( * counter, - * "no change", * n => n < 10 - * ? Option.some([`decremented ${n}`, n - 5]) - * : Option.none() + * ? [`decremented ${n}`, Option.some(n - 5)] + * : ["no change", Option.none()] * ) * * console.log(result2) // "no change" @@ -592,20 +515,21 @@ import * as Option from "effect/data/Option" * @since 2.0.0 * @category setters */ -export const modifySome = dual< +export const modifySome: { + (pf: (a: A) => readonly [B, Option.Option]): (self: Ref) => Effect.Effect + (self: Ref, pf: (a: A) => readonly [B, Option.Option]): Effect.Effect +} = dual< ( - fallback: B, - pf: (a: A) => Option.Option + pf: (a: A) => readonly [B, Option.Option] ) => (self: Ref) => Effect.Effect, ( self: Ref, - fallback: B, - pf: (a: A) => Option.Option + pf: (a: A) => readonly [B, Option.Option] ) => Effect.Effect ->(3, (self, fallback, pf) => +>(2, (self, pf) => modify(self, (value) => { - const option = pf(value) - return option._tag === "None" ? [fallback, value] : option.value + const [b, option] = pf(value) + return [b, option._tag === "None" ? value : option.value] })) /** diff --git a/packages/effect/src/ScopedRef.ts b/packages/effect/src/ScopedRef.ts new file mode 100644 index 0000000000..9023a0ff8d --- /dev/null +++ b/packages/effect/src/ScopedRef.ts @@ -0,0 +1,144 @@ +/** + * @since 2.0.0 + */ +import * as Effect from "./Effect.ts" +import * as Exit from "./Exit.ts" +import { dual, type LazyArg } from "./Function.ts" +import type { Pipeable } from "./interfaces/Pipeable.ts" +import { PipeInspectableProto } from "./internal/core.ts" +import * as Scope from "./Scope.ts" +import * as Synchronized from "./SynchronizedRef.ts" + +/** + * @since 2.0.0 + * @category symbols + */ +export const TypeId: TypeId = "~effect/ScopedRef" + +/** + * @since 2.0.0 + * @category symbols + */ +export type TypeId = "~effect/ScopedRef" + +/** + * A `ScopedRef` is a reference whose value is associated with resources, + * which must be released properly. You can both get the current value of any + * `ScopedRef`, as well as set it to a new value (which may require new + * resources). The reference itself takes care of properly releasing resources + * for the old value whenever a new value is obtained. + * + * @since 2.0.0 + * @category models + */ +export interface ScopedRef extends Pipeable { + readonly [TypeId]: TypeId + readonly backing: Synchronized.SynchronizedRef +} + +const Proto = { + ...PipeInspectableProto, + [TypeId]: TypeId, + toJSON(this: ScopedRef) { + return { + _id: "ScopedRef", + value: this.backing.backing.ref.current[1] + } + } +} + +const unsafeMake = ( + scope: Scope.Scope.Closeable, + value: A +): ScopedRef => { + const self = Object.create(Proto) + self.backing = Synchronized.unsafeMake([scope, value] as const) + return self +} + +/** + * Creates a new `ScopedRef` from an effect that resourcefully produces a + * value. + * + * @since 2.0.0 + * @category constructors + */ +export const fromAcquire: ( + acquire: Effect.Effect +) => Effect.Effect, E, Scope.Scope | R> = Effect.fnUntraced(function*( + acquire: Effect.Effect +) { + const scope = Scope.unsafeMake() + const value = yield* acquire.pipe( + Scope.provide(scope), + Effect.tapCause((cause) => scope.close(Exit.failCause(cause))) + ) + const self = unsafeMake(scope, value) + yield* Effect.addFinalizer((exit) => self.backing.backing.ref.current[0].close(exit)) + return self +}, Effect.uninterruptible) + +/** + * Retrieves the current value of the scoped reference. + * + * @since 4.0.0 + * @category getters + */ +export const unsafeGet = (self: ScopedRef): A => self.backing.backing.ref.current[1] + +/** + * Retrieves the current value of the scoped reference. + * + * @since 2.0.0 + * @category getters + */ +export const get = (self: ScopedRef): Effect.Effect => Effect.sync(() => unsafeGet(self)) + +/** + * Creates a new `ScopedRef` from the specified value. This method should + * not be used for values whose creation require the acquisition of resources. + * + * @since 2.0.0 + * @category constructors + */ +export const make = (evaluate: LazyArg): Effect.Effect, never, Scope.Scope> => + Effect.suspend(() => { + const scope = Scope.unsafeMake() + const value = evaluate() + const self = unsafeMake(scope, value) + return Effect.as(Effect.addFinalizer((exit) => self.backing.backing.ref.current[0].close(exit)), self) + }) + +/** + * Sets the value of this reference to the specified resourcefully-created + * value. Any resources associated with the old value will be released. + * + * This method will not return until either the reference is successfully + * changed to the new value, with old resources released, or until the attempt + * to acquire a new value fails. + * + * @since 2.0.0 + * @category getters + */ +export const set: { + (acquire: Effect.Effect): (self: ScopedRef) => Effect.Effect> + (self: ScopedRef, acquire: Effect.Effect): Effect.Effect> +} = dual( + 2, + Effect.fnUntraced( + function*( + self: ScopedRef, + acquire: Effect.Effect + ) { + yield* self.backing.backing.ref.current[0].close(Exit.void) + const scope = Scope.unsafeMake() + const value = yield* acquire.pipe( + Scope.provide(scope), + Effect.tapCause((cause) => scope.close(Exit.failCause(cause))) + ) + self.backing.backing.ref.current = [scope, value] + }, + Effect.uninterruptible, + (effect, self) => self.backing.semaphore.withPermit(effect) + ) +) diff --git a/packages/effect/src/SynchronizedRef.ts b/packages/effect/src/SynchronizedRef.ts new file mode 100644 index 0000000000..6ae13a5deb --- /dev/null +++ b/packages/effect/src/SynchronizedRef.ts @@ -0,0 +1,393 @@ +/** + * @since 2.0.0 + */ +import * as Option from "./data/Option.ts" +import * as Effect from "./Effect.ts" +import { dual } from "./Function.ts" +import { PipeInspectableProto } from "./internal/core.ts" +import * as Ref from "./Ref.ts" + +/** + * @since 2.0.0 + * @category symbols + */ +export const TypeId: TypeId = "~effect/SynchronizedRef" + +/** + * @since 2.0.0 + * @category symbols + */ +export type TypeId = "~effect/SynchronizedRef" + +/** + * @since 2.0.0 + * @category models + */ +export interface SynchronizedRef extends Ref.Ref { + readonly [TypeId]: TypeId + readonly backing: Ref.Ref + readonly semaphore: Effect.Semaphore +} + +const Proto = { + ...PipeInspectableProto, + [TypeId]: TypeId, + toJSON(this: SynchronizedRef) { + return { + _id: "SynchronizedRef", + value: this.backing.ref.current + } + } +} + +/** + * @since 4.0.0 + * @category constructors + */ +export const unsafeMake = (value: A): SynchronizedRef => { + const self = Object.create(Proto) + self.semaphore = Effect.unsafeMakeSemaphore(1) + self.backing = Ref.unsafeMake(value) + return self +} + +/** + * @since 2.0.0 + * @category constructors + */ +export const make = (value: A): Effect.Effect> => Effect.sync(() => unsafeMake(value)) + +/** + * @since 2.0.0 + * @category getters + */ +export const unsafeGet = (self: SynchronizedRef): A => self.backing.ref.current + +/** + * @since 2.0.0 + * @category getters + */ +export const get = (self: SynchronizedRef): Effect.Effect => Effect.sync(() => unsafeGet(self)) + +/** + * @since 2.0.0 + * @category utils + */ +export const getAndSet: { + (value: A): (self: SynchronizedRef) => Effect.Effect + (self: SynchronizedRef, value: A): Effect.Effect +} = dual( + 2, + (self: SynchronizedRef, value: A): Effect.Effect => + self.semaphore.withPermit(Ref.getAndSet(self.backing, value)) +) + +/** + * @since 2.0.0 + * @category utils + */ +export const getAndUpdate: { + (f: (a: A) => A): (self: SynchronizedRef) => Effect.Effect + (self: SynchronizedRef, f: (a: A) => A): Effect.Effect +} = dual( + 2, + (self: SynchronizedRef, f: (a: A) => A): Effect.Effect => + self.semaphore.withPermit(Ref.getAndUpdate(self.backing, f)) +) + +/** + * @since 2.0.0 + * @category utils + */ +export const getAndUpdateEffect: { + (f: (a: A) => Effect.Effect): (self: SynchronizedRef) => Effect.Effect + (self: SynchronizedRef, f: (a: A) => Effect.Effect): Effect.Effect +} = dual( + 2, + (self: SynchronizedRef, f: (a: A) => Effect.Effect): Effect.Effect => + self.semaphore.withPermit(Effect.suspend(() => { + const value = unsafeGet(self) + return Effect.map(f(value), (newValue) => { + self.backing.ref.current = newValue + return value + }) + })) +) + +/** + * @since 2.0.0 + * @category utils + */ +export const getAndUpdateSome: { + (pf: (a: A) => Option.Option): (self: SynchronizedRef) => Effect.Effect + (self: SynchronizedRef, pf: (a: A) => Option.Option): Effect.Effect +} = dual( + 2, + (self: SynchronizedRef, pf: (a: A) => Option.Option): Effect.Effect => + self.semaphore.withPermit(Ref.getAndUpdateSome(self, pf)) +) + +/** + * @since 2.0.0 + * @category utils + */ +export const getAndUpdateSomeEffect: { + (pf: (a: A) => Effect.Effect, E, R>): (self: SynchronizedRef) => Effect.Effect + (self: SynchronizedRef, pf: (a: A) => Effect.Effect, E, R>): Effect.Effect +} = dual( + 2, + (self: SynchronizedRef, pf: (a: A) => Effect.Effect, E, R>): Effect.Effect => + self.semaphore.withPermit(Effect.suspend(() => { + const value = unsafeGet(self) + return Effect.flatMap(pf(value), (option) => { + if (Option.isNone(option)) { + return Effect.succeed(value) + } + self.backing.ref.current = option.value + return Effect.succeed(value) + }) + })) +) + +/** + * @since 2.0.0 + * @category utils + */ +export const modify: { + (f: (a: A) => readonly [B, A]): (self: SynchronizedRef) => Effect.Effect + (self: SynchronizedRef, f: (a: A) => readonly [B, A]): Effect.Effect +} = dual( + 2, + (self: SynchronizedRef, f: (a: A) => readonly [B, A]): Effect.Effect => + self.semaphore.withPermit(Ref.modify(self.backing, f)) +) + +/** + * @since 2.0.0 + * @category utils + */ +export const modifyEffect: { + (f: (a: A) => Effect.Effect): (self: SynchronizedRef) => Effect.Effect + (self: SynchronizedRef, f: (a: A) => Effect.Effect): Effect.Effect +} = dual( + 2, + (self: SynchronizedRef, f: (a: A) => Effect.Effect): Effect.Effect => + self.semaphore.withPermit(Effect.suspend(() => { + const value = unsafeGet(self) + return Effect.map(f(value), ([b, a]) => { + self.backing.ref.current = a + return b + }) + })) +) + +/** + * @since 2.0.0 + * @category utils + */ +export const modifySome: { + ( + pf: (a: A) => readonly [B, Option.Option] + ): (self: SynchronizedRef) => Effect.Effect + ( + self: SynchronizedRef, + pf: (a: A) => readonly [B, Option.Option] + ): Effect.Effect +} = dual( + 2, + ( + self: SynchronizedRef, + pf: (a: A) => readonly [B, Option.Option] + ): Effect.Effect => self.semaphore.withPermit(Ref.modifySome(self.backing, pf)) +) + +/** + * @since 2.0.0 + * @category utils + */ +export const modifySomeEffect: { + ( + fallback: B, + pf: (a: A) => Effect.Effect], E, R> + ): (self: SynchronizedRef) => Effect.Effect + ( + self: SynchronizedRef, + pf: (a: A) => Effect.Effect], E, R> + ): Effect.Effect +} = dual( + 2, + ( + self: SynchronizedRef, + pf: (a: A) => Effect.Effect], E, R> + ): Effect.Effect => + self.semaphore.withPermit(Effect.suspend(() => { + const value = unsafeGet(self) + return Effect.flatMap(pf(value), ([b, maybeA]) => { + if (Option.isNone(maybeA)) { + return Effect.succeed(b) + } + self.backing.ref.current = maybeA.value + return Effect.succeed(b) + }) + })) +) + +/** + * @since 2.0.0 + * @category utils + */ +export const set: { + (value: A): (self: SynchronizedRef) => Effect.Effect + (self: SynchronizedRef, value: A): Effect.Effect +} = dual( + 2, + (self: SynchronizedRef, value: A): Effect.Effect => + self.semaphore.withPermit(Ref.set(self.backing, value)) +) + +/** + * @since 2.0.0 + * @category utils + */ +export const setAndGet: { + (value: A): (self: SynchronizedRef) => Effect.Effect + (self: SynchronizedRef, value: A): Effect.Effect +} = dual( + 2, + (self: SynchronizedRef, value: A): Effect.Effect => + self.semaphore.withPermit(Ref.setAndGet(self.backing, value)) +) + +/** + * @since 2.0.0 + * @category utils + */ +export const update: { + (f: (a: A) => A): (self: SynchronizedRef) => Effect.Effect + (self: SynchronizedRef, f: (a: A) => A): Effect.Effect +} = dual( + 2, + (self: SynchronizedRef, f: (a: A) => A): Effect.Effect => + self.semaphore.withPermit(Ref.update(self.backing, f)) +) + +/** + * @since 2.0.0 + * @category utils + */ +export const updateEffect: { + (f: (a: A) => Effect.Effect): (self: SynchronizedRef) => Effect.Effect + (self: SynchronizedRef, f: (a: A) => Effect.Effect): Effect.Effect +} = dual( + 2, + (self: SynchronizedRef, f: (a: A) => Effect.Effect): Effect.Effect => + self.semaphore.withPermit(Effect.suspend(() => { + const value = unsafeGet(self) + return Effect.map(f(value), (newValue) => { + self.backing.ref.current = newValue + }) + })) +) + +/** + * @since 2.0.0 + * @category utils + */ +export const updateAndGet: { + (f: (a: A) => A): (self: SynchronizedRef) => Effect.Effect + (self: SynchronizedRef, f: (a: A) => A): Effect.Effect +} = dual( + 2, + (self: SynchronizedRef, f: (a: A) => A): Effect.Effect => + self.semaphore.withPermit(Ref.updateAndGet(self.backing, f)) +) + +/** + * @since 2.0.0 + * @category utils + */ +export const updateAndGetEffect: { + (f: (a: A) => Effect.Effect): (self: SynchronizedRef) => Effect.Effect + (self: SynchronizedRef, f: (a: A) => Effect.Effect): Effect.Effect +} = dual( + 2, + (self: SynchronizedRef, f: (a: A) => Effect.Effect): Effect.Effect => + self.semaphore.withPermit(Effect.suspend(() => { + const value = unsafeGet(self) + return Effect.map(f(value), (newValue) => { + self.backing.ref.current = newValue + return newValue + }) + })) +) + +/** + * @since 2.0.0 + * @category utils + */ +export const updateSome: { + (f: (a: A) => Option.Option): (self: SynchronizedRef) => Effect.Effect + (self: SynchronizedRef, f: (a: A) => Option.Option): Effect.Effect +} = dual( + 2, + (self: SynchronizedRef, f: (a: A) => Option.Option): Effect.Effect => + self.semaphore.withPermit(Ref.updateSome(self.backing, f)) +) + +/** + * @since 2.0.0 + * @category utils + */ +export const updateSomeEffect: { + ( + pf: (a: A) => Effect.Effect, E, R> + ): (self: SynchronizedRef) => Effect.Effect + (self: SynchronizedRef, pf: (a: A) => Effect.Effect, E, R>): Effect.Effect +} = dual( + 2, + (self: SynchronizedRef, pf: (a: A) => Effect.Effect, E, R>): Effect.Effect => + self.semaphore.withPermit(Effect.suspend(() => { + const value = unsafeGet(self) + return Effect.map(pf(value), (option) => { + if (Option.isNone(option)) { + return + } + self.backing.ref.current = option.value + }) + })) +) + +/** + * @since 2.0.0 + * @category utils + */ +export const updateSomeAndGet: { + (pf: (a: A) => Option.Option): (self: SynchronizedRef) => Effect.Effect + (self: SynchronizedRef, pf: (a: A) => Option.Option): Effect.Effect +} = dual( + 2, + (self: SynchronizedRef, pf: (a: A) => Option.Option): Effect.Effect => + self.semaphore.withPermit(Ref.updateSomeAndGet(self.backing, pf)) +) + +/** + * @since 2.0.0 + * @category utils + */ +export const updateSomeAndGetEffect: { + (pf: (a: A) => Effect.Effect, E, R>): (self: SynchronizedRef) => Effect.Effect + (self: SynchronizedRef, pf: (a: A) => Effect.Effect, E, R>): Effect.Effect +} = dual( + 2, + (self: SynchronizedRef, pf: (a: A) => Effect.Effect, E, R>): Effect.Effect => + self.semaphore.withPermit(Effect.suspend(() => { + const value = unsafeGet(self) + return Effect.flatMap(pf(value), (option) => { + if (Option.isNone(option)) { + return Effect.succeed(value) + } + self.backing.ref.current = option.value + return Effect.succeed(option.value) + }) + })) +) diff --git a/packages/effect/src/collections/MutableHashMap.ts b/packages/effect/src/collections/MutableHashMap.ts index b679b0bc34..c4e0bce127 100644 --- a/packages/effect/src/collections/MutableHashMap.ts +++ b/packages/effect/src/collections/MutableHashMap.ts @@ -679,3 +679,18 @@ export const clear = (self: MutableHashMap) => { * @category elements */ export const size = (self: MutableHashMap): number => self.backing.size + +/** + * @since 2.0.0 + */ +export const isEmpty = (self: MutableHashMap): boolean => self.backing.size === 0 + +/** + * @since 2.0.0 + */ +export const forEach: { + (f: (value: V, key: K) => void): (self: MutableHashMap) => void + (self: MutableHashMap, f: (value: V, key: K) => void): void +} = dual(2, (self: MutableHashMap, f: (value: V, key: K) => void) => { + self.backing.forEach(f) +}) diff --git a/packages/effect/src/index.ts b/packages/effect/src/index.ts index 3fe5dcf91d..3527e646e1 100644 --- a/packages/effect/src/index.ts +++ b/packages/effect/src/index.ts @@ -391,6 +391,11 @@ export * as ManagedRuntime from "./ManagedRuntime.ts" */ export * as MutableRef from "./MutableRef.ts" +/** + * @since 2.0.0 + */ +export * as Pool from "./Pool.ts" + /** * This module provides utilities for working with publish-subscribe (PubSub) systems. * @@ -608,6 +613,11 @@ export * as Scheduler from "./Scheduler.ts" */ export * as Scope from "./Scope.ts" +/** + * @since 2.0.0 + */ +export * as ScopedRef from "./ScopedRef.ts" + /** * This module provides a data structure called `ServiceMap` that can be used for dependency injection in effectful * programs. It is essentially a table mapping `Keys`s to their implementations (called `Service`s), and can be used to @@ -619,6 +629,11 @@ export * as Scope from "./Scope.ts" */ export * as ServiceMap from "./ServiceMap.ts" +/** + * @since 2.0.0 + */ +export * as SynchronizedRef from "./SynchronizedRef.ts" + /** * @since 2.0.0 */ diff --git a/packages/effect/src/interfaces/PrimaryKey.ts b/packages/effect/src/interfaces/PrimaryKey.ts index 1b6d4c78ff..ea6fc2a13e 100644 --- a/packages/effect/src/interfaces/PrimaryKey.ts +++ b/packages/effect/src/interfaces/PrimaryKey.ts @@ -10,6 +10,8 @@ * @since 2.0.0 */ +import { hasProperty } from "../data/Predicate.ts" + /** * The unique symbol used to identify objects that implement the `PrimaryKey` interface. * @@ -63,6 +65,12 @@ export interface PrimaryKey { [symbol](): string } +/** + * @category models + * @since 2.0.0 + */ +export const isPrimaryKey = (u: unknown): u is PrimaryKey => hasProperty(u, symbol) + /** * Extracts the string value from a `PrimaryKey`. * diff --git a/packages/effect/src/internal/effect.ts b/packages/effect/src/internal/effect.ts index 5d6c8f9c44..b286199a84 100644 --- a/packages/effect/src/internal/effect.ts +++ b/packages/effect/src/internal/effect.ts @@ -1137,10 +1137,19 @@ const unsafeFromIterator: ( op: "Iterator", single: false, [contA](value, fiber) { - const state = this[args][0].next(value) - if (state.done) return succeed(state.value) - fiber._stack.push(this) - return state.value.asEffect() + const iter = this[args][0] + while (true) { + const state = iter.next(value) + if (state.done) return succeed(state.value) + const eff = state.value.asEffect() + if (!effectIsExit(eff)) { + fiber._stack.push(this) + return eff + } else if (eff._tag === "Failure") { + return eff + } + value = eff.value + } }, [evaluate](this: any, fiber: FiberImpl) { return this[contA](this[args][1], fiber) @@ -1920,7 +1929,10 @@ export const provideServices: { ( self: Effect.Effect, services: ServiceMap.ServiceMap - ): Effect.Effect> => updateServices(self, ServiceMap.merge(services)) as any + ): Effect.Effect> => { + if (effectIsExit(self)) return self as any + return updateServices(self, ServiceMap.merge(services)) as any + } ) /** @internal */ @@ -2824,6 +2836,24 @@ export const matchCauseEager: { } ) +// ---------------------------------------------------------------------------- +// Condition checking +// ---------------------------------------------------------------------------- + +/** @internal */ +export const isFailure = (self: Effect.Effect): Effect.Effect => + matchEager(self, { + onFailure: () => true, + onSuccess: () => false + }) + +/** @internal */ +export const isSuccess = (self: Effect.Effect): Effect.Effect => + matchEager(self, { + onFailure: () => false, + onSuccess: () => true + }) + // ---------------------------------------------------------------------------- // delays & timeouts // ---------------------------------------------------------------------------- @@ -2871,13 +2901,7 @@ export const timeoutOrElse: { ): Effect.Effect => raceFirst( self, - flatMap(interruptible(sleep(options.duration)), options.onTimeout), - { - onWinner: ({ fiber, index, parentFiber }) => { - if (index !== 0) return - ;(parentFiber as FiberImpl).setServices(fiber.services) - } - } + flatMap(interruptible(sleep(options.duration)), options.onTimeout) ) ) @@ -2923,6 +2947,15 @@ export const timeoutOption: { ): Effect.Effect, E, R> => raceFirst(asSome(self), as(interruptible(sleep(duration)), Option.none())) ) +/** @internal */ +export const timed = ( + self: Effect.Effect +): Effect.Effect<[duration: Duration.Duration, result: A], E, R> => + clockWith((clock) => { + const start = clock.unsafeCurrentTimeNanos() + return map(self, (a) => [Duration.nanos(clock.unsafeCurrentTimeNanos() - start), a]) + }) + // ---------------------------------------------------------------------------- // resources & finalization // ---------------------------------------------------------------------------- @@ -2953,7 +2986,9 @@ const ScopeProto = { } let exits: Array> = [] const fibers: Array> = [] - for (const finalizer of Array.from(finalizers.values()).reverse()) { + const arr = Array.from(finalizers.values()) + for (let i = arr.length - 1; i >= 0; i--) { + const finalizer = arr[i] if (this.strategy === "sequential") { exits.push(yield* exit(finalizer(exit_))) } else { @@ -4057,6 +4092,8 @@ class Semaphore { flatMap(restore(this.take(n)), (permits) => ensuring(restore(self), this.release(permits))) ) + readonly withPermit = this.withPermits(1) + readonly withPermitsIfAvailable = (n: number) => (self: Effect.Effect) => uninterruptibleMask((restore) => suspend(() => { diff --git a/packages/effect/src/logging/Logger.ts b/packages/effect/src/logging/Logger.ts index 0509449fb3..609f3438bc 100644 --- a/packages/effect/src/logging/Logger.ts +++ b/packages/effect/src/logging/Logger.ts @@ -1193,9 +1193,9 @@ export const layer = < options?: { mergeWithExisting: boolean } ): Layer.Layer< never, - Loggers[number] extends Effect.Effect ? _E : never, + Loggers extends readonly [] ? never : Effect.Error, Exclude< - Loggers[number] extends Effect.Effect ? _R : never, + Loggers extends readonly [] ? never : Effect.Services, Scope.Scope > > => diff --git a/packages/effect/src/observability/Metric.ts b/packages/effect/src/observability/Metric.ts index 4fde4cbeb4..6ff6811553 100644 --- a/packages/effect/src/observability/Metric.ts +++ b/packages/effect/src/observability/Metric.ts @@ -2782,11 +2782,11 @@ export const update: { } = dual< (input: Input) => (self: Metric) => Effect, (self: Metric, input: Input) => Effect ->(2, (self, input) => - InternalEffect.flatMap( - InternalEffect.services(), - (context) => InternalEffect.sync(() => self.unsafeUpdate(input, context)) - )) +>( + 2, + (self, input) => + InternalEffect.servicesWith((services) => InternalEffect.sync(() => self.unsafeUpdate(input, services))) +) /** * Returns a new metric that is powered by this one, but which accepts updates diff --git a/packages/effect/src/platform/PlatformError.ts b/packages/effect/src/platform/PlatformError.ts index d6c63bf41d..e68fea7e6c 100644 --- a/packages/effect/src/platform/PlatformError.ts +++ b/packages/effect/src/platform/PlatformError.ts @@ -4,25 +4,25 @@ import * as Data from "../data/Data.ts" /** - * @since 1.0.0 + * @since 4.0.0 * @category type id */ export const TypeId: TypeId = "~effect/PlatformError" /** - * @since 1.0.0 + * @since 4.0.0 * @category type id */ export type TypeId = "~effect/PlatformError" /** - * @since 1.0.0 + * @since 4.0.0 * @category Models */ export type Module = "Clipboard" | "Command" | "FileSystem" | "KeyValueStore" | "Path" | "Stream" | "Terminal" /** - * @since 1.0.0 + * @since 4.0.0 * @category Models * @example * ```ts @@ -55,12 +55,12 @@ export class BadArgument extends Data.TaggedError("BadArgument")<{ cause?: unknown }> { /** - * @since 1.0.0 + * @since 4.0.0 */ readonly [TypeId]: typeof TypeId = TypeId /** - * @since 1.0.0 + * @since 4.0.0 */ override get message(): string { return `${this.module}.${this.method}${this.description ? `: ${this.description}` : ""}` @@ -68,7 +68,7 @@ export class BadArgument extends Data.TaggedError("BadArgument")<{ } /** - * @since 1.0.0 + * @since 4.0.0 * @category Model * @example * ```ts @@ -145,7 +145,7 @@ export type SystemErrorReason = * }) * ``` * - * @since 1.0.0 + * @since 4.0.0 * @category models */ export class SystemError extends Data.TaggedError("SystemError")<{ @@ -158,12 +158,12 @@ export class SystemError extends Data.TaggedError("SystemError")<{ cause?: unknown }> { /** - * @since 1.0.0 + * @since 4.0.0 */ readonly [TypeId]: typeof TypeId = TypeId /** - * @since 1.0.0 + * @since 4.0.0 */ override get message(): string { return `${this.reason}: ${this.module}.${this.method}${ @@ -173,7 +173,7 @@ export class SystemError extends Data.TaggedError("SystemError")<{ } /** - * @since 1.0.0 + * @since 4.0.0 * @category Models * @example * ```ts diff --git a/packages/effect/src/schema/AST.ts b/packages/effect/src/schema/AST.ts index 9dfda86b8c..771fccb786 100644 --- a/packages/effect/src/schema/AST.ts +++ b/packages/effect/src/schema/AST.ts @@ -509,6 +509,10 @@ export class AnyKeyword extends AbstractParser { return fromRefinement(this, Predicate.isUnknown) } /** @internal */ + goJson() { + return this + } + /** @internal */ getExpected(): string { return "any" } @@ -530,6 +534,10 @@ export class UnknownKeyword extends AbstractParser { return fromRefinement(this, Predicate.isUnknown) } /** @internal */ + goJson() { + return this + } + /** @internal */ getExpected(): string { return "unknown" } diff --git a/packages/effect/src/schema/Getter.ts b/packages/effect/src/schema/Getter.ts index 9cacf830dd..9ffd9ea012 100644 --- a/packages/effect/src/schema/Getter.ts +++ b/packages/effect/src/schema/Getter.ts @@ -6,6 +6,7 @@ import * as Predicate from "../data/Predicate.ts" import * as Effect from "../Effect.ts" import { PipeableClass } from "../internal/schema/util.ts" import * as Str from "../primitives/String.ts" +import * as DateTime from "../time/DateTime.ts" import type * as Annotations from "./Annotations.ts" import type * as AST from "./AST.ts" import * as Issue from "./Issue.ts" @@ -257,6 +258,19 @@ export function Date(): Getter { return map((u) => new globalThis.Date(u)) } +/** + * @category Coercions + * @since 4.0.0 + */ +export function DateTimeUtc(): Getter { + return onSome((u) => + Effect.try({ + try: () => Option.some(DateTime.toUtc(DateTime.unsafeMake(u))), + catch: (e) => new Issue.InvalidValue(Option.some(u), { message: globalThis.String(e) }) + }) + ) +} + /** * @category String transformations * @since 4.0.0 diff --git a/packages/effect/src/schema/Schema.ts b/packages/effect/src/schema/Schema.ts index ce22769f60..7c57b068a8 100644 --- a/packages/effect/src/schema/Schema.ts +++ b/packages/effect/src/schema/Schema.ts @@ -567,7 +567,7 @@ export const asserts = ToParser.asserts export function decodeUnknownEffect(codec: Codec) { const parser = ToParser.decodeUnknownEffect(codec) return (input: unknown, options?: AST.ParseOptions): Effect.Effect => { - return Effect.mapError(parser(input, options), (issue) => new SchemaError({ issue })) + return Effect.mapErrorEager(parser(input, options), (issue) => new SchemaError({ issue })) } } @@ -641,7 +641,7 @@ export const decodeSync = ToParser.decodeSync export function encodeUnknownEffect(codec: Codec) { const parser = ToParser.encodeUnknownEffect(codec) return (input: unknown, options?: AST.ParseOptions): Effect.Effect => { - return Effect.mapError(parser(input, options), (issue) => new SchemaError({ issue })) + return Effect.mapErrorEager(parser(input, options), (issue) => new SchemaError({ issue })) } } @@ -3912,14 +3912,10 @@ export const DateTimeUtc = declare( defaultJsonSerializer: () => link()( String, - Transformation.transformOrFail({ - decode: (s) => - Effect.try({ - try: () => DateTime.unsafeMake(s), - catch: (e) => new Issue.InvalidValue(O.some(s), { message: globalThis.String(e) }) - }), - encode: (utc) => Effect.succeed(utc.toString()) - }) + new Transformation.Transformation( + Getter.DateTimeUtc(), + Getter.map(DateTime.formatIso) + ) ), // TODO: test arbitrary, pretty and equivalence annotations arbitrary: { diff --git a/packages/effect/src/schema/unstable/index.ts b/packages/effect/src/schema/unstable/index.ts index 717f5903eb..52787f64ee 100644 --- a/packages/effect/src/schema/unstable/index.ts +++ b/packages/effect/src/schema/unstable/index.ts @@ -4,5 +4,6 @@ /** * @since 4.0.0 + * @experimental */ export * as MetaAST from "./MetaAST.ts" diff --git a/packages/effect/src/stream/Stream.ts b/packages/effect/src/stream/Stream.ts index 1f2395cb82..f53c39aa00 100644 --- a/packages/effect/src/stream/Stream.ts +++ b/packages/effect/src/stream/Stream.ts @@ -617,6 +617,12 @@ export const failSync = (evaluate: LazyArg): Stream => fromChann */ export const failCause = (cause: Cause.Cause): Stream => fromChannel(Channel.failCause(cause)) +/** + * @since 2.0.0 + * @category constructors + */ +export const die = (defect: unknown): Stream => fromChannel(Channel.die(defect)) + /** * The stream that always fails with the specified lazily evaluated `Cause`. * @@ -1219,6 +1225,23 @@ export const map: { Arr.map(f) ))) +/** + * @since 2.0.0 + * @category mapping + */ +export const mapArray: { + ( + f: (a: Arr.NonEmptyReadonlyArray) => Arr.NonEmptyReadonlyArray + ): (self: Stream) => Stream + ( + self: Stream, + f: (a: Arr.NonEmptyReadonlyArray) => Arr.NonEmptyReadonlyArray + ): Stream +} = dual(2, ( + self: Stream, + f: (a: Arr.NonEmptyReadonlyArray) => Arr.NonEmptyReadonlyArray +): Stream => fromChannel(Channel.map(self.channel, f))) + /** * Maps over elements of the stream with the specified effectful function. * diff --git a/packages/effect/src/unstable/cluster/ClusterCron.ts b/packages/effect/src/unstable/cluster/ClusterCron.ts new file mode 100644 index 0000000000..3d0ffb8985 --- /dev/null +++ b/packages/effect/src/unstable/cluster/ClusterCron.ts @@ -0,0 +1,137 @@ +/** + * @since 4.0.0 + */ +import * as Option from "../../data/Option.ts" +import * as Effect from "../../Effect.ts" +import * as PrimaryKey from "../../interfaces/PrimaryKey.ts" +import * as Layer from "../../Layer.ts" +import * as Schedule from "../../Schedule.ts" +import * as Schema from "../../schema/Schema.ts" +import type { Scope } from "../../Scope.ts" +import * as Cron from "../../time/Cron.ts" +import * as DateTime from "../../time/DateTime.ts" +import * as Duration from "../../time/Duration.ts" +import * as Rpc from "../rpc/Rpc.ts" +import * as ClusterSchema from "./ClusterSchema.ts" +import { Persisted, Uninterruptible } from "./ClusterSchema.ts" +import * as DeliverAt from "./DeliverAt.ts" +import * as Entity from "./Entity.ts" +import type { Sharding } from "./Sharding.ts" +import * as Singleton from "./Singleton.ts" + +/** + * @since 4.0.0 + * @category Constructors + */ +export const make = (options: { + readonly name: string + readonly cron: Cron.Cron + readonly execute: Effect.Effect + + /** + * Choose a shard group to run this cron job on. + */ + readonly shardGroup?: string | undefined + + /** + * Whether to run the next cron job based from the time of the previous run. + * + * Defaults to `false`, meaning the next run will be calculated from the + * current time. + */ + readonly calculateNextRunFromPrevious?: boolean | undefined + + /** + * If set, the cron job will skip execution if the scheduled time is older + * than this duration. + * + * This is useful to prevent running jobs that were scheduled too far in the + * past. + * + * Defaults to "1 day". + */ + readonly skipIfOlderThan?: Duration.DurationInput | undefined +}): Layer.Layer> => { + const CronEntity = Entity.make(`ClusterCron/${options.name}`, [ + Rpc.make("run", { + payload: CronPayload + }) + .annotate(Persisted, true) + .annotate(Uninterruptible, true) + ]) + .annotate(ClusterSchema.ShardGroup, () => options.shardGroup ?? "default") + .annotate(ClusterSchema.ClientTracingEnabled, false) + + const InitialRun = Singleton.make( + `ClusterCron/${options.name}`, + Effect.gen(function*() { + const client = (yield* CronEntity.client)("initial") + const now = yield* DateTime.now + const next = Cron.next(options.cron, now) + yield* client.run({ + dateTime: DateTime.unsafeFromDate(next) + }, { discard: true }) + }), + { shardGroup: options.shardGroup } + ) + + const skipIfOlderThan = Option.fromNullishOr(options.skipIfOlderThan).pipe( + Option.map(Duration.decode), + Option.getOrElse(() => Duration.days(1)) + ) + + const effect = Effect.fnUntraced(function*(dateTime: DateTime.Utc) { + const now = yield* DateTime.now + if (DateTime.lessThan(dateTime, DateTime.subtractDuration(now, skipIfOlderThan))) { + return + } + return yield* options.execute + }, Effect.orDie) + + const EntityLayer = CronEntity.toLayer(Effect.gen(function*() { + const makeClient = yield* CronEntity.client + return { + run(request) { + return Effect.ensuring( + effect(request.payload.dateTime), + Effect.gen(function*() { + const now = yield* DateTime.now + const next = DateTime.unsafeFromDate(Cron.next( + options.cron, + options.calculateNextRunFromPrevious ? request.payload.dateTime : now + )) + const client = makeClient(DateTime.formatIso(next)) + return yield* client.run({ dateTime: next }, { discard: true }).pipe( + Effect.sandbox, + Effect.retry(retryPolicy) + ) + }).pipe( + Effect.catchCause(Effect.logWarning), + Effect.annotateLogs({ + module: "ClusterCron", + name: options.name, + dateTime: request.payload.dateTime + }) + ) + ) + } + } + })) + + return Layer.merge(InitialRun, EntityLayer) +} + +const retryPolicy = Schedule.exponential(200, 1.5).pipe( + Schedule.either(Schedule.spaced("1 minute")) +) + +class CronPayload extends Schema.Class("@effect/cluster/ClusterCron/CronPayload")({ + dateTime: Schema.DateTimeUtc +}) { + [PrimaryKey.symbol]() { + return "" + } + [DeliverAt.symbol]() { + return this.dateTime + } +} diff --git a/packages/effect/src/unstable/cluster/ClusterError.ts b/packages/effect/src/unstable/cluster/ClusterError.ts new file mode 100644 index 0000000000..a10887eade --- /dev/null +++ b/packages/effect/src/unstable/cluster/ClusterError.ts @@ -0,0 +1,221 @@ +/** + * @since 4.0.0 + */ +import * as Cause from "../../Cause.ts" +import { hasProperty, isTagged } from "../../data/Predicate.ts" +import * as Effect from "../../Effect.ts" +import * as Schema from "../../schema/Schema.ts" +import { EntityAddress } from "./EntityAddress.ts" +import { RunnerAddress } from "./RunnerAddress.ts" +import { SnowflakeFromString } from "./Snowflake.ts" + +/** + * @since 4.0.0 + * @category Symbols + */ +export const TypeId: TypeId = "~effect/cluster/ClusterError" + +/** + * @since 4.0.0 + * @category Symbols + */ +export type TypeId = "~effect/cluster/ClusterError" + +/** + * Represents an error that occurs when a Runner receives a message for an entity + * that it is not assigned to it. + * + * @since 4.0.0 + * @category errors + */ +export class EntityNotAssignedToRunner + extends Schema.ErrorClass(`${TypeId}/EntityNotAssignedToRunner`)({ + _tag: Schema.tag("EntityNotAssignedToRunner"), + address: EntityAddress + }) +{ + /** + * @since 4.0.0 + */ + readonly [TypeId] = TypeId + + /** + * @since 4.0.0 + */ + static is(u: unknown): u is EntityNotAssignedToRunner { + return hasProperty(u, TypeId) && isTagged(u, "EntityNotAssignedToRunner") + } +} + +/** + * Represents an error that occurs when a Runner receives a message for an entity + * that it is not responsible for managing. + * + * @since 4.0.0 + * @category errors + */ +export class EntityNotManagedByRunner + extends Schema.ErrorClass(`${TypeId}/EntityNotManagedByRunner`)({ + _tag: Schema.tag("EntityNotManagedByRunner"), + address: EntityAddress + }) +{ + /** + * @since 4.0.0 + */ + readonly [TypeId] = TypeId + + /** + * @since 4.0.0 + */ + static is(u: unknown): u is EntityNotManagedByRunner { + return hasProperty(u, TypeId) && isTagged(u, "EntityNotManagedByRunner") + } +} + +/** + * Represents an error that occurs when a message fails to be properly + * deserialized by an entity. + * + * @since 4.0.0 + * @category errors + */ +export class MalformedMessage extends Schema.ErrorClass(`${TypeId}/MalformedMessage`)({ + _tag: Schema.tag("MalformedMessage"), + cause: Schema.Defect +}) { + /** + * @since 4.0.0 + */ + readonly [TypeId] = TypeId + + /** + * @since 4.0.0 + */ + static is(u: unknown): u is MalformedMessage { + return hasProperty(u, TypeId) && isTagged(u, "MalformedMessage") + } + + /** + * @since 4.0.0 + */ + static refail: (effect: Effect.Effect) => Effect.Effect< + A, + MalformedMessage, + R + > = Effect.mapError((cause) => new MalformedMessage({ cause })) +} + +/** + * Represents an error that occurs when a message fails to be persisted into + * cluster's mailbox storage. + * + * @since 4.0.0 + * @category errors + */ +export class PersistenceError extends Schema.ErrorClass(`${TypeId}/PersistenceError`)({ + _tag: Schema.tag("PersistenceError"), + cause: Schema.Defect +}) { + /** + * @since 4.0.0 + */ + readonly [TypeId] = TypeId + + /** + * @since 4.0.0 + */ + static refail(effect: Effect.Effect): Effect.Effect { + return Effect.catchCause(effect, (cause) => Effect.fail(new PersistenceError({ cause: Cause.squash(cause) }))) + } +} + +/** + * Represents an error that occurs when a Runner is not registered with the shard + * manager. + * + * @since 4.0.0 + * @category errors + */ +export class RunnerNotRegistered extends Schema.ErrorClass(`${TypeId}/RunnerNotRegistered`)({ + _tag: Schema.tag("RunnerNotRegistered"), + address: RunnerAddress +}) { + /** + * @since 4.0.0 + */ + readonly [TypeId] = TypeId +} + +/** + * Represents an error that occurs when a Runner is unresponsive. + * + * @since 4.0.0 + * @category errors + */ +export class RunnerUnavailable extends Schema.ErrorClass(`${TypeId}/RunnerUnavailable`)({ + _tag: Schema.tag("RunnerUnavailable"), + address: RunnerAddress +}) { + /** + * @since 4.0.0 + */ + readonly [TypeId] = TypeId + + /** + * @since 4.0.0 + */ + static is(u: unknown): u is RunnerUnavailable { + return hasProperty(u, TypeId) && isTagged(u, "RunnerUnavailable") + } +} + +/** + * Represents an error that occurs when the entities mailbox is full. + * + * @since 4.0.0 + * @category errors + */ +export class MailboxFull extends Schema.ErrorClass(`${TypeId}/MailboxFull`)({ + _tag: Schema.tag("MailboxFull"), + address: EntityAddress +}) { + /** + * @since 4.0.0 + */ + readonly [TypeId] = TypeId + + /** + * @since 4.0.0 + */ + static is(u: unknown): u is MailboxFull { + return hasProperty(u, TypeId) && isTagged(u, "MailboxFull") + } +} + +/** + * Represents an error that occurs when the entity is already processing a + * request. + * + * @since 4.0.0 + * @category errors + */ +export class AlreadyProcessingMessage + extends Schema.ErrorClass(`${TypeId}/AlreadyProcessingMessage`)({ + _tag: Schema.tag("AlreadyProcessingMessage"), + envelopeId: SnowflakeFromString, + address: EntityAddress + }) +{ + /** + * @since 4.0.0 + */ + readonly [TypeId] = TypeId + + /** + * @since 4.0.0 + */ + static is(u: unknown): u is AlreadyProcessingMessage { + return hasProperty(u, TypeId) && isTagged(u, "AlreadyProcessingMessage") + } +} diff --git a/packages/effect/src/unstable/cluster/ClusterMetrics.ts b/packages/effect/src/unstable/cluster/ClusterMetrics.ts new file mode 100644 index 0000000000..5c2de19ea3 --- /dev/null +++ b/packages/effect/src/unstable/cluster/ClusterMetrics.ts @@ -0,0 +1,48 @@ +/** + * @since 4.0.0 + */ +import * as Metric from "../../observability/Metric.ts" + +/** + * @since 4.0.0 + * @category metrics + */ +export const shards = Metric.gauge("effect_cluster_shards") + +/** + * @since 4.0.0 + * @category metrics + */ +export const entities = Metric.gauge("effect_cluster_entities", { + bigint: true +}) + +/** + * @since 4.0.0 + * @category metrics + */ +export const singletons = Metric.gauge("effect_cluster_singletons") + +/** + * @since 4.0.0 + * @category metrics + */ +export const runners = Metric.gauge("effect_cluster_runners") + +/** + * @since 4.0.0 + * @category metrics + */ +export const assignedShards = Metric.gauge("effect_cluster_shards_assigned") + +/** + * @since 4.0.0 + * @category metrics + */ +export const unassignedShards = Metric.gauge("effect_cluster_shards_unassigned") + +/** + * @since 4.0.0 + * @category metrics + */ +export const rebalances = Metric.counter("effect_cluster_rebalances") diff --git a/packages/effect/src/unstable/cluster/ClusterSchema.ts b/packages/effect/src/unstable/cluster/ClusterSchema.ts new file mode 100644 index 0000000000..1c6b1c7b3c --- /dev/null +++ b/packages/effect/src/unstable/cluster/ClusterSchema.ts @@ -0,0 +1,39 @@ +/** + * @since 4.0.0 + */ +import { constFalse, constTrue } from "../../Function.ts" +import * as ServiceMap from "../../ServiceMap.ts" +import type { EntityId } from "./EntityId.ts" + +/** + * @since 4.0.0 + * @category Annotations + */ +export const Persisted = ServiceMap.Reference("effect/cluster/ClusterSchema/Persisted", { + defaultValue: constFalse +}) + +/** + * @since 4.0.0 + * @category Annotations + */ +export const Uninterruptible = ServiceMap.Reference("effect/cluster/ClusterSchema/Uninterruptible", { + defaultValue: constFalse +}) + +/** + * @since 4.0.0 + * @category Annotations + */ +export const ShardGroup = ServiceMap.Reference<(entityId: EntityId) => string>( + "effect/cluster/ClusterSchema/ShardGroup", + { defaultValue: () => (_) => "default" } +) + +/** + * @since 4.0.0 + * @category Annotations + */ +export const ClientTracingEnabled = ServiceMap.Reference("effect/cluster/ClusterSchema/ClientTracingEnabled", { + defaultValue: constTrue +}) diff --git a/packages/effect/src/unstable/cluster/DeliverAt.ts b/packages/effect/src/unstable/cluster/DeliverAt.ts new file mode 100644 index 0000000000..c20a6f30ec --- /dev/null +++ b/packages/effect/src/unstable/cluster/DeliverAt.ts @@ -0,0 +1,36 @@ +/** + * @since 4.0.0 + */ +import { hasProperty } from "../../data/Predicate.ts" +import type { DateTime } from "../../time/DateTime.ts" + +/** + * @since 4.0.0 + * @category symbols + */ +export const symbol: "~effect/cluster/DeliverAt" = "~effect/cluster/DeliverAt" as const + +/** + * @since 4.0.0 + * @category models + */ +export interface DeliverAt { + [symbol](): DateTime +} + +/** + * @since 4.0.0 + * @category guards + */ +export const isDeliverAt = (self: unknown): self is DeliverAt => hasProperty(self, symbol) + +/** + * @since 4.0.0 + * @category accessors + */ +export const toMillis = (self: unknown): number | null => { + if (isDeliverAt(self)) { + return self[symbol]().epochMillis + } + return null +} diff --git a/packages/effect/src/unstable/cluster/Entity.ts b/packages/effect/src/unstable/cluster/Entity.ts new file mode 100644 index 0000000000..759db0b841 --- /dev/null +++ b/packages/effect/src/unstable/cluster/Entity.ts @@ -0,0 +1,596 @@ +/** + * @since 4.0.0 + */ +import type * as Cause from "../../Cause.ts" +import * as Arr from "../../collections/Array.ts" +import * as Data from "../../data/Data.ts" +import * as Option from "../../data/Option.ts" +import * as Predicate from "../../data/Predicate.ts" +import * as Effect from "../../Effect.ts" +import * as Exit from "../../Exit.ts" +import { identity } from "../../Function.ts" +import * as Equal from "../../interfaces/Equal.ts" +import * as Hash from "../../interfaces/Hash.ts" +import * as Layer from "../../Layer.ts" +import * as Queue from "../../Queue.ts" +import type * as Schedule from "../../Schedule.ts" +import { Scope } from "../../Scope.ts" +import * as ServiceMap from "../../ServiceMap.ts" +import type * as Stream from "../../stream/Stream.ts" +import type { DurationInput } from "../../time/Duration.ts" +import type * as Rpc from "../rpc/Rpc.ts" +import * as RpcClient from "../rpc/RpcClient.ts" +import * as RpcGroup from "../rpc/RpcGroup.ts" +import * as RpcServer from "../rpc/RpcServer.ts" +import type { + AlreadyProcessingMessage, + EntityNotManagedByRunner, + MailboxFull, + PersistenceError +} from "./ClusterError.ts" +import { ShardGroup } from "./ClusterSchema.ts" +import { EntityAddress } from "./EntityAddress.ts" +import type { EntityId } from "./EntityId.ts" +import { EntityType } from "./EntityType.ts" +import * as Envelope from "./Envelope.ts" +import { hashString } from "./internal/hash.ts" +import { ResourceMap } from "./internal/resourceMap.ts" +import type * as Reply from "./Reply.ts" +import { RunnerAddress } from "./RunnerAddress.ts" +import * as ShardId from "./ShardId.ts" +import type { Sharding } from "./Sharding.ts" +import { ShardingConfig } from "./ShardingConfig.ts" +import * as Snowflake from "./Snowflake.ts" + +/** + * @since 4.0.0 + * @category type ids + */ +export const TypeId: TypeId = "~effect/cluster/Entity" + +/** + * @since 4.0.0 + * @category type ids + */ +export type TypeId = "~effect/cluster/Entity" + +/** + * @since 4.0.0 + * @category models + */ +export interface Entity< + in out Type extends string, + in out Rpcs extends Rpc.Any +> extends Equal.Equal { + readonly [TypeId]: TypeId + /** + * The name of the entity type. + */ + readonly type: EntityType + + /** + * A RpcGroup definition for messages which represents the messaging protocol + * that the entity is capable of processing. + */ + readonly protocol: RpcGroup.RpcGroup + + /** + * Get the shard group for the given EntityId. + */ + getShardGroup(entityId: EntityId): string + + /** + * Get the ShardId for the given EntityId. + */ + getShardId(entityId: EntityId): Effect.Effect + + /** + * Annotate the entity with a value. + */ + annotate(key: ServiceMap.Key, value: S): Entity + + /** + * Annotate the Rpc's above this point with a value. + */ + annotateRpcs(key: ServiceMap.Key, value: S): Entity + + /** + * Annotate the entity with the given annotations. + */ + annotateMerge(annotation: ServiceMap.ServiceMap): Entity + + /** + * Annotate the Rpc's above this point with a context object. + */ + annotateRpcsMerge(context: ServiceMap.ServiceMap): Entity + + /** + * Create a client for this entity. + */ + readonly client: Effect.Effect< + ( + entityId: string + ) => RpcClient.RpcClient.From< + Rpcs, + MailboxFull | AlreadyProcessingMessage | PersistenceError | EntityNotManagedByRunner + >, + never, + Sharding + > + + /** + * Create a Layer from an Entity. + * + * It will register the entity with the Sharding service. + */ + toLayer< + Handlers extends HandlersFrom, + RX = never + >( + build: Handlers | Effect.Effect, + options?: { + readonly maxIdleTime?: DurationInput | undefined + readonly concurrency?: number | "unbounded" | undefined + readonly mailboxCapacity?: number | "unbounded" | undefined + readonly disableFatalDefects?: boolean | undefined + readonly defectRetryPolicy?: Schedule.Schedule | undefined + readonly spanAttributes?: Record | undefined + } + ): Layer.Layer< + never, + never, + | Exclude + | RpcGroup.HandlersServices + | Rpc.ServicesClient + | Rpc.ServicesServer + | Rpc.Middleware + | Sharding + > + + of>(handlers: Handlers): Handlers + + /** + * Create a Layer from an Entity. + * + * It will register the entity with the Sharding service. + */ + toLayerQueue< + R, + RX = never + >( + build: + | (( + queue: Queue.Dequeue>, + replier: Replier + ) => Effect.Effect) + | Effect.Effect< + ( + queue: Queue.Dequeue>, + replier: Replier + ) => Effect.Effect, + never, + RX + >, + options?: { + readonly maxIdleTime?: DurationInput | undefined + readonly mailboxCapacity?: number | "unbounded" | undefined + readonly disableFatalDefects?: boolean | undefined + readonly defectRetryPolicy?: Schedule.Schedule | undefined + readonly spanAttributes?: Record | undefined + } + ): Layer.Layer< + never, + never, + | Exclude + | R + | Rpc.ServicesClient + | Rpc.ServicesServer + | Rpc.Middleware + | Sharding + > +} +/** + * @since 4.0.0 + * @category models + */ +export type Any = Entity + +/** + * @since 4.0.0 + * @category models + */ +export type HandlersFrom = { + readonly [Current in Rpc as Current["_tag"]]: ( + envelope: Request + ) => Rpc.ResultFrom | Rpc.Fork> +} + +/** + * @since 4.0.0 + * @category refinements + */ +export const isEntity = (u: unknown): u is Any => Predicate.hasProperty(u, TypeId) + +const Proto = { + [TypeId]: TypeId, + [Hash.symbol](this: Entity): number { + return Hash.structure({ type: this.type }) + }, + [Equal.symbol](this: Entity, that: Equal.Equal): boolean { + return isEntity(that) && this.type === that.type + }, + annotate(this: Entity, key: ServiceMap.Key, value: S) { + return fromRpcGroup(this.type, this.protocol.annotate(key, value)) + }, + annotateRpcs(this: Entity, key: ServiceMap.Key, value: S) { + return fromRpcGroup(this.type, this.protocol.annotateRpcs(key, value)) + }, + annotateMerge(this: Entity, annotations: ServiceMap.ServiceMap) { + return fromRpcGroup(this.type, this.protocol.annotateMerge(annotations)) + }, + annotateRpcsMerge(this: Entity, annotations: ServiceMap.ServiceMap) { + return fromRpcGroup(this.type, this.protocol.annotateRpcsMerge(annotations)) + }, + getShardId(this: Entity, entityId: EntityId) { + return Effect.map(shardingTag.asEffect(), (sharding) => sharding.getShardId(entityId, this.getShardGroup(entityId))) + }, + get client() { + return shardingTag.asEffect().pipe( + Effect.flatMap((sharding) => sharding.makeClient(this as any)) + ) + }, + toLayer< + Rpcs extends Rpc.Any, + Handlers extends HandlersFrom, + RX = never + >( + this: Entity, + build: Handlers | Effect.Effect, + options?: { + readonly maxIdleTime?: DurationInput | undefined + readonly concurrency?: number | "unbounded" | undefined + readonly mailboxCapacity?: number | "unbounded" | undefined + readonly disableFatalDefects?: boolean | undefined + readonly defectRetryPolicy?: Schedule.Schedule | undefined + readonly spanAttributes?: Record | undefined + } + ): Layer.Layer< + never, + never, + | Exclude + | RpcGroup.HandlersServices + | Rpc.ServicesClient + | Rpc.ServicesServer + | Rpc.Middleware + | Sharding + > { + return shardingTag.asEffect().pipe( + Effect.flatMap((sharding) => + sharding.registerEntity( + this, + Effect.isEffect(build) ? build : Effect.succeed(build), + options + ) + ), + Layer.effectDiscard + ) + }, + of: identity, + toLayerQueue< + Rpcs extends Rpc.Any, + R, + RX = never + >( + this: Entity, + build: + | (( + mailbox: Queue.Dequeue>, + replier: Replier + ) => Effect.Effect) + | Effect.Effect< + ( + mailbox: Queue.Dequeue>, + replier: Replier + ) => Effect.Effect, + never, + RX + >, + options?: { + readonly maxIdleTime?: DurationInput | undefined + readonly mailboxCapacity?: number | "unbounded" | undefined + readonly disableFatalDefects?: boolean | undefined + readonly defectRetryPolicy?: Schedule.Schedule | undefined + readonly spanAttributes?: Record | undefined + } + ) { + const buildHandlers = Effect.gen(this, function*() { + const behaviour = Effect.isEffect(build) ? yield* build : build + const queue = yield* Queue.make>() + + // create the rpc handlers for the entity + const handler = (envelope: any) => { + return Effect.callback((resume) => { + Queue.unsafeOffer(queue, envelope) + resumes.set(envelope, resume) + }) + } + const handlers: Record = {} + for (const rpc of this.protocol.requests.keys()) { + handlers[rpc] = handler + } + + // make the Replier for the behaviour + const resumes = new Map, (exit: Exit.Exit) => void>() + const complete = (request: Envelope.Request, exit: Exit.Exit) => + Effect.sync(() => { + const resume = resumes.get(request) + if (resume) { + resumes.delete(request) + resume(exit) + } + }) + const replier: Replier = { + succeed: (request, value) => complete(request, Exit.succeed(value)), + fail: (request, error) => complete(request, Exit.fail(error)), + failCause: (request, cause) => complete(request, Exit.failCause(cause)), + complete + } + + // fork the behaviour into the layer scope + yield* behaviour(queue, replier).pipe( + Effect.catchCause((cause) => { + const exit = Exit.failCause(cause) + for (const resume of resumes.values()) { + resume(exit) + } + return Effect.void + }), + Effect.interruptible, + Effect.forkScoped + ) + + return handlers as any + }) + + return this.toLayer(buildHandlers, { + ...options, + concurrency: "unbounded" + }) + } +} + +/** + * Creates a new `Entity` of the specified `type` which will accept messages + * that adhere to the provided `RpcGroup`. + * + * @since 4.0.0 + * @category constructors + */ +export const fromRpcGroup = ( + /** + * The entity type name. + */ + type: Type, + /** + * The schema definition for messages that the entity is capable of + * processing. + */ + protocol: RpcGroup.RpcGroup +): Entity => { + const self = Object.create(Proto) + self.type = EntityType.makeSync(type) + self.protocol = protocol + self.getShardGroup = ServiceMap.get(protocol.annotations, ShardGroup) + return self +} + +/** + * Creates a new `Entity` of the specified `type` which will accept messages + * that adhere to the provided schemas. + * + * @since 4.0.0 + * @category constructors + */ +export const make = >( + /** + * The entity type name. + */ + type: Type, + /** + * The schema definition for messages that the entity is capable of + * processing. + */ + protocol: Rpcs +): Entity => fromRpcGroup(type, RpcGroup.make(...protocol)) + +/** + * A Context.Tag to access the current entity address. + * + * @since 4.0.0 + * @category context + */ +export class CurrentAddress extends ServiceMap.Key< + CurrentAddress, + EntityAddress +>()("effect/cluster/Entity/EntityAddress") {} + +/** + * A Context.Tag to access the current Runner address. + * + * @since 4.0.0 + * @category context + */ +export class CurrentRunnerAddress extends ServiceMap.Key< + CurrentRunnerAddress, + RunnerAddress +>()("effect/cluster/Entity/RunnerAddress") {} + +/** + * @since 4.0.0 + * @category Replier + */ +export interface Replier { + readonly succeed: ( + request: Envelope.Request, + value: Replier.Success + ) => Effect.Effect + + readonly fail: ( + request: Envelope.Request, + error: Rpc.Error + ) => Effect.Effect + + readonly failCause: ( + request: Envelope.Request, + cause: Cause.Cause> + ) => Effect.Effect + + readonly complete: ( + request: Envelope.Request, + exit: Exit.Exit, Rpc.Error> + ) => Effect.Effect +} + +/** + * @since 4.0.0 + * @category Replier + */ +export declare namespace Replier { + /** + * @since 4.0.0 + * @category Replier + */ + export type Success = Rpc.Success extends Stream.Stream ? + Stream.Stream<_A, _E | Rpc.Error, _R> | Queue.Dequeue<_A, _E | Rpc.Error> + : Rpc.Success +} + +/** + * @since 4.0.0 + * @category Request + */ +export class Request extends Data.Class< + Envelope.Request & { + readonly lastSentChunk: Option.Option> + } +> { + /** + * @since 4.0.0 + */ + get lastSentChunkValue(): Option.Option> { + return this.lastSentChunk.pipe(Option.map((chunk) => Arr.lastNonEmpty(chunk.values))) + } + + /** + * @since 4.0.0 + */ + get nextSequence(): number { + if (Option.isNone(this.lastSentChunk)) { + return 0 + } + return this.lastSentChunk.value.sequence + 1 + } +} + +const shardingTag = ServiceMap.Key("effect/cluster/Sharding") + +/** + * @since 4.0.0 + * @category Testing + */ +export const makeTestClient: ( + entity: Entity, + layer: Layer.Layer +) => Effect.Effect< + (entityId: string) => Effect.Effect>, + LE, + Scope | ShardingConfig | Exclude | Rpc.MiddlewareClient +> = Effect.fnUntraced(function*( + entity: Entity, + layer: Layer.Layer +) { + const config = yield* ShardingConfig + const makeShardId = (entityId: string) => + ShardId.make( + entity.getShardGroup(entityId as EntityId), + (Math.abs(hashString(entityId) % config.shardsPerGroup)) + 1 + ) + const snowflakeGen = yield* Snowflake.makeGenerator + const runnerAddress = new RunnerAddress({ host: "localhost", port: 3000 }) + const entityMap = new Map | Rpc.ServicesServer | Rpc.Middleware | LR + > + readonly concurrency: number | "unbounded" + readonly build: Effect.Effect< + ServiceMap.ServiceMap>, + never, + Scope | CurrentAddress + > + }>() + const sharding = shardingTag.of({ + ...({} as Sharding["Service"]), + registerEntity: (entity, handlers, options) => + Effect.servicesWith((services) => { + entityMap.set(entity.type, { + services: services as any, + concurrency: options?.concurrency ?? 1, + build: entity.protocol.toHandlers(handlers as any).pipe( + Effect.provideServices(services.pipe( + ServiceMap.add(CurrentRunnerAddress, runnerAddress), + ServiceMap.omit(Scope) + )) + ) as any + }) + return Effect.void + }) + }) + yield* Layer.build(Layer.provide(layer, Layer.succeed(shardingTag)(sharding))) + const entityEntry = entityMap.get(entity.type) + if (!entityEntry) { + return yield* Effect.die(`Entity.makeTestClient: ${entity.type} was not registered by layer`) + } + + const map = yield* ResourceMap.make(Effect.fnUntraced(function*(entityId: string) { + const address = new EntityAddress({ + entityType: entity.type, + entityId: entityId as EntityId, + shardId: makeShardId(entityId) + }) + const handlers = yield* entityEntry.build.pipe( + Effect.provideService(CurrentAddress, address) + ) + + // eslint-disable-next-line prefer-const + let client!: Effect.Success>> + const server = yield* RpcServer.makeNoSerialization(entity.protocol, { + concurrency: entityEntry.concurrency, + onFromServer(response) { + return client.write(response) + } + }).pipe(Effect.provide(handlers)) + + client = yield* RpcClient.makeNoSerialization(entity.protocol, { + supportsAck: true, + generateRequestId: () => snowflakeGen.unsafeNext() as any, + onFromClient({ message }) { + if (message._tag === "Request") { + return server.write(0, { + ...message, + payload: new Request({ + ...message, + [Envelope.TypeId]: Envelope.TypeId, + address, + requestId: Snowflake.Snowflake(message.id), + lastSentChunk: Option.none() + }) as any + }) + } + return server.write(0, message) + } + }) + return client.client + })) + + return (entityId: string) => map.get(entityId) +}) diff --git a/packages/effect/src/unstable/cluster/EntityAddress.ts b/packages/effect/src/unstable/cluster/EntityAddress.ts new file mode 100644 index 0000000000..a3c0547781 --- /dev/null +++ b/packages/effect/src/unstable/cluster/EntityAddress.ts @@ -0,0 +1,62 @@ +/** + * @since 4.0.0 + */ +import * as Equal from "../../interfaces/Equal.ts" +import * as Hash from "../../interfaces/Hash.ts" +import * as Schema from "../../schema/Schema.ts" +import { EntityId } from "./EntityId.ts" +import { EntityType } from "./EntityType.ts" +import { ShardId } from "./ShardId.ts" + +/** + * @since 4.0.0 + * @category type ids + */ +export const TypeId: TypeId = "~effect/cluster/EntityAddress" + +/** + * @since 4.0.0 + * @category type ids + */ +export type TypeId = "~effect/cluster/EntityAddress" + +/** + * Represents the unique address of an entity within the cluster. + * + * @since 4.0.0 + * @category models + */ +export class EntityAddress extends Schema.Class(TypeId)({ + shardId: ShardId, + entityType: EntityType, + entityId: EntityId +}) { + /** + * @since 4.0.0 + */ + readonly [TypeId] = TypeId; + + /** + * @since 4.0.0 + */ + [Equal.symbol](that: EntityAddress): boolean { + return this.entityType === that.entityType && this.entityId === that.entityId && + this.shardId[Equal.symbol](that.shardId) + } + + /** + * @since 4.0.0 + */ + [Hash.symbol]() { + return Hash.cached(this, () => Hash.string(`${this.entityType}:${this.entityId}:${this.shardId.toString()}`)) + } +} +/** + * @since 4.0.0 + * @category constructors + */ +export const make = (options: { + readonly shardId: ShardId + readonly entityType: EntityType + readonly entityId: EntityId +}): EntityAddress => new EntityAddress(options, { disableValidation: true }) diff --git a/packages/effect/src/unstable/cluster/EntityId.ts b/packages/effect/src/unstable/cluster/EntityId.ts new file mode 100644 index 0000000000..ec0f4937ff --- /dev/null +++ b/packages/effect/src/unstable/cluster/EntityId.ts @@ -0,0 +1,22 @@ +/** + * @since 4.0.0 + */ +import * as Schema from "../../schema/Schema.ts" + +/** + * @since 4.0.0 + * @category constructors + */ +export const EntityId = Schema.String.pipe(Schema.brand("~effect/cluster/EntityId")) + +/** + * @since 4.0.0 + * @category models + */ +export type EntityId = typeof EntityId.Type + +/** + * @since 4.0.0 + * @category constructors + */ +export const make = (id: string): EntityId => id as EntityId diff --git a/packages/effect/src/unstable/cluster/EntityProxy.ts b/packages/effect/src/unstable/cluster/EntityProxy.ts new file mode 100644 index 0000000000..170742165d --- /dev/null +++ b/packages/effect/src/unstable/cluster/EntityProxy.ts @@ -0,0 +1,238 @@ +/** + * @since 4.0.0 + */ +import * as Schema from "../../schema/Schema.ts" +import * as HttpApiEndpoint from "../httpapi/HttpApiEndpoint.ts" +import * as HttpApiGroup from "../httpapi/HttpApiGroup.ts" +import * as Rpc from "../rpc/Rpc.ts" +import * as RpcGroup from "../rpc/RpcGroup.ts" +import { AlreadyProcessingMessage, EntityNotManagedByRunner, MailboxFull, PersistenceError } from "./ClusterError.ts" +import type * as Entity from "./Entity.ts" +import type { EntityId } from "./EntityId.ts" + +const clientErrors = [ + MailboxFull, + AlreadyProcessingMessage, + PersistenceError, + EntityNotManagedByRunner +] as const + +/** + * Derives an `RpcGroup` from an `Entity`. + * + * ```ts + * import { ClusterSchema, Entity, EntityProxy, EntityProxyServer } from "effect/unstable/cluster" + * import { Rpc, RpcServer } from "effect/unstable/rpc" + * import { Schema } from "effect/schema" + * import { Layer } from "effect" + * + * export const Counter = Entity.make("Counter", [ + * Rpc.make("Increment", { + * payload: { id: Schema.String, amount: Schema.Number }, + * primaryKey: ({ id }) => id, + * success: Schema.Number + * }) + * ]).annotateRpcs(ClusterSchema.Persisted, true) + * + * // Use EntityProxy.toRpcGroup to create a `RpcGroup` from the Counter entity + * export class MyRpcs extends EntityProxy.toRpcGroup(Counter) {} + * + * // Use EntityProxyServer.layerRpcHandlers to create a layer that implements + * // the rpc handlers + * const RpcServerLayer = RpcServer.layer(MyRpcs).pipe( + * Layer.provide(EntityProxyServer.layerRpcHandlers(Counter)) + * ) + * ``` + * + * @since 4.0.0 + * @category Constructors + */ +export const toRpcGroup = ( + entity: Entity.Entity +): RpcGroup.RpcGroup> => { + const rpcs: Array = [] + for (const parentRpc_ of entity.protocol.requests.values()) { + const parentRpc = parentRpc_ as any as Rpc.AnyWithProps + const payloadSchema = Schema.Struct({ + entityId: Schema.String, + payload: parentRpc.payloadSchema + }) + const oldMake = payloadSchema.makeSync + payloadSchema.makeSync = (input: any, options?: Schema.MakeOptions) => { + return oldMake({ + entityId: input.entityId, + payload: parentRpc.payloadSchema.makeSync(input.payload, options) + }, options) + } + const rpc = Rpc.make(`${entity.type}.${parentRpc._tag}`, { + payload: payloadSchema, + error: Schema.Union([parentRpc.errorSchema, ...clientErrors]), + success: parentRpc.successSchema + }).annotateMerge(parentRpc.annotations) + const rpcDiscard = Rpc.make(`${entity.type}.${parentRpc._tag}Discard`, { + payload: payloadSchema, + error: Schema.Union(clientErrors) + }).annotateMerge(parentRpc.annotations) + rpcs.push(rpc, rpcDiscard) + } + return RpcGroup.make(...rpcs) as any as RpcGroup.RpcGroup> +} + +/** + * @since 4.0.0 + */ +export type ConvertRpcs = Rpcs extends Rpc.Rpc< + infer _Tag, + infer _Payload, + infer _Success, + infer _Error, + infer _Middleware, + infer _Requires +> ? + | Rpc.Rpc< + `${Prefix}.${_Tag}`, + Schema.Struct<{ + entityId: typeof Schema.String + payload: _Payload + }>, + _Success, + Schema.Codec< + _Error["Type"] | MailboxFull | AlreadyProcessingMessage | PersistenceError | EntityNotManagedByRunner, + | _Error["Encoded"] + | typeof MailboxFull["Encoded"] + | typeof AlreadyProcessingMessage["Encoded"] + | typeof PersistenceError["Encoded"] + | typeof EntityNotManagedByRunner["Encoded"], + _Error["DecodingServices"], + _Error["EncodingServices"] + > + > + | Rpc.Rpc< + `${Prefix}.${_Tag}Discard`, + Schema.Struct<{ + entityId: typeof Schema.String + payload: _Payload + }>, + typeof Schema.Void, + Schema.Union<[ + typeof MailboxFull, + typeof AlreadyProcessingMessage, + typeof PersistenceError, + typeof EntityNotManagedByRunner + ]> + > + : never + +const entityIdPath = Schema.Struct({ + entityId: Schema.String +}) + +/** + * Derives an `HttpApiGroup` from an `Entity`. + * + * ```ts + * import { ClusterSchema, Entity, EntityProxy, EntityProxyServer } from "effect/unstable/cluster" + * import { HttpApi, HttpApiBuilder } from "effect/unstable/httpapi" + * import { Rpc } from "effect/unstable/rpc" + * import { Schema } from "effect/schema" + * import { Layer } from "effect" + * + * export const Counter = Entity.make("Counter", [ + * Rpc.make("Increment", { + * payload: { id: Schema.String, amount: Schema.Number }, + * primaryKey: ({ id }) => id, + * success: Schema.Number + * }) + * ]).annotateRpcs(ClusterSchema.Persisted, true) + * + * // Use EntityProxy.toHttpApiGroup to create a `HttpApiGroup` from the + * // Counter entity + * export class MyApi extends HttpApi.make("api") + * .add( + * EntityProxy.toHttpApiGroup("counter", Counter) + * .prefix("/counter") + * ) + * {} + * + * // Use EntityProxyServer.layerHttpApi to create a layer that implements + * // the handlers for the HttpApiGroup + * const ApiLayer = HttpApiBuilder.layer(MyApi).pipe( + * Layer.provide(EntityProxyServer.layerHttpApi(MyApi, "counter", Counter)) + * ) + * ``` + * + * @since 4.0.0 + * @category Constructors + */ +export const toHttpApiGroup = ( + name: Name, + entity: Entity.Entity +): HttpApiGroup.HttpApiGroup> => { + let group = HttpApiGroup.make(name) + for (const parentRpc_ of entity.protocol.requests.values()) { + const parentRpc = parentRpc_ as any as Rpc.AnyWithProps + const endpoint = HttpApiEndpoint.post(parentRpc._tag, `/${tagToPath(parentRpc._tag)}/:entityId`) + .setPath(entityIdPath) + .setPayload(parentRpc.payloadSchema) + .addSuccess(parentRpc.successSchema) + .addError(Schema.Union([parentRpc.errorSchema, ...clientErrors])) + .annotateMerge(parentRpc.annotations) + const endpointDiscard = HttpApiEndpoint.post( + `${parentRpc._tag}Discard`, + `/${tagToPath(parentRpc._tag)}/:entityId/discard` + ) + .setPath(entityIdPath) + .setPayload(parentRpc.payloadSchema) + .addError(Schema.Union(clientErrors)) + .annotateMerge(parentRpc.annotations) + + group = group.add(endpoint).add(endpointDiscard) as any + } + return group as any as HttpApiGroup.HttpApiGroup> +} + +// TODO: type level equivalent +const tagToPath = (tag: string): string => + tag + // .replace(/[^a-zA-Z0-9]+/g, "-") // Replace non-alphanumeric characters with hyphen + // .replace(/([a-z])([A-Z])/g, "$1-$2") // Insert hyphen before uppercase letters + .toLowerCase() + +/** + * @since 4.0.0 + */ +export type ConvertHttpApi = Rpcs extends Rpc.Rpc< + infer _Tag, + infer _Payload, + infer _Success, + infer _Error, + infer _Middleware, + infer _Requires +> ? + | HttpApiEndpoint.HttpApiEndpoint< + _Tag, + "POST", + `/${Lowercase<_Tag>}/:entityId`, + Schema.Struct<{ entityId: typeof EntityId }>, + never, + _Payload, + never, + _Success, + | _Error + | typeof MailboxFull + | typeof AlreadyProcessingMessage + | typeof PersistenceError + | typeof EntityNotManagedByRunner + > + | HttpApiEndpoint.HttpApiEndpoint< + `${_Tag}Discard`, + "POST", + `/${Lowercase<_Tag>}/:entityId/discard`, + Schema.Struct<{ entityId: typeof EntityId }>, + never, + _Payload, + never, + Schema.Void, + typeof MailboxFull | typeof AlreadyProcessingMessage | typeof PersistenceError | typeof EntityNotManagedByRunner + > + : never diff --git a/packages/effect/src/unstable/cluster/EntityProxyServer.ts b/packages/effect/src/unstable/cluster/EntityProxyServer.ts new file mode 100644 index 0000000000..28930f2625 --- /dev/null +++ b/packages/effect/src/unstable/cluster/EntityProxyServer.ts @@ -0,0 +1,118 @@ +/** + * @since 4.0.0 + */ +import * as Effect from "../../Effect.ts" +import * as Layer from "../../Layer.ts" +import * as ServiceMap from "../../ServiceMap.ts" +import type * as HttpApi from "../httpapi/HttpApi.ts" +import * as HttpApiBuilder from "../httpapi/HttpApiBuilder.ts" +import type * as HttpApiGroup from "../httpapi/HttpApiGroup.ts" +import type * as Rpc from "../rpc/Rpc.ts" +import type * as Entity from "./Entity.ts" +import type { Sharding } from "./Sharding.ts" + +/** + * @since 4.0.0 + * @category Layers + */ +export const layerHttpApi = < + ApiId extends string, + Groups extends HttpApiGroup.Any, + Name extends HttpApiGroup.Name, + Type extends string, + Rpcs extends Rpc.Any +>( + api: HttpApi.HttpApi, + name: Name, + entity: Entity.Entity +): Layer.Layer, never, Sharding | Rpc.ServicesServer> => + HttpApiBuilder.group( + api, + name, + Effect.fnUntraced(function*(handlers_) { + const client = yield* entity.client + let handlers = handlers_ + for (const parentRpc_ of entity.protocol.requests.values()) { + const parentRpc = parentRpc_ as any as Rpc.AnyWithProps + handlers = handlers + .handle( + parentRpc._tag as any, + (({ path, payload }: { path: { entityId: string }; payload: any }) => + (client(path.entityId) as any as Record Effect.Effect>)[parentRpc._tag]( + payload + ).pipe( + Effect.tapDefect(Effect.logError), + Effect.annotateLogs({ + module: "EntityProxyServer", + entity: entity.type, + entityId: path.entityId, + method: parentRpc._tag + }) + )) as any + ) + .handle( + `${parentRpc._tag}Discard` as any, + (({ path, payload }: { path: { entityId: string }; payload: any }) => + (client(path.entityId) as any as Record Effect.Effect>)[parentRpc._tag]( + payload, + { discard: true } + ).pipe( + Effect.tapDefect(Effect.logError), + Effect.annotateLogs({ + module: "EntityProxyServer", + entity: entity.type, + entityId: path.entityId, + method: `${parentRpc._tag}Discard` + }) + )) as any + ) as any + } + return handlers as HttpApiBuilder.Handlers + }) + ) + +/** + * @since 4.0.0 + * @category Layers + */ +export const layerRpcHandlers = < + const Type extends string, + Rpcs extends Rpc.Any +>( + entity: Entity.Entity +): Layer.Layer, never, Sharding | Rpc.ServicesServer> => + Layer.effectServices(Effect.gen(function*() { + const services = yield* Effect.services() + const client = yield* entity.client + const handlers = new Map>() + for (const parentRpc_ of entity.protocol.requests.values()) { + const parentRpc = parentRpc_ as any as Rpc.AnyWithProps + const tag = `${entity.type}.${parentRpc._tag}` as const + const key = `effect/rpc/Rpc/${tag}` + handlers.set(key, { + services, + tag, + handler: ({ entityId, payload }: any) => (client(entityId) as any)[parentRpc._tag](payload) as any + } as any) + handlers.set(`${key}Discard`, { + services, + tag, + handler: ({ entityId, payload }: any) => + (client(entityId) as any)[parentRpc._tag](payload, { discard: true }) as any + } as any) + } + return ServiceMap.unsafeMake(handlers) + })) + +/** + * @since 4.0.0 + */ +export type RpcHandlers = Rpcs extends Rpc.Rpc< + infer _Tag, + infer _Payload, + infer _Success, + infer _Error, + infer _Middleware, + infer _Requires +> ? Rpc.Handler<`${Prefix}.${_Tag}`> | Rpc.Handler<`${Prefix}.${_Tag}Discard`> + : never diff --git a/packages/effect/src/unstable/cluster/EntityType.ts b/packages/effect/src/unstable/cluster/EntityType.ts new file mode 100644 index 0000000000..a0e7b5d809 --- /dev/null +++ b/packages/effect/src/unstable/cluster/EntityType.ts @@ -0,0 +1,22 @@ +/** + * @since 4.0.0 + */ +import * as Schema from "../../schema/Schema.ts" + +/** + * @since 4.0.0 + * @category constructors + */ +export const EntityType = Schema.String.pipe(Schema.brand("~effect/cluster/EntityType")) + +/** + * @since 4.0.0 + * @category models + */ +export type EntityType = typeof EntityType.Type + +/** + * @since 4.0.0 + * @category constructors + */ +export const make = (value: string): EntityType => value as EntityType diff --git a/packages/effect/src/unstable/cluster/Envelope.ts b/packages/effect/src/unstable/cluster/Envelope.ts new file mode 100644 index 0000000000..cc5055b201 --- /dev/null +++ b/packages/effect/src/unstable/cluster/Envelope.ts @@ -0,0 +1,334 @@ +/** + * @since 4.0.0 + */ +import * as Predicate from "../../data/Predicate.ts" +import type { ReadonlyRecord } from "../../data/Record.ts" +import * as PrimaryKey from "../../interfaces/PrimaryKey.ts" +import * as Schema from "../../schema/Schema.ts" +import * as Serializer from "../../schema/Serializer.ts" +import * as Transformation from "../../schema/Transformation.ts" +import * as Headers from "../http/Headers.ts" +import type * as Rpc from "../rpc/Rpc.ts" +import { EntityAddress } from "./EntityAddress.ts" +import { type Snowflake, SnowflakeFromBigInt } from "./Snowflake.ts" + +/** + * @since 4.0.0 + * @category type ids + */ +export const TypeId: TypeId = "~effect/cluster/Envelope" + +/** + * @since 4.0.0 + * @category type ids + */ +export type TypeId = "~effect/cluster/Envelope" + +/** + * @since 4.0.0 + * @category models + */ +export type Envelope = Request | AckChunk | Interrupt + +/** + * @since 4.0.0 + * @category models + */ +export type Encoded = PartialRequestEncoded | AckChunkEncoded | InterruptEncoded + +/** + * @since 4.0.0 + */ +export declare namespace Envelope { + /** + * @since 4.0.0 + * @category models + */ + export type Any = Envelope +} + +/** + * @since 4.0.0 + * @category models + */ +export interface Request { + readonly [TypeId]: TypeId + readonly _tag: "Request" + readonly requestId: Snowflake + readonly address: EntityAddress + readonly tag: Rpc.Tag + readonly payload: Rpc.Payload + readonly headers: Headers.Headers + readonly traceId?: string + readonly spanId?: string + readonly sampled?: boolean +} + +/** + * @since 4.0.0 + * @category models + */ +export class PartialRequest extends Schema.Opaque()(Schema.Struct({ + _tag: Schema.tag("Request"), + requestId: SnowflakeFromBigInt, + address: EntityAddress, + tag: Schema.String, + payload: Schema.Unknown, + headers: Headers.schema, + traceId: Schema.optional(Schema.String), + spanId: Schema.optional(Schema.String), + sampled: Schema.optional(Schema.Boolean) +})) {} + +/** + * @since 4.0.0 + * @category models + */ +export interface PartialRequestEncoded { + readonly _tag: "Request" + readonly requestId: string + readonly address: { + readonly shardId: { + readonly group: string + readonly id: number + } + readonly entityType: string + readonly entityId: string + } + readonly tag: string + readonly payload: unknown + readonly headers: ReadonlyRecord + readonly traceId?: string + readonly spanId?: string + readonly sampled?: boolean +} + +/** + * @since 4.0.0 + * @category models + */ +export class AckChunk extends Schema.Class("effect/cluster/Envelope/AckChunk")({ + _tag: Schema.tag("AckChunk"), + id: SnowflakeFromBigInt, + address: EntityAddress, + requestId: SnowflakeFromBigInt, + replyId: SnowflakeFromBigInt +}) { + /** + * @since 4.0.0 + */ + readonly [TypeId]: TypeId = TypeId + + /** + * @since 4.0.0 + */ + withRequestId(requestId: Snowflake): AckChunk { + return new AckChunk({ + ...this, + requestId + }) + } +} + +/** + * @since 4.0.0 + * @category models + */ +export interface AckChunkEncoded { + readonly _tag: "AckChunk" + readonly id: string + readonly address: { + readonly shardId: { + readonly group: string + readonly id: number + } + readonly entityType: string + readonly entityId: string + } + readonly requestId: string + readonly replyId: string +} + +/** + * @since 4.0.0 + * @category models + */ +export class Interrupt extends Schema.Class("effect/cluster/Envelope/Interrupt")({ + _tag: Schema.tag("Interrupt"), + id: SnowflakeFromBigInt, + address: EntityAddress, + requestId: SnowflakeFromBigInt +}) { + /** + * @since 4.0.0 + */ + readonly [TypeId]: TypeId = TypeId + + /** + * @since 4.0.0 + */ + withRequestId(requestId: Snowflake): Interrupt { + return new Interrupt({ + ...this, + requestId + }) + } +} + +/** + * @since 4.0.0 + * @category models + */ +export interface InterruptEncoded { + readonly _tag: "Interrupt" + readonly id: string + readonly address: { + readonly shardId: { + readonly group: string + readonly id: number + } + readonly entityType: string + readonly entityId: string + } + readonly requestId: string +} + +/** + * @since 4.0.0 + * @category schemas + */ +export const Partial: Schema.Union< + readonly [ + typeof PartialRequest, + typeof AckChunk, + typeof Interrupt + ] +> = Schema.Union([PartialRequest, AckChunk, Interrupt]) + +/** + * @since 4.0.0 + * @category schemas + */ +export type Partial = typeof Partial.Type + +/** + * @since 4.0.0 + * @category schemas + */ +export const PartialJson: Schema.Codec< + AckChunk | Interrupt | PartialRequest, + Encoded +> = Serializer.json(Partial) as any + +/** + * @since 4.0.0 + * @category schemas + */ +export const PartialArray: Schema.mutable< + Schema.Array$> +> = Schema.mutable(Schema.Array(PartialJson)) + +/** + * @since 4.0.0 + */ +export declare namespace Request { + /** + * @since 4.0.0 + * @category models + */ + export type Any = Request +} + +/** + * @since 4.0.0 + * @category refinements + */ +export const isEnvelope = (u: unknown): u is Envelope => Predicate.hasProperty(u, TypeId) + +/** + * @since 4.0.0 + * @category constructors + */ +export const makeRequest = ( + options: { + readonly requestId: Snowflake + readonly address: EntityAddress + readonly tag: Rpc.Tag + readonly payload: Rpc.Payload + readonly headers: Headers.Headers + readonly traceId?: string | undefined + readonly spanId?: string | undefined + readonly sampled?: boolean | undefined + } +): Request => ({ + [TypeId]: TypeId, + _tag: "Request", + requestId: options.requestId, + tag: options.tag, + address: options.address, + payload: options.payload, + headers: options.headers, + ...(options.traceId !== undefined ? + { + traceId: options.traceId!, + spanId: options.spanId!, + sampled: options.sampled! + } : + {}) +}) + +/** + * @since 4.0.0 + * @category serialization / deserialization + */ +export const Envelope: Schema.Codec = Schema.declare(isEnvelope, { + identifier: "Envelope" +}) + +/** + * @since 4.0.0 + * @category serialization / deserialization + */ +export const Request: Schema.Codec = Schema.declare( + (u): u is Request.Any => isEnvelope(u) && u._tag === "Request", + { identifier: "Request" } +) + +/** + * @since 4.0.0 + * @category serialization / deserialization + */ +export const RequestTransform: Transformation.Transformation< + Request.Any, + any +> = Transformation.transform({ + decode: (u: any) => makeRequest(u), + encode: (u) => u as any +}) + +/** + * @since 4.0.0 + * @category primary key + */ +export const primaryKey = (envelope: Envelope): string | null => { + if (envelope._tag !== "Request" || !PrimaryKey.isPrimaryKey(envelope.payload)) { + return null + } + return primaryKeyByAddress({ + address: envelope.address, + tag: envelope.tag, + id: PrimaryKey.value(envelope.payload) + }) +} + +/** + * @since 4.0.0 + * @category primary key + */ +export const primaryKeyByAddress = (options: { + readonly address: EntityAddress + readonly tag: string + readonly id: string +}): string => + // hash the entity address to save space? + `${options.address.entityType}/${options.address.entityId}/${options.tag}/${options.id}` diff --git a/packages/effect/src/unstable/cluster/HttpCommon.ts b/packages/effect/src/unstable/cluster/HttpCommon.ts new file mode 100644 index 0000000000..5300fd6e5d --- /dev/null +++ b/packages/effect/src/unstable/cluster/HttpCommon.ts @@ -0,0 +1,71 @@ +/** + * @since 4.0.0 + */ +import * as Effect from "../../Effect.ts" +import * as Layer from "../../Layer.ts" +import * as HttpClient from "../http/HttpClient.ts" +import * as HttpClientRequest from "../http/HttpClientRequest.ts" +import * as RpcClient from "../rpc/RpcClient.ts" +import * as RpcSerialization from "../rpc/RpcSerialization.ts" +import * as Socket from "../socket/Socket.ts" +import { RpcClientProtocol } from "./Runners.ts" + +/** + * @since 4.0.0 + * @category Layers + */ +export const layerClientProtocolHttp = (options: { + readonly path: string + readonly https?: boolean | undefined +}): Layer.Layer< + RpcClientProtocol, + never, + RpcSerialization.RpcSerialization | HttpClient.HttpClient +> => + Layer.effect(RpcClientProtocol)( + Effect.gen(function*() { + const serialization = yield* RpcSerialization.RpcSerialization + const client = yield* HttpClient.HttpClient + const https = options.https ?? false + return (address) => { + const clientWithUrl = HttpClient.mapRequest( + client, + HttpClientRequest.prependUrl(`http${https ? "s" : ""}://${address.host}:${address.port}/${options.path}`) + ) + return RpcClient.makeProtocolHttp(clientWithUrl).pipe( + Effect.provideService(RpcSerialization.RpcSerialization, serialization) + ) + } + }) + ) + +/** + * @since 4.0.0 + * @category Layers + */ +export const layerClientProtocolWebsocket = (options: { + readonly path: string + readonly https?: boolean | undefined +}): Layer.Layer< + RpcClientProtocol, + never, + RpcSerialization.RpcSerialization | Socket.WebSocketConstructor +> => + Layer.effect(RpcClientProtocol)( + Effect.gen(function*() { + const serialization = yield* RpcSerialization.RpcSerialization + const https = options.https ?? false + const constructor = yield* Socket.WebSocketConstructor + return Effect.fnUntraced(function*(address) { + const socket = yield* Socket.makeWebSocket( + `ws${https ? "s" : ""}://${address.host}:${address.port}/${options.path}` + ).pipe( + Effect.provideService(Socket.WebSocketConstructor, constructor) + ) + return yield* RpcClient.makeProtocolSocket().pipe( + Effect.provideService(Socket.Socket, socket), + Effect.provideService(RpcSerialization.RpcSerialization, serialization) + ) + }) + }) + ) diff --git a/packages/effect/src/unstable/cluster/HttpRunner.ts b/packages/effect/src/unstable/cluster/HttpRunner.ts new file mode 100644 index 0000000000..86bb21cfdc --- /dev/null +++ b/packages/effect/src/unstable/cluster/HttpRunner.ts @@ -0,0 +1,173 @@ +/** + * @since 4.0.0 + */ +import * as Effect from "../../Effect.ts" +import * as Layer from "../../Layer.ts" +import type { Scope } from "../../Scope.ts" +import type * as HttpClient from "../http/HttpClient.ts" +import * as HttpRouter from "../http/HttpRouter.ts" +import type * as HttpServer from "../http/HttpServer.ts" +import type { HttpServerRequest } from "../http/HttpServerRequest.ts" +import type { HttpServerResponse } from "../http/HttpServerResponse.ts" +import type * as RpcSerialization from "../rpc/RpcSerialization.ts" +import * as RpcServer from "../rpc/RpcServer.ts" +import type * as Socket from "../socket/Socket.ts" +import { layerClientProtocolHttp, layerClientProtocolWebsocket } from "./HttpCommon.ts" +import type { MessageStorage } from "./MessageStorage.ts" +import * as Runners from "./Runners.ts" +import * as RunnerServer from "./RunnerServer.ts" +import * as Sharding from "./Sharding.ts" +import type * as ShardingConfig from "./ShardingConfig.ts" +import * as ShardManager from "./ShardManager.ts" +import type { ShardStorage } from "./ShardStorage.ts" +import * as SynchronizedClock from "./SynchronizedClock.ts" + +/** + * @since 4.0.0 + * @category Http App + */ +export const toHttpEffect: Effect.Effect< + Effect.Effect, + never, + Scope | RpcSerialization.RpcSerialization | Sharding.Sharding | MessageStorage +> = Effect.gen(function*() { + const handlers = yield* Layer.build(RunnerServer.layerHandlers) + return yield* RpcServer.toHttpEffect(Runners.Rpcs, { + spanPrefix: "RunnerServer", + disableTracing: true + }).pipe(Effect.provideServices(handlers)) +}) + +/** + * @since 4.0.0 + * @category Http App + */ +export const toHttpEffectWebsocket: Effect.Effect< + Effect.Effect, + never, + Scope | RpcSerialization.RpcSerialization | Sharding.Sharding | MessageStorage +> = Effect.gen(function*() { + const handlers = yield* Layer.build(RunnerServer.layerHandlers) + return yield* RpcServer.toHttpEffectWebsocket(Runners.Rpcs, { + spanPrefix: "RunnerServer", + disableTracing: true + }).pipe(Effect.provideServices(handlers)) +}) + +/** + * @since 4.0.0 + * @category Layers + */ +export const layerClient: Layer.Layer< + Sharding.Sharding | Runners.Runners, + never, + ShardingConfig.ShardingConfig | Runners.RpcClientProtocol | MessageStorage | ShardStorage +> = Sharding.layer.pipe( + Layer.provideMerge(Runners.layerRpc), + Layer.provideMerge(SynchronizedClock.layer), + Layer.provide(ShardManager.layerClientRpc) +) + +/** + * A HTTP layer for the `Runners` services, that adds a route to the provided + * `HttpRouter`. + * + * @since 4.0.0 + * @category Layers + */ +export const layerHttpOptions = (options: { + readonly path: HttpRouter.PathInput +}): Layer.Layer< + Sharding.Sharding | Runners.Runners, + never, + | ShardStorage + | RpcSerialization.RpcSerialization + | MessageStorage + | ShardingConfig.ShardingConfig + | Runners.RpcClientProtocol + | HttpRouter.HttpRouter +> => + RunnerServer.layerWithClients.pipe( + Layer.provide(RpcServer.layerProtocolHttp(options)) + ) + +/** + * @since 4.0.0 + * @category Layers + */ +export const layerWebsocketOptions = (options: { + readonly path: HttpRouter.PathInput +}): Layer.Layer< + Sharding.Sharding | Runners.Runners, + never, + | ShardingConfig.ShardingConfig + | Runners.RpcClientProtocol + | MessageStorage + | ShardStorage + | RpcSerialization.RpcSerialization + | HttpRouter.HttpRouter +> => + RunnerServer.layerWithClients.pipe( + Layer.provide(RpcServer.layerProtocolWebsocket(options)) + ) + +/** + * @since 4.0.0 + * @category Layers + */ +export const layerHttp: Layer.Layer< + Sharding.Sharding | Runners.Runners, + never, + | RpcSerialization.RpcSerialization + | ShardingConfig.ShardingConfig + | HttpClient.HttpClient + | HttpServer.HttpServer + | MessageStorage + | ShardStorage +> = HttpRouter.serve(layerHttpOptions({ path: "/" })).pipe( + Layer.provide(layerClientProtocolHttp({ path: "/" })) +) + +/** + * @since 4.0.0 + * @category Layers + */ +export const layerHttpClientOnly: Layer.Layer< + Sharding.Sharding | Runners.Runners, + never, + | RpcSerialization.RpcSerialization + | ShardingConfig.ShardingConfig + | HttpClient.HttpClient + | MessageStorage +> = RunnerServer.layerClientOnly.pipe( + Layer.provide(layerClientProtocolHttp({ path: "/" })) +) + +/** + * @since 4.0.0 + * @category Layers + */ +export const layerWebsocket: Layer.Layer< + Sharding.Sharding | Runners.Runners, + never, + | RpcSerialization.RpcSerialization + | ShardingConfig.ShardingConfig + | Socket.WebSocketConstructor + | HttpServer.HttpServer + | MessageStorage + | ShardStorage +> = HttpRouter.serve(layerWebsocketOptions({ path: "/" })).pipe( + Layer.provide(layerClientProtocolWebsocket({ path: "/" })) +) + +/** + * @since 4.0.0 + * @category Layers + */ +export const layerWebsocketClientOnly: Layer.Layer< + Sharding.Sharding | Runners.Runners, + never, + ShardingConfig.ShardingConfig | MessageStorage | RpcSerialization.RpcSerialization | Socket.WebSocketConstructor +> = RunnerServer.layerClientOnly.pipe( + Layer.provide(layerClientProtocolWebsocket({ path: "/" })) +) diff --git a/packages/effect/src/unstable/cluster/HttpShardManager.ts b/packages/effect/src/unstable/cluster/HttpShardManager.ts new file mode 100644 index 0000000000..cb82f45263 --- /dev/null +++ b/packages/effect/src/unstable/cluster/HttpShardManager.ts @@ -0,0 +1,249 @@ +/** + * @since 4.0.0 + */ +import * as Effect from "../../Effect.ts" +import * as Layer from "../../Layer.ts" +import type { Scope } from "../../Scope.ts" +import type * as HttpClient from "../http/HttpClient.ts" +import * as HttpRouter from "../http/HttpRouter.ts" +import type * as HttpServer from "../http/HttpServer.ts" +import type { HttpServerRequest } from "../http/HttpServerRequest.ts" +import type { HttpServerResponse } from "../http/HttpServerResponse.ts" +import type * as RpcSerialization from "../rpc/RpcSerialization.ts" +import * as RpcServer from "../rpc/RpcServer.ts" +import type * as Socket from "../socket/Socket.ts" +import { layerClientProtocolHttp, layerClientProtocolWebsocket } from "./HttpCommon.ts" +import * as MessageStorage from "./MessageStorage.ts" +import * as RunnerHealth from "./RunnerHealth.ts" +import * as Runners from "./Runners.ts" +import type { ShardingConfig } from "./ShardingConfig.ts" +import * as ShardManager from "./ShardManager.ts" +import type { ShardStorage } from "./ShardStorage.ts" + +/** + * @since 4.0.0 + * @category Http App + */ +export const toHttpEffect: Effect.Effect< + Effect.Effect, + never, + Scope | RpcSerialization.RpcSerialization | ShardManager.ShardManager +> = Effect.gen(function*() { + const handlers = yield* Layer.build(ShardManager.layerServerHandlers) + return yield* RpcServer.toHttpEffect(ShardManager.Rpcs).pipe( + Effect.provideServices(handlers) + ) +}) + +/** + * @since 4.0.0 + * @category Http App + */ +export const toHttpAppWebsocket: Effect.Effect< + Effect.Effect, + never, + Scope | RpcSerialization.RpcSerialization | ShardManager.ShardManager +> = Effect.gen(function*() { + const handlers = yield* Layer.build(ShardManager.layerServerHandlers) + return yield* RpcServer.toHttpEffectWebsocket(ShardManager.Rpcs).pipe( + Effect.provideServices(handlers) + ) +}) + +/** + * A layer for the `ShardManager` service, that does not run a server. + * + * It only provides the `Runners` rpc client. + * + * You can use this with the `toHttpEffect` and `toHttpEffectWebsocket` apis + * to run a complete `ShardManager` server. + * + * @since 4.0.0 + * @category Layers + */ +export const layerNoServerHttp = ( + options: { + readonly runnerPath: string + readonly runnerHttps?: boolean | undefined + } +): Layer.Layer< + ShardManager.ShardManager, + never, + | RpcSerialization.RpcSerialization + | ShardStorage + | RunnerHealth.RunnerHealth + | HttpClient.HttpClient + | ShardManager.Config + | ShardingConfig +> => + ShardManager.layer.pipe( + Layer.provide(Runners.layerRpc.pipe( + Layer.provide([ + layerClientProtocolHttp({ + path: options.runnerPath, + https: options.runnerHttps + }), + MessageStorage.layerNoop + ]) + )) + ) + +/** + * A layer for the `ShardManager` service, that does not run a server. + * + * It only provides the `Runners` rpc client. + * + * You can use this with the `toHttpEffect` and `toHttpEffectWebsocket` apis + * to run a complete `ShardManager` server. + * + * @since 4.0.0 + * @category Layers + */ +export const layerNoServerWebsocket = ( + options: { + readonly runnerPath: string + readonly runnerHttps?: boolean | undefined + } +): Layer.Layer< + ShardManager.ShardManager, + never, + | RpcSerialization.RpcSerialization + | ShardStorage + | RunnerHealth.RunnerHealth + | Socket.WebSocketConstructor + | ShardManager.Config + | ShardingConfig +> => + ShardManager.layer.pipe( + Layer.provide(Runners.layerRpc.pipe( + Layer.provide([ + layerClientProtocolWebsocket({ + path: options.runnerPath, + https: options.runnerHttps + }), + MessageStorage.layerNoop + ]) + )) + ) + +/** + * A HTTP layer for the `ShardManager` server, that adds a route to the provided + * `HttpRouter`. + * + * @since 4.0.0 + * @category Layers + */ +export const layerHttpOptions = ( + options: { + readonly path: HttpRouter.PathInput + readonly runnerPath: string + readonly runnerHttps?: boolean | undefined + } +): Layer.Layer< + ShardManager.ShardManager, + never, + | RpcSerialization.RpcSerialization + | ShardStorage + | RunnerHealth.RunnerHealth + | HttpClient.HttpClient + | ShardManager.Config + | ShardingConfig + | HttpRouter.HttpRouter +> => + ShardManager.layerServer.pipe( + Layer.provide(RpcServer.layerProtocolHttp(options)), + Layer.provideMerge(layerNoServerHttp(options)) + ) + +/** + * A WebSocket layer for the `ShardManager` server, that adds a route to the provided + * `HttpRouter.Tag`. + * + * By default, it uses the `HttpRouter.Default` tag. + * + * @since 4.0.0 + * @category Layers + */ +export const layerWebsocketOptions = ( + options: { + readonly path: HttpRouter.PathInput + readonly runnerPath: string + readonly runnerHttps?: boolean | undefined + } +): Layer.Layer< + ShardManager.ShardManager, + never, + | RpcSerialization.RpcSerialization + | HttpRouter.HttpRouter + | ShardStorage + | RunnerHealth.RunnerHealth + | Socket.WebSocketConstructor + | ShardManager.Config + | ShardingConfig +> => + ShardManager.layerServer.pipe( + Layer.provide(RpcServer.layerProtocolWebsocket(options)), + Layer.provideMerge(layerNoServerWebsocket(options)) + ) + +/** + * A HTTP layer for the `ShardManager` server, that adds a route to the provided + * `HttpRouter.Tag`. + * + * By default, it uses the `HttpRouter.Default` tag. + * + * @since 4.0.0 + * @category Layers + */ +export const layerHttp: Layer.Layer< + ShardManager.ShardManager, + never, + | RpcSerialization.RpcSerialization + | ShardStorage + | RunnerHealth.RunnerHealth + | HttpClient.HttpClient + | HttpServer.HttpServer + | ShardManager.Config + | ShardingConfig +> = HttpRouter.serve(layerHttpOptions({ path: "/", runnerPath: "/" })) + +/** + * A Websocket layer for the `ShardManager` server, that adds a route to the provided + * `HttpRouter.Tag`. + * + * By default, it uses the `HttpRouter.Default` tag. + * + * @since 4.0.0 + * @category Layers + */ +export const layerWebsocket: Layer.Layer< + ShardManager.ShardManager, + never, + | RpcSerialization.RpcSerialization + | ShardStorage + | RunnerHealth.RunnerHealth + | Socket.WebSocketConstructor + | HttpServer.HttpServer + | ShardManager.Config + | ShardingConfig +> = HttpRouter.serve(layerWebsocketOptions({ path: "/", runnerPath: "/" })) + +/** + * @since 4.0.0 + * @category Layers + */ +export const layerRunnerHealthHttp: Layer.Layer< + RunnerHealth.RunnerHealth, + never, + RpcSerialization.RpcSerialization | HttpClient.HttpClient | ShardingConfig +> = Layer.provide(RunnerHealth.layerRpc, layerClientProtocolHttp({ path: "/" })) + +/** + * @since 4.0.0 + * @category Layers + */ +export const layerRunnerHealthWebsocket: Layer.Layer< + RunnerHealth.RunnerHealth, + never, + RpcSerialization.RpcSerialization | Socket.WebSocketConstructor | ShardingConfig +> = Layer.provide(RunnerHealth.layerRpc, layerClientProtocolWebsocket({ path: "/" })) diff --git a/packages/effect/src/unstable/cluster/MachineId.ts b/packages/effect/src/unstable/cluster/MachineId.ts new file mode 100644 index 0000000000..01cf49cea4 --- /dev/null +++ b/packages/effect/src/unstable/cluster/MachineId.ts @@ -0,0 +1,28 @@ +/** + * @since 4.0.0 + */ +import * as Schema from "../../schema/Schema.ts" + +/** + * @since 4.0.0 + * @category constructors + */ +export const MachineId = Schema.Int.pipe( + Schema.brand("~effect/cluster/MachineId") + // TODO: override pretty + // Schema.annotations({ + // pretty: () => (machineId) => `MachineId(${machineId})` + // }) +) + +/** + * @since 4.0.0 + * @category models + */ +export type MachineId = typeof MachineId.Type + +/** + * @since 4.0.0 + * @category Constructors + */ +export const make = (id: number): MachineId => id as MachineId diff --git a/packages/effect/src/unstable/cluster/Message.ts b/packages/effect/src/unstable/cluster/Message.ts new file mode 100644 index 0000000000..03fa4ff780 --- /dev/null +++ b/packages/effect/src/unstable/cluster/Message.ts @@ -0,0 +1,206 @@ +/** + * @since 4.0.0 + */ +import * as Data from "../../data/Data.ts" +import * as Option from "../../data/Option.ts" +import * as Effect from "../../Effect.ts" +import * as Schema from "../../schema/Schema.ts" +import * as Serializer from "../../schema/Serializer.ts" +import type { ServiceMap } from "../../ServiceMap.ts" +import * as Rpc from "../rpc/Rpc.ts" +import type { PersistenceError } from "./ClusterError.ts" +import { MalformedMessage } from "./ClusterError.ts" +import type { EntityAddress } from "./EntityAddress.ts" +import * as Envelope from "./Envelope.ts" +import type * as Reply from "./Reply.ts" +import type { Snowflake } from "./Snowflake.ts" + +/** + * @since 4.0.0 + * @category incoming + */ +export type Incoming = IncomingRequest | IncomingEnvelope + +/** + * @since 4.0.0 + * @category incoming + */ +export type IncomingLocal = IncomingRequestLocal | IncomingEnvelope + +/** + * @since 4.0.0 + * @category incoming + */ +export const incomingLocalFromOutgoing = (self: Outgoing): IncomingLocal => { + if (self._tag === "OutgoingEnvelope") { + return new IncomingEnvelope({ envelope: self.envelope }) + } + return new IncomingRequestLocal({ + envelope: self.envelope, + respond: self.respond, + lastSentReply: Option.none() + }) +} + +/** + * @since 4.0.0 + * @category incoming + */ +export class IncomingRequest extends Data.TaggedClass("IncomingRequest")<{ + readonly envelope: Envelope.PartialRequest + readonly lastSentReply: Option.Option + readonly respond: (reply: Reply.ReplyWithContext) => Effect.Effect +}> {} + +/** + * @since 4.0.0 + * @category outgoing + */ +export class IncomingRequestLocal extends Data.TaggedClass("IncomingRequestLocal")<{ + readonly envelope: Envelope.Request + readonly lastSentReply: Option.Option> + readonly respond: (reply: Reply.Reply) => Effect.Effect +}> {} + +/** + * @since 4.0.0 + * @category incoming + */ +export class IncomingEnvelope extends Data.TaggedClass("IncomingEnvelope")<{ + readonly _tag: "IncomingEnvelope" + readonly envelope: Envelope.AckChunk | Envelope.Interrupt +}> {} + +/** + * @since 4.0.0 + * @category outgoing + */ +export type Outgoing = OutgoingRequest | OutgoingEnvelope + +/** + * @since 4.0.0 + * @category outgoing + */ +export class OutgoingRequest extends Data.TaggedClass("OutgoingRequest")<{ + readonly envelope: Envelope.Request + readonly services: ServiceMap> + readonly lastReceivedReply: Option.Option> + readonly rpc: R + readonly respond: (reply: Reply.Reply) => Effect.Effect +}> { + /** + * @since 4.0.0 + */ + public encodedCache?: Envelope.PartialRequest +} + +/** + * @since 4.0.0 + * @category outgoing + */ +export class OutgoingEnvelope extends Data.TaggedClass("OutgoingEnvelope")<{ + readonly envelope: Envelope.AckChunk | Envelope.Interrupt + readonly rpc: Rpc.AnyWithProps +}> { + /** + * @since 4.0.0 + */ + static interrupt(options: { + readonly address: EntityAddress + readonly id: Snowflake + readonly requestId: Snowflake + }): OutgoingEnvelope { + return new OutgoingEnvelope({ + envelope: new Envelope.Interrupt(options), + rpc: neverRpc + }) + } +} + +const neverRpc = Rpc.make("Never", { + success: Schema.Never as any, + error: Schema.Never, + payload: {} +}) + +/** + * @since 4.0.0 + * @category serialization / deserialization + */ +export const serialize = ( + message: Outgoing +): Effect.Effect => { + if (message._tag !== "OutgoingRequest") { + return Effect.succeed(message.envelope) + } + return Effect.suspend(() => + message.encodedCache + ? Effect.succeed(message.encodedCache) + : serializeRequest(message) + ) +} + +/** + * @since 4.0.0 + * @category serialization / deserialization + */ +export const serializeEnvelope = ( + message: Outgoing +): Effect.Effect => + Effect.flatMap( + serialize(message), + (envelope) => MalformedMessage.refail(Schema.encodeEffect(Envelope.PartialJson)(envelope)) + ) + +/** + * @since 4.0.0 + * @category serialization / deserialization + */ +export const serializeRequest = ( + self: OutgoingRequest +): Effect.Effect => { + const rpc = self.rpc as any as Rpc.AnyWithProps + return Schema.encodeEffect(Serializer.json(rpc.payloadSchema))(self.envelope.payload).pipe( + Effect.provideServices(self.services), + MalformedMessage.refail, + Effect.map((payload) => ({ + ...self.envelope, + payload + })) + ) as any as Effect.Effect +} + +/** + * @since 4.0.0 + * @category serialization / deserialization + */ +export const deserializeLocal = ( + self: Outgoing, + encoded: Envelope.Partial +): Effect.Effect< + IncomingLocal, + MalformedMessage +> => { + if (encoded._tag !== "Request") { + return Effect.succeed(new IncomingEnvelope({ envelope: encoded })) + } else if (self._tag !== "OutgoingRequest") { + return Effect.fail( + new MalformedMessage({ cause: new Error("Can only deserialize a Request with an OutgoingRequest message") }) + ) + } + const rpc = self.rpc as any as Rpc.AnyWithProps + return Schema.decodeEffect(Serializer.json(rpc.payloadSchema))(encoded.payload).pipe( + Effect.provideServices(self.services), + MalformedMessage.refail, + Effect.map((payload) => + new IncomingRequestLocal({ + envelope: Envelope.makeRequest({ + ...encoded, + payload + } as any), + lastSentReply: Option.none(), + respond: self.respond + }) + ) + ) as Effect.Effect, MalformedMessage> +} diff --git a/packages/effect/src/unstable/cluster/MessageStorage.ts b/packages/effect/src/unstable/cluster/MessageStorage.ts new file mode 100644 index 0000000000..a62e47fa84 --- /dev/null +++ b/packages/effect/src/unstable/cluster/MessageStorage.ts @@ -0,0 +1,834 @@ +/** + * @since 4.0.0 + */ +import * as Arr from "../../collections/Array.ts" +import * as Data from "../../data/Data.ts" +import * as Option from "../../data/Option.ts" +import type { Predicate } from "../../data/Predicate.ts" +import * as Effect from "../../Effect.ts" +import * as Exit from "../../Exit.ts" +import * as Layer from "../../Layer.ts" +import { Serializer } from "../../schema/index.ts" +import * as Schema from "../../schema/Schema.ts" +import * as ServiceMap from "../../ServiceMap.ts" +import { Clock } from "../../time/Clock.ts" +import type * as Rpc from "../rpc/Rpc.ts" +import type { PersistenceError } from "./ClusterError.ts" +import { MalformedMessage } from "./ClusterError.ts" +import * as DeliverAt from "./DeliverAt.ts" +import type { EntityAddress } from "./EntityAddress.ts" +import * as Envelope from "./Envelope.ts" +import * as Message from "./Message.ts" +import * as Reply from "./Reply.ts" +import { ShardId } from "./ShardId.ts" +import type { ShardingConfig } from "./ShardingConfig.ts" +import * as Snowflake from "./Snowflake.ts" + +/** + * @since 4.0.0 + * @category context + */ +export class MessageStorage extends ServiceMap.Key( + envelope: Message.OutgoingRequest + ) => Effect.Effect, PersistenceError | MalformedMessage> + + /** + * Save the provided message and its associated metadata. + */ + readonly saveEnvelope: ( + envelope: Message.OutgoingEnvelope + ) => Effect.Effect + + /** + * Save the provided `Reply` and its associated metadata. + */ + readonly saveReply: ( + reply: Reply.ReplyWithContext + ) => Effect.Effect + + /** + * Clear the `Reply`s for the given request id. + */ + readonly clearReplies: (requestId: Snowflake.Snowflake) => Effect.Effect + + /** + * Retrieves the replies for the specified requests. + * + * - Un-acknowledged chunk replies + * - WithExit replies + */ + readonly repliesFor: ( + requests: Iterable> + ) => Effect.Effect>, PersistenceError | MalformedMessage> + + /** + * Retrieves the encoded replies for the specified request ids. + */ + readonly repliesForUnfiltered: ( + requestIds: Iterable + ) => Effect.Effect, PersistenceError | MalformedMessage> + + /** + * Retrieves the request id for the specified primary key. + */ + readonly requestIdForPrimaryKey: ( + options: { + readonly address: EntityAddress + readonly tag: string + readonly id: string + } + ) => Effect.Effect, PersistenceError> + + /** + * For locally sent messages, register a handler to process the replies. + */ + readonly registerReplyHandler: ( + message: Message.OutgoingRequest | Message.IncomingRequest + ) => Effect.Effect + + /** + * Retrieves the unprocessed messages for the specified shards. + * + * A message is unprocessed when: + * + * - Requests that have no WithExit replies + * - Or they have no unacknowledged chunk replies + * - The latest AckChunk envelope + * - All Interrupt's for unprocessed requests + */ + readonly unprocessedMessages: ( + shardIds: Iterable + ) => Effect.Effect>, PersistenceError> + + /** + * Retrieves the unprocessed messages by id. + */ + readonly unprocessedMessagesById: ( + messageIds: Iterable + ) => Effect.Effect>, PersistenceError> + + /** + * Reset the mailbox state for the provided shards. + */ + readonly resetShards: ( + shardIds: Iterable + ) => Effect.Effect + + /** + * Reset the mailbox state for the provided address. + */ + readonly resetAddress: ( + address: EntityAddress + ) => Effect.Effect + + /** + * Clear all messages and replies for the provided address. + */ + readonly clearAddress: ( + address: EntityAddress + ) => Effect.Effect +}>()("effect/cluster/MessageStorage") {} + +/** + * @since 4.0.0 + * @category SaveResult + */ +export type SaveResult = SaveResult.Success | SaveResult.Duplicate + +/** + * @since 4.0.0 + * @category SaveResult + */ +export const SaveResult = Data.taggedEnum() + +/** + * @since 4.0.0 + * @category SaveResult + */ +export const SaveResultEncoded = Data.taggedEnum() + +/** + * @since 4.0.0 + * @category SaveResult + */ +export declare namespace SaveResult { + /** + * @since 4.0.0 + * @category SaveResult + */ + export type Encoded = SaveResult.Success | SaveResult.DuplicateEncoded + + /** + * @since 4.0.0 + * @category SaveResult + */ + export interface Success { + readonly _tag: "Success" + } + + /** + * @since 4.0.0 + * @category SaveResult + */ + export interface Duplicate { + readonly _tag: "Duplicate" + readonly originalId: Snowflake.Snowflake + readonly lastReceivedReply: Option.Option> + } + + /** + * @since 4.0.0 + * @category SaveResult + */ + export interface DuplicateEncoded { + readonly _tag: "Duplicate" + readonly originalId: Snowflake.Snowflake + readonly lastReceivedReply: Option.Option + } + + /** + * @since 4.0.0 + * @category SaveResult + */ + export interface Constructor extends Data.TaggedEnum.WithGenerics<1> { + readonly taggedEnum: SaveResult + } +} + +/** + * @since 4.0.0 + * @category Encoded + */ +export type Encoded = { + /** + * Save the provided message and its associated metadata. + */ + readonly saveEnvelope: ( + options: { + readonly envelope: Envelope.Encoded + readonly primaryKey: string | null + readonly deliverAt: number | null + } + ) => Effect.Effect + + /** + * Save the provided `Reply` and its associated metadata. + */ + readonly saveReply: (reply: Reply.Encoded) => Effect.Effect + + /** + * Remove the replies for the specified request. + */ + readonly clearReplies: (requestId: Snowflake.Snowflake) => Effect.Effect + + /** + * Retrieves the request id for the specified primary key. + */ + readonly requestIdForPrimaryKey: ( + primaryKey: string + ) => Effect.Effect, PersistenceError> + + /** + * Retrieves the replies for the specified requests. + * + * - Un-acknowledged chunk replies + * - WithExit replies + */ + readonly repliesFor: (requestIds: Array) => Effect.Effect< + Array, + PersistenceError + > + + /** + * Retrieves the replies for the specified request ids. + */ + readonly repliesForUnfiltered: (requestIds: Array) => Effect.Effect< + Array, + PersistenceError + > + + /** + * Retrieves the unprocessed messages for the given shards. + * + * A message is unprocessed when: + * + * - Requests that have no WithExit replies + * - Or they have no unacknowledged chunk replies + * - The latest AckChunk envelope + * - All Interrupt's for unprocessed requests + */ + readonly unprocessedMessages: ( + shardIds: ReadonlyArray, + now: number + ) => Effect.Effect< + Array<{ + readonly envelope: Envelope.Encoded + readonly lastSentReply: Option.Option + }>, + PersistenceError + > + + /** + * Retrieves the unprocessed messages by id. + */ + readonly unprocessedMessagesById: ( + messageIds: ReadonlyArray, + now: number + ) => Effect.Effect< + Array<{ + readonly envelope: Envelope.Encoded + readonly lastSentReply: Option.Option + }>, + PersistenceError + > + + /** + * Reset the mailbox state for the provided address. + */ + readonly resetAddress: ( + address: EntityAddress + ) => Effect.Effect + + /** + * Clear all messages and replies for the provided address. + */ + readonly clearAddress: ( + address: EntityAddress + ) => Effect.Effect + + /** + * Reset the mailbox state for the provided shards. + */ + readonly resetShards: ( + shardIds: ReadonlyArray + ) => Effect.Effect +} + +/** + * @since 4.0.0 + * @category Encoded + */ +export type EncodedUnprocessedOptions = { + readonly existingShards: Array + readonly newShards: Array + readonly cursor: Option.Option +} + +/** + * @since 4.0.0 + * @category Encoded + */ +export type EncodedRepliesOptions = { + readonly existingRequests: Array + readonly newRequests: Array + readonly cursor: Option.Option +} + +/** + * @since 4.0.0 + * @category constructors + */ +export const make = ( + storage: Omit +): Effect.Effect => + Effect.sync(() => { + const replyHandlers = new Map< + Snowflake.Snowflake, + (reply: Reply.ReplyWithContext) => Effect.Effect + >() + return MessageStorage.of({ + ...storage, + registerReplyHandler: (message) => + Effect.sync(() => { + replyHandlers.set( + message.envelope.requestId, + message._tag === "IncomingRequest" ? message.respond : (reply) => message.respond(reply.reply) + ) + }), + saveReply(reply) { + return Effect.flatMap(storage.saveReply(reply), () => { + const handler = replyHandlers.get(reply.reply.requestId) + if (!handler) { + return Effect.void + } else if (reply.reply._tag === "WithExit") { + replyHandlers.delete(reply.reply.requestId) + } + return handler(reply) + }) + } + }) + }) + +/** + * @since 4.0.0 + * @category constructors + */ +export const makeEncoded: (encoded: Encoded) => Effect.Effect< + MessageStorage["Service"], + never, + Snowflake.Generator +> = Effect.fnUntraced(function*(encoded: Encoded) { + const snowflakeGen = yield* Snowflake.Generator + const clock = yield* Clock + + const storage: MessageStorage["Service"] = yield* make({ + saveRequest: (message) => + Message.serializeEnvelope(message).pipe( + Effect.flatMap((envelope) => + encoded.saveEnvelope({ + envelope, + primaryKey: Envelope.primaryKey(message.envelope), + deliverAt: DeliverAt.toMillis(message.envelope.payload) + }) + ), + Effect.flatMap((result) => { + if (result._tag === "Success" || result.lastReceivedReply._tag === "None") { + return Effect.succeed(result as SaveResult) + } + const duplicate = result + const schema = Reply.Reply(message.rpc) + return Schema.decodeEffect(schema)(result.lastReceivedReply.value).pipe( + Effect.provideServices(message.services), + MalformedMessage.refail, + Effect.map((reply) => + SaveResult.Duplicate({ + originalId: duplicate.originalId, + lastReceivedReply: Option.some(reply) + }) + ) + ) + }) + ), + saveEnvelope: (message) => + Message.serializeEnvelope(message).pipe( + Effect.flatMap((envelope) => + encoded.saveEnvelope({ + envelope, + primaryKey: null, + deliverAt: null + }) + ), + Effect.asVoid + ), + saveReply: (reply) => Effect.flatMap(Reply.serialize(reply), encoded.saveReply), + clearReplies: encoded.clearReplies, + repliesFor: Effect.fnUntraced(function*(messages) { + const requestIds = Arr.empty() + const map = new Map>() + for (const message of messages) { + const id = String(message.envelope.requestId) + requestIds.push(id) + map.set(id, message) + } + if (requestIds.length === 0) return [] + const encodedReplies = yield* encoded.repliesFor(requestIds) + return yield* decodeReplies(map, encodedReplies) + }), + repliesForUnfiltered: (ids) => encoded.repliesForUnfiltered(Array.from(ids, String)), + requestIdForPrimaryKey(options) { + const primaryKey = Envelope.primaryKeyByAddress(options) + return encoded.requestIdForPrimaryKey(primaryKey) + }, + unprocessedMessages: (shardIds) => { + const shards = Array.from(shardIds) + if (shards.length === 0) return Effect.succeed([]) + return Effect.flatMap( + Effect.suspend(() => + encoded.unprocessedMessages(shards.map((id) => id.toString()), clock.unsafeCurrentTimeMillis()) + ), + decodeMessages + ) + }, + unprocessedMessagesById(messageIds) { + const ids = Array.from(messageIds) + if (ids.length === 0) return Effect.succeed([]) + return Effect.flatMap( + Effect.suspend(() => encoded.unprocessedMessagesById(ids, clock.unsafeCurrentTimeMillis())), + decodeMessages + ) + }, + resetAddress: encoded.resetAddress, + clearAddress: encoded.clearAddress, + resetShards: (shardIds) => encoded.resetShards(Array.from(shardIds, (id) => id.toString())) + }) + + const decodeMessages = ( + envelopes: Array<{ + readonly envelope: Envelope.Encoded + readonly lastSentReply: Option.Option + }> + ) => { + const messages: Array> = [] + let index = 0 + + // if we have a malformed message, we should not return it and update + // the storage with a defect + const decodeMessage = Effect.catch( + Effect.suspend(() => { + const envelope = envelopes[index] + if (!envelope) return Effect.succeed(undefined) + return decodeEnvelopeWithReply(envelope) + }), + (error) => { + const envelope = envelopes[index] + return storage.saveReply(Reply.ReplyWithContext.fromDefect({ + id: snowflakeGen.unsafeNext(), + requestId: Snowflake.Snowflake(envelope.envelope.requestId), + defect: error.toString() + })).pipe( + Effect.forkDaemon, + Effect.asVoid + ) + } + ) + return Effect.as( + Effect.whileLoop({ + while: () => index < envelopes.length, + body: () => decodeMessage, + step: (message) => { + const envelope = envelopes[index++] + if (!message) return + messages.push( + message.envelope._tag === "Request" + ? new Message.IncomingRequest({ + envelope: message.envelope, + lastSentReply: envelope.lastSentReply, + respond: storage.saveReply + }) + : new Message.IncomingEnvelope({ + envelope: message.envelope + }) + ) + } + }), + messages + ) + } + + const decodeReplies = ( + messages: Map>, + encodedReplies: Array + ) => { + const replies: Array> = [] + const ignoredRequests = new Set() + let index = 0 + + const decodeReply: Effect.Effect> = Effect.catch( + Effect.suspend(() => { + const reply = encodedReplies[index] + if (ignoredRequests.has(reply.requestId)) return Effect.void + const message = messages.get(reply.requestId) + if (!message) return Effect.void + const schema = Reply.Reply(message.rpc) + return Schema.decodeEffect(schema)(reply).pipe( + Effect.provideServices(message.services) + ) as Effect.Effect, Schema.SchemaError> + }), + (error) => { + const reply = encodedReplies[index] + ignoredRequests.add(reply.requestId) + return Effect.succeed( + new Reply.WithExit({ + id: snowflakeGen.unsafeNext(), + requestId: Snowflake.Snowflake(reply.requestId), + exit: Exit.die(error) + }) + ) + } + ) + + return Effect.as( + Effect.whileLoop({ + while: () => index < encodedReplies.length, + body: () => decodeReply, + step: (reply) => { + index++ + if (reply) replies.push(reply) + } + }), + replies + ) + } + + return storage +}) + +/** + * @since 4.0.0 + * @category Constructors + */ +export const noop: MessageStorage["Service"] = Effect.runSync(make({ + saveRequest: () => Effect.succeed(SaveResult.Success()), + saveEnvelope: () => Effect.void, + saveReply: () => Effect.void, + clearReplies: () => Effect.void, + repliesFor: () => Effect.succeed([]), + repliesForUnfiltered: () => Effect.succeed([]), + requestIdForPrimaryKey: () => Effect.succeedNone, + unprocessedMessages: () => Effect.succeed([]), + unprocessedMessagesById: () => Effect.succeed([]), + resetAddress: () => Effect.void, + clearAddress: () => Effect.void, + resetShards: () => Effect.void +})) + +/** + * @since 4.0.0 + * @category Memory + */ +export type MemoryEntry = { + readonly envelope: Envelope.Encoded + lastReceivedChunk: Option.Option + replies: Array + deliverAt: number | null +} + +/** + * @since 4.0.0 + * @category Memory + */ +export class MemoryDriver extends ServiceMap.Key()("effect/cluster/MessageStorage/MemoryDriver", { + make: Effect.gen(function*() { + const clock = yield* Clock + const requests = new Map() + const requestsByPrimaryKey = new Map() + const unprocessed = new Set() + const replyIds = new Set() + + const journal: Array = [] + + const cursors = new WeakMap<{}, number>() + + const unprocessedWith = (predicate: Predicate) => { + const messages: Array<{ + readonly envelope: Envelope.Encoded + readonly lastSentReply: Option.Option + }> = [] + const now = clock.unsafeCurrentTimeMillis() + for (const envelope of unprocessed) { + if (!predicate(envelope)) { + continue + } + if (envelope._tag === "Request") { + const entry = requests.get(envelope.requestId) + if (entry?.deliverAt && entry.deliverAt > now) { + continue + } + messages.push({ + envelope, + lastSentReply: Option.fromNullishOr(entry?.replies[entry.replies.length - 1]) + }) + } else { + messages.push({ + envelope, + lastSentReply: Option.none() + }) + } + } + return messages + } + + const replyLatch = yield* Effect.makeLatch() + + function repliesFor(requestIds: Array) { + const replies = Arr.empty() + for (const requestId of requestIds) { + const request = requests.get(requestId) + if (!request) continue + else if (Option.isNone(request.lastReceivedChunk)) { + // eslint-disable-next-line no-restricted-syntax + replies.push(...request.replies) + continue + } + const sequence = request.lastReceivedChunk.value.sequence + for (const reply of request.replies) { + if (reply._tag === "Chunk" && reply.sequence <= sequence) { + continue + } + replies.push(reply) + } + } + return replies + } + + const encoded: Encoded = { + saveEnvelope: ({ deliverAt, envelope: envelope_, primaryKey }) => + Effect.sync(() => { + const envelope = JSON.parse(JSON.stringify(envelope_)) as Envelope.Encoded + const existing = primaryKey + ? requestsByPrimaryKey.get(primaryKey) + : envelope._tag === "Request" && requests.get(envelope.requestId) + if (existing) { + return SaveResultEncoded.Duplicate({ + originalId: Snowflake.Snowflake(existing.envelope.requestId), + lastReceivedReply: existing.replies.length === 1 && existing.replies[0]._tag === "WithExit" + ? Option.some(existing.replies[0]) + : existing.lastReceivedChunk + }) + } + if (envelope._tag === "Request") { + const entry: MemoryEntry = { envelope, replies: [], lastReceivedChunk: Option.none(), deliverAt } + requests.set(envelope.requestId, entry) + if (primaryKey) { + requestsByPrimaryKey.set(primaryKey, entry) + } + } else if (envelope._tag === "AckChunk") { + const entry = requests.get(envelope.requestId) + if (entry) { + entry.lastReceivedChunk = Arr.findFirst( + entry.replies, + (r): r is Reply.ChunkEncoded => r._tag === "Chunk" && r.id === envelope.replyId + ).pipe(Option.orElse(() => entry.lastReceivedChunk)) + } + } + unprocessed.add(envelope) + journal.push(envelope) + return SaveResultEncoded.Success() + }), + saveReply: (reply_) => + Effect.sync(() => { + const reply = JSON.parse(JSON.stringify(reply_)) as Reply.Encoded + const entry = requests.get(reply.requestId) + if (!entry || replyIds.has(reply.id)) return + if (reply._tag === "WithExit") { + unprocessed.delete(entry.envelope) + } + entry.replies.push(reply) + replyIds.add(reply.id) + replyLatch.unsafeOpen() + }), + clearReplies: (id) => + Effect.sync(() => { + const entry = requests.get(String(id)) + if (!entry) return + entry.replies = [] + entry.lastReceivedChunk = Option.none() + unprocessed.add(entry.envelope) + }), + requestIdForPrimaryKey: (primaryKey) => + Effect.sync(() => { + const entry = requestsByPrimaryKey.get(primaryKey) + return Option.fromNullishOr(entry?.envelope.requestId).pipe(Option.map(Snowflake.Snowflake)) + }), + repliesFor: (requestIds) => Effect.sync(() => repliesFor(requestIds)), + repliesForUnfiltered: (requestIds) => + Effect.sync(() => requestIds.flatMap((id) => requests.get(String(id))?.replies ?? [])), + unprocessedMessages: (shardIds) => + Effect.sync(() => { + if (unprocessed.size === 0) return [] + const now = clock.unsafeCurrentTimeMillis() + const messages = Arr.empty<{ + envelope: Envelope.Encoded + lastSentReply: Option.Option + }>() + for (let index = 0; index < journal.length; index++) { + const envelope = journal[index] + const shardId = ShardId.makeSync(envelope.address.shardId) + if (!unprocessed.has(envelope as any) || !shardIds.includes(shardId.toString())) { + continue + } + if (envelope._tag === "Request") { + const entry = requests.get(envelope.requestId)! + if (entry.deliverAt && entry.deliverAt > now) { + continue + } + messages.push({ + envelope, + lastSentReply: Arr.last(entry.replies) + }) + } else { + messages.push({ + envelope, + lastSentReply: Option.none() + }) + unprocessed.delete(envelope) + } + } + return messages + }), + unprocessedMessagesById: (ids) => + Effect.sync(() => { + const envelopeIds = new Set() + for (const id of ids) { + envelopeIds.add(String(id)) + } + return unprocessedWith((envelope) => envelopeIds.has(envelope.requestId)) + }), + resetAddress: () => Effect.void, + clearAddress: (address) => + Effect.sync(() => { + for (let i = journal.length - 1; i >= 0; i--) { + const envelope = journal[i] + const sameAddress = address.entityType === envelope.address.entityType && + address.entityId === envelope.address.entityId + if (!sameAddress || envelope._tag !== "Request") { + continue + } + unprocessed.delete(envelope) + requests.delete(envelope.requestId) + journal.splice(i, 1) + } + }), + resetShards: () => Effect.void + } + + const storage = yield* makeEncoded(encoded) + + return { + storage, + encoded, + requests, + requestsByPrimaryKey, + unprocessed, + replyIds, + journal, + cursors + } as const + }) +}) { + /** + * @since 4.0.0 + */ + static readonly layer: Layer.Layer = Layer.effect(this)(this.make).pipe( + Layer.provide(Snowflake.layerGenerator) + ) +} + +/** + * @since 4.0.0 + * @category layers + */ +export const layerNoop: Layer.Layer = Layer.succeed(MessageStorage)(noop) + +/** + * @since 4.0.0 + * @category layers + */ +export const layerMemory: Layer.Layer< + MessageStorage | MemoryDriver, + never, + ShardingConfig +> = Layer.effect(MessageStorage)(Effect.map(MemoryDriver.asEffect(), (_) => _.storage)).pipe( + Layer.provideMerge(MemoryDriver.layer) +) + +// --- internal --- + +const EnvelopeWithReply: Schema.Struct< + { + readonly envelope: Schema.Codec< + Envelope.PartialRequest | Envelope.AckChunk | Envelope.Interrupt, + unknown + > + readonly lastSentReply: Schema.Option> + } +> = Schema.Struct({ + envelope: Serializer.json(Envelope.Partial), + lastSentReply: Schema.Option(Serializer.json(Reply.Encoded)) +}) + +const decodeEnvelopeWithReply = Schema.decodeEffect(EnvelopeWithReply) diff --git a/packages/effect/src/unstable/cluster/Reply.ts b/packages/effect/src/unstable/cluster/Reply.ts new file mode 100644 index 0000000000..ce1e0e24d2 --- /dev/null +++ b/packages/effect/src/unstable/cluster/Reply.ts @@ -0,0 +1,339 @@ +/** + * @since 4.0.0 + */ +import type { NonEmptyReadonlyArray } from "../../collections/Array.ts" +import * as Data from "../../data/Data.ts" +import type * as Option from "../../data/Option.ts" +import { hasProperty } from "../../data/Predicate.ts" +import * as Effect from "../../Effect.ts" +import * as Exit from "../../Exit.ts" +import * as Schema from "../../schema/Schema.ts" +import * as Serializer from "../../schema/Serializer.ts" +import * as Transformation from "../../schema/Transformation.ts" +import * as ServiceMap from "../../ServiceMap.ts" +import * as Rpc from "../rpc/Rpc.ts" +import type * as RpcMessage from "../rpc/RpcMessage.ts" +import type * as RpcSchema from "../rpc/RpcSchema.ts" +import { MalformedMessage } from "./ClusterError.ts" +import type { OutgoingRequest } from "./Message.ts" +import { Snowflake, SnowflakeFromBigInt } from "./Snowflake.ts" + +/** + * @since 4.0.0 + * @category type ids + */ +export const TypeId: TypeId = "~effect/cluster/Reply" + +/** + * @since 4.0.0 + * @category type ids + */ +export type TypeId = "~effect/cluster/Reply" + +/** + * @since 4.0.0 + * @category guards + */ +export const isReply = (u: unknown): u is Reply => hasProperty(u, TypeId) + +/** + * @since 4.0.0 + * @category models + */ +export type Reply = WithExit | Chunk + +/** + * @since 4.0.0 + * @category models + */ +export type Encoded = WithExitEncoded | ChunkEncoded + +/** + * @since 4.0.0 + * @category models + */ +export const Encoded: Schema.Codec = Schema.Any as any + +/** + * @since 4.0.0 + * @category models + */ +export class ReplyWithContext extends Data.TaggedClass("ReplyWithContext")<{ + readonly reply: Reply + readonly services: ServiceMap.ServiceMap> + readonly rpc: R +}> { + /** + * @since 4.0.0 + */ + static fromDefect(options: { + readonly id: Snowflake + readonly requestId: Snowflake + readonly defect: unknown + }): ReplyWithContext { + return new ReplyWithContext({ + reply: new WithExit({ + requestId: options.requestId, + id: options.id, + exit: Exit.die(Schema.encodeSync(Schema.Defect)(options.defect)) + }), + services: ServiceMap.empty() as any, + rpc: neverRpc + }) + } + /** + * @since 4.0.0 + */ + static interrupt(options: { + readonly id: Snowflake + readonly requestId: Snowflake + }): ReplyWithContext { + return new ReplyWithContext({ + reply: new WithExit({ + requestId: options.requestId, + id: options.id, + exit: Exit.interrupt() + }), + services: ServiceMap.empty() as any, + rpc: neverRpc + }) + } +} + +const neverRpc = Rpc.make("Never", { + success: Schema.Never as any, + error: Schema.Never, + payload: {} +}) + +/** + * @since 4.0.0 + * @category models + */ +export interface WithExitEncoded { + readonly _tag: "WithExit" + readonly requestId: string + readonly id: string + readonly exit: RpcMessage.ResponseExitEncoded["exit"] +} + +/** + * @since 4.0.0 + * @category models + */ +export interface ChunkEncoded { + readonly _tag: "Chunk" + readonly requestId: string + readonly id: string + readonly sequence: number + readonly values: NonEmptyReadonlyArray +} + +const schemaCache = new WeakMap() + +/** + * @since 4.0.0 + * @category schemas + */ +export const Reply = ( + rpc: R +): Schema.Codec< + WithExit | Chunk, + Encoded, + Rpc.ServicesServer, + Rpc.ServicesClient +> => { + if (schemaCache.has(rpc)) { + return schemaCache.get(rpc) as any + } + const schema = Serializer.json(Schema.Union([WithExit.schema(rpc), Chunk.schema(rpc)])) + schemaCache.set(rpc, schema) + return schema as any +} + +/** + * @since 4.0.0 + * @category models + */ +export class Chunk extends Data.TaggedClass("Chunk")<{ + readonly requestId: Snowflake + readonly id: Snowflake + readonly sequence: number + readonly values: NonEmptyReadonlyArray> +}> { + /** + * @since 4.0.0 + */ + readonly [TypeId] = TypeId + + /** + * @since 4.0.0 + */ + static emptyFrom(requestId: Snowflake) { + return new Chunk({ + requestId, + id: Snowflake(BigInt(0)), + sequence: 0, + values: [undefined] + }) + } + + /** + * @since 4.0.0 + */ + static readonly Any: Schema.Schema> = Schema.declare((u): u is Chunk => + isReply(u) && u._tag === "Chunk" + ) + + /** + * @since 4.0.0 + */ + static readonly transform: Transformation.Transformation = Transformation.transform({ + decode: (a: any) => new Chunk(a), + encode: (a) => a as any + }) + + /** + * @since 4.0.0 + */ + static schema( + rpc: R + ): Schema.decodeTo< + Schema.Schema>, + Schema.Struct< + { + readonly _tag: Schema.tag<"Chunk"> + readonly requestId: Schema.Codec + readonly id: Schema.Codec + readonly sequence: Schema.Number + readonly values: Schema.NonEmptyArray> + } + > + > { + const successSchema = ((rpc as any as Rpc.AnyWithProps).successSchema as RpcSchema.Stream).success + if (!successSchema) { + return Schema.Never as any + } + return Schema.Struct({ + _tag: Schema.tag("Chunk"), + requestId: SnowflakeFromBigInt, + id: SnowflakeFromBigInt, + sequence: Schema.Number, + values: Schema.NonEmptyArray(successSchema) + }).pipe( + Schema.decodeTo(Chunk.Any, Chunk.transform) + ) + } + + /** + * @since 4.0.0 + */ + withRequestId(requestId: Snowflake): Chunk { + return new Chunk({ + ...this, + requestId + }) + } +} + +/** + * @since 4.0.0 + * @category models + */ +export class WithExit extends Data.TaggedClass("WithExit")<{ + readonly requestId: Snowflake + readonly id: Snowflake + readonly exit: Rpc.Exit +}> { + /** + * @since 4.0.0 + */ + readonly [TypeId] = TypeId + + /** + * @since 4.0.0 + */ + static is(u: unknown): u is WithExit { + return isReply(u) && u._tag === "WithExit" + } + + /** + * @since 4.0.0 + */ + static readonly Any = Schema.declare(WithExit.is, { + id: "WithExit" + }) + + /** + * @since 4.0.0 + */ + static readonly transform = Transformation.transform({ + decode: (a: any) => new WithExit(a), + encode: (a) => a as any + }) + + /** + * @since 4.0.0 + */ + static schema( + rpc: R + ): Schema.decodeTo< + Schema.declare>, + Schema.Struct< + { + readonly _tag: Schema.Literal<"WithExit"> + readonly requestId: Schema.Codec + readonly id: Schema.Codec + readonly exit: Schema.Exit, Rpc.ErrorExitSchema, Schema.Defect> + } + > + > { + return Schema.Struct({ + _tag: Schema.Literal("WithExit"), + requestId: SnowflakeFromBigInt, + id: SnowflakeFromBigInt, + exit: Rpc.exitSchema(rpc) + }).pipe( + Schema.decodeTo(WithExit.Any, WithExit.transform) + ) + } + + /** + * @since 4.0.0 + */ + withRequestId(requestId: Snowflake): WithExit { + return new WithExit({ + ...this, + requestId + }) + } +} + +/** + * @since 4.0.0 + * @category serialization / deserialization + */ +export const serialize = ( + self: ReplyWithContext +): Effect.Effect => { + const schema = Reply(self.rpc) + return MalformedMessage.refail( + Effect.provideServices(Schema.encodeEffect(schema)(self.reply), self.services) + ) +} + +/** + * @since 4.0.0 + * @category serialization / deserialization + */ +export const serializeLastReceived = ( + self: OutgoingRequest +): Effect.Effect, MalformedMessage> => { + if (self.lastReceivedReply._tag === "None") { + return Effect.succeedNone + } + const schema = Reply(self.rpc) + return Effect.asSome(MalformedMessage.refail( + Effect.provideServices(Schema.encodeEffect(schema)(self.lastReceivedReply.value), self.services) + )) +} diff --git a/packages/effect/src/unstable/cluster/Runner.ts b/packages/effect/src/unstable/cluster/Runner.ts new file mode 100644 index 0000000000..eb60e4937f --- /dev/null +++ b/packages/effect/src/unstable/cluster/Runner.ts @@ -0,0 +1,100 @@ +/** + * @since 4.0.0 + */ +import * as Equal from "../../interfaces/Equal.ts" +import * as Hash from "../../interfaces/Hash.ts" +import { NodeInspectSymbol } from "../../interfaces/Inspectable.ts" +import * as Schema from "../../schema/Schema.ts" +import * as ToPretty from "../../schema/ToPretty.ts" +import { RunnerAddress } from "./RunnerAddress.ts" + +/** + * @since 4.0.0 + * @category type ids + */ +export const TypeId: TypeId = "~effect/cluster/Runner" + +/** + * @since 4.0.0 + * @category type ids + */ +export type TypeId = "~effect/cluster/Runner" + +/** + * A `Runner` represents a physical application server that is capable of running + * entities. + * + * Because a Runner represents a physical application server, a Runner must have a + * unique `address` which can be used to communicate with the server. + * + * The version of a Runner is used during rebalancing to give priority to newer + * application servers and slowly decommission older ones. + * + * @since 4.0.0 + * @category models + */ +export class Runner extends Schema.Class(TypeId)({ + address: RunnerAddress, + groups: Schema.Array(Schema.String), + version: Schema.Int +}) { + /** + * @since 4.0.0 + */ + static pretty = ToPretty.make(this) + + /** + * @since 4.0.0 + */ + readonly [TypeId] = TypeId + + /** + * @since 4.0.0 + */ + static readonly decodeSync = Schema.decodeSync(Schema.fromJsonString(Runner)) + + /** + * @since 4.0.0 + */ + static readonly encodeSync = Schema.encodeSync(Schema.fromJsonString(Runner)); + + /** + * @since 4.0.0 + */ + [NodeInspectSymbol](): string { + return this.toString() + } + + /** + * @since 4.0.0 + */ + [Equal.symbol](that: Runner): boolean { + return this.address[Equal.symbol](that.address) && this.version === that.version + } + + /** + * @since 4.0.0 + */ + [Hash.symbol](): number { + return Hash.cached(this, () => Hash.string(`${this.address.toString()}:${this.version}`)) + } +} + +/** + * A `Runner` represents a physical application server that is capable of running + * entities. + * + * Because a Runner represents a physical application server, a Runner must have a + * unique `address` which can be used to communicate with the server. + * + * The version of a Runner is used during rebalancing to give priority to newer + * application servers and slowly decommission older ones. + * + * @since 4.0.0 + * @category Constructors + */ +export const make = (props: { + readonly address: RunnerAddress + readonly groups: ReadonlyArray + readonly version: number +}): Runner => new Runner(props, { disableValidation: true }) diff --git a/packages/effect/src/unstable/cluster/RunnerAddress.ts b/packages/effect/src/unstable/cluster/RunnerAddress.ts new file mode 100644 index 0000000000..16cced8782 --- /dev/null +++ b/packages/effect/src/unstable/cluster/RunnerAddress.ts @@ -0,0 +1,68 @@ +/** + * @since 4.0.0 + */ +import * as Equal from "../../interfaces/Equal.ts" +import * as Hash from "../../interfaces/Hash.ts" +import { NodeInspectSymbol } from "../../interfaces/Inspectable.ts" +import * as Schema from "../../schema/Schema.ts" + +/** + * @since 4.0.0 + * @category type ids + */ +export const TypeId: TypeId = "~effect/cluster/RunnerAddress" + +/** + * @since 4.0.0 + * @category type ids + */ +export type TypeId = "~effect/cluster/RunnerAddress" + +/** + * @since 4.0.0 + * @category models + */ +export class RunnerAddress extends Schema.Class(TypeId)({ + host: Schema.String, + port: Schema.Number +}) { + /** + * @since 4.0.0 + */ + readonly [TypeId] = TypeId; + + /** + * @since 4.0.0 + */ + [Equal.symbol](that: RunnerAddress): boolean { + return this.host === that.host && this.port === that.port + } + + /** + * @since 4.0.0 + */ + [Hash.symbol]() { + return Hash.cached(this, () => Hash.string(this.toString())) + } + + /** + * @since 4.0.0 + */ + override toString(): string { + return `RunnerAddress(${this.host}:${this.port})` + } + + /** + * @since 4.0.0 + */ + [NodeInspectSymbol](): string { + return this.toString() + } +} + +/** + * @since 4.0.0 + * @category constructors + */ +export const make = (host: string, port: number): RunnerAddress => + new RunnerAddress({ host, port }, { disableValidation: true }) diff --git a/packages/effect/src/unstable/cluster/RunnerHealth.ts b/packages/effect/src/unstable/cluster/RunnerHealth.ts new file mode 100644 index 0000000000..258cfc8042 --- /dev/null +++ b/packages/effect/src/unstable/cluster/RunnerHealth.ts @@ -0,0 +1,126 @@ +/** + * @since 4.0.0 + */ +import * as Effect from "../../Effect.ts" +import * as Layer from "../../Layer.ts" +import * as RcMap from "../../RcMap.ts" +import type * as Scope from "../../Scope.ts" +import * as ServiceMap from "../../ServiceMap.ts" +import * as MessageStorage from "./MessageStorage.ts" +import type { RunnerAddress } from "./RunnerAddress.ts" +import * as Runners from "./Runners.ts" +import type { ShardingConfig } from "./ShardingConfig.ts" + +/** + * Represents the service used to check if a Runner is healthy. + * + * If a Runner is responsive, shards will not be re-assigned because the Runner may + * still be processing messages. If a Runner is not responsive, then its + * associated shards can and will be re-assigned to a different Runner. + * + * @since 4.0.0 + * @category models + */ +export class RunnerHealth extends ServiceMap.Key< + RunnerHealth, + { + /** + * Used to indicate that a Runner is connected to this host and is healthy, + * while the Scope is active. + */ + readonly onConnection: (address: RunnerAddress) => Effect.Effect + readonly isAlive: (address: RunnerAddress) => Effect.Effect + } +>()("effect/cluster/RunnerHealth") {} + +/** + * @since 4.0.0 + * @category Constructors + */ +export const make: ( + options: { readonly isAlive: (address: RunnerAddress) => Effect.Effect } +) => Effect.Effect< + RunnerHealth["Service"], + never, + Scope.Scope +> = Effect.fnUntraced(function*(options: { + readonly isAlive: (address: RunnerAddress) => Effect.Effect +}) { + const connections = yield* RcMap.make({ + lookup: (_address: RunnerAddress) => Effect.void + }) + + const onConnection = (address: RunnerAddress) => RcMap.get(connections, address) + const isAlive = Effect.fnUntraced(function*(address: RunnerAddress) { + if (yield* RcMap.has(connections, address)) { + return true + } + return yield* options.isAlive(address) + }) + + return RunnerHealth.of({ + onConnection, + isAlive + }) +}) + +/** + * A layer which will **always** consider a Runner healthy. + * + * This is useful for testing. + * + * @since 4.0.0 + * @category layers + */ +export const layerNoop = Layer.effect(RunnerHealth)(make({ + isAlive: () => Effect.succeed(true) +})) + +/** + * @since 4.0.0 + * @category Constructors + */ +export const makePing: Effect.Effect< + RunnerHealth["Service"], + never, + Runners.Runners | Scope.Scope +> = Effect.gen(function*() { + const runners = yield* Runners.Runners + + function isAlive(address: RunnerAddress): Effect.Effect { + return runners.ping(address).pipe( + Effect.timeout(3000), + Effect.retry({ times: 3 }), + Effect.isSuccess + ) + } + + return yield* make({ isAlive }) +}) + +/** + * A layer which will ping a Runner directly to check if it is healthy. + * + * @since 4.0.0 + * @category layers + */ +export const layer: Layer.Layer< + RunnerHealth, + never, + Runners.Runners +> = Layer.effect(RunnerHealth)(makePing) + +/** + * A layer which will ping a Runner directly to check if it is healthy. + * + * @since 4.0.0 + * @category layers + */ +export const layerRpc: Layer.Layer< + RunnerHealth, + never, + Runners.RpcClientProtocol | ShardingConfig +> = layer.pipe( + Layer.provide(Runners.layerRpc), + Layer.provide(MessageStorage.layerNoop) +) diff --git a/packages/effect/src/unstable/cluster/RunnerServer.ts b/packages/effect/src/unstable/cluster/RunnerServer.ts new file mode 100644 index 0000000000..e7262ec167 --- /dev/null +++ b/packages/effect/src/unstable/cluster/RunnerServer.ts @@ -0,0 +1,165 @@ +/** + * @since 4.0.0 + */ +import * as Option from "../../data/Option.ts" +import * as Effect from "../../Effect.ts" +import { constant } from "../../Function.ts" +import * as Layer from "../../Layer.ts" +import * as Queue from "../../Queue.ts" +import * as RpcServer from "../rpc/RpcServer.ts" +import * as Message from "./Message.ts" +import * as MessageStorage from "./MessageStorage.ts" +import * as Reply from "./Reply.ts" +import * as Runners from "./Runners.ts" +import * as Sharding from "./Sharding.ts" +import { ShardingConfig } from "./ShardingConfig.ts" +import * as ShardManager from "./ShardManager.ts" +import * as ShardStorage from "./ShardStorage.ts" +import * as SynchronizedClock from "./SynchronizedClock.ts" + +const constVoid = constant(Effect.void) + +/** + * @since 4.0.0 + * @category Layers + */ +export const layerHandlers = Runners.Rpcs.toLayer(Effect.gen(function*() { + const sharding = yield* Sharding.Sharding + const storage = yield* MessageStorage.MessageStorage + + return { + Ping: () => Effect.void, + Notify: ({ envelope }) => + sharding.notify( + envelope._tag === "Request" + ? new Message.IncomingRequest({ + envelope, + respond: constVoid, + lastSentReply: Option.none() + }) + : new Message.IncomingEnvelope({ envelope }) + ), + Effect: ({ persisted, request }) => { + let resume: (reply: Effect.Effect) => void + let replyEncoded: Reply.Encoded | undefined + const message = new Message.IncomingRequest({ + envelope: request, + lastSentReply: Option.none(), + respond(reply) { + return Effect.flatMap(Reply.serialize(reply), (reply) => { + if (resume) { + resume(Effect.succeed(reply)) + } else { + replyEncoded = reply + } + return Effect.void + }) + } + }) + return Effect.flatMap( + persisted ? + Effect.flatMap( + storage.registerReplyHandler(message), + () => sharding.notify(message) + ) : + sharding.send(message), + () => + Effect.callback((resume_) => { + if (replyEncoded) { + resume_(Effect.succeed(replyEncoded)) + } else { + resume = resume_ + } + }) + ) + }, + Stream: ({ persisted, request }) => + Effect.flatMap( + Queue.make(), + (queue) => { + const message = new Message.IncomingRequest({ + envelope: request, + lastSentReply: Option.none(), + respond(reply) { + return Effect.flatMap(Reply.serialize(reply), (reply) => Queue.offer(queue, reply)) + } + }) + return Effect.as( + persisted ? + Effect.flatMap( + storage.registerReplyHandler(message), + () => sharding.notify(message) + ) : + sharding.send(message), + queue + ) + } + ), + Envelope: ({ envelope }) => sharding.send(new Message.IncomingEnvelope({ envelope })) + } +})) + +/** + * The `RunnerServer` recieves messages from other Runners and forwards them to the + * `Sharding` layer. + * + * It also responds to `Ping` requests. + * + * @since 4.0.0 + * @category Layers + */ +export const layer: Layer.Layer< + never, + never, + RpcServer.Protocol | Sharding.Sharding | MessageStorage.MessageStorage +> = RpcServer.layer(Runners.Rpcs, { + spanPrefix: "RunnerServer", + disableTracing: true +}).pipe(Layer.provide(layerHandlers)) + +/** + * A `RunnerServer` layer that includes the `Runners` & `Sharding` clients. + * + * @since 4.0.0 + * @category Layers + */ +export const layerWithClients: Layer.Layer< + Sharding.Sharding | Runners.Runners, + never, + | RpcServer.Protocol + | ShardingConfig + | Runners.RpcClientProtocol + | MessageStorage.MessageStorage + | ShardStorage.ShardStorage +> = layer.pipe( + Layer.provideMerge(Sharding.layer), + Layer.provideMerge(Runners.layerRpc), + Layer.provideMerge(SynchronizedClock.layer), + Layer.provide(ShardManager.layerClientRpc) +) + +/** + * A `Runners` layer that is client only. + * + * It will not register with the ShardManager and recieve shard assignments, + * so this layer can be used to embed a cluster client inside another effect + * application. + * + * @since 4.0.0 + * @category Layers + */ +export const layerClientOnly: Layer.Layer< + Sharding.Sharding | Runners.Runners, + never, + | ShardingConfig + | Runners.RpcClientProtocol + | MessageStorage.MessageStorage +> = Sharding.layer.pipe( + Layer.provideMerge(Runners.layerRpc), + Layer.provide(ShardManager.layerClientRpc), + Layer.provide(ShardStorage.layerNoop), + Layer.updateService(ShardingConfig, (config) => ({ + ...config, + runnerAddress: Option.none() + })) +) diff --git a/packages/effect/src/unstable/cluster/Runners.ts b/packages/effect/src/unstable/cluster/Runners.ts new file mode 100644 index 0000000000..4da4b5d5e1 --- /dev/null +++ b/packages/effect/src/unstable/cluster/Runners.ts @@ -0,0 +1,605 @@ +/** + * @since 4.0.0 + */ +import * as Option from "../../data/Option.ts" +import * as Effect from "../../Effect.ts" +import * as Exit from "../../Exit.ts" +import * as Layer from "../../Layer.ts" +import * as Queue from "../../Queue.ts" +import * as RcMap from "../../RcMap.ts" +import * as Schema from "../../schema/Schema.ts" +import type { Scope } from "../../Scope.ts" +import * as ServiceMap from "../../ServiceMap.ts" +import * as Rpc from "../rpc/Rpc.ts" +import * as RpcClient_ from "../rpc/RpcClient.ts" +import type { RpcClientError } from "../rpc/RpcClientError.ts" +import * as RpcGroup from "../rpc/RpcGroup.ts" +import * as RpcSchema from "../rpc/RpcSchema.ts" +import type { PersistenceError } from "./ClusterError.ts" +import { + AlreadyProcessingMessage, + EntityNotAssignedToRunner, + EntityNotManagedByRunner, + MailboxFull, + RunnerUnavailable +} from "./ClusterError.ts" +import { Persisted } from "./ClusterSchema.ts" +import * as Envelope from "./Envelope.ts" +import * as Message from "./Message.ts" +import * as MessageStorage from "./MessageStorage.ts" +import * as Reply from "./Reply.ts" +import type { RunnerAddress } from "./RunnerAddress.ts" +import { ShardingConfig } from "./ShardingConfig.ts" +import * as Snowflake from "./Snowflake.ts" + +/** + * @since 4.0.0 + * @category context + */ +export class Runners extends ServiceMap.Key Effect.Effect + + /** + * Send a message locally. + * + * This ensures that the message hits storage before being sent to the local + * entity. + */ + readonly sendLocal: ( + options: { + readonly message: Message.Outgoing + readonly send: ( + message: Message.IncomingLocal + ) => Effect.Effect< + void, + EntityNotManagedByRunner | EntityNotAssignedToRunner | MailboxFull | AlreadyProcessingMessage + > + readonly simulateRemoteSerialization: boolean + } + ) => Effect.Effect< + void, + EntityNotManagedByRunner | EntityNotAssignedToRunner | MailboxFull | AlreadyProcessingMessage | PersistenceError + > + + /** + * Send a message to a Runner. + */ + readonly send: ( + options: { + readonly address: RunnerAddress + readonly message: Message.Outgoing + } + ) => Effect.Effect< + void, + | EntityNotManagedByRunner + | EntityNotAssignedToRunner + | RunnerUnavailable + | MailboxFull + | AlreadyProcessingMessage + | PersistenceError + > + + /** + * Notify a Runner that a message is available, then read replies from storage. + */ + readonly notify: ( + options: { + readonly address: Option.Option + readonly message: Message.Outgoing + readonly discard: boolean + } + ) => Effect.Effect + + /** + * Notify the current Runner that a message is available, then read replies from + * storage. + * + * This ensures that the message hits storage before being sent to the local + * entity. + */ + readonly notifyLocal: ( + options: { + readonly message: Message.Outgoing + readonly notify: ( + options: Message.IncomingLocal + ) => Effect.Effect + readonly discard: boolean + } + ) => Effect.Effect +}>()("effect/cluster/Runners") {} + +/** + * @since 4.0.0 + * @category Constructors + */ +export const make: (options: Omit) => Effect.Effect< + Runners["Service"], + never, + MessageStorage.MessageStorage | Snowflake.Generator | ShardingConfig | Scope +> = Effect.fnUntraced(function*(options: Omit) { + const storage = yield* MessageStorage.MessageStorage + const snowflakeGen = yield* Snowflake.Generator + const config = yield* ShardingConfig + + const requestIdRewrites = new Map() + + function notifyWith( + message: Message.Outgoing, + afterPersist: (message: Message.Outgoing, isDuplicate: boolean) => Effect.Effect + ): Effect.Effect { + const rpc = message.rpc as any as Rpc.AnyWithProps + const persisted = ServiceMap.get(rpc.annotations, Persisted) + if (!persisted) { + return Effect.die("Runners.notify only supports persisted messages") + } + + if (message._tag === "OutgoingEnvelope") { + const rewriteId = requestIdRewrites.get(message.envelope.requestId) + const requestId = rewriteId ?? message.envelope.requestId + const entry = storageRequests.get(requestId) + if (rewriteId) { + message = new Message.OutgoingEnvelope({ + ...message, + envelope: message.envelope.withRequestId(rewriteId) + }) + } + return storage.saveEnvelope(message).pipe( + Effect.catchTag("MalformedMessage", Effect.die), + Effect.flatMap( + entry + ? () => Effect.flatMap(entry.latch.open, () => afterPersist(message, false)) + : () => afterPersist(message, false) + ) + ) + } + + // For requests, after persisting the request, we need to check if the + // request is a duplicate. If it is, we need to resume from the last + // received reply. + // + // Otherwise, we notify the remote entity and then reply from storage. + return Effect.flatMap( + Effect.catchTag(storage.saveRequest(message), "MalformedMessage", Effect.die), + MessageStorage.SaveResult.$match({ + Success: () => afterPersist(message, false), + Duplicate: ({ lastReceivedReply, originalId }) => { + // If the last received reply is an exit, we can just return it + // as the response. + if (Option.isSome(lastReceivedReply) && lastReceivedReply.value._tag === "WithExit") { + return message.respond(lastReceivedReply.value.withRequestId(message.envelope.requestId)) + } + requestIdRewrites.set(message.envelope.requestId, originalId) + return afterPersist( + new Message.OutgoingRequest({ + ...message, + lastReceivedReply, + envelope: Envelope.makeRequest({ + ...message.envelope, + requestId: originalId + }), + respond(reply) { + if (reply._tag === "WithExit") { + requestIdRewrites.delete(message.envelope.requestId) + } + return message.respond(reply.withRequestId(message.envelope.requestId)) + } + }), + true + ) + } + }) + ) + } + + type StorageRequestEntry = { + readonly latch: Effect.Latch + replies: Array> + } + const storageRequests = new Map() + const waitingStorageRequests = new Map>() + const replyFromStorage = Effect.fnUntraced( + function*(message: Message.OutgoingRequest) { + const entry: StorageRequestEntry = { + latch: Effect.unsafeMakeLatch(false), + replies: [] + } + storageRequests.set(message.envelope.requestId, entry) + + while (true) { + // wait for the storage loop to notify us + entry.latch.unsafeClose() + waitingStorageRequests.set(message.envelope.requestId, message) + yield* storageLatch.open + yield* entry.latch.await + + // send the replies back + for (const reply of entry.replies) { + // we have reached the end + if (reply._tag === "WithExit") { + return yield* message.respond(reply) + } + + entry.latch.unsafeClose() + yield* message.respond(reply) + yield* entry.latch.await + } + entry.replies = [] + } + }, + (effect, message) => + Effect.ensuring( + effect, + Effect.sync(() => { + storageRequests.delete(message.envelope.requestId) + waitingStorageRequests.delete(message.envelope.requestId) + }) + ) + ) + + const storageLatch = Effect.unsafeMakeLatch(false) + if (storage !== MessageStorage.noop) { + yield* Effect.gen(function*() { + while (true) { + yield* storageLatch.await + storageLatch.unsafeClose() + + const replies = yield* storage.repliesFor(waitingStorageRequests.values()).pipe( + Effect.catchCause((cause) => + Effect.as( + Effect.annotateLogs(Effect.logDebug(cause), { + package: "@effect/cluster", + module: "Runners", + fiber: "Read replies loop" + }), + [] + ) + ) + ) + + const foundRequests = new Set() + + // put the replies into the storage requests and then open the latches + for (const reply of replies) { + const entry = storageRequests.get(reply.requestId) + if (!entry) continue + entry.replies.push(reply) + waitingStorageRequests.delete(reply.requestId) + foundRequests.add(entry) + } + + for (const entry of foundRequests) { + entry.latch.unsafeOpen() + } + } + }).pipe( + Effect.interruptible, + Effect.forkScoped + ) + + yield* Effect.suspend(() => { + if (waitingStorageRequests.size === 0) { + return storageLatch.await + } + return storageLatch.open + }).pipe( + Effect.delay(config.entityReplyPollInterval), + Effect.forever, + Effect.interruptible, + Effect.forkScoped + ) + } + + return Runners.of({ + ...options, + sendLocal(options) { + const message = options.message + if (!options.simulateRemoteSerialization) { + return options.send(Message.incomingLocalFromOutgoing(message)) + } + return Message.serialize(message).pipe( + Effect.flatMap((encoded) => Message.deserializeLocal(message, encoded)), + Effect.flatMap(options.send), + Effect.catchTag("MalformedMessage", (error) => { + if (message._tag === "OutgoingEnvelope") { + return Effect.die(error) + } + return message.respond( + new Reply.WithExit({ + id: snowflakeGen.unsafeNext(), + requestId: message.envelope.requestId, + exit: Exit.die(error) + }) + ) + }) + ) + }, + notify(options_) { + const { discard, message } = options_ + return notifyWith(message, (message, duplicate) => { + if (discard || message._tag === "OutgoingEnvelope") { + return options.notify(options_) + } else if (!duplicate && options_.address._tag === "Some") { + return Effect.catch( + options.send({ + address: options_.address.value, + message + }), + (error) => { + if (error._tag === "EntityNotManagedByRunner") { + return Effect.fail(error) + } + return replyFromStorage(message) + } + ) + } + return options.notify(options_).pipe( + Effect.andThen(replyFromStorage(message)) + ) + }) + }, + notifyLocal(options) { + return notifyWith(options.message, (message, duplicate) => { + if (options.discard || message._tag === "OutgoingEnvelope") { + return Effect.catchTag( + options.notify(Message.incomingLocalFromOutgoing(message)), + "EntityNotAssignedToRunner", + () => Effect.void + ) + } else if (!duplicate) { + return storage.registerReplyHandler(message).pipe( + Effect.andThen(options.notify(Message.incomingLocalFromOutgoing(message))), + Effect.catchTag("EntityNotAssignedToRunner", () => Effect.void) + ) + } + return options.notify(Message.incomingLocalFromOutgoing(message)).pipe( + Effect.catchTag("EntityNotAssignedToRunner", () => Effect.void), + Effect.andThen(replyFromStorage(message)) + ) + }) + } + }) +}) + +/** + * @since 4.0.0 + * @category No-op + */ +export const makeNoop: Effect.Effect< + Runners["Service"], + never, + MessageStorage.MessageStorage | Snowflake.Generator | ShardingConfig | Scope +> = make({ + send: ({ message }) => Effect.fail(new EntityNotManagedByRunner({ address: message.envelope.address })), + notify: () => Effect.void, + ping: () => Effect.void +}) + +/** + * @since 4.0.0 + * @category Layers + */ +export const layerNoop: Layer.Layer< + Runners, + never, + ShardingConfig | MessageStorage.MessageStorage +> = Layer.effect(Runners)(makeNoop).pipe(Layer.provide([Snowflake.layerGenerator])) + +const rpcErrors: Schema.Union<[ + typeof EntityNotManagedByRunner, + typeof EntityNotAssignedToRunner, + typeof MailboxFull, + typeof AlreadyProcessingMessage +]> = Schema.Union([ + EntityNotManagedByRunner, + EntityNotAssignedToRunner, + MailboxFull, + AlreadyProcessingMessage +]) + +/** + * @since 4.0.0 + * @category Rpcs + */ +export class Rpcs extends RpcGroup.make( + Rpc.make("Ping"), + Rpc.make("Notify", { + payload: { + envelope: Envelope.Partial + }, + success: Schema.Void, + error: Schema.Union([EntityNotManagedByRunner, EntityNotAssignedToRunner, AlreadyProcessingMessage]) + }), + Rpc.make("Effect", { + payload: { + request: Envelope.PartialRequest, + persisted: Schema.Boolean + }, + success: Reply.Encoded, + error: rpcErrors + }), + Rpc.make("Stream", { + payload: { + request: Envelope.PartialRequest, + persisted: Schema.Boolean + }, + error: rpcErrors, + success: Reply.Encoded, + stream: true + }), + Rpc.make("Envelope", { + payload: { + envelope: Schema.Union([Envelope.AckChunk, Envelope.Interrupt]), + persisted: Schema.Boolean + }, + error: rpcErrors + }) +) {} + +/** + * @since 4.0.0 + * @category Rpcs + */ +export interface RpcClient extends RpcClient_.FromGroup {} + +/** + * @since 4.0.0 + * @category Rpcs + */ +export const makeRpcClient: Effect.Effect< + RpcClient, + never, + RpcClient_.Protocol | Scope +> = RpcClient_.make(Rpcs, { spanPrefix: "Runners", disableTracing: true }) + +/** + * @since 4.0.0 + * @category constructors + */ +export const makeRpc: Effect.Effect< + Runners["Service"], + never, + Scope | RpcClientProtocol | MessageStorage.MessageStorage | Snowflake.Generator | ShardingConfig +> = Effect.gen(function*() { + const makeClientProtocol = yield* RpcClientProtocol + const snowflakeGen = yield* Snowflake.Generator + + const clients = yield* RcMap.make({ + lookup: (address: RunnerAddress) => + Effect.flatMap( + makeClientProtocol(address), + (protocol) => Effect.provideService(makeRpcClient, RpcClient_.Protocol, protocol) + ), + idleTimeToLive: "3 minutes" + }) + + return yield* make({ + ping(address) { + return RcMap.get(clients, address).pipe( + Effect.flatMap((client) => client.Ping()), + Effect.catchCause(() => Effect.fail(new RunnerUnavailable({ address }))), + Effect.scoped + ) + }, + send({ address, message }) { + const rpc = message.rpc as any as Rpc.AnyWithProps + const isPersisted = ServiceMap.get(rpc.annotations, Persisted) + if (message._tag === "OutgoingEnvelope") { + return RcMap.get(clients, address).pipe( + Effect.flatMap((client) => + client.Envelope({ + envelope: message.envelope, + persisted: isPersisted + }) + ), + Effect.catchTag("RpcClientError", Effect.die), + Effect.scoped, + Effect.catchDefect(() => Effect.fail(new RunnerUnavailable({ address }))) + ) + } + const isStream = RpcSchema.isStreamSchema(rpc.successSchema) + if (!isStream) { + return Effect.matchEffect(Message.serializeRequest(message), { + onSuccess: (request) => + RcMap.get(clients, address).pipe( + Effect.flatMap((client) => + client.Effect({ + request, + persisted: isPersisted + }) + ), + Effect.catchTag("RpcClientError", Effect.die), + Effect.flatMap((reply) => + Schema.decodeEffect(Reply.Reply(message.rpc))(reply).pipe( + Effect.provideServices(message.services), + Effect.orDie + ) + ), + Effect.flatMap(message.respond), + Effect.scoped, + Effect.catchDefect(() => Effect.fail(new RunnerUnavailable({ address }))) + ), + onFailure: (error) => + message.respond( + new Reply.WithExit({ + id: snowflakeGen.unsafeNext(), + requestId: message.envelope.requestId, + exit: Exit.die(error) + }) + ) + }) + } + return Effect.matchEffect(Message.serializeRequest(message), { + onSuccess: (request) => + RcMap.get(clients, address).pipe( + Effect.flatMap((client) => + client.Stream({ + request, + persisted: isPersisted + }, { asQueue: true }) + ), + Effect.flatMap((queue) => { + const decode = Schema.decodeEffect(Reply.Reply(message.rpc)) + return Queue.take(queue).pipe( + Effect.flatMap((reply) => Effect.orDie(decode(reply))), + Effect.flatMap(message.respond), + Effect.forever({ autoYield: false }), + Effect.catchTag("RpcClientError", Effect.die), + Effect.provideServices(message.services), + Effect.catchTag("Done", () => Effect.void), + Effect.catchDefect(() => Effect.fail(new RunnerUnavailable({ address }))) + ) + }), + Effect.scoped + ), + onFailure: (error) => + message.respond( + new Reply.WithExit({ + id: snowflakeGen.unsafeNext(), + requestId: message.envelope.requestId, + exit: Exit.die(error) + }) + ) + }) + }, + notify({ address, message }) { + if (Option.isNone(address)) { + return Effect.void + } + const envelope = message.envelope + return RcMap.get(clients, address.value).pipe( + Effect.flatMap((client) => client.Notify({ envelope })), + Effect.scoped, + Effect.catch((error) => { + if (error._tag === "EntityNotManagedByRunner") { + return Effect.fail(error) + } + return Effect.void + }) + ) + } + }) +}) + +/** + * @since 4.0.0 + * @category Layers + */ +export const layerRpc: Layer.Layer< + Runners, + never, + MessageStorage.MessageStorage | RpcClientProtocol | ShardingConfig +> = Layer.effect(Runners)(makeRpc).pipe( + Layer.provide(Snowflake.layerGenerator) +) + +/** + * @since 4.0.0 + * @category Client + */ +export class RpcClientProtocol extends ServiceMap.Key< + RpcClientProtocol, + (address: RunnerAddress) => Effect.Effect +>()("effect/cluster/Runners/RpcClientProtocol") {} diff --git a/packages/effect/src/unstable/cluster/ShardId.ts b/packages/effect/src/unstable/cluster/ShardId.ts new file mode 100644 index 0000000000..783a74c61a --- /dev/null +++ b/packages/effect/src/unstable/cluster/ShardId.ts @@ -0,0 +1,97 @@ +/** + * @since 4.0.0 + */ +import * as Equal from "../../interfaces/Equal.ts" +import * as Hash from "../../interfaces/Hash.ts" +import * as S from "../../schema/Schema.ts" + +/** + * @since 4.0.0 + * @category Symbols + */ +export const TypeId: TypeId = "~effect/cluster/ShardId" + +/** + * @since 4.0.0 + * @category Symbols + */ +export type TypeId = "~effect/cluster/ShardId" + +const constDisableValidation = { disableValidation: true } + +/** + * @since 4.0.0 + * @category Constructors + */ +export const make = (group: string, id: number): ShardId => new ShardId({ group, id }, constDisableValidation) + +/** + * @since 4.0.0 + * @category Models + */ +export class ShardId extends S.Class(TypeId)({ + group: S.String, + id: S.Int +}) { + /** + * @since 4.0.0 + */ + readonly [TypeId]: TypeId = TypeId; + + /** + * @since 4.0.0 + */ + [Equal.symbol](that: ShardId): boolean { + return this.group === that.group && this.id === that.id + } + + /** + * @since 4.0.0 + */ + [Hash.symbol](): number { + return Hash.cached(this, () => Hash.string(this.toString())) + } + + /** + * @since 4.0.0 + */ + override toString(): string { + return `${this.group}:${this.id}` + } + + /** + * @since 4.0.0 + */ + static override toString(shardId: { + readonly group: string + readonly id: number + }): string { + return `${shardId.group}:${shardId.id}` + } + + /** + * @since 4.0.0 + */ + static fromStringEncoded(s: string): { + readonly group: string + readonly id: number + } { + const index = s.lastIndexOf(":") + if (index === -1) { + throw new Error(`Invalid ShardId format`) + } + const group = s.substring(0, index) + const id = Number(s.substring(index + 1)) + if (isNaN(id)) { + throw new Error(`ShardId id must be a number`) + } + return { group, id } + } + + /** + * @since 4.0.0 + */ + static fromString(s: string): ShardId { + return new ShardId(ShardId.fromStringEncoded(s), constDisableValidation) + } +} diff --git a/packages/effect/src/unstable/cluster/ShardManager.ts b/packages/effect/src/unstable/cluster/ShardManager.ts new file mode 100644 index 0000000000..9d9fead16a --- /dev/null +++ b/packages/effect/src/unstable/cluster/ShardManager.ts @@ -0,0 +1,823 @@ +/** + * @since 4.0.0 + */ +import * as Arr from "../../collections/Array.ts" +import * as Iterable from "../../collections/Iterable.ts" +import * as MutableHashMap from "../../collections/MutableHashMap.ts" +import * as MutableHashSet from "../../collections/MutableHashSet.ts" +import * as Config_ from "../../config/Config.ts" +import * as ConfigProvider from "../../config/ConfigProvider.ts" +import * as Data from "../../data/Data.ts" +import * as Option from "../../data/Option.ts" +import * as Deferred from "../../Deferred.ts" +import * as Effect from "../../Effect.ts" +import * as FiberSet from "../../FiberSet.ts" +import { identity } from "../../Function.ts" +import * as Equal from "../../interfaces/Equal.ts" +import * as Layer from "../../Layer.ts" +import * as Metric from "../../observability/Metric.ts" +import * as PubSub from "../../PubSub.ts" +import * as Queue from "../../Queue.ts" +import * as Schedule from "../../Schedule.ts" +import * as Schema from "../../schema/Schema.ts" +import type { Scope } from "../../Scope.ts" +import * as ServiceMap from "../../ServiceMap.ts" +import * as Clock from "../../time/Clock.ts" +import * as Duration from "../../time/Duration.ts" +import * as Rpc from "../rpc/Rpc.ts" +import * as RpcClient from "../rpc/RpcClient.ts" +import * as RpcGroup from "../rpc/RpcGroup.ts" +import * as RpcServer from "../rpc/RpcServer.ts" +import { RunnerNotRegistered } from "./ClusterError.ts" +import * as ClusterMetrics from "./ClusterMetrics.ts" +import { addAllNested, decideAssignmentsForShards, State } from "./internal/shardManager.ts" +import * as MachineId from "./MachineId.ts" +import { make as makeRunner, Runner } from "./Runner.ts" +import { RunnerAddress } from "./RunnerAddress.ts" +import * as RunnerHealth from "./RunnerHealth.ts" +import type { Runners } from "./Runners.ts" +import { RpcClientProtocol } from "./Runners.ts" +import { make as makeShardId, ShardId } from "./ShardId.ts" +import { ShardingConfig } from "./ShardingConfig.ts" +import { ShardStorage } from "./ShardStorage.ts" + +/** + * @since 4.0.0 + * @category models + */ +export class ShardManager extends ServiceMap.Key]> + > + /** + * Get a stream of sharding events emit by the shard manager. + */ + readonly shardingEvents: ( + address: Option.Option + ) => Effect.Effect, never, Scope> + /** + * Register a new runner with the cluster. + */ + readonly register: (runner: Runner) => Effect.Effect + /** + * Unregister a runner from the cluster. + */ + readonly unregister: (address: RunnerAddress) => Effect.Effect + /** + * Rebalance shards assigned to runners within the cluster. + */ + readonly rebalance: Effect.Effect + /** + * Notify the cluster of an unhealthy runner. + */ + readonly notifyUnhealthyRunner: (address: RunnerAddress) => Effect.Effect + /** + * Check and repot on the health of all runners in the cluster. + */ + readonly checkRunnerHealth: Effect.Effect +}>()("effect/cluster/ShardManager") {} + +/** + * @since 4.0.0 + * @category Config + */ +export class Config extends ServiceMap.Key()("effect/cluster/ShardManager/Config") { + /** + * @since 4.0.0 + */ + static readonly defaults: Config["Service"] = { + rebalanceDebounce: Duration.seconds(3), + rebalanceInterval: Duration.seconds(20), + rebalanceRetryInterval: Duration.seconds(10), + rebalanceRate: 2 / 100, + persistRetryCount: 100, + persistRetryInterval: Duration.seconds(3), + runnerHealthCheckInterval: Duration.minutes(1), + runnerPingTimeout: Duration.seconds(3) + } +} + +/** + * @since 4.0.0 + * @category Config + */ +export const configConfig: Config_.Config = Config_.all({ + rebalanceDebounce: Config_.duration("rebalanceDebounce").pipe( + Config_.withDefault(() => Config.defaults.rebalanceDebounce) + // Config_.withDescription("The duration to wait before rebalancing shards after a change.") + ), + rebalanceInterval: Config_.duration("rebalanceInterval").pipe( + Config_.withDefault(() => Config.defaults.rebalanceInterval) + // Config_.withDescription("The interval on which regular rebalancing of shards will occur.") + ), + rebalanceRetryInterval: Config_.duration("rebalanceRetryInterval").pipe( + Config_.withDefault(() => Config.defaults.rebalanceRetryInterval) + // Config_.withDescription( + // "The interval on which rebalancing of shards which failed to be rebalanced will be retried." + // ) + ), + rebalanceRate: Config_.number("rebalanceRate").pipe( + Config_.withDefault(() => Config.defaults.rebalanceRate) + // Config_.withDescription("The maximum ratio of shards to rebalance at once.") + ), + persistRetryCount: Config_.int("persistRetryCount").pipe( + Config_.withDefault(() => Config.defaults.persistRetryCount) + // Config_.withDescription("The number of times persistence of runners will be retried if it fails.") + ), + persistRetryInterval: Config_.duration("persistRetryInterval").pipe( + Config_.withDefault(() => Config.defaults.persistRetryInterval) + // Config_.withDescription("The interval on which persistence of runners will be retried if it fails.") + ), + runnerHealthCheckInterval: Config_.duration("runnerHealthCheckInterval").pipe( + Config_.withDefault(() => Config.defaults.runnerHealthCheckInterval) + // Config_.withDescription("The interval on which runner health will be checked.") + ), + runnerPingTimeout: Config_.duration("runnerPingTimeout").pipe( + Config_.withDefault(() => Config.defaults.runnerPingTimeout) + // Config_.withDescription("The length of time to wait for a runner to respond to a ping.") + ) +}) + +/** + * @since 4.0.0 + * @category Config + */ +export const configFromEnv: Effect.Effect = configConfig.asEffect().pipe( + Effect.provideService( + ConfigProvider.ConfigProvider, + ConfigProvider.fromEnv().pipe( + ConfigProvider.constantCase + ) + ) +) + +/** + * @since 4.0.0 + * @category Config + */ +export const layerConfig = (config?: Partial | undefined): Layer.Layer => + Layer.succeed(Config)({ + ...Config.defaults, + ...config + }) + +/** + * @since 4.0.0 + * @category Config + */ +export const layerConfigFromEnv = ( + config?: Partial | undefined +): Layer.Layer => + Layer.effect(Config)(config ? Effect.map(configFromEnv, (env) => ({ ...env, ...config })) : configFromEnv) + +/** + * Represents a client which can be used to communicate with the + * `ShardManager`. + * + * @since 4.0.0 + * @category Client + */ +export class ShardManagerClient extends ServiceMap.Key + ) => Effect.Effect + /** + * Unregister a runner from the cluster. + */ + readonly unregister: (address: RunnerAddress) => Effect.Effect + /** + * Notify the cluster of an unhealthy runner. + */ + readonly notifyUnhealthyRunner: (address: RunnerAddress) => Effect.Effect + /** + * Get all shard assignments. + */ + readonly getAssignments: Effect.Effect< + Iterable]> + > + /** + * Get a stream of sharding events emit by the shard manager. + */ + readonly shardingEvents: ( + address: Option.Option + ) => Effect.Effect, never, Scope> + /** + * Get the current time on the shard manager. + */ + readonly getTime: Effect.Effect +}>()("effect/cluster/ShardManager/ShardManagerClient") {} + +/** + * @since 4.0.0 + * @category models + */ +export const ShardingEventSchema = Schema.Union([ + Schema.TaggedStruct("StreamStarted", {}), + Schema.TaggedStruct("ShardsAssigned", { + address: RunnerAddress, + shards: Schema.Array(ShardId) + }), + Schema.TaggedStruct("ShardsUnassigned", { + address: RunnerAddress, + shards: Schema.Array(ShardId) + }), + Schema.TaggedStruct("RunnerRegistered", { + address: RunnerAddress + }), + Schema.TaggedStruct("RunnerUnregistered", { + address: RunnerAddress + }) +]) satisfies Schema.Codec + +/** + * The messaging protocol for the `ShardManager`. + * + * @since 4.0.0 + * @category Rpcs + */ +export class Rpcs extends RpcGroup.make( + Rpc.make("Register", { + payload: { runner: Runner }, + success: MachineId.MachineId + }), + Rpc.make("Unregister", { + payload: { address: RunnerAddress } + }), + Rpc.make("NotifyUnhealthyRunner", { + payload: { address: RunnerAddress } + }), + Rpc.make("GetAssignments", { + success: Schema.Array(Schema.Tuple([ShardId, Schema.Option(RunnerAddress)])) + }), + Rpc.make("ShardingEvents", { + payload: { address: Schema.Option(RunnerAddress) }, + success: ShardingEventSchema, + stream: true + }), + Rpc.make("GetTime", { + success: Schema.Number + }) +) {} + +/** + * @since 4.0.0 + * @category models + */ +export type ShardingEvent = Data.TaggedEnum<{ + StreamStarted: {} + ShardsAssigned: { + address: RunnerAddress + shards: ReadonlyArray + } + ShardsUnassigned: { + address: RunnerAddress + shards: ReadonlyArray + } + RunnerRegistered: { address: RunnerAddress } + RunnerUnregistered: { address: RunnerAddress } +}> + +/** + * @since 4.0.0 + * @category models + */ +export const ShardingEvent = Data.taggedEnum() + +/** + * @since 4.0.0 + * @category Client + */ +export const makeClientLocal = Effect.gen(function*() { + const config = yield* ShardingConfig + const clock = yield* Clock.Clock + + const groups = new Set() + const shards = MutableHashMap.empty>() + + let machineId = 0 + + return ShardManagerClient.of({ + register: (_, groupsToAdd) => + Effect.sync(() => { + for (const group of groupsToAdd) { + if (groups.has(group)) continue + groups.add(group) + for (let n = 1; n <= config.shardsPerGroup; n++) { + MutableHashMap.set(shards, makeShardId(group, n), config.runnerAddress) + } + } + return MachineId.make(++machineId) + }), + unregister: () => Effect.void, + notifyUnhealthyRunner: () => Effect.void, + getAssignments: Effect.succeed(shards), + shardingEvents: Effect.fnUntraced(function*(_address) { + const queue = yield* Queue.make() + yield* Queue.offer(queue, ShardingEvent.StreamStarted()) + return queue + }), + getTime: clock.currentTimeMillis + }) +}) + +/** + * @since 4.0.0 + * @category Client + */ +export const makeClientRpc: Effect.Effect< + ShardManagerClient["Service"], + never, + ShardingConfig | RpcClient.Protocol | Scope +> = Effect.gen(function*() { + const config = yield* ShardingConfig + const client = yield* RpcClient.make(Rpcs, { + spanPrefix: "ShardManagerClient", + disableTracing: true + }) + + return ShardManagerClient.of({ + register: (address, groups) => + client.Register({ runner: makeRunner({ address, version: config.serverVersion, groups }) }).pipe( + Effect.orDie + ), + unregister: (address) => Effect.orDie(client.Unregister({ address })), + notifyUnhealthyRunner: (address) => Effect.orDie(client.NotifyUnhealthyRunner({ address })), + getAssignments: Effect.orDie(client.GetAssignments()), + shardingEvents: (address) => + Queue.make().pipe( + Effect.tap(Effect.fnUntraced( + function*(queue) { + const events = yield* client.ShardingEvents({ address }, { asQueue: true }) + const take = Effect.orDie(Queue.takeAll(events)) + while (true) { + Queue.unsafeOfferAll(queue, yield* take) + } + }, + (effect, queue) => Queue.into(effect, queue as any), + (effect) => Effect.forkScoped(effect) + )) + ), + getTime: Effect.orDie(client.GetTime()) + }) +}) + +/** + * @since 4.0.0 + * @category Client + */ +export const layerClientLocal: Layer.Layer< + ShardManagerClient, + never, + ShardingConfig +> = Layer.effect(ShardManagerClient)(makeClientLocal) + +/** + * @since 4.0.0 + * @category Client + */ +export const layerClientRpc: Layer.Layer< + ShardManagerClient, + never, + ShardingConfig | RpcClientProtocol +> = Layer.effect(ShardManagerClient)(makeClientRpc).pipe( + Layer.provide( + Layer.effect(RpcClient.Protocol)( + Effect.gen(function*() { + const config = yield* ShardingConfig + const clientProtocol = yield* RpcClientProtocol + return yield* clientProtocol(config.shardManagerAddress) + }) + ) + ) +) + +/** + * @since 4.0.0 + * @category Constructors + */ +export const make = Effect.gen(function*() { + const storage = yield* ShardStorage + const runnerHealthApi = yield* RunnerHealth.RunnerHealth + const clock = yield* Clock.Clock + const config = yield* Config + const shardingConfig = yield* ShardingConfig + + const state = yield* Effect.orDie(State.fromStorage(shardingConfig.shardsPerGroup)) + const scope = yield* Effect.scope + const events = yield* PubSub.unbounded() + + function updateRunnerMetrics() { + ClusterMetrics.runners.unsafeUpdate(MutableHashMap.size(state.allRunners), ServiceMap.empty()) + } + + function updateShardMetrics() { + const stats = state.shardStats + for (const [address, shardCount] of stats.perRunner) { + ClusterMetrics.assignedShards.unsafeUpdate( + shardCount, + Metric.CurrentMetricAttributes.serviceMap({ address }) + ) + } + ClusterMetrics.unassignedShards.unsafeUpdate(stats.unassigned, ServiceMap.empty()) + } + updateShardMetrics() + + function withRetry(effect: Effect.Effect): Effect.Effect { + return effect.pipe( + Effect.retry({ + schedule: Schedule.spaced(config.persistRetryCount), + times: config.persistRetryCount + }), + Effect.ignore + ) + } + + const persistRunners = Effect.unsafeMakeSemaphore(1).withPermits(1)(withRetry( + Effect.suspend(() => + storage.saveRunners( + Iterable.map(state.allRunners, ([address, runner]) => [address, runner.runner]) + ) + ) + )) + + const persistAssignments = Effect.unsafeMakeSemaphore(1).withPermits(1)(withRetry( + Effect.suspend(() => storage.saveAssignments(state.assignments)) + )) + + const notifyUnhealthyRunner = Effect.fnUntraced(function*(address: RunnerAddress) { + if (!MutableHashMap.has(state.allRunners, address)) return + + if (!(yield* runnerHealthApi.isAlive(address))) { + yield* Effect.logWarning(`Runner at address '${address.toString()}' is not alive`) + yield* unregister(address) + } + }) + + function updateShardsState( + shards: Iterable, + address: Option.Option + ): Effect.Effect { + return Effect.suspend(() => { + if (Option.isSome(address) && !MutableHashMap.has(state.allRunners, address.value)) { + return Effect.fail(new RunnerNotRegistered({ address: address.value })) + } + state.addAssignments(shards, address) + return Effect.void + }) + } + + const getAssignments = Effect.sync(() => state.assignments) + + let machineId = 0 + const register = Effect.fnUntraced(function*(runner: Runner) { + yield* Effect.logInfo(`Registering runner ${Runner.pretty(runner)}`) + + const current = MutableHashMap.get(state.allRunners, runner.address).pipe( + Option.filter((r) => r.runner.version === runner.version) + ) + if (Option.isSome(current)) { + return MachineId.make(++machineId) + } + + state.addRunner(runner, clock.unsafeCurrentTimeMillis()) + updateRunnerMetrics() + yield* PubSub.publish(events, ShardingEvent.RunnerRegistered({ address: runner.address })) + yield* Effect.forkIn(persistRunners, scope) + yield* Effect.forkIn(rebalance, scope) + return MachineId.make(++machineId) + }) + + const unregister = Effect.fnUntraced(function*(address: RunnerAddress) { + if (!MutableHashMap.has(state.allRunners, address)) return + + yield* Effect.logInfo("Unregistering runner at address:", address) + const unassignments = Arr.empty() + for (const [shard, runner] of state.assignments) { + if (Option.isSome(runner) && Equal.equals(runner.value, address)) { + unassignments.push(shard) + } + } + state.addAssignments(unassignments, Option.none()) + state.removeRunner(address) + updateRunnerMetrics() + + if (unassignments.length > 0) { + yield* PubSub.publish(events, ShardingEvent.RunnerUnregistered({ address })) + } + + yield* Effect.forkIn(persistRunners, scope) + yield* Effect.forkIn(rebalance, scope) + }) + + let rebalancing = false + let rebalanceDeferred: Deferred.Deferred | undefined + const rebalanceFibers = yield* FiberSet.make() + + const rebalance = Effect.suspend(() => { + if (!rebalancing) { + rebalancing = true + return rebalanceLoop + } + if (!rebalanceDeferred) { + rebalanceDeferred = Deferred.unsafeMake() + } + return Deferred.await(rebalanceDeferred) + }) + + const rebalanceLoop: Effect.Effect = Effect.suspend(() => { + const deferred = rebalanceDeferred + rebalanceDeferred = undefined + return runRebalance.pipe( + deferred ? Deferred.into(deferred) : identity, + Effect.onExit(() => { + if (!rebalanceDeferred) { + rebalancing = false + return Effect.void + } + return Effect.forkIn(rebalanceLoop, scope) + }) + ) + }) + + const runRebalance = Effect.gen(function*() { + yield* Effect.sleep(config.rebalanceDebounce) + + if (state.shards.size === 0) { + yield* Effect.logDebug("No shards to rebalance") + return + } else if (MutableHashMap.size(state.allRunners) === 0) { + yield* Effect.logDebug("No runners to rebalance") + return + } + + // Determine which shards to assign and unassign + const assignments = MutableHashMap.empty>() + const unassignments = MutableHashMap.empty>() + const changes = MutableHashSet.empty() + for (const group of state.shards.keys()) { + const [groupAssignments, groupUnassignments, groupChanges] = decideAssignmentsForShards(state, group) + for (const [address, shards] of groupAssignments) { + addAllNested(assignments, address, Array.from(shards, (id) => makeShardId(group, id))) + } + for (const [address, shards] of groupUnassignments) { + addAllNested(unassignments, address, Array.from(shards, (id) => makeShardId(group, id))) + } + for (const address of groupChanges) { + MutableHashSet.add(changes, address) + } + } + + yield* Effect.logDebug(`Rebalancing shards`) + + if (MutableHashSet.size(changes) === 0) return + + yield* Metric.update(ClusterMetrics.rebalances, 1) + + // Ping runners first and remove unhealthy ones + const failedRunners = MutableHashSet.empty() + for (const address of changes) { + yield* FiberSet.run( + rebalanceFibers, + Effect.flatMap(runnerHealthApi.isAlive(address), (isAlive) => { + if (isAlive) return Effect.void + MutableHashSet.add(failedRunners, address) + MutableHashMap.remove(assignments, address) + MutableHashMap.remove(unassignments, address) + return Effect.void + }), + { startImmediately: true } + ) + } + yield* FiberSet.awaitEmpty(rebalanceFibers) + + const failedUnassignments = new Set() + for (const [address, shards] of unassignments) { + yield* FiberSet.run( + rebalanceFibers, + updateShardsState(shards, Option.none()).pipe( + Effect.matchEffect({ + onFailure: () => { + MutableHashSet.add(failedRunners, address) + for (const shard of shards) { + failedUnassignments.add(shard) + } + // Remove failed runners from the assignments + MutableHashMap.remove(assignments, address) + return Effect.void + }, + onSuccess: () => + PubSub.publish(events, ShardingEvent.ShardsUnassigned({ address, shards: Array.from(shards) })) + }) + ), + { startImmediately: true } + ) + } + yield* FiberSet.awaitEmpty(rebalanceFibers) + + // Remove failed shard unassignments from the assignments + MutableHashMap.forEach(assignments, (shards, address) => { + for (const shard of failedUnassignments) { + MutableHashSet.remove(shards, shard) + } + if (MutableHashSet.size(shards) === 0) { + MutableHashMap.remove(assignments, address) + } + }) + + // Perform the assignments + for (const [address, shards] of assignments) { + yield* FiberSet.run( + rebalanceFibers, + updateShardsState(shards, Option.some(address)).pipe( + Effect.matchEffect({ + onFailure: () => { + MutableHashSet.add(failedRunners, address) + return Effect.void + }, + onSuccess: () => + PubSub.publish(events, ShardingEvent.ShardsAssigned({ address, shards: Array.from(shards) })) + }) + ), + { startImmediately: true } + ) + } + yield* FiberSet.awaitEmpty(rebalanceFibers) + + updateShardMetrics() + + const wereFailures = MutableHashSet.size(failedRunners) > 0 + if (wereFailures) { + // Check if the failing runners are still reachable + yield* Effect.forEach(failedRunners, notifyUnhealthyRunner, { discard: true }).pipe( + Effect.forkIn(scope) + ) + yield* Effect.logWarning("Failed to rebalance runners: ", failedRunners) + } + + if (wereFailures) { + // Try rebalancing again later if there were any failures + yield* Effect.sleep(config.rebalanceRetryInterval).pipe( + Effect.flatMap(() => rebalance), + Effect.forkIn(scope) + ) + } + + yield* persistAssignments + }).pipe(Effect.withSpan("ShardManager.rebalance", undefined, { captureStackTrace: false })) + + const checkRunnerHealth: Effect.Effect = Effect.suspend(() => + Effect.forEach(MutableHashMap.keys(state.allRunners), notifyUnhealthyRunner, { + concurrency: 10, + discard: true + }) + ) + + yield* Effect.addFinalizer(() => + persistAssignments.pipe( + Effect.catchCause((cause) => Effect.logWarning("Failed to persist assignments on shutdown", cause)), + Effect.flatMap(() => + persistRunners.pipe( + Effect.catchCause((cause) => Effect.logWarning("Failed to persist runners on shutdown", cause)) + ) + ) + ) + ) + + yield* Effect.forkIn(persistRunners, scope) + + // Start a regular cluster rebalance at the configured interval + yield* rebalance.pipe( + Effect.andThen(Effect.sleep(config.rebalanceInterval)), + Effect.forever, + Effect.forkIn(scope) + ) + + yield* checkRunnerHealth.pipe( + Effect.andThen(Effect.sleep(config.runnerHealthCheckInterval)), + Effect.forever, + Effect.forkIn(scope) + ) + + yield* Effect.gen(function*() { + const queue = yield* PubSub.subscribe(events) + while (true) { + yield* Effect.logInfo("Shard manager event:", yield* PubSub.take(queue)) + } + }).pipe(Effect.forkIn(scope)) + + yield* Effect.logInfo("Shard manager initialized") + + return ShardManager.of({ + getAssignments, + shardingEvents: (address) => + Effect.flatMap( + Option.isSome(address) ? runnerHealthApi.onConnection(address.value) : Effect.void, + () => PubSub.subscribe(events) + ), + register, + unregister, + rebalance, + notifyUnhealthyRunner, + checkRunnerHealth + }) +}) + +/** + * @since 4.0.0 + * @category layer + */ +export const layer: Layer.Layer< + ShardManager, + never, + ShardStorage | RunnerHealth.RunnerHealth | Runners | Config | ShardingConfig +> = Layer.effect(ShardManager)(make) + +/** + * @since 4.0.0 + * @category Server + */ +export const layerServerHandlers = Rpcs.toLayer(Effect.gen(function*() { + const shardManager = yield* ShardManager + const clock = yield* Clock.Clock + return { + Register: ({ runner }) => shardManager.register(runner), + Unregister: ({ address }) => shardManager.unregister(address), + NotifyUnhealthyRunner: ({ address }) => shardManager.notifyUnhealthyRunner(address), + GetAssignments: () => + Effect.map( + shardManager.getAssignments, + (assignments) => Array.from(assignments) + ), + ShardingEvents: Effect.fnUntraced(function*({ address }) { + const sub = yield* shardManager.shardingEvents(address) + const queue = yield* Queue.make() + + yield* Queue.offer(queue, ShardingEvent.StreamStarted()) + + yield* PubSub.takeAll(sub).pipe( + Effect.flatMap((events) => Queue.offerAll(queue, events)), + Effect.forever, + Effect.forkScoped + ) + + return queue + }), + GetTime: () => clock.currentTimeMillis + } +})) + +/** + * @since 4.0.0 + * @category Server + */ +export const layerServer: Layer.Layer< + never, + never, + ShardManager | RpcServer.Protocol +> = RpcServer.layer(Rpcs, { + spanPrefix: "ShardManager", + disableTracing: true +}).pipe(Layer.provide(layerServerHandlers)) diff --git a/packages/effect/src/unstable/cluster/ShardStorage.ts b/packages/effect/src/unstable/cluster/ShardStorage.ts new file mode 100644 index 0000000000..0531672362 --- /dev/null +++ b/packages/effect/src/unstable/cluster/ShardStorage.ts @@ -0,0 +1,296 @@ +/** + * @since 4.0.0 + */ +import * as Arr from "../../collections/Array.ts" +import * as MutableHashMap from "../../collections/MutableHashMap.ts" +import * as Option from "../../data/Option.ts" +import * as Effect from "../../Effect.ts" +import * as Layer from "../../Layer.ts" +import * as ServiceMap from "../../ServiceMap.ts" +import type { PersistenceError } from "./ClusterError.ts" +import { Runner } from "./Runner.ts" +import { RunnerAddress } from "./RunnerAddress.ts" +import { ShardId } from "./ShardId.ts" + +/** + * Represents a generic interface to the persistent storage required by the + * cluster. + * + * @since 4.0.0 + * @category models + */ +export class ShardStorage extends ServiceMap.Key]>, + PersistenceError + > + + /** + * Save the current state of shards assignments to runners. + */ + readonly saveAssignments: ( + assignments: Iterable]> + ) => Effect.Effect + + /** + * Get all runners registered with the cluster. + */ + readonly getRunners: Effect.Effect, PersistenceError> + + /** + * Save the current runners registered with the cluster. + */ + readonly saveRunners: (runners: Iterable) => Effect.Effect + + /** + * Try to acquire the given shard ids for processing. + * + * It returns an array of shards it was able to acquire. + */ + readonly acquire: ( + address: RunnerAddress, + shardIds: Iterable + ) => Effect.Effect, PersistenceError> + + /** + * Refresh the locks owned by the given runner. + * + * Locks expire after 15 seconds, so this method should be called every 10 + * seconds to keep the locks alive. + */ + readonly refresh: ( + address: RunnerAddress, + shardIds: Iterable + ) => Effect.Effect, PersistenceError> + + /** + * Release the given shard ids. + */ + readonly release: ( + address: RunnerAddress, + shardId: ShardId + ) => Effect.Effect + + /** + * Release all the shards assigned to the given runner. + */ + readonly releaseAll: (address: RunnerAddress) => Effect.Effect +}>()("effect/cluster/ShardStorage") {} + +/** + * @since 4.0.0 + * @category Encoded + */ +export interface Encoded { + /** + * Get the current assignments of shards to runners. + */ + readonly getAssignments: Effect.Effect< + Array< + readonly [ + shardId: string, + runnerAddress: string | null + ] + >, + PersistenceError + > + + /** + * Save the current state of shards assignments to runners. + */ + readonly saveAssignments: ( + assignments: Array + ) => Effect.Effect + + /** + * Get all runners registered with the cluster. + */ + readonly getRunners: Effect.Effect, PersistenceError> + + /** + * Save the current runners registered with the cluster. + */ + readonly saveRunners: ( + runners: Array + ) => Effect.Effect + + /** + * Acquire the lock on the given shards, returning the shards that were + * successfully locked. + */ + readonly acquire: ( + address: string, + shardIds: ReadonlyArray + ) => Effect.Effect, PersistenceError> + + /** + * Refresh the lock on the given shards, returning the shards that were + * successfully locked. + */ + readonly refresh: ( + address: string, + shardIds: ReadonlyArray + ) => Effect.Effect, PersistenceError> + + /** + * Release the lock on the given shard. + */ + readonly release: ( + address: string, + shardId: string + ) => Effect.Effect + + /** + * Release the lock on all shards for the given runner. + */ + readonly releaseAll: (address: string) => Effect.Effect +} + +/** + * @since 4.0.0 + * @category layers + */ +export const makeEncoded = (encoded: Encoded) => + ShardStorage.of({ + getAssignments: Effect.map(encoded.getAssignments, (assignments) => { + const arr = Arr.empty<[ShardId, Option.Option]>() + for (const [shardId, runnerAddress] of assignments) { + arr.push([ + ShardId.fromString(shardId), + runnerAddress === null ? Option.none() : Option.some(decodeRunnerAddress(runnerAddress)) + ]) + } + return arr + }), + saveAssignments: (assignments) => { + const arr = Arr.empty() + for (const [shardId, runnerAddress] of assignments) { + arr.push([ + shardId.toString(), + Option.isNone(runnerAddress) ? null : encodeRunnerAddress(runnerAddress.value) + ]) + } + return encoded.saveAssignments(arr) + }, + getRunners: Effect.gen(function*() { + const runners = yield* encoded.getRunners + const results: Array<[RunnerAddress, Runner]> = [] + for (let i = 0; i < runners.length; i++) { + const [address, runner] = runners[i] + try { + results.push([decodeRunnerAddress(address), Runner.decodeSync(runner)]) + } catch { + // + } + } + return results + }), + saveRunners: (runners) => + Effect.suspend(() => + encoded.saveRunners( + Array.from(runners, ([address, runner]) => [encodeRunnerAddress(address), Runner.encodeSync(runner)]) + ) + ), + acquire: (address, shardIds) => { + const arr = Array.from(shardIds, (id) => id.toString()) + return encoded.acquire(encodeRunnerAddress(address), arr).pipe( + Effect.map((shards) => shards.map(ShardId.fromString)) + ) + }, + refresh: (address, shardIds) => { + const arr = Array.from(shardIds, (id) => id.toString()) + return encoded.refresh(encodeRunnerAddress(address), arr).pipe( + Effect.map((shards) => shards.map(ShardId.fromString)) + ) + }, + release(address, shardId) { + return encoded.release(encodeRunnerAddress(address), shardId.toString()) + }, + releaseAll(address) { + return encoded.releaseAll(encodeRunnerAddress(address)) + } + }) + +/** + * @since 4.0.0 + * @category layers + */ +export const layerNoop: Layer.Layer = Layer.sync(ShardStorage)( + () => { + let acquired: Array = [] + return ShardStorage.of({ + getAssignments: Effect.sync(() => []), + saveAssignments: () => Effect.void, + getRunners: Effect.sync(() => []), + saveRunners: () => Effect.void, + acquire: (_address, shards) => { + acquired = Array.from(shards) + return Effect.succeed(Array.from(shards)) + }, + refresh: () => Effect.sync(() => acquired), + release: () => Effect.void, + releaseAll: () => Effect.void + }) + } +) + +/** + * @since 4.0.0 + * @category constructors + */ +export const makeMemory = Effect.gen(function*() { + const assignments = MutableHashMap.empty>() + const runners = MutableHashMap.empty() + + function saveAssignments(value: Iterable]>) { + return Effect.sync(() => { + for (const [shardId, runnerAddress] of value) { + MutableHashMap.set(assignments, shardId, runnerAddress) + } + }) + } + + function saveRunners(value: Iterable) { + return Effect.sync(() => { + for (const [address, runner] of value) { + MutableHashMap.set(runners, address, runner) + } + }) + } + + let acquired: Array = [] + + return ShardStorage.of({ + getAssignments: Effect.sync(() => Array.from(assignments)), + saveAssignments, + getRunners: Effect.sync(() => Array.from(runners)), + saveRunners, + acquire: (_address, shardIds) => { + acquired = Array.from(shardIds) + return Effect.succeed(Array.from(shardIds)) + }, + refresh: () => Effect.sync(() => acquired), + release: () => Effect.void, + releaseAll: () => Effect.void + }) +}) + +/** + * @since 4.0.0 + * @category layers + */ +export const layerMemory: Layer.Layer = Layer.effect(ShardStorage)(makeMemory) + +// ------------------------------------------------------------------------------------- +// internal +// ------------------------------------------------------------------------------------- + +const encodeRunnerAddress = (runnerAddress: RunnerAddress) => `${runnerAddress.host}:${runnerAddress.port}` + +const decodeRunnerAddress = (runnerAddress: string): RunnerAddress => { + const [host, port] = runnerAddress.split(":") + return new RunnerAddress({ host, port: Number(port) }) +} diff --git a/packages/effect/src/unstable/cluster/Sharding.ts b/packages/effect/src/unstable/cluster/Sharding.ts new file mode 100644 index 0000000000..0d59488f78 --- /dev/null +++ b/packages/effect/src/unstable/cluster/Sharding.ts @@ -0,0 +1,1236 @@ +/** + * @since 4.0.0 + */ +import * as Cause from "../../Cause.ts" +import * as Arr from "../../collections/Array.ts" +import * as Iterable from "../../collections/Iterable.ts" +import * as MutableHashMap from "../../collections/MutableHashMap.ts" +import * as MutableHashSet from "../../collections/MutableHashSet.ts" +import * as Filter from "../../data/Filter.ts" +import * as Option from "../../data/Option.ts" +import * as Deferred from "../../Deferred.ts" +import * as Effect from "../../Effect.ts" +import * as Exit from "../../Exit.ts" +import * as Fiber from "../../Fiber.ts" +import * as FiberHandle from "../../FiberHandle.ts" +import * as FiberMap from "../../FiberMap.ts" +import { constant } from "../../Function.ts" +import * as Equal from "../../interfaces/Equal.ts" +import * as Layer from "../../Layer.ts" +import * as MutableRef from "../../MutableRef.ts" +import * as PubSub from "../../PubSub.ts" +import * as Queue from "../../Queue.ts" +import { CurrentLogAnnotations } from "../../References.ts" +import * as Schedule from "../../Schedule.ts" +import * as Scope from "../../Scope.ts" +import * as ServiceMap from "../../ServiceMap.ts" +import * as Stream from "../../stream/Stream.ts" +import type { DurationInput } from "../../time/Duration.ts" +import type * as Rpc from "../rpc/Rpc.ts" +import * as RpcClient from "../rpc/RpcClient.ts" +import { type FromServer, RequestId } from "../rpc/RpcMessage.ts" +import type { MailboxFull, PersistenceError } from "./ClusterError.ts" +import { AlreadyProcessingMessage, EntityNotAssignedToRunner, EntityNotManagedByRunner } from "./ClusterError.ts" +import { Persisted, Uninterruptible } from "./ClusterSchema.ts" +import * as ClusterSchema from "./ClusterSchema.ts" +import type { CurrentAddress, CurrentRunnerAddress, Entity, HandlersFrom } from "./Entity.ts" +import type { EntityAddress } from "./EntityAddress.ts" +import { make as makeEntityAddress } from "./EntityAddress.ts" +import type { EntityId } from "./EntityId.ts" +import { make as makeEntityId } from "./EntityId.ts" +import * as Envelope from "./Envelope.ts" +import * as EntityManager from "./internal/entityManager.ts" +import { EntityReaper } from "./internal/entityReaper.ts" +import { hashString } from "./internal/hash.ts" +import { internalInterruptors } from "./internal/interruptors.ts" +import { ResourceMap } from "./internal/resourceMap.ts" +import * as Message from "./Message.ts" +import * as MessageStorage from "./MessageStorage.ts" +import * as Reply from "./Reply.ts" +import type { RunnerAddress } from "./RunnerAddress.ts" +import { Runners } from "./Runners.ts" +import type { ShardId } from "./ShardId.ts" +import { make as makeShardId } from "./ShardId.ts" +import { ShardingConfig } from "./ShardingConfig.ts" +import { EntityRegistered, type ShardingRegistrationEvent, SingletonRegistered } from "./ShardingRegistrationEvent.ts" +import { ShardManagerClient } from "./ShardManager.ts" +import { ShardStorage } from "./ShardStorage.ts" +import { SingletonAddress } from "./SingletonAddress.ts" +import * as Snowflake from "./Snowflake.ts" + +/** + * @since 4.0.0 + * @category models + */ +export class Sharding extends ServiceMap.Key + + /** + * Returns the `ShardId` of the shard to which the entity at the specified + * `address` is assigned. + */ + readonly getShardId: (entityId: EntityId, group: string) => ShardId + + /** + * Returns `true` if sharding is shutting down, `false` otherwise. + */ + readonly isShutdown: Effect.Effect + + /** + * Constructs a `RpcClient` which can be used to send messages to the + * specified `Entity`. + */ + readonly makeClient: ( + entity: Entity + ) => Effect.Effect< + ( + entityId: string + ) => RpcClient.RpcClient.From< + Rpcs, + MailboxFull | AlreadyProcessingMessage | PersistenceError | EntityNotManagedByRunner + > + > + + /** + * Registers a new entity with the runner. + */ + readonly registerEntity: , RX>( + entity: Entity, + handlers: Effect.Effect, + options?: { + readonly maxIdleTime?: DurationInput | undefined + readonly concurrency?: number | "unbounded" | undefined + readonly mailboxCapacity?: number | "unbounded" | undefined + readonly disableFatalDefects?: boolean | undefined + readonly defectRetryPolicy?: Schedule.Schedule | undefined + readonly spanAttributes?: Record | undefined + } + ) => Effect.Effect< + void, + never, + Rpc.ServicesServer | Rpc.Middleware | Exclude + > + + /** + * Registers a new singleton with the runner. + */ + readonly registerSingleton: ( + name: string, + run: Effect.Effect, + options?: { + readonly shardGroup?: string | undefined + } + ) => Effect.Effect> + + /** + * Sends a message to the specified entity. + */ + readonly send: (message: Message.Incoming) => Effect.Effect< + void, + EntityNotManagedByRunner | EntityNotAssignedToRunner | MailboxFull | AlreadyProcessingMessage + > + + /** + * Sends an outgoing message + */ + readonly sendOutgoing: ( + message: Message.Outgoing, + discard: boolean + ) => Effect.Effect< + void, + EntityNotManagedByRunner | MailboxFull | AlreadyProcessingMessage | PersistenceError + > + + /** + * Notify sharding that a message has been persisted to storage. + */ + readonly notify: (message: Message.Incoming) => Effect.Effect< + void, + EntityNotManagedByRunner | EntityNotAssignedToRunner | AlreadyProcessingMessage + > + + /** + * Reset the state of a message + */ + readonly reset: (requestId: Snowflake.Snowflake) => Effect.Effect + + /** + * Trigger a storage read, which will read all unprocessed messages. + */ + readonly pollStorage: Effect.Effect + + /** + * Retrieves the active entity count for the current runner. + */ + readonly activeEntityCount: Effect.Effect +}>()("effect/cluster/Sharding") {} + +// ----------------------------------------------------------------------------- +// Implementation +// ----------------------------------------------------------------------------- + +interface EntityManagerState { + readonly entity: Entity + readonly scope: Scope.Scope.Closeable + readonly manager: EntityManager.EntityManager +} + +const make = Effect.gen(function*() { + const config = yield* ShardingConfig + + const runners = yield* Runners + const shardManager = yield* ShardManagerClient + const snowflakeGen = yield* Snowflake.Generator + const shardingScope = yield* Effect.scope + const isShutdown = MutableRef.make(false) + + const storage = yield* MessageStorage.MessageStorage + const storageEnabled = storage !== MessageStorage.noop + const shardStorage = yield* ShardStorage + + const entityManagers = new Map() + + const shardAssignments = MutableHashMap.empty() + const selfShards = MutableHashSet.empty() + + // the active shards are the ones that we have acquired the lock for + const acquiredShards = MutableHashSet.empty() + const activeShardsLatch = yield* Effect.makeLatch(false) + + const events = yield* PubSub.unbounded() + const getRegistrationEvents: Stream.Stream = Stream.fromPubSub(events) + + const isLocalRunner = (address: RunnerAddress) => + Option.isSome(config.runnerAddress) && Equal.equals(address, config.runnerAddress.value) + + function getShardId(entityId: EntityId, group: string): ShardId { + const id = Math.abs(hashString(entityId) % config.shardsPerGroup) + 1 + return makeShardId(group, id) + } + + function isEntityOnLocalShards(address: EntityAddress): boolean { + return MutableHashSet.has(acquiredShards, address.shardId) + } + + // --- Shard acquisition --- + + if (Option.isSome(config.runnerAddress)) { + const selfAddress = config.runnerAddress.value + yield* Scope.addFinalizerExit(shardingScope, () => { + // the locks expire over time, so if this fails we ignore it + return Effect.ignore(shardStorage.releaseAll(selfAddress)) + }) + + const releasingShards = MutableHashSet.empty() + yield* Effect.gen(function*() { + while (true) { + yield* activeShardsLatch.await + + // if a shard is no longer assigned to this runner, we release it + for (const shardId of acquiredShards) { + if (MutableHashSet.has(selfShards, shardId)) continue + MutableHashSet.remove(acquiredShards, shardId) + MutableHashSet.add(releasingShards, shardId) + } + // if a shard has been assigned to this runner, we acquire it + const unacquiredShards = MutableHashSet.empty() + for (const shardId of selfShards) { + if (MutableHashSet.has(acquiredShards, shardId) || MutableHashSet.has(releasingShards, shardId)) continue + MutableHashSet.add(unacquiredShards, shardId) + } + + if (MutableHashSet.size(releasingShards) > 0) { + yield* Effect.forkIn(syncSingletons, shardingScope) + yield* releaseShards + } + + if (MutableHashSet.size(unacquiredShards) === 0) { + yield* activeShardsLatch.close + continue + } + + const acquired = yield* shardStorage.acquire(selfAddress, unacquiredShards) + yield* Effect.ignore(storage.resetShards(acquired)) + for (const shardId of acquired) { + MutableHashSet.add(acquiredShards, shardId) + } + if (acquired.length > 0) { + yield* storageReadLatch.open + yield* Effect.forkIn(syncSingletons, shardingScope) + } + yield* Effect.sleep(1000) + } + }).pipe( + Effect.catchCause((cause) => Effect.logWarning("Could not acquire/release shards", cause)), + Effect.repeat(Schedule.spaced(config.entityMessagePollInterval)), + Effect.annotateLogs({ + package: "@effect/cluster", + module: "Sharding", + fiber: "Shard acquisition loop", + runner: selfAddress + }), + Effect.interruptible, + Effect.forkIn(shardingScope) + ) + + // refresh the shard locks every 4s + yield* Effect.suspend(() => + shardStorage.refresh(selfAddress, [ + ...acquiredShards, + ...releasingShards + ]) + ).pipe( + Effect.flatMap((acquired) => { + for (const shardId of acquiredShards) { + if (!acquired.some((_) => _[Equal.symbol](shardId))) { + MutableHashSet.remove(acquiredShards, shardId) + MutableHashSet.add(releasingShards, shardId) + } + } + return MutableHashSet.size(releasingShards) > 0 ? + Effect.andThen( + Effect.forkIn(syncSingletons, shardingScope), + releaseShards + ) : + Effect.void + }), + Effect.retry({ + times: 5, + schedule: Schedule.spaced(50) + }), + Effect.catchCause((cause) => + Effect.logError("Could not refresh shard locks", cause).pipe( + Effect.andThen(clearSelfShards) + ) + ), + Effect.delay("4 seconds"), + Effect.forever, + Effect.interruptible, + Effect.forkIn(shardingScope) + ) + + const releaseShardsLock = Effect.unsafeMakeSemaphore(1).withPermits(1) + const releaseShards = releaseShardsLock( + Effect.suspend(() => + Effect.forEach( + releasingShards, + (shardId) => + Effect.forEach( + entityManagers.values(), + (state) => state.manager.interruptShard(shardId), + { concurrency: "unbounded", discard: true } + ).pipe( + Effect.andThen(shardStorage.release(selfAddress, shardId)), + Effect.annotateLogs({ + runner: selfAddress + }), + Effect.andThen(() => { + MutableHashSet.remove(releasingShards, shardId) + }) + ), + { concurrency: "unbounded", discard: true } + ) + ) + ) + } + + const clearSelfShards = Effect.suspend(() => { + MutableHashSet.clear(selfShards) + return activeShardsLatch.open + }) + + // --- Singletons --- + + const singletons = new Map>>() + const singletonFibers = yield* FiberMap.make() + const withSingletonLock = Effect.unsafeMakeSemaphore(1).withPermits(1) + + const registerSingleton: Sharding["Service"]["registerSingleton"] = Effect.fnUntraced( + function*(name, run, options) { + const shardGroup = options?.shardGroup ?? "default" + const address = new SingletonAddress({ + shardId: getShardId(makeEntityId(name), shardGroup), + name + }) + + let map = singletons.get(address.shardId) + if (!map) { + map = MutableHashMap.empty() + singletons.set(address.shardId, map) + } + if (MutableHashMap.has(map, address)) { + return yield* Effect.die(`Singleton '${name}' is already registered`) + } + + const services = yield* Effect.services() + const wrappedRun = run.pipe( + Effect.provideService(CurrentLogAnnotations, {}), + Effect.andThen(Effect.never), + Effect.scoped, + Effect.provideServices(services), + Effect.orDie, + Effect.interruptible + ) as Effect.Effect + MutableHashMap.set(map, address, wrappedRun) + + yield* PubSub.publish(events, SingletonRegistered({ address })) + + // start if we are on the right shard + if (MutableHashSet.has(acquiredShards, address.shardId)) { + yield* Effect.logDebug("Starting singleton", address) + yield* FiberMap.run(singletonFibers, address, wrappedRun) + } + }, + withSingletonLock + ) + + const syncSingletons = withSingletonLock(Effect.gen(function*() { + for (const [shardId, map] of singletons) { + for (const [address, run] of map) { + const running = FiberMap.unsafeHas(singletonFibers, address) + const shouldBeRunning = MutableHashSet.has(acquiredShards, shardId) + if (running && !shouldBeRunning) { + yield* Effect.logDebug("Stopping singleton", address) + internalInterruptors.add(Fiber.getCurrent()!.id) + yield* FiberMap.remove(singletonFibers, address) + } else if (!running && shouldBeRunning) { + yield* Effect.logDebug("Starting singleton", address) + yield* FiberMap.run(singletonFibers, address, run) + } + } + } + })) + + // --- Storage inbox --- + + const storageReadLatch = yield* Effect.makeLatch(true) + const openStorageReadLatch = constant(Effect.asVoid(storageReadLatch.open)) + + const storageReadLock = Effect.unsafeMakeSemaphore(1) + const withStorageReadLock = storageReadLock.withPermits(1) + + let storageAlreadyProcessed = (_message: Message.IncomingRequest) => true + + // keep track of the last sent request ids to avoid duplicates + // we only keep the last 30 sets to avoid memory leaks + const sentRequestIds = new Set() + const sentRequestIdSets = new Set>() + + if (storageEnabled && Option.isSome(config.runnerAddress)) { + const selfAddress = config.runnerAddress.value + + yield* Effect.gen(function*() { + yield* Effect.logDebug("Starting") + yield* Effect.addFinalizer(() => Effect.logDebug("Shutting down")) + + sentRequestIds.clear() + sentRequestIdSets.clear() + + storageAlreadyProcessed = (message: Message.IncomingRequest) => { + if (!sentRequestIds.has(message.envelope.requestId)) { + return false + } + const state = entityManagers.get(message.envelope.address.entityType) + if (!state) return true + return !state.manager.isProcessingFor(message, { excludeReplies: true }) + } + + while (true) { + // wait for the next poll interval, or if we get notified of a change + yield* storageReadLatch.await + + // if we get notified of a change, ensure we start a read immediately + // next iteration + storageReadLatch.unsafeClose() + + // the lock is used to ensure resuming entities have a garantee that no + // more items are added to the unprocessed set while the semaphore is + // acquired. + yield* storageReadLock.take(1) + + const messages = yield* storage.unprocessedMessages(acquiredShards) + const currentSentRequestIds = new Set() + sentRequestIdSets.add(currentSentRequestIds) + + const send = Effect.catchCause( + Effect.suspend(() => { + const message = messages[index] + if (message._tag === "IncomingRequest") { + if (sentRequestIds.has(message.envelope.requestId)) { + return Effect.void + } + sentRequestIds.add(message.envelope.requestId) + currentSentRequestIds.add(message.envelope.requestId) + } + const address = message.envelope.address + if (!MutableHashSet.has(acquiredShards, address.shardId)) { + return Effect.void + } + const state = entityManagers.get(address.entityType) + if (!state) { + if (message._tag === "IncomingRequest") { + return Effect.orDie(message.respond(Reply.ReplyWithContext.fromDefect({ + id: snowflakeGen.unsafeNext(), + requestId: message.envelope.requestId, + defect: new EntityNotManagedByRunner({ address }) + }))) + } + return Effect.void + } + + const isProcessing = state.manager.isProcessingFor(message) + + // If the message might affect a currently processing request, we + // send it to the entity manager to be processed. + if (message._tag === "IncomingEnvelope" && isProcessing) { + return state.manager.send(message) + } else if (isProcessing) { + return Effect.void + } + + // If the entity was resuming in another fiber, we add the message + // id to the unprocessed set. + const resumptionState = MutableHashMap.get(entityResumptionState, address) + if (Option.isSome(resumptionState)) { + resumptionState.value.unprocessed.add(message.envelope.requestId) + if (message.envelope._tag === "Interrupt") { + resumptionState.value.interrupts.set(message.envelope.requestId, message as Message.IncomingEnvelope) + } + return Effect.void + } + return state.manager.send(message) + }), + (cause) => { + const message = messages[index] + const error = Cause.filterError(cause) + // if we get a defect, then update storage + if (Filter.isFail(error)) { + return storage.saveReply(Reply.ReplyWithContext.fromDefect({ + id: snowflakeGen.unsafeNext(), + requestId: message.envelope.requestId, + defect: Cause.squash(cause) + })) + } + if (error._tag === "MailboxFull") { + // MailboxFull can only happen for requests, so this cast is safe + return resumeEntityFromStorage(message as Message.IncomingRequest) + } + return Effect.void + } + ) + + let index = 0 + yield* Effect.whileLoop({ + while: () => index < messages.length, + step: () => index++, + body: constant(send) + }) + + // let the resuming entities check if they are done + yield* storageReadLock.release(1) + + while (sentRequestIdSets.size > 30) { + const oldest = Iterable.unsafeHead(sentRequestIdSets) + sentRequestIdSets.delete(oldest) + for (const id of oldest) { + sentRequestIds.delete(id) + } + } + } + }).pipe( + Effect.scoped, + Effect.ensuring(storageReadLock.releaseAll), + Effect.catchCause((cause) => Effect.logWarning("Could not read messages from storage", cause)), + Effect.repeat(Schedule.spaced(config.entityMessagePollInterval)), + Effect.annotateLogs({ + package: "@effect/cluster", + module: "Sharding", + fiber: "Storage read loop", + runner: selfAddress + }), + Effect.interruptible, + Effect.forkIn(shardingScope) + ) + + // open the storage latch every poll interval + yield* storageReadLatch.open.pipe( + Effect.delay(config.entityMessagePollInterval), + Effect.forever, + Effect.interruptible, + Effect.forkIn(shardingScope) + ) + + // Resume unprocessed messages for entities that reached a full mailbox. + const entityResumptionState = MutableHashMap.empty + interrupts: Map + }>() + const resumeEntityFromStorage = (lastReceivedMessage: Message.IncomingRequest) => { + const address = lastReceivedMessage.envelope.address + const resumptionState = MutableHashMap.get(entityResumptionState, address) + if (Option.isSome(resumptionState)) { + resumptionState.value.unprocessed.add(lastReceivedMessage.envelope.requestId) + return Effect.void + } + MutableHashMap.set(entityResumptionState, address, { + unprocessed: new Set([lastReceivedMessage.envelope.requestId]), + interrupts: new Map() + }) + return resumeEntityFromStorageImpl(address) + } + const resumeEntityFromStorageImpl = Effect.fnUntraced( + function*(address: EntityAddress) { + const state = entityManagers.get(address.entityType) + if (!state) { + MutableHashMap.remove(entityResumptionState, address) + return + } + + const resumptionState = Option.getOrThrow(MutableHashMap.get(entityResumptionState, address)) + let done = false + + while (!done) { + // if the shard is no longer assigned to this runner, we stop + if (!MutableHashSet.has(acquiredShards, address.shardId)) { + return + } + + // take a batch of unprocessed messages ids + const messageIds = Arr.empty() + for (const id of resumptionState.unprocessed) { + if (messageIds.length === 1024) break + messageIds.push(id) + } + + const messages = yield* storage.unprocessedMessagesById(messageIds) + + // this should not happen, but we handle it just in case + if (messages.length === 0) { + yield* Effect.sleep(config.entityMessagePollInterval) + continue + } + + let index = 0 + + const sendWithRetry: Effect.Effect< + void, + EntityNotManagedByRunner | EntityNotAssignedToRunner + > = Effect.catchTags( + Effect.suspend(() => { + if (!MutableHashSet.has(acquiredShards, address.shardId)) { + return Effect.fail(new EntityNotAssignedToRunner({ address })) + } + + const message = messages[index] + // check if this is a request that was interrupted + const interrupt = message._tag === "IncomingRequest" && + resumptionState.interrupts.get(message.envelope.requestId) + return interrupt ? + Effect.flatMap(state.manager.send(message), () => { + resumptionState.interrupts.delete(message.envelope.requestId) + return state.manager.send(interrupt) + }) : + state.manager.send(message) + }), + { + MailboxFull: () => Effect.delay(sendWithRetry, config.sendRetryInterval), + AlreadyProcessingMessage: () => Effect.void + } + ) + + yield* Effect.whileLoop({ + while: () => index < messages.length, + body: constant(sendWithRetry), + step: () => index++ + }) + + for (const id of messageIds) { + resumptionState.unprocessed.delete(id) + } + if (resumptionState.unprocessed.size > 0) continue + + // if we have caught up to the main storage loop, we let it take over + yield* withStorageReadLock(Effect.sync(() => { + if (resumptionState.unprocessed.size === 0) { + MutableHashMap.remove(entityResumptionState, address) + done = true + } + })) + } + }, + Effect.retry({ + while: (e) => e._tag === "PersistenceError", + schedule: Schedule.spaced(config.entityMessagePollInterval) + }), + Effect.catchCause((cause) => Effect.logError("Could not resume unprocessed messages", cause)), + (effect, address) => + Effect.annotateLogs(effect, { + package: "@effect/cluster", + module: "Sharding", + fiber: "Resuming unprocessed messages", + runner: selfAddress, + entity: address + }), + (effect, address) => + Effect.ensuring( + effect, + Effect.sync(() => MutableHashMap.remove(entityResumptionState, address)) + ), + Effect.interruptible, + Effect.forkIn(shardingScope) + ) + } + + // --- Sending messages --- + + const sendLocal = | Message.Incoming>( + message: M + ): Effect.Effect< + void, + | EntityNotAssignedToRunner + | EntityNotManagedByRunner + | MailboxFull + | AlreadyProcessingMessage + | (M extends Message.Incoming ? never : PersistenceError) + > => + Effect.suspend(() => { + const address = message.envelope.address + if (!isEntityOnLocalShards(address)) { + return Effect.fail(new EntityNotAssignedToRunner({ address })) + } + const state = entityManagers.get(address.entityType) + if (!state) { + return Effect.fail(new EntityNotManagedByRunner({ address })) + } + + return message._tag === "IncomingRequest" || message._tag === "IncomingEnvelope" ? + state.manager.send(message) : + runners.sendLocal({ + message, + send: state.manager.sendLocal, + simulateRemoteSerialization: config.simulateRemoteSerialization + }) as any + }) + + const notifyLocal = | Message.Incoming>( + message: M, + discard: boolean + ) => + Effect.suspend( + (): Effect.Effect< + void, + | EntityNotManagedByRunner + | EntityNotAssignedToRunner + | AlreadyProcessingMessage + | (M extends Message.Incoming ? never : PersistenceError) + > => { + const address = message.envelope.address + if (!isEntityOnLocalShards(address)) { + return Effect.fail(new EntityNotAssignedToRunner({ address })) + } else if (!entityManagers.has(address.entityType)) { + return Effect.fail(new EntityNotManagedByRunner({ address })) + } + + const notify = storageEnabled + ? openStorageReadLatch + : () => Effect.die("Sharding.notifyLocal: storage is disabled") + + if (message._tag === "IncomingRequest" || message._tag === "IncomingEnvelope") { + if (message._tag === "IncomingRequest" && storageAlreadyProcessed(message)) { + return Effect.fail(new AlreadyProcessingMessage({ address, envelopeId: message.envelope.requestId })) + } + return notify() + } + + return runners.notifyLocal({ message, notify, discard }) as any + } + ) + + function sendOutgoing( + message: Message.Outgoing, + discard: boolean, + retries?: number + ): Effect.Effect< + void, + EntityNotManagedByRunner | MailboxFull | AlreadyProcessingMessage | PersistenceError + > { + return Effect.catchFilter( + Effect.suspend(() => { + const address = message.envelope.address + const maybeRunner = MutableHashMap.get(shardAssignments, address.shardId) + const isPersisted = ServiceMap.get(message.rpc.annotations, Persisted) + if (isPersisted && !storageEnabled) { + return Effect.die("Sharding.sendOutgoing: Persisted messages require MessageStorage") + } + const runnerIsLocal = Option.isSome(maybeRunner) && isLocalRunner(maybeRunner.value) + if (isPersisted) { + return runnerIsLocal + ? notifyLocal(message, discard) + : runners.notify({ address: maybeRunner, message, discard }) + } else if (Option.isNone(maybeRunner)) { + return Effect.fail(new EntityNotAssignedToRunner({ address })) + } + return runnerIsLocal + ? sendLocal(message) + : runners.send({ address: maybeRunner.value, message }) + }), + (error) => + error._tag === "EntityNotAssignedToRunner" || error._tag === "RunnerUnavailable" ? error : Filter.fail(error), + (error) => { + if (retries === 0) { + return Effect.die(error) + } + return Effect.delay(sendOutgoing(message, discard, retries && retries - 1), config.sendRetryInterval) + } + ) + } + + const reset: Sharding["Service"]["reset"] = Effect.fnUntraced( + function*(requestId) { + yield* storage.clearReplies(requestId) + sentRequestIds.delete(requestId) + }, + Effect.matchCause({ + onSuccess: () => true, + onFailure: () => false + }) + ) + + // --- Shard Manager sync --- + + const shardManagerTimeoutFiber = yield* FiberHandle.make().pipe( + Scope.provide(shardingScope) + ) + const startShardManagerTimeout = FiberHandle.run( + shardManagerTimeoutFiber, + Effect.flatMap(Effect.sleep(config.shardManagerUnavailableTimeout), () => { + MutableHashMap.clear(shardAssignments) + return clearSelfShards + }), + { onlyIfMissing: true } + ) + const stopShardManagerTimeout = FiberHandle.clear(shardManagerTimeoutFiber) + + // Every time the link to the shard manager is lost, we re-register the runner + // and re-subscribe to sharding events + yield* Effect.gen(function*() { + yield* Effect.logDebug("Registering with shard manager") + if (Option.isSome(config.runnerAddress)) { + const machineId = yield* shardManager.register(config.runnerAddress.value, config.shardGroups) + yield* snowflakeGen.setMachineId(machineId) + } + + yield* stopShardManagerTimeout + + yield* Effect.logDebug("Subscribing to sharding events") + const queue = yield* shardManager.shardingEvents(config.runnerAddress) + const startedLatch = yield* Deferred.make() + + const eventsFiber = yield* Effect.gen(function*() { + while (true) { + const events = yield* Queue.takeAll(queue) + for (const event of events) { + yield* Effect.logDebug("Received sharding event", event) + + switch (event._tag) { + case "StreamStarted": { + yield* Deferred.done(startedLatch, Exit.void) + break + } + case "ShardsAssigned": { + for (const shard of event.shards) { + MutableHashMap.set(shardAssignments, shard, event.address) + } + if (!MutableRef.get(isShutdown) && isLocalRunner(event.address)) { + for (const shardId of event.shards) { + if (MutableHashSet.has(selfShards, shardId)) continue + MutableHashSet.add(selfShards, shardId) + } + yield* activeShardsLatch.open + } + break + } + case "ShardsUnassigned": { + for (const shard of event.shards) { + MutableHashMap.remove(shardAssignments, shard) + } + if (isLocalRunner(event.address)) { + for (const shard of event.shards) { + MutableHashSet.remove(selfShards, shard) + } + yield* activeShardsLatch.open + } + break + } + } + } + } + }).pipe( + Deferred.into(startedLatch), + Effect.forkScoped({ startImmediately: true }) + ) + + // Wait for the stream to be established + yield* Deferred.await(startedLatch) + + // perform a full sync every config.refreshAssignmentsInterval + const syncFiber = yield* syncAssignments.pipe( + Effect.andThen(Effect.sleep(config.refreshAssignmentsInterval)), + Effect.forever, + Effect.forkScoped({ startImmediately: true }) + ) + + yield* Fiber.awaitAll([eventsFiber, syncFiber]).pipe( + Effect.flatMap(Exit.asVoidAll) + ) + }).pipe( + Effect.scoped, + Effect.catchCause((cause) => Effect.logDebug(cause)), + Effect.flatMap(() => startShardManagerTimeout), + Effect.repeat( + Schedule.exponential(1000).pipe( + Schedule.either(Schedule.spaced(10_000)) + ) + ), + Effect.annotateLogs({ + package: "@effect/cluster", + module: "Sharding", + fiber: "ShardManager sync", + runner: config.runnerAddress + }), + Effect.interruptible, + Effect.forkIn(shardingScope) + ) + + const syncAssignments = Effect.gen(function*() { + const assignments = yield* shardManager.getAssignments + yield* Effect.logDebug("Received shard assignments", assignments) + + for (const [shardId, runner] of assignments) { + if (Option.isNone(runner)) { + MutableHashMap.remove(shardAssignments, shardId) + MutableHashSet.remove(selfShards, shardId) + continue + } + + MutableHashMap.set(shardAssignments, shardId, runner.value) + + if (!isLocalRunner(runner.value)) { + MutableHashSet.remove(selfShards, shardId) + continue + } + if (MutableRef.get(isShutdown) || MutableHashSet.has(selfShards, shardId)) { + continue + } + MutableHashSet.add(selfShards, shardId) + } + + yield* activeShardsLatch.open + }) + + // --- Clients --- + + type ClientRequestEntry = { + readonly rpc: Rpc.AnyWithProps + readonly services: ServiceMap.ServiceMap + lastChunkId?: Snowflake.Snowflake + } + const clientRequests = new Map() + + const clients: ResourceMap< + Entity, + (entityId: string) => RpcClient.RpcClient< + any, + MailboxFull | AlreadyProcessingMessage | EntityNotManagedByRunner + >, + never + > = yield* ResourceMap.make(Effect.fnUntraced(function*(entity: Entity) { + const client = yield* RpcClient.makeNoSerialization(entity.protocol, { + spanPrefix: `${entity.type}.client`, + disableTracing: !ServiceMap.get(entity.protocol.annotations, ClusterSchema.ClientTracingEnabled), + supportsAck: true, + generateRequestId: () => RequestId(snowflakeGen.unsafeNext()), + flatten: true, + onFromClient(options): Effect.Effect< + void, + MailboxFull | AlreadyProcessingMessage | EntityNotManagedByRunner | PersistenceError + > { + const address = ServiceMap.unsafeGet(options.context, ClientAddressTag) + switch (options.message._tag) { + case "Request": { + const fiber = Fiber.getCurrent()! + const id = Snowflake.Snowflake(options.message.id) + const rpc = entity.protocol.requests.get(options.message.tag)! + let respond: (reply: Reply.Reply) => Effect.Effect + if (!options.discard) { + const entry: ClientRequestEntry = { + rpc: rpc as any, + services: fiber.services + } + clientRequests.set(id, entry) + respond = makeClientRespond(entry, client.write) + } else { + respond = clientRespondDiscard + } + return sendOutgoing( + new Message.OutgoingRequest({ + envelope: Envelope.makeRequest({ + requestId: id, + address, + tag: options.message.tag, + payload: options.message.payload, + headers: options.message.headers, + traceId: options.message.traceId, + spanId: options.message.spanId, + sampled: options.message.sampled + }), + lastReceivedReply: Option.none(), + rpc, + services: fiber.services as ServiceMap.ServiceMap, + respond + }), + options.discard + ) + } + case "Ack": { + const requestId = Snowflake.Snowflake(options.message.requestId) + const entry = clientRequests.get(requestId) + if (!entry) return Effect.void + return sendOutgoing( + new Message.OutgoingEnvelope({ + envelope: new Envelope.AckChunk({ + id: snowflakeGen.unsafeNext(), + address, + requestId, + replyId: entry.lastChunkId! + }), + rpc: entry.rpc + }), + false + ) + } + case "Interrupt": { + const requestId = Snowflake.Snowflake(options.message.requestId) + const entry = clientRequests.get(requestId)! + if (!entry) return Effect.void + clientRequests.delete(requestId) + if (ServiceMap.get(entry.rpc.annotations, Uninterruptible)) { + return Effect.void + } + // for durable messages, we ignore interrupts on shutdown or as a + // result of a shard being resassigned + const isTransientInterrupt = MutableRef.get(isShutdown) || + options.message.interruptors.some((id) => internalInterruptors.has(id)) + if (isTransientInterrupt && ServiceMap.get(entry.rpc.annotations, Persisted)) { + return Effect.void + } + return Effect.ignore(sendOutgoing( + new Message.OutgoingEnvelope({ + envelope: new Envelope.Interrupt({ + id: snowflakeGen.unsafeNext(), + address, + requestId + }), + rpc: entry.rpc + }), + false, + 3 + )) + } + } + return Effect.void + } + }) + + yield* Scope.addFinalizer( + yield* Effect.scope, + Effect.withFiber((fiber) => { + internalInterruptors.add(fiber.id) + return Effect.void + }) + ) + + return (entityId: string) => { + const id = makeEntityId(entityId) + const address = ClientAddressTag.serviceMap(makeEntityAddress({ + shardId: getShardId(id, entity.getShardGroup(entityId as EntityId)), + entityId: id, + entityType: entity.type + })) + const clientFn = function(tag: string, payload: any, options?: { + readonly context?: ServiceMap.ServiceMap + }) { + const context = options?.context ? ServiceMap.merge(options.context, address) : address + return client.client(tag, payload, { + ...options, + context + }) + } + const proxyClient: any = {} + return new Proxy(proxyClient, { + has(_, p) { + return entity.protocol.requests.has(p as string) + }, + get(target, p) { + if (p in target) { + return target[p] + } else if (!entity.protocol.requests.has(p as string)) { + return undefined + } + return target[p] = (payload: any, options?: {}) => clientFn(p as string, payload, options) + } + }) + } + })) + + const makeClient = (entity: Entity): Effect.Effect< + ( + entityId: string + ) => RpcClient.RpcClient.From + > => clients.get(entity) as any + + const clientRespondDiscard = (_reply: Reply.Reply) => Effect.void + + const makeClientRespond = ( + entry: ClientRequestEntry, + write: (reply: FromServer) => Effect.Effect + ) => + (reply: Reply.Reply) => { + switch (reply._tag) { + case "Chunk": { + entry.lastChunkId = reply.id + return write({ + _tag: "Chunk", + clientId: 0, + requestId: RequestId(reply.requestId), + values: reply.values + }) + } + case "WithExit": { + clientRequests.delete(reply.requestId) + return write({ + _tag: "Exit", + clientId: 0, + requestId: RequestId(reply.requestId), + exit: reply.exit + }) + } + } + } + + // --- Entities --- + + const services = yield* Effect.services() + const reaper = yield* EntityReaper + const registerEntity: Sharding["Service"]["registerEntity"] = Effect.fnUntraced( + function*(entity, build, options) { + if (Option.isNone(config.runnerAddress) || entityManagers.has(entity.type)) return + const scope = yield* Scope.make() + const manager = yield* EntityManager.make(entity, build, { + ...options, + storage, + runnerAddress: config.runnerAddress.value, + sharding + }).pipe( + Effect.provideServices(services.pipe( + ServiceMap.add(EntityReaper, reaper), + ServiceMap.add(Scope.Scope, scope), + ServiceMap.add(Snowflake.Generator, snowflakeGen) + )) + ) as Effect.Effect + entityManagers.set(entity.type, { + entity, + scope, + manager + }) + + yield* Scope.addFinalizer(scope, Effect.sync(() => entityManagers.delete(entity.type))) + yield* PubSub.publish(events, EntityRegistered({ entity })) + } + ) + + yield* Scope.addFinalizerExit( + shardingScope, + (exit) => + Effect.forEach( + entityManagers.values(), + (state) => + Effect.catchCause(Scope.close(state.scope, exit), (cause) => + Effect.annotateLogs(Effect.logError("Error closing entity manager", cause), { + entity: state.entity.type + })), + { concurrency: "unbounded", discard: true } + ) + ) + + // --- Finalization --- + + if (Option.isSome(config.runnerAddress)) { + const selfAddress = config.runnerAddress.value + // Unregister runner from shard manager when scope is closed + yield* Scope.addFinalizer( + shardingScope, + Effect.gen(function*() { + yield* Effect.logDebug("Unregistering runner from shard manager", selfAddress) + yield* shardManager.unregister(selfAddress).pipe( + Effect.catchCause((cause) => Effect.logError("Error calling unregister with shard manager", cause)) + ) + yield* clearSelfShards + }) + ) + } + + yield* Scope.addFinalizer( + shardingScope, + Effect.withFiber((fiber) => { + MutableRef.set(isShutdown, true) + internalInterruptors.add(fiber.id) + return Effect.void + }) + ) + + const activeEntityCount = Effect.gen(function*() { + let count = 0 + for (const state of entityManagers.values()) { + count += yield* state.manager.activeEntityCount + } + return count + }) + + const sharding = Sharding.of({ + getRegistrationEvents, + getShardId, + isShutdown: Effect.sync(() => MutableRef.get(isShutdown)), + registerEntity, + registerSingleton, + makeClient, + send: sendLocal, + sendOutgoing: (message, discard) => sendOutgoing(message, discard), + notify: (message) => notifyLocal(message, false), + activeEntityCount, + pollStorage: storageReadLatch.open, + reset + }) + + return sharding +}) + +/** + * @since 4.0.0 + * @category layers + */ +export const layer: Layer.Layer< + Sharding, + never, + ShardingConfig | Runners | ShardManagerClient | MessageStorage.MessageStorage | ShardStorage +> = Layer.effect(Sharding)(make).pipe( + Layer.provide([Snowflake.layerGenerator, EntityReaper.layer]) +) + +// Utilities + +const ClientAddressTag = ServiceMap.Key("effect/cluster/Sharding/ClientAddress") diff --git a/packages/effect/src/unstable/cluster/ShardingConfig.ts b/packages/effect/src/unstable/cluster/ShardingConfig.ts new file mode 100644 index 0000000000..12c28aff8c --- /dev/null +++ b/packages/effect/src/unstable/cluster/ShardingConfig.ts @@ -0,0 +1,244 @@ +/** + * @since 4.0.0 + */ +import * as Config from "../../config/Config.ts" +import * as ConfigProvider from "../../config/ConfigProvider.ts" +import * as Option from "../../data/Option.ts" +import * as Effect from "../../Effect.ts" +import * as Layer from "../../Layer.ts" +import * as Schema from "../../schema/Schema.ts" +import * as ServiceMap from "../../ServiceMap.ts" +import type { DurationInput } from "../../time/Duration.ts" +import * as Duration from "../../time/Duration.ts" +import { RunnerAddress } from "./RunnerAddress.ts" + +/** + * Represents the configuration for the `Sharding` service on a given runner. + * + * @since 4.0.0 + * @category models + */ +export class ShardingConfig extends ServiceMap.Key + /** + * The listen address for the current runner. + * + * Defaults to the `runnerAddress`. + */ + readonly runnerListenAddress: Option.Option + /** + * The version of the current runner. + */ + readonly serverVersion: number + /** + * The shard groups that are assigned to this runner. + * + * Defaults to `["default"]`. + */ + readonly shardGroups: ReadonlyArray + /** + * The number of shards to allocate per shard group. + * + * **Note**: this value should be consistent across all runners. + */ + readonly shardsPerGroup: number + /** + * The address of the shard manager. + */ + readonly shardManagerAddress: RunnerAddress + /** + * If the shard manager is unavailable for this duration, all the shard + * assignments will be reset. + */ + readonly shardManagerUnavailableTimeout: DurationInput + /** + * The default capacity of the mailbox for entities. + */ + readonly entityMailboxCapacity: number | "unbounded" + /** + * The maximum duration of inactivity (i.e. without receiving a message) + * after which an entity will be interrupted. + */ + readonly entityMaxIdleTime: DurationInput + /** + * The maximum duration of time to wait for an entity to terminate. + * + * By default this is set to 15 seconds to stay within kubernetes defaults. + */ + readonly entityTerminationTimeout: DurationInput + /** + * The interval at which to poll for unprocessed messages from storage. + */ + readonly entityMessagePollInterval: DurationInput + /** + * The interval at which to poll for client replies from storage. + */ + readonly entityReplyPollInterval: DurationInput + readonly refreshAssignmentsInterval: DurationInput + /** + * The interval to retry a send if EntityNotAssignedToRunner is returned. + */ + readonly sendRetryInterval: DurationInput + // readonly unhealthyRunnerReportInterval: Duration.Duration + /** + * Simulate serialization and deserialization to remote runners for local + * entities. + */ + readonly simulateRemoteSerialization: boolean +}>()("effect/cluster/ShardingConfig") {} + +const defaultRunnerAddress = RunnerAddress.makeSync({ host: "localhost", port: 34431 }) + +/** + * @since 4.0.0 + * @category defaults + */ +export const defaults: ShardingConfig["Service"] = { + runnerAddress: Option.some(defaultRunnerAddress), + runnerListenAddress: Option.none(), + serverVersion: 1, + shardsPerGroup: 300, + shardManagerAddress: RunnerAddress.makeSync({ host: "localhost", port: 8080 }), + shardManagerUnavailableTimeout: Duration.minutes(10), + shardGroups: ["default"], + entityMailboxCapacity: 4096, + entityMaxIdleTime: Duration.minutes(1), + entityTerminationTimeout: Duration.seconds(15), + entityMessagePollInterval: Duration.seconds(10), + entityReplyPollInterval: Duration.millis(200), + sendRetryInterval: Duration.millis(100), + refreshAssignmentsInterval: Duration.minutes(5), + simulateRemoteSerialization: true +} + +/** + * @since 4.0.0 + * @category Layers + */ +export const layer = (options?: Partial): Layer.Layer => + Layer.succeed(ShardingConfig)({ ...defaults, ...options }) + +/** + * @since 4.0.0 + * @category defaults + */ +export const layerDefaults: Layer.Layer = layer() + +/** + * @since 4.0.0 + * @category Config + */ +export const config: Config.Config = Config.all({ + runnerAddress: Config.all({ + host: Config.string("host").pipe( + Config.withDefault(() => defaultRunnerAddress.host) + // Config.withDescription("The hostname or IP address of the runner.") + ), + port: Config.int("port").pipe( + Config.withDefault(() => defaultRunnerAddress.port) + // Config.withDescription("The port used for inter-runner communication.") + ) + }).pipe(Config.map((options) => RunnerAddress.makeSync(options)), Config.option), + runnerListenAddress: Config.all({ + host: Config.string("listenHost"), + // Config.withDescription("The host to listen on.") + port: Config.int("listenPort").pipe( + Config.withDefault(() => defaultRunnerAddress.port) + // Config.withDescription("The port to listen on.") + ) + }).pipe(Config.map((options) => RunnerAddress.makeSync(options)), Config.option), + serverVersion: Config.int("serverVersion").pipe( + Config.withDefault(() => defaults.serverVersion) + // Config.withDescription("The version of the current runner.") + ), + shardGroups: Config.schema(Schema.Array(Schema.String), "shardGroups").pipe( + Config.withDefault(() => ["default"]) + // Config.withDescription("The shard groups that are assigned to this runner.") + ), + shardsPerGroup: Config.int("shardsPerGroup").pipe( + Config.withDefault(() => defaults.shardsPerGroup) + // Config.withDescription("The number of shards to allocate per shard group.") + ), + shardManagerAddress: Config.all({ + host: Config.string("shardManagerHost").pipe( + Config.withDefault(() => defaults.shardManagerAddress.host) + // Config.withDescription("The host of the shard manager.") + ), + port: Config.int("shardManagerPort").pipe( + Config.withDefault(() => defaults.shardManagerAddress.port) + // Config.withDescription("The port of the shard manager.") + ) + }).pipe(Config.map((options) => RunnerAddress.makeSync(options))), + shardManagerUnavailableTimeout: Config.duration("shardManagerUnavailableTimeout").pipe( + Config.withDefault(() => defaults.shardManagerUnavailableTimeout) + // Config.withDescription( + // "If the shard is unavilable for this duration, all the shard assignments will be reset." + // ) + ), + entityMailboxCapacity: Config.int("entityMailboxCapacity").pipe( + Config.withDefault(() => defaults.entityMailboxCapacity) + // Config.withDescription("The default capacity of the mailbox for entities.") + ), + entityMaxIdleTime: Config.duration("entityMaxIdleTime").pipe( + Config.withDefault(() => defaults.entityMaxIdleTime) + // Config.withDescription( + // "The maximum duration of inactivity (i.e. without receiving a message) after which an entity will be interrupted." + // ) + ), + entityTerminationTimeout: Config.duration("entityTerminationTimeout").pipe( + Config.withDefault(() => defaults.entityTerminationTimeout) + // Config.withDescription("The maximum duration of time to wait for an entity to terminate.") + ), + entityMessagePollInterval: Config.duration("entityMessagePollInterval").pipe( + Config.withDefault(() => defaults.entityMessagePollInterval) + // Config.withDescription("The interval at which to poll for unprocessed messages from storage.") + ), + entityReplyPollInterval: Config.duration("entityReplyPollInterval").pipe( + Config.withDefault(() => defaults.entityReplyPollInterval) + // Config.withDescription("The interval at which to poll for client replies from storage.") + ), + sendRetryInterval: Config.duration("sendRetryInterval").pipe( + Config.withDefault(() => defaults.sendRetryInterval) + // Config.withDescription("The interval to retry a send if EntityNotManagedByRunner is returned.") + ), + refreshAssignmentsInterval: Config.duration("refreshAssignmentsInterval").pipe( + Config.withDefault(() => defaults.refreshAssignmentsInterval) + // Config.withDescription("The interval at which to refresh shard assignments.") + ), + simulateRemoteSerialization: Config.boolean("simulateRemoteSerialization").pipe( + Config.withDefault(() => defaults.simulateRemoteSerialization) + // Config.withDescription("Simulate serialization and deserialization to remote runners for local entities.") + ) +}) + +/** + * @since 4.0.0 + * @category Config + */ +export const configFromEnv = config.asEffect().pipe( + Effect.provideService( + ConfigProvider.ConfigProvider, + ConfigProvider.fromEnv().pipe( + ConfigProvider.constantCase + ) + ) +) + +/** + * @since 4.0.0 + * @category Layers + */ +export const layerFromEnv = (options?: Partial | undefined): Layer.Layer< + ShardingConfig, + Config.ConfigError +> => + Layer.effect(ShardingConfig)( + options ? Effect.map(configFromEnv, (config) => ({ ...config, ...options })) : configFromEnv + ) diff --git a/packages/effect/src/unstable/cluster/ShardingRegistrationEvent.ts b/packages/effect/src/unstable/cluster/ShardingRegistrationEvent.ts new file mode 100644 index 0000000000..0151f25df1 --- /dev/null +++ b/packages/effect/src/unstable/cluster/ShardingRegistrationEvent.ts @@ -0,0 +1,61 @@ +/** + * @since 4.0.0 + */ +import * as Data from "../../data/Data.ts" +import type { Entity } from "./Entity.ts" +import type { SingletonAddress } from "./SingletonAddress.ts" + +/** + * Represents events that can occur when a runner registers entities or singletons. + * + * @since 4.0.0 + * @category models + */ +export type ShardingRegistrationEvent = + | EntityRegistered + | SingletonRegistered + +/** + * Represents an event that occurs when a new entity is registered with a runner. + * + * @since 4.0.0 + * @category models + */ +export interface EntityRegistered { + readonly _tag: "EntityRegistered" + readonly entity: Entity +} + +/** + * Represents an event that occurs when a new singleton is registered with a + * runner. + * + * @since 4.0.0 + * @category models + */ +export interface SingletonRegistered { + readonly _tag: "SingletonRegistered" + readonly address: SingletonAddress +} + +/** + * @since 4.0.0 + * @category pattern matching + */ +export const { + /** + * @since 4.0.0 + * @category pattern matching + */ + $match: match, + /** + * @since 4.0.0 + * @category constructors + */ + EntityRegistered, + /** + * @since 4.0.0 + * @category constructors + */ + SingletonRegistered +} = Data.taggedEnum() diff --git a/packages/effect/src/unstable/cluster/Singleton.ts b/packages/effect/src/unstable/cluster/Singleton.ts new file mode 100644 index 0000000000..f1b650a668 --- /dev/null +++ b/packages/effect/src/unstable/cluster/Singleton.ts @@ -0,0 +1,23 @@ +/** + * @since 4.0.0 + */ +import * as Effect from "../../Effect.ts" +import * as Layer from "../../Layer.ts" +import type { Scope } from "../../Scope.ts" +import { Sharding } from "./Sharding.ts" + +/** + * @since 4.0.0 + * @category constructors + */ +export const make = ( + name: string, + run: Effect.Effect, + options?: { + readonly shardGroup?: string | undefined + } +): Layer.Layer> => + Layer.effectDiscard(Effect.gen(function*() { + const sharding = yield* Sharding + yield* sharding.registerSingleton(name, run, options) + })) diff --git a/packages/effect/src/unstable/cluster/SingletonAddress.ts b/packages/effect/src/unstable/cluster/SingletonAddress.ts new file mode 100644 index 0000000000..fa817a589a --- /dev/null +++ b/packages/effect/src/unstable/cluster/SingletonAddress.ts @@ -0,0 +1,47 @@ +/** + * @since 4.0.0 + */ +import * as Equal from "../../interfaces/Equal.ts" +import * as Hash from "../../interfaces/Hash.ts" +import * as Schema from "../../schema/Schema.ts" +import { ShardId } from "./ShardId.ts" + +/** + * @since 4.0.0 + * @category Address + */ +export const TypeId: TypeId = "~effect/cluster/SingletonAddress" + +/** + * @since 4.0.0 + * @category Address + */ +export type TypeId = "~effect/cluster/SingletonAddress" + +/** + * Represents the unique address of an singleton within the cluster. + * + * @since 4.0.0 + * @category Address + */ +export class SingletonAddress extends Schema.Class(TypeId)({ + shardId: ShardId, + name: Schema.String +}) { + /** + * @since 4.0.0 + */ + readonly [TypeId] = TypeId; + /** + * @since 4.0.0 + */ + [Hash.symbol]() { + return Hash.cached(this, () => Hash.string(`${this.name}:${this.shardId.toString()}`)) + } + /** + * @since 4.0.0 + */ + [Equal.symbol](that: SingletonAddress): boolean { + return this.name === that.name && this.shardId[Equal.symbol](that.shardId) + } +} diff --git a/packages/effect/src/unstable/cluster/Snowflake.ts b/packages/effect/src/unstable/cluster/Snowflake.ts new file mode 100644 index 0000000000..fb1979e7df --- /dev/null +++ b/packages/effect/src/unstable/cluster/Snowflake.ts @@ -0,0 +1,196 @@ +/** + * @since 4.0.0 + */ +import type * as Brand from "../../data/Brand.ts" +import * as Effect from "../../Effect.ts" +import { identity } from "../../Function.ts" +import * as Layer from "../../Layer.ts" +import * as Schema from "../../schema/Schema.ts" +import * as Transformation from "../../schema/Transformation.ts" +import * as ServiceMap from "../../ServiceMap.ts" +import { Clock } from "../../time/Clock.ts" +import * as DateTime from "../../time/DateTime.ts" +import type { MachineId } from "./MachineId.ts" + +/** + * @since 4.0.0 + * @category Symbols + */ +export const TypeId: TypeId = "~effect/cluster/Snowflake" + +/** + * @since 4.0.0 + * @category Symbols + */ +export type TypeId = "~effect/cluster/Snowflake" + +/** + * @since 4.0.0 + * @category Models + */ +export type Snowflake = Brand.Branded + +/** + * @since 4.0.0 + * @category Models + */ +export const Snowflake = (input: string | bigint): Snowflake => + typeof input === "string" ? BigInt(input) as Snowflake : input as Snowflake + +/** + * @since 4.0.0 + * @category Models + */ +export declare namespace Snowflake { + /** + * @since 4.0.0 + * @category Models + */ + export interface Parts { + readonly timestamp: number + readonly machineId: MachineId + readonly sequence: number + } + + /** + * @since 4.0.0 + * @category Models + */ + export interface Generator { + readonly unsafeNext: () => Snowflake + readonly setMachineId: (machineId: MachineId) => Effect.Effect + } +} + +/** + * @since 4.0.0 + * @category Schemas + */ +export const SnowflakeFromBigInt: Schema.Codec = Schema.BigInt.pipe( + Schema.brand(TypeId) +) + +/** + * @since 4.0.0 + * @category Schemas + */ +export const SnowflakeFromString: Schema.Codec = Schema.String.pipe( + Schema.decodeTo(SnowflakeFromBigInt, Transformation.bigintFromString) +) + +/** + * @since 4.0.0 + * @category Epoch + */ +export const constEpochMillis: number = Date.UTC(2025, 0, 1) + +const sinceUnixEpoch = constEpochMillis - Date.UTC(1970, 0, 1) +const constBigInt12 = BigInt(12) +const constBigInt22 = BigInt(22) +const constBigInt1024 = BigInt(1024) +const constBigInt4096 = BigInt(4096) + +/** + * @since 4.0.0 + * @category constructors + */ +export const make = (options: { + readonly machineId: MachineId + readonly sequence: number + readonly timestamp: number +}): Snowflake => + (BigInt(options.timestamp - constEpochMillis) << constBigInt22 + | (BigInt(options.machineId % 1024) << constBigInt12) + | BigInt(options.sequence % 4096)) as Snowflake + +/** + * @since 4.0.0 + * @category Parts + */ +export const timestamp = (snowflake: Snowflake): number => Number(snowflake >> constBigInt22) + sinceUnixEpoch + +/** + * @since 4.0.0 + * @category Parts + */ +export const dateTime = (snowflake: Snowflake): DateTime.Utc => DateTime.unsafeMake(timestamp(snowflake)) + +/** + * @since 4.0.0 + * @category Parts + */ +export const machineId = (snowflake: Snowflake): MachineId => + Number((snowflake >> constBigInt12) % constBigInt1024) as MachineId + +/** + * @since 4.0.0 + * @category Parts + */ +export const sequence = (snowflake: Snowflake): number => Number(snowflake % constBigInt4096) + +/** + * @since 4.0.0 + * @category Parts + */ +export const toParts = (snowflake: Snowflake): Snowflake.Parts => ({ + timestamp: timestamp(snowflake), + machineId: machineId(snowflake), + sequence: sequence(snowflake) +}) + +/** + * @since 4.0.0 + * @category Generator + */ +export const makeGenerator: Effect.Effect = Effect.gen(function*() { + let machineId = Math.floor(Math.random() * 1024) as MachineId + const clock = yield* Clock + + let sequence = 0 + let sequenceAt = Math.floor(clock.unsafeCurrentTimeMillis()) + + return identity({ + setMachineId: (newMachineId) => + Effect.sync(() => { + machineId = newMachineId + }), + unsafeNext() { + let now = Math.floor(clock.unsafeCurrentTimeMillis()) + + // account for clock drift, only allow time to move forward + if (now < sequenceAt) { + now = sequenceAt + } else if (now > sequenceAt) { + // reset sequence if we're in a new millisecond + sequence = 0 + sequenceAt = now + } else if (sequence >= 1024) { + // if we've hit the max sequence for this millisecond, go to the next + // millisecond + sequenceAt++ + sequence = 0 + } + + return make({ + machineId, + sequence: sequence++, + timestamp: sequenceAt + }) + } + }) +}) + +/** + * @since 4.0.0 + * @category Generator + */ +export class Generator extends ServiceMap.Key< + Generator, + Snowflake.Generator +>()("effect/cluster/Snowflake/Generator") {} + +/** + * @since 4.0.0 + * @category Generator + */ +export const layerGenerator: Layer.Layer = Layer.effect(Generator)(makeGenerator) diff --git a/packages/effect/src/unstable/cluster/SocketRunner.ts b/packages/effect/src/unstable/cluster/SocketRunner.ts new file mode 100644 index 0000000000..470b87e321 --- /dev/null +++ b/packages/effect/src/unstable/cluster/SocketRunner.ts @@ -0,0 +1,54 @@ +/** + * @since 4.0.0 + */ +import * as Effect from "../../Effect.ts" +import * as Layer from "../../Layer.ts" +import type * as RpcSerialization from "../rpc/RpcSerialization.ts" +import * as RpcServer from "../rpc/RpcServer.ts" +import { SocketServer } from "../socket/SocketServer.ts" +import type { MessageStorage } from "./MessageStorage.ts" +import type * as Runners from "./Runners.ts" +import * as RunnerServer from "./RunnerServer.ts" +import type * as Sharding from "./Sharding.ts" +import type { ShardingConfig } from "./ShardingConfig.ts" +import type * as ShardStorage from "./ShardStorage.ts" + +const withLogAddress = (layer: Layer.Layer): Layer.Layer => + Layer.effectDiscard(Effect.gen(function*() { + const server = yield* SocketServer + const address = server.address._tag === "UnixAddress" + ? server.address.path + : `${server.address.hostname}:${server.address.port}` + yield* Effect.annotateLogs(Effect.logInfo(`Listening on: ${address}`), { + package: "@effect/cluster", + service: "Runner" + }) + })).pipe(Layer.provideMerge(layer)) + +/** + * @since 4.0.0 + * @category Layers + */ +export const layer: Layer.Layer< + Sharding.Sharding | Runners.Runners, + never, + | Runners.RpcClientProtocol + | ShardingConfig + | RpcSerialization.RpcSerialization + | SocketServer + | MessageStorage + | ShardStorage.ShardStorage +> = RunnerServer.layerWithClients.pipe( + withLogAddress, + Layer.provide(RpcServer.layerProtocolSocketServer) +) + +/** + * @since 4.0.0 + * @category Layers + */ +export const layerClientOnly: Layer.Layer< + Sharding.Sharding | Runners.Runners, + never, + Runners.RpcClientProtocol | ShardingConfig | MessageStorage +> = RunnerServer.layerClientOnly diff --git a/packages/effect/src/unstable/cluster/SocketShardManager.ts b/packages/effect/src/unstable/cluster/SocketShardManager.ts new file mode 100644 index 0000000000..badb3d439c --- /dev/null +++ b/packages/effect/src/unstable/cluster/SocketShardManager.ts @@ -0,0 +1,48 @@ +/** + * @since 4.0.0 + */ +import * as Effect from "../../Effect.ts" +import * as Layer from "../../Layer.ts" +import type { RpcSerialization } from "../rpc/RpcSerialization.ts" +import * as RpcServer from "../rpc/RpcServer.ts" +import { SocketServer } from "../socket/SocketServer.ts" +import * as MessageStorage from "./MessageStorage.ts" +import type { RunnerHealth } from "./RunnerHealth.ts" +import * as Runners from "./Runners.ts" +import type { ShardingConfig } from "./ShardingConfig.ts" +import * as ShardManager from "./ShardManager.ts" +import type { ShardStorage } from "./ShardStorage.ts" + +const withLogAddress = (layer: Layer.Layer): Layer.Layer => + Layer.effectDiscard(Effect.gen(function*() { + const server = yield* SocketServer + const address = server.address._tag === "UnixAddress" + ? server.address.path + : `${server.address.hostname}:${server.address.port}` + yield* Effect.annotateLogs(Effect.logInfo(`Listening on: ${address}`), { + package: "@effect/cluster", + service: "ShardManager" + }) + })).pipe(Layer.provideMerge(layer)) + +/** + * @since 4.0.0 + * @category Layers + */ +export const layer: Layer.Layer< + ShardManager.ShardManager, + never, + | ShardStorage + | SocketServer + | Runners.RpcClientProtocol + | RpcSerialization + | RunnerHealth + | ShardManager.Config + | ShardingConfig +> = ShardManager.layerServer.pipe( + withLogAddress, + Layer.provide(RpcServer.layerProtocolSocketServer), + Layer.provideMerge(ShardManager.layer), + Layer.provide(Runners.layerRpc), + Layer.provide(MessageStorage.layerNoop) +) diff --git a/packages/effect/src/unstable/cluster/SqlMessageStorage.ts b/packages/effect/src/unstable/cluster/SqlMessageStorage.ts new file mode 100644 index 0000000000..a69617563e --- /dev/null +++ b/packages/effect/src/unstable/cluster/SqlMessageStorage.ts @@ -0,0 +1,971 @@ +/** + * @since 1.0.0 + */ +import * as Arr from "../../collections/Array.ts" +import * as Option from "../../data/Option.ts" +import * as Effect from "../../Effect.ts" +import * as Layer from "../../Layer.ts" +import * as Schedule from "../../Schedule.ts" +import * as Migrator from "../sql/Migrator.ts" +import * as SqlClient from "../sql/SqlClient.ts" +import type { Row } from "../sql/SqlConnection.ts" +import type { SqlError } from "../sql/SqlError.ts" +import { PersistenceError } from "./ClusterError.ts" +import type * as Envelope from "./Envelope.ts" +import * as MessageStorage from "./MessageStorage.ts" +import { SaveResultEncoded } from "./MessageStorage.ts" +import type * as Reply from "./Reply.ts" +import { ShardId } from "./ShardId.ts" +import type { ShardingConfig } from "./ShardingConfig.ts" +import * as Snowflake from "./Snowflake.ts" + +const withTracerDisabled = Effect.withTracerEnabled(false) + +/** + * @since 1.0.0 + * @category Constructors + */ +export const make = Effect.fnUntraced(function*(options: { + readonly prefix?: string | undefined +}) { + const sql = (yield* SqlClient.SqlClient).withoutTransforms() + const prefix = options?.prefix ?? "cluster" + const table = (name: string) => `${prefix}_${name}` + + yield* Effect.orDie( + Migrator.make({})({ + loader: migrations(options), + table: table("migrations") + }) + ) + + const messageKindAckChunk = sql.literal(String(messageKind.AckChunk)) + const replyKindWithExit = sql.literal(String(replyKind.WithExit)) + + const messagesTable = table("messages") + const messagesTableSql = sql(messagesTable) + + const repliesTable = table("replies") + const repliesTableSql = sql(repliesTable) + + const envelopeToRow = ( + envelope: Envelope.Encoded, + message_id: string | null, + deliver_at: number | null + ): MessageRow => { + switch (envelope._tag) { + case "Request": + return { + id: envelope.requestId, + message_id, + shard_id: ShardId.toString(envelope.address.shardId), + entity_type: envelope.address.entityType, + entity_id: envelope.address.entityId, + kind: messageKind.Request, + tag: envelope.tag, + payload: JSON.stringify(envelope.payload), + headers: JSON.stringify(envelope.headers), + trace_id: envelope.traceId ?? null, + span_id: envelope.spanId ?? null, + sampled: envelope.sampled === undefined + ? null + : supportsBooleans + ? envelope.sampled + : envelope.sampled + ? 1 + : 0, + request_id: envelope.requestId, + reply_id: null, + deliver_at + } + case "AckChunk": + return { + id: envelope.id, + message_id, + shard_id: ShardId.toString(envelope.address.shardId), + entity_type: envelope.address.entityType, + entity_id: envelope.address.entityId, + kind: messageKind.AckChunk, + tag: null, + payload: null, + headers: null, + trace_id: null, + span_id: null, + sampled: null, + request_id: envelope.requestId, + reply_id: envelope.replyId, + deliver_at + } + case "Interrupt": + return { + id: envelope.id, + message_id, + shard_id: ShardId.toString(envelope.address.shardId), + entity_type: envelope.address.entityType, + entity_id: envelope.address.entityId, + kind: messageKind.Interrupt, + payload: null, + tag: null, + headers: null, + trace_id: null, + span_id: null, + sampled: null, + request_id: envelope.requestId, + reply_id: null, + deliver_at + } + } + } + + const replyToRow = (reply: Reply.Encoded): ReplyRow => ({ + id: reply.id, + kind: replyKind[reply._tag], + request_id: reply.requestId, + payload: reply._tag === "WithExit" ? JSON.stringify(reply.exit) : JSON.stringify(reply.values), + sequence: reply._tag === "Chunk" ? reply.sequence : null + }) + + const supportsBooleans = sql.onDialectOrElse({ + mssql: () => false, + sqlite: () => false, + orElse: () => true + }) + + const messageFromRow = (row: MessageRow & ReplyJoinRow): { + readonly envelope: Envelope.Encoded + readonly lastSentReply: Option.Option + } => { + switch (Number(row.kind) as 0 | 1 | 2) { + case 0: + return { + envelope: { + _tag: "Request", + requestId: String(row.id), + address: { + shardId: ShardId.fromStringEncoded(row.shard_id), + entityType: row.entity_type, + entityId: row.entity_id + }, + tag: row.tag!, + payload: JSON.parse(row.payload!), + headers: JSON.parse(row.headers!), + ...(row.trace_id ? + { + traceId: row.trace_id, + spanId: row.span_id!, + sampled: !!row.sampled + } : + {}) + }, + lastSentReply: row.reply_reply_id ? + Option.some({ + _tag: "Chunk", + id: String(row.reply_reply_id), + requestId: String(row.request_id), + sequence: Number(row.reply_sequence!), + values: JSON.parse(row.reply_payload!) + } as any) : + Option.none() + } + case 1: + return { + envelope: { + _tag: "AckChunk", + id: String(row.id), + requestId: String(row.request_id!), + replyId: String(row.reply_id!), + address: { + shardId: ShardId.fromStringEncoded(row.shard_id), + entityType: row.entity_type, + entityId: row.entity_id + } + }, + lastSentReply: Option.none() + } + case 2: + return { + envelope: { + _tag: "Interrupt", + id: String(row.id), + requestId: String(row.request_id!), + address: { + shardId: ShardId.fromStringEncoded(row.shard_id), + entityType: row.entity_type, + entityId: row.entity_id + } + }, + lastSentReply: Option.none() + } + } + } + + const sqlFalse = sql.literal(supportsBooleans ? "FALSE" : "0") + const sqlTrue = sql.literal(supportsBooleans ? "TRUE" : "1") + + const insertEnvelope: ( + row: MessageRow, + message_id: string + ) => Effect.Effect, SqlError> = sql.onDialectOrElse({ + pg: () => (row, message_id) => + sql` + WITH inserted AS ( + INSERT INTO ${messagesTableSql} ${sql.insert(row)} + ON CONFLICT (message_id) DO NOTHING + RETURNING id + ), + existing AS ( + SELECT m.id, r.id as reply_id, r.kind as reply_kind, r.payload as reply_payload, r.sequence as reply_sequence + FROM ${messagesTableSql} m + LEFT JOIN ${repliesTableSql} r ON r.id = m.last_reply_id + WHERE m.message_id = ${message_id} + AND NOT EXISTS (SELECT 1 FROM inserted) + ) + SELECT * FROM existing + `, + mysql: () => (row, message_id) => + sql` + SELECT m.id, r.id as reply_id, r.kind as reply_kind, r.payload as reply_payload, r.sequence as reply_sequence + FROM ${messagesTableSql} m + LEFT JOIN ${repliesTableSql} r ON r.id = m.last_reply_id + WHERE m.message_id = ${message_id}; + INSERT INTO ${messagesTableSql} ${sql.insert(row)} + ON DUPLICATE KEY UPDATE id = id; + `.unprepared.pipe( + // we need 2 queries for mysql, so we need to run them in a + // transaction with retries + sql.withTransaction, + Effect.retry({ times: 3 }), + Effect.map(([rows]) => rows as any as ReadonlyArray) + ), + mssql: () => (row, message_id) => + sql` + MERGE ${messagesTableSql} WITH (HOLDLOCK) AS target + USING (SELECT ${message_id} as message_id) AS source + ON target.message_id = source.message_id + WHEN NOT MATCHED THEN + INSERT ${sql.insert(row)} + OUTPUT + inserted.id, + CASE + WHEN inserted.id IS NULL THEN ( + SELECT r.id, r.kind, r.payload + FROM ${repliesTableSql} r + WHERE r.id = target.last_reply_id + ) + END as reply_id, + CASE + WHEN inserted.id IS NULL THEN ( + SELECT r.kind + FROM ${repliesTableSql} r + WHERE r.id = target.last_reply_id + ) + END as reply_kind, + CASE + WHEN inserted.id IS NULL THEN ( + SELECT r.payload + FROM ${repliesTableSql} r + WHERE r.id = target.last_reply_id + ) + END as reply_payload, + CASE + WHEN inserted.id IS NULL THEN ( + SELECT r.sequence + FROM ${repliesTableSql} r + WHERE r.id = target.last_reply_id + ) + END as reply_sequence; + `, + orElse: () => (row, message_id) => + sql` + SELECT m.id, r.id as reply_id, r.kind as reply_kind, r.payload as reply_payload, r.sequence as reply_sequence + FROM ${messagesTableSql} m + LEFT JOIN ${repliesTableSql} r ON r.id = m.last_reply_id + WHERE m.message_id = ${message_id} + `.pipe( + Effect.tap(sql`INSERT OR IGNORE INTO ${messagesTableSql} ${sql.insert(row)}`), + sql.withTransaction, + Effect.retry({ times: 3 }) + ) + }) + + const fiveMinutesAgo = sql.onDialectOrElse({ + mssql: () => sql.literal(`DATEADD(MINUTE, -5, GETDATE())`), + mysql: () => sql.literal(`NOW() - INTERVAL 5 MINUTE`), + pg: () => sql.literal(`NOW() - INTERVAL '5 minutes'`), + orElse: () => sql.literal(`DATETIME('now', '-5 minute')`) + }) + const sqlNowString = sql.onDialectOrElse({ + pg: () => "NOW()", + mysql: () => "NOW()", + mssql: () => "GETDATE()", + orElse: () => "CURRENT_TIMESTAMP" + }) + const sqlNow = sql.literal(sqlNowString) + + const wrapString = sql.onDialectOrElse({ + mssql: () => (s: string) => `N'${s}'`, + orElse: () => (s: string) => `'${s}'` + }) + + const getUnprocessedMessages = sql.onDialectOrElse({ + pg: () => (shardIds: ReadonlyArray, now: number) => + sql` + UPDATE ${messagesTableSql} m + SET last_read = ${sqlNow} + FROM ( + SELECT m.* + FROM ${messagesTableSql} m + WHERE m.shard_id IN (${sql.literal(shardIds.map(wrapString).join(","))}) + AND NOT EXISTS ( + SELECT 1 FROM ${repliesTableSql} + WHERE request_id = m.request_id + AND (kind = ${replyKindWithExit} OR acked = ${sqlFalse}) + ) + AND m.processed = ${sqlFalse} + AND (m.last_read IS NULL OR m.last_read < ${fiveMinutesAgo}) + AND (m.deliver_at IS NULL OR m.deliver_at <= ${sql.literal(String(now))}) + ORDER BY m.rowid ASC + FOR UPDATE + ) AS ids + LEFT JOIN ${repliesTableSql} r ON r.id = ids.last_reply_id + WHERE m.id = ids.id + RETURNING ids.*, r.id as reply_reply_id, r.kind as reply_kind, r.payload as reply_payload, r.sequence as reply_sequence + `, + orElse: () => (shardIds: ReadonlyArray, now: number) => + sql` + SELECT m.*, r.id as reply_reply_id, r.kind as reply_kind, r.payload as reply_payload, r.sequence as reply_sequence + FROM ${messagesTableSql} m + LEFT JOIN ${repliesTableSql} r ON r.id = m.last_reply_id + WHERE m.shard_id IN (${sql.literal(shardIds.map(wrapString).join(","))}) + AND NOT EXISTS ( + SELECT 1 FROM ${repliesTableSql} + WHERE request_id = m.request_id + AND (kind = ${replyKindWithExit} OR acked = ${sqlFalse}) + ) + AND processed = ${sqlFalse} + AND (m.last_read IS NULL OR m.last_read < ${fiveMinutesAgo}) + AND (m.deliver_at IS NULL OR m.deliver_at <= ${sql.literal(String(now))}) + ORDER BY m.rowid ASC + `.unprepared.pipe( + Effect.tap((rows) => { + if (rows.length === 0) { + return Effect.void + } + return sql` + UPDATE ${messagesTableSql} + SET last_read = ${sqlNow} + WHERE id IN (${sql.literal(rows.map((row) => row.id).join(","))}) + `.unprepared + }), + sql.withTransaction + ) + }) + + return yield* MessageStorage.makeEncoded({ + saveEnvelope: ({ deliverAt, envelope, primaryKey }) => + Effect.suspend(() => { + const row = envelopeToRow(envelope, primaryKey, deliverAt) + let insert = primaryKey + ? insertEnvelope(row, primaryKey) + : Effect.as(sql`INSERT INTO ${messagesTableSql} ${sql.insert(row)}`.unprepared, []) + if (envelope._tag === "AckChunk") { + insert = sql`UPDATE ${repliesTableSql} SET acked = ${sqlTrue} WHERE id = ${envelope.replyId}`.pipe( + Effect.andThen( + sql`UPDATE ${messagesTableSql} SET processed = ${sqlTrue} WHERE processed = ${sqlFalse} AND request_id = ${envelope.requestId} AND kind = ${messageKindAckChunk}` + ), + Effect.andThen(insert), + sql.withTransaction + ) + } + return insert.pipe( + Effect.map((rows) => { + if (rows.length === 0) { + return SaveResultEncoded.Success() + } + const row = rows[0] + return SaveResultEncoded.Duplicate({ + originalId: Snowflake.Snowflake(row.id as any), + lastReceivedReply: row.reply_id ? + Option.some({ + id: String(row.reply_id), + requestId: String(row.id), + _tag: row.reply_kind === replyKind.WithExit ? "WithExit" : "Chunk", + ...(row.reply_kind === replyKind.WithExit + ? { exit: JSON.parse(row.reply_payload as string) } + : { + sequence: Number(row.reply_sequence), + values: JSON.parse(row.reply_payload as string) + }) + } as any) : + Option.none() + }) + }) + ) + }).pipe( + Effect.provideService(SqlClient.SafeIntegers, true), + PersistenceError.refail + ), + + saveReply: (reply) => + Effect.suspend(() => { + const row = replyToRow(reply) + const update = reply._tag === "Chunk" ? + sql`UPDATE ${messagesTableSql} SET last_reply_id = ${reply.id} WHERE id = ${reply.requestId}` : + sql`UPDATE ${messagesTableSql} SET processed = ${sqlTrue}, last_reply_id = ${reply.id} WHERE request_id = ${reply.requestId}` + return update.unprepared.pipe( + Effect.andThen(sql`INSERT INTO ${repliesTableSql} ${sql.insert(row)}`), + sql.withTransaction + ) + }).pipe( + Effect.asVoid, + PersistenceError.refail + ), + + clearReplies: Effect.fnUntraced( + function*(requestId) { + yield* sql`DELETE FROM ${repliesTableSql} WHERE request_id = ${String(requestId)}` + yield* sql`UPDATE ${messagesTableSql} SET processed = ${sqlFalse}, last_reply_id = NULL, last_read = NULL WHERE request_id = ${ + String(requestId) + }` + }, + sql.withTransaction, + PersistenceError.refail + ), + + requestIdForPrimaryKey: (primaryKey) => + sql<{ id: string | bigint }>`SELECT id FROM ${messagesTableSql} WHERE message_id = ${primaryKey}`.pipe( + Effect.map((rows) => + Option.fromUndefinedOr(rows[0]?.id).pipe( + Option.map(Snowflake.Snowflake) + ) + ), + Effect.provideService(SqlClient.SafeIntegers, true), + PersistenceError.refail + ), + + repliesFor: (requestIds) => + // replies where: + // - the request is in the list + // - the kind is WithExit + // - or the kind is Chunk and has not been acked yet + sql` + SELECT id, kind, request_id, payload, sequence + FROM ${repliesTableSql} + WHERE request_id IN (${sql.literal(requestIds.join(","))}) + AND ( + kind = ${replyKindWithExit} + OR ( + kind IS NULL + AND acked = ${sqlFalse} + ) + ) + ORDER BY rowid ASC + `.unprepared.pipe( + Effect.provideService(SqlClient.SafeIntegers, true), + Effect.map(Arr.map(replyFromRow)), + PersistenceError.refail, + withTracerDisabled + ), + + repliesForUnfiltered: (requestIds) => + sql` + SELECT id, kind, request_id, payload, sequence + FROM ${repliesTableSql} + WHERE request_id IN (${sql.literal(requestIds.join(","))}) + ORDER BY rowid ASC + `.unprepared.pipe( + Effect.provideService(SqlClient.SafeIntegers, true), + Effect.map(Arr.map(replyFromRow)), + PersistenceError.refail, + withTracerDisabled + ), + + unprocessedMessages: Effect.fnUntraced( + function*(shardIds, now) { + const rows = yield* getUnprocessedMessages(shardIds, now) + if (rows.length === 0) { + return [] + } + const messages: Array<{ + readonly envelope: Envelope.Encoded + readonly lastSentReply: Option.Option + }> = new Array(rows.length) + const ids = new Array(rows.length) + for (let i = 0; i < rows.length; i++) { + messages[i] = messageFromRow(rows[i]) + ids[i] = String(rows[i].id) + } + return messages + }, + Effect.provideService(SqlClient.SafeIntegers, true), + PersistenceError.refail, + withTracerDisabled + ), + + unprocessedMessagesById(ids, now) { + const idArr = Array.from(ids, (id) => String(id)) + return sql` + SELECT m.*, r.id as reply_id, r.kind as reply_kind, r.payload as reply_payload, r.sequence as reply_sequence + FROM ${messagesTableSql} m + LEFT JOIN ${repliesTableSql} r ON r.id = m.last_reply_id + WHERE m.id IN (${sql.literal(idArr.join(","))}) + AND NOT EXISTS ( + SELECT 1 FROM ${repliesTableSql} + WHERE request_id = m.request_id + AND (kind = ${replyKindWithExit} OR acked = ${sqlFalse}) + ) + AND m.processed = ${sqlFalse} + AND (m.deliver_at IS NULL OR m.deliver_at <= ${sql.literal(String(now))}) + ORDER BY m.rowid ASC + `.unprepared.pipe( + Effect.map(Arr.map(messageFromRow)), + Effect.provideService(SqlClient.SafeIntegers, true), + PersistenceError.refail, + withTracerDisabled + ) + }, + + resetAddress: (address) => + sql` + UPDATE ${messagesTableSql} + SET last_read = NULL + WHERE processed = ${sqlFalse} + AND shard_id = ${address.shardId.toString()} + AND entity_type = ${address.entityType} + AND entity_id = ${address.entityId} + `.pipe( + Effect.asVoid, + PersistenceError.refail, + withTracerDisabled + ), + + clearAddress: (address) => + sql` + DELETE FROM ${repliesTableSql} + WHERE request_id IN ( + SELECT id FROM ${messagesTableSql} + WHERE entity_type = ${address.entityType} + AND entity_id = ${address.entityId} + ) + `.pipe( + Effect.andThen( + sql` + DELETE FROM ${messagesTableSql} + WHERE entity_type = ${address.entityType} + AND entity_id = ${address.entityId} + ` + ), + sql.withTransaction, + Effect.asVoid, + PersistenceError.refail, + withTracerDisabled + ), + + resetShards: (shardIds) => + sql` + UPDATE ${messagesTableSql} + SET last_read = NULL + WHERE processed = ${sqlFalse} + AND shard_id IN (${sql.literal(shardIds.map(wrapString).join(","))}) + `.pipe( + Effect.asVoid, + PersistenceError.refail, + withTracerDisabled + ) + }) +}, withTracerDisabled) + +/** + * @since 1.0.0 + * @category Layers + */ +export const layer: Layer.Layer< + MessageStorage.MessageStorage, + never, + SqlClient.SqlClient | ShardingConfig +> = Layer.effect(MessageStorage.MessageStorage)(make({})).pipe( + Layer.provide(Snowflake.layerGenerator) +) + +/** + * @since 1.0.0 + * @category Layers + */ +export const layerWith = (options: { + readonly prefix?: string | undefined +}): Layer.Layer => + Layer.effect(MessageStorage.MessageStorage)(make(options)).pipe( + Layer.provide(Snowflake.layerGenerator) + ) + +// ------------------------------------------------------------------------------------------------- +// internal +// ------------------------------------------------------------------------------------------------- + +const migrations = (options?: { + readonly prefix?: string | undefined +}) => { + const prefix = options?.prefix ?? "cluster" + const table = (name: string) => `${prefix}_${name}` + const messagesTable = table("messages") + const repliesTable = table("replies") + + return Migrator.fromRecord({ + "0001_create_tables": Effect.gen(function*() { + const sql = (yield* SqlClient.SqlClient).withoutTransforms() + const messagesTableSql = sql(messagesTable) + const repliesTableSql = sql(repliesTable) + + yield* sql.onDialectOrElse({ + mssql: () => + sql` + IF OBJECT_ID(N'${messagesTableSql}', N'U') IS NULL + CREATE TABLE ${messagesTableSql} ( + id BIGINT PRIMARY KEY, + rowid BIGINT IDENTITY(1,1), + message_id VARCHAR(255), + shard_id VARCHAR(50) NOT NULL, + entity_type VARCHAR(150) NOT NULL, + entity_id VARCHAR(255) NOT NULL, + kind INT NOT NULL, + tag VARCHAR(50), + payload TEXT, + headers TEXT, + trace_id VARCHAR(32), + span_id VARCHAR(16), + sampled BIT, + processed BIT NOT NULL DEFAULT 0, + request_id BIGINT NOT NULL, + reply_id BIGINT, + last_reply_id BIGINT, + last_read DATETIME, + deliver_at BIGINT, + UNIQUE (message_id), + FOREIGN KEY (request_id) REFERENCES ${messagesTableSql} (id) ON DELETE CASCADE + ) + `, + mysql: () => + sql` + CREATE TABLE IF NOT EXISTS ${messagesTableSql} ( + id BIGINT NOT NULL, + rowid BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, + message_id VARCHAR(255), + shard_id VARCHAR(50) NOT NULL, + entity_type VARCHAR(150) NOT NULL, + entity_id VARCHAR(255) NOT NULL, + kind INT NOT NULL, + tag VARCHAR(50), + payload TEXT, + headers TEXT, + trace_id VARCHAR(32), + span_id VARCHAR(16), + sampled BOOLEAN, + processed BOOLEAN NOT NULL DEFAULT FALSE, + request_id BIGINT NOT NULL, + reply_id BIGINT, + last_reply_id BIGINT, + last_read DATETIME, + deliver_at BIGINT, + UNIQUE (id), + UNIQUE (message_id), + FOREIGN KEY (request_id) REFERENCES ${messagesTableSql} (id) ON DELETE CASCADE + ) + `, + pg: () => + sql` + CREATE TABLE IF NOT EXISTS ${messagesTableSql} ( + id BIGINT PRIMARY KEY, + rowid BIGSERIAL, + message_id VARCHAR(255), + shard_id VARCHAR(50) NOT NULL, + entity_type VARCHAR(150) NOT NULL, + entity_id VARCHAR(255) NOT NULL, + kind INT NOT NULL, + tag VARCHAR(50), + payload TEXT, + headers TEXT, + trace_id VARCHAR(32), + span_id VARCHAR(16), + sampled BOOLEAN, + processed BOOLEAN NOT NULL DEFAULT FALSE, + request_id BIGINT NOT NULL, + reply_id BIGINT, + last_reply_id BIGINT, + last_read TIMESTAMP, + deliver_at BIGINT, + UNIQUE (message_id), + FOREIGN KEY (request_id) REFERENCES ${messagesTableSql} (id) ON DELETE CASCADE + ) + `.pipe(Effect.ignore), + orElse: () => + // sqlite + sql` + CREATE TABLE IF NOT EXISTS ${messagesTableSql} ( + id INTEGER PRIMARY KEY, + message_id TEXT, + shard_id TEXT NOT NULL, + entity_type TEXT NOT NULL, + entity_id TEXT NOT NULL, + kind INTEGER NOT NULL, + tag TEXT, + payload TEXT, + headers TEXT, + trace_id TEXT, + span_id TEXT, + sampled BOOLEAN, + processed BOOLEAN NOT NULL DEFAULT FALSE, + request_id INTEGER NOT NULL, + reply_id INTEGER, + last_reply_id INTEGER, + last_read TEXT, + deliver_at INTEGER, + UNIQUE (message_id), + FOREIGN KEY (request_id) REFERENCES ${messagesTableSql} (id) ON DELETE CASCADE + ) + ` + }) + + // Add message indexes optimized for the specific query patterns + const shardLookupIndex = `${messagesTable}_shard_idx` + const requestIdLookupIndex = `${messagesTable}_request_id_idx` + yield* sql.onDialectOrElse({ + mssql: () => + sql` + IF NOT EXISTS (SELECT * FROM sys.indexes WHERE name = ${shardLookupIndex}) + CREATE INDEX ${sql(shardLookupIndex)} + ON ${messagesTableSql} (shard_id, processed, last_read, deliver_at); + + IF NOT EXISTS (SELECT * FROM sys.indexes WHERE name = ${requestIdLookupIndex}) + CREATE INDEX ${sql(requestIdLookupIndex)} + ON ${messagesTableSql} (request_id); + `, + mysql: () => + sql` + CREATE INDEX ${sql(shardLookupIndex)} + ON ${messagesTableSql} (shard_id, processed, last_read, deliver_at); + + CREATE INDEX ${sql(requestIdLookupIndex)} + ON ${messagesTableSql} (request_id); + `.unprepared.pipe(Effect.ignore), + pg: () => + sql` + CREATE INDEX IF NOT EXISTS ${sql(shardLookupIndex)} + ON ${messagesTableSql} (shard_id, processed, last_read, deliver_at); + + CREATE INDEX IF NOT EXISTS ${sql(requestIdLookupIndex)} + ON ${messagesTableSql} (request_id); + `.pipe( + Effect.tapDefect((error) => + Effect.annotateLogs(Effect.logDebug("Failed to create indexes", error), { + package: "@effect/cluster", + module: "SqlMessageStorage" + }) + ), + Effect.retry({ + schedule: Schedule.spaced(1000) + }) + ), + orElse: () => + // sqlite + Effect.all([ + sql` + CREATE INDEX IF NOT EXISTS ${sql(shardLookupIndex)} + ON ${messagesTableSql} (shard_id, processed, last_read, deliver_at) + `, + sql` + CREATE INDEX IF NOT EXISTS ${sql(requestIdLookupIndex)} + ON ${messagesTableSql} (request_id) + ` + ]).pipe(sql.withTransaction) + }) + + yield* sql.onDialectOrElse({ + mssql: () => + sql` + IF OBJECT_ID(N'${repliesTableSql}', N'U') IS NULL + CREATE TABLE ${repliesTableSql} ( + id BIGINT PRIMARY KEY, + rowid BIGINT IDENTITY(1,1), + kind INT, + request_id BIGINT NOT NULL, + payload TEXT NOT NULL, + sequence INT, + acked BIT NOT NULL DEFAULT 0, + CONSTRAINT ${sql(repliesTable + "_one_exit")} UNIQUE (request_id, kind), + CONSTRAINT ${sql(repliesTable + "_sequence")} UNIQUE (request_id, sequence), + FOREIGN KEY (request_id) REFERENCES ${messagesTableSql} (id) ON DELETE CASCADE + ) + `, + mysql: () => + sql` + CREATE TABLE IF NOT EXISTS ${repliesTableSql} ( + id BIGINT NOT NULL, + rowid BIGINT AUTO_INCREMENT PRIMARY KEY, + kind INT, + request_id BIGINT NOT NULL, + payload TEXT NOT NULL, + sequence INT, + acked BOOLEAN NOT NULL DEFAULT FALSE, + UNIQUE (id), + UNIQUE (request_id, kind), + UNIQUE (request_id, sequence), + FOREIGN KEY (request_id) REFERENCES ${messagesTableSql} (id) ON DELETE CASCADE + ) + `, + pg: () => + sql` + CREATE TABLE IF NOT EXISTS ${repliesTableSql} ( + id BIGINT PRIMARY KEY, + rowid BIGSERIAL, + kind INT, + request_id BIGINT NOT NULL, + payload TEXT NOT NULL, + sequence INT, + acked BOOLEAN NOT NULL DEFAULT FALSE, + UNIQUE (request_id, kind), + UNIQUE (request_id, sequence), + FOREIGN KEY (request_id) REFERENCES ${messagesTableSql} (id) ON DELETE CASCADE + ) + `, + orElse: () => + // sqlite + sql` + CREATE TABLE IF NOT EXISTS ${repliesTableSql} ( + id INTEGER PRIMARY KEY, + kind INTEGER, + request_id INTEGER NOT NULL, + payload TEXT NOT NULL, + sequence INTEGER, + acked BOOLEAN NOT NULL DEFAULT FALSE, + UNIQUE (request_id, kind), + UNIQUE (request_id, sequence), + FOREIGN KEY (request_id) REFERENCES ${messagesTableSql} (id) ON DELETE CASCADE + ) + ` + }) + + // Add reply indexes optimized for request_id lookups + const replyLookupIndex = `${repliesTable}_request_lookup_idx` + yield* sql.onDialectOrElse({ + mssql: () => + sql` + IF NOT EXISTS (SELECT * FROM sys.indexes WHERE name = ${replyLookupIndex}) + CREATE INDEX ${sql(replyLookupIndex)} + ON ${repliesTableSql} (request_id, kind, acked); + `, + mysql: () => + sql` + CREATE INDEX ${sql(replyLookupIndex)} + ON ${repliesTableSql} (request_id, kind, acked); + `.unprepared.pipe(Effect.ignore), + pg: () => + sql` + CREATE INDEX IF NOT EXISTS ${sql(replyLookupIndex)} + ON ${repliesTableSql} (request_id, kind, acked); + `.pipe( + Effect.tapDefect((error) => + Effect.annotateLogs(Effect.logDebug("Failed to create indexes", error), { + package: "@effect/cluster", + module: "SqlMessageStorage" + }) + ), + Effect.retry({ + schedule: Schedule.spaced(1000) + }) + ), + orElse: () => + // sqlite + sql` + CREATE INDEX IF NOT EXISTS ${sql(replyLookupIndex)} + ON ${repliesTableSql} (request_id, kind, acked); + ` + }) + }), + "0002_entity_type_size": Effect.gen(function*() { + const sql = (yield* SqlClient.SqlClient).withoutTransforms() + const messagesTableSql = sql(messagesTable) + + // resize entity_type to 150 characters + yield* sql.onDialectOrElse({ + mssql: () => + sql` + ALTER TABLE ${messagesTableSql} ALTER COLUMN entity_type VARCHAR(150) NOT NULL; + `, + mysql: () => + sql` + ALTER TABLE ${messagesTableSql} MODIFY entity_type VARCHAR(150) NOT NULL; + `.unprepared.pipe(Effect.ignore), + pg: () => + sql` + ALTER TABLE ${messagesTableSql} ALTER COLUMN entity_type TYPE VARCHAR(150); + `, + orElse: () => + // sqlite + Effect.void + }) + }) + }) +} + +const messageKind = { + "Request": 0, + "AckChunk": 1, + "Interrupt": 2 +} as const satisfies Record + +const replyKind = { + "WithExit": 0, + "Chunk": null +} as const satisfies Record["_tag"], number | null> + +const replyFromRow = (row: ReplyRow): Reply.Encoded => + Number(row.kind) === replyKind.WithExit ? + { + _tag: "WithExit", + id: String(row.id), + requestId: String(row.request_id), + exit: JSON.parse(row.payload) + } : + { + _tag: "Chunk", + id: String(row.id), + requestId: String(row.request_id), + values: JSON.parse(row.payload), + sequence: Number(row.sequence!) + } + +type MessageRow = { + readonly id: string | bigint + readonly message_id: string | null + readonly shard_id: string + readonly entity_type: string + readonly entity_id: string + readonly kind: 0 | 1 | 2 | 0n | 1n | 2n + readonly tag: string | null + readonly payload: string | null + readonly headers: string | null + readonly trace_id: string | null + readonly span_id: string | null + readonly sampled: boolean | number | bigint | null + readonly request_id: string | bigint | null + readonly reply_id: string | bigint | null + readonly deliver_at: number | bigint | null +} + +type ReplyRow = { + readonly id: string | bigint + readonly kind: 0 | null | 0n + readonly request_id: string | bigint + readonly payload: string + readonly sequence: number | bigint | null +} + +type ReplyJoinRow = { + readonly reply_reply_id: string | bigint | null + readonly reply_payload: string | null + readonly reply_sequence: number | bigint | null +} + +type MessageJoinRow = MessageRow & ReplyJoinRow & { + readonly sequence: number | bigint +} diff --git a/packages/effect/src/unstable/cluster/SqlShardStorage.ts b/packages/effect/src/unstable/cluster/SqlShardStorage.ts new file mode 100644 index 0000000000..3a78427eab --- /dev/null +++ b/packages/effect/src/unstable/cluster/SqlShardStorage.ts @@ -0,0 +1,303 @@ +/** + * @since 1.0.0 + */ +import * as Arr from "../../collections/Array.ts" +import * as Effect from "../../Effect.ts" +import * as Layer from "../../Layer.ts" +import * as SqlClient from "../sql/SqlClient.ts" +import type { SqlError } from "../sql/SqlError.ts" +import { PersistenceError } from "./ClusterError.ts" +import * as ShardStorage from "./ShardStorage.ts" + +const withTracerDisabled = Effect.withTracerEnabled(false) + +/** + * @since 1.0.0 + * @category Constructors + */ +export const make = Effect.fnUntraced(function*(options: { + readonly prefix?: string | undefined +}) { + const sql = (yield* SqlClient.SqlClient).withoutTransforms() + const prefix = options?.prefix ?? "cluster" + const table = (name: string) => `${prefix}_${name}` + + const runnersTable = table("runners") + const runnersTableSql = sql(runnersTable) + + yield* sql.onDialectOrElse({ + mssql: () => + sql` + IF OBJECT_ID(N'${runnersTableSql}', N'U') IS NULL + CREATE TABLE ${runnersTableSql} ( + address VARCHAR(255) PRIMARY KEY, + runner TEXT NOT NULL + ) + `, + mysql: () => + sql` + CREATE TABLE IF NOT EXISTS ${runnersTableSql} ( + address VARCHAR(255) PRIMARY KEY, + runner TEXT NOT NULL + ) + `, + pg: () => + sql` + CREATE TABLE IF NOT EXISTS ${runnersTableSql} ( + address VARCHAR(255) PRIMARY KEY, + runner TEXT NOT NULL + ) + `, + orElse: () => + // sqlite + sql` + CREATE TABLE IF NOT EXISTS ${runnersTableSql} ( + address TEXT PRIMARY KEY, + runner TEXT NOT NULL + ) + ` + }) + + const shardsTable = table("shards") + const shardsTableSql = sql(shardsTable) + + yield* sql.onDialectOrElse({ + mssql: () => + sql` + IF OBJECT_ID(N'${shardsTableSql}', N'U') IS NULL + CREATE TABLE ${shardsTableSql} ( + shard_id VARCHAR(50) PRIMARY KEY, + address VARCHAR(255) + ) + `, + mysql: () => + sql` + CREATE TABLE IF NOT EXISTS ${shardsTableSql} ( + shard_id VARCHAR(50) PRIMARY KEY, + address VARCHAR(255) + ) + `, + pg: () => + sql` + CREATE TABLE IF NOT EXISTS ${shardsTableSql} ( + shard_id VARCHAR(50) PRIMARY KEY, + address VARCHAR(255) + ) + `, + orElse: () => + // sqlite + sql` + CREATE TABLE IF NOT EXISTS ${shardsTableSql} ( + shard_id TEXT PRIMARY KEY, + address TEXT + ) + ` + }) + + const locksTable = table("locks") + const locksTableSql = sql(locksTable) + + yield* sql.onDialectOrElse({ + mssql: () => + sql` + IF OBJECT_ID(N'${locksTableSql}', N'U') IS NULL + CREATE TABLE ${locksTableSql} ( + shard_id VARCHAR(50) PRIMARY KEY, + address VARCHAR(255) NOT NULL, + acquired_at DATETIME NOT NULL + ) + `, + mysql: () => + sql` + CREATE TABLE IF NOT EXISTS ${locksTableSql} ( + shard_id VARCHAR(50) PRIMARY KEY, + address VARCHAR(255) NOT NULL, + acquired_at DATETIME NOT NULL + ) + `, + pg: () => + sql` + CREATE TABLE IF NOT EXISTS ${locksTableSql} ( + shard_id VARCHAR(50) PRIMARY KEY, + address VARCHAR(255) NOT NULL, + acquired_at TIMESTAMP NOT NULL + ) + `, + orElse: () => + // sqlite + sql` + CREATE TABLE IF NOT EXISTS ${locksTableSql} ( + shard_id TEXT PRIMARY KEY, + address TEXT NOT NULL, + acquired_at DATETIME NOT NULL + ) + ` + }) + + const sqlNowString = sql.onDialectOrElse({ + pg: () => "NOW()", + mysql: () => "NOW()", + mssql: () => "GETDATE()", + orElse: () => "CURRENT_TIMESTAMP" + }) + const sqlNow = sql.literal(sqlNowString) + + const lockExpiresAt = sql.onDialectOrElse({ + pg: () => sql`${sqlNow} - INTERVAL '10 seconds'`, + mysql: () => sql`DATE_SUB(${sqlNow}, INTERVAL 5 SECOND)`, + mssql: () => sql`DATEADD(SECOND, -5, ${sqlNow})`, + orElse: () => sql`datetime(${sqlNow}, '-5 seconds')` + }) + + const acquireLock = sql.onDialectOrElse({ + pg: () => (address: string, values: Array) => + sql` + INSERT INTO ${locksTableSql} (shard_id, address, acquired_at) VALUES ${sql.csv(values)} + ON CONFLICT (shard_id) DO UPDATE + SET address = ${address}, acquired_at = ${sqlNow} + WHERE ${locksTableSql}.address = ${address} + OR ${locksTableSql}.acquired_at < ${lockExpiresAt} + `, + mysql: () => (_address: string, values: Array) => + sql` + INSERT INTO ${locksTableSql} (shard_id, address, acquired_at) VALUES ${sql.csv(values)} + ON DUPLICATE KEY UPDATE + address = IF(address = VALUES(address) OR acquired_at < ${lockExpiresAt}, VALUES(address), address), + acquired_at = IF(address = VALUES(address) OR acquired_at < ${lockExpiresAt}, VALUES(acquired_at), acquired_at) + `.unprepared, + mssql: () => (_address: string, values: Array) => + sql` + MERGE ${locksTableSql} WITH (HOLDLOCK) AS target + USING (SELECT * FROM (VALUES ${sql.csv(values)})) AS source (shard_id, address, acquired_at) + ON target.shard_id = source.shard_id + WHEN MATCHED AND (target.address = source.address OR DATEDIFF(SECOND, target.acquired_at, ${sqlNow}) > 5) THEN + UPDATE SET address = source.address, acquired_at = source.acquired_at + WHEN NOT MATCHED THEN + INSERT (shard_id, address, acquired_at) + VALUES (source.shard_id, source.address, source.acquired_at); + `, + orElse: () => (address: string, values: Array) => + // sqlite + sql` + WITH source(shard_id, address, acquired_at) AS (VALUES ${sql.csv(values)}) + INSERT INTO ${locksTableSql} (shard_id, address, acquired_at) + SELECT source.shard_id, source.address, source.acquired_at + FROM source + WHERE NOT EXISTS ( + SELECT 1 FROM ${locksTableSql} + WHERE shard_id = source.shard_id + AND address != ${address} + AND (strftime('%s', ${sqlNow}) - strftime('%s', acquired_at)) <= 5 + ) + ON CONFLICT(shard_id) DO UPDATE + SET address = ${address}, acquired_at = ${sqlNow} + ` + }) + + const forUpdate = sql.onDialectOrElse({ + sqlite: () => sql.literal(""), + orElse: () => sql.literal("FOR UPDATE") + }) + + return ShardStorage.makeEncoded({ + getAssignments: sql`SELECT shard_id, address FROM ${shardsTableSql} ORDER BY shard_id`.values.pipe( + PersistenceError.refail, + withTracerDisabled + ) as any, + + saveAssignments: (assignments) => { + const remove = sql`DELETE FROM ${shardsTableSql}` + if (assignments.length === 0) { + return PersistenceError.refail(remove) + } + const values = assignments.map(([shardId, address]) => sql`(${shardId}, ${address})`) + return remove.pipe( + Effect.andThen(sql`INSERT INTO ${shardsTableSql} (shard_id, address) VALUES ${sql.csv(values)}`.unprepared), + sql.withTransaction, + PersistenceError.refail, + withTracerDisabled + ) + }, + + getRunners: sql`SELECT address, runner FROM ${runnersTableSql}`.values.pipe( + PersistenceError.refail, + Effect.map(Arr.map(([address, runner]) => [String(address), String(runner)] as const)), + withTracerDisabled + ), + + saveRunners: (runners) => { + const remove = sql`DELETE FROM ${runnersTableSql}` + if (runners.length === 0) { + return PersistenceError.refail(remove) + } + const values = runners.map(([address, runner]) => sql`(${address}, ${runner})`) + const insert = sql`INSERT INTO ${runnersTableSql} (address, runner) VALUES ${sql.csv(values)}`.unprepared + return remove.pipe( + Effect.andThen(insert), + sql.withTransaction, + PersistenceError.refail, + withTracerDisabled + ) + }, + + acquire: Effect.fnUntraced( + function*(address, shardIds) { + const values = shardIds.map((shardId) => sql`(${shardId}, ${address}, ${sqlNow})`) + yield* acquireLock(address, values) + const currentLocks = yield* sql<{ shard_id: string }>` + SELECT shard_id FROM ${sql(locksTable)} + WHERE address = ${address} AND acquired_at >= ${lockExpiresAt} + ${forUpdate} + `.values + return currentLocks.map((row) => row[0] as string) + }, + sql.withTransaction, + PersistenceError.refail, + withTracerDisabled + ), + + refresh: (address, shardIds) => + sql`UPDATE ${locksTableSql} SET acquired_at = ${sqlNow} WHERE address = ${address} AND ${ + sql.in("shard_id", shardIds) + }`.pipe( + Effect.andThen( + sql`SELECT shard_id FROM ${locksTableSql} WHERE address = ${address} AND acquired_at >= ${lockExpiresAt} ${forUpdate}` + .values + ), + Effect.map((rows) => rows.map((row) => row[0] as string)), + PersistenceError.refail, + withTracerDisabled + ), + + release: (address, shardId) => + sql`DELETE FROM ${locksTableSql} WHERE address = ${address} AND shard_id = ${shardId}`.pipe( + PersistenceError.refail, + withTracerDisabled + ), + + releaseAll: (address) => + sql`DELETE FROM ${locksTableSql} WHERE address = ${address}`.pipe( + PersistenceError.refail, + withTracerDisabled + ) + }) +}, withTracerDisabled) + +/** + * @since 1.0.0 + * @category Layers + */ +export const layer: Layer.Layer< + ShardStorage.ShardStorage, + SqlError, + SqlClient.SqlClient +> = Layer.effect(ShardStorage.ShardStorage)(make({})) + +/** + * @since 1.0.0 + * @category Layers + */ +export const layerWith = (options: { + readonly prefix?: string | undefined +}): Layer.Layer => + Layer.effect(ShardStorage.ShardStorage)(make(options)) diff --git a/packages/effect/src/unstable/cluster/SynchronizedClock.ts b/packages/effect/src/unstable/cluster/SynchronizedClock.ts new file mode 100644 index 0000000000..607363aedb --- /dev/null +++ b/packages/effect/src/unstable/cluster/SynchronizedClock.ts @@ -0,0 +1,82 @@ +/** + * @since 4.0.0 + */ +import * as Effect from "../../Effect.ts" +import * as Layer from "../../Layer.ts" +import * as Schedule from "../../Schedule.ts" +import type { Scope } from "../../Scope.ts" +import * as Clock from "../../time/Clock.ts" +import * as Duration from "../../time/Duration.ts" +import { ShardManagerClient } from "./ShardManager.ts" + +/** + * @since 4.0.0 + * @category Constructors + */ +export const make: (getRemoteTime: Effect.Effect) => Effect.Effect< + Clock.Clock, + never, + Scope +> = Effect.fnUntraced(function*(getRemoteTime) { + const clock = yield* Clock.Clock + + let driftMillis = 0 + let driftNanos = BigInt(0) + + yield* getRemoteTime.pipe( + Effect.timed, + Effect.map(([duration, shardManagerTime]) => { + const halfTrip = Duration.unsafeDivide(duration, 2) + shardManagerTime = shardManagerTime + Duration.toMillis(halfTrip) + 1 + const selfTime = clock.unsafeCurrentTimeMillis() + return shardManagerTime - selfTime + }), + Effect.replicateEffect(5), + Effect.flatMap((drifts) => { + drifts.sort() + const drift = (driftMillis + drifts[2]) / 2 + driftMillis = Math.round(drift) + driftNanos = BigInt(Math.round(drift * 1_000_000)) + return Effect.logDebug("Current drift", driftMillis) + }), + Effect.andThen(Effect.sleep(Duration.minutes(5))), + Effect.forever, + Effect.sandbox, + Effect.retry(Schedule.spaced(Duration.minutes(1))), + Effect.annotateLogs({ + package: "@effect/cluster", + service: "SynchronizedClock" + }), + Effect.forkScoped + ) + + function unsafeCurrentTimeMillis() { + return clock.unsafeCurrentTimeMillis() + driftMillis + } + function unsafeCurrentTimeNanos() { + return clock.unsafeCurrentTimeNanos() + driftNanos + } + + return Clock.Clock.of({ + sleep: clock.sleep, + unsafeCurrentTimeMillis, + unsafeCurrentTimeNanos, + currentTimeMillis: Effect.sync(unsafeCurrentTimeMillis), + currentTimeNanos: Effect.sync(unsafeCurrentTimeNanos) + }) +}) + +/** + * @since 4.0.0 + * @category Layers + */ +export const layer: Layer.Layer< + never, + never, + ShardManagerClient +> = Layer.effect(Clock.Clock)( + Effect.gen(function*() { + const shardManager = yield* ShardManagerClient + return yield* make(shardManager.getTime) + }) +) diff --git a/packages/effect/src/unstable/cluster/index.ts b/packages/effect/src/unstable/cluster/index.ts new file mode 100644 index 0000000000..0c53427022 --- /dev/null +++ b/packages/effect/src/unstable/cluster/index.ts @@ -0,0 +1,193 @@ +/** + * @since 4.0.0 + */ + +/** + * @since 4.0.0 + */ +export * as ClusterCron from "./ClusterCron.ts" + +/** + * @since 4.0.0 + */ +export * as ClusterError from "./ClusterError.ts" + +/** + * @since 4.0.0 + */ +export * as ClusterMetrics from "./ClusterMetrics.ts" + +/** + * @since 4.0.0 + */ +export * as ClusterSchema from "./ClusterSchema.ts" + +/** + * @since 4.0.0 + */ +export * as DeliverAt from "./DeliverAt.ts" + +/** + * @since 4.0.0 + */ +export * as Entity from "./Entity.ts" + +/** + * @since 4.0.0 + */ +export * as EntityAddress from "./EntityAddress.ts" + +/** + * @since 4.0.0 + */ +export * as EntityId from "./EntityId.ts" + +/** + * @since 4.0.0 + */ +export * as EntityProxy from "./EntityProxy.ts" + +/** + * @since 4.0.0 + */ +export * as EntityProxyServer from "./EntityProxyServer.ts" + +/** + * @since 4.0.0 + */ +export * as EntityType from "./EntityType.ts" + +/** + * @since 4.0.0 + */ +export * as Envelope from "./Envelope.ts" + +/** + * @since 4.0.0 + */ +export * as HttpCommon from "./HttpCommon.ts" + +/** + * @since 4.0.0 + */ +export * as HttpRunner from "./HttpRunner.ts" + +/** + * @since 4.0.0 + */ +export * as HttpShardManager from "./HttpShardManager.ts" + +/** + * @since 4.0.0 + */ +export * as MachineId from "./MachineId.ts" + +/** + * @since 4.0.0 + */ +export * as Message from "./Message.ts" + +/** + * @since 4.0.0 + */ +export * as MessageStorage from "./MessageStorage.ts" + +/** + * @since 4.0.0 + */ +export * as Reply from "./Reply.ts" + +/** + * @since 4.0.0 + */ +export * as Runner from "./Runner.ts" + +/** + * @since 4.0.0 + */ +export * as RunnerAddress from "./RunnerAddress.ts" + +/** + * @since 4.0.0 + */ +export * as RunnerHealth from "./RunnerHealth.ts" + +/** + * @since 4.0.0 + */ +export * as Runners from "./Runners.ts" + +/** + * @since 4.0.0 + */ +export * as RunnerServer from "./RunnerServer.ts" + +/** + * @since 4.0.0 + */ +export * as ShardId from "./ShardId.ts" + +/** + * @since 4.0.0 + */ +export * as Sharding from "./Sharding.ts" + +/** + * @since 4.0.0 + */ +export * as ShardingConfig from "./ShardingConfig.ts" + +/** + * @since 4.0.0 + */ +export * as ShardingRegistrationEvent from "./ShardingRegistrationEvent.ts" + +/** + * @since 4.0.0 + */ +export * as ShardManager from "./ShardManager.ts" + +/** + * @since 4.0.0 + */ +export * as ShardStorage from "./ShardStorage.ts" + +/** + * @since 4.0.0 + */ +export * as Singleton from "./Singleton.ts" + +/** + * @since 4.0.0 + */ +export * as SingletonAddress from "./SingletonAddress.ts" + +/** + * @since 4.0.0 + */ +export * as Snowflake from "./Snowflake.ts" + +/** + * @since 4.0.0 + */ +export * as SocketRunner from "./SocketRunner.ts" + +/** + * @since 4.0.0 + */ +export * as SocketShardManager from "./SocketShardManager.ts" + +/** + * @since 1.0.0 + */ +export * as SqlMessageStorage from "./SqlMessageStorage.ts" + +/** + * @since 1.0.0 + */ +export * as SqlShardStorage from "./SqlShardStorage.ts" + +/** + * @since 4.0.0 + */ +export * as SynchronizedClock from "./SynchronizedClock.ts" diff --git a/packages/effect/src/unstable/cluster/index.ts.tpl b/packages/effect/src/unstable/cluster/index.ts.tpl new file mode 100644 index 0000000000..c2aac82f76 --- /dev/null +++ b/packages/effect/src/unstable/cluster/index.ts.tpl @@ -0,0 +1,3 @@ +/** + * @since 4.0.0 + */ diff --git a/packages/effect/src/unstable/cluster/internal/entityManager.ts b/packages/effect/src/unstable/cluster/internal/entityManager.ts new file mode 100644 index 0000000000..c202bc1226 --- /dev/null +++ b/packages/effect/src/unstable/cluster/internal/entityManager.ts @@ -0,0 +1,543 @@ +import * as Cause from "../../../Cause.ts" +import * as Arr from "../../../collections/Array.ts" +import * as Option from "../../../data/Option.ts" +import * as Effect from "../../../Effect.ts" +import * as Exit from "../../../Exit.ts" +import { identity } from "../../../Function.ts" +import * as Equal from "../../../interfaces/Equal.ts" +import * as Metric from "../../../observability/Metric.ts" +import { CurrentLogAnnotations } from "../../../References.ts" +import * as Schedule from "../../../Schedule.ts" +import * as Schema from "../../../schema/Schema.ts" +import * as Serializer from "../../../schema/Serializer.ts" +import * as Scope from "../../../Scope.ts" +import * as ServiceMap from "../../../ServiceMap.ts" +import { Clock } from "../../../time/Clock.ts" +import * as Duration from "../../../time/Duration.ts" +import type { DurationInput } from "../../../time/Duration.ts" +import type * as Rpc from "../../rpc/Rpc.ts" +import { RequestId } from "../../rpc/RpcMessage.ts" +import * as RpcServer from "../../rpc/RpcServer.ts" +import { AlreadyProcessingMessage, EntityNotAssignedToRunner, MailboxFull, MalformedMessage } from "../ClusterError.ts" +import * as ClusterMetrics from "../ClusterMetrics.ts" +import { Persisted, Uninterruptible } from "../ClusterSchema.ts" +import type { Entity, HandlersFrom } from "../Entity.ts" +import { CurrentAddress, CurrentRunnerAddress, Request } from "../Entity.ts" +import type { EntityAddress } from "../EntityAddress.ts" +import type { EntityId } from "../EntityId.ts" +import * as Envelope from "../Envelope.ts" +import * as Message from "../Message.ts" +import * as MessageStorage from "../MessageStorage.ts" +import * as Reply from "../Reply.ts" +import type { RunnerAddress } from "../RunnerAddress.ts" +import type { ShardId } from "../ShardId.ts" +import type { Sharding } from "../Sharding.ts" +import { ShardingConfig } from "../ShardingConfig.ts" +import * as Snowflake from "../Snowflake.ts" +import { EntityReaper } from "./entityReaper.ts" +import { internalInterruptors } from "./interruptors.ts" +import { ResourceMap } from "./resourceMap.ts" +import { ResourceRef } from "./resourceRef.ts" + +/** @internal */ +export interface EntityManager { + readonly sendLocal: ( + message: Message.IncomingLocal + ) => Effect.Effect + + readonly send: ( + message: Message.Incoming + ) => Effect.Effect + + readonly isProcessingFor: (message: Message.Incoming, options?: { + readonly excludeReplies?: boolean + }) => boolean + + readonly interruptShard: (shardId: ShardId) => Effect.Effect + + readonly activeEntityCount: Effect.Effect +} + +// Represents the entities managed by this entity manager +/** @internal */ +export type EntityState = { + readonly address: EntityAddress + readonly activeRequests: Map + sentReply: boolean + lastSentChunk: Option.Option> + sequence: number + }> + lastActiveCheck: number + write: RpcServer.RpcServer["write"] +} + +/** @internal */ +export const make = Effect.fnUntraced(function*< + Type extends string, + Rpcs extends Rpc.Any, + Handlers extends HandlersFrom, + RX +>( + entity: Entity, + buildHandlers: Effect.Effect, + options: { + readonly sharding: Sharding["Service"] + readonly storage: MessageStorage.MessageStorage["Service"] + readonly runnerAddress: RunnerAddress + readonly maxIdleTime?: DurationInput | undefined + readonly concurrency?: number | "unbounded" | undefined + readonly mailboxCapacity?: number | "unbounded" | undefined + readonly disableFatalDefects?: boolean | undefined + readonly defectRetryPolicy?: Schedule.Schedule | undefined + readonly spanAttributes?: Record | undefined + } +) { + const config = yield* ShardingConfig + const snowflakeGen = yield* Snowflake.Generator + const managerScope = yield* Effect.scope + const storageEnabled = options.storage !== MessageStorage.noop + const mailboxCapacity = options.mailboxCapacity ?? config.entityMailboxCapacity + const clock = yield* Clock + const services = yield* Effect.services | Rpc.Middleware | RX>() + const retryDriver = yield* Schedule.toStepWithSleep( + options.defectRetryPolicy ? Schedule.andThen(options.defectRetryPolicy, defaultRetryPolicy) : defaultRetryPolicy + ) + + const activeServers = new Map() + + const entities: ResourceMap< + EntityAddress, + EntityState, + EntityNotAssignedToRunner + > = yield* ResourceMap.make(Effect.fnUntraced(function*(address) { + if (yield* options.sharding.isShutdown) { + return yield* Effect.fail(new EntityNotAssignedToRunner({ address })) + } + + const scope = yield* Effect.scope + const endLatch = Effect.unsafeMakeLatch() + + // on shutdown, reset the storage for the entity + yield* Scope.addFinalizer( + scope, + Effect.ignore(options.storage.resetAddress(address)) + ) + + const activeRequests: EntityState["activeRequests"] = new Map() + let defectRequestIds: Array = [] + + // the server is stored in a ref, so if there is a defect, we can + // swap the server without losing the active requests + const writeRef = yield* ResourceRef.from( + scope, + Effect.fnUntraced(function*(scope) { + let isShuttingDown = false + + // Initiate the behavior for the entity + const handlers = yield* (entity.protocol.toHandlers(buildHandlers as any).pipe( + Effect.provideService(CurrentLogAnnotations, {}), + Effect.provideServices(services.pipe( + ServiceMap.add(CurrentAddress, address), + ServiceMap.add(CurrentRunnerAddress, options.runnerAddress), + ServiceMap.add(Scope.Scope, scope) + )) + ) as Effect.Effect>>) + + const server = yield* RpcServer.makeNoSerialization(entity.protocol, { + spanPrefix: `${entity.type}(${address.entityId})`, + spanAttributes: { + ...options.spanAttributes, + "entity.type": entity.type, + "entity.id": address.entityId + }, + concurrency: options.concurrency ?? 1, + disableFatalDefects: options.disableFatalDefects, + onFromServer(response): Effect.Effect { + switch (response._tag) { + case "Exit": { + const request = activeRequests.get(response.requestId) + if (!request) return Effect.void + + request.sentReply = true + + // For durable messages, ignore interrupts during shutdown. + // They will be retried when the entity is restarted. + // Also, if the request is uninterruptible, we ignore the + // interrupt. + if ( + storageEnabled && + ServiceMap.get(request.rpc.annotations, Persisted) && + Exit.hasInterrupt(response.exit) && + (isShuttingDown || ServiceMap.get(request.rpc.annotations, Uninterruptible)) + ) { + return Effect.void + } + + return retryRespond( + 4, + Effect.suspend(() => + request.message.respond( + new Reply.WithExit({ + requestId: Snowflake.Snowflake(response.requestId), + id: snowflakeGen.unsafeNext(), + exit: response.exit + }) + ) + ) + ).pipe( + Effect.flatMap(() => { + activeRequests.delete(response.requestId) + + // ensure that the reaper does not remove the entity as we haven't + // been "idle" yet + if (activeRequests.size === 0) { + state.lastActiveCheck = clock.unsafeCurrentTimeMillis() + } + + return Effect.void + }), + Effect.orDie + ) + } + case "Chunk": { + const request = activeRequests.get(response.requestId) + if (!request) return Effect.void + const sequence = request.sequence + request.sequence++ + if (!request.sentReply) { + request.sentReply = true + } + return Effect.orDie(retryRespond( + 4, + Effect.suspend(() => { + const reply = new Reply.Chunk({ + requestId: Snowflake.Snowflake(response.requestId), + id: snowflakeGen.unsafeNext(), + sequence, + values: response.values + }) + request.lastSentChunk = Option.some(reply) + return request.message.respond(reply) + }) + )) + } + case "Defect": { + return Effect.forkIn(onDefect(Cause.die(response.defect)), managerScope) + } + case "ClientEnd": { + return endLatch.open + } + } + } + }).pipe( + Scope.provide(scope), + Effect.provideServices(handlers) + ) + + yield* Scope.addFinalizer( + scope, + Effect.sync(() => { + isShuttingDown = true + }) + ) + + for (const id of defectRequestIds) { + const { lastSentChunk, message } = activeRequests.get(id)! + yield* server.write(0, { + ...message.envelope, + id: RequestId(message.envelope.requestId), + tag: message.envelope.tag as any, + payload: new Request({ + ...message.envelope, + lastSentChunk + } as any) as any + }) + } + defectRequestIds = [] + + return server.write + }) + ) + + function onDefect(cause: Cause.Cause): Effect.Effect { + const effect = writeRef.unsafeRebuild() + defectRequestIds = Array.from(activeRequests.keys()) + return Effect.logError("Defect in entity, restarting", cause).pipe( + Effect.andThen(Effect.ignore(retryDriver(void 0))), + Effect.andThen(effect), + Effect.annotateLogs({ + module: "EntityManager", + address, + runner: options.runnerAddress + }), + Effect.catchCause(onDefect) + ) + } + + const state: EntityState = { + address, + write(clientId, message) { + if (writeRef.state.current._tag !== "Acquired") { + return Effect.flatMap(writeRef.await, (write) => write(clientId, message)) + } + return writeRef.state.current.value(clientId, message) + }, + activeRequests, + lastActiveCheck: clock.unsafeCurrentTimeMillis() + } + + // During shutdown, signal that no more messages will be processed + // and wait for the fiber to complete. + // + // If the termination timeout is reached, let the server clean itself up + yield* Scope.addFinalizer( + scope, + Effect.withFiber((fiber) => { + activeServers.delete(address.entityId) + internalInterruptors.add(fiber.id) + return state.write(0, { _tag: "Eof" }).pipe( + Effect.andThen(Effect.interruptible(endLatch.await)), + Effect.timeoutOption(config.entityTerminationTimeout) + ) + }) + ) + activeServers.set(address.entityId, state) + + return state + }, Effect.provideService(CurrentLogAnnotations, {}))) + + const reaper = yield* EntityReaper + const maxIdleTime = Duration.toMillis(options.maxIdleTime ?? config.entityMaxIdleTime) + if (Number.isFinite(maxIdleTime)) { + yield* reaper.register({ + maxIdleTime, + servers: activeServers, + entities + }) + } + + // update metrics for active servers + const typeAttributes = Metric.CurrentMetricAttributes.serviceMap({ type: entity.type }) + yield* Effect.sync(() => { + ClusterMetrics.entities.unsafeUpdate(BigInt(activeServers.size), typeAttributes) + }).pipe( + Effect.andThen(Effect.sleep(1000)), + Effect.forever, + Effect.forkIn(managerScope) + ) + + function sendLocal( + message: Message.IncomingLocal + ): Effect.Effect { + return Effect.provideService( + Effect.flatMap( + entities.get(message.envelope.address), + (server): Effect.Effect => { + switch (message._tag) { + case "IncomingRequestLocal": { + // If the request is already running, then we might have more than + // one sender for the same request. In this case, the other senders + // should resume from storage only. + let entry = server.activeRequests.get(message.envelope.requestId) + if (entry) { + return Effect.fail( + new AlreadyProcessingMessage({ + envelopeId: message.envelope.requestId, + address: message.envelope.address + }) + ) + } + + const rpc = entity.protocol.requests.get(message.envelope.tag)! as any as Rpc.AnyWithProps + if (!storageEnabled && ServiceMap.get(rpc.annotations, Persisted)) { + return Effect.die( + "EntityManager.sendLocal: Cannot process a persisted message without MessageStorage" + ) + } + + if (mailboxCapacity !== "unbounded" && server.activeRequests.size >= mailboxCapacity) { + return Effect.fail(new MailboxFull({ address: message.envelope.address })) + } + + entry = { + rpc, + message, + sentReply: false, + lastSentChunk: message.lastSentReply as any, + sequence: Option.match(message.lastSentReply, { + onNone: () => 0, + onSome: (reply) => reply._tag === "Chunk" ? reply.sequence + 1 : 0 + }) + } + server.activeRequests.set(message.envelope.requestId, entry) + return server.write(0, { + ...message.envelope, + id: RequestId(message.envelope.requestId), + payload: new Request({ + ...message.envelope, + lastSentChunk: message.lastSentReply as any + }) + }) + } + case "IncomingEnvelope": { + const entry = server.activeRequests.get(message.envelope.requestId) + if (!entry) { + return Effect.void + } else if ( + message.envelope._tag === "AckChunk" && + Option.isSome(entry.lastSentChunk) && + message.envelope.replyId !== entry.lastSentChunk.value.id + ) { + return Effect.void + } + return server.write( + 0, + message.envelope._tag === "AckChunk" + ? { _tag: "Ack", requestId: RequestId(message.envelope.requestId) } + : { _tag: "Interrupt", requestId: RequestId(message.envelope.requestId), interruptors: [] } + ) + } + } + } + ), + CurrentLogAnnotations, + {} + ) + } + + const interruptShard = (shardId: ShardId) => + Effect.suspend(function loop(): Effect.Effect { + const toInterrupt = new Set() + for (const state of activeServers.values()) { + if (shardId[Equal.symbol](state.address.shardId)) { + toInterrupt.add(state) + } + } + if (toInterrupt.size === 0) { + return Effect.void + } + return Effect.flatMap( + Effect.forEach(toInterrupt, (state) => entities.removeIgnore(state.address), { + concurrency: "unbounded", + discard: true + }), + loop + ) + }) + + const decodeMessage = Schema.decodeEffect(makeMessageSchema(entity)) + + return identity({ + interruptShard, + isProcessingFor(message, options) { + const state = activeServers.get(message.envelope.address.entityId) + if (!state) return false + const request = state.activeRequests.get(message.envelope.requestId) + if (request === undefined) { + return false + } else if (options?.excludeReplies && request.sentReply) { + return false + } + return true + }, + sendLocal, + send: (message) => + decodeMessage(message).pipe( + Effect.matchEffect({ + onFailure: (cause) => { + if (message._tag === "IncomingEnvelope") { + return Effect.die(new MalformedMessage({ cause })) + } + return Effect.orDie(message.respond( + new Reply.ReplyWithContext({ + reply: new Reply.WithExit({ + id: snowflakeGen.unsafeNext(), + requestId: message.envelope.requestId, + exit: Exit.die(new MalformedMessage({ cause })) + }), + rpc: entity.protocol.requests.get(message.envelope.tag)!, + services: services as any + }) + )) + }, + onSuccess: (decoded) => { + if (decoded._tag === "IncomingEnvelope") { + return sendLocal( + new Message.IncomingEnvelope(decoded) + ) + } + const request = message as Message.IncomingRequest + const rpc = entity.protocol.requests.get(decoded.envelope.tag)! + return sendLocal( + new Message.IncomingRequestLocal({ + envelope: decoded.envelope, + lastSentReply: decoded.lastSentReply, + respond: (reply) => + request.respond( + new Reply.ReplyWithContext({ + reply, + rpc, + services: services as any + }) + ) + }) + ) + } + }), + Effect.provideServices(services as ServiceMap.ServiceMap) + ), + activeEntityCount: Effect.sync(() => activeServers.size) + }) +}) + +const defaultRetryPolicy = Schedule.exponential(500, 1.5).pipe( + Schedule.either(Schedule.spaced("10 seconds")) +) + +const makeMessageSchema = (entity: Entity): Schema.Codec< + { + readonly _tag: "IncomingRequest" + readonly envelope: Envelope.Request.Any + readonly lastSentReply: Option.Option> + } | { + readonly _tag: "IncomingEnvelope" + readonly envelope: Envelope.AckChunk | Envelope.Interrupt + }, + Message.Incoming, + Rpc.ServicesServer, + Rpc.ServicesClient +> => { + const requests = Arr.empty() + + for (const rpc of entity.protocol.requests.values()) { + requests.push( + Schema.TaggedStruct("IncomingRequest", { + envelope: Schema.Struct({ + ...Envelope.PartialRequest.fields, + tag: Schema.Literal(rpc._tag), + payload: Serializer.json((rpc as any as Rpc.AnyWithProps).payloadSchema) + }).pipe( + Schema.decodeTo(Envelope.Request, Envelope.RequestTransform) + ), + lastSentReply: Schema.Option(Reply.Reply(rpc)) + }) + ) + } + + return Schema.Union([ + ...requests, + Schema.TaggedStruct("IncomingEnvelope", { + envelope: Schema.Union([ + Schema.typeCodec(Envelope.AckChunk), + Schema.typeCodec(Envelope.Interrupt) + ]) + }) + ]) as any +} + +const retryRespond = (times: number, effect: Effect.Effect): Effect.Effect => + times === 0 ? + effect : + Effect.catch(effect, () => Effect.delay(retryRespond(times - 1, effect), 200)) diff --git a/packages/effect/src/unstable/cluster/internal/entityReaper.ts b/packages/effect/src/unstable/cluster/internal/entityReaper.ts new file mode 100644 index 0000000000..480055c296 --- /dev/null +++ b/packages/effect/src/unstable/cluster/internal/entityReaper.ts @@ -0,0 +1,58 @@ +import * as Effect from "../../../Effect.ts" +import * as Layer from "../../../Layer.ts" +import * as ServiceMap from "../../../ServiceMap.ts" +import { Clock } from "../../../time/Clock.ts" +import type { EntityNotAssignedToRunner } from "../ClusterError.ts" +import type { EntityAddress } from "../EntityAddress.ts" +import type { EntityId } from "../EntityId.ts" +import type { EntityState } from "./entityManager.ts" +import type { ResourceMap } from "./resourceMap.ts" + +/** @internal */ +export class EntityReaper extends ServiceMap.Key()("effect/cluster/EntityReaper", { + make: Effect.gen(function*() { + let currentResolution = 30_000 + const registered: Array<{ + readonly maxIdleTime: number + readonly servers: Map + readonly entities: ResourceMap + }> = [] + const latch = yield* Effect.makeLatch() + + const register = (options: { + readonly maxIdleTime: number + readonly servers: Map + readonly entities: ResourceMap + }) => + Effect.suspend(() => { + currentResolution = Math.max(Math.min(currentResolution, options.maxIdleTime), 5000) + registered.push(options) + return latch.open + }) + + const clock = yield* Clock + yield* Effect.gen(function*() { + while (true) { + yield* Effect.sleep(currentResolution) + const now = clock.unsafeCurrentTimeMillis() + for (const { entities, maxIdleTime, servers } of registered) { + for (const state of servers.values()) { + const duration = now - state.lastActiveCheck + if (state.activeRequests.size > 0 || duration < maxIdleTime) { + continue + } + yield* Effect.fork(entities.removeIgnore(state.address)) + } + } + } + }).pipe( + latch.whenOpen, + Effect.interruptible, + Effect.forkScoped + ) + + return { register } as const + }) +}) { + static readonly layer: Layer.Layer = Layer.effect(this)(this.make) +} diff --git a/packages/effect/src/unstable/cluster/internal/hash.ts b/packages/effect/src/unstable/cluster/internal/hash.ts new file mode 100644 index 0000000000..cd3045931e --- /dev/null +++ b/packages/effect/src/unstable/cluster/internal/hash.ts @@ -0,0 +1,11 @@ +/** @internal */ +export const hashOptimize = (n: number): number => (n & 0xbfffffff) | ((n >>> 1) & 0x40000000) + +/** @internal */ +export const hashString = (str: string) => { + let h = 5381, i = str.length + while (i) { + h = (h * 33) ^ str.charCodeAt(--i) + } + return hashOptimize(h) +} diff --git a/packages/effect/src/unstable/cluster/internal/interruptors.ts b/packages/effect/src/unstable/cluster/internal/interruptors.ts new file mode 100644 index 0000000000..0606f660e8 --- /dev/null +++ b/packages/effect/src/unstable/cluster/internal/interruptors.ts @@ -0,0 +1,2 @@ +/** @internal */ +export const internalInterruptors = new Set() diff --git a/packages/effect/src/unstable/cluster/internal/resourceMap.ts b/packages/effect/src/unstable/cluster/internal/resourceMap.ts new file mode 100644 index 0000000000..c27e903794 --- /dev/null +++ b/packages/effect/src/unstable/cluster/internal/resourceMap.ts @@ -0,0 +1,100 @@ +import * as MutableHashMap from "../../../collections/MutableHashMap.ts" +import * as Option from "../../../data/Option.ts" +import * as Deferred from "../../../Deferred.ts" +import * as Effect from "../../../Effect.ts" +import * as Exit from "../../../Exit.ts" +import * as MutableRef from "../../../MutableRef.ts" +import * as Scope from "../../../Scope.ts" +import * as ServiceMap from "../../../ServiceMap.ts" + +/** @internal */ +export class ResourceMap { + readonly lookup: (key: K, scope: Scope.Scope) => Effect.Effect + readonly entries: MutableHashMap.MutableHashMap + }> + readonly isClosed: MutableRef.MutableRef + constructor( + lookup: (key: K, scope: Scope.Scope) => Effect.Effect, + entries: MutableHashMap.MutableHashMap + }>, + isClosed: MutableRef.MutableRef + ) { + this.lookup = lookup + this.entries = entries + this.isClosed = isClosed + } + + static make = Effect.fnUntraced(function*(lookup: (key: K) => Effect.Effect) { + const scope = yield* Effect.scope + const services = yield* Effect.services() + const isClosed = MutableRef.make(false) + + const entries = MutableHashMap.empty + }>() + + yield* Scope.addFinalizerExit( + scope, + (exit) => { + MutableRef.set(isClosed, true) + return Effect.forEach(entries, ([key, { scope }]) => { + MutableHashMap.remove(entries, key) + return Effect.exit(Scope.close(scope, exit)) + }, { concurrency: "unbounded", discard: true }) + } + ) + + return new ResourceMap( + (key, scope) => Effect.provide(lookup(key), ServiceMap.add(services, Scope.Scope, scope)), + entries, + isClosed + ) + }) + + get(key: K): Effect.Effect { + return Effect.suspend(() => { + if (MutableRef.get(this.isClosed)) { + return Effect.interrupt + } + const existing = MutableHashMap.get(this.entries, key) + if (Option.isSome(existing)) { + return Deferred.await(existing.value.deferred) + } + const scope = Effect.runSync(Scope.make()) + const deferred = Deferred.unsafeMake() + MutableHashMap.set(this.entries, key, { scope, deferred }) + return Effect.onExit(this.lookup(key, scope), (exit) => { + if (exit._tag === "Success") { + return Deferred.done(deferred, exit) + } + MutableHashMap.remove(this.entries, key) + return Deferred.done(deferred, exit) + }) + }) + } + + remove(key: K): Effect.Effect { + return Effect.suspend(() => { + const entry = MutableHashMap.get(this.entries, key) + if (Option.isNone(entry)) { + return Effect.void + } + MutableHashMap.remove(this.entries, key) + return Scope.close(entry.value.scope, Exit.void) + }) + } + + removeIgnore(key: K): Effect.Effect { + return Effect.catchCause(this.remove(key), (cause) => + Effect.annotateLogs(Effect.logDebug(cause), { + module: "ResourceMap", + method: "removeIgnore", + key + })) + } +} diff --git a/packages/effect/src/unstable/cluster/internal/resourceRef.ts b/packages/effect/src/unstable/cluster/internal/resourceRef.ts new file mode 100644 index 0000000000..37b9cd8875 --- /dev/null +++ b/packages/effect/src/unstable/cluster/internal/resourceRef.ts @@ -0,0 +1,95 @@ +import * as Option from "../../../data/Option.ts" +import * as Effect from "../../../Effect.ts" +import * as Exit from "../../../Exit.ts" +import * as MutableRef from "../../../MutableRef.ts" +import * as Scope from "../../../Scope.ts" +import { internalInterruptors } from "./interruptors.ts" + +/** @internal */ +export type State = { + readonly _tag: "Closed" +} | { + readonly _tag: "Acquiring" + readonly scope: Scope.Scope.Closeable +} | { + readonly _tag: "Acquired" + readonly scope: Scope.Scope.Closeable + readonly value: A +} + +/** @internal */ +export class ResourceRef { + static from = Effect.fnUntraced(function*( + parentScope: Scope.Scope, + acquire: (scope: Scope.Scope) => Effect.Effect + ) { + const state = MutableRef.make>({ _tag: "Closed" }) + + yield* Scope.addFinalizerExit(parentScope, (exit) => { + const s = MutableRef.get(state) + if (s._tag === "Closed") { + return Effect.void + } + const scope = s.scope + MutableRef.set(state, { _tag: "Closed" }) + return Scope.close(scope, exit) + }) + + const scope = yield* Scope.make() + MutableRef.set(state, { _tag: "Acquiring", scope }) + const value = yield* acquire(scope) + MutableRef.set(state, { _tag: "Acquired", scope, value }) + + return new ResourceRef(state, acquire) + }) + + readonly state: MutableRef.MutableRef> + readonly acquire: (scope: Scope.Scope) => Effect.Effect + constructor( + state: MutableRef.MutableRef>, + acquire: (scope: Scope.Scope) => Effect.Effect + ) { + this.state = state + this.acquire = acquire + } + + latch = Effect.unsafeMakeLatch(true) + + unsafeGet(): Option.Option { + if (this.state.current._tag === "Acquired") { + return Option.some(this.state.current.value) + } + return Option.none() + } + + unsafeRebuild(): Effect.Effect { + const s = this.state.current + if (s._tag === "Closed") { + return Effect.interrupt + } + const prevScope = s.scope + const scope = Effect.runSync(Scope.make()) + this.latch.unsafeClose() + MutableRef.set(this.state, { _tag: "Acquiring", scope }) + return Effect.withFiber((fiber) => { + internalInterruptors.add(fiber.id) + return Scope.close(prevScope, Exit.void) + }).pipe( + Effect.andThen(this.acquire(scope)), + Effect.flatMap((value) => { + MutableRef.set(this.state, { _tag: "Acquired", scope, value }) + return this.latch.open + }) + ) + } + + await: Effect.Effect = Effect.suspend(() => { + const s = this.state.current + if (s._tag === "Closed") { + return Effect.interrupt + } else if (s._tag === "Acquired") { + return Effect.succeed(s.value) + } + return Effect.flatMap(this.latch.await, () => this.await) + }) +} diff --git a/packages/effect/src/unstable/cluster/internal/shardManager.ts b/packages/effect/src/unstable/cluster/internal/shardManager.ts new file mode 100644 index 0000000000..656cb018da --- /dev/null +++ b/packages/effect/src/unstable/cluster/internal/shardManager.ts @@ -0,0 +1,421 @@ +import * as Arr from "../../../collections/Array.ts" +import * as MutableHashMap from "../../../collections/MutableHashMap.ts" +import * as MutableHashSet from "../../../collections/MutableHashSet.ts" +import * as Option from "../../../data/Option.ts" +import * as Effect from "../../../Effect.ts" +import { constFalse } from "../../../Function.ts" +import * as Clock from "../../../time/Clock.ts" +import type { Runner } from "../Runner.ts" +import type { RunnerAddress } from "../RunnerAddress.ts" +import { RunnerHealth } from "../RunnerHealth.ts" +import { ShardId } from "../ShardId.ts" +import { ShardStorage } from "../ShardStorage.ts" + +/** @internal */ +export class State { + static fromStorage = Effect.fnUntraced(function*( + shardsPerGroup: number + ) { + const storage = yield* ShardStorage + const runnerHealth = yield* RunnerHealth + + // Fetch registered runners and shard assignments from cluster storage + const storedRunners = yield* storage.getRunners + const storedAssignments = yield* storage.getAssignments + + // Determine which runners are still alive + const deadRunners = Arr.empty() + const aliveRunners = MutableHashMap.empty() + yield* Effect.forEach(storedRunners, ([address, runner]) => + Effect.map(runnerHealth.isAlive(address), (isAlive) => { + if (isAlive) { + MutableHashMap.set(aliveRunners, address, runner) + } else { + deadRunners.push(runner) + } + }), { concurrency: "unbounded", discard: true }) + if (deadRunners.length > 0) { + yield* Effect.logWarning("Ignoring runners that are no longer considered alive:", deadRunners) + } + + // Determine which shards remain unassigned to a runner + const assignedShards = MutableHashMap.empty() + const invalidAssignments = Arr.empty<[ShardId, RunnerAddress]>() + for (const [shard, address] of storedAssignments) { + if (Option.isSome(address) && MutableHashMap.has(aliveRunners, address.value)) { + MutableHashMap.set(assignedShards, shard, address.value) + } else if (Option.isSome(address)) { + invalidAssignments.push([shard, address.value]) + } + } + if (invalidAssignments.length > 0) { + yield* Effect.logWarning( + "Ignoring shard assignments for runners that are no longer considered alive: ", + invalidAssignments + ) + } + + // Construct the initial state + const now = yield* Clock.currentTimeMillis + const allRunners = MutableHashMap.empty() + const runnerState = new Map>() + for (const [address, runner] of aliveRunners) { + const withMetadata = RunnerWithMetadata({ runner, registeredAt: now }) + MutableHashMap.set(allRunners, address, withMetadata) + for (const group of runner.groups) { + let groupMap = runnerState.get(group) + if (!groupMap) { + groupMap = MutableHashMap.empty() + runnerState.set(group, groupMap) + } + MutableHashMap.set(groupMap, address, withMetadata) + } + } + + const shardState = new Map>>() + for (const group of runnerState.keys()) { + const groupMap = new Map>() + shardState.set(group, groupMap) + for (let n = 1; n <= shardsPerGroup; n++) { + const shardId = new ShardId({ group, id: n }) + groupMap.set(n, MutableHashMap.get(assignedShards, shardId)) + } + } + + return new State(allRunners, runnerState, shardState, shardsPerGroup) + }) + + readonly allRunners: MutableHashMap.MutableHashMap + readonly runners: Map> + readonly shards: Map>> + readonly shardsPerGroup: number + + constructor( + allRunners: MutableHashMap.MutableHashMap, + runners: Map>, + shards: Map>>, + shardsPerGroup: number + ) { + this.allRunners = allRunners + this.runners = runners + this.shards = shards + this.shardsPerGroup = shardsPerGroup + this.assignments = MutableHashMap.empty>() + this.perRunner = new Map>>() + + for (const [address, meta] of this.allRunners) { + for (const group of meta.runner.groups) { + let runnerMap = this.perRunner.get(group) + if (!runnerMap) { + runnerMap = MutableHashMap.empty>() + this.perRunner.set(group, runnerMap) + } + MutableHashMap.set(runnerMap, address, new Set()) + } + } + + for (const [group, groupMap] of this.shards) { + const perRunnerMap = this.perRunner.get(group)! + for (const [id, address_] of groupMap) { + const address = Option.filter(address_, (addr) => MutableHashMap.has(this.allRunners, addr)) + MutableHashMap.set(this.assignments, new ShardId({ group, id }), address) + if (Option.isSome(address)) { + Option.getOrUndefined(MutableHashMap.get(perRunnerMap, address.value))?.add(id) + } + } + } + } + + readonly assignments: MutableHashMap.MutableHashMap> + readonly perRunner: Map>> + + addGroup(group: string): void { + this.runners.set(group, MutableHashMap.empty()) + const shardMap = new Map>() + this.shards.set(group, shardMap) + for (let n = 1; n <= this.shardsPerGroup; n++) { + shardMap.set(n, Option.none()) + MutableHashMap.set(this.assignments, new ShardId({ group, id: n }), Option.none()) + } + + const perRunnerMap = MutableHashMap.empty>() + this.perRunner.set(group, perRunnerMap) + for (const [address] of this.allRunners) { + MutableHashMap.set(perRunnerMap, address, new Set()) + } + } + + addAssignments( + shards: Iterable, + address: Option.Option + ) { + for (const shardId of shards) { + const currentAddress = Option.flatten(MutableHashMap.get(this.assignments, shardId)) + MutableHashMap.set(this.assignments, shardId, address) + this.shards.get(shardId.group)?.set(shardId.id, address) + + const perRunner = this.perRunner.get(shardId.group)! + if (Option.isSome(currentAddress)) { + Option.getOrUndefined(MutableHashMap.get(perRunner, currentAddress.value))?.delete(shardId.id) + } + if (Option.isSome(address)) { + Option.getOrUndefined(MutableHashMap.get(perRunner, address.value))?.add(shardId.id) + } + } + } + + addRunner(runner: Runner, registeredAt: number): void { + const withMetadata = RunnerWithMetadata({ runner, registeredAt }) + MutableHashMap.set(this.allRunners, runner.address, withMetadata) + for (const group of runner.groups) { + if (!this.runners.has(group)) { + this.addGroup(group) + } + const groupMap = this.runners.get(group)! + MutableHashMap.set(groupMap, runner.address, withMetadata) + const perRunner = this.perRunner.get(group)! + MutableHashMap.set(perRunner, runner.address, new Set()) + } + } + + removeRunner(address: RunnerAddress): void { + MutableHashMap.remove(this.allRunners, address) + for (const group of this.runners.keys()) { + const groupMap = this.runners.get(group)! + MutableHashMap.remove(groupMap, address) + + const perRunner = this.perRunner.get(group)! + MutableHashMap.remove(perRunner, address) + } + } + + get maxVersion(): Option.Option { + if (MutableHashMap.size(this.allRunners) === 0) return Option.none() + let version: number | undefined = undefined + for (const [, meta] of this.allRunners) { + if (version === undefined || meta.runner.version > version) { + version = meta.runner.version + } + } + return Option.some(version!) + } + + allRunnersHaveVersion(version: Option.Option): boolean { + return version.pipe( + Option.map((max) => Arr.every(this.runnerVersions, (version) => version === max)), + Option.getOrElse(constFalse) + ) + } + + get shardStats(): { + readonly perRunner: Map + readonly unassigned: number + } { + const perRunner = new Map() + let unassigned = 0 + for (const [, address] of this.assignments) { + if (Option.isNone(address)) { + unassigned++ + continue + } + const runner = address.value.toString() + const count = perRunner.get(runner) ?? 0 + perRunner.set(runner, count + 1) + } + + return { perRunner, unassigned } + } + + shardsPerRunner(group: string): MutableHashMap.MutableHashMap> { + const shards = MutableHashMap.empty>() + const perRunner = this.perRunner.get(group) + if (!perRunner || MutableHashMap.isEmpty(perRunner)) return shards + + for (const [address, shardSet] of perRunner) { + MutableHashMap.set(shards, address, new Set(shardSet)) + } + + return shards + } + + averageShardsPerRunner(group: string): number { + const runnerCount = MutableHashMap.size(this.runners.get(group) ?? MutableHashMap.empty()) + const shardGroup = this.shards.get(group) ?? new Map() + return runnerCount > 0 ? shardGroup.size / runnerCount : 0 + } + + get allUnassignedShards(): Array { + const unassigned: Array = [] + for (const [shardId, address] of this.assignments) { + if (Option.isNone(address)) { + unassigned.push(shardId) + } + } + return unassigned + } + + unassignedShards(group: string): Array { + const shardIds: Array = [] + const assignments = this.shards.get(group)! + for (const [shard, address] of assignments) { + if (Option.isNone(address)) { + shardIds.push(shard) + } + } + return shardIds + } + + private get runnerVersions(): Array { + const runnerVersions: Array = [] + for (const [, meta] of this.allRunners) { + runnerVersions.push(meta.runner.version) + } + return runnerVersions + } +} + +/** @internal */ +export interface RunnerWithMetadata { + readonly runner: Runner + readonly registeredAt: number +} +/** @internal */ +export const RunnerWithMetadata = (runner: RunnerWithMetadata): RunnerWithMetadata => runner + +/** @internal */ +export function decideAssignmentsForShards(state: State, group: string): readonly [ + assignments: MutableHashMap.MutableHashMap>, + unassignments: MutableHashMap.MutableHashMap>, + changes: MutableHashSet.MutableHashSet +] { + const shardsPerRunner = state.shardsPerRunner(group) + const maxVersion = state.maxVersion + const shardsToRebalance = state.unassignedShards(group) + + if (state.allRunnersHaveVersion(maxVersion)) { + const averageShardsPerRunner = state.averageShardsPerRunner(group) + MutableHashMap.forEach(shardsPerRunner, (shards) => { + const extraShards = Math.max(0, shards.size - averageShardsPerRunner) + const iter = shards.values() + for (let i = 0; i < extraShards; i++) { + const shard = iter.next() + if (shard.done) break + shardsToRebalance.push(shard.value) + } + }) + } + + return pickNewRunners(shardsToRebalance, state, group, shardsPerRunner, maxVersion) +} + +function pickNewRunners( + shardsToRebalance: ReadonlyArray, + state: State, + group: string, + shardsPerRunner: MutableHashMap.MutableHashMap>, + maybeMaxVersion = state.maxVersion +): readonly [ + assignments: MutableHashMap.MutableHashMap>, + unassignments: MutableHashMap.MutableHashMap>, + changes: MutableHashSet.MutableHashSet +] { + const addressAssignments = MutableHashMap.empty>() + const unassignments = MutableHashMap.empty>() + const changes = MutableHashSet.empty() + + if (Option.isNone(maybeMaxVersion)) { + return [addressAssignments, unassignments, changes] + } + const maxVersion = maybeMaxVersion.value + + const runnerGroup = state.runners.get(group)! + const shardsGroup = state.shards.get(group)! + + for (const shardId of shardsToRebalance) { + // Find the runner with the fewest assigned shards + let candidate: RunnerAddress | undefined + let candidateShards: Set | undefined + + for (const [address, shards] of shardsPerRunner) { + // Keep only runners with the maximum version + const maybeRunnerMeta = MutableHashMap.get(runnerGroup, address) + if (Option.isNone(maybeRunnerMeta)) continue + const runnerMeta = maybeRunnerMeta.value + if (runnerMeta.runner.version !== maxVersion) continue + + // Do not assign to a runner that has unassignments in the same rebalance + if (MutableHashMap.has(unassignments, address)) continue + + if (candidate === undefined || shards.size < candidateShards!.size) { + candidate = address + candidateShards = shards + } + } + if (!candidate || !candidateShards) break + + // If the old runner is the same as the new runner, do nothing + const oldRunner = Option.getOrUndefined(shardsGroup.get(shardId) ?? Option.none()) + if (oldRunner && oldRunner.toString() === candidate.toString()) { + continue + } + const oldShards = oldRunner && Option.getOrUndefined(MutableHashMap.get(shardsPerRunner, oldRunner)) + + // If the new runner has one less, as many, or more shards than the + // old runner, do not change anything + if (oldShards && candidateShards.size + 1 >= oldShards.size) continue + + // Otherwise create a new assignment + MutableHashMap.modifyAt( + addressAssignments, + candidate, + Option.match({ + onNone: () => Option.some(new Set([shardId])), + onSome: (shards) => { + shards.add(shardId) + return Option.some(shards) + } + }) + ) + if (oldRunner) { + MutableHashMap.modifyAt( + unassignments, + oldRunner, + Option.match({ + onNone: () => Option.some(new Set([shardId])), + onSome: (shards) => { + shards.add(shardId) + return Option.some(shards) + } + }) + ) + } + + // Move the shard to the new runner + candidateShards.add(shardId) + if (oldShards) { + oldShards.delete(shardId) + } + + // Track changes + MutableHashSet.add(changes, candidate) + if (oldRunner) MutableHashSet.add(changes, oldRunner) + } + + return [addressAssignments, unassignments, changes] +} + +/** @internal */ +export const addAllNested = ( + self: MutableHashMap.MutableHashMap>, + key: K, + values: Iterable +) => { + const oset = MutableHashMap.get(self, key) + if (Option.isSome(oset)) { + for (const value of values) { + MutableHashSet.add(oset.value, value) + } + } else { + MutableHashMap.set(self, key, MutableHashSet.fromIterable(values)) + } +} diff --git a/packages/effect/src/unstable/http/FetchHttpClient.ts b/packages/effect/src/unstable/http/FetchHttpClient.ts index f44fb64d06..62d20649c6 100644 --- a/packages/effect/src/unstable/http/FetchHttpClient.ts +++ b/packages/effect/src/unstable/http/FetchHttpClient.ts @@ -1,5 +1,5 @@ /** - * @since 1.0.0 + * @since 4.0.0 */ import * as Effect from "../../Effect.ts" import type * as Layer from "../../Layer.ts" @@ -11,7 +11,7 @@ import { RequestError } from "./HttpClientError.ts" import * as HttpClientResponse from "./HttpClientResponse.ts" /** - * @since 1.0.0 + * @since 4.0.0 * @category tags */ export const Fetch = ServiceMap.Reference("effect/http/FetchHttpClient/Fetch", { @@ -19,7 +19,7 @@ export const Fetch = ServiceMap.Reference("effect/http/ }) /** - * @since 1.0.0 + * @since 4.0.0 * @category tags */ export class RequestInit @@ -64,7 +64,7 @@ const fetch: HttpClient.HttpClient = HttpClient.make((request, url, signal, fibe }) /** - * @since 1.0.0 + * @since 4.0.0 * @category layers */ export const layer: Layer.Layer = HttpClient.layerMergedServices(Effect.succeed(fetch)) diff --git a/packages/effect/src/unstable/http/HttpRouter.ts b/packages/effect/src/unstable/http/HttpRouter.ts index a7639a68e2..d75c164b06 100644 --- a/packages/effect/src/unstable/http/HttpRouter.ts +++ b/packages/effect/src/unstable/http/HttpRouter.ts @@ -1106,7 +1106,7 @@ export const serve = | Request.On ) => Effect.Effect } ): Layer.Layer< - never, + A, Request.Without, HttpServer.HttpServer | Exclude | Exclude, HttpRouter> > => { @@ -1123,7 +1123,7 @@ export const serve = | Request.On return middleware ? HttpServer.serve(handler, middleware) : HttpServer.serve(handler) }).pipe( Layer.unwrap, - Layer.provide(appLayer), + Layer.provideMerge(appLayer), Layer.provide(RouterLayer), options?.disableListenLog ? identity : HttpServer.withLogAddress ) as any diff --git a/packages/effect/src/unstable/http/Multipart.ts b/packages/effect/src/unstable/http/Multipart.ts index 1cd91814e9..733b445368 100644 --- a/packages/effect/src/unstable/http/Multipart.ts +++ b/packages/effect/src/unstable/http/Multipart.ts @@ -142,7 +142,7 @@ export type ErrorTypeId = "~effect/http/Multipart/MultipartError" export class MultipartError extends Schema.ErrorClass(ErrorTypeId)({ _tag: Schema.tag("MultipartError"), reason: Schema.Literals(["FileTooLarge", "FieldTooLarge", "BodyTooLarge", "TooManyParts", "InternalError", "Parse"]), - cause: Schema.Unknown + cause: Schema.Defect }) { /** * @since 4.0.0 diff --git a/packages/effect/src/unstable/http/index.ts b/packages/effect/src/unstable/http/index.ts index 636a85a223..e02f4d0fb9 100644 --- a/packages/effect/src/unstable/http/index.ts +++ b/packages/effect/src/unstable/http/index.ts @@ -13,7 +13,7 @@ export * as Cookies from "./Cookies.ts" export * as Etag from "./Etag.ts" /** - * @since 1.0.0 + * @since 4.0.0 */ export * as FetchHttpClient from "./FetchHttpClient.ts" diff --git a/packages/effect/src/unstable/httpapi/HttpApiBuilder.ts b/packages/effect/src/unstable/httpapi/HttpApiBuilder.ts index dc599fd030..327a021a9e 100644 --- a/packages/effect/src/unstable/httpapi/HttpApiBuilder.ts +++ b/packages/effect/src/unstable/httpapi/HttpApiBuilder.ts @@ -45,7 +45,7 @@ import * as OpenApi from "./OpenApi.ts" /** * Register an `HttpApi` with a `HttpRouter`. * - * @since 1.0.0 + * @since 4.0.0 * @category constructors */ export const layer = ( @@ -202,12 +202,12 @@ export interface Handlers< } /** - * @since 1.0.0 + * @since 4.0.0 * @category handlers */ export declare namespace Handlers { /** - * @since 1.0.0 + * @since 4.0.0 * @category handlers */ export interface Any { @@ -215,7 +215,7 @@ export declare namespace Handlers { } /** - * @since 1.0.0 + * @since 4.0.0 * @category handlers */ export type Item = { @@ -226,7 +226,7 @@ export declare namespace Handlers { } /** - * @since 1.0.0 + * @since 4.0.0 * @category handlers */ export type FromGroup = Handlers< @@ -235,7 +235,7 @@ export declare namespace Handlers { > /** - * @since 1.0.0 + * @since 4.0.0 * @category handlers */ export type ValidateReturn = A extends ( @@ -256,7 +256,7 @@ export declare namespace Handlers { `Must return the implemented handlers` /** - * @since 1.0.0 + * @since 4.0.0 * @category handlers */ export type Error = A extends Effect.Effect< @@ -270,7 +270,7 @@ export declare namespace Handlers { never /** - * @since 1.0.0 + * @since 4.0.0 * @category handlers */ export type Context = A extends Handlers< @@ -289,7 +289,7 @@ export declare namespace Handlers { } /** - * @since 1.0.0 + * @since 4.0.0 * @category security */ export const securityDecode = ( diff --git a/packages/effect/src/unstable/httpapi/HttpApiError.ts b/packages/effect/src/unstable/httpapi/HttpApiError.ts index 4ec59a18ee..02acf82f7a 100644 --- a/packages/effect/src/unstable/httpapi/HttpApiError.ts +++ b/packages/effect/src/unstable/httpapi/HttpApiError.ts @@ -1,25 +1,25 @@ /** - * @since 1.0.0 + * @since 4.0.0 */ import * as Effect from "../../Effect.ts" import * as Schema from "../../schema/Schema.ts" import * as HttpApiSchema from "./HttpApiSchema.ts" /** - * @since 1.0.0 + * @since 4.0.0 * @category type ids */ export const TypeId: TypeId = "~effect/httpapi/HttpApiError" /** - * @since 1.0.0 + * @since 4.0.0 * @category type ids */ export type TypeId = "~effect/httpapi/HttpApiError" // TODO: Add schema for structured issues // /** -// * @since 1.0.0 +// * @since 4.0.0 // * @category schemas // */ // export class Issue extends Schema.ArrayFormatterIssue.annotations({ @@ -28,7 +28,7 @@ export type TypeId = "~effect/httpapi/HttpApiError" // }) {} /** - * @since 1.0.0 + * @since 4.0.0 * @category errors */ export class HttpApiSchemaError extends Schema.ErrorClass("effect/HttpApiSchemaError")({ @@ -40,13 +40,13 @@ export class HttpApiSchemaError extends Schema.ErrorClass("e description: "The request or response did not match the expected schema" }) { /** - * @since 1.0.0 + * @since 4.0.0 */ static fromSchemaError(error: Schema.SchemaError): HttpApiSchemaError { return new HttpApiSchemaError({ message: error.message }) } /** - * @since 1.0.0 + * @since 4.0.0 */ static refailSchemaError(error: Schema.SchemaError): Effect.Effect { return Effect.fail(HttpApiSchemaError.fromSchemaError(error)) @@ -54,7 +54,7 @@ export class HttpApiSchemaError extends Schema.ErrorClass("e } /** - * @since 1.0.0 + * @since 4.0.0 * @category empty errors */ export class BadRequest extends HttpApiSchema.EmptyError()({ @@ -63,7 +63,7 @@ export class BadRequest extends HttpApiSchema.EmptyError()({ }) {} /** - * @since 1.0.0 + * @since 4.0.0 * @category empty errors */ export class Unauthorized extends HttpApiSchema.EmptyError()({ @@ -72,7 +72,7 @@ export class Unauthorized extends HttpApiSchema.EmptyError()({ }) {} /** - * @since 1.0.0 + * @since 4.0.0 * @category empty errors */ export class Forbidden extends HttpApiSchema.EmptyError()({ @@ -81,7 +81,7 @@ export class Forbidden extends HttpApiSchema.EmptyError()({ }) {} /** - * @since 1.0.0 + * @since 4.0.0 * @category empty errors */ export class NotFound extends HttpApiSchema.EmptyError()({ @@ -90,7 +90,7 @@ export class NotFound extends HttpApiSchema.EmptyError()({ }) {} /** - * @since 1.0.0 + * @since 4.0.0 * @category empty errors */ export class MethodNotAllowed extends HttpApiSchema.EmptyError()({ @@ -99,7 +99,7 @@ export class MethodNotAllowed extends HttpApiSchema.EmptyError }) {} /** - * @since 1.0.0 + * @since 4.0.0 * @category empty errors */ export class NotAcceptable extends HttpApiSchema.EmptyError()({ @@ -108,7 +108,7 @@ export class NotAcceptable extends HttpApiSchema.EmptyError()({ }) {} /** - * @since 1.0.0 + * @since 4.0.0 * @category empty errors */ export class RequestTimeout extends HttpApiSchema.EmptyError()({ @@ -117,7 +117,7 @@ export class RequestTimeout extends HttpApiSchema.EmptyError()({ }) {} /** - * @since 1.0.0 + * @since 4.0.0 * @category empty errors */ export class Conflict extends HttpApiSchema.EmptyError()({ @@ -126,7 +126,7 @@ export class Conflict extends HttpApiSchema.EmptyError()({ }) {} /** - * @since 1.0.0 + * @since 4.0.0 * @category empty errors */ export class Gone extends HttpApiSchema.EmptyError()({ @@ -135,7 +135,7 @@ export class Gone extends HttpApiSchema.EmptyError()({ }) {} /** - * @since 1.0.0 + * @since 4.0.0 * @category empty errors */ export class InternalServerError extends HttpApiSchema.EmptyError()({ @@ -144,7 +144,7 @@ export class InternalServerError extends HttpApiSchema.EmptyError()({ @@ -153,7 +153,7 @@ export class NotImplemented extends HttpApiSchema.EmptyError()({ }) {} /** - * @since 1.0.0 + * @since 4.0.0 * @category empty errors */ export class ServiceUnavailable extends HttpApiSchema.EmptyError()({ diff --git a/packages/effect/src/unstable/httpapi/HttpApiSchema.ts b/packages/effect/src/unstable/httpapi/HttpApiSchema.ts index ad2959e45e..a826782bfe 100644 --- a/packages/effect/src/unstable/httpapi/HttpApiSchema.ts +++ b/packages/effect/src/unstable/httpapi/HttpApiSchema.ts @@ -437,7 +437,7 @@ const encodingJson: Encoding = { } /** - * @since 1.0.0 + * @since 4.0.0 * @category annotations */ export const getEncoding = (ast: AST.AST, fallback = encodingJson): Encoding => diff --git a/packages/effect/src/unstable/httpapi/index.ts b/packages/effect/src/unstable/httpapi/index.ts index a0de6397ce..27f1229f9a 100644 --- a/packages/effect/src/unstable/httpapi/index.ts +++ b/packages/effect/src/unstable/httpapi/index.ts @@ -23,7 +23,7 @@ export * as HttpApiClient from "./HttpApiClient.ts" export * as HttpApiEndpoint from "./HttpApiEndpoint.ts" /** - * @since 1.0.0 + * @since 4.0.0 */ export * as HttpApiError from "./HttpApiError.ts" diff --git a/packages/effect/src/unstable/reactivity/Reactivity.ts b/packages/effect/src/unstable/reactivity/Reactivity.ts new file mode 100644 index 0000000000..2a964ae503 --- /dev/null +++ b/packages/effect/src/unstable/reactivity/Reactivity.ts @@ -0,0 +1,258 @@ +/** + * @since 4.0.0 + */ +import type { ReadonlyRecord } from "../../data/Record.ts" +import * as Effect from "../../Effect.ts" +import * as Exit from "../../Exit.ts" +import * as FiberHandle from "../../FiberHandle.ts" +import { dual } from "../../Function.ts" +import * as Hash from "../../interfaces/Hash.ts" +import * as Layer from "../../Layer.ts" +import * as Queue from "../../Queue.ts" +import * as Scope from "../../Scope.ts" +import * as ServiceMap from "../../ServiceMap.ts" +import * as Stream from "../../stream/Stream.ts" + +/** + * @since 4.0.0 + * @category tags + */ +export class Reactivity extends ServiceMap.Key< + Reactivity, + { + readonly unsafeInvalidate: (keys: ReadonlyArray | ReadonlyRecord>) => void + readonly unsafeRegister: ( + keys: ReadonlyArray | ReadonlyRecord>, + handler: () => void + ) => () => void + readonly invalidate: ( + keys: ReadonlyArray | ReadonlyRecord> + ) => Effect.Effect + readonly mutation: ( + keys: ReadonlyArray | ReadonlyRecord>, + effect: Effect.Effect + ) => Effect.Effect + readonly query: ( + keys: ReadonlyArray | ReadonlyRecord>, + effect: Effect.Effect + ) => Effect.Effect, never, R | Scope.Scope> + readonly stream: ( + keys: ReadonlyArray | ReadonlyRecord>, + effect: Effect.Effect + ) => Stream.Stream> + } +>()("effect/experimental/Reactivity") {} + +/** + * @since 4.0.0 + * @category constructors + */ +export const make = Effect.sync(() => { + const handlers = new Map void>>() + + const unsafeInvalidate = (keys: ReadonlyArray | ReadonlyRecord>): void => { + if (Array.isArray(keys)) { + for (let i = 0; i < keys.length; i++) { + const set = handlers.get(stringOrHash(keys[i])) + if (set === undefined) continue + for (const run of set) run() + } + } else { + const record = keys as ReadonlyRecord> + for (const key in record) { + const hashes = idHashes(key, record[key]) + for (let i = 0; i < hashes.length; i++) { + const set = handlers.get(hashes[i]) + if (set === undefined) continue + for (const run of set) run() + } + + const set = handlers.get(key) + if (set !== undefined) { + for (const run of set) run() + } + } + } + } + + const invalidate = ( + keys: ReadonlyArray | ReadonlyRecord> + ): Effect.Effect => Effect.sync(() => unsafeInvalidate(keys)) + + const mutation = ( + keys: ReadonlyArray | ReadonlyRecord>, + effect: Effect.Effect + ): Effect.Effect => Effect.tap(effect, invalidate(keys)) + + const unsafeRegister = ( + keys: ReadonlyArray | ReadonlyRecord>, + handler: () => void + ): () => void => { + const resolvedKeys = Array.isArray(keys) ? keys.map(stringOrHash) : recordHashes(keys as any) + for (let i = 0; i < resolvedKeys.length; i++) { + let set = handlers.get(resolvedKeys[i]) + if (set === undefined) { + set = new Set() + handlers.set(resolvedKeys[i], set) + } + set.add(handler) + } + return () => { + for (let i = 0; i < resolvedKeys.length; i++) { + const set = handlers.get(resolvedKeys[i])! + set.delete(handler) + if (set.size === 0) { + handlers.delete(resolvedKeys[i]) + } + } + } + } + + const query = ( + keys: ReadonlyArray | ReadonlyRecord>, + effect: Effect.Effect + ): Effect.Effect, never, R | Scope.Scope> => + Effect.gen(function*() { + const scope = yield* Effect.scope + const results = yield* Queue.make() + const runFork = yield* FiberHandle.makeRuntime() + + let running = false + let pending = false + const handleExit = (exit: Exit.Exit) => { + if (exit._tag === "Failure") { + Queue.unsafeDone(results, Exit.failCause(exit.cause)) + } else { + Queue.unsafeOffer(results, exit.value) + } + if (pending) { + pending = false + runFork(effect).addObserver(handleExit) + } else { + running = false + } + } + + function run() { + if (running) { + pending = true + return + } + running = true + runFork(effect).addObserver(handleExit) + } + + const cancel = unsafeRegister(keys, run) + yield* Scope.addFinalizer(scope, Effect.sync(cancel)) + run() + + return results as Queue.Dequeue + }) + + const stream = ( + tables: ReadonlyArray | ReadonlyRecord>, + effect: Effect.Effect + ): Stream.Stream> => + query(tables, effect).pipe( + Effect.map(Stream.fromQueue), + Stream.unwrap + ) + + return Reactivity.of({ mutation, query, stream, unsafeInvalidate, invalidate, unsafeRegister }) +}) + +/** + * @since 4.0.0 + * @category accessors + */ +export const mutation: { + ( + keys: ReadonlyArray | ReadonlyRecord> + ): (effect: Effect.Effect) => Effect.Effect + ( + effect: Effect.Effect, + keys: ReadonlyArray | ReadonlyRecord> + ): Effect.Effect +} = dual(2, ( + effect: Effect.Effect, + keys: ReadonlyArray | ReadonlyRecord> +): Effect.Effect => Effect.flatMap(Reactivity.asEffect(), (r) => r.mutation(keys, effect))) + +/** + * @since 4.0.0 + * @category accessors + */ +export const query: { + ( + keys: ReadonlyArray | ReadonlyRecord> + ): ( + effect: Effect.Effect + ) => Effect.Effect, never, R | Scope.Scope | Reactivity> + ( + effect: Effect.Effect, + keys: ReadonlyArray | ReadonlyRecord> + ): Effect.Effect, never, R | Scope.Scope | Reactivity> +} = dual(2, ( + effect: Effect.Effect, + keys: ReadonlyArray | ReadonlyRecord> +): Effect.Effect, never, R | Scope.Scope | Reactivity> => + Effect.flatMap(Reactivity.asEffect(), (r) => r.query(keys, effect))) + +/** + * @since 4.0.0 + * @category accessors + */ +export const stream: { + ( + keys: ReadonlyArray | ReadonlyRecord> + ): (effect: Effect.Effect) => Stream.Stream | Reactivity> + ( + effect: Effect.Effect, + keys: ReadonlyArray | ReadonlyRecord> + ): Stream.Stream | Reactivity> +} = dual(2, ( + effect: Effect.Effect, + keys: ReadonlyArray | ReadonlyRecord> +): Stream.Stream | Reactivity> => + Reactivity.asEffect().pipe( + Effect.flatMap((r) => r.query(keys, effect)), + Effect.map(Stream.fromQueue), + Stream.unwrap + )) + +/** + * @since 4.0.0 + * @category accessors + */ +export const invalidate = ( + keys: ReadonlyArray | ReadonlyRecord> +): Effect.Effect => Effect.flatMap(Reactivity.asEffect(), (r) => r.invalidate(keys)) + +/** + * @since 4.0.0 + * @category layers + */ +export const layer: Layer.Layer = Layer.effect(Reactivity)(make) + +function stringOrHash(u: unknown): string | number { + return typeof u === "string" ? u : Hash.hash(u) +} + +const idHashes = (keyHash: number | string, ids: ReadonlyArray): ReadonlyArray => { + const hashes: Array = new Array(ids.length) + for (let i = 0; i < ids.length; i++) { + hashes[i] = `${keyHash}:${stringOrHash(ids[i])}` + } + return hashes +} + +const recordHashes = (record: ReadonlyRecord>): ReadonlyArray => { + const hashes: Array = [] + for (const key in record) { + hashes.push(key) + for (const idHash of idHashes(key, record[key])) { + hashes.push(idHash) + } + } + return hashes +} diff --git a/packages/effect/src/unstable/reactivity/index.ts b/packages/effect/src/unstable/reactivity/index.ts new file mode 100644 index 0000000000..e7b6613ef3 --- /dev/null +++ b/packages/effect/src/unstable/reactivity/index.ts @@ -0,0 +1,8 @@ +/** + * @since 4.0.0 + */ + +/** + * @since 4.0.0 + */ +export * as Reactivity from "./Reactivity.ts" diff --git a/packages/effect/src/unstable/reactivity/index.ts.tpl b/packages/effect/src/unstable/reactivity/index.ts.tpl new file mode 100644 index 0000000000..c2aac82f76 --- /dev/null +++ b/packages/effect/src/unstable/reactivity/index.ts.tpl @@ -0,0 +1,3 @@ +/** + * @since 4.0.0 + */ diff --git a/packages/effect/src/unstable/rpc/Rpc.ts b/packages/effect/src/unstable/rpc/Rpc.ts index 4120abf421..d9affdceaa 100644 --- a/packages/effect/src/unstable/rpc/Rpc.ts +++ b/packages/effect/src/unstable/rpc/Rpc.ts @@ -322,7 +322,7 @@ export type Payload = R extends Rpc< * @since 4.0.0 * @category models */ -export type ServicesServer = R extends Rpc< +export type Services = R extends Rpc< infer _Tag, infer _Payload, infer _Success, @@ -331,8 +331,12 @@ export type ServicesServer = R extends Rpc< infer _Requires > ? | _Payload["DecodingServices"] + | _Payload["EncodingServices"] + | _Success["DecodingServices"] | _Success["EncodingServices"] + | _Error["DecodingServices"] | _Error["EncodingServices"] + | _Middleware["error"]["DecodingServices"] | _Middleware["error"]["EncodingServices"] : never @@ -354,6 +358,24 @@ export type ServicesClient = R extends Rpc< | _Middleware["error"]["DecodingServices"] : never +/** + * @since 4.0.0 + * @category models + */ +export type ServicesServer = R extends Rpc< + infer _Tag, + infer _Payload, + infer _Success, + infer _Error, + infer _Middleware, + infer _Requires +> ? + | _Payload["DecodingServices"] + | _Success["EncodingServices"] + | _Error["EncodingServices"] + | _Middleware["error"]["EncodingServices"] + : never + /** * @since 4.0.0 * @category models diff --git a/packages/effect/src/unstable/rpc/RpcClient.ts b/packages/effect/src/unstable/rpc/RpcClient.ts index b51b824885..097fa465a8 100644 --- a/packages/effect/src/unstable/rpc/RpcClient.ts +++ b/packages/effect/src/unstable/rpc/RpcClient.ts @@ -87,12 +87,12 @@ export declare namespace RpcClient { Current in Rpcs as Current["_tag"] extends `${Prefix}.${infer Method}` ? Method : Current["_tag"] ]: < - const AsMailbox extends boolean = false, + const AsQueue extends boolean = false, const Discard = false >( input: Rpc.PayloadConstructor, options?: Rpc.Success extends Stream.Stream ? { - readonly asMailbox?: AsMailbox | undefined + readonly asQueue?: AsQueue | undefined readonly streamBufferSize?: number | undefined readonly headers?: Headers.Input | undefined readonly context?: ServiceMap.ServiceMap | undefined @@ -109,7 +109,7 @@ export declare namespace RpcClient { infer _Error, infer _Middleware, infer _Requires - > ? [_Success] extends [RpcSchema.Stream] ? AsMailbox extends true ? Effect.Effect< + > ? [_Success] extends [RpcSchema.Stream] ? AsQueue extends true ? Effect.Effect< Queue.Dequeue<_A["Type"], _E["Type"] | _Error["Type"] | E | _Middleware["error"]["Type"] | Queue.Done>, never, | Scope.Scope @@ -143,13 +143,13 @@ export declare namespace RpcClient { */ export type Flat = < const Tag extends Rpcs["_tag"], - const AsMailbox extends boolean = false, + const AsQueue extends boolean = false, const Discard = false >( tag: Tag, payload: Rpc.PayloadConstructor>, options?: Rpc.Success> extends Stream.Stream ? { - readonly asMailbox?: AsMailbox | undefined + readonly asQueue?: AsQueue | undefined readonly streamBufferSize?: number | undefined readonly headers?: Headers.Input | undefined readonly context?: ServiceMap.ServiceMap | undefined @@ -166,7 +166,7 @@ export declare namespace RpcClient { infer _Error, infer _Middleware, infer _Requires - > ? [_Success] extends [RpcSchema.Stream] ? AsMailbox extends true ? Effect.Effect< + > ? [_Success] extends [RpcSchema.Stream] ? AsQueue extends true ? Effect.Effect< Queue.Dequeue<_A["Type"], _E["Type"] | _Error["Type"] | E | _Middleware["error"]["Type"]>, never, | Scope.Scope @@ -294,7 +294,7 @@ export const makeNoSerialization: | undefined @@ -327,7 +327,7 @@ export const makeNoSerialization: , payload, - traceId: span?.traceId, - spanId: span?.spanId, - sampled: span?.sampled, + ...(span ? + { + traceId: span.traceId, + spanId: span.spanId, + sampled: span.sampled + } : + {}), headers: Headers.merge(parentFiber.getRef(CurrentHeaders), headers) } ) @@ -465,17 +469,21 @@ export const makeNoSerialization: , - traceId: span?.traceId, payload, - spanId: span?.spanId, - sampled: span?.sampled, + ...(span ? + { + traceId: span.traceId, + spanId: span.spanId, + sampled: span.sampled + } : + {}), headers: Headers.merge(fiber.getRef(CurrentHeaders), headers) } ).pipe( span ? Effect.withParentSpan(span) : identity, Effect.catchCause((error) => Queue.failCause(queue, error)), Effect.interruptible, - Effect.forkIn(scope) + Effect.forkIn(scope, { startImmediately: true }) ) return queue diff --git a/packages/effect/src/unstable/rpc/RpcMessage.ts b/packages/effect/src/unstable/rpc/RpcMessage.ts index 72b6a63dd8..c175fe3923 100644 --- a/packages/effect/src/unstable/rpc/RpcMessage.ts +++ b/packages/effect/src/unstable/rpc/RpcMessage.ts @@ -43,9 +43,9 @@ export interface RequestEncoded { readonly tag: string readonly payload: unknown readonly headers: ReadonlyArray<[string, string]> - readonly traceId?: string | undefined - readonly spanId?: string | undefined - readonly sampled?: boolean | undefined + readonly traceId?: string + readonly spanId?: string + readonly sampled?: boolean } /** @@ -58,9 +58,9 @@ export interface Request { readonly tag: Rpc.Tag readonly payload: Rpc.Payload readonly headers: Headers - readonly traceId?: string | undefined - readonly spanId?: string | undefined - readonly sampled?: boolean | undefined + readonly traceId?: string + readonly spanId?: string + readonly sampled?: boolean } /** diff --git a/packages/effect/src/unstable/rpc/RpcSerialization.ts b/packages/effect/src/unstable/rpc/RpcSerialization.ts index 3f6e94d4bd..285a8de150 100644 --- a/packages/effect/src/unstable/rpc/RpcSerialization.ts +++ b/packages/effect/src/unstable/rpc/RpcSerialization.ts @@ -202,9 +202,13 @@ function decodeJsonRpcMessage(decoded: JsonRpcMessage): RpcMessage.FromClientEnc tag: decoded.method, payload: decoded.params, headers: decoded.headers ?? [], - traceId: decoded.traceId, - spanId: decoded.spanId, - sampled: decoded.sampled + ...(decoded.spanId ? + { + traceId: decoded.traceId, + spanId: decoded.spanId!, + sampled: decoded.sampled! + } : + {}) } } else if (decoded.error && decoded.error._tag === "Defect") { return { diff --git a/packages/effect/src/unstable/rpc/RpcServer.ts b/packages/effect/src/unstable/rpc/RpcServer.ts index c11ca61b1e..e867a62875 100644 --- a/packages/effect/src/unstable/rpc/RpcServer.ts +++ b/packages/effect/src/unstable/rpc/RpcServer.ts @@ -95,6 +95,7 @@ export const makeNoSerialization: ( const disableFatalDefects = options.disableFatalDefects ?? false const services = yield* Effect.services | Scope.Scope>() const scope = ServiceMap.get(services, Scope.Scope) + const fiberScope = yield* Scope.fork(scope, "parallel") const concurrencySemaphore = concurrency === "unbounded" ? undefined : yield* Effect.makeSemaphore(concurrency) @@ -118,7 +119,7 @@ export const makeNoSerialization: ( if (client.fibers.size === 0) { Fiber.runIn( Effect.runForkWith(services)(endClient(client)), - scope + fiberScope ) continue } @@ -171,12 +172,14 @@ export const makeNoSerialization: ( } case "Interrupt": { const fiber = client.fibers.get(message.requestId) - return fiber ? Effect.forkDaemon(Fiber.interrupt(fiber)) : options.onFromServer({ - _tag: "Exit", - clientId, - requestId: message.requestId, - exit: Exit.interrupt() - }) + return fiber ? + Effect.forkDaemon(Fiber.interrupt(fiber), { startImmediately: true }) : + options.onFromServer({ + _tag: "Exit", + clientId, + requestId: message.requestId, + exit: Exit.interrupt() + }) } case "Eof": { client.ended = true @@ -307,7 +310,7 @@ export const makeNoSerialization: ( effect = concurrencySemaphore.withPermits(1)(effect) } const runFork = Effect.runForkWith(ServiceMap.merge(entry.services, requestFiber.services)) - const fiber = Fiber.runIn(runFork(effect), scope) + const fiber = Fiber.runIn(runFork(effect), fiberScope) client.fibers.set(request.id, fiber) fiber.addObserver((exit) => { if (!responded && exit._tag === "Failure") { @@ -318,13 +321,13 @@ export const makeNoSerialization: ( requestId: request.id, exit: Exit.interrupt() })), - scope + fiberScope ) } client.fibers.delete(request.id) client.latches.delete(request.id) if (client.ended && client.fibers.size === 0) { - Fiber.runIn(runFork(endClient(client)), scope) + Fiber.runIn(runFork(endClient(client)), fiberScope) } }) return Effect.void @@ -1091,7 +1094,7 @@ export const makeProtocolStdio = Effect.fnUntraced(function*("Group")({ + * id: Model.Generated(GroupId), + * name: Schema.String, + * createdAt: Model.DateTimeInsertFromDate, + * updatedAt: Model.DateTimeUpdateFromDate + * }) {} + * + * // schema used for selects + * Group + * + * // schema used for inserts + * Group.insert + * + * // schema used for updates + * Group.update + * + * // schema used for json api + * Group.json + * Group.jsonCreate + * Group.jsonUpdate + * + * // you can also turn them into classes + * class GroupJson extends Schema.Class("GroupJson")(Group.json) { + * get upperName() { + * return this.name.toUpperCase() + * } + * } + * ``` + */ + Class, + /** + * @since 4.0.0 + * @category extraction + */ + extract, + /** + * @since 4.0.0 + * @category fields + */ + Field, + /** + * @since 4.0.0 + * @category fields + */ + fieldEvolve, + /** + * @since 4.0.0 + * @category fields + */ + FieldExcept, + /** + * @since 4.0.0 + * @category fields + */ + FieldOnly, + /** + * @since 4.0.0 + * @category constructors + */ + Struct, + /** + * @since 4.0.0 + * @category constructors + */ + Union +} + +/** + * @since 4.0.0 + * @category fields + */ +export const fields: >(self: A) => A[VariantSchema.TypeId] = VariantSchema.fields + +/** + * @since 4.0.0 + * @category overrideable + */ +export const Override: (value: A) => A & Brand<"Override"> = VariantSchema.Override + +/** + * @since 4.0.0 + * @category generated + */ +export interface Generated extends + VariantSchema.Field<{ + readonly select: S + readonly update: S + readonly json: S + }> +{} + +/** + * A field that represents a column that is generated by the database. + * + * It is available for selection and update, but not for insertion. + * + * @since 4.0.0 + * @category generated + */ +export const Generated = ( + schema: S +): Generated => + Field({ + select: schema, + update: schema, + json: schema + }) + +/** + * @since 4.0.0 + * @category generated + */ +export interface GeneratedByApp extends + VariantSchema.Field<{ + readonly select: S + readonly insert: S + readonly update: S + readonly json: S + }> +{} + +/** + * A field that represents a column that is generated by the application. + * + * It is required by the database, but not by the JSON variants. + * + * @since 4.0.0 + * @category generated + */ +export const GeneratedByApp = (schema: S): GeneratedByApp => + Field({ + select: schema, + insert: schema, + update: schema, + json: schema + }) + +/** + * @since 4.0.0 + * @category sensitive + */ +export interface Sensitive extends + VariantSchema.Field<{ + readonly select: S + readonly insert: S + readonly update: S + }> +{} + +/** + * A field that represents a sensitive value that should not be exposed in the + * JSON variants. + * + * @since 4.0.0 + * @category sensitive + */ +export const Sensitive = (schema: S): Sensitive => + Field({ + select: schema, + insert: schema, + update: schema + }) + +/** + * @since 4.0.0 + * @category optional + */ +export interface optionalOption + extends Schema.decodeTo>, Schema.optionalKey>> +{} + +/** + * @since 4.0.0 + * @category optional + */ +export const optionalOption = (schema: S): optionalOption => + Schema.optionalKey(Schema.NullOr(schema)).pipe( + Schema.decodeTo( + Schema.Option(Schema.typeCodec(schema)), + Transformation.transformOptional, S["Type"] | null>({ + decode: (oe) => oe.pipe(Option.filter(Predicate.isNotNull), Option.some), + encode: Option.flatten + }) as any + ) + ) + +/** + * Convert a field to one that is optional for all variants. + * + * For the database variants, it will accept `null`able values. + * For the JSON variants, it will also accept missing keys. + * + * @since 4.0.0 + * @category optional + */ +export interface FieldOption extends + VariantSchema.Field<{ + readonly select: Schema.OptionFromNullOr + readonly insert: Schema.OptionFromNullOr + readonly update: Schema.OptionFromNullOr + readonly json: optionalOption + readonly jsonCreate: optionalOption + readonly jsonUpdate: optionalOption + }> +{} + +/** + * Convert a field to one that is optional for all variants. + * + * For the database variants, it will accept `null`able values. + * For the JSON variants, it will also accept missing keys. + * + * @since 4.0.0 + * @category optional + */ +export const FieldOption: | Schema.Top>( + self: Field +) => Field extends Schema.Top ? FieldOption + : Field extends VariantSchema.Field ? VariantSchema.Field< + { + readonly [K in keyof S]: S[K] extends Schema.Top ? K extends VariantsDatabase ? Schema.OptionFromNullOr : + optionalOption + : never + } + > : + never = fieldEvolve({ + select: Schema.OptionFromNullOr, + insert: Schema.OptionFromNullOr, + update: Schema.OptionFromNullOr, + json: optionalOption, + jsonCreate: optionalOption, + jsonUpdate: optionalOption + }) as any + +/** + * @since 4.0.0 + * @category date & time + */ +export const DateTimeFromInput = Getter.onSome((input) => { + try { + return Effect.succeedSome(DateTime.unsafeMake(input) as DateTime.Utc) + } catch { + return Effect.fail( + new Issue.InvalidValue(Option.some(input), { + description: "Invalid DateTime input" + }) + ) + } +}) + +/** + * @since 4.0.0 + * @category date & time + */ +export interface DateTimeFromDate extends Schema.decodeTo, Schema.ValidDate> {} + +/** + * @since 4.0.0 + * @category date & time + */ +export const DateTimeFromDate: DateTimeFromDate = Schema.ValidDate.pipe( + Schema.decodeTo(Schema.DateTimeUtc, { + decode: DateTimeFromInput, + encode: Getter.map(DateTime.toDateUtc) + }) +) + +/** + * @since 4.0.0 + * @category date & time + */ +export const DateFromInput = DateTimeFromInput.compose( + Getter.map(DateTime.removeTime) +) + +/** + * @since 4.0.0 + * @category date & time + */ +export interface Date extends + Schema.decodeTo< + Schema.instanceOf, + Schema.String + > +{} + +/** + * A schema for a `DateTime.Utc` that is serialized as a date string in the + * format `YYYY-MM-DD`. + * + * @since 4.0.0 + * @category date & time + */ +export const Date: Date = Schema.String.pipe( + Schema.decodeTo(Schema.DateTimeUtc, { + decode: DateFromInput, + encode: Getter.map(DateTime.formatIsoDate) + }) +) + +/** + * @since 4.0.0 + * @category date & time + */ +export const DateWithNow = VariantSchema.Overrideable(Date, { + defaultValue: Effect.map(DateTime.now, DateTime.removeTime) +}) + +/** + * @since 4.0.0 + * @category date & time + */ +export interface DateTimeFromString extends Schema.decodeTo, Schema.String> {} + +/** + * @since 4.0.0 + * @category date & time + */ +export const DateTimeFromString: DateTimeFromString = Schema.String.pipe( + Schema.decodeTo(Schema.DateTimeUtc, { + decode: DateTimeFromInput, + encode: Getter.map(DateTime.formatIso) + }) +) + +/** + * @since 4.0.0 + * @category date & time + */ +export const DateTimeWithNow = VariantSchema.Overrideable(DateTimeFromString, { + defaultValue: DateTime.now +}) + +/** + * @since 4.0.0 + * @category date & time + */ +export const DateTimeFromDateWithNow = VariantSchema.Overrideable(DateTimeFromDate, { + defaultValue: DateTime.now +}) + +/** + * @since 4.0.0 + * @category date & time + */ +export interface DateTimeFromNumber extends Schema.decodeTo, Schema.Number> {} + +/** + * @since 4.0.0 + * @category date & time + */ +export const DateTimeFromNumber: DateTimeFromNumber = Schema.Number.pipe( + Schema.decodeTo(Schema.DateTimeUtc, { + decode: DateTimeFromInput, + encode: Getter.map(DateTime.toEpochMillis) + }) +) + +/** + * @since 4.0.0 + * @category date & time + */ +export const DateTimeFromNumberWithNow = VariantSchema.Overrideable(DateTimeFromNumber, { + defaultValue: DateTime.now +}) + +/** + * @since 4.0.0 + * @category date & time + */ +export interface DateTimeInsert extends + VariantSchema.Field<{ + readonly select: DateTimeFromString + readonly insert: VariantSchema.Overrideable + readonly json: DateTimeFromString + }> +{} + +/** + * A field that represents a date-time value that is inserted as the current + * `DateTime.Utc`. It is serialized as a string for the database. + * + * It is omitted from updates and is available for selection. + * + * @since 4.0.0 + * @category date & time + */ +export const DateTimeInsert: DateTimeInsert = Field({ + select: DateTimeFromString, + insert: DateTimeWithNow, + json: DateTimeFromString +}) + +/** + * @since 4.0.0 + * @category date & time + */ +export interface DateTimeInsertFromDate extends + VariantSchema.Field<{ + readonly select: DateTimeFromDate + readonly insert: VariantSchema.Overrideable + readonly json: DateTimeFromString + }> +{} + +/** + * A field that represents a date-time value that is inserted as the current + * `DateTime.Utc`. It is serialized as a `Date` for the database. + * + * It is omitted from updates and is available for selection. + * + * @since 4.0.0 + * @category date & time + */ +export const DateTimeInsertFromDate: DateTimeInsertFromDate = Field({ + select: DateTimeFromDate, + insert: DateTimeFromDateWithNow, + json: DateTimeFromString +}) + +/** + * @since 4.0.0 + * @category date & time + */ +export interface DateTimeInsertFromNumber extends + VariantSchema.Field<{ + readonly select: DateTimeFromNumber + readonly insert: VariantSchema.Overrideable + readonly json: DateTimeFromNumber + }> +{} + +/** + * A field that represents a date-time value that is inserted as the current + * `DateTime.Utc`. It is serialized as a `number`. + * + * It is omitted from updates and is available for selection. + * + * @since 4.0.0 + * @category date & time + */ +export const DateTimeInsertFromNumber: DateTimeInsertFromNumber = Field({ + select: DateTimeFromNumber, + insert: DateTimeFromNumberWithNow, + json: DateTimeFromNumber +}) + +/** + * @since 4.0.0 + * @category date & time + */ +export interface DateTimeUpdate extends + VariantSchema.Field<{ + readonly select: DateTimeFromString + readonly insert: VariantSchema.Overrideable + readonly update: VariantSchema.Overrideable + readonly json: DateTimeFromString + }> +{} + +/** + * A field that represents a date-time value that is updated as the current + * `DateTime.Utc`. It is serialized as a string for the database. + * + * It is set to the current `DateTime.Utc` on updates and inserts and is + * available for selection. + * + * @since 4.0.0 + * @category date & time + */ +export const DateTimeUpdate: DateTimeUpdate = Field({ + select: DateTimeFromString, + insert: DateTimeWithNow, + update: DateTimeWithNow, + json: DateTimeFromString +}) + +/** + * @since 4.0.0 + * @category date & time + */ +export interface DateTimeUpdateFromDate extends + VariantSchema.Field<{ + readonly select: DateTimeFromDate + readonly insert: VariantSchema.Overrideable + readonly update: VariantSchema.Overrideable + readonly json: DateTimeFromString + }> +{} + +/** + * A field that represents a date-time value that is updated as the current + * `DateTime.Utc`. It is serialized as a `Date` for the database. + * + * It is set to the current `DateTime.Utc` on updates and inserts and is + * available for selection. + * + * @since 4.0.0 + * @category date & time + */ +export const DateTimeUpdateFromDate: DateTimeUpdateFromDate = Field({ + select: DateTimeFromDate, + insert: DateTimeFromDateWithNow, + update: DateTimeFromDateWithNow, + json: DateTimeFromString +}) + +/** + * @since 4.0.0 + * @category date & time + */ +export interface DateTimeUpdateFromNumber extends + VariantSchema.Field<{ + readonly select: DateTimeFromNumber + readonly insert: VariantSchema.Overrideable + readonly update: VariantSchema.Overrideable + readonly json: DateTimeFromNumber + }> +{} + +/** + * A field that represents a date-time value that is updated as the current + * `DateTime.Utc`. It is serialized as a `number`. + * + * It is set to the current `DateTime.Utc` on updates and inserts and is + * available for selection. + * + * @since 4.0.0 + * @category date & time + */ +export const DateTimeUpdateFromNumber: DateTimeUpdateFromNumber = Field({ + select: DateTimeFromNumber, + insert: DateTimeFromNumberWithNow, + update: DateTimeFromNumberWithNow, + json: DateTimeFromNumber +}) + +/** + * @since 4.0.0 + * @category json + */ +export interface JsonFromString extends + VariantSchema.Field<{ + readonly select: Schema.fromJsonString + readonly insert: Schema.fromJsonString + readonly update: Schema.fromJsonString + readonly json: S + readonly jsonCreate: S + readonly jsonUpdate: S + }> +{} + +/** + * A field that represents a JSON value stored as text in the database. + * + * The "json" variants will use the object schema directly. + * + * @since 4.0.0 + * @category json + */ +export const JsonFromString = ( + schema: S +): JsonFromString => { + const parsed = Schema.fromJsonString(schema) + return Field({ + select: parsed, + insert: parsed, + update: parsed, + json: schema, + jsonCreate: schema, + jsonUpdate: schema + }) +} + +/** + * @since 4.0.0 + * @category Brand + */ +export interface brand extends + Schema.refine< + S["Type"] & Brand, + S["~rebuild.out"] + > +{} + +/** + * @since 4.0.0 + * @category uuid + */ +export interface UuidV4Insert extends + VariantSchema.Field<{ + readonly select: brand>, B> + readonly insert: VariantSchema.Overrideable>, B>> + readonly update: brand>, B> + readonly json: brand>, B> + }> +{} + +/** + * @since 4.0.0 + * @category Uint8Array + */ +export const Uint8ArrayFromSelf: Schema.instanceOf> = Schema.instanceOf(Uint8Array) + +/** + * @since 4.0.0 + * @category uuid + */ +export const UuidV4WithGenerate = ( + schema: brand>, B> +): VariantSchema.Overrideable>, B>> => + VariantSchema.Overrideable(schema, { + defaultValue: Effect.sync(() => Uuid.v4({}, new Uint8Array(16))) + }) + +/** + * A field that represents a binary UUID v4 that is generated on inserts. + * + * @since 4.0.0 + * @category uuid + */ +export const UuidV4Insert = ( + schema: brand>, B> +): UuidV4Insert => + Field({ + select: schema, + insert: UuidV4WithGenerate(schema), + update: schema, + json: schema + }) diff --git a/packages/effect/src/unstable/schema/VariantSchema.ts b/packages/effect/src/unstable/schema/VariantSchema.ts new file mode 100644 index 0000000000..7260cf8050 --- /dev/null +++ b/packages/effect/src/unstable/schema/VariantSchema.ts @@ -0,0 +1,547 @@ +/** + * @since 4.0.0 + */ +import type { Brand } from "../../data/Brand.ts" +import * as Predicate from "../../data/Predicate.ts" +import * as Struct_ from "../../data/Struct.ts" +import * as Effect from "../../Effect.ts" +import { dual } from "../../Function.ts" +import { type Pipeable, pipeArguments } from "../../interfaces/Pipeable.ts" +import type * as Annotations from "../../schema/Annotations.ts" +import type * as AST from "../../schema/AST.ts" +import * as Schema from "../../schema/Schema.ts" + +/** + * @since 4.0.0 + * @category type ids + */ +export const TypeId: TypeId = "~effect/unstable/schema/VariantSchema" + +/** + * @since 4.0.0 + * @category type ids + */ +export type TypeId = "~effect/unstable/schema/VariantSchema" + +const cacheSymbol = Symbol.for(`${TypeId}/cache`) + +/** + * @since 4.0.0 + * @category models + */ +export interface Struct extends Pipeable { + readonly [TypeId]: A + /** @internal */ + [cacheSymbol]?: Record +} + +/** + * @since 4.0.0 + * @category guards + */ +export const isStruct = (u: unknown): u is Struct => Predicate.hasProperty(u, TypeId) + +/** + * @since 4.0.0 + * @category models + */ +export declare namespace Struct { + /** + * @since 4.0.0 + * @category models + */ + export type Any = { readonly [TypeId]: any } + + /** + * @since 4.0.0 + * @category models + */ + export type Fields = { + readonly [key: string]: + | Schema.Top + | Field + | Struct + | undefined + } + + /** + * @since 4.0.0 + * @category models + */ + export type Validate = { + readonly [K in keyof A]: A[K] extends { readonly [TypeId]: infer _ } ? Validate : + A[K] extends Field ? [keyof Config] extends [Variant] ? {} : "field must have valid variants" + : {} + } +} + +/** + * @since 4.0.0 + * @category type ids + */ +export const FieldTypeId: FieldTypeId = "~effect/unstable/schema/VariantSchema/Field" + +/** + * @since 4.0.0 + * @category type ids + */ +export type FieldTypeId = "~effect/unstable/schema/VariantSchema/Field" + +/** + * @since 4.0.0 + * @category models + */ +export interface Field extends Pipeable { + readonly [FieldTypeId]: FieldTypeId + readonly schemas: A +} + +/** + * @since 4.0.0 + * @category guards + */ +export const isField = (u: unknown): u is Field => Predicate.hasProperty(u, FieldTypeId) + +/** + * @since 4.0.0 + * @category models + */ +export declare namespace Field { + /** + * @since 4.0.0 + * @category models + */ + export type Any = { readonly [FieldTypeId]: FieldTypeId } + + /** + * @since 4.0.0 + * @category models + */ + export type Config = { + readonly [key: string]: Schema.Top | undefined + } + + /** + * @since 4.0.0 + * @category models + */ + export type ConfigWithKeys = { + readonly [P in K]?: Schema.Top + } + + /** + * @since 4.0.0 + * @category models + */ + export type Fields = { + readonly [key: string]: + | Schema.Top + | Field + | Struct + | undefined + } +} + +/** + * @since 4.0.0 + * @category extractors + */ +export type ExtractFields = { + readonly [ + K in keyof Fields as [Fields[K]] extends [Field] ? V extends keyof Config ? K + : never + : K + ]: [Fields[K]] extends [Struct] ? Extract + : [Fields[K]] extends [Field] ? [Config[V]] extends [Schema.Top] ? Config[V] + : never + : [Fields[K]] extends [Schema.Top] ? Fields[K] + : never +} + +/** + * @since 4.0.0 + * @category extractors + */ +export type Extract, IsDefault = false> = [A] extends [ + Struct +] ? IsDefault extends true ? [A] extends [Schema.Top] ? A : Schema.Struct>> + : Schema.Struct>> + : never + +const extract: { + ( + variant: V, + options?: { + readonly isDefault?: IsDefault | undefined + } + ): >(self: A) => Extract + , const IsDefault extends boolean = false>(self: A, variant: V, options?: { + readonly isDefault?: IsDefault | undefined + }): Extract +} = dual( + (args) => isStruct(args[0]), + >( + self: A, + variant: V, + options?: { + readonly isDefault?: boolean | undefined + } + ): Extract => { + const cache = self[cacheSymbol] ?? (self[cacheSymbol] = {}) + const cacheKey = options?.isDefault === true ? "__default" : variant + if (cache[cacheKey] !== undefined) { + return cache[cacheKey] as any + } + const fields: Record = {} + for (const key of Object.keys(self[TypeId])) { + const value = self[TypeId][key] + if (TypeId in value) { + if (options?.isDefault === true && Schema.isSchema(value)) { + fields[key] = value + } else { + fields[key] = extract(value, variant) + } + } else if (FieldTypeId in value) { + if (variant in value.schemas) { + fields[key] = value.schemas[variant] + } + } else { + fields[key] = value + } + } + return cache[cacheKey] = Schema.Struct(fields) as any + } +) + +/** + * @category accessors + * @since 4.0.0 + */ +export const fields = >(self: A): A[TypeId] => self[TypeId] + +/** + * @since 4.0.0 + * @category models + */ +export interface Class< + Self, + Fields extends Struct.Fields, + S extends Schema.Top & { + readonly fields: Schema.Struct.Fields + } +> extends + Schema.Bottom< + Self, + S["Encoded"], + S["DecodingServices"], + S["EncodingServices"], + AST.Declaration, + Class, + Annotations.Declaration, + S["~type.make.in"], + Self, + S["~type.mutability"], + S["~type.optionality"], + S["~type.constructor.default"], + S["~encoded.mutability"], + S["~encoded.optionality"] + >, + Struct> +{ + new( + props: S["~type.make.in"], + options?: { + readonly disableValidation?: boolean + } | undefined + ): S["Type"] + + make, X>( + this: { new(...args: Args): X }, + ...args: Args + ): X + + readonly fields: S["fields"] +} + +type MissingSelfGeneric = + `Missing \`Self\` generic - use \`class Self extends Class()(${Params}{ ... })\`` + +/** + * @since 4.0.0 + * @category models + */ +export interface Union>> extends + Schema.Union< + { + readonly [K in keyof Members]: [Members[K]] extends [Schema.Top] ? Members[K] : never + } + > +{} + +/** + * @since 4.0.0 + * @category models + */ +export declare namespace Union { + /** + * @since 4.0.0 + * @category models + */ + export type Variants>, Variants extends string> = { + readonly [Variant in Variants]: Schema.Union< + { + [K in keyof Members]: Extract + } + > + } +} + +/** + * @since 4.0.0 + * @category constructors + */ +export const make = < + const Variants extends ReadonlyArray, + const Default extends Variants[number] +>(options: { + readonly variants: Variants + readonly defaultVariant: Default +}): { + readonly Struct: ( + fields: A & Struct.Validate + ) => Struct + readonly Field: >( + config: A & { readonly [K in Exclude]: never } + ) => Field + readonly FieldOnly: >( + ...keys: Keys + ) => ( + schema: S + ) => Field<{ readonly [K in Keys[number]]: S }> + readonly FieldExcept: >( + ...keys: Keys + ) => ( + schema: S + ) => Field<{ readonly [K in Exclude]: S }> + readonly fieldEvolve: { + < + Self extends Field | Schema.Top, + const Mapping extends (Self extends Field ? { readonly [K in keyof S]?: (variant: S[K]) => Schema.Top } + : { readonly [K in Variants[number]]?: (variant: Self) => Schema.Top }) + >(f: Mapping): (self: Self) => Field< + Self extends Field ? { + readonly [K in keyof S]: K extends keyof Mapping + ? Mapping[K] extends (arg: any) => any ? ReturnType : S[K] + : S[K] + } : + { + readonly [K in Variants[number]]: K extends keyof Mapping + ? Mapping[K] extends (arg: any) => any ? ReturnType : Self + : Self + } + > + < + Self extends Field | Schema.Top, + const Mapping extends (Self extends Field ? { + readonly [K in keyof S]?: (variant: S[K]) => Schema.Top + } + : { readonly [K in Variants[number]]?: (variant: Self) => Schema.Top }) + >(self: Self, f: Mapping): Field< + Self extends Field ? { + readonly [K in keyof S]: K extends keyof Mapping + ? Mapping[K] extends (arg: any) => any ? ReturnType : S[K] + : S[K] + } : + { + readonly [K in Variants[number]]: K extends keyof Mapping + ? Mapping[K] extends (arg: any) => any ? ReturnType : Self + : Self + } + > + } + readonly Class: ( + identifier: string + ) => ( + fields: Fields & Struct.Validate, + annotations?: + | Annotations.Declaration>]> + | undefined + ) => [Self] extends [never] ? MissingSelfGeneric + : + & Class< + Self, + Fields, + Schema.Struct> + > + & { + readonly [V in Variants[number]]: Extract> + } + readonly Union: >>( + ...members: Members + ) => Union & Union.Variants + readonly extract: { + ( + variant: V + ): >(self: A) => Extract + >( + self: A, + variant: V + ): Extract + } +} => { + function Class(identifier: string) { + return function( + fields: Struct.Fields, + annotations?: Annotations.Declaration>]> + ) { + const variantStruct = Struct(fields) + const schema = extract(variantStruct, options.defaultVariant, { + isDefault: true + }) + const SClass = Schema.Class as any + class Base extends SClass(identifier)(schema.fields, annotations) { + static [TypeId] = fields + } + for (const variant of options.variants) { + Object.defineProperty(Base, variant, { + value: extract(variantStruct, variant).annotate({ + id: `${identifier}.${variant}`, + title: `${identifier}.${variant}` + }) + }) + } + return Base + } + } + function FieldOnly(...keys: Keys) { + return function(schema: S) { + const obj: Record = {} + for (const key of keys) { + obj[key] = schema + } + return Field(obj) + } + } + function FieldExcept(...keys: Keys) { + return function(schema: S) { + const obj: Record = {} + for (const variant of options.variants) { + if (!keys.includes(variant)) { + obj[variant] = schema + } + } + return Field(obj) + } + } + function UnionVariants(...members: ReadonlyArray>) { + return Union(members, options.variants) + } + const fieldEvolve = dual( + 2, + ( + self: Field | Schema.Top, + f: Record Schema.Top> + ): Field => { + const field = isField(self) ? self : Field(Object.fromEntries( + options.variants.map((variant) => [variant, self]) + )) + return Field(Struct_.evolve(field.schemas, f)) + } + ) + const extractVariants = dual( + 2, + (self: Struct, variant: string): any => + extract(self, variant, { + isDefault: variant === options.defaultVariant + }) + ) + return { + Struct, + Field, + FieldOnly, + FieldExcept, + Class, + Union: UnionVariants, + fieldEvolve, + // fieldFromKey, + extract: extractVariants + } as any +} + +/** + * @since 4.0.0 + * @category overrideable + */ +export const Override = (value: A): A & Brand<"Override"> => value as any + +/** + * @since 4.0.0 + * @category overrideable + */ +export interface Overrideable extends + Schema.Bottom< + S["Type"] & Brand<"Override">, + S["Encoded"], + S["DecodingServices"], + S["EncodingServices"], + S["ast"], + Overrideable, + Annotations.Bottom>, + S["~type.make.in"] & Brand<"Override"> | undefined, + S["Type"] & Brand<"Override"> | undefined, + S["~type.mutability"], + S["~type.optionality"], + "with-default", + S["~encoded.mutability"], + S["~encoded.optionality"] + > +{} + +/** + * @since 4.0.0 + * @category overrideable + */ +export const Overrideable = (schema: S, options: { + readonly defaultValue: Effect.Effect +}): Overrideable => + (schema as any).pipe( + Schema.withConstructorDefault(() => Effect.asSome(options.defaultValue)) + ) + +const StructProto = { + pipe() { + return pipeArguments(this, arguments) + } +} + +const Struct = (fields: A): Struct => { + const self = Object.create(StructProto) + self[TypeId] = fields + return self +} + +const FieldProto = { + [FieldTypeId]: FieldTypeId, + pipe() { + return pipeArguments(this, arguments) + } +} + +const Field = (schemas: A): Field => { + const self = Object.create(FieldProto) + self.schemas = schemas + return self +} + +const Union = >, Variants extends ReadonlyArray>( + members: Members, + variants: Variants +) => { + class VariantUnion extends (Schema.Union(members.filter((member) => Schema.isSchema(member))) as any) {} + for (const variant of variants) { + Object.defineProperty(VariantUnion, variant, { + value: Schema.Union(members.map((member) => extract(member, variant))) + }) + } + return VariantUnion +} diff --git a/packages/effect/src/unstable/schema/index.ts b/packages/effect/src/unstable/schema/index.ts new file mode 100644 index 0000000000..33da1dc3ea --- /dev/null +++ b/packages/effect/src/unstable/schema/index.ts @@ -0,0 +1,13 @@ +/** + * @since 4.0.0 + */ + +/** + * @since 4.0.0 + */ +export * as Model from "./Model.ts" + +/** + * @since 4.0.0 + */ +export * as VariantSchema from "./VariantSchema.ts" diff --git a/packages/effect/src/unstable/schema/index.ts.tpl b/packages/effect/src/unstable/schema/index.ts.tpl new file mode 100644 index 0000000000..c2aac82f76 --- /dev/null +++ b/packages/effect/src/unstable/schema/index.ts.tpl @@ -0,0 +1,3 @@ +/** + * @since 4.0.0 + */ diff --git a/packages/effect/src/unstable/sql/Migrator.ts b/packages/effect/src/unstable/sql/Migrator.ts new file mode 100644 index 0000000000..894708a5a3 --- /dev/null +++ b/packages/effect/src/unstable/sql/Migrator.ts @@ -0,0 +1,396 @@ +/** + * @since 4.0.0 + */ +import * as Arr from "../../collections/Array.ts" +import * as Data from "../../data/Data.ts" +import * as Filter from "../../data/Filter.ts" +import * as Option from "../../data/Option.ts" +import * as Order from "../../data/Order.ts" +import * as Effect from "../../Effect.ts" +import { pipe } from "../../Function.ts" +import { FileSystem } from "../../platform/FileSystem.ts" +import * as Client from "./SqlClient.ts" +import type { SqlError } from "./SqlError.ts" + +/** + * @category model + * @since 4.0.0 + */ +export interface MigratorOptions { + readonly loader: Loader + readonly schemaDirectory?: string + readonly table?: string +} + +/** + * @category model + * @since 4.0.0 + */ +export type Loader = Effect.Effect< + ReadonlyArray, + MigrationError, + R +> + +/** + * @category model + * @since 4.0.0 + */ +export type ResolvedMigration = readonly [ + id: number, + name: string, + load: Effect.Effect +] + +/** + * @category model + * @since 4.0.0 + */ +export interface Migration { + readonly id: number + readonly name: string + readonly createdAt: Date +} + +/** + * @category errors + * @since 4.0.0 + */ +export class MigrationError extends Data.TaggedError("MigrationError")<{ + readonly _tag: "MigrationError" + readonly cause?: unknown + readonly reason: + | "bad-state" + | "import-error" + | "failed" + | "duplicates" + | "locked" + readonly message: string +}> {} + +/** + * @category constructor + * @since 4.0.0 + */ +export const make = ({ + dumpSchema = () => Effect.void +}: { + dumpSchema?: ( + path: string, + migrationsTable: string + ) => Effect.Effect +}) => +({ + loader, + schemaDirectory, + table = "effect_sql_migrations" +}: MigratorOptions): Effect.Effect< + ReadonlyArray, + MigrationError | SqlError, + Client.SqlClient | RD | R2 +> => + Effect.gen(function*() { + const sql = yield* Client.SqlClient + + const ensureMigrationsTable = sql.onDialectOrElse({ + mssql: () => + sql`IF OBJECT_ID(N'${sql.literal(table)}', N'U') IS NULL + CREATE TABLE ${sql(table)} ( + migration_id INT NOT NULL PRIMARY KEY, + name VARCHAR(255) NOT NULL, + created_at DATETIME NOT NULL DEFAULT GETDATE() + )`, + mysql: () => + sql`CREATE TABLE IF NOT EXISTS ${sql(table)} ( + migration_id INTEGER UNSIGNED NOT NULL, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + name VARCHAR(255) NOT NULL, + PRIMARY KEY (migration_id) +)`, + pg: () => + Effect.catch( + sql`select ${table}::regclass`, + () => + sql`CREATE TABLE ${sql(table)} ( + migration_id integer primary key, + created_at timestamp with time zone not null default now(), + name text not null +)`.asEffect() + ), + orElse: () => + sql`CREATE TABLE IF NOT EXISTS ${sql(table)} ( + migration_id integer PRIMARY KEY NOT NULL, + created_at datetime NOT NULL DEFAULT current_timestamp, + name VARCHAR(255) NOT NULL +)` + }) + + const insertMigrations = ( + rows: ReadonlyArray<[id: number, name: string]> + ) => + sql`INSERT INTO ${sql(table)} ${ + sql.insert( + rows.map(([migration_id, name]) => ({ migration_id, name })) + ) + }`.withoutTransform + + const latestMigration = Effect.map( + sql<{ migration_id: number; name: string; created_at: Date }>`SELECT migration_id, name, created_at FROM ${ + sql(table) + } ORDER BY migration_id DESC`.withoutTransform, + (_) => + Option.map( + Option.fromNullishOr(_[0] as any), + ({ created_at, migration_id, name }): Migration => ({ + id: migration_id, + name, + createdAt: created_at + }) + ) + ) + + const loadMigration = ([id, name, load]: ResolvedMigration) => + Effect.catchDefect(load, (_) => + Effect.fail( + new MigrationError({ + reason: "import-error", + message: `Could not import migration "${id}_${name}"\n\n${_}` + }) + )).pipe( + Effect.flatMap((_) => + Effect.isEffect(_) + ? Effect.succeed(_) + : _.default + ? Effect.succeed(_.default?.default ?? _.default) + : Effect.fail( + new MigrationError({ + reason: "import-error", + message: `Default export not found for migration "${id}_${name}"` + }) + ) + ), + Effect.filterOrFail( + (_) => Effect.isEffect(_) ? _ as Effect.Effect : Filter.failVoid, + () => + new MigrationError({ + reason: "import-error", + message: `Default export was not an Effect for migration "${id}_${name}"` + }) + ) + ) + + const runMigration = ( + id: number, + name: string, + effect: Effect.Effect + ) => + Effect.catch(effect, (error: unknown) => + Effect.die( + new MigrationError({ + cause: error, + reason: "failed", + message: `Migration "${id}_${name}" failed` + }) + )) + + // === run + + const run = Effect.gen(function*() { + yield* sql.onDialectOrElse({ + pg: () => sql`LOCK TABLE ${sql(table)} IN ACCESS EXCLUSIVE MODE`, + orElse: () => Effect.void + }) + + const [latestMigrationId, current] = yield* Effect.all([ + Effect.map( + latestMigration, + Option.match({ + onNone: () => 0, + onSome: (_) => _.id + }) + ), + loader + ]) + + if (new Set(current.map(([id]) => id)).size !== current.length) { + return yield* new MigrationError({ + reason: "duplicates", + message: "Found duplicate migration id's" + }) + } + + const required: Array = [] + + for (const resolved of current) { + const [currentId, currentName] = resolved + if (currentId <= latestMigrationId) { + continue + } + + required.push([ + currentId, + currentName, + yield* loadMigration(resolved) + ]) + } + + if (required.length > 0) { + yield* pipe( + insertMigrations(required.map(([id, name]) => [id, name])), + Effect.mapError((_) => + new MigrationError({ + reason: "locked", + message: "Migrations already running" + }) + ) + ) + } + + yield* Effect.forEach( + required, + ([id, name, effect]) => + Effect.logDebug(`Running migration`).pipe( + Effect.flatMap(() => runMigration(id, name, effect)), + Effect.annotateLogs("migration_id", String(id)), + Effect.annotateLogs("migration_name", name), + Effect.withSpan(`Migrator ${id}_${name}`) + ), + { discard: true } + ) + + yield* pipe( + latestMigration, + Effect.flatMap( + Option.match({ + onNone: () => Effect.logDebug(`Migrations complete`), + onSome: (_) => + Effect.logDebug(`Migrations complete`).pipe( + Effect.annotateLogs("latest_migration_id", _.id.toString()), + Effect.annotateLogs("latest_migration_name", _.name) + ) + }) + ) + ) + + return required.map(([id, name]) => [id, name] as const) + }) + + yield* ensureMigrationsTable + + const completed = yield* pipe( + sql.withTransaction(run), + Effect.catchTag("MigrationError", (_) => + _.reason === "locked" + ? Effect.as(Effect.logDebug(_.message), []) + : Effect.fail(_)) + ) + + if (schemaDirectory && completed.length > 0) { + yield* dumpSchema(`${schemaDirectory}/_schema.sql`, table).pipe( + Effect.catchCause((cause) => Effect.logInfo("Could not dump schema", cause)) + ) + } + + return completed + }) + +const migrationOrder = Order.make(([a], [b]) => Order.number(a, b)) + +/** + * @since 4.0.0 + * @category loaders + */ +export const fromGlob = ( + migrations: Record Promise> +): Loader => + pipe( + Object.keys(migrations), + Arr.filterMap((_) => Option.fromNullishOr(_.match(/^(?:.*\/)?(\d+)_([^.]+)\.(js|ts)$/))), + Arr.map( + ([key, id, name]): ResolvedMigration => [ + Number(id), + name, + Effect.promise(() => migrations[key]()) + ] + ), + Arr.sort(migrationOrder), + Effect.succeed + ) + +/** + * @since 4.0.0 + * @category loaders + */ +export const fromBabelGlob = (migrations: Record): Loader => + pipe( + Object.keys(migrations), + Arr.filterMap((_) => Option.fromNullishOr(_.match(/^_(\d+)_([^.]+?)(Js|Ts)?$/))), + Arr.map( + ([key, id, name]): ResolvedMigration => [ + Number(id), + name, + Effect.succeed(migrations[key]) + ] + ), + Arr.sort(migrationOrder), + Effect.succeed + ) + +/** + * @since 4.0.0 + * @category loaders + */ +export const fromRecord = (migrations: Record>): Loader => + pipe( + Object.keys(migrations), + Arr.filterMap((_) => Option.fromNullishOr(_.match(/^(\d+)_(.+)$/))), + Arr.map( + ([key, id, name]): ResolvedMigration => [ + Number(id), + name, + Effect.succeed(migrations[key]) + ] + ), + Arr.sort(migrationOrder), + Effect.succeed + ) + +/** + * @since 4.0.0 + * @category loaders + */ +export const fromFileSystem: (directory: string) => Loader = Effect.fnUntraced(function*(directory) { + const Fs = yield* FileSystem + const files = yield* Effect.mapError( + Fs.readDirectory(directory), + (cause) => + new MigrationError({ + reason: "failed", + cause, + message: "Failed to read migrations directory" + }) + ) + return files + .map((file) => Option.fromNullishOr(file.match(/^(?:.*\/)?(\d+)_([^.]+)\.(js|ts)$/))) + .flatMap( + Option.match({ + onNone: () => [], + onSome: ([basename, id, name]): ReadonlyArray => + [ + [ + Number(id), + name, + Effect.promise( + () => + import( + /* @vite-ignore */ + /* webpackIgnore: true */ + `${directory}/${basename}` + ) + ) + ] + ] as const + }) + ) + .sort(([a], [b]) => a - b) +}) diff --git a/packages/effect/src/unstable/sql/SqlClient.ts b/packages/effect/src/unstable/sql/SqlClient.ts new file mode 100644 index 0000000000..0225665bf3 --- /dev/null +++ b/packages/effect/src/unstable/sql/SqlClient.ts @@ -0,0 +1,275 @@ +/** + * @since 4.0.0 + */ +import * as Option from "../../data/Option.ts" +import type { ReadonlyRecord } from "../../data/Record.ts" +import * as Effect from "../../Effect.ts" +import * as Exit from "../../Exit.ts" +import * as Tracer from "../../observability/Tracer.ts" +import type * as Queue from "../../Queue.ts" +import * as Scope from "../../Scope.ts" +import * as ServiceMap from "../../ServiceMap.ts" +import * as Stream from "../../stream/Stream.ts" +import { Clock } from "../../time/Clock.ts" +import type { NoInfer } from "../../types/Types.ts" +import { Reactivity } from "../reactivity/Reactivity.ts" +import type * as Connection from "./SqlConnection.ts" +import type { SqlError } from "./SqlError.ts" +import type { Compiler, Constructor } from "./Statement.ts" +import * as Statement from "./Statement.ts" + +/** + * @category type ids + * @since 4.0.0 + */ +export const TypeId: TypeId = "~effect/sql/SqlClient" + +/** + * @category type ids + * @since 4.0.0 + */ +export type TypeId = "~effect/sql/SqlClient" + +/** + * @category models + * @since 4.0.0 + */ +export interface SqlClient extends Constructor { + readonly [TypeId]: TypeId + + /** + * Copy of the client for safeql etc. + */ + readonly safe: this + + /** + * Copy of the client without transformations. + */ + readonly withoutTransforms: () => this + + readonly reserve: Effect.Effect + + /** + * With the given effect, ensure all sql queries are run in a transaction. + */ + readonly withTransaction: ( + self: Effect.Effect + ) => Effect.Effect + + /** + * Use the Reactivity service from @effect/experimental to create a reactive + * query. + */ + readonly reactive: ( + keys: ReadonlyArray | ReadonlyRecord>, + effect: Effect.Effect + ) => Stream.Stream + + /** + * Use the Reactivity service to create a reactive + * query. + */ + readonly reactiveMailbox: ( + keys: ReadonlyArray | ReadonlyRecord>, + effect: Effect.Effect + ) => Effect.Effect, never, R | Scope.Scope> +} + +/** + * @category models + * @since 4.0.0 + */ +export const SqlClient = ServiceMap.Key("effect/sql/SqlClient") + +/** + * @category models + * @since 4.0.0 + */ +export namespace SqlClient { + /** + * @category models + * @since 4.0.0 + */ + export interface MakeOptions { + readonly acquirer: Connection.Acquirer + readonly compiler: Compiler + readonly transactionAcquirer?: Connection.Acquirer + readonly spanAttributes: ReadonlyArray + readonly beginTransaction?: string | undefined + readonly rollback?: string | undefined + readonly commit?: string | undefined + readonly savepoint?: ((name: string) => string) | undefined + readonly rollbackSavepoint?: ((name: string) => string) | undefined + readonly transformRows?: ((row: ReadonlyArray) => ReadonlyArray) | undefined + readonly reactiveQueue?: ( + keys: ReadonlyArray | ReadonlyRecord>, + effect: Effect.Effect + ) => Effect.Effect, never, R | Scope.Scope> + } +} + +/** + * @category constructors + * @since 4.0.0 + */ +export const make = Effect.fnUntraced(function*(options: SqlClient.MakeOptions) { + const getConnection = Effect.flatMap( + Effect.serviceOption(TransactionConnection), + Option.match({ + onNone: () => options.acquirer, + onSome: ([conn]) => Effect.succeed(conn) + }) + ) + + const beginTransaction = options.beginTransaction ?? "BEGIN" + const commit = options.commit ?? "COMMIT" + const savepoint = options.savepoint ?? ((name: string) => `SAVEPOINT ${name}`) + const rollback = options.rollback ?? "ROLLBACK" + const rollbackSavepoint = options.rollbackSavepoint ?? ((name: string) => `ROLLBACK TO SAVEPOINT ${name}`) + const transactionAcquirer = options.transactionAcquirer ?? options.acquirer + const withTransaction = makeWithTransaction({ + transactionTag: TransactionConnection, + spanAttributes: options.spanAttributes, + acquireConnection: Effect.flatMap( + Scope.make(), + (scope) => Effect.map(Scope.provide(transactionAcquirer!, scope), (conn) => [scope, conn] as const) + ), + begin: (conn) => conn.executeUnprepared(beginTransaction, [], undefined), + savepoint: (conn, id) => conn.executeUnprepared(savepoint(`effect_sql_${id}`), [], undefined), + commit: (conn) => conn.executeUnprepared(commit, [], undefined), + rollback: (conn) => conn.executeUnprepared(rollback, [], undefined), + rollbackSavepoint: (conn, id) => conn.executeUnprepared(rollbackSavepoint(`effect_sql_${id}`), [], undefined) + }) + + const reactivity = yield* Reactivity + const client: SqlClient = Object.assign( + Statement.make(getConnection, options.compiler, options.spanAttributes, options.transformRows), + { + [TypeId]: TypeId, + safe: undefined as any, + withTransaction, + reserve: transactionAcquirer, + withoutTransforms(): any { + if (options.transformRows === undefined) { + return this + } + const statement = Statement.make( + getConnection, + options.compiler.withoutTransform, + options.spanAttributes, + undefined + ) + const client = Object.assign(statement, { + ...this, + ...statement + }) + ;(client as any).safe = client + ;(client as any).withoutTransforms = () => client + return client + }, + reactive: options.reactiveQueue ? + ( + keys: ReadonlyArray | ReadonlyRecord>, + effect: Effect.Effect + ) => + options.reactiveQueue!(keys, effect).pipe( + Effect.map(Stream.fromQueue), + Stream.unwrap + ) : + reactivity.stream, + reactiveMailbox: options.reactiveQueue ?? reactivity.query + } + ) + ;(client as any).safe = client + + return client +}) + +/** + * @since 4.0.0 + * @category transactions + */ +export const makeWithTransaction = (options: { + readonly transactionTag: ServiceMap.Key + readonly spanAttributes: ReadonlyArray + readonly acquireConnection: Effect.Effect + readonly begin: (conn: NoInfer) => Effect.Effect + readonly savepoint: (conn: NoInfer, id: number) => Effect.Effect + readonly commit: (conn: NoInfer) => Effect.Effect + readonly rollback: (conn: NoInfer) => Effect.Effect + readonly rollbackSavepoint: (conn: NoInfer, id: number) => Effect.Effect +}) => +(effect: Effect.Effect): Effect.Effect => + Effect.uninterruptibleMask((restore) => + Effect.useSpan( + "sql.transaction", + { kind: "client", captureStackTrace: false }, + (span) => + Effect.withFiber((fiber) => { + for (const [key, value] of options.spanAttributes) { + span.attribute(key, value) + } + const services = fiber.services + const clock = fiber.getRef(Clock) + const connOption = ServiceMap.getOption(services, options.transactionTag) + const conn = connOption._tag === "Some" + ? Effect.succeed([undefined, connOption.value[0]] as const) + : options.acquireConnection + const id = connOption._tag === "Some" ? connOption.value[1] + 1 : 0 + return Effect.flatMap( + conn, + ( + [scope, conn] + ) => + (id === 0 ? options.begin(conn) : options.savepoint(conn, id)).pipe( + Effect.flatMap(() => + Effect.provideServices( + restore(effect), + ServiceMap.add(services, options.transactionTag, [conn, id]).pipe( + ServiceMap.add(Tracer.ParentSpan, span) + ) + ) + ), + Effect.exit, + Effect.flatMap((exit) => { + let effect: Effect.Effect + if (Exit.isSuccess(exit)) { + if (id === 0) { + span.event("db.transaction.commit", clock.unsafeCurrentTimeNanos()) + effect = Effect.orDie(options.commit(conn)) + } else { + span.event("db.transaction.savepoint", clock.unsafeCurrentTimeNanos()) + effect = Effect.void + } + } else { + span.event("db.transaction.rollback", clock.unsafeCurrentTimeNanos()) + effect = Effect.orDie( + id > 0 + ? options.rollbackSavepoint(conn, id) + : options.rollback(conn) + ) + } + const withScope = scope !== undefined ? Effect.ensuring(effect, Scope.close(scope, exit)) : effect + return Effect.flatMap(withScope, () => exit) + }) + ) + ) + }) + ) + ) + +/** + * @since 4.0.0 + */ +export class TransactionConnection + extends ServiceMap.Key()( + "effect/sql/SqlClient/TransactionConnection" + ) +{} + +/** + * @since 4.0.0 + */ +export const SafeIntegers = ServiceMap.Reference("effect/sql/SqlClient/SafeIntegers", { + defaultValue: () => false +}) diff --git a/packages/effect/src/unstable/sql/SqlConnection.ts b/packages/effect/src/unstable/sql/SqlConnection.ts new file mode 100644 index 0000000000..9fbaf02646 --- /dev/null +++ b/packages/effect/src/unstable/sql/SqlConnection.ts @@ -0,0 +1,65 @@ +/** + * @since 4.0.0 + */ +import type { Effect } from "../../Effect.ts" +import type { Scope } from "../../Scope.ts" +import * as ServiceMap from "../../ServiceMap.ts" +import type { Stream } from "../../stream/Stream.ts" +import type { SqlError } from "./SqlError.ts" +import type { Primitive } from "./Statement.ts" + +/** + * @category model + * @since 4.0.0 + */ +export interface Connection { + readonly execute: ( + sql: string, + params: ReadonlyArray, + transformRows: ((row: ReadonlyArray) => ReadonlyArray) | undefined + ) => Effect, SqlError> + + /** + * Execute the specified SQL query and return the raw results directly from + * underlying SQL client. + */ + readonly executeRaw: ( + sql: string, + params: ReadonlyArray + ) => Effect + + readonly executeStream: ( + sql: string, + params: ReadonlyArray, + transformRows: ((row: ReadonlyArray) => ReadonlyArray) | undefined + ) => Stream + + readonly executeValues: ( + sql: string, + params: ReadonlyArray + ) => Effect>, SqlError> + + readonly executeUnprepared: ( + sql: string, + params: ReadonlyArray, + transformRows: ((row: ReadonlyArray) => ReadonlyArray) | undefined + ) => Effect, SqlError> +} + +/** + * @category model + * @since 4.0.0 + */ +export type Acquirer = Effect + +/** + * @category tag + * @since 4.0.0 + */ +export const Connection = ServiceMap.Key("effect/sql/SqlConnection") + +/** + * @category model + * @since 4.0.0 + */ +export type Row = { readonly [column: string]: Primitive } diff --git a/packages/effect/src/unstable/sql/SqlError.ts b/packages/effect/src/unstable/sql/SqlError.ts new file mode 100644 index 0000000000..1eea111158 --- /dev/null +++ b/packages/effect/src/unstable/sql/SqlError.ts @@ -0,0 +1,47 @@ +/** + * @since 4.0.0 + */ +import * as Data from "../../data/Data.ts" + +/** + * @since 4.0.0 + */ +export const TypeId: TypeId = "~effect/sql/SqlError" + +/** + * @since 4.0.0 + */ +export type TypeId = "~effect/sql/SqlError" + +/** + * @since 4.0.0 + */ +export class SqlError extends Data.TaggedError("SqlError")<{ + cause: unknown + message?: string +}> { + /** + * @since 4.0.0 + */ + readonly [TypeId]: TypeId = TypeId +} + +/** + * @since 4.0.0 + */ +export class ResultLengthMismatch extends Data.TaggedError("ResultLengthMismatch")<{ + readonly expected: number + readonly actual: number +}> { + /** + * @since 4.0.0 + */ + readonly [TypeId]: TypeId = TypeId + + /** + * @since 4.0.0 + */ + override get message() { + return `Expected ${this.expected} results but got ${this.actual}` + } +} diff --git a/packages/effect/src/unstable/sql/SqlModel.ts b/packages/effect/src/unstable/sql/SqlModel.ts new file mode 100644 index 0000000000..0fc238034a --- /dev/null +++ b/packages/effect/src/unstable/sql/SqlModel.ts @@ -0,0 +1,344 @@ +/** + * @since 4.0.0 + * @category models + */ +import * as RequestResolver from "../../batching/RequestResolver.ts" +import type * as Cause from "../../Cause.ts" +import * as Effect from "../../Effect.ts" +import { identity } from "../../Function.ts" +import type * as Schema from "../../schema/Schema.ts" +import type { Scope } from "../../Scope.ts" +import type { DurationInput } from "../../time/Duration.ts" +import type * as Model from "../schema/Model.ts" +import { SqlClient } from "./SqlClient.ts" +import type { SqlError } from "./SqlError.ts" +import * as SqlResolver from "./SqlResolver.ts" +import * as SqlSchema from "./SqlSchema.ts" + +/** + * Create a simple CRUD repository from a model. + * + * @since 4.0.0 + * @category repository + */ +export const makeRepository = < + S extends Model.Any, + Id extends (keyof S["Type"]) & (keyof S["update"]["Type"]) & (keyof S["fields"]) +>(Model: S, options: { + readonly tableName: string + readonly spanPrefix: string + readonly idColumn: Id +}): Effect.Effect< + { + readonly insert: ( + insert: S["insert"]["Type"] + ) => Effect.Effect< + S["Type"], + Schema.SchemaError | SqlError, + S["DecodingServices"] | S["insert"]["EncodingServices"] + > + readonly insertVoid: ( + insert: S["insert"]["Type"] + ) => Effect.Effect + readonly update: ( + update: S["update"]["Type"] + ) => Effect.Effect< + S["Type"], + Schema.SchemaError | SqlError, + S["DecodingServices"] | S["update"]["EncodingServices"] + > + readonly updateVoid: ( + update: S["update"]["Type"] + ) => Effect.Effect + readonly findById: ( + id: S["fields"][Id]["Type"] + ) => Effect.Effect< + S["Type"], + Cause.NoSuchElementError | Schema.SchemaError | SqlError, + S["DecodingServices"] | S["fields"][Id]["EncodingServices"] + > + readonly delete: ( + id: S["fields"][Id]["Type"] + ) => Effect.Effect + }, + never, + SqlClient +> => + Effect.gen(function*() { + const sql = yield* SqlClient + const idSchema = Model.fields[options.idColumn] as Schema.Top + const idColumn = options.idColumn as string + + const insertSchema = SqlSchema.findOne({ + Request: Model.insert, + Result: Model, + execute: (request) => + sql.onDialectOrElse({ + mysql: () => + sql`insert into ${sql(options.tableName)} ${sql.insert(request as any)}; +select * from ${sql(options.tableName)} where ${sql(idColumn)} = LAST_INSERT_ID();`.unprepared.pipe( + Effect.map(([, results]) => results as any) + ), + orElse: () => sql`insert into ${sql(options.tableName)} ${sql.insert(request as any).returning("*")}` + }) + }) + const insert = ( + insert: S["insert"]["Type"] + ): Effect.Effect< + S["Type"], + Schema.SchemaError | SqlError, + S["DecodingServices"] | S["insert"]["EncodingServices"] + > => + insertSchema(insert).pipe( + Effect.catchTag("NoSuchElementError", Effect.die), + Effect.withSpan(`${options.spanPrefix}.insert`, {}, { captureStackTrace: false }) + ) as any + + const insertVoidSchema = SqlSchema.void({ + Request: Model.insert, + execute: (request) => sql`insert into ${sql(options.tableName)} ${sql.insert(request as any)}` + }) + const insertVoid = ( + insert: S["insert"]["Type"] + ): Effect.Effect => + insertVoidSchema(insert).pipe( + Effect.withSpan(`${options.spanPrefix}.insertVoid`, {}, { + captureStackTrace: false + }) + ) as any + + const updateSchema = SqlSchema.findOne({ + Request: Model.update, + Result: Model, + execute: (request: any) => + sql.onDialectOrElse({ + mysql: () => + sql`update ${sql(options.tableName)} set ${sql.update(request, [idColumn])} where ${sql(idColumn)} = ${ + request[idColumn] + }; +select * from ${sql(options.tableName)} where ${sql(idColumn)} = ${request[idColumn]};`.unprepared.pipe( + Effect.map(([, results]) => results as any) + ), + orElse: () => + sql`update ${sql(options.tableName)} set ${sql.update(request, [idColumn])} where ${sql(idColumn)} = ${ + request[idColumn] + } returning *` + }) + }) + const update = ( + update: S["update"]["Type"] + ): Effect.Effect< + S["Type"], + Schema.SchemaError | SqlError, + S["DecodingServices"] | S["update"]["EncodingServices"] + > => + updateSchema(update).pipe( + Effect.catchTag("NoSuchElementError", Effect.die), + Effect.withSpan(`${options.spanPrefix}.update`, { + attributes: { id: (update as any)[idColumn] } + }, { + captureStackTrace: false + }) + ) as any + + const updateVoidSchema = SqlSchema.void({ + Request: Model.update, + execute: (request: any) => + sql`update ${sql(options.tableName)} set ${sql.update(request, [idColumn])} where ${sql(idColumn)} = ${ + request[idColumn] + }` + }) + const updateVoid = ( + update: S["update"]["Type"] + ): Effect.Effect => + updateVoidSchema(update).pipe( + Effect.withSpan(`${options.spanPrefix}.updateVoid`, { + attributes: { id: (update as any)[idColumn] } + }, { + captureStackTrace: false + }) + ) as any + + const findByIdSchema = SqlSchema.findOne({ + Request: idSchema, + Result: Model, + execute: (id: any) => sql`select * from ${sql(options.tableName)} where ${sql(idColumn)} = ${id}` + }) + const findById = ( + id: S["fields"][Id]["Type"] + ): Effect.Effect< + S["Type"], + Cause.NoSuchElementError | Schema.SchemaError | SqlError, + S["DecodingServices"] | S["fields"][Id]["EncodingServices"] + > => + findByIdSchema(id).pipe( + Effect.withSpan(`${options.spanPrefix}.findById`, { attributes: { id } }, { + captureStackTrace: false + }) + ) as any + + const deleteSchema = SqlSchema.void({ + Request: idSchema, + execute: (id: any) => sql`delete from ${sql(options.tableName)} where ${sql(idColumn)} = ${id}` + }) + const delete_ = ( + id: S["fields"][Id]["Type"] + ): Effect.Effect => + deleteSchema(id).pipe( + Effect.withSpan(`${options.spanPrefix}.delete`, { + attributes: { id } + }, { + captureStackTrace: false + }) + ) as any + + return { insert, insertVoid, update, updateVoid, findById, delete: delete_ } as const + }) + +/** + * Create some simple data loaders from a model. + * + * @since 4.0.0 + * @category repository + */ +export const makeDataLoaders = < + S extends Model.Any, + Id extends (keyof S["Type"]) & (keyof S["update"]["Type"]) & (keyof S["fields"]) +>( + Model: S, + options: { + readonly tableName: string + readonly spanPrefix: string + readonly idColumn: Id + readonly window: DurationInput + readonly maxBatchSize?: number | undefined + } +): Effect.Effect< + { + readonly insert: ( + insert: S["insert"]["Type"] + ) => Effect.Effect< + S["Type"], + SqlError | Schema.SchemaError, + S["DecodingServices"] | S["insert"]["EncodingServices"] + > + readonly insertVoid: ( + insert: S["insert"]["Type"] + ) => Effect.Effect + readonly findById: ( + id: S["fields"][Id]["Type"] + ) => Effect.Effect< + S["Type"], + SqlError | Schema.SchemaError | Cause.NoSuchElementError, + S["DecodingServices"] | S["fields"][Id]["EncodingServices"] + > + readonly delete: ( + id: S["fields"][Id]["Type"] + ) => Effect.Effect + }, + never, + SqlClient | Scope +> => + Effect.gen(function*() { + const sql = yield* SqlClient + const idSchema = Model.fields[options.idColumn] as Schema.Top + const idColumn = options.idColumn as string + const setMaxBatchSize = options.maxBatchSize ? RequestResolver.batchN(options.maxBatchSize) : identity + + const insertResolver = SqlResolver.ordered({ + Request: Model.insert, + Result: Model, + execute: (request: any) => + sql.onDialectOrElse({ + mysql: () => + Effect.forEach(request, (request: any) => + sql`insert into ${sql(options.tableName)} ${sql.insert(request)}; +select * from ${sql(options.tableName)} where ${sql(idColumn)} = LAST_INSERT_ID();`.unprepared.pipe( + Effect.map(([, results]) => results[0] as any) + ), { concurrency: 10 }), + orElse: () => sql`insert into ${sql(options.tableName)} ${sql.insert(request).returning("*")}` + }) + }).pipe( + RequestResolver.setDelay(options.window), + setMaxBatchSize, + RequestResolver.withSpan(`${options.spanPrefix}.insertResolver`) + ) + const insertExecute = SqlResolver.request(insertResolver) + const insert = ( + insert: S["insert"]["Type"] + ): Effect.Effect< + S["Type"], + SqlError | Schema.SchemaError, + S["DecodingServices"] | S["insert"]["EncodingServices"] + > => + insertExecute(insert).pipe( + Effect.catchTag("ResultLengthMismatch", Effect.die), + Effect.withSpan(`${options.spanPrefix}.insert`, {}, { + captureStackTrace: false + }) + ) as any + + const insertVoidResolver = SqlResolver.void({ + Request: Model.insert, + execute: (request: any) => sql`insert into ${sql(options.tableName)} ${sql.insert(request)}` + }).pipe( + RequestResolver.setDelay(options.window), + setMaxBatchSize, + RequestResolver.withSpan(`${options.spanPrefix}.insertVoidResolver`) + ) + const insertVoidExecute = SqlResolver.request(insertVoidResolver) + const insertVoid = ( + insert: S["insert"]["Type"] + ): Effect.Effect => + insertVoidExecute(insert).pipe( + Effect.withSpan(`${options.spanPrefix}.insertVoid`, {}, { + captureStackTrace: false + }) + ) as any + + const findByIdResolver = SqlResolver.findById({ + Id: idSchema, + Result: Model, + ResultId(request: any) { + return request[idColumn] + }, + execute: (ids: any) => sql`select * from ${sql(options.tableName)} where ${sql.in(idColumn, ids)}` + }).pipe( + RequestResolver.setDelay(options.window), + setMaxBatchSize, + RequestResolver.withSpan(`${options.spanPrefix}.findByIdResolver`) + ) + const findByIdExecute = SqlResolver.request(findByIdResolver) + const findById = ( + id: S["fields"][Id]["Type"] + ): Effect.Effect< + S["Type"], + Cause.NoSuchElementError | SqlError | Schema.SchemaError, + S["DecodingServices"] | S["fields"][Id]["EncodingServices"] + > => + findByIdExecute(id).pipe( + Effect.withSpan(`${options.spanPrefix}.findById`, { attributes: { id } }, { + captureStackTrace: false + }) + ) as any + + const deleteResolver = SqlResolver.void({ + Request: idSchema, + execute: (ids: any) => sql`delete from ${sql(options.tableName)} where ${sql.in(idColumn, ids)}` + }).pipe( + RequestResolver.setDelay(options.window), + setMaxBatchSize, + RequestResolver.withSpan(`${options.spanPrefix}.deleteResolver`) + ) + const deleteExecute = SqlResolver.request(deleteResolver) + const delete_ = ( + id: S["fields"][Id]["Type"] + ): Effect.Effect => + deleteExecute(id).pipe( + Effect.withSpan(`${options.spanPrefix}.delete`, { attributes: { id } }, { + captureStackTrace: false + }) + ) as any + + return { insert, insertVoid, findById, delete: delete_ } as const + }) diff --git a/packages/effect/src/unstable/sql/SqlResolver.ts b/packages/effect/src/unstable/sql/SqlResolver.ts new file mode 100644 index 0000000000..86bc367c08 --- /dev/null +++ b/packages/effect/src/unstable/sql/SqlResolver.ts @@ -0,0 +1,350 @@ +/** + * @since 4.0.0 + */ +import * as Request from "../../batching/Request.ts" +import * as RequestResolver from "../../batching/RequestResolver.ts" +import * as Cause from "../../Cause.ts" +import * as Arr from "../../collections/Array.ts" +import * as MutableHashMap from "../../collections/MutableHashMap.ts" +import * as Effect from "../../Effect.ts" +import * as Exit from "../../Exit.ts" +import * as Equal from "../../interfaces/Equal.ts" +import * as Hash from "../../interfaces/Hash.ts" +import * as Schema from "../../schema/Schema.ts" +import type * as Types from "../../types/Types.ts" +import * as SqlClient from "./SqlClient.ts" +import { ResultLengthMismatch } from "./SqlError.ts" + +/** + * @since 4.0.0 + * @category requests + */ +export interface SqlRequest extends Request.Request { + readonly payload: In +} + +const SqlRequestProto = { + ...Request.Class.prototype, + [Equal.symbol]( + this: SqlRequest, + that: SqlRequest + ): boolean { + return Equal.equals(this.payload, that.payload) + }, + [Hash.symbol](this: SqlRequest): number { + return Hash.cached(this, () => Hash.hash(this.payload)) + } +} + +/** + * @since 4.0.0 + * @category requests + */ +export const request: { + ( + resolver: RequestResolver.RequestResolver> + ): (payload: In) => Effect.Effect + ( + payload: In, + resolver: RequestResolver.RequestResolver> + ): Effect.Effect +} = function() { + if (arguments.length === 1) { + const resolver = arguments[0] + return (payload: any) => Effect.request(SqlRequest(payload), resolver) + } + return Effect.request(SqlRequest(arguments[0]), arguments[1]) +} as any + +/** + * @since 4.0.0 + * @category requests + */ +export const SqlRequest = (payload: In): SqlRequest => { + const self = Object.create(SqlRequestProto) + self.payload = payload + return self +} + +/** + * Create a resolver for a sql query with a request schema and a result schema. + * + * The request schema is used to validate the input of the query. + * The result schema is used to validate the output of the query. + * + * Results are mapped to the requests in order, so the length of the results must match the length of the requests. + * + * @since 4.0.0 + * @category resolvers + */ +export const ordered = ( + options: { + readonly Request: Req + readonly Result: Res + readonly execute: ( + requests: Arr.NonEmptyArray + ) => Effect.Effect, E, R> + } +): RequestResolver.RequestResolver< + SqlRequest +> => { + const decodeArray = Schema.decodeUnknownEffect(Schema.Array(options.Result)) + return RequestResolver.makeGrouped< + SqlRequest< + Req["Type"], + Res["Type"], + E | ResultLengthMismatch, + Req["EncodingServices"] | Res["DecodingServices"] | R + >, + SqlClient.TransactionConnection["Service"] | undefined + >({ + key: (entry) => entry.services.unsafeMap.get(SqlClient.TransactionConnection.key), + resolver: Effect.fnUntraced(function*(entries) { + const inputs = yield* partitionRequests(entries, options.Request) + const results = yield* options.execute(inputs as any).pipe( + Effect.provideServices(entries[0].services) + ) + if (results.length !== inputs.length) { + return yield* Effect.fail(new ResultLengthMismatch({ expected: inputs.length, actual: results.length })) + } + const decodedResults = yield* decodeArray(results).pipe( + Effect.provideServices(entries[0].services) + ) + for (let i = 0; i < entries.length; i++) { + entries[i].unsafeComplete(Exit.succeed(decodedResults[i])) + } + }) + }) +} + +/** + * Create a resolver the can return multiple results for a single request. + * + * Results are grouped by a common key extracted from the request and result. + * + * @since 4.0.0 + * @category resolvers + */ +export const grouped = ( + options: { + readonly Request: Req + readonly RequestGroupKey: (request: Req["Type"]) => K + readonly Result: Res + readonly ResultGroupKey: (result: Res["Type"], row: Types.NoInfer) => K + readonly execute: ( + requests: Arr.NonEmptyArray + ) => Effect.Effect, E, R> + } +): RequestResolver.RequestResolver< + SqlRequest< + Req["Type"], + Arr.NonEmptyArray, + E | Schema.SchemaError | Cause.NoSuchElementError, + Req["EncodingServices"] | Res["DecodingServices"] | R + > +> => { + const decodeResults = Schema.decodeUnknownEffect(Schema.Array(options.Result)) + + return RequestResolver.makeGrouped< + SqlRequest< + Req["Type"], + Arr.NonEmptyArray, + E | Schema.SchemaError | Cause.NoSuchElementError, + Req["EncodingServices"] | Res["DecodingServices"] | R + >, + SqlClient.TransactionConnection["Service"] | undefined + >({ + key: (entry) => entry.services.unsafeMap.get(SqlClient.TransactionConnection.key), + resolver: Effect.fnUntraced(function*(entries) { + const inputs = yield* partitionRequests(entries, options.Request) + const resultMap = MutableHashMap.empty>() + const results = yield* options.execute(inputs as any).pipe( + Effect.provideServices(entries[0].services) + ) + const decodedResults = yield* decodeResults(results).pipe( + Effect.provideServices(entries[0].services) + ) + for (let i = 0, len = decodedResults.length; i < len; i++) { + const result = decodedResults[i] + const key = options.ResultGroupKey(result, results[i]) + const group = MutableHashMap.get(resultMap, key) + if (group._tag === "None") { + MutableHashMap.set(resultMap, key, [result]) + } else { + group.value.push(result) + } + } + for (let i = 0, len = entries.length; i < len; i++) { + const entry = entries[i] + const key = options.RequestGroupKey(entry.request.payload) + const result = MutableHashMap.get(resultMap, key) + entry.unsafeComplete( + result._tag === "None" ? constNoSuchElement : Exit.succeed(result.value) + ) + } + }) + }) +} + +/** + * Create a resolver that resolves results by id. + * + * @since 4.0.0 + * @category resolvers + */ +export const findById = ( + options: { + readonly Id: Id + readonly Result: Res + readonly ResultId: (result: Res["Type"], row: Types.NoInfer) => Id["Type"] + readonly execute: ( + requests: Arr.NonEmptyArray + ) => Effect.Effect, E, R> + } +): RequestResolver.RequestResolver< + SqlRequest< + Id["Type"], + Res["Type"], + E | Schema.SchemaError | Cause.NoSuchElementError, + Id["EncodingServices"] | Res["DecodingServices"] | R + > +> => { + const decodeResults = Schema.decodeUnknownEffect(Schema.Array(options.Result)) + + return RequestResolver.makeGrouped< + SqlRequest< + Id["Type"], + Res["Type"], + E | Schema.SchemaError | Cause.NoSuchElementError, + Id["EncodingServices"] | Res["DecodingServices"] | R + >, + SqlClient.TransactionConnection["Service"] | undefined + >({ + key: (entry) => entry.services.unsafeMap.get(SqlClient.TransactionConnection.key), + resolver: Effect.fnUntraced(function*(entries) { + const [inputs, idMap] = yield* partitionRequestsById(entries, options.Id) + const results = yield* options.execute(inputs as any).pipe( + Effect.provideServices(entries[0].services) + ) + const decodedResults = yield* decodeResults(results).pipe( + Effect.provideServices(entries[0].services) + ) + for (let i = 0; i < decodedResults.length; i++) { + const result = decodedResults[i] + const id = options.ResultId(result, results[i]) + const request = MutableHashMap.get(idMap, id) + if (request._tag === "None") { + continue + } + MutableHashMap.remove(idMap, id) + request.value.unsafeComplete(Exit.succeed(result)) + } + if (MutableHashMap.isEmpty(idMap)) { + return + } + MutableHashMap.forEach(idMap, (request) => { + request.unsafeComplete(constNoSuchElement) + }) + }) + }) +} + +const void_ = ( + options: { + readonly Request: Req + readonly execute: ( + requests: Arr.NonEmptyArray + ) => Effect.Effect, E, R> + } +): RequestResolver.RequestResolver< + SqlRequest< + Req["Type"], + void, + E | Schema.SchemaError, + Req["EncodingServices"] | R + > +> => + RequestResolver.makeGrouped< + SqlRequest< + Req["Type"], + void, + E | Schema.SchemaError, + Req["EncodingServices"] | R + >, + SqlClient.TransactionConnection["Service"] | undefined + >({ + key: (entry) => entry.services.unsafeMap.get(SqlClient.TransactionConnection.key), + resolver: Effect.fnUntraced(function*(entries) { + const inputs = yield* partitionRequests(entries, options.Request) + yield* options.execute(inputs as any).pipe( + Effect.provideServices(entries[0].services) + ) + for (let i = 0; i < entries.length; i++) { + entries[i].unsafeComplete(Exit.void) + } + }) + }) + +export { + /** + * Create a resolver that performs side effects. + * + * @since 4.0.0 + * @category resolvers + */ + void_ as void +} + +const constNoSuchElement = Exit.fail(new Cause.NoSuchElementError()) + +const partitionRequests = function*( + requests: Arr.NonEmptyArray>>, + schema: Schema.Codec +) { + const len = requests.length + const inputs = Arr.empty() + let entry!: Request.Entry> + const encode = Schema.encodeEffect(schema) + const handle = Effect.matchCauseEager({ + onFailure(cause: Cause.Cause) { + entry.unsafeComplete(Exit.failCause(cause)) + }, + onSuccess(value: InE) { + inputs.push(value) + } + }) + + for (let i = 0; i < len; i++) { + entry = requests[i] + yield (Effect.provideServices(handle(encode(entry.request.payload)), entry.services) as Effect.Effect) + } + + return inputs +} + +const partitionRequestsById = function*( + requests: ReadonlyArray>>, + schema: Schema.Codec +) { + const len = requests.length + const inputs = Arr.empty() + const byIdMap = MutableHashMap.empty>>() + let entry!: Request.Entry> + const encode = Schema.encodeEffect(schema) + const handle = Effect.matchCauseEager({ + onFailure(cause: Cause.Cause) { + entry.unsafeComplete(Exit.failCause(cause)) + }, + onSuccess(value: InE) { + inputs.push(value) + } + }) + + for (let i = 0; i < len; i++) { + entry = requests[i] + yield (Effect.provideServices(handle(encode(entry.request.payload)), entry.services) as Effect.Effect) + MutableHashMap.set(byIdMap, entry.request.payload, entry) + } + + return [inputs, byIdMap] as const +} diff --git a/packages/effect/src/unstable/sql/SqlSchema.ts b/packages/effect/src/unstable/sql/SqlSchema.ts new file mode 100644 index 0000000000..e9c083aaca --- /dev/null +++ b/packages/effect/src/unstable/sql/SqlSchema.ts @@ -0,0 +1,96 @@ +/** + * @since 4.0.0 + */ +import * as Cause from "../../Cause.ts" +import * as Arr from "../../collections/Array.ts" +import * as Effect from "../../Effect.ts" +import * as Schema from "../../schema/Schema.ts" + +/** + * Run a sql query with a request schema and a result schema. + * + * @since 4.0.0 + * @category constructor + */ +export const findMany = ( + options: { + readonly Request: Req + readonly Result: Res + readonly execute: (request: Req["Encoded"]) => Effect.Effect, E, R> + } +) => { + const encodeRequest = Schema.encodeEffect(options.Request) + const decode = Schema.decodeUnknownEffect(Schema.Array(options.Result)) + return ( + request: Req["Encoded"] + ): Effect.Effect< + Arr.NonEmptyArray, + E | Schema.SchemaError | Cause.NoSuchElementError, + Req["EncodingServices"] | Res["DecodingServices"] | R + > => + Effect.flatMap( + Effect.flatMap(encodeRequest(request), options.execute), + (results): Effect.Effect< + Arr.NonEmptyArray, + Schema.SchemaError | Cause.NoSuchElementError, + Req["EncodingServices"] | Res["DecodingServices"] + > => + Arr.isNonEmptyReadonlyArray(results) + ? decode(results) as Effect.Effect, Schema.SchemaError> + : Effect.fail(new Cause.NoSuchElementError()) + ) +} + +const void_ = ( + options: { + readonly Request: Req + readonly execute: (request: Req["Encoded"]) => Effect.Effect + } +) => { + const encode = Schema.encodeEffect(options.Request) + return (request: Req["Type"]): Effect.Effect => + Effect.asVoid( + Effect.flatMap(encode(request), options.execute) + ) +} +export { + /** + * Run a sql query with a request schema and discard the result. + * + * @since 4.0.0 + * @category constructor + */ + void_ as void +} + +/** + * Run a sql query with a request schema and a result schema and return the first result. + * + * @since 4.0.0 + * @category constructor + */ +export const findOne = ( + options: { + readonly Request: Req + readonly Result: Res + readonly execute: (request: Req["Encoded"]) => Effect.Effect, E, R> + } +) => { + const encodeRequest = Schema.encodeEffect(options.Request) + const decode = Schema.decodeUnknownEffect(options.Result) + return ( + request: Req["Type"] + ): Effect.Effect< + Res["Type"], + E | Schema.SchemaError | Cause.NoSuchElementError, + R | Req["EncodingServices"] | Res["DecodingServices"] + > => + Effect.flatMap( + Effect.flatMap(encodeRequest(request), options.execute), + (arr): Effect.Effect< + Res["Type"], + Schema.SchemaError | Cause.NoSuchElementError, + Req["EncodingServices"] | Res["DecodingServices"] + > => Arr.isNonEmptyReadonlyArray(arr) ? decode(arr[0]) : Effect.fail(new Cause.NoSuchElementError()) + ) +} diff --git a/packages/effect/src/unstable/sql/SqlStream.ts b/packages/effect/src/unstable/sql/SqlStream.ts new file mode 100644 index 0000000000..2ed8f414c2 --- /dev/null +++ b/packages/effect/src/unstable/sql/SqlStream.ts @@ -0,0 +1,65 @@ +/** + * @since 4.0.0 + */ +import * as Effect from "../../Effect.ts" +import * as Exit from "../../Exit.ts" +import * as Queue from "../../Queue.ts" +import type * as Scope from "../../Scope.ts" +import * as Stream from "../../stream/Stream.ts" + +/** + * @since 4.0.0 + */ +export const asyncPauseResume = ( + register: (emit: { + readonly single: (item: A) => void + readonly array: (arr: ReadonlyArray) => void + readonly fail: (error: E) => void + readonly end: () => void + }) => Effect.Effect< + { + onPause(): void + onResume(): void + }, + E, + R | Scope.Scope + >, + bufferSize = 128 +): Stream.Stream => + Stream.callback((queue) => + Effect.suspend(() => { + let cbs!: { + onPause(): void + onResume(): void + } + + let paused = false + const offer = (arr: ReadonlyArray) => { + if (arr.length === 0) return + const isFull = Queue.unsafeIsFull(queue) + if (!isFull || (isFull && paused)) { + return Effect.runFork(Queue.offerAll(queue, arr)) + } + paused = true + cbs.onPause() + return Queue.offerAll(queue, arr).pipe( + Effect.tap(() => { + cbs.onResume() + paused = false + }), + Effect.runFork + ) + } + + return Effect.map( + register({ + single: (item) => offer([item]), + array: (chunk) => offer(chunk), + fail: (error) => Queue.unsafeDone(queue, Exit.fail(error)), + end: () => Queue.unsafeDone(queue, Exit.void) + }), + (_) => { + cbs = _ + } + ) + }), { bufferSize }) diff --git a/packages/effect/src/unstable/sql/Statement.ts b/packages/effect/src/unstable/sql/Statement.ts new file mode 100644 index 0000000000..6d634cf56c --- /dev/null +++ b/packages/effect/src/unstable/sql/Statement.ts @@ -0,0 +1,1398 @@ +/** + * @since 4.0.0 + */ +import { hasProperty } from "../../data/Predicate.ts" +import * as Effect from "../../Effect.ts" +import type * as Fiber from "../../Fiber.ts" +import { constUndefined } from "../../Function.ts" +import type { Inspectable } from "../../interfaces/Inspectable.ts" +import type { Pipeable } from "../../interfaces/Pipeable.ts" +import * as core from "../../internal/core.ts" +import * as internalEffect from "../../internal/effect.ts" +import type * as Tracer from "../../observability/Tracer.ts" +import * as ServiceMap from "../../ServiceMap.ts" +import * as Stream from "../../stream/Stream.ts" +import { Clock } from "../../time/Clock.ts" +import type { Acquirer, Connection, Row } from "./SqlConnection.ts" +import type { SqlError } from "./SqlError.ts" + +/** + * @category type id + * @since 4.0.0 + */ +export const FragmentTypeId: FragmentTypeId = "~effect/sql/Fragment" + +/** + * @category type id + * @since 4.0.0 + */ +export type FragmentTypeId = "~effect/sql/Fragment" + +/** + * @category model + * @since 4.0.0 + */ +export interface Fragment { + readonly [FragmentTypeId]: FragmentTypeId + readonly segments: ReadonlyArray +} + +/** + * @category constructors + * @since 4.0.0 + */ +export const fragment = ( + segments: ReadonlyArray +): Fragment => ({ + [FragmentTypeId]: FragmentTypeId, + segments +}) + +/** + * @category model + * @since 4.0.0 + */ +export type Dialect = "sqlite" | "pg" | "mysql" | "mssql" | "clickhouse" + +/** + * @category model + * @since 4.0.0 + */ +export interface Statement extends Fragment, Effect.Effect, SqlError>, Pipeable, Inspectable { + readonly raw: Effect.Effect + readonly withoutTransform: Effect.Effect, SqlError> + readonly stream: Stream.Stream + readonly values: Effect.Effect>, SqlError> + readonly unprepared: Effect.Effect, SqlError> + readonly compile: (withoutTransform?: boolean | undefined) => readonly [ + sql: string, + params: ReadonlyArray + ] +} + +/** + * @category model + * @since 4.0.0 + */ +export type Transformer = ( + self: Statement, + sql: Constructor, + fiber: Fiber.Fiber, + span: Tracer.Span +) => Effect.Effect> + +/** + * @category transformer + * @since 4.0.0 + */ +export const CurrentTransformer = ServiceMap.Reference("effect/sql/CurrentTransformer", { + defaultValue: constUndefined +}) + +/** + * @category guard + * @since 4.0.0 + */ +export const isFragment = (u: unknown): u is Fragment => hasProperty(u, FragmentTypeId) + +/** + * @category guard + * @since 4.0.0 + */ +export const isCustom = >( + kind: A["kind"] +) => +(u: unknown): u is A => hasProperty(u, "_tag") && u._tag === "Custom" && (u as any).kind === kind + +/** + * @category model + * @since 4.0.0 + */ +export type Segment = + | Literal + | Identifier + | Parameter + | ArrayHelper + | RecordInsertHelper + | RecordUpdateHelper + | RecordUpdateHelperSingle + | Custom + +/** + * @category model + * @since 4.0.0 + */ +export interface Literal { + readonly _tag: "Literal" + readonly value: string + readonly params?: ReadonlyArray | undefined +} + +/** + * @category constructors + * @since 4.0.0 + */ +export const literal = (value: string, params?: ReadonlyArray | undefined): Literal => ({ + _tag: "Literal", + value, + params +}) + +/** + * @category model + * @since 4.0.0 + */ +export interface Identifier { + readonly _tag: "Identifier" + readonly value: string +} + +/** + * @category constructors + * @since 4.0.0 + */ +export const identifier = (value: string): Identifier => ({ + _tag: "Identifier", + value +}) + +/** + * @category model + * @since 4.0.0 + */ +export interface Parameter { + readonly _tag: "Parameter" + readonly value: Primitive +} + +/** + * @category constructors + * @since 4.0.0 + */ +export const parameter = (value: Primitive): Parameter => ({ + _tag: "Parameter", + value +}) + +/** + * @category model + * @since 4.0.0 + */ +export interface ArrayHelper { + readonly _tag: "ArrayHelper" + readonly value: ReadonlyArray +} + +/** + * @category constructors + * @since 4.0.0 + */ +export const arrayHelper = (value: ReadonlyArray): ArrayHelper => ({ + _tag: "ArrayHelper", + value +}) + +/** + * @category model + * @since 4.0.0 + */ +export interface RecordInsertHelper { + readonly _tag: "RecordInsertHelper" + readonly value: ReadonlyArray> + /** @internal */ + readonly returningIdentifier: string | Fragment | undefined + readonly returning: (sql: string | Identifier | Fragment) => RecordInsertHelper +} + +const RecordInsertHelperProto = { + _tag: "RecordInsertHelper" as const, + returning(this: RecordInsertHelper, sql: string | Identifier | Fragment) { + const self = Object.create(Object.getPrototypeOf(this)) + Object.assign(self, this, { + returningIdentifier: sql + }) + return self + } +} + +/** + * @category constructors + * @since 4.0.0 + */ +export const recordInsertHelper = ( + value: ReadonlyArray> +): RecordInsertHelper => + Object.assign(Object.create(RecordInsertHelperProto), { + value, + returningIdentifier: undefined + }) + +/** + * @category model + * @since 4.0.0 + */ +export interface RecordUpdateHelper { + readonly _tag: "RecordUpdateHelper" + readonly value: ReadonlyArray> + readonly alias: string + /** @internal */ + readonly returningIdentifier: string | Fragment | undefined + readonly returning: (sql: string | Identifier | Fragment) => RecordUpdateHelper +} + +const RecordUpdateHelperProto = { + ...RecordInsertHelperProto, + _tag: "RecordUpdateHelper" as const +} + +/** + * @category constructors + * @since 4.0.0 + */ +export const recordUpdateHelper = ( + value: ReadonlyArray>, + alias: string +): RecordUpdateHelper => + Object.assign(Object.create(RecordUpdateHelperProto), { + value, + alias, + returningIdentifier: undefined + }) + +/** + * @category model + * @since 4.0.0 + */ +export interface RecordUpdateHelperSingle { + readonly _tag: "RecordUpdateHelperSingle" + readonly value: Record + readonly omit: ReadonlyArray + /** @internal */ + readonly returningIdentifier: string | Fragment | undefined + readonly returning: (sql: string | Identifier | Fragment) => RecordUpdateHelperSingle +} + +const RecordUpdateHelperSingleProto = { + ...RecordInsertHelperProto, + _tag: "RecordUpdateHelperSingle" as const +} + +/** + * @category constructors + * @since 4.0.0 + */ +export const recordUpdateHelperSingle = ( + value: Record, + omit: ReadonlyArray +): RecordUpdateHelperSingle => + Object.assign(Object.create(RecordUpdateHelperSingleProto), { + value, + omit, + returningIdentifier: undefined + }) + +/** + * @category model + * @since 4.0.0 + */ +export interface Custom< + T extends string = string, + A = void, + B = void, + C = void +> { + readonly _tag: "Custom" + readonly kind: T + readonly paramA: A + readonly paramB: B + readonly paramC: C +} + +/** + * @category constructor + * @since 4.0.0 + */ +export const custom = >( + kind: C["kind"] +) => +( + paramA: C["paramA"], + paramB: C["paramB"], + paramC: C["paramC"] +): C => ({ _tag: "Custom", kind, paramA, paramB, paramC } as C) + +/** + * @category model + * @since 4.0.0 + */ +export type Primitive = + | string + | number + | bigint + | boolean + | Date + | null + | Int8Array + | Uint8Array + +/** + * @category model + * @since 4.0.0 + */ +export type PrimitiveKind = + | "string" + | "number" + | "bigint" + | "boolean" + | "Date" + | "null" + | "Int8Array" + | "Uint8Array" + +/** + * @category model + * @since 4.0.0 + */ +export type Helper = + | ArrayHelper + | RecordInsertHelper + | RecordUpdateHelper + | RecordUpdateHelperSingle + | Identifier + | Custom + +/** + * @category model + * @since 4.0.0 + */ +export type Argument = Primitive | Helper | Fragment + +/** + * @category model + * @since 4.0.0 + */ +export interface Constructor { + ( + strings: TemplateStringsArray, + ...args: Array + ): Statement + + (value: string): Identifier + + /** + * Create unsafe SQL query + */ + readonly unsafe: ( + sql: string, + params?: ReadonlyArray | undefined + ) => Statement + + readonly literal: (sql: string) => Fragment + + readonly in: { + (value: ReadonlyArray): ArrayHelper + (column: string, value: ReadonlyArray): Fragment + } + + readonly insert: { + ( + value: ReadonlyArray> + ): RecordInsertHelper + (value: Record): RecordInsertHelper + } + + /** Update a single row */ + readonly update: >( + value: A, + omit?: ReadonlyArray + ) => RecordUpdateHelperSingle + + /** + * Update multiple rows + * + * **Note:** Not supported in sqlite + */ + readonly updateValues: ( + value: ReadonlyArray>, + alias: string + ) => RecordUpdateHelper + + /** + * Create an `AND` chain for a where clause + */ + readonly and: (clauses: ReadonlyArray) => Fragment + + /** + * Create an `OR` chain for a where clause + */ + readonly or: (clauses: ReadonlyArray) => Fragment + + /** + * Create comma seperated values, with an optional prefix + * + * Useful for `ORDER BY` and `GROUP BY` clauses + */ + readonly csv: { + (values: ReadonlyArray): Fragment + (prefix: string, values: ReadonlyArray): Fragment + } + + readonly join: ( + literal: string, + addParens?: boolean, + fallback?: string + ) => (clauses: ReadonlyArray) => Fragment + + readonly onDialect: (options: { + readonly sqlite: () => A + readonly pg: () => B + readonly mysql: () => C + readonly mssql: () => D + readonly clickhouse: () => E + }) => A | B | C | D | E + + readonly onDialectOrElse: (options: { + readonly orElse: () => A + readonly sqlite?: () => B + readonly pg?: () => C + readonly mysql?: () => D + readonly mssql?: () => E + readonly clickhouse?: () => F + }) => A | B | C | D | E | F +} + +/** + * @category constructor + * @since 4.0.0 + */ +export const make = ( + acquirer: Acquirer, + compiler: Compiler, + spanAttributes: ReadonlyArray, + transformRows: ((row: ReadonlyArray) => ReadonlyArray) | undefined +): Constructor => { + const cache = transformRows === undefined ? constructorCache.noTransforms : constructorCache.transforms + if (cache.has(acquirer)) { + return cache.get(acquirer)! + } + const self = Object.assign( + function sql(strings: unknown, ...args: Array): any { + if (typeof strings === "string") { + return identifier(strings) + } else if (Array.isArray(strings) && "raw" in strings) { + return statement( + acquirer, + compiler, + strings as TemplateStringsArray, + args, + spanAttributes, + transformRows + ) + } + + throw "absurd" + }, + { + unsafe( + sql: string, + params?: ReadonlyArray + ) { + return unsafeMake( + [literal(sql, params)], + acquirer, + compiler, + spanAttributes, + transformRows + ) + }, + literal(sql: string) { + return fragment([literal(sql)]) + }, + in: in_, + insert(value: any) { + return recordInsertHelper( + Array.isArray(value) ? value : [value] + ) + }, + update(value: any, omit: any) { + return recordUpdateHelperSingle(value, omit ?? []) + }, + updateValues(value: any, alias: any) { + return recordUpdateHelper(value, alias) + }, + and, + or, + csv, + join, + onDialect(options: Record) { + return options[compiler.dialect]() + }, + onDialectOrElse(options: any) { + return options[compiler.dialect] !== undefined ? options[compiler.dialect]() : options.orElse() + } + } + ) + + cache.set(acquirer, self) + + return self +} + +const constructorCache = { + transforms: new WeakMap(), + noTransforms: new WeakMap() +} + +/** + * @category constructors + * @since 4.0.0 + */ +export const statement = ( + acquirer: Acquirer, + compiler: Compiler, + strings: TemplateStringsArray, + args: Array, + spanAttributes: ReadonlyArray, + transformRows: ((row: ReadonlyArray) => ReadonlyArray) | undefined +): Statement => { + const segments: Array = strings[0].length > 0 ? [literal(strings[0])] : [] + + for (let i = 0; i < args.length; i++) { + const arg = args[i] + + if (isFragment(arg)) { + // eslint-disable-next-line no-restricted-syntax + segments.push(...arg.segments) + } else if (isSegment(arg)) { + segments.push(arg) + } else { + segments.push(parameter(arg)) + } + + if (strings[i + 1].length > 0) { + segments.push(literal(strings[i + 1])) + } + } + + return unsafeMake(segments, acquirer, compiler, spanAttributes, transformRows) +} + +/** + * @category constructor + * @since 4.0.0 + */ +export function join(lit: string, addParens = true, fallback = "") { + const literalStatement = literal(lit) + const fallbackFragment = fragment([literal(fallback)]) + + return (clauses: ReadonlyArray): Fragment => { + if (clauses.length === 0) { + return fallbackFragment + } else if (clauses.length === 1) { + return fragment(convertLiteralOrFragment(clauses[0])) + } + + const segments: Array = [] + + if (addParens) { + segments.push(literal("(")) + } + + segments.push.apply(segments, convertLiteralOrFragment(clauses[0])) + + for (let i = 1; i < clauses.length; i++) { + segments.push(literalStatement) + segments.push.apply(segments, convertLiteralOrFragment(clauses[i])) + } + + if (addParens) { + segments.push(literal(")")) + } + + return fragment(segments) + } +} + +/** + * @category constructor + * @since 4.0.0 + */ +export const and: (clauses: ReadonlyArray) => Fragment = join(" AND ", true, "1=1") + +/** + * @category constructor + * @since 4.0.0 + */ +export const or: (clauses: ReadonlyArray) => Fragment = join(" OR ", true, "1=1") + +/** + * @category constructor + * @since 4.0.0 + */ +export const csv: { + (values: ReadonlyArray): Fragment + (prefix: string, values: ReadonlyArray): Fragment +} = function( + ...args: + | [values: ReadonlyArray] + | [prefix: string, values: ReadonlyArray] +) { + if (args[args.length - 1].length === 0) { + return emptyFragment + } + + if (args.length === 1) { + return csvRaw(args[0]) + } + + return fragment([ + literal(`${args[0]} `), + ...csvRaw(args[1]).segments + ]) +} + +const csvRaw = join(",", false) +const emptyFragment = fragment([literal("")]) + +/** + * @category compiler + * @since 4.0.0 + */ +export interface Compiler { + readonly dialect: Dialect + readonly compile: ( + statement: Fragment, + withoutTransform: boolean + ) => readonly [sql: string, params: ReadonlyArray] + readonly withoutTransform: this +} + +/** + * @category compiler + * @since 4.0.0 + */ +export type CompilerOptions = any> = { + readonly dialect: Dialect + readonly placeholder: (index: number, value: unknown) => string + readonly onIdentifier: (value: string, withoutTransform: boolean) => string + readonly onRecordUpdate: ( + placeholders: string, + alias: string, + columns: string, + values: ReadonlyArray>, + returning: readonly [sql: string, params: ReadonlyArray] | undefined + ) => readonly [sql: string, params: ReadonlyArray] + readonly onCustom: ( + type: C, + placeholder: (u: unknown) => string, + withoutTransform: boolean + ) => readonly [sql: string, params: ReadonlyArray] + readonly onInsert?: ( + columns: ReadonlyArray, + placeholders: string, + values: ReadonlyArray>, + returning: readonly [sql: string, params: ReadonlyArray] | undefined + ) => readonly [sql: string, binds: ReadonlyArray] + readonly onRecordUpdateSingle?: ( + columns: ReadonlyArray, + values: ReadonlyArray, + returning: readonly [sql: string, params: ReadonlyArray] | undefined + ) => readonly [sql: string, params: ReadonlyArray] +} + +/** + * @category compiler + * @since 4.0.0 + */ +export const makeCompiler = = any>( + options: CompilerOptions +): Compiler => { + const self = Object.create(CompilerProto) + self.options = options + self.dialect = options.dialect + self.disableTransforms = false + return self +} + +interface CompilerImpl extends Compiler { + readonly options: CompilerOptions + readonly disableTransforms: boolean + compile( + statement: Fragment, + withoutTransform?: boolean, + placeholderOverride?: (u: unknown) => string + ): readonly [sql: string, binds: ReadonlyArray] +} + +const statementCacheSymbol = Symbol.for("effect/unstable/sql/Statement/statementCache") +const statementCacheNoTransformSymbol = Symbol.for("effect/unstable/sql/Statement/statementCacheNoTransform") + +const CompilerProto = { + compile( + this: CompilerImpl, + statement: Fragment, + withoutTransform = false, + placeholderOverride?: (u: unknown) => string + ): readonly [sql: string, binds: ReadonlyArray] { + const opts = this.options + withoutTransform = withoutTransform || this.disableTransforms + const cacheSymbol = withoutTransform ? statementCacheNoTransformSymbol : statementCacheSymbol + if (cacheSymbol in statement) { + return (statement as any)[cacheSymbol] + } + + const segments = statement.segments + const len = segments.length + + let sql = "" + const binds: Array = [] + let placeholderCount = 0 + const placeholder = placeholderOverride ?? ((u: unknown) => opts.placeholder(++placeholderCount, u)) + const placeholderNoIncrement = (u: unknown) => opts.placeholder(placeholderCount, u) + const placeholders = makePlaceholdersArray(placeholder) + + for (let i = 0; i < len; i++) { + const segment = segments[i] + + switch (segment._tag) { + case "Literal": { + sql += segment.value + if (segment.params) { + binds.push.apply(binds, segment.params as any) + } + break + } + + case "Identifier": { + sql += opts.onIdentifier(segment.value, withoutTransform) + break + } + + case "Parameter": { + sql += placeholder(segment.value) + binds.push(segment.value) + break + } + + case "ArrayHelper": { + sql += `(${placeholders(segment.value)})` + binds.push.apply(binds, segment.value as any) + break + } + + case "RecordInsertHelper": { + const keys = Object.keys(segment.value[0]) + + if (opts.onInsert) { + const values: Array> = new Array(segment.value.length) + let placeholders = "" + for (let i = 0; i < segment.value.length; i++) { + const row: Array = new Array(keys.length) + values[i] = row + placeholders += i === 0 ? "(" : ",(" + for (let j = 0; j < keys.length; j++) { + const key = keys[j] + const value = segment.value[i][key] + const primitive = extractPrimitive(value, opts.onCustom, placeholderNoIncrement, withoutTransform) + row[j] = primitive + placeholders += j === 0 ? placeholder(value) : `,${placeholder(value)}` + } + placeholders += ")" + } + const [s, b] = opts.onInsert( + keys.map((_) => opts.onIdentifier(_, withoutTransform)), + placeholders, + values, + typeof segment.returningIdentifier === "string" + ? [segment.returningIdentifier, []] + : segment.returningIdentifier + ? this.compile(segment.returningIdentifier, withoutTransform, placeholder) + : undefined + ) + sql += s + binds.push.apply(binds, b as any) + } else { + let placeholders = "" + for (let i = 0; i < segment.value.length; i++) { + placeholders += i === 0 ? "(" : ",(" + for (let j = 0; j < keys.length; j++) { + const value = segment.value[i][keys[j]] + const primitive = extractPrimitive(value, opts.onCustom, placeholderNoIncrement, withoutTransform) + binds.push(primitive) + placeholders += j === 0 ? placeholder(value) : `,${placeholder(value)}` + } + placeholders += ")" + } + sql += `${ + generateColumns( + keys, + opts.onIdentifier, + withoutTransform + ) + } VALUES ${placeholders}` + + if (typeof segment.returningIdentifier === "string") { + sql += ` RETURNING ${segment.returningIdentifier}` + } else if (segment.returningIdentifier) { + sql += " RETURNING " + const [s, b] = this.compile(segment.returningIdentifier, withoutTransform, placeholder) + sql += s + binds.push.apply(binds, b as any) + } + } + break + } + + case "RecordUpdateHelperSingle": { + let keys = Object.keys(segment.value) + if (segment.omit.length > 0) { + keys = keys.filter((key) => !segment.omit.includes(key)) + } + if (opts.onRecordUpdateSingle) { + const [s, b] = opts.onRecordUpdateSingle( + keys.map((_) => opts.onIdentifier(_, withoutTransform)), + keys.map((key) => + extractPrimitive( + segment.value[key], + opts.onCustom, + placeholderNoIncrement, + withoutTransform + ) + ), + typeof segment.returningIdentifier === "string" + ? [segment.returningIdentifier, []] + : segment.returningIdentifier + ? this.compile(segment.returningIdentifier, withoutTransform, placeholder) + : undefined + ) + sql += s + binds.push.apply(binds, b as any) + } else { + for (let i = 0, len = keys.length; i < len; i++) { + const column = opts.onIdentifier(keys[i], withoutTransform) + if (i === 0) { + sql += `${column} = ${placeholder(segment.value[keys[i]])}` + } else { + sql += `, ${column} = ${placeholder(segment.value[keys[i]])}` + } + binds.push( + extractPrimitive( + segment.value[keys[i]], + opts.onCustom, + placeholderNoIncrement, + withoutTransform + ) + ) + } + if (typeof segment.returningIdentifier === "string") { + if (this.dialect === "mssql") { + sql += ` OUTPUT ${segment.returningIdentifier === "*" ? "INSERTED.*" : segment.returningIdentifier}` + } else { + sql += ` RETURNING ${segment.returningIdentifier}` + } + } else if (segment.returningIdentifier) { + sql += this.dialect === "mssql" ? " OUTPUT " : " RETURNING " + const [s, b] = this.compile(segment.returningIdentifier, withoutTransform, placeholder) + sql += s + binds.push.apply(binds, b as any) + } + } + break + } + + case "RecordUpdateHelper": { + const keys = Object.keys(segment.value[0]) + const values: Array> = new Array(segment.value.length) + let placeholders = "" + for (let i = 0; i < segment.value.length; i++) { + const row: Array = new Array(keys.length) + values[i] = row + placeholders += i === 0 ? "(" : ",(" + for (let j = 0; j < keys.length; j++) { + const key = keys[j] + const value = segment.value[i][key] + row[j] = extractPrimitive(value, opts.onCustom, placeholderNoIncrement, withoutTransform) + placeholders += j === 0 ? placeholder(value) : `,${placeholder(value)}` + } + placeholders += ")" + } + const [s, b] = opts.onRecordUpdate( + placeholders, + segment.alias, + generateColumns(keys, opts.onIdentifier, withoutTransform), + values, + typeof segment.returningIdentifier === "string" + ? [segment.returningIdentifier, []] + : segment.returningIdentifier + ? this.compile(segment.returningIdentifier, withoutTransform, placeholder) + : undefined + ) + sql += s + binds.push.apply(binds, b as any) + break + } + + case "Custom": { + const [s, b] = opts.onCustom(segment, placeholder, withoutTransform) + sql += s + binds.push.apply(binds, b as any) + break + } + } + } + + const result = [sql, binds] as const + if (placeholderOverride !== undefined) { + return result + } + return (statement as any)[cacheSymbol] = result + }, + + get withoutTransform() { + const self = Object.create(CompilerProto) + Object.assign(self, this, { + disableTransforms: true + }) + return self + } +} + +/** + * @category compiler + * @since 4.0.0 + */ +export const makeCompilerSqlite = (transform?: ((_: string) => string) | undefined): Compiler => + makeCompiler({ + dialect: "sqlite", + placeholder(_) { + return "?" + }, + onIdentifier: transform ? + function(value, withoutTransform) { + return withoutTransform ? escapeSqlite(value) : escapeSqlite(transform(value)) + } : + escapeSqlite, + onRecordUpdate() { + return ["", []] + }, + onCustom() { + return ["", []] + } + }) + +/** + * @since 4.0.0 + */ +export function defaultEscape(c: string) { + const re = new RegExp(c, "g") + const double = c + c + const dot = c + "." + c + return function(str: string): string { + return c + str.replace(re, double).replace(/\./g, dot) + c + } +} + +/** + * @since 4.0.0 + */ +export const primitiveKind = (value: Primitive): PrimitiveKind => { + switch (typeof value) { + case "string": + return "string" + case "number": + return "number" + case "boolean": + return "boolean" + case "bigint": + return "bigint" + case "undefined": + return "null" + } + + if (value === null) { + return "null" + } else if (value instanceof Date) { + return "Date" + } else if (value instanceof Uint8Array) { + return "Uint8Array" + } else if (value instanceof Int8Array) { + return "Int8Array" + } + + return "string" +} + +/** + * @since 4.0.0 + */ +export const defaultTransforms = ( + transformer: (str: string) => string, + nested = true +) => { + const transformValue = (value: any) => { + if (Array.isArray(value)) { + if (value.length === 0 || value[0].constructor !== Object) { + return value + } + return array(value) + } else if (value?.constructor === Object) { + return transformObject(value) + } + return value + } + + const transformObject = (obj: Record): any => { + const newObj: Record = {} + for (const key in obj) { + newObj[transformer(key)] = transformValue(obj[key]) + } + return newObj + } + + const transformArrayNested = ( + rows: ReadonlyArray + ): ReadonlyArray => { + const newRows: Array = new Array(rows.length) + for (let i = 0, len = rows.length; i < len; i++) { + const row = rows[i] + if (Array.isArray(row)) { + newRows[i] = transformArrayNested(row) as any + } else { + const obj: any = {} + for (const key in row) { + obj[transformer(key)] = transformValue(row[key]) + } + newRows[i] = obj + } + } + return newRows + } + + const transformArray = ( + rows: ReadonlyArray + ): ReadonlyArray => { + const newRows: Array = new Array(rows.length) + for (let i = 0, len = rows.length; i < len; i++) { + const row = rows[i] + if (Array.isArray(row)) { + newRows[i] = transformArray(row) as any + } else { + const obj: any = {} + for (const key in row) { + obj[transformer(key)] = row[key] + } + newRows[i] = obj + } + } + return newRows + } + + const array = nested ? transformArrayNested : transformArray + + return { + value: transformValue, + object: transformObject, + array + } as const +} + +// internal + +const ATTR_DB_OPERATION_NAME = "db.operation.name" +const ATTR_DB_QUERY_TEXT = "db.query.text" + +interface StatementImpl extends Statement { + readonly segments: ReadonlyArray + readonly acquirer: Acquirer + readonly compiler: Compiler + readonly spanAttributes: ReadonlyArray + readonly transformRows: ((row: ReadonlyArray) => ReadonlyArray) | undefined + + withConnection( + operation: string, + f: ( + connection: Connection, + sql: string, + params: ReadonlyArray + ) => Effect.Effect, + withoutTransform?: boolean | undefined + ): Effect.Effect + withConnectionSpan( + operation: string, + f: ( + connection: Connection, + sql: string, + params: ReadonlyArray + ) => Effect.Effect, + withoutTransform: boolean, + span: Tracer.Span + ): Effect.Effect +} + +const unsafeMake = ( + segments: ReadonlyArray, + acquirer: Acquirer, + compiler: Compiler, + spanAttributes: ReadonlyArray, + transformRows: ((row: ReadonlyArray) => ReadonlyArray) | undefined +): StatementImpl => { + const self = Object.create(StatementProto) + self.segments = segments + self.acquirer = acquirer + self.compiler = compiler + self.spanAttributes = spanAttributes + self.transformRows = transformRows + return self +} + +const StatementProto: Omit< + StatementImpl, + "segments" | "acquirer" | "compiler" | "spanAttributes" | "transformRows" +> = { + ...core.EffectProto, + [core.identifier as any]: "Statement", + [FragmentTypeId]: FragmentTypeId, + withConnection( + this: StatementImpl, + operation: string, + f: ( + connection: Connection, + sql: string, + params: ReadonlyArray + ) => Effect.Effect, + withoutTransform = false + ): Effect.Effect { + return Effect.useSpan( + "sql.execute", + { kind: "client", captureStackTrace: false }, + (span) => + this.withConnectionSpan( + operation, + f, + withoutTransform, + span + ) + ) + }, + withConnectionSpan( + this: StatementImpl, + operation: string, + f: ( + connection: Connection, + sql: string, + params: ReadonlyArray + ) => Effect.Effect, + withoutTransform: boolean, + span: Tracer.Span + ): Effect.Effect { + return withStatement(this, span, (statement) => { + const [sql, params] = statement.compile(withoutTransform) + for (const [key, value] of this.spanAttributes) { + span.attribute(key, value) + } + span.attribute(ATTR_DB_OPERATION_NAME, operation) + span.attribute(ATTR_DB_QUERY_TEXT, sql) + return Effect.scoped(Effect.flatMap(this.acquirer, (_) => f(_, sql, params))) + }) + }, + + get withoutTransform(): Effect.Effect, SqlError> { + return this.withConnection( + "executeWithoutTransform", + (connection, sql, params) => connection.execute(sql, params, undefined), + true + ) + }, + + get raw(): Effect.Effect { + return this.withConnection( + "executeRaw", + (connection, sql, params) => connection.executeRaw(sql, params), + true + ) + }, + + get stream(): Stream.Stream { + const self = this as StatementImpl + return Stream.unwrap(Effect.flatMap( + Effect.makeSpanScoped("sql.execute", { kind: "client", captureStackTrace: false }), + (span) => + withStatement(self, span, (statement) => { + const [sql, params] = statement.compile() + for (const [key, value] of self.spanAttributes) { + span.attribute(key, value) + } + span.attribute(ATTR_DB_OPERATION_NAME, "executeStream") + span.attribute(ATTR_DB_QUERY_TEXT, sql) + return Effect.map(self.acquirer, (_) => _.executeStream(sql, params, self.transformRows)) + }) + )) + }, + + get values(): Effect.Effect< + ReadonlyArray>, + SqlError + > { + return this.withConnection("executeValues", (connection, sql, params) => connection.executeValues(sql, params)) + }, + + get unprepared(): Effect.Effect, SqlError> { + const self = this as StatementImpl + return self.withConnection( + "executeUnprepared", + (connection, sql, params) => connection.executeUnprepared(sql, params, self.transformRows) + ) + }, + + compile( + this: StatementImpl, + withoutTransform?: boolean | undefined + ) { + return this.compiler.compile(this, withoutTransform ?? false) + }, + [core.evaluate as any]( + this: StatementImpl, + fiber: Fiber.Fiber + ): Effect.Effect, SqlError> { + const span = internalEffect.unsafeMakeSpan(fiber, "sql.execute", { kind: "client", captureStackTrace: false }) + const clock = fiber.getRef(Clock) + return Effect.onExit( + this.withConnectionSpan( + "execute", + (connection, sql, params) => connection.execute(sql, params, this.transformRows), + false, + span + ), + (exit) => internalEffect.endSpan(span, exit, clock) + ) + }, + toJSON(this: StatementImpl) { + const [sql, params] = this.compile() + return { + _id: "Statement", + segments: this.segments, + sql, + params + } + } +} + +const withStatement = ( + self: StatementImpl, + span: Tracer.Span, + f: (statement: StatementImpl) => Effect.Effect +) => + Effect.withFiber((fiber) => { + const transform = fiber.getRef(CurrentTransformer) + if (transform === undefined) { + return f(self) + } + return Effect.flatMap( + transform( + self, + make(self.acquirer, self.compiler, self.spanAttributes, self.transformRows), + fiber, + span + ) as Effect.Effect>, + f + ) + }) + +const isSegment = (u: unknown): u is Segment => { + if (!hasProperty(u, "_tag")) { + return false + } + switch (u._tag) { + case "Literal": + case "Parameter": + case "ArrayHelper": + case "RecordInsertHelper": + case "RecordUpdateHelper": + case "RecordUpdateHelperSingle": + case "Identifier": + case "Custom": + return true + default: + return false + } +} + +function convertLiteralOrFragment(clause: string | Fragment): Array { + if (typeof clause === "string") { + return [literal(clause)] + } + return clause.segments as Array +} + +const makePlaceholdersArray = (evaluate: (u: unknown) => string) => (values: ReadonlyArray): string => { + if (values.length === 0) { + return "" + } + + let result = evaluate(values[0]) + for (let i = 1; i < values.length; i++) { + result += `,${evaluate(values[i])}` + } + + return result +} + +const generateColumns = ( + keys: ReadonlyArray, + escape: (_: string, withoutTransform: boolean) => string, + withoutTransform: boolean +) => { + if (keys.length === 0) { + return "()" + } + + let str = `(${escape(keys[0], withoutTransform)}` + for (let i = 1; i < keys.length; i++) { + str += `,${escape(keys[i], withoutTransform)}` + } + return str + ")" +} + +const extractPrimitive = ( + value: Primitive | Fragment | undefined, + onCustom: ( + type: Custom, + placeholder: (u: unknown) => string, + withoutTransform: boolean + ) => readonly [sql: string, binds: ReadonlyArray], + placeholder: (u: unknown) => string, + withoutTransform: boolean +): Primitive => { + if (value === undefined) { + return null + } else if (isFragment(value)) { + const head = value.segments[0] + if (head._tag === "Custom") { + const compiled = onCustom(head, placeholder, withoutTransform) + return compiled[1][0] ?? null + } else if (head._tag === "Parameter") { + return head.value + } + return null + } + return value +} + +const escapeSqlite = defaultEscape("\"") + +function in_(values: ReadonlyArray): ArrayHelper +function in_(column: string, values: ReadonlyArray): Fragment +function in_(): Fragment | ArrayHelper { + if (arguments.length === 1) { + return arrayHelper(arguments[0]) + } + const column = arguments[0] + const values = arguments[1] + return values.length === 0 ? neverFragment : fragment([ + identifier(column), + literal(" IN "), + arrayHelper(values) + ]) +} + +const neverFragment = fragment([literal("1=0")]) diff --git a/packages/effect/src/unstable/sql/index.ts b/packages/effect/src/unstable/sql/index.ts new file mode 100644 index 0000000000..748e0e485c --- /dev/null +++ b/packages/effect/src/unstable/sql/index.ts @@ -0,0 +1,49 @@ +/** + * @since 4.0.0 + */ + +/** + * @since 4.0.0 + */ +export * as Migrator from "./Migrator.ts" + +/** + * @since 4.0.0 + */ +export * as SqlClient from "./SqlClient.ts" + +/** + * @since 4.0.0 + */ +export * as SqlConnection from "./SqlConnection.ts" + +/** + * @since 4.0.0 + */ +export * as SqlError from "./SqlError.ts" + +/** + * @since 4.0.0 + * @category models + */ +export * as SqlModel from "./SqlModel.ts" + +/** + * @since 4.0.0 + */ +export * as SqlResolver from "./SqlResolver.ts" + +/** + * @since 4.0.0 + */ +export * as SqlSchema from "./SqlSchema.ts" + +/** + * @since 4.0.0 + */ +export * as SqlStream from "./SqlStream.ts" + +/** + * @since 4.0.0 + */ +export * as Statement from "./Statement.ts" diff --git a/packages/effect/src/unstable/sql/index.ts.tpl b/packages/effect/src/unstable/sql/index.ts.tpl new file mode 100644 index 0000000000..c2aac82f76 --- /dev/null +++ b/packages/effect/src/unstable/sql/index.ts.tpl @@ -0,0 +1,3 @@ +/** + * @since 4.0.0 + */ diff --git a/packages/effect/test/Pool.test.ts b/packages/effect/test/Pool.test.ts new file mode 100644 index 0000000000..5f6f7f2367 --- /dev/null +++ b/packages/effect/test/Pool.test.ts @@ -0,0 +1,423 @@ +import { assert, describe, it } from "@effect/vitest" +import { deepStrictEqual, strictEqual } from "@effect/vitest/utils" +import { Deferred, Effect, Exit, Fiber, pipe, Pool, Ref, Schedule, Scope } from "effect" +import { TestClock } from "effect/testing" +import { Duration } from "effect/time" + +describe("Pool", () => { + it.effect("preallocates pool items", () => + Effect.gen(function*() { + const count = yield* Ref.make(0) + const get = Effect.acquireRelease( + Ref.updateAndGet(count, (n) => n + 1), + () => Ref.update(count, (n) => n - 1) + ) + yield* Pool.make({ acquire: get, size: 10 }) + yield* Effect.repeat(Ref.get(count), { until: (n) => n === 10 }) + const result = yield* Ref.get(count) + strictEqual(result, 10) + })) + + // it.effect("benchmark", () => + // Effect.gen(function*() { + // const get = Effect.succeed("resource") + // const pool = yield* Pool.make({ acquire: get, size: 10 }) + // yield* Pool.get(pool).pipe( + // Effect.scoped, + // Effect.repeatN(10000), + // Console.withTime("Pool.get") + // ) + // })) + + it.effect("cleans up items when shut down", () => + Effect.gen(function*() { + const count = yield* Ref.make(0) + const get = Effect.acquireRelease( + Ref.updateAndGet(count, (n) => n + 1), + () => Ref.update(count, (n) => n - 1) + ) + const scope = yield* Scope.make() + yield* Scope.provide(Pool.make({ acquire: get, size: 10 }), scope) + yield* Effect.repeat(Ref.get(count), { until: (n) => n === 10 }) + yield* Scope.close(scope, Exit.succeed(void 0)) + const result = yield* Ref.get(count) + strictEqual(result, 0) + })) + + it.effect("defects don't prevent cleanup", () => + Effect.gen(function*() { + const count = yield* Ref.make(0) + const get = Effect.acquireRelease( + Ref.updateAndGet(count, (n) => n + 1), + () => Effect.andThen(Ref.update(count, (n) => n - 1), Effect.die("boom")) + ) + const scope = yield* Scope.make() + yield* Scope.provide(Pool.make({ acquire: get, size: 10 }), scope) + yield* Effect.repeat(Ref.get(count), { until: (n) => n === 10 }) + yield* Scope.close(scope, Exit.succeed(void 0)) + const result = yield* Ref.get(count) + strictEqual(result, 0) + })) + + it.effect("acquire one item", () => + Effect.gen(function*() { + const count = yield* Ref.make(0) + const get = Effect.acquireRelease( + Ref.updateAndGet(count, (n) => n + 1), + () => Ref.update(count, (n) => n - 1) + ) + const pool = yield* Pool.make({ acquire: get, size: 10 }) + yield* Effect.repeat(Ref.get(count), { until: (n) => n === 10 }) + const item = yield* Pool.get(pool) + strictEqual(item, 1) + })) + + it.effect("reports failures via get", () => + Effect.gen(function*() { + const count = yield* Ref.make(0) + const get = Effect.acquireRelease( + Effect.flatMap( + Ref.updateAndGet(count, (n) => n + 1), + Effect.fail + ), + () => Ref.update(count, (n) => n - 1) + ) + const pool = yield* Pool.make({ acquire: get, size: 10 }) + const values = yield* Effect.all(Effect.replicate(9)(Effect.flip(Pool.get(pool)))) + deepStrictEqual(Array.from(values), [1, 2, 3, 4, 5, 6, 7, 8, 9]) + })) + + it.live("blocks when item not available", () => + Effect.gen(function*() { + const count = yield* Ref.make(0) + const get = Effect.acquireRelease( + Ref.updateAndGet(count, (n) => n + 1), + () => Ref.update(count, (n) => n - 1) + ) + const pool = yield* Pool.make({ acquire: get, size: 10 }) + yield* Effect.repeat(Ref.get(count), { until: (n) => n === 10 }) + yield* Effect.all(Effect.replicate(10)(Pool.get(pool))) + const result = yield* Effect.scoped(Pool.get(pool)).pipe( + Effect.fork({ startImmediately: true }) + ) + yield* Effect.sleep(10) + assert.isUndefined(result.unsafePoll()) + })) + + it.effect("reuse released items", () => + Effect.gen(function*() { + const count = yield* Ref.make(0) + const get = Effect.acquireRelease( + Ref.updateAndGet(count, (n) => n + 1), + () => Ref.update(count, (n) => n - 1) + ) + const pool = yield* Pool.make({ acquire: get, size: 10 }) + yield* Effect.replicateEffect(99)(Effect.scoped(Pool.get(pool))) + const result = yield* Ref.get(count) + strictEqual(result, 10) + })) + + it.effect("invalidate item", () => + Effect.gen(function*() { + const count = yield* Ref.make(0) + const get = Effect.acquireRelease( + Ref.updateAndGet(count, (n) => n + 1), + () => Ref.update(count, (n) => n - 1) + ) + const pool = yield* Pool.make({ acquire: get, size: 10 }) + yield* Effect.repeat(Ref.get(count), { until: (n) => n === 10 }) + yield* Pool.invalidate(pool, 1) + yield* Effect.repeat(Ref.get(count), { until: (n) => n === 10 }) + const result = yield* Effect.scoped(Pool.get(pool)) + const value = yield* Ref.get(count) + strictEqual(result, 2) + strictEqual(value, 10) + })) + + it.effect("invalidate all items in pool and check that pool.get doesn't hang forever", () => + Effect.gen(function*() { + const allocated = yield* Ref.make(0) + const finalized = yield* Ref.make(0) + const get = Effect.acquireRelease( + Ref.updateAndGet(allocated, (n) => n + 1), + () => Ref.update(finalized, (n) => n + 1) + ) + const pool = yield* Pool.make({ acquire: get, size: 2 }) + yield* Effect.repeat(Ref.get(allocated), { until: (n) => n === 2 }) + yield* Pool.invalidate(pool, 1) + yield* Pool.invalidate(pool, 2) + const result = yield* Effect.scoped(Pool.get(pool)) + const allocatedCount = yield* Ref.get(allocated) + const finalizedCount = yield* Ref.get(finalized) + strictEqual(result, 3) + strictEqual(allocatedCount, 4) + strictEqual(finalizedCount, 2) + })) + + it.live("retry on failed acquire should not exhaust pool", () => + Effect.gen(function*() { + const acquire = Effect.as(Effect.fail("error"), 1) + const pool = yield* Pool.makeWithTTL({ acquire, min: 0, max: 1, timeToLive: Duration.infinity }) + const result = yield* pipe( + Effect.scoped(Effect.retry(Pool.get(pool), { times: 5 })), + Effect.timeoutOrElse({ + onTimeout: () => Effect.fail("timeout"), + duration: Duration.seconds(1) + }), + Effect.flip + ) + strictEqual(result, "error") + })) + + it.effect("compositional retry", () => + Effect.gen(function*() { + const cond = (i: number) => (i <= 10 ? Effect.fail(i) : Effect.succeed(i)) + const count = yield* Ref.make(0) + const get = Effect.acquireRelease( + Ref.updateAndGet(count, (n) => n + 1).pipe( + Effect.flatMap(cond) + ), + () => Ref.update(count, (n) => n - 1) + ) + const pool = yield* Pool.make({ acquire: get, size: 10 }) + const result = yield* Effect.retry(Effect.scoped(Pool.get(pool)), Schedule.forever) + strictEqual(result, 11) + })) + + it.effect("max pool size", () => + Effect.gen(function*() { + const deferred = yield* Deferred.make() + const count = yield* Ref.make(0) + const acquire = Effect.acquireRelease( + Ref.updateAndGet(count, (n) => n + 1), + () => Ref.update(count, (n) => n - 1) + ) + const pool = yield* Pool.makeWithTTL({ + acquire, + min: 10, + max: 15, + timeToLive: Duration.seconds(60) + }) + yield* pipe( + Effect.scoped(Effect.andThen( + Pool.get(pool), + Deferred.await(deferred) + )), + Effect.fork, + Effect.repeat({ times: 14 }) + ) + yield* Effect.repeat(Ref.get(count), { until: (n) => n === 15 }) + yield* Deferred.succeed(deferred, void 0) + const max = yield* Ref.get(count) + yield* TestClock.adjust(Duration.seconds(60)) + const min = yield* Ref.get(count) + strictEqual(min, 10) + strictEqual(max, 15) + })) + + it.effect("max pool size with concurrency: 3", () => + Effect.gen(function*() { + const deferred = yield* Deferred.make() + const count = yield* Ref.make(0) + const acquire = Effect.acquireRelease( + Ref.updateAndGet(count, (n) => n + 1), + () => Ref.update(count, (n) => n - 1) + ) + const pool = yield* Pool.makeWithTTL({ + acquire, + min: 10, + max: 15, + concurrency: 3, + timeToLive: Duration.seconds(60) + }) + yield* pipe( + Effect.scoped(Effect.andThen( + Pool.get(pool), + Deferred.await(deferred) + )), + Effect.fork, + Effect.repeat({ times: 14 * 3 }) + ) + yield* Effect.repeat(Ref.get(count), { until: (n) => n === 15 }) + yield* Deferred.succeed(deferred, void 0) + const max = yield* Ref.get(count) + yield* TestClock.adjust(Duration.seconds(60)) + const min = yield* Ref.get(count) + strictEqual(min, 10) + strictEqual(max, 15) + })) + + it.effect("concurrency reclaim", () => + Effect.gen(function*() { + const count = yield* Ref.make(0) + const acquire = Effect.acquireRelease( + Ref.updateAndGet(count, (n) => n + 1), + () => Ref.update(count, (n) => n - 1) + ) + const pool = yield* Pool.makeWithTTL({ + acquire, + min: 0, + max: 2, + concurrency: 2, + timeToLive: Duration.seconds(60) + }) + + const scope1 = yield* Scope.make() + yield* Scope.provide(Pool.get(pool), scope1) + yield* Pool.get(pool) + yield* Effect.scoped(Pool.get(pool)) + yield* TestClock.adjust(Duration.seconds(60)) + yield* Scope.close(scope1, Exit.void) + yield* Pool.get(pool) + yield* Pool.get(pool) + strictEqual(yield* Pool.get(pool), 1) + strictEqual(yield* Ref.get(count), 2) + })) + + it.effect("scale to zero", () => + Effect.gen(function*() { + const deferred = yield* Deferred.make() + const count = yield* Ref.make(0) + const acquire = Effect.acquireRelease( + Ref.updateAndGet(count, (n) => n + 1), + () => Ref.update(count, (n) => n - 1) + ) + const pool = yield* Pool.makeWithTTL({ + acquire, + min: 0, + max: 10, + concurrency: 3, + timeToLive: Duration.seconds(60) + }) + yield* pipe( + Effect.scoped(Effect.andThen( + Pool.get(pool), + Deferred.await(deferred) + )), + Effect.fork, + Effect.repeat({ times: 29 }) + ) + yield* Effect.repeat(Ref.get(count), { until: (n) => n === 10 }) + yield* Deferred.succeed(deferred, void 0) + const max = yield* Ref.get(count) + yield* TestClock.adjust(Duration.seconds(60)) + const min = yield* Ref.get(count) + strictEqual(min, 0) + strictEqual(max, 10) + })) + + it.effect("max pool size creation strategy", () => + Effect.gen(function*() { + const invalidated = yield* Ref.make(0) + const acquire = Effect.acquireRelease( + Effect.succeed("resource"), + () => Ref.update(invalidated, (n) => n + 1) + ) + const pool = yield* Pool.makeWithTTL({ + acquire, + min: 10, + max: 15, + timeToLive: Duration.seconds(60), + timeToLiveStrategy: "creation" + }) + const scope = yield* Scope.make() + yield* Pool.get(pool).pipe( + Effect.repeat({ times: 14 }), + Scope.provide(scope) + ) + const one = yield* Ref.get(invalidated) + yield* TestClock.adjust(Duration.seconds(60)) + const two = yield* Ref.get(invalidated) + yield* Scope.close(scope, Exit.void) + const three = yield* Ref.get(invalidated) + strictEqual(one, 0) + strictEqual(two, 0) + strictEqual(three, 15) + })) + + it.effect("shutdown robustness", () => + Effect.gen(function*() { + const count = yield* Ref.make(0) + const get = Effect.acquireRelease( + Ref.updateAndGet(count, (n) => n + 1), + () => Ref.update(count, (n) => n - 1) + ) + const scope = yield* Scope.make() + const pool = yield* Scope.provide(Pool.make({ acquire: get, size: 10 }), scope) + yield* pipe( + Effect.scoped(Pool.get(pool)), + Effect.fork, + Effect.repeat({ times: 99 }) + ) + yield* Scope.close(scope, Exit.succeed(void 0)) + const result = yield* Effect.repeat(Ref.get(count), { until: (n) => n === 0 }) + strictEqual(result, 0) + })) + + it.effect("shutdown with pending takers", () => + Effect.gen(function*() { + const count = yield* Ref.make(0) + const get = Effect.acquireRelease( + Ref.updateAndGet(count, (n) => n + 1), + () => Ref.update(count, (n) => n - 1) + ) + const scope = yield* Scope.make() + const pool = yield* Scope.provide(Pool.make({ acquire: get, size: 10 }), scope) + yield* pipe( + Pool.get(pool), + Scope.provide(scope), + Effect.fork, + Effect.repeat({ times: 99 }) + ) + yield* Scope.close(scope, Exit.succeed(void 0)) + const result = yield* Effect.repeat(Ref.get(count), { until: (n) => n === 0 }) + strictEqual(result, 0) + })) + + it.effect("get is interruptible", () => + Effect.gen(function*() { + const count = yield* Ref.make(0) + const get = Effect.acquireRelease( + Ref.updateAndGet(count, (n) => n + 1), + () => Ref.update(count, (n) => n - 1) + ) + const fiberId = Fiber.getCurrent()!.id + const pool = yield* Pool.make({ acquire: get, size: 10 }) + yield* Effect.repeat(Pool.get(pool), { times: 9 }) + const fiber = yield* Effect.fork(Pool.get(pool)) + yield* Fiber.interrupt(fiber) + deepStrictEqual(fiber.unsafePoll(), Exit.interrupt(fiberId)) + })) + + it.effect("get is interruptible with dynamic size", () => + Effect.gen(function*() { + const get = Effect.never.pipe(Effect.forkScoped) + const fiberId = Fiber.getCurrent()!.id + const pool = yield* Pool.makeWithTTL({ acquire: get, min: 0, max: 10, timeToLive: Duration.infinity }) + yield* Effect.repeat(Pool.get(pool), { times: 9 }) + const fiber = yield* Effect.fork(Pool.get(pool)) + yield* Fiber.interrupt(fiber) + deepStrictEqual(yield* Fiber.await(fiber), Exit.interrupt(fiberId)) + })) + + it.effect("finalizer is called for failed allocations", () => + Effect.gen(function*() { + const scope = yield* Scope.make() + const allocations = yield* Ref.make(0) + const released = yield* Ref.make(0) + const get = Effect.acquireRelease( + Ref.updateAndGet(allocations, (n) => n + 1), + () => Ref.update(released, (n) => n + 1) + ).pipe( + Effect.andThen(Effect.fail("boom")) + ) + const pool = yield* Pool.make({ acquire: get, size: 10 }).pipe( + Scope.provide(scope) + ) + yield* Effect.scoped(Pool.get(pool)).pipe( + Effect.ignore + ) + strictEqual(yield* Ref.get(allocations), 10) + strictEqual(yield* Ref.get(released), 10) + })) +}) diff --git a/packages/effect/test/Ref.test.ts b/packages/effect/test/Ref.test.ts index 113b6b5c65..1be6227a5d 100644 --- a/packages/effect/test/Ref.test.ts +++ b/packages/effect/test/Ref.test.ts @@ -161,26 +161,27 @@ describe("Ref", () => { it.effect("modifySome - once", () => Effect.gen(function*() { const ref = yield* Ref.make(Active) - const result = yield* Ref.modifySome(ref, "state does not change", (state) => + const result = yield* Ref.modifySome(ref, (state) => isClosed(state) ? - Option.some(["active", Active]) : - Option.none()) + ["active", Option.some(Active)] : + ["state does not change", Option.none()]) assert.strictEqual(result, "state does not change") })) it.effect("modifySome - twice", () => Effect.gen(function*() { const ref = yield* Ref.make(Active) - const result1 = yield* Ref.modifySome(ref, "state does not change", (state) => + const result1 = yield* Ref.modifySome(ref, (state) => isActive(state) ? - Option.some(["changed", Changed]) : - Option.none()) - const result2 = yield* Ref.modifySome(ref, "state does not change", (state) => + ["changed", Option.some(Changed)] : + ["state does not change", Option.none()]) + + const result2 = yield* Ref.modifySome(ref, (state) => isActive(state) ? - Option.some(["changed", Changed]) : + ["changed", Option.some(Changed)] : isChanged(state) ? - Option.some(["closed", Closed]) : - Option.none()) + ["closed", Option.some(Closed)] : + ["state does not change", Option.none()]) assert.strictEqual(result1, "changed") assert.strictEqual(result2, "closed") })) diff --git a/packages/effect/test/ScopedRef.test.ts b/packages/effect/test/ScopedRef.test.ts new file mode 100644 index 0000000000..2e590b9b5a --- /dev/null +++ b/packages/effect/test/ScopedRef.test.ts @@ -0,0 +1,80 @@ +import { describe, it } from "@effect/vitest" +import { strictEqual } from "@effect/vitest/utils" +import { Effect, identity, pipe, ScopedRef } from "effect" +import * as Counter from "./utils/counter.ts" + +describe("ScopedRef", () => { + it.effect("single set", () => + Effect.gen(function*() { + const counter = yield* Counter.make() + const ref = yield* ScopedRef.make(() => 0) + yield* ScopedRef.set(ref, counter.acquire()) + const result = yield* (ScopedRef.get(ref)) + strictEqual(result, 1) + })) + it.effect("dual set", () => + Effect.gen(function*() { + const counter = yield* Counter.make() + const ref = yield* ScopedRef.make(() => 0) + yield* pipe( + ScopedRef.set(ref, counter.acquire()), + Effect.andThen(ScopedRef.set(ref, counter.acquire())) + ) + const result = yield* ScopedRef.get(ref) + strictEqual(result, 2) + })) + it.effect("release on swap", () => + Effect.gen(function*() { + const counter = yield* Counter.make() + const ref = yield* ScopedRef.make(() => 0) + yield* pipe( + ScopedRef.set(ref, counter.acquire()), + Effect.andThen(ScopedRef.set(ref, counter.acquire())) + ) + + const acquired = yield* counter.acquired() + const released = yield* counter.released() + strictEqual(acquired, 2) + strictEqual(released, 1) + })) + it.effect("double release on double swap", () => + Effect.gen(function*() { + const counter = yield* Counter.make() + const ref = yield* ScopedRef.make(() => 0) + yield* ( + pipe( + ScopedRef.set(ref, counter.acquire()), + Effect.andThen(ScopedRef.set(ref, counter.acquire())), + Effect.andThen(ScopedRef.set(ref, counter.acquire())) + ) + ) + const acquired = yield* counter.acquired() + const released = yield* counter.released() + strictEqual(acquired, 3) + strictEqual(released, 2) + })) + it.effect("full release", () => + Effect.gen(function*() { + const counter = yield* Counter.make() + yield* pipe( + ScopedRef.make(() => 0), + Effect.flatMap((ref) => + pipe( + ScopedRef.set(ref, counter.acquire()), + Effect.andThen(ScopedRef.set(ref, counter.acquire())), + Effect.andThen(ScopedRef.set(ref, counter.acquire())) + ) + ), + Effect.scoped + ) + const acquired = yield* counter.acquired() + const released = yield* counter.released() + strictEqual(acquired, 3) + strictEqual(released, 3) + })) + it.effect("full release", () => + Effect.gen(function*() { + const ref = yield* Effect.scoped(ScopedRef.make(() => 0)) + strictEqual(ref.pipe(identity), ref) + })) +}) diff --git a/packages/effect/test/SynchronizedRef.test.ts b/packages/effect/test/SynchronizedRef.test.ts new file mode 100644 index 0000000000..b65614a153 --- /dev/null +++ b/packages/effect/test/SynchronizedRef.test.ts @@ -0,0 +1,105 @@ +import { describe, it } from "@effect/vitest" +import { deepStrictEqual, strictEqual } from "@effect/vitest/utils" +import { Deferred, Effect, Exit, Fiber, pipe, SynchronizedRef } from "effect" + +const current = "value" +const update = "new value" +const failure = "failure" + +type State = Active | Changed | Closed + +interface Active { + readonly _tag: "Active" +} + +interface Changed { + readonly _tag: "Changed" +} + +interface Closed { + readonly _tag: "Closed" +} + +export const Active: State = { _tag: "Active" } +export const Changed: State = { _tag: "Changed" } +export const Closed: State = { _tag: "Closed" } + +const isActive = (self: State): boolean => self._tag === "Active" +const isChanged = (self: State): boolean => self._tag === "Changed" +const isClosed = (self: State): boolean => self._tag === "Closed" + +describe("SynchronizedRef", () => { + it.effect("get", () => + Effect.gen(function*() { + const result = yield* pipe(SynchronizedRef.make(current), Effect.flatMap(SynchronizedRef.get)) + strictEqual(result, current) + })) + it.effect("getAndUpdateEffect - happy path", () => + Effect.gen(function*() { + const ref = yield* SynchronizedRef.make(current) + const result1 = yield* SynchronizedRef.getAndUpdateEffect(ref, () => Effect.succeed(update)) + const result2 = yield* SynchronizedRef.get(ref) + strictEqual(result1, current) + strictEqual(result2, update) + })) + it.effect("getAndUpdateEffect - with failure", () => + Effect.gen(function*() { + const ref = yield* SynchronizedRef.make(current) + const result = yield* pipe(SynchronizedRef.getAndUpdateEffect(ref, (_) => Effect.fail(failure)), Effect.exit) + deepStrictEqual(result, Exit.fail(failure)) + })) + it.effect("getAndUpdateSomeEffect - happy path", () => + Effect.gen(function*() { + const ref = yield* SynchronizedRef.make(Active) + const result1 = yield* (SynchronizedRef.getAndUpdateSomeEffect(ref, (state) => + isClosed(state) ? + Effect.succeedSome(Changed) : + Effect.succeedNone)) + const result2 = yield* SynchronizedRef.get(ref) + deepStrictEqual(result1, Active) + deepStrictEqual(result2, Active) + })) + it.effect("getAndUpdateSomeEffect - twice", () => + Effect.gen(function*() { + const ref = yield* SynchronizedRef.make(Active) + const result1 = yield* SynchronizedRef.getAndUpdateSomeEffect(ref, (state) => + isActive(state) ? + Effect.succeedSome(Changed) : + Effect.succeedNone) + const result2 = yield* SynchronizedRef.getAndUpdateSomeEffect(ref, (state) => + isClosed(state) + ? Effect.succeedSome(Active) + : isChanged(state) + ? Effect.succeedSome(Closed) + : Effect.succeedNone) + const result3 = yield* SynchronizedRef.get(ref) + deepStrictEqual(result1, Active) + deepStrictEqual(result2, Changed) + deepStrictEqual(result3, Closed) + })) + it.effect("getAndUpdateSomeEffect - with failure", () => + Effect.gen(function*() { + const ref = yield* SynchronizedRef.make(Active) + const result = yield* pipe( + SynchronizedRef.getAndUpdateSomeEffect(ref, (state) => + isActive(state) ? + Effect.fail(failure) : + Effect.succeedNone), + Effect.exit + ) + deepStrictEqual(result, Exit.fail(failure)) + })) + it.effect("getAndUpdateSomeEffect - interrupt parent fiber and update", () => + Effect.gen(function*() { + const deferred = yield* Deferred.make>() + const latch = yield* Deferred.make() + const makeAndWait = Deferred.complete(deferred, SynchronizedRef.make(Active)).pipe( + Effect.andThen(Deferred.await(latch)) + ) + const fiber = yield* Effect.fork(makeAndWait) + const ref = yield* Deferred.await(deferred) + yield* Fiber.interrupt(fiber) + const result = yield* SynchronizedRef.updateAndGetEffect(ref, (_) => Effect.succeed(Closed)) + deepStrictEqual(result, Closed) + })) +}) diff --git a/packages/effect/test/cluster/Entity.test.ts b/packages/effect/test/cluster/Entity.test.ts new file mode 100644 index 0000000000..4ef564552b --- /dev/null +++ b/packages/effect/test/cluster/Entity.test.ts @@ -0,0 +1,24 @@ +import { assert, describe, it } from "@effect/vitest" +import { Effect } from "effect" +import { Entity, ShardingConfig } from "effect/unstable/cluster" +import { TestEntity, TestEntityLayer, User } from "./TestEntity.js" + +describe.concurrent("Entity", () => { + describe("makeTestClient", () => { + it.effect("round trip", () => + Effect.gen(function*() { + const makeClient = yield* Entity.makeTestClient(TestEntity, TestEntityLayer) + const client = yield* makeClient("123") + const user = yield* client.GetUser({ id: 1 }) + assert.deepEqual(user, new User({ id: 1, name: "User 1" })) + }).pipe(Effect.provide(TestShardingConfig))) + }) +}) + +const TestShardingConfig = ShardingConfig.layer({ + shardsPerGroup: 300, + entityMailboxCapacity: 10, + entityTerminationTimeout: 0, + entityMessagePollInterval: 5000, + sendRetryInterval: 100 +}) diff --git a/packages/effect/test/cluster/MessageStorage.test.ts b/packages/effect/test/cluster/MessageStorage.test.ts new file mode 100644 index 0000000000..e054da1822 --- /dev/null +++ b/packages/effect/test/cluster/MessageStorage.test.ts @@ -0,0 +1,197 @@ +import { describe, expect, it } from "@effect/vitest" +import { Effect, Exit, Layer, ServiceMap } from "effect" +import { Option } from "effect/data" +import { Schema } from "effect/schema" +import { + EntityAddress, + EntityId, + EntityType, + Envelope, + Message, + MessageStorage, + Reply, + ShardId, + ShardingConfig, + Snowflake +} from "effect/unstable/cluster" +import { Headers } from "effect/unstable/http" +import { Rpc, RpcSchema } from "effect/unstable/rpc" + +const MemoryLive = MessageStorage.layerMemory.pipe( + Layer.provideMerge(Snowflake.layerGenerator), + Layer.provide(ShardingConfig.layerDefaults) +) + +describe("MessageStorage", () => { + describe("memory", () => { + it.effect("saves a request", () => + Effect.gen(function*() { + const storage = yield* MessageStorage.MessageStorage + const request = yield* makeRequest() + const result = yield* storage.saveRequest(request) + expect(result._tag).toEqual("Success") + const messages = yield* storage.unprocessedMessages([request.envelope.address.shardId]) + expect(messages).toHaveLength(1) + }).pipe(Effect.provide(MemoryLive))) + + it.effect("detects duplicates", () => + Effect.gen(function*() { + const storage = yield* MessageStorage.MessageStorage + yield* storage.saveRequest( + yield* makeRequest({ + rpc: PrimaryKeyTest, + payload: PrimaryKeyTest.payloadSchema.makeSync({ id: 123 }) + }) + ) + const result = yield* storage.saveRequest( + yield* makeRequest({ + rpc: PrimaryKeyTest, + payload: PrimaryKeyTest.payloadSchema.makeSync({ id: 123 }) + }) + ) + expect(result._tag).toEqual("Duplicate") + }).pipe(Effect.provide(MemoryLive))) + + it.effect("unprocessedMessages excludes complete requests", () => + Effect.gen(function*() { + const storage = yield* MessageStorage.MessageStorage + const request = yield* makeRequest() + yield* storage.saveRequest(request) + yield* storage.saveReply(yield* makeReply(request)) + const messages = yield* storage.unprocessedMessages([request.envelope.address.shardId]) + expect(messages).toHaveLength(0) + }).pipe(Effect.provide(MemoryLive))) + + it.effect("repliesFor", () => + Effect.gen(function*() { + const storage = yield* MessageStorage.MessageStorage + const request = yield* makeRequest() + yield* storage.saveRequest(request) + let replies = yield* storage.repliesFor([request]) + expect(replies).toHaveLength(0) + yield* storage.saveReply(yield* makeReply(request)) + replies = yield* storage.repliesFor([request]) + expect(replies).toHaveLength(1) + expect(replies[0].requestId).toEqual(request.envelope.requestId) + }).pipe(Effect.provide(MemoryLive))) + + it.effect("registerReplyHandler", () => + Effect.gen(function*() { + const storage = yield* MessageStorage.MessageStorage + const latch = yield* Effect.makeLatch() + const request = yield* makeRequest() + yield* storage.saveRequest(request) + yield* storage.registerReplyHandler( + new Message.OutgoingRequest({ + ...request, + respond: () => latch.open + }) + ) + yield* storage.saveReply(yield* makeReply(request)) + yield* latch.await + }).pipe(Effect.provide(MemoryLive))) + }) +}) + +export const GetUserRpc = Rpc.make("GetUser", { + payload: { id: Schema.Number } +}) + +export const makeRequest = Effect.fnUntraced(function*(options?: { + readonly rpc?: Rpc.AnyWithProps + readonly payload?: any +}) { + const snowflake = yield* Snowflake.Generator + const rpc = options?.rpc ?? GetUserRpc + return new Message.OutgoingRequest({ + envelope: Envelope.makeRequest({ + requestId: snowflake.unsafeNext(), + address: EntityAddress.make({ + shardId: ShardId.make("default", 1), + entityType: EntityType.make("test"), + entityId: EntityId.make("1") + }), + tag: rpc._tag, + payload: options?.payload ?? { id: 123 }, + traceId: "noop", + spanId: "noop", + sampled: false, + headers: Headers.empty + }), + services: ServiceMap.empty() as any, + rpc, + lastReceivedReply: Option.none(), + respond() { + return Effect.void + } + }) +}) + +export class PrimaryKeyTest extends Rpc.make("PrimaryKeyTest", { + payload: { + id: Schema.Number + }, + primaryKey: (value) => value.id.toString() +}) {} + +export class StreamRpc extends Rpc.make("StreamTest", { + success: RpcSchema.Stream({ + success: Schema.Void, + error: Schema.Never + }), + payload: { + id: Schema.Number + }, + primaryKey: (value) => value.id.toString() +}) {} + +export const makeReply = Effect.fnUntraced(function*(request: Message.OutgoingRequest) { + const snowflake = yield* Snowflake.Generator + return new Reply.ReplyWithContext({ + reply: new Reply.WithExit({ + id: snowflake.unsafeNext(), + requestId: request.envelope.requestId, + exit: Exit.void as any + }), + services: request.services, + rpc: request.rpc + }) +}) + +export const makeAckChunk = Effect.fnUntraced(function*( + request: Message.OutgoingRequest, + chunk: Reply.ReplyWithContext +) { + const snowflake = yield* Snowflake.Generator + return new Message.OutgoingEnvelope({ + envelope: new Envelope.AckChunk({ + id: snowflake.unsafeNext(), + address: request.envelope.address, + requestId: chunk.reply.requestId, + replyId: chunk.reply.id + }), + rpc: request.rpc + }) +}) + +export const makeChunkReply = Effect.fnUntraced(function*(request: Message.OutgoingRequest, sequence = 0) { + const snowflake = yield* Snowflake.Generator + return new Reply.ReplyWithContext({ + reply: new Reply.Chunk({ + id: snowflake.unsafeNext(), + requestId: request.envelope.requestId, + sequence, + values: [undefined] + }), + services: request.services, + rpc: request.rpc + }) +}) + +export const makeEmptyReply = (request: Message.OutgoingRequest) => { + return new Reply.ReplyWithContext({ + reply: Reply.Chunk.emptyFrom(request.envelope.requestId), + services: request.services, + rpc: request.rpc + }) +} diff --git a/packages/effect/test/cluster/ShardManager.bench.ts b/packages/effect/test/cluster/ShardManager.bench.ts new file mode 100644 index 0000000000..7133ac91ed --- /dev/null +++ b/packages/effect/test/cluster/ShardManager.bench.ts @@ -0,0 +1,151 @@ +import { bench, describe, expect } from "@effect/vitest" +import { Effect, Layer } from "effect" +import { Array, MutableHashMap } from "effect/collections" +import { Data, Option } from "effect/data" +import { Logger } from "effect/logging" +import { TestClock, TestConsole } from "effect/testing" +import { + MessageStorage, + Runner, + RunnerAddress, + RunnerHealth, + Runners, + ShardingConfig, + ShardManager, + ShardStorage +} from "effect/unstable/cluster" +import { decideAssignmentsForShards, RunnerWithMetadata, State } from "effect/unstable/cluster/internal/shardManager" + +describe("ShardManager", () => { + const shards300 = Array.makeBy( + 300, + (i) => [i + 1, Option.none()] as const + ) + const state30 = makeDefaultState( + MutableHashMap.fromIterable(Array.makeBy(30, (i) => { + const address = RunnerAddress.make(`${i}`, i) + const meta = RunnerWithMetadata({ + runner: Runner.make({ address, groups: ["default"], version: 1 }), + registeredAt: Date.now() + }) + return [address, meta] as const + })), + new Map(shards300) + ) + + const shards1000 = Array.makeBy( + 1000, + (i) => [i + 1, Option.none()] as const + ) + const state100 = makeDefaultState( + MutableHashMap.fromIterable(Array.makeBy(100, (i) => { + const address = RunnerAddress.make(`${i}`, i) + const meta = RunnerWithMetadata({ + runner: Runner.make({ address, groups: ["default"], version: 1 }), + registeredAt: Date.now() + }) + return [address, meta] as const + })), + new Map(shards1000) + ) + + bench("decideAssignmentsForShards - 30 runners 300 shards", () => { + decideAssignmentsForShards(state30, "default") + }) + + bench("decideAssignmentsForShards - 100 runners 1000 shards", () => { + decideAssignmentsForShards(state100, "default") + }) + + const ShardManagerLive = ShardManager.layer.pipe( + Layer.provide(ShardManager.layerConfig({ + rebalanceDebounce: 0 + })) + ) + const RunnerHealthLive = RunnerHealth.layer.pipe( + Layer.provideMerge(Runners.layerNoop) + ) + const TestLive = ShardManagerLive.pipe( + Layer.provideMerge(Layer.mergeAll( + ShardStorage.layerNoop, + RunnerHealthLive + )), + Layer.provide(ShardingConfig.layer()), + Layer.provide(MessageStorage.layerNoop), + Layer.provideMerge(Layer.mergeAll( + TestConsole.layer, + TestClock.layer() + )), + Layer.provideMerge(Logger.layer([])) + ) + + bench("ShardManager - 50 runners up & down", () => + Effect.gen(function*() { + const manager = yield* ShardManager.ShardManager + + yield* simulate(Array.range(1, 50).map(registerRunner)) + yield* TestClock.adjust("20 seconds") + + const assignments = yield* manager.getAssignments + const values = globalThis.Array.from(assignments, ([, address]) => address) + const allRunnersAssigned = Array.every(values, Option.isSome) + expect(allRunnersAssigned).toBe(true) + + yield* simulate(Array.range(1, 50).map(unregisterRunner)) + yield* TestClock.adjust("1 second") + + const assignments2 = yield* manager.getAssignments + const values2 = globalThis.Array.from(assignments2, ([, address]) => address) + const allRunnersUnassigned = Array.every(values2, Option.isNone) + expect(allRunnersUnassigned).toBe(true) + }).pipe( + Effect.provide(TestLive), + Effect.runPromise + )) +}) + +function registerRunner(n: number) { + const runner = Runner.make({ + address: RunnerAddress.make("server", n), + groups: ["default"], + version: 1 + }) + return SimulationEvent.RegisterRunner({ runner }) +} +function unregisterRunner(n: number) { + const address = RunnerAddress.make("server", n) + return SimulationEvent.UnregisterRunner({ address }) +} + +type SimulationEvent = Data.TaggedEnum<{ + readonly RegisterRunner: { readonly runner: Runner.Runner } + readonly UnregisterRunner: { readonly address: RunnerAddress.RunnerAddress } +}> +const SimulationEvent = Data.taggedEnum() + +const handleEvent = SimulationEvent.$match({ + RegisterRunner: ({ runner }) => + ShardManager.ShardManager.asEffect().pipe( + Effect.flatMap((manager) => manager.register(runner)), + Effect.asVoid + ), + UnregisterRunner: ({ address }) => + ShardManager.ShardManager.asEffect().pipe( + Effect.flatMap((manager) => manager.unregister(address)) + ) +}) + +function simulate(events: ReadonlyArray) { + return Effect.forEach(events, handleEvent, { discard: true }) +} + +const makeDefaultState = ( + runners: MutableHashMap.MutableHashMap, + shards: Map> +) => + new State( + runners, + new Map([["default", runners]]), + new Map([["default", shards]]), + shards.size + ) diff --git a/packages/effect/test/cluster/ShardManager.test.ts b/packages/effect/test/cluster/ShardManager.test.ts new file mode 100644 index 0000000000..a204329038 --- /dev/null +++ b/packages/effect/test/cluster/ShardManager.test.ts @@ -0,0 +1,365 @@ +import { describe, expect, it } from "@effect/vitest" +import { Effect, Fiber, Layer, pipe } from "effect" +import { Array, Iterable, MutableHashMap } from "effect/collections" +import { Data, Option } from "effect/data" +import { Logger } from "effect/logging" +import { TestClock } from "effect/testing" +import type { ShardId } from "effect/unstable/cluster" +import { + MessageStorage, + Runner, + RunnerAddress, + RunnerHealth, + Runners, + ShardingConfig, + ShardManager, + ShardStorage +} from "effect/unstable/cluster" +import { decideAssignmentsForShards, RunnerWithMetadata, State } from "effect/unstable/cluster/internal/shardManager" + +const runner1 = RunnerWithMetadata({ + runner: Runner.make({ address: RunnerAddress.make("1", 1), groups: ["default"], version: 1 }), + registeredAt: Number.MIN_SAFE_INTEGER +}) +const runner2 = RunnerWithMetadata({ + runner: Runner.make({ address: RunnerAddress.make("2", 2), groups: ["default", "custom"], version: 1 }), + registeredAt: Number.MIN_SAFE_INTEGER +}) +const runner3 = RunnerWithMetadata({ + runner: Runner.make({ address: RunnerAddress.make("3", 3), groups: ["default", "custom"], version: 1 }), + registeredAt: Number.MIN_SAFE_INTEGER +}) + +describe("ShardManager", () => { + describe("Rebalancing", () => { + it("should rebalance unbalanced assignments", () => { + const state = makeDefaultState( + MutableHashMap.make( + [runner1.runner.address, runner1], + [runner2.runner.address, runner2] + ), + new Map([ + [1, Option.some(runner1.runner.address)], + [2, Option.some(runner1.runner.address)] + ]) + ) + const [assignments, unassignments] = decideAssignmentsForShards(state, "default") + expect(MutableHashMap.has(assignments, runner2.runner.address)).toBe(true) + expect(MutableHashMap.size(assignments)).toBe(1) + expect(MutableHashMap.has(unassignments, runner1.runner.address)).toBe(true) + expect(MutableHashMap.size(unassignments)).toBe(1) + }) + + it("should not rebalance to runners with an older version", () => { + const oldRunner2 = RunnerWithMetadata({ + runner: Runner.make({ address: runner2.runner.address, groups: ["default"], version: 0 }), + registeredAt: runner2.registeredAt + }) + const state = makeDefaultState( + MutableHashMap.make( + [runner1.runner.address, runner1], + [runner2.runner.address, oldRunner2] + ), + new Map([ + [1, Option.some(runner1.runner.address)], + [2, Option.some(runner1.runner.address)] + ]) + ) + const [assignments, unassignments] = decideAssignmentsForShards(state, "default") + expect(MutableHashMap.size(assignments) === 0).toBe(true) + expect(MutableHashMap.size(unassignments) === 0).toBe(true) + }) + + it("should not rebalance when already well-balanced", () => { + const state = makeDefaultState( + MutableHashMap.make( + [runner1.runner.address, runner1], + [runner2.runner.address, runner2] + ), + new Map([ + [1, Option.some(runner1.runner.address)], + [2, Option.some(runner2.runner.address)] + ]) + ) + const [assignments, unassignments] = decideAssignmentsForShards(state, "default") + expect(MutableHashMap.isEmpty(assignments)).toBe(true) + expect(MutableHashMap.isEmpty(unassignments)).toBe(true) + }) + + it("should not rebalance when there is only a one-shard difference", () => { + const state = makeDefaultState( + MutableHashMap.make( + [runner1.runner.address, runner1], + [runner2.runner.address, runner2] + ), + new Map([ + [1, Option.some(runner1.runner.address)], + [2, Option.some(runner1.runner.address)], + [3, Option.some(runner2.runner.address)] + ]) + ) + const [assignments, unassignments] = decideAssignmentsForShards(state, "default") + expect(MutableHashMap.isEmpty(assignments)).toBe(true) + expect(MutableHashMap.isEmpty(unassignments)).toBe(true) + }) + + it("should rebalance when there is more than a one-shard difference", () => { + const state = makeDefaultState( + MutableHashMap.make( + [runner1.runner.address, runner1], + [runner2.runner.address, runner2] + ), + new Map([ + [1, Option.some(runner1.runner.address)], + [2, Option.some(runner1.runner.address)], + [3, Option.some(runner1.runner.address)], + [4, Option.some(runner2.runner.address)] + ]) + ) + const [assignments, unassignments] = decideAssignmentsForShards(state, "default") + expect(MutableHashMap.has(assignments, runner2.runner.address)).toBe(true) + expect(MutableHashMap.size(assignments)).toBe(1) + expect(MutableHashMap.has(unassignments, runner1.runner.address)).toBe(true) + expect(MutableHashMap.size(unassignments)).toBe(1) + }) + + it("should pick the runner with less shards", () => { + const state = makeDefaultState( + MutableHashMap.make( + [runner1.runner.address, runner1], + [runner2.runner.address, runner2], + [runner3.runner.address, runner3] + ), + new Map([ + [1, Option.some(runner1.runner.address)], + [2, Option.some(runner1.runner.address)], + [3, Option.some(runner2.runner.address)] + ]) + ) + const [assignments, unassignments] = decideAssignmentsForShards(state, "default") + expect(MutableHashMap.has(assignments, runner3.runner.address)).toBe(true) + expect(MutableHashMap.size(assignments)).toBe(1) + expect(MutableHashMap.has(unassignments, runner1.runner.address)).toBe(true) + expect(MutableHashMap.size(unassignments)).toBe(1) + }) + + it("should not rebalance if there are no runners", () => { + const state = makeDefaultState( + MutableHashMap.empty(), + new Map([ + [1, Option.some(runner1.runner.address)] + ]) + ) + const [assignments, unassignments] = decideAssignmentsForShards(state, "default") + expect(MutableHashMap.isEmpty(assignments)).toBe(true) + expect(MutableHashMap.isEmpty(unassignments)).toBe(true) + }) + }) + + describe.concurrent("Simulation", () => { + const ShardManagerLive = ShardManager.layer.pipe( + Layer.provide(ShardManager.layerConfig({ + rebalanceDebounce: 500, + rebalanceInterval: "20 seconds" + })) + ) + const RunnerHealthLive = RunnerHealth.layer.pipe( + Layer.provideMerge(Runners.layerNoop) + ) + const TestLive = ShardManagerLive.pipe( + Layer.provideMerge(Layer.mergeAll( + ShardStorage.layerNoop, + RunnerHealthLive + )), + Layer.provide([ + MessageStorage.layerNoop, + ShardingConfig.layer({ + shardGroups: ["custom"] + }) + ]), + Layer.provide(Logger.layer([Logger.consolePretty()])) + ) + + it.effect("should successfully scale up", () => + Effect.gen(function*() { + const manager = yield* ShardManager.ShardManager + + // Setup 20 runners first + yield* simulate(Array.range(1, 20).map(registerRunner)) + + // Check that all runners are assigned and have 15 shards each + const assignments = yield* manager.getAssignments + const values = globalThis.Array.from(assignments, ([, address]) => address) + const allRunnersAssigned = Array.every(values, Option.isSome) + expect(allRunnersAssigned).toBe(true) + let shardsPerRunner = getShardsPerRunner(assignments, "default") + expect(shardsPerRunner.every((shards) => shards.length === 15)).toBe(true) + shardsPerRunner = getShardsPerRunner(assignments, "custom") + expect(shardsPerRunner.every((shards) => shards.length === 30)).toBe(true) + + // Setup another 5 runners + yield* simulate(Array.range(21, 25).map(registerRunner)) + yield* TestClock.adjust("20 seconds") + + // Check that each of the new runners received 6 shards + const assignments2 = yield* manager.getAssignments.pipe( + Effect.map(Iterable.filter(([shardId, address]) => + shardId.group === "default" && Option.isSome(address) && address.value.port > 20 + )) + ) + const shardsPerRunner2 = getShardsPerRunner(assignments2, "default") + expect(shardsPerRunner2.every((shards) => + shards.length === 12 + )).toBe(true) + }).pipe(Effect.provide(TestLive)), 10_000) + + it.effect("should succcessfully scale down", () => + Effect.gen(function*() { + const manager = yield* ShardManager.ShardManager + + // Setup 25 runners + yield* simulate(Array.range(1, 25).map(registerRunner)) + + // Check that all runners are assigned and have 12 shards each + const assignments = yield* manager.getAssignments + const values = globalThis.Array.from(assignments, ([, address]) => address) + const allRunnersAssigned = Array.every(values, Option.isSome) + expect(allRunnersAssigned).toBe(true) + let shardsPerRunner = getShardsPerRunner(assignments, "default") + expect(shardsPerRunner.every((shards) => shards.length === 12)).toBe(true) + shardsPerRunner = getShardsPerRunner(assignments, "custom") + expect(shardsPerRunner.every((shards) => shards.length === 25)).toBe(true) + + // Remove 5 runners + yield* simulate(Array.range(21, 25).map(unregisterRunner)) + yield* TestClock.adjust("1 second") + + // Check that all shards have already been rebalanced + const assignments2 = yield* manager.getAssignments + const allRunnersUnassigned = pipe( + Array.fromIterable(assignments2), + Array.every(([, address]) => Option.isSome(address) && address.value.port <= 20) + ) + expect(allRunnersUnassigned).toBe(true) + const shardsPerRunner2 = getShardsPerRunner(assignments2, "default") + expect(shardsPerRunner2.every((shards) => shards.length === 15)).toBe(true) + }).pipe(Effect.provide(TestLive)), 10_000) + + it.effect("should save state to storage when restarted", () => + Effect.gen(function*() { + const setup = Effect.gen(function*() { + const storage = yield* ShardStorage.ShardStorage + + yield* simulate(Array.range(1, 10).map(registerRunner)) + yield* TestClock.adjust("20 seconds") + + // Wait for the forked daemon fibers to do their work + yield* storage.getAssignments.pipe( + Effect.repeat({ + while: Array.isEmptyArray + }) + ) + yield* storage.getRunners.pipe( + Effect.repeat({ + while: Array.isEmptyArray + }) + ) + // Simulate a non-persistent storage restart + yield* storage.saveAssignments([]) + yield* storage.saveRunners([]) + }).pipe( + Effect.provide( + ShardManagerLive.pipe( + Layer.provide(RunnerHealthLive), + Layer.provide([MessageStorage.layerNoop, ShardingConfig.layer()]) + ) + ) + ) + + const test = Effect.gen(function*() { + const storage = yield* ShardStorage.ShardStorage + const shutdownAssignments = yield* storage.getAssignments + const shutdownRunners = yield* storage.getRunners + // ShardManager should have saved its state to persistent storage + // as part of shutdown procedures + expect(shutdownAssignments.length === 0).toBe(false) + expect(Array.isEmptyArray(shutdownRunners)).toBe(false) + }) + + yield* setup + yield* test + }).pipe(Effect.provide(ShardStorage.layerMemory)), 10_000) + }) +}) + +function registerRunner(n: number) { + const runner = Runner.make({ + address: RunnerAddress.make("server", n), + groups: n % 2 === 0 ? ["default", "custom"] : ["default"], + version: 1 + }) + return SimulationEvent.RegisterRunner({ runner }) +} +function unregisterRunner(n: number) { + const address = RunnerAddress.make("server", n) + return SimulationEvent.UnregisterRunner({ address }) +} + +function getShardsPerRunner( + assignments: Iterable]>, + group: string +) { + const shardsPerRunner = MutableHashMap.empty>() + for (const [shard, address] of assignments) { + if (shard.group !== group || Option.isNone(address)) continue + MutableHashMap.modifyAt( + shardsPerRunner, + address.value, + Option.match({ + onNone: () => Option.some(Array.of(shard.id)), + onSome: (shards) => Option.some(Array.append(shards, shard.id)) + }) + ) + } + return Array.fromIterable(MutableHashMap.values(shardsPerRunner)) +} + +type SimulationEvent = Data.TaggedEnum<{ + readonly RegisterRunner: { readonly runner: Runner.Runner } + readonly UnregisterRunner: { readonly address: RunnerAddress.RunnerAddress } +}> +const SimulationEvent = Data.taggedEnum() + +const handleEvent = SimulationEvent.$match({ + RegisterRunner: ({ runner }) => + ShardManager.ShardManager.asEffect().pipe( + Effect.flatMap((manager) => manager.register(runner)), + Effect.asVoid + ), + UnregisterRunner: ({ address }) => + ShardManager.ShardManager.asEffect().pipe( + Effect.flatMap((manager) => manager.unregister(address)) + ) +}) + +const simulate = Effect.fnUntraced(function*(events: ReadonlyArray) { + const fiber = yield* Effect.forEach(events, handleEvent, { concurrency: events.length, discard: true }).pipe( + Effect.fork + ) + yield* TestClock.adjust(1) + // Wait for shard manager to debounce rebalancing + yield* TestClock.adjust(500) + yield* TestClock.adjust(500) + yield* Fiber.join(fiber) +}) + +const makeDefaultState = ( + runners: MutableHashMap.MutableHashMap, + shards: Map> +) => + new State( + runners, + new Map([["default", runners]]), + new Map([["default", shards]]), + shards.size + ) diff --git a/packages/effect/test/cluster/Sharding.test.ts b/packages/effect/test/cluster/Sharding.test.ts new file mode 100644 index 0000000000..112869bc1a --- /dev/null +++ b/packages/effect/test/cluster/Sharding.test.ts @@ -0,0 +1,556 @@ +import { assert, describe, expect, it } from "@effect/vitest" +import { Cause, Effect, Exit, Fiber, Layer, MutableRef, Queue } from "effect" +import { Array } from "effect/collections" +import { Option } from "effect/data" +import { Stream } from "effect/stream" +import { TestClock } from "effect/testing" +import { Clock } from "effect/time" +import { + MessageStorage, + RunnerAddress, + Runners, + Sharding, + ShardingConfig, + ShardManager, + ShardStorage, + Snowflake +} from "effect/unstable/cluster" +import { TestEntity, TestEntityNoState, TestEntityState, User } from "./TestEntity.js" + +describe.concurrent("Sharding", () => { + it.effect("delivers a message", () => + Effect.gen(function*() { + yield* TestClock.adjust(2000) + const makeClient = yield* TestEntity.client + const client = makeClient("1") + const user = yield* client.GetUserVolatile({ id: 1 }) + expect(user).toEqual(new User({ id: 1, name: "User 1" })) + }).pipe(Effect.provide(TestSharding))) + + it.effect("delivers a message via storage", () => + Effect.gen(function*() { + yield* TestClock.adjust(2000) + const driver = yield* MessageStorage.MemoryDriver + const makeClient = yield* TestEntity.client + const client = makeClient("1") + const user = yield* client.GetUser({ id: 1 }) + expect(user).toEqual(new User({ id: 1, name: "User 1" })) + expect(driver.journal.length).toEqual(1) + expect(driver.unprocessed.size).toEqual(0) + }).pipe(Effect.provide(TestSharding))) + + it.effect("interrupts", () => + Effect.gen(function*() { + const driver = yield* MessageStorage.MemoryDriver + const state = yield* TestEntityState + const makeClient = yield* TestEntity.client + yield* TestClock.adjust(2000) + const client = makeClient("1") + + const fiber = yield* client.Never().pipe(Effect.fork({ startImmediately: true })) + yield* Fiber.interrupt(fiber) + + yield* TestClock.adjust(2000) + expect(driver.journal.length).toEqual(2) + expect(driver.replyIds.size).toEqual(1) + expect(Queue.unsafeSize(state.interrupts)).toEqual(1) + }).pipe(Effect.provide(TestSharding))) + + it.effect("interrupts aren't sent for durable messages on shutdown", () => + Effect.gen(function*() { + let driver!: MessageStorage.MemoryDriver["Service"] + yield* Effect.gen(function*() { + driver = yield* MessageStorage.MemoryDriver + const makeClient = yield* TestEntity.client + yield* TestClock.adjust(2000) + const client = makeClient("1") + yield* client.Never().pipe(Effect.fork) + yield* TestClock.adjust(1) + }).pipe(Effect.provide(TestSharding)) + + // request, client interrupt is dropped + expect(driver.journal.length).toEqual(1) + // server interrupt is not sent + expect(driver.replyIds.size).toEqual(0) + })) + + it.effect("interrupts are sent for volatile messages on shutdown", () => + Effect.gen(function*() { + let interrupted = false + const testClock = (yield* Clock.Clock) as TestClock.TestClock + + yield* Effect.gen(function*() { + const makeClient = yield* TestEntity.client + yield* TestClock.adjust(2000) + const client = makeClient("1") + const fiber = yield* client.NeverVolatile().pipe(Effect.fork) + yield* TestClock.adjust(1) + const config = yield* ShardingConfig.ShardingConfig + ;(config as any).runnerAddress = Option.some(RunnerAddress.make("localhost", 1234)) + setTimeout(() => { + fiber.unsafeInterrupt() + Effect.runFork(testClock.adjust(30000)) + }, 0) + }).pipe( + Effect.provide(TestShardingWithoutRunners.pipe( + Layer.provide( + Layer.effect(Runners.Runners)( + Effect.gen(function*() { + const runners = yield* Runners.makeNoop + return { + ...runners, + send(options) { + if (options.message.envelope._tag === "Interrupt") { + interrupted = true + return Effect.void + } + return runners.send(options) + } + } + }) + ) + ), + Layer.provide([MessageStorage.layerMemory, Snowflake.layerGenerator]), + Layer.provideMerge(ShardingConfig.layer({ + entityMailboxCapacity: 10, + entityTerminationTimeout: 30000, + entityMessagePollInterval: 5000, + sendRetryInterval: 100 + })) + )) + ) + + assert.isTrue(interrupted) + })) + + it.effect("malformed message in storage", () => + Effect.gen(function*() { + const driver = yield* MessageStorage.MemoryDriver + const makeClient = yield* TestEntity.client + yield* TestClock.adjust(2000) + const client = makeClient("1") + + const fiber = yield* client.Never().pipe(Effect.fork) + yield* TestClock.adjust(1) + + const request = driver.journal[0] + yield* driver.encoded.saveEnvelope({ + envelope: { + id: "boom", + _tag: "Interrupt", + requestId: request.requestId, + address: { + shardId: request.address.shardId + } as any + }, + primaryKey: null, + deliverAt: null + }) + + // wait for storage to poll + yield* TestClock.adjust(5000) + + const exit = fiber.unsafePoll() + assert(exit && Exit.isFailure(exit) && Cause.hasDie(exit.cause)) + + // malformed message should be left in the database + expect(driver.journal.length).toEqual(2) + // defect reply should be sent + expect(driver.replyIds.size).toEqual(1) + + const reply = driver.requests.get(request.requestId)!.replies[0] + assert(reply._tag === "WithExit" && reply.exit._tag === "Failure" && reply.exit.cause[0]._tag === "Die") + }).pipe(Effect.provide(TestSharding))) + + it.effect("MailboxFull for volatile messages", () => + Effect.gen(function*() { + const makeClient = yield* TestEntity.client + yield* TestClock.adjust(2000) + const client = makeClient("1") + + yield* client.NeverVolatile().pipe(Effect.fork, Effect.replicateEffect(10)) + yield* TestClock.adjust(1) + const error = yield* client.NeverVolatile().pipe(Effect.flip) + assert.strictEqual(error._tag, "MailboxFull") + }).pipe(Effect.provide(TestSharding))) + + it.effect("durable messages are retried when mailbox is full", () => + Effect.gen(function*() { + const requestedIds = yield* Queue.make>() + yield* Effect.gen(function*() { + const state = yield* TestEntityState + const makeClient = yield* TestEntity.client + yield* TestClock.adjust(2000) + const client = makeClient("1") + + const fibers = yield* client.NeverFork().pipe(Effect.fork, Effect.replicateEffect(11)) + yield* TestClock.adjust(1) + + // wait for entity to go into resume mode and request ids + const ids = yield* Queue.take(requestedIds) + assert.strictEqual(ids.length, 1) + + // test entity should still only have 10 requests + assert.deepStrictEqual(Queue.unsafeSize(state.envelopes), 10) + + // interrupt first request + yield* Fiber.interrupt(fibers[0]) + yield* TestClock.adjust(100) // let retry happen + + // last request should come through + assert.deepStrictEqual(Queue.unsafeSize(state.envelopes), 11) + + // interrupt second request, now the entity should be back in the main storage loop + yield* Fiber.interrupt(fibers[1]) + + // send another request within mailbox capacity + yield* client.NeverFork().pipe(Effect.fork) + yield* TestClock.adjust(1) + yield* Fiber.interruptAll(fibers) + yield* TestClock.adjust(100) + + // no more ids should have been requested from entity catch up + assert.deepStrictEqual(Queue.unsafeSize(requestedIds), 0) + }).pipe(Effect.provide(TestShardingWithoutStorage.pipe( + Layer.updateService(MessageStorage.MessageStorage, (storage) => ({ + ...storage, + unprocessedMessagesById(messageIds) { + Queue.unsafeOffer(requestedIds, Array.fromIterable(messageIds)) + return storage.unprocessedMessagesById(messageIds) + } + })), + Layer.provide(MessageStorage.layerMemory), + Layer.provide(TestShardingConfig) + ))) + })) + + it.effect("interrupt for future request works while mailbox is full", () => + Effect.gen(function*() { + const state = yield* TestEntityState + const makeClient = yield* TestEntity.client + yield* TestClock.adjust(2000) + const client = makeClient("1") + + const fibers = yield* client.NeverFork().pipe( + Effect.fork({ startImmediately: true }), + Effect.replicateEffect(12) + ) + yield* TestClock.adjust(1) + + assert.deepStrictEqual(Queue.unsafeSize(state.envelopes), 10) + + // interrupt 11th request + yield* Fiber.interrupt(fibers[10]) + yield* TestClock.adjust(100) // let retry happen + // interrupt first request, and let the 11th request come through + yield* Fiber.interrupt(fibers[0]) + yield* TestClock.adjust(100) // let retry happen + + assert.deepStrictEqual(Queue.unsafeSize(state.envelopes), 12) + // second interrupt should be sent + assert.deepStrictEqual(Queue.unsafeSize(state.interrupts), 2) + }).pipe(Effect.provide(TestSharding))) + + it.effect("delivers a durable stream", () => + Effect.gen(function*() { + const driver = yield* MessageStorage.MemoryDriver + yield* TestClock.adjust(2000) + const makeClient = yield* TestEntity.client + const client = makeClient("1") + const users = yield* client.GetAllUsers({ ids: [1, 2, 3] }).pipe( + Stream.runCollect + ) + expect(users).toEqual([ + new User({ id: 1, name: "User 1" }), + new User({ id: 2, name: "User 2" }), + new User({ id: 3, name: "User 3" }) + ]) + + // 1 request, 3 acks, 4 replies + expect(driver.journal.length).toEqual(4) + expect(driver.replyIds.size).toEqual(4) + }).pipe(Effect.provide(TestSharding))) + + it.effect("durable stream while mailbox is full", () => + Effect.gen(function*() { + const requestedIds = yield* Queue.make>() + yield* Effect.gen(function*() { + const state = yield* TestEntityState + const makeClient = yield* TestEntity.client + yield* TestClock.adjust(2000) + const client = makeClient("1") + + const fibers = yield* client.NeverFork().pipe(Effect.fork, Effect.replicateEffect(10)) + yield* TestClock.adjust(1) + + const fiber = yield* client.GetAllUsers({ ids: [1, 2, 3] }).pipe( + Stream.runCollect, + Effect.fork + ) + + // wait for entity to go into resume mode and request ids + const ids = yield* Queue.take(requestedIds) + assert.strictEqual(ids.length, 1) + assert.deepStrictEqual(Queue.unsafeSize(state.envelopes), 10) + + // make sure entity doesn't leave resume mode + yield* client.NeverFork().pipe(Effect.fork) + yield* TestClock.adjust(1) + + // interrupt first request + yield* Fiber.interrupt(fibers[0]) + yield* TestClock.adjust(100) // let retry happen + + // last request should come through + assert.deepStrictEqual(Queue.unsafeSize(state.envelopes), 11) + + // acks should be allowed to be sent + const users = yield* Fiber.join(fiber) + expect(users).toEqual([ + new User({ id: 1, name: "User 1" }), + new User({ id: 2, name: "User 2" }), + new User({ id: 3, name: "User 3" }) + ]) + + const driver = yield* MessageStorage.MemoryDriver + // 12 requests, 3 acks, 1 interrupt, 5 replies + assert.strictEqual(driver.journal.length, 12 + 3 + 1) + assert.strictEqual(driver.replyIds.size, 1 + 4) + }).pipe(Effect.provide(TestShardingWithoutStorage.pipe( + Layer.provideMerge(Layer.effect(MessageStorage.MemoryDriver)(MessageStorage.MemoryDriver.asEffect())), + Layer.updateService(MessageStorage.MessageStorage, (storage) => ({ + ...storage, + unprocessedMessagesById(messageIds) { + Queue.unsafeOffer(requestedIds, Array.fromIterable(messageIds)) + return storage.unprocessedMessagesById(messageIds) + } + })), + Layer.provide(MessageStorage.layerMemory), + Layer.provide(TestShardingConfig) + ))) + })) + + it.effect("durable messages are retried on restart", () => + Effect.gen(function*() { + const EnvLayer = TestShardingWithoutState.pipe( + Layer.provide(Runners.layerNoop), + Layer.provide(TestShardingConfig) + ) + const driver = yield* MessageStorage.MemoryDriver + const state = yield* TestEntityState + + yield* Effect.gen(function*() { + yield* TestClock.adjust(2000) + const makeClient = yield* TestEntity.client + const client = makeClient("1") + yield* Effect.fork(client.RequestWithKey({ key: "abc" })) + yield* TestClock.adjust(1) + }).pipe( + Effect.provide(EnvLayer), + Effect.scoped + ) + + // only the request should be in the journal + expect(driver.journal.length).toEqual(1) + expect(driver.replyIds.size).toEqual(0) + expect(driver.unprocessed.size).toEqual(1) + + // add response + yield* Queue.offer(state.messages, void 0) + + // Let the shards get assigned and storage poll + yield* TestClock.adjust(5000).pipe( + Effect.provide(EnvLayer), + Effect.scoped + ) + + expect(driver.journal.length).toEqual(1) + expect(driver.replyIds.size).toEqual(1) + expect(driver.unprocessed.size).toEqual(0) + + // the client should read the result from storage + yield* Effect.gen(function*() { + yield* TestClock.adjust(2000) + const makeClient = yield* TestEntity.client + const client = makeClient("1") + const result = yield* client.RequestWithKey({ key: "abc" }) + expect(result).toEqual(void 0) + }).pipe( + Effect.provide(EnvLayer), + Effect.scoped + ) + + // the request should not hit the entity + expect(driver.journal.length).toEqual(1) + expect(driver.replyIds.size).toEqual(1) + expect(driver.unprocessed.size).toEqual(0) + }).pipe(Effect.provide(MessageStorage.layerMemory.pipe( + Layer.provide(TestShardingConfig), + Layer.merge(TestEntityState.layer) + )))) + + it.effect("durable streams are resumed on restart", () => + Effect.gen(function*() { + const EnvLayer = TestShardingWithoutState.pipe( + Layer.provide(Runners.layerNoop), + Layer.provide(TestShardingConfig) + ) + const driver = yield* MessageStorage.MemoryDriver + const state = yield* TestEntityState + + // first chunk + yield* Queue.offerAll(state.streamMessages, [void 0, void 0]) + + yield* Effect.gen(function*() { + yield* TestClock.adjust(2000) + const makeClient = yield* TestEntity.client + const client = makeClient("1") + yield* Effect.fork(Stream.runDrain(client.StreamWithKey({ key: "abc" }))) + yield* TestClock.adjust(2000) + // second chunk + yield* Queue.offer(state.streamMessages, void 0) + yield* TestClock.adjust(2000) + }).pipe( + Effect.provide(EnvLayer), + Effect.scoped + ) + + // 1 request, 2 acks, 2 replies + expect(driver.journal.length).toEqual(1 + 2) + expect(driver.replyIds.size).toEqual(2) + expect(driver.unprocessed.size).toEqual(1) + + // third chunk + yield* Queue.offerAll(state.streamMessages, [void 0, void 0]) + yield* Queue.end(state.streamMessages) + + // the client should resume + yield* Effect.gen(function*() { + yield* TestClock.adjust(5000) // let the shards get assigned and storage poll + const makeClient = yield* TestEntity.client + const client = makeClient("1") + + // let the reply loop run + yield* TestClock.adjust(500).pipe(Effect.fork) + + const results = yield* Stream.runCollect(client.StreamWithKey({ key: "abc" })) + expect(results).toEqual([3, 4]) + }).pipe( + Effect.provide(EnvLayer), + Effect.scoped + ) + + // 1 request, 3 acks, 4 replies (3 chunks + WithExit) + expect(driver.journal.length).toEqual(1 + 3) + expect(driver.replyIds.size).toEqual(4) + expect(driver.unprocessed.size).toEqual(0) + }).pipe(Effect.provide(MessageStorage.layerMemory.pipe( + Layer.provide(TestShardingConfig), + Layer.merge(TestEntityState.layer) + )))) + + it.effect("client discard option", () => + Effect.gen(function*() { + yield* TestClock.adjust(2000) + const driver = yield* MessageStorage.MemoryDriver + const makeClient = yield* TestEntity.client + const client = makeClient("1") + const result = yield* client.GetUser({ id: 123 }, { discard: true }) + expect(result).toEqual(void 0) + yield* TestClock.adjust(1) + expect(driver.journal.length).toEqual(1) + expect(driver.unprocessed.size).toEqual(0) + }).pipe(Effect.provide(TestSharding))) + + it.effect("client discard with Never", () => + Effect.gen(function*() { + yield* TestClock.adjust(2000) + const driver = yield* MessageStorage.MemoryDriver + const makeClient = yield* TestEntity.client + const client = makeClient("1") + const result = yield* client.Never(void 0, { discard: true }) + expect(result).toEqual(void 0) + yield* TestClock.adjust(1) + expect(driver.journal.length).toEqual(1) + // should still be processing + expect(driver.unprocessed.size).toEqual(1) + }).pipe(Effect.provide(TestSharding))) + + it.effect("defect when no MessageStorage", () => + Effect.gen(function*() { + const makeClient = yield* TestEntity.client + const client = makeClient("1") + const cause = yield* client.Never().pipe( + Effect.sandbox, + Effect.flip + ) + assert(Cause.hasDie(cause)) + }).pipe(Effect.provide(TestShardingWithoutStorage.pipe( + Layer.provide(MessageStorage.layerNoop) + )))) + + it.effect("EntityNotManagedByRunner", () => + Effect.gen(function*() { + yield* TestClock.adjust(2000) + const makeClient = yield* TestEntity.client + const client = makeClient("1") + yield* TestClock.adjust(2000).pipe( + Effect.fork + ) + const error = yield* client.GetUser({ id: 123 }).pipe( + Effect.flip + ) + expect(error._tag).toEqual("EntityNotManagedByRunner") + }).pipe( + Effect.provide(TestShardingWithoutEntities) + )) + + it.effect("restart on defect", () => + Effect.gen(function*() { + yield* TestClock.adjust(2000) + const state = yield* TestEntityState + const makeClient = yield* TestEntity.client + const client = makeClient("1") + MutableRef.set(state.defectTrigger, true) + const result = yield* client.GetUser({ id: 123 }) + expect(result).toEqual(new User({ id: 123, name: "User 123" })) + expect(state.layerBuilds.current).toEqual(2) + }).pipe(Effect.provide(TestSharding))) +}) + +const TestShardingConfig = ShardingConfig.layer({ + entityMailboxCapacity: 10, + entityTerminationTimeout: 0, + entityMessagePollInterval: 5000, + sendRetryInterval: 100 +}) + +const TestShardingWithoutState = TestEntityNoState.pipe( + Layer.provideMerge(Sharding.layer), + Layer.provide(ShardManager.layerClientLocal), + Layer.provide(ShardStorage.layerMemory) + // Layer.provide(Logger.minimumLogLevel(LogLevel.All)), + // Layer.provideMerge(Logger.pretty) +) + +const TestShardingWithoutRunners = TestShardingWithoutState.pipe( + Layer.provideMerge(TestEntityState.layer) +) + +const TestShardingWithoutStorage = TestShardingWithoutRunners.pipe( + Layer.provide(Runners.layerNoop), + Layer.provide(TestShardingConfig) +) + +const TestSharding = TestShardingWithoutStorage.pipe( + Layer.provideMerge(MessageStorage.layerMemory), + Layer.provide(TestShardingConfig) +) + +const TestShardingWithoutEntities = Sharding.layer.pipe( + Layer.provide(ShardManager.layerClientLocal), + Layer.provide(ShardStorage.layerMemory), + Layer.provide(Runners.layerNoop), + Layer.provideMerge(MessageStorage.layerMemory), + Layer.provide(TestShardingConfig) +) diff --git a/packages/effect/test/cluster/TestEntity.ts b/packages/effect/test/cluster/TestEntity.ts new file mode 100644 index 0000000000..9be867d936 --- /dev/null +++ b/packages/effect/test/cluster/TestEntity.ts @@ -0,0 +1,132 @@ +import { Effect, Layer, MutableRef, Queue, Schedule, ServiceMap } from "effect" +import { Option } from "effect/data" +import { Schema } from "effect/schema" +import { Stream } from "effect/stream" +import type { Envelope } from "effect/unstable/cluster" +import { ClusterSchema, Entity } from "effect/unstable/cluster" +import type { RpcGroup } from "effect/unstable/rpc" +import { Rpc, RpcSchema } from "effect/unstable/rpc" + +export class User extends Schema.Class("User")({ + id: Schema.Number, + name: Schema.String +}) {} + +export class StreamWithKey extends Rpc.make("StreamWithKey", { + success: RpcSchema.Stream({ + success: Schema.Number, + error: Schema.Never + }), + payload: { key: Schema.String }, + primaryKey: ({ key }) => key +}) {} + +export const TestEntity = Entity.make("TestEntity", [ + Rpc.make("GetUser", { + success: User, + payload: { id: Schema.Number } + }), + Rpc.make("GetUserVolatile", { + success: User, + payload: { id: Schema.Number } + }).annotate(ClusterSchema.Persisted, false), + Rpc.make("Never"), + Rpc.make("NeverFork"), + Rpc.make("NeverVolatile").annotate(ClusterSchema.Persisted, false), + Rpc.make("RequestWithKey", { + payload: { key: Schema.String }, + primaryKey: ({ key }) => key + }), + StreamWithKey, + Rpc.make("GetAllUsers", { + success: User, + payload: { ids: Schema.Array(Schema.Number) }, + stream: true + }) +]).annotateRpcs(ClusterSchema.Persisted, true) + +export class TestEntityState extends ServiceMap.Key()("TestEntityState", { + make: Effect.gen(function*() { + const messages = yield* Queue.make() + const streamMessages = yield* Queue.make() + const envelopes = yield* Queue.make< + RpcGroup.Rpcs extends infer R ? R extends Rpc.Any ? Envelope.Request : never + : never + >() + const interrupts = yield* Queue.make< + RpcGroup.Rpcs extends infer R ? R extends Rpc.Any ? Envelope.Request : never + : never + >() + const defectTrigger = MutableRef.make(false) + const layerBuilds = MutableRef.make(0) + + return { + messages, + streamMessages, + envelopes, + interrupts, + defectTrigger, + layerBuilds + } as const + }) +}) { + static layer = Layer.effect(this)(this.make) +} + +export const TestEntityNoState = TestEntity.toLayer( + Effect.gen(function*() { + const state = yield* TestEntityState + + MutableRef.update(state.layerBuilds, (count) => count + 1) + + const never = (envelope: any) => + Effect.suspend(() => { + Queue.unsafeOffer(state.envelopes, envelope) + return Effect.never + }).pipe(Effect.onInterrupt(() => { + Queue.unsafeOffer(state.interrupts, envelope) + return Effect.void + })) + return { + GetUser: (envelope) => + Effect.sync(() => { + Queue.unsafeOffer(state.envelopes, envelope) + if (state.defectTrigger.current) { + MutableRef.set(state.defectTrigger, false) + throw new Error("User not found") + } + return new User({ id: envelope.payload.id, name: `User ${envelope.payload.id}` }) + }), + GetUserVolatile: (envelope) => + Effect.sync(() => { + Queue.unsafeOffer(state.envelopes, envelope) + return new User({ id: envelope.payload.id, name: `User ${envelope.payload.id}` }) + }), + Never: never, + NeverFork: (envelope) => Rpc.fork(never(envelope)), + NeverVolatile: never, + RequestWithKey: (envelope) => { + Queue.unsafeOffer(state.envelopes, envelope) + return Queue.take(state.messages) + }, + StreamWithKey: (envelope) => { + let sequence = envelope.lastSentChunkValue.pipe( + Option.map((value) => value + 1), + Option.getOrElse(() => 0) + ) + return Stream.fromQueue(state.streamMessages).pipe( + Stream.map(() => sequence++) + ) + }, + GetAllUsers: (envelope) => { + Queue.unsafeOffer(state.envelopes, envelope) + return Stream.fromIterable(envelope.payload.ids.map((id) => new User({ id, name: `User ${id}` }))).pipe( + Stream.rechunk(1) + ) + } + } + }), + { defectRetryPolicy: Schedule.forever } +) + +export const TestEntityLayer = TestEntityNoState.pipe(Layer.provideMerge(TestEntityState.layer)) diff --git a/packages/effect/test/schema/Serializer.test.ts b/packages/effect/test/schema/Serializer.test.ts index 822a1f2450..b4a3294e36 100644 --- a/packages/effect/test/schema/Serializer.test.ts +++ b/packages/effect/test/schema/Serializer.test.ts @@ -31,22 +31,6 @@ describe("Serializer", () => { ) }) - it("Any", async () => { - await assertions.serialization.json.typeCodec.fail( - Schema.Any, - "a", - `cannot serialize to JSON, required \`defaultJsonSerializer\` annotation for AnyKeyword` - ) - }) - - it("Unknown", async () => { - await assertions.serialization.json.typeCodec.fail( - Schema.Unknown, - "a", - `cannot serialize to JSON, required \`defaultJsonSerializer\` annotation for UnknownKeyword` - ) - }) - it("Object", async () => { await assertions.serialization.json.typeCodec.fail( Schema.Object, @@ -196,6 +180,20 @@ describe("Serializer", () => { }) }) + it("Any", async () => { + const schema = Schema.Any + + await assertions.serialization.json.typeCodec.succeed(schema, {}) + await assertions.deserialization.json.typeCodec.succeed(schema, {}) + }) + + it("Unknown", async () => { + const schema = Schema.Unknown + + await assertions.serialization.json.typeCodec.succeed(schema, {}) + await assertions.deserialization.json.typeCodec.succeed(schema, {}) + }) + it("Undefined", async () => { const schema = Schema.Undefined @@ -934,22 +932,6 @@ describe("Serializer", () => { ) }) - it("Any", async () => { - await assertions.serialization.stringLeafJson.typeCodec.fail( - Schema.Any, - "a", - `cannot serialize to JSON, required \`defaultJsonSerializer\` annotation for AnyKeyword` - ) - }) - - it("Unknown", async () => { - await assertions.serialization.stringLeafJson.typeCodec.fail( - Schema.Unknown, - "a", - `cannot serialize to JSON, required \`defaultJsonSerializer\` annotation for UnknownKeyword` - ) - }) - it("Object", async () => { await assertions.serialization.stringLeafJson.typeCodec.fail( Schema.Object, @@ -972,6 +954,20 @@ describe("Serializer", () => { }) }) + it("Any", async () => { + const schema = Schema.Any + + await assertions.serialization.stringLeafJson.typeCodec.succeed(schema, "a") + await assertions.deserialization.stringLeafJson.typeCodec.succeed(schema, "a") + }) + + it("Unknown", async () => { + const schema = Schema.Unknown + + await assertions.serialization.stringLeafJson.typeCodec.succeed(schema, "a") + await assertions.deserialization.stringLeafJson.typeCodec.succeed(schema, "a") + }) + it("Undefined", async () => { const schema = Schema.Undefined diff --git a/packages/effect/test/utils/counter.ts b/packages/effect/test/utils/counter.ts new file mode 100644 index 0000000000..1254d568d7 --- /dev/null +++ b/packages/effect/test/utils/counter.ts @@ -0,0 +1,54 @@ +import * as Effect from "effect/Effect" +import { pipe } from "effect/Function" +import * as Ref from "effect/Ref" +import type * as Scope from "effect/Scope" + +interface Counter { + acquire(): Effect.Effect + incrementAcquire(): Effect.Effect + incrementRelease(): Effect.Effect + acquired(): Effect.Effect + released(): Effect.Effect +} + +class CounterImpl implements Counter { + constructor(readonly ref: Ref.Ref) {} + + acquire(): Effect.Effect { + return pipe( + this.incrementAcquire(), + Effect.andThen(Effect.addFinalizer(() => this.incrementRelease())), + Effect.andThen(this.acquired()), + Effect.uninterruptible + ) + } + + incrementAcquire(): Effect.Effect { + return Ref.modify(this.ref, ([acquire, release]) => [acquire + 1, [acquire + 1, release] as const] as const) + } + + incrementRelease(): Effect.Effect { + return Ref.modify(this.ref, ([acquire, release]) => [release + 1, [acquire, release + 1] as const] as const) + } + + acquired(): Effect.Effect { + return pipe( + Ref.get(this.ref), + Effect.map((tuple) => tuple[0]) + ) + } + + released(): Effect.Effect { + return pipe( + Ref.get(this.ref), + Effect.map((tuple) => tuple[1]) + ) + } +} + +export const make = (): Effect.Effect => { + return pipe( + Ref.make([0, 0]), + Effect.map((ref) => new CounterImpl(ref as any)) + ) +} diff --git a/packages/platform-bun/package.json b/packages/platform-bun/package.json index eaa9a59603..e20388efad 100644 --- a/packages/platform-bun/package.json +++ b/packages/platform-bun/package.json @@ -64,7 +64,7 @@ "@effect/platform-node-shared": "workspace:^" }, "devDependencies": { - "@types/bun": "^1.2.18", + "@types/bun": "^1.2.21", "effect": "workspace:^" } } diff --git a/packages/platform-bun/src/BunClusterRunnerHttp.ts b/packages/platform-bun/src/BunClusterRunnerHttp.ts new file mode 100644 index 0000000000..71223f79c4 --- /dev/null +++ b/packages/platform-bun/src/BunClusterRunnerHttp.ts @@ -0,0 +1,100 @@ +/** + * @since 1.0.0 + */ +import type * as Config from "effect/config/Config" +import * as Option from "effect/data/Option" +import * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" +import * as HttpRunner from "effect/unstable/cluster/HttpRunner" +import * as MessageStorage from "effect/unstable/cluster/MessageStorage" +import type * as Runners from "effect/unstable/cluster/Runners" +import type { Sharding } from "effect/unstable/cluster/Sharding" +import * as ShardingConfig from "effect/unstable/cluster/ShardingConfig" +import * as ShardStorage from "effect/unstable/cluster/ShardStorage" +import * as SqlMessageStorage from "effect/unstable/cluster/SqlMessageStorage" +import * as SqlShardStorage from "effect/unstable/cluster/SqlShardStorage" +import type * as Etag from "effect/unstable/http/Etag" +import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient" +import type { HttpPlatform } from "effect/unstable/http/HttpPlatform" +import type { HttpServer } from "effect/unstable/http/HttpServer" +import type { ServeError } from "effect/unstable/http/HttpServerError" +import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization" +import type { SqlClient } from "effect/unstable/sql/SqlClient" +import type { SqlError } from "effect/unstable/sql/SqlError" +import * as BunHttpServer from "./BunHttpServer.ts" +import type { BunServices } from "./BunServices.ts" +import * as BunSocket from "./BunSocket.ts" + +/** + * @since 1.0.0 + * @category Layers + */ +export const layerHttpServer: Layer.Layer< + | HttpPlatform + | Etag.Generator + | BunServices + | HttpServer, + ServeError, + ShardingConfig.ShardingConfig +> = Effect.gen(function*() { + const config = yield* ShardingConfig.ShardingConfig + const listenAddress = config.runnerListenAddress.pipe( + Option.orElse(() => config.runnerAddress) + ) + if (Option.isNone(listenAddress)) { + return yield* Effect.die("BunClusterHttpRunners.layerHttpServer: ShardingConfig.runnerAddress is None") + } + return BunHttpServer.layer(listenAddress.value) +}).pipe(Layer.unwrap) + +/** + * @since 1.0.0 + * @category Layers + */ +export const layer = < + const ClientOnly extends boolean = false, + const Storage extends "noop" | "sql" = never +>(options: { + readonly transport: "http" | "websocket" + readonly serialization?: "msgpack" | "ndjson" | undefined + readonly clientOnly?: ClientOnly | undefined + readonly storage?: Storage | undefined + readonly shardingConfig?: Partial | undefined +}): ClientOnly extends true ? Layer.Layer< + Sharding | Runners.Runners | MessageStorage.MessageStorage, + Config.ConfigError | ("sql" extends Storage ? SqlError : never), + "sql" extends Storage ? SqlClient : never + > : + Layer.Layer< + Sharding | Runners.Runners | MessageStorage.MessageStorage, + ServeError | Config.ConfigError | ("sql" extends Storage ? SqlError : never), + "sql" extends Storage ? SqlClient : never + > => +{ + const layer: Layer.Layer = options.clientOnly + // client only + ? options.transport === "http" + ? Layer.provide(HttpRunner.layerHttpClientOnly, FetchHttpClient.layer) + : Layer.provide(HttpRunner.layerWebsocketClientOnly, BunSocket.layerWebSocketConstructor) + // with server + : options.transport === "http" + ? Layer.provide(HttpRunner.layerHttp, [layerHttpServer, FetchHttpClient.layer]) + : Layer.provide(HttpRunner.layerWebsocket, [layerHttpServer, BunSocket.layerWebSocketConstructor]) + + return layer.pipe( + Layer.provideMerge( + options?.storage === "sql" ? + SqlMessageStorage.layer + : MessageStorage.layerNoop + ), + Layer.provide( + options?.storage === "sql" + ? options.clientOnly ? Layer.empty : SqlShardStorage.layer + : ShardStorage.layerNoop + ), + Layer.provide(ShardingConfig.layerFromEnv(options?.shardingConfig)), + Layer.provide( + options?.serialization === "ndjson" ? RpcSerialization.layerNdjson : RpcSerialization.layerMsgPack + ) + ) as any +} diff --git a/packages/platform-bun/src/BunClusterRunnerSocket.ts b/packages/platform-bun/src/BunClusterRunnerSocket.ts new file mode 100644 index 0000000000..f863b18e12 --- /dev/null +++ b/packages/platform-bun/src/BunClusterRunnerSocket.ts @@ -0,0 +1,9 @@ +/** + * @since 1.0.0 + */ + +/** + * @since 1.0.0 + * @category Re-exports + */ +export * from "@effect/platform-node-shared/NodeClusterRunnerSocket" diff --git a/packages/platform-bun/src/BunClusterShardManagerHttp.ts b/packages/platform-bun/src/BunClusterShardManagerHttp.ts new file mode 100644 index 0000000000..8a4a3fd38d --- /dev/null +++ b/packages/platform-bun/src/BunClusterShardManagerHttp.ts @@ -0,0 +1,72 @@ +/** + * @since 1.0.0 + */ +import type * as Config from "effect/config/Config" +import * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" +import * as HttpShardManager from "effect/unstable/cluster/HttpShardManager" +import * as ShardingConfig from "effect/unstable/cluster/ShardingConfig" +import * as ShardManager from "effect/unstable/cluster/ShardManager" +import * as ShardStorage from "effect/unstable/cluster/ShardStorage" +import * as SqlShardStorage from "effect/unstable/cluster/SqlShardStorage" +import type * as Etag from "effect/unstable/http/Etag" +import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient" +import type { HttpPlatform } from "effect/unstable/http/HttpPlatform" +import type { HttpServer } from "effect/unstable/http/HttpServer" +import type { ServeError } from "effect/unstable/http/HttpServerError" +import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization" +import type { SqlClient } from "effect/unstable/sql/SqlClient" +import type { SqlError } from "effect/unstable/sql/SqlError" +import * as BunHttpServer from "./BunHttpServer.ts" +import type { BunServices } from "./BunServices.ts" +import * as BunSocket from "./BunSocket.ts" + +/** + * @since 1.0.0 + * @category Layers + */ +export const layerHttpServer: Layer.Layer< + | HttpPlatform + | Etag.Generator + | BunServices + | HttpServer, + ServeError, + ShardingConfig.ShardingConfig +> = Effect.gen(function*() { + const config = yield* ShardingConfig.ShardingConfig + return BunHttpServer.layer(config.shardManagerAddress) +}).pipe(Layer.unwrap) + +/** + * @since 1.0.0 + * @category Layers + */ +export const layer = (options: { + readonly transport: "http" | "websocket" + readonly serialization?: "msgpack" | "ndjson" | undefined + readonly shardingConfig?: Partial | undefined + readonly storage?: Storage | undefined + readonly config?: Partial | undefined +}): Layer.Layer< + ShardManager.ShardManager, + ServeError | Config.ConfigError | ("sql" extends Storage ? SqlError : never), + "sql" extends Storage ? SqlClient : never +> => { + const layer: Layer.Layer = options.transport === "http" ? + HttpShardManager.layerHttp.pipe( + Layer.provide([HttpShardManager.layerRunnerHealthHttp, layerHttpServer]), + Layer.provide(FetchHttpClient.layer) + ) : + HttpShardManager.layerWebsocket.pipe( + Layer.provide([HttpShardManager.layerRunnerHealthWebsocket, layerHttpServer]), + Layer.provide(BunSocket.layerWebSocketConstructor) + ) + return layer.pipe( + Layer.provide(options?.storage === "sql" ? SqlShardStorage.layer : ShardStorage.layerNoop), + Layer.provide([ + ShardingConfig.layerFromEnv(options.shardingConfig), + ShardManager.layerConfigFromEnv(options?.config), + options?.serialization === "ndjson" ? RpcSerialization.layerNdjson : RpcSerialization.layerMsgPack + ]) + ) +} diff --git a/packages/platform-bun/src/BunClusterShardManagerSocket.ts b/packages/platform-bun/src/BunClusterShardManagerSocket.ts new file mode 100644 index 0000000000..1fed8e6c7f --- /dev/null +++ b/packages/platform-bun/src/BunClusterShardManagerSocket.ts @@ -0,0 +1,9 @@ +/** + * @since 1.0.0 + */ + +/** + * @since 1.0.0 + * @category Re-exports + */ +export * from "@effect/platform-node-shared/NodeClusterShardManagerSocket" diff --git a/packages/platform-bun/src/BunServices.ts b/packages/platform-bun/src/BunServices.ts index ae32c97dd4..d8e8206baa 100644 --- a/packages/platform-bun/src/BunServices.ts +++ b/packages/platform-bun/src/BunServices.ts @@ -7,6 +7,12 @@ import type { Path } from "effect/platform/Path" import * as NodeFileSystem from "./BunFileSystem.ts" import * as NodePath from "./BunPath.ts" +/** + * @since 1.0.0 + * @category Models + */ +export type BunServices = FileSystem | Path + /** * @since 1.0.0 * @category layer diff --git a/packages/platform-bun/src/index.ts b/packages/platform-bun/src/index.ts index 5269f50fdf..3ab2063527 100644 --- a/packages/platform-bun/src/index.ts +++ b/packages/platform-bun/src/index.ts @@ -2,6 +2,26 @@ * @since 1.0.0 */ +/** + * @since 1.0.0 + */ +export * as BunClusterRunnerHttp from "./BunClusterRunnerHttp.ts" + +/** + * @since 1.0.0 + */ +export * as BunClusterRunnerSocket from "./BunClusterRunnerSocket.ts" + +/** + * @since 1.0.0 + */ +export * as BunClusterShardManagerHttp from "./BunClusterShardManagerHttp.ts" + +/** + * @since 1.0.0 + */ +export * as BunClusterShardManagerSocket from "./BunClusterShardManagerSocket.ts" + /** * @since 1.0.0 */ diff --git a/packages/platform-node-shared/docgen.json b/packages/platform-node-shared/docgen.json index 9781bdfd42..148819f070 100644 --- a/packages/platform-node-shared/docgen.json +++ b/packages/platform-node-shared/docgen.json @@ -27,8 +27,8 @@ "@effect/platform-node-shared/*": ["../../../platform-node-shared/src/*.js"], "@effect/rpc": ["../../../rpc/src/index.js"], "@effect/rpc/*": ["../../../rpc/src/*.js"], - "@effect/sql": ["../../../sql/src/index.js"], - "@effect/sql/*": ["../../../sql/src/*.js"] + "effect/unstable/sql": ["../../../sql/src/index.js"], + "effect/unstable/sql/*": ["../../../sql/src/*.js"] } } } diff --git a/packages/platform-node-shared/package.json b/packages/platform-node-shared/package.json index c075edbb25..0f28a9c77c 100644 --- a/packages/platform-node-shared/package.json +++ b/packages/platform-node-shared/package.json @@ -61,7 +61,7 @@ "effect": "workspace:^" }, "devDependencies": { - "@types/node": "^24.0.14", + "@types/node": "^24.3.0", "effect": "workspace:^", "tar": "^7.4.3" }, diff --git a/packages/platform-node-shared/src/NodeClusterRunnerSocket.ts b/packages/platform-node-shared/src/NodeClusterRunnerSocket.ts new file mode 100644 index 0000000000..712ff5eb70 --- /dev/null +++ b/packages/platform-node-shared/src/NodeClusterRunnerSocket.ts @@ -0,0 +1,86 @@ +/** + * @since 1.0.0 + */ +import type * as Config from "effect/config/Config" +import * as Option from "effect/data/Option" +import * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" +import * as MessageStorage from "effect/unstable/cluster/MessageStorage" +import type * as Runners from "effect/unstable/cluster/Runners" +import type { Sharding } from "effect/unstable/cluster/Sharding" +import * as ShardingConfig from "effect/unstable/cluster/ShardingConfig" +import * as ShardStorage from "effect/unstable/cluster/ShardStorage" +import * as SocketRunner from "effect/unstable/cluster/SocketRunner" +import * as SqlMessageStorage from "effect/unstable/cluster/SqlMessageStorage" +import * as SqlShardStorage from "effect/unstable/cluster/SqlShardStorage" +import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization" +import type * as SocketServer from "effect/unstable/socket/SocketServer" +import type { SqlClient } from "effect/unstable/sql/SqlClient" +import type { SqlError } from "effect/unstable/sql/SqlError" +import { layerClientProtocol } from "./NodeClusterSocketCommon.js" +import * as NodeSocketServer from "./NodeSocketServer.js" + +/** + * @since 1.0.0 + * @category Layers + */ +export const layerSocketServer: Layer.Layer< + SocketServer.SocketServer, + SocketServer.SocketServerError, + ShardingConfig.ShardingConfig +> = Effect.gen(function*() { + const config = yield* ShardingConfig.ShardingConfig + const listenAddress = config.runnerListenAddress.pipe( + Option.orElse(() => config.runnerAddress) + ) + if (Option.isNone(listenAddress)) { + return yield* Effect.die("layerSocketServer: ShardingConfig.runnerListenAddress is None") + } + return NodeSocketServer.layer(listenAddress.value) +}).pipe(Layer.unwrap) + +/** + * @since 1.0.0 + * @category Layers + */ +export const layer = ( + options?: { + readonly serialization?: "msgpack" | "ndjson" | undefined + readonly clientOnly?: ClientOnly | undefined + readonly storage?: Storage | undefined + readonly shardingConfig?: Partial | undefined + } +): ClientOnly extends true ? Layer.Layer< + Sharding | Runners.Runners | MessageStorage.MessageStorage, + Config.ConfigError, + "sql" extends Storage ? SqlClient : never + > : + Layer.Layer< + Sharding | Runners.Runners | MessageStorage.MessageStorage, + SocketServer.SocketServerError | Config.ConfigError | ("sql" extends Storage ? SqlError : never), + "sql" extends Storage ? SqlClient : never + > => +{ + const layer: Layer.Layer = options?.clientOnly + // client only + ? Layer.provide(SocketRunner.layerClientOnly, layerClientProtocol) + // with server + : Layer.provide(SocketRunner.layer, [layerSocketServer, layerClientProtocol]) + + return layer.pipe( + Layer.provideMerge( + options?.storage === "sql" + ? SqlMessageStorage.layer + : MessageStorage.layerNoop + ), + Layer.provide( + options?.storage === "sql" + ? options.clientOnly ? Layer.empty : SqlShardStorage.layer + : ShardStorage.layerNoop + ), + Layer.provide(ShardingConfig.layerFromEnv(options?.shardingConfig)), + Layer.provide( + options?.serialization === "ndjson" ? RpcSerialization.layerNdjson : RpcSerialization.layerMsgPack + ) + ) as any +} diff --git a/packages/platform-node-shared/src/NodeClusterShardManagerSocket.ts b/packages/platform-node-shared/src/NodeClusterShardManagerSocket.ts new file mode 100644 index 0000000000..a80a079764 --- /dev/null +++ b/packages/platform-node-shared/src/NodeClusterShardManagerSocket.ts @@ -0,0 +1,59 @@ +/** + * @since 1.0.0 + */ +import type * as Config from "effect/config/Config" +import * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" +import * as RunnerHealth from "effect/unstable/cluster/RunnerHealth" +import * as ShardingConfig from "effect/unstable/cluster/ShardingConfig" +import * as ShardManager from "effect/unstable/cluster/ShardManager" +import * as ShardStorage from "effect/unstable/cluster/ShardStorage" +import * as SocketShardManager from "effect/unstable/cluster/SocketShardManager" +import * as SqlShardStorage from "effect/unstable/cluster/SqlShardStorage" +import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization" +import type * as SocketServer from "effect/unstable/socket/SocketServer" +import type { SqlClient } from "effect/unstable/sql/SqlClient" +import type { SqlError } from "effect/unstable/sql/SqlError" +import { layerClientProtocol } from "./NodeClusterSocketCommon.js" +import * as NodeSocketServer from "./NodeSocketServer.js" + +/** + * @since 1.0.0 + * @category Layers + */ +export const layerSocketServer: Layer.Layer< + SocketServer.SocketServer, + SocketServer.SocketServerError, + ShardingConfig.ShardingConfig +> = Effect.gen(function*() { + const config = yield* ShardingConfig.ShardingConfig + return NodeSocketServer.layer(config.shardManagerAddress) +}).pipe(Layer.unwrap) + +/** + * @since 1.0.0 + * @category Layers + */ +export const layer = (options?: { + readonly serialization?: "msgpack" | "ndjson" | undefined + readonly shardingConfig?: Partial | undefined + readonly storage?: Storage | undefined + readonly config?: Partial | undefined +}): Layer.Layer< + ShardManager.ShardManager, + SocketServer.SocketServerError | Config.ConfigError | ("sql" extends Storage ? SqlError : never), + "sql" extends Storage ? SqlClient : never +> => + SocketShardManager.layer.pipe( + Layer.provide([ + RunnerHealth.layerRpc, + layerSocketServer, + ShardManager.layerConfigFromEnv(options?.config) + ]), + Layer.provide(layerClientProtocol), + Layer.provide(options?.storage === "sql" ? SqlShardStorage.layer : ShardStorage.layerNoop), + Layer.provide([ + options?.serialization === "ndjson" ? RpcSerialization.layerNdjson : RpcSerialization.layerMsgPack, + ShardingConfig.layerFromEnv(options?.shardingConfig) + ]) + ) as any diff --git a/packages/platform-node-shared/src/NodeClusterSocketCommon.ts b/packages/platform-node-shared/src/NodeClusterSocketCommon.ts new file mode 100644 index 0000000000..6adbab48eb --- /dev/null +++ b/packages/platform-node-shared/src/NodeClusterSocketCommon.ts @@ -0,0 +1,34 @@ +/** + * @since 1.0.0 + */ +import * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" +import * as Runners from "effect/unstable/cluster/Runners" +import * as RpcClient from "effect/unstable/rpc/RpcClient" +import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization" +import { Socket } from "effect/unstable/socket/Socket" +import * as NodeSocket from "./NodeSocket.js" + +/** + * @since 1.0.0 + * @category Layers + */ +export const layerClientProtocol: Layer.Layer< + Runners.RpcClientProtocol, + never, + RpcSerialization.RpcSerialization +> = Layer.effect(Runners.RpcClientProtocol)( + Effect.gen(function*() { + const serialization = yield* RpcSerialization.RpcSerialization + return Effect.fnUntraced(function*(address) { + const socket = yield* NodeSocket.makeNet({ + host: address.host, + port: address.port + }) + return yield* RpcClient.makeProtocolSocket().pipe( + Effect.provideService(Socket, socket), + Effect.provideService(RpcSerialization.RpcSerialization, serialization) + ) + }, Effect.orDie) + }) +) diff --git a/packages/platform-node/docgen.json b/packages/platform-node/docgen.json index 9781bdfd42..6cf8ac0d93 100644 --- a/packages/platform-node/docgen.json +++ b/packages/platform-node/docgen.json @@ -14,21 +14,7 @@ "allowImportingTsExtensions": true, "paths": { "effect": ["../../../effect/src/index.js"], - "effect/*": ["../../../effect/src/*.js"], - "@effect/cluster": ["../../../cluster/src/index.js"], - "@effect/cluster/*": ["../../../cluster/src/*.js"], - "@effect/experimental": ["../../../experimental/src/index.js"], - "@effect/experimental/*": ["../../../experimental/src/*.js"], - "@effect/platform": ["../../../platform/src/index.js"], - "@effect/platform/*": ["../../../platform/src/*.js"], - "@effect/platform-node": ["../../../platform-node/src/index.js"], - "@effect/platform-node/*": ["../../../platform-node/src/*.js"], - "@effect/platform-node-shared": ["../../../platform-node-shared/src/index.js"], - "@effect/platform-node-shared/*": ["../../../platform-node-shared/src/*.js"], - "@effect/rpc": ["../../../rpc/src/index.js"], - "@effect/rpc/*": ["../../../rpc/src/*.js"], - "@effect/sql": ["../../../sql/src/index.js"], - "@effect/sql/*": ["../../../sql/src/*.js"] + "effect/*": ["../../../effect/src/*.js"] } } } diff --git a/packages/platform-node/package.json b/packages/platform-node/package.json index 1d7d66d0ff..0bae2c87b8 100644 --- a/packages/platform-node/package.json +++ b/packages/platform-node/package.json @@ -63,13 +63,15 @@ "dependencies": { "@effect/platform-node-shared": "workspace:^", "mime": "^4.0.7", - "undici": "^7.11.0" + "undici": "^7.15.0" }, "peerDependencies": { "effect": "workspace:^" }, "devDependencies": { - "@types/node": "^24.0.14", + "@testcontainers/mysql": "^11.5.1", + "@testcontainers/postgresql": "^11.5.1", + "@types/node": "^24.3.0", "effect": "workspace:^" } } diff --git a/packages/platform-node/src/NodeClusterRunnerHttp.ts b/packages/platform-node/src/NodeClusterRunnerHttp.ts new file mode 100644 index 0000000000..f803dce9fb --- /dev/null +++ b/packages/platform-node/src/NodeClusterRunnerHttp.ts @@ -0,0 +1,101 @@ +/** + * @since 1.0.0 + */ +import type * as Config from "effect/config/Config" +import * as Option from "effect/data/Option" +import * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" +import * as HttpRunner from "effect/unstable/cluster/HttpRunner" +import * as MessageStorage from "effect/unstable/cluster/MessageStorage" +import type * as Runners from "effect/unstable/cluster/Runners" +import type { Sharding } from "effect/unstable/cluster/Sharding" +import * as ShardingConfig from "effect/unstable/cluster/ShardingConfig" +import * as ShardStorage from "effect/unstable/cluster/ShardStorage" +import * as SqlMessageStorage from "effect/unstable/cluster/SqlMessageStorage" +import * as SqlShardStorage from "effect/unstable/cluster/SqlShardStorage" +import type * as Etag from "effect/unstable/http/Etag" +import type { HttpPlatform } from "effect/unstable/http/HttpPlatform" +import type { HttpServer } from "effect/unstable/http/HttpServer" +import type { ServeError } from "effect/unstable/http/HttpServerError" +import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization" +import type { SqlClient } from "effect/unstable/sql/SqlClient" +import type { SqlError } from "effect/unstable/sql/SqlError" +import { createServer } from "node:http" +import * as NodeHttpClient from "./NodeHttpClient.ts" +import * as NodeHttpServer from "./NodeHttpServer.ts" +import type { NodeServices } from "./NodeServices.ts" +import * as NodeSocket from "./NodeSocket.ts" + +/** + * @since 1.0.0 + * @category Layers + */ +export const layer = < + const ClientOnly extends boolean = false, + const Storage extends "noop" | "sql" = never +>(options: { + readonly transport: "http" | "websocket" + readonly serialization?: "msgpack" | "ndjson" | undefined + readonly clientOnly?: ClientOnly | undefined + readonly storage?: Storage | undefined + readonly shardingConfig?: Partial | undefined +}): ClientOnly extends true ? Layer.Layer< + Sharding | Runners.Runners | MessageStorage.MessageStorage, + Config.ConfigError | ("sql" extends Storage ? SqlError : never), + "sql" extends Storage ? SqlClient : never + > : + Layer.Layer< + Sharding | Runners.Runners | MessageStorage.MessageStorage, + ServeError | Config.ConfigError | ("sql" extends Storage ? SqlError : never), + "sql" extends Storage ? SqlClient : never + > => +{ + const layer: Layer.Layer = options.clientOnly + // client only + ? options.transport === "http" + ? Layer.provide(HttpRunner.layerHttpClientOnly, NodeHttpClient.layerUndici) + : Layer.provide(HttpRunner.layerWebsocketClientOnly, NodeSocket.layerWebSocketConstructor) + // with server + : options.transport === "http" + ? Layer.provide(HttpRunner.layerHttp, [layerHttpServer, NodeHttpClient.layerUndici]) + : Layer.provide(HttpRunner.layerWebsocket, [layerHttpServer, NodeSocket.layerWebSocketConstructor]) + + return layer.pipe( + Layer.provideMerge( + options?.storage === "sql" ? + SqlMessageStorage.layer + : MessageStorage.layerNoop + ), + Layer.provide( + options?.storage === "sql" + ? options.clientOnly ? Layer.empty : SqlShardStorage.layer + : ShardStorage.layerNoop + ), + Layer.provide(ShardingConfig.layerFromEnv(options?.shardingConfig)), + Layer.provide( + options?.serialization === "ndjson" ? RpcSerialization.layerNdjson : RpcSerialization.layerMsgPack + ) + ) as any +} + +/** + * @since 1.0.0 + * @category Layers + */ +export const layerHttpServer: Layer.Layer< + | HttpPlatform + | Etag.Generator + | NodeServices + | HttpServer, + ServeError, + ShardingConfig.ShardingConfig +> = Effect.gen(function*() { + const config = yield* ShardingConfig.ShardingConfig + const listenAddress = config.runnerListenAddress.pipe( + Option.orElse(() => config.runnerAddress) + ) + if (Option.isNone(listenAddress)) { + return yield* Effect.die("NodeClusterHttpRunner.layerHttpServer: ShardingConfig.podAddress is None") + } + return NodeHttpServer.layer(createServer, listenAddress.value) +}).pipe(Layer.unwrap) diff --git a/packages/platform-node/src/NodeClusterRunnerSocket.ts b/packages/platform-node/src/NodeClusterRunnerSocket.ts new file mode 100644 index 0000000000..f863b18e12 --- /dev/null +++ b/packages/platform-node/src/NodeClusterRunnerSocket.ts @@ -0,0 +1,9 @@ +/** + * @since 1.0.0 + */ + +/** + * @since 1.0.0 + * @category Re-exports + */ +export * from "@effect/platform-node-shared/NodeClusterRunnerSocket" diff --git a/packages/platform-node/src/NodeClusterShardManagerHttp.ts b/packages/platform-node/src/NodeClusterShardManagerHttp.ts new file mode 100644 index 0000000000..fd79f3f9ed --- /dev/null +++ b/packages/platform-node/src/NodeClusterShardManagerHttp.ts @@ -0,0 +1,73 @@ +/** + * @since 1.0.0 + */ +import type * as Config from "effect/config/Config" +import * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" +import * as HttpShardManager from "effect/unstable/cluster/HttpShardManager" +import * as ShardingConfig from "effect/unstable/cluster/ShardingConfig" +import * as ShardManager from "effect/unstable/cluster/ShardManager" +import * as ShardStorage from "effect/unstable/cluster/ShardStorage" +import * as SqlShardStorage from "effect/unstable/cluster/SqlShardStorage" +import type * as Etag from "effect/unstable/http/Etag" +import type { HttpPlatform } from "effect/unstable/http/HttpPlatform" +import type { HttpServer } from "effect/unstable/http/HttpServer" +import type { ServeError } from "effect/unstable/http/HttpServerError" +import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization" +import type { SqlClient } from "effect/unstable/sql/SqlClient" +import type { SqlError } from "effect/unstable/sql/SqlError" +import { createServer } from "node:http" +import * as NodeHttpClient from "./NodeHttpClient.ts" +import * as NodeHttpServer from "./NodeHttpServer.ts" +import type { NodeServices } from "./NodeServices.ts" +import * as NodeSocket from "./NodeSocket.ts" + +/** + * @since 1.0.0 + * @category Layers + */ +export const layerHttpServer: Layer.Layer< + | HttpPlatform + | Etag.Generator + | NodeServices + | HttpServer, + ServeError, + ShardingConfig.ShardingConfig +> = Effect.gen(function*() { + const config = yield* ShardingConfig.ShardingConfig + return NodeHttpServer.layer(createServer, config.shardManagerAddress) +}).pipe(Layer.unwrap) + +/** + * @since 1.0.0 + * @category Layers + */ +export const layer = (options: { + readonly transport: "http" | "websocket" + readonly serialization?: "msgpack" | "ndjson" | undefined + readonly shardingConfig?: Partial | undefined + readonly storage?: Storage | undefined + readonly config?: Partial | undefined +}): Layer.Layer< + ShardManager.ShardManager, + ServeError | Config.ConfigError | ("sql" extends Storage ? SqlError : never), + "sql" extends Storage ? SqlClient : never +> => { + const layer: Layer.Layer = options.transport === "http" ? + HttpShardManager.layerHttp.pipe( + Layer.provide([HttpShardManager.layerRunnerHealthHttp, layerHttpServer]), + Layer.provide(NodeHttpClient.layerUndici) + ) : + HttpShardManager.layerWebsocket.pipe( + Layer.provide([HttpShardManager.layerRunnerHealthWebsocket, layerHttpServer]), + Layer.provide(NodeSocket.layerWebSocketConstructor) + ) + return layer.pipe( + Layer.provide(options?.storage === "sql" ? SqlShardStorage.layer : ShardStorage.layerNoop), + Layer.provide([ + ShardingConfig.layerFromEnv(options.shardingConfig), + ShardManager.layerConfigFromEnv(options?.config), + options?.serialization === "ndjson" ? RpcSerialization.layerNdjson : RpcSerialization.layerMsgPack + ]) + ) +} diff --git a/packages/platform-node/src/NodeClusterShardManagerSocket.ts b/packages/platform-node/src/NodeClusterShardManagerSocket.ts new file mode 100644 index 0000000000..1fed8e6c7f --- /dev/null +++ b/packages/platform-node/src/NodeClusterShardManagerSocket.ts @@ -0,0 +1,9 @@ +/** + * @since 1.0.0 + */ + +/** + * @since 1.0.0 + * @category Re-exports + */ +export * from "@effect/platform-node-shared/NodeClusterShardManagerSocket" diff --git a/packages/platform-node/src/NodeServices.ts b/packages/platform-node/src/NodeServices.ts index 3e2bb4d4a5..56ab0a8941 100644 --- a/packages/platform-node/src/NodeServices.ts +++ b/packages/platform-node/src/NodeServices.ts @@ -7,6 +7,12 @@ import type { Path } from "effect/platform/Path" import * as NodeFileSystem from "./NodeFileSystem.ts" import * as NodePath from "./NodePath.ts" +/** + * @since 1.0.0 + * @category Models + */ +export type NodeServices = FileSystem | Path + /** * @since 1.0.0 * @category layer diff --git a/packages/platform-node/src/index.ts b/packages/platform-node/src/index.ts index 8fb1a0b869..1123d373e2 100644 --- a/packages/platform-node/src/index.ts +++ b/packages/platform-node/src/index.ts @@ -7,6 +7,26 @@ */ export * as Mime from "./Mime.ts" +/** + * @since 1.0.0 + */ +export * as NodeClusterRunnerHttp from "./NodeClusterRunnerHttp.ts" + +/** + * @since 1.0.0 + */ +export * as NodeClusterRunnerSocket from "./NodeClusterRunnerSocket.ts" + +/** + * @since 1.0.0 + */ +export * as NodeClusterShardManagerHttp from "./NodeClusterShardManagerHttp.ts" + +/** + * @since 1.0.0 + */ +export * as NodeClusterShardManagerSocket from "./NodeClusterShardManagerSocket.ts" + /** * @since 1.0.0 */ diff --git a/packages/platform-node/test/NodeHttpServer.test.ts b/packages/platform-node/test/NodeHttpServer.test.ts index 904cd2e4a4..1ffe5695ea 100644 --- a/packages/platform-node/test/NodeHttpServer.test.ts +++ b/packages/platform-node/test/NodeHttpServer.test.ts @@ -45,8 +45,8 @@ describe("HttpServer", () => { ({ id }) => todoResponse({ id, title: "test" }) ) ).pipe( - HttpRouter.toHttpEffect, - Effect.flatMap(HttpServer.serveEffect()) + HttpRouter.serve, + Layer.build ) const todo = yield* HttpClient.get("/todos/1").pipe( Effect.flatMap(HttpClientResponse.schemaBodyJson(Todo)) @@ -71,8 +71,8 @@ describe("HttpServer", () => { return yield* HttpServerResponse.json({ ok: "file" in formData }) }) ).pipe( - HttpRouter.toHttpEffect, - Effect.flatMap(HttpServer.serveEffect()) + HttpRouter.serve, + Layer.build ) const client = yield* HttpClient.HttpClient const formData = new FormData() @@ -98,8 +98,8 @@ describe("HttpServer", () => { return HttpServerResponse.empty() }) ).pipe( - HttpRouter.toHttpEffect, - Effect.flatMap(HttpServer.serveEffect()) + HttpRouter.serve, + Layer.build ) const client = yield* HttpClient.HttpClient const formData = new FormData() @@ -125,8 +125,8 @@ describe("HttpServer", () => { Effect.fail(error)) ) ).pipe( - HttpRouter.toHttpEffect, - Effect.flatMap(HttpServer.serveEffect()), + HttpRouter.serve, + Layer.build, Effect.provideService(Multipart.MaxFileSize, Option.some(100)) ) const client = yield* HttpClient.HttpClient @@ -153,8 +153,8 @@ describe("HttpServer", () => { Effect.fail(error)) ) ).pipe( - HttpRouter.toHttpEffect, - Effect.flatMap(HttpServer.serveEffect()), + HttpRouter.serve, + Layer.build, Effect.provideService(Multipart.MaxFieldSize, 100) ) const client = yield* HttpClient.HttpClient @@ -169,8 +169,8 @@ describe("HttpServer", () => { Effect.gen(function*() { const child = Effect.map(HttpServerRequest.HttpServerRequest.asEffect(), (_) => HttpServerResponse.text(_.url)) yield* HttpRouter.use((router) => router.prefixed("/child").add("*", "*", child)).pipe( - HttpRouter.toHttpEffect, - Effect.flatMap(HttpServer.serveEffect()) + HttpRouter.serve, + Layer.build ) const client = yield* HttpClient.HttpClient const todo = yield* client.get("/child/1").pipe(Effect.flatMap((_) => _.text)) @@ -263,8 +263,8 @@ describe("HttpServer", () => { ({ id, title }) => todoResponse({ id, title }) ) ).pipe( - HttpRouter.toHttpEffect, - Effect.flatMap(HttpServer.serveEffect()) + HttpRouter.serve, + Layer.build ) const todo = yield* HttpClientRequest.post("/todos").pipe( HttpClientRequest.bodyUrlParams({ id: "1", title: "test" }), @@ -290,8 +290,8 @@ describe("HttpServer", () => { Effect.succeed(HttpServerResponse.unsafeJson({ error }, { status: 400 }))) ) ).pipe( - HttpRouter.toHttpEffect, - Effect.flatMap(HttpServer.serveEffect()) + HttpRouter.serve, + Layer.build ) const client = yield* HttpClient.HttpClient const response = yield* client.get("/todos") @@ -311,8 +311,8 @@ describe("HttpServer", () => { return HttpServerResponse.empty() }) ).pipe( - HttpRouter.toHttpEffect, - Effect.flatMap(HttpServer.serveEffect()) + HttpRouter.serve, + Layer.build ) const client = yield* HttpClient.HttpClient const formData = new FormData() @@ -335,8 +335,8 @@ describe("HttpServer", () => { return HttpServerResponse.empty() }) ).pipe( - HttpRouter.toHttpEffect, - Effect.flatMap(HttpServer.serveEffect()) + HttpRouter.serve, + Layer.build ) const client = yield* HttpClient.HttpClient const formData = new FormData() @@ -362,8 +362,8 @@ describe("HttpServer", () => { return HttpServerResponse.empty() }) ).pipe( - HttpRouter.toHttpEffect, - Effect.flatMap(HttpServer.serveEffect()) + HttpRouter.serve, + Layer.build ) const client = yield* HttpClient.HttpClient const response = yield* client.post("/upload", { @@ -384,8 +384,8 @@ describe("HttpServer", () => { (_) => HttpServerResponse.json({ spanId: _.spanId, parent: _.parent }) ) ).pipe( - HttpRouter.toHttpEffect, - Effect.flatMap(HttpServer.serveEffect()) + HttpRouter.serve, + Layer.build ) const client = yield* HttpClient.HttpClient const requestSpan = yield* Effect.makeSpan("client request") @@ -424,8 +424,8 @@ describe("HttpServer", () => { HttpServerResponse.htmlStream`${Stream.make("", 123, "hello")}` ) ]).pipe( - HttpRouter.toHttpEffect, - Effect.flatMap(HttpServer.serveEffect()) + HttpRouter.serve, + Layer.build ) const client = yield* HttpClient.HttpClient const home = yield* client.get("/home").pipe(Effect.flatMap((r) => r.text)) @@ -455,8 +455,8 @@ describe("HttpServer", () => { }) ) ).pipe( - HttpRouter.toHttpEffect, - Effect.flatMap(HttpServer.serveEffect()) + HttpRouter.serve, + Layer.build ) const client = yield* HttpClient.HttpClient const res = yield* client.get("/home") @@ -491,8 +491,8 @@ describe("HttpServer", () => { }), { uninterruptible: true } ).pipe( - HttpRouter.toHttpEffect, - Effect.flatMap(HttpServer.serveEffect()) + HttpRouter.serve, + Layer.build ) const client = yield* HttpClient.HttpClient const res = yield* client.get("/home") @@ -515,8 +515,8 @@ describe("HttpServer", () => { "/home", new CustomError({ name: "test" }).asEffect() ).pipe( - HttpRouter.toHttpEffect, - Effect.flatMap(HttpServer.serveEffect()) + HttpRouter.serve, + Layer.build ) const client = yield* HttpClient.HttpClient const res = yield* client.get("/home") @@ -533,8 +533,8 @@ describe("HttpServer", () => { "/:param", Effect.succeed(HttpServerResponse.empty()) ).pipe( - HttpRouter.toHttpEffect, - Effect.flatMap(HttpServer.serveEffect()) + HttpRouter.serve, + Layer.build ) let res = yield* HttpClient.get("/123456") assert.strictEqual(res.status, 404) @@ -549,7 +549,7 @@ describe("HttpServer", () => { it.effect("HttpRouter prefixed", () => Effect.gen(function*() { - const handler = yield* HttpRouter.toHttpEffect(HttpRouter.use(Effect.fnUntraced(function*(router_) { + const handler = HttpRouter.serve(HttpRouter.use(Effect.fnUntraced(function*(router_) { const router = router_.prefixed("/todos") yield* router.add( "GET", @@ -564,7 +564,7 @@ describe("HttpServer", () => { ]) }))) - yield* HttpServer.serveEffect(handler) + yield* Layer.build(handler) const todo = yield* HttpClient.get("/todos/1").pipe( Effect.flatMap(HttpClientResponse.schemaBodyJson(Todo)) diff --git a/packages/platform-node/test/cluster/MessageStorageTest.ts b/packages/platform-node/test/cluster/MessageStorageTest.ts new file mode 120000 index 0000000000..199cc74c29 --- /dev/null +++ b/packages/platform-node/test/cluster/MessageStorageTest.ts @@ -0,0 +1 @@ +../../../effect/test/cluster/MessageStorage.test.ts \ No newline at end of file diff --git a/packages/platform-node/test/cluster/SqlMessageStorage.test.ts b/packages/platform-node/test/cluster/SqlMessageStorage.test.ts new file mode 100644 index 0000000000..3e9722fe36 --- /dev/null +++ b/packages/platform-node/test/cluster/SqlMessageStorage.test.ts @@ -0,0 +1,196 @@ +import { NodeFileSystem } from "@effect/platform-node" +import { SqliteClient } from "@effect/sql-sqlite-node" +import { describe, expect, it } from "@effect/vitest" +import { Effect, Fiber, Layer } from "effect" +import { FileSystem } from "effect/platform" +import { TestClock } from "effect/testing" +import { Message, MessageStorage, ShardingConfig, Snowflake, SqlMessageStorage } from "effect/unstable/cluster" +import { SqlClient } from "effect/unstable/sql" +import { MysqlContainer } from "../fixtures/mysql2-utils.ts" +import { PgContainer } from "../fixtures/pg-utils.ts" +import { + makeAckChunk, + makeChunkReply, + makeReply, + makeRequest, + PrimaryKeyTest, + StreamRpc +} from "./MessageStorageTest.ts" + +const StorageLive = SqlMessageStorage.layer.pipe( + Layer.provideMerge(Snowflake.layerGenerator), + Layer.provide(ShardingConfig.layerDefaults) +) + +const truncate = Effect.gen(function*() { + const sql = yield* SqlClient.SqlClient + yield* sql`DELETE FROM cluster_replies` + yield* sql`DELETE FROM cluster_messages` +}) + +describe("SqlMessageStorage", () => { + ;([ + ["pg", Layer.orDie(PgContainer.layerClient)], + ["mysql", Layer.orDie(MysqlContainer.layerClient)], + ["sqlite", Layer.orDie(SqliteLayer)] + ] as const).forEach(([label, layer]) => { + it.layer(StorageLive.pipe(Layer.provideMerge(layer)), { + timeout: 30000 + })(label, (it) => { + it.effect("saveRequest", () => + Effect.gen(function*() { + const storage = yield* MessageStorage.MessageStorage + const request = yield* makeRequest() + const result = yield* storage.saveRequest(request) + expect(result._tag).toEqual("Success") + + const messages = yield* storage.unprocessedMessages([request.envelope.address.shardId]) + expect(messages).toHaveLength(1) + })) + + it.effect("saveReply + saveRequest duplicate", () => + Effect.gen(function*() { + const sql = yield* SqlClient.SqlClient + const storage = yield* MessageStorage.MessageStorage + const request = yield* makeRequest({ + rpc: StreamRpc, + payload: StreamRpc.payloadSchema.makeSync({ id: 123 }) + }) + let result = yield* storage.saveRequest(request) + expect(result._tag).toEqual("Success") + + let chunk = yield* makeChunkReply(request, 0) + yield* storage.saveReply(chunk) + const ackChunk = yield* makeAckChunk(request, chunk) + yield* storage.saveEnvelope(ackChunk) + + chunk = yield* makeChunkReply(request, 1) + yield* storage.saveReply(chunk) + + result = yield* storage.saveRequest( + yield* makeRequest({ + rpc: StreamRpc, + payload: StreamRpc.payloadSchema.makeSync({ id: 123 }) + }) + ) + expect(result._tag === "Duplicate" && result.lastReceivedReply._tag).toEqual("Some") + + // get the un-acked chunk + const replies = yield* storage.repliesFor([request]) + expect(replies).toHaveLength(1) + + yield* storage.saveReply(yield* makeReply(request)) + // duplicate WithExit + const fiber = yield* storage.saveReply(yield* makeReply(request)).pipe(Effect.fork) + yield* TestClock.adjust(1) + while (!fiber.unsafePoll()) { + yield* sql`SELECT 1` + yield* TestClock.adjust(1000) + } + const error = yield* Effect.flip(Fiber.join(fiber)) + expect(error._tag).toEqual("PersistenceError") + })) + + it.effect("detects duplicates", () => + Effect.gen(function*() { + yield* truncate + + const storage = yield* MessageStorage.MessageStorage + yield* storage.saveRequest( + yield* makeRequest({ + rpc: PrimaryKeyTest, + payload: PrimaryKeyTest.payloadSchema.makeSync({ id: 123 }) + }) + ) + const result = yield* storage.saveRequest( + yield* makeRequest({ + rpc: PrimaryKeyTest, + payload: PrimaryKeyTest.payloadSchema.makeSync({ id: 123 }) + }) + ) + expect(result._tag).toEqual("Duplicate") + })) + + it.effect("unprocessedMessages", () => + Effect.gen(function*() { + yield* truncate + + const storage = yield* MessageStorage.MessageStorage + const request = yield* makeRequest() + yield* storage.saveRequest(request) + let messages = yield* storage.unprocessedMessages([request.envelope.address.shardId]) + expect(messages).toHaveLength(1) + messages = yield* storage.unprocessedMessages([request.envelope.address.shardId]) + expect(messages).toHaveLength(0) + yield* storage.saveRequest(yield* makeRequest()) + messages = yield* storage.unprocessedMessages([request.envelope.address.shardId]) + expect(messages).toHaveLength(1) + })) + + it.effect("unprocessedMessages excludes complete requests", () => + Effect.gen(function*() { + yield* truncate + + const storage = yield* MessageStorage.MessageStorage + const request = yield* makeRequest() + yield* storage.saveRequest(request) + yield* storage.saveReply(yield* makeReply(request)) + const messages = yield* storage.unprocessedMessages([request.envelope.address.shardId]) + expect(messages).toHaveLength(0) + })) + + it.effect("repliesFor", () => + Effect.gen(function*() { + yield* truncate + + const storage = yield* MessageStorage.MessageStorage + const request = yield* makeRequest() + yield* storage.saveRequest(request) + let replies = yield* storage.repliesFor([request]) + expect(replies).toHaveLength(0) + yield* storage.saveReply(yield* makeReply(request)) + replies = yield* storage.repliesFor([request]) + expect(replies).toHaveLength(1) + expect(replies[0].requestId).toEqual(request.envelope.requestId) + })) + + it.effect("registerReplyHandler", () => + Effect.gen(function*() { + const storage = yield* MessageStorage.MessageStorage + const latch = yield* Effect.makeLatch() + const request = yield* makeRequest() + yield* storage.saveRequest(request) + yield* storage.registerReplyHandler( + new Message.OutgoingRequest({ + ...request, + respond: () => latch.open + }) + ) + yield* storage.saveReply(yield* makeReply(request)) + yield* latch.await + })) + + it.effect("unprocessedMessagesById", () => + Effect.gen(function*() { + yield* truncate + + const storage = yield* MessageStorage.MessageStorage + const request = yield* makeRequest() + yield* storage.saveRequest(request) + let messages = yield* storage.unprocessedMessagesById([request.envelope.requestId]) + expect(messages).toHaveLength(1) + yield* storage.saveReply(yield* makeReply(request)) + messages = yield* storage.unprocessedMessagesById([request.envelope.requestId]) + expect(messages).toHaveLength(0) + })) + }) + }) +}) + +const SqliteLayer = Effect.gen(function*() { + const fs = yield* FileSystem.FileSystem + const dir = yield* fs.makeTempDirectoryScoped() + return SqliteClient.layer({ + filename: dir + "/test.db" + }) +}).pipe(Layer.unwrap, Layer.provide(NodeFileSystem.layer)) diff --git a/packages/platform-node/test/cluster/SqlShardStorage.test.ts b/packages/platform-node/test/cluster/SqlShardStorage.test.ts new file mode 100644 index 0000000000..f8e86ea882 --- /dev/null +++ b/packages/platform-node/test/cluster/SqlShardStorage.test.ts @@ -0,0 +1,107 @@ +import { NodeFileSystem } from "@effect/platform-node" +import { SqliteClient } from "@effect/sql-sqlite-node" +import { describe, expect, it } from "@effect/vitest" +import { Effect, Layer } from "effect" +import { MutableHashSet } from "effect/collections" +import { Option } from "effect/data" +import { Equal } from "effect/interfaces" +import { FileSystem } from "effect/platform" +import { Runner, RunnerAddress, ShardId, ShardStorage, SqlShardStorage } from "effect/unstable/cluster" +import { MysqlContainer } from "../fixtures/mysql2-utils.ts" +import { PgContainer } from "../fixtures/pg-utils.ts" + +const StorageLive = SqlShardStorage.layer + +describe("SqlMessageStorage", () => { + ;([ + ["pg", Layer.orDie(PgContainer.layerClient)], + ["mysql", Layer.orDie(MysqlContainer.layerClient)], + ["sqlite", Layer.orDie(SqliteLayer)] + ] as const).forEach(([label, layer]) => { + it.layer(StorageLive.pipe(Layer.provideMerge(layer)), { + timeout: 30000 + })(label, (it) => { + it.effect("saveRunners", () => + Effect.gen(function*() { + const storage = yield* ShardStorage.ShardStorage + + yield* storage.saveRunners([[ + runnerAddress1, + Runner.make({ + address: runnerAddress1, + groups: ["default"], + version: 1 + }) + ]]) + expect(yield* storage.getRunners).toEqual([[ + runnerAddress1, + Runner.make({ + address: runnerAddress1, + groups: ["default"], + version: 1 + }) + ]]) + }).pipe(Effect.repeat({ times: 2 }))) + + it.effect("saveAssignments", () => + Effect.gen(function*() { + const storage = yield* ShardStorage.ShardStorage + + yield* storage.saveAssignments([ + [ShardId.make("default", 1), Option.some(runnerAddress1)], + [ShardId.make("default", 2), Option.none()] + ]) + expect(Equal.equals( + yield* storage.getAssignments, + MutableHashSet.fromIterable([ + [ShardId.make("default", 1), Option.some(runnerAddress1)], + [ShardId.make("default", 2), Option.none()] + ]) + )) + }).pipe(Effect.repeat({ times: 2 }))) + + it.effect("acquireShards", () => + Effect.gen(function*() { + const storage = yield* ShardStorage.ShardStorage + + let acquired = yield* storage.acquire(runnerAddress1, [ + ShardId.make("default", 1), + ShardId.make("default", 2), + ShardId.make("default", 3) + ]) + expect(acquired.map((_) => _.id)).toEqual([1, 2, 3]) + acquired = yield* storage.acquire(runnerAddress1, [ + ShardId.make("default", 1), + ShardId.make("default", 2), + ShardId.make("default", 3) + ]) + expect(acquired.map((_) => _.id)).toEqual([1, 2, 3]) + + const refreshed = yield* storage.refresh(runnerAddress1, [ + ShardId.make("default", 1), + ShardId.make("default", 2), + ShardId.make("default", 3) + ]) + expect(refreshed.map((_) => _.id)).toEqual([1, 2, 3]) + + acquired = yield* storage.acquire(runnerAddress2, [ + ShardId.make("default", 1), + ShardId.make("default", 2), + ShardId.make("default", 3) + ]) + expect(acquired).toEqual([]) + })) + }) + }) +}) + +const runnerAddress1 = RunnerAddress.make("localhost", 1234) +const runnerAddress2 = RunnerAddress.make("localhost", 1235) + +const SqliteLayer = Effect.gen(function*() { + const fs = yield* FileSystem.FileSystem + const dir = yield* fs.makeTempDirectoryScoped() + return SqliteClient.layer({ + filename: dir + "/test.db" + }) +}).pipe(Layer.unwrap, Layer.provide(NodeFileSystem.layer)) diff --git a/packages/platform-node/test/fixtures/mysql2-utils.ts b/packages/platform-node/test/fixtures/mysql2-utils.ts new file mode 120000 index 0000000000..78c6ff9fb2 --- /dev/null +++ b/packages/platform-node/test/fixtures/mysql2-utils.ts @@ -0,0 +1 @@ +../../../sql/mysql2/test/utils.ts \ No newline at end of file diff --git a/packages/platform-node/test/fixtures/pg-utils.ts b/packages/platform-node/test/fixtures/pg-utils.ts new file mode 120000 index 0000000000..9b44f07132 --- /dev/null +++ b/packages/platform-node/test/fixtures/pg-utils.ts @@ -0,0 +1 @@ +../../../sql/pg/test/utils.ts \ No newline at end of file diff --git a/packages/platform-node/tsconfig.test.json b/packages/platform-node/tsconfig.test.json index 1afeb3b58c..e2cbc0f090 100644 --- a/packages/platform-node/tsconfig.test.json +++ b/packages/platform-node/tsconfig.test.json @@ -2,7 +2,12 @@ "$schema": "http://json.schemastore.org/tsconfig", "extends": "../../tsconfig.base.jsonc", "include": ["test/**/*.ts", "test/**/*.json"], - "references": [{ "path": "tsconfig.src.json" }], + "references": [ + { "path": "tsconfig.src.json" }, + { "path": "../sql/pg/tsconfig.src.json" }, + { "path": "../sql/mysql2/tsconfig.src.json" }, + { "path": "../sql/sqlite-node/tsconfig.src.json" } + ], "compilerOptions": { "tsBuildInfoFile": ".tsbuildinfo/test.tsbuildinfo", "outDir": ".tsbuildinfo/test", @@ -13,7 +18,13 @@ "baseUrl": ".", "paths": { "@effect/platform-node": ["src/index.ts"], - "@effect/platform-node/*": ["src/*/index.ts", "src/*.ts"] + "@effect/platform-node/*": ["src/*/index.ts", "src/*.ts"], + "@effect/sql-mysql2": ["../sql/mysql2/src/index.ts"], + "@effect/sql-mysql2/*": ["../sql/mysql2/src/*.ts"], + "@effect/sql-pg": ["../sql/pg/src/index.ts"], + "@effect/sql-pg/*": ["../sql/pg/src/*.ts"], + "@effect/sql-sqlite-node": ["../sql/sqlite-node/src/index.ts"], + "@effect/sql-sqlite-node/*": ["../sql/sqlite-node/src/*.ts"] }, "plugins": [ { diff --git a/packages/sql/clickhouse/LICENSE b/packages/sql/clickhouse/LICENSE new file mode 100644 index 0000000000..7f6fe480f7 --- /dev/null +++ b/packages/sql/clickhouse/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023-present The Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/sql/clickhouse/README.md b/packages/sql/clickhouse/README.md new file mode 100644 index 0000000000..15d5a7faa8 --- /dev/null +++ b/packages/sql/clickhouse/README.md @@ -0,0 +1,7 @@ +# `@effect/sql-clickhouse` + +An `@effect/sql` implementation for [ClickHouse](https://clickhouse.com/). + +## Documentation + +- **API Reference**: [View the full documentation](https://effect-ts.github.io/effect/docs/sql-clickhouse). diff --git a/packages/sql/clickhouse/docgen.json b/packages/sql/clickhouse/docgen.json new file mode 100644 index 0000000000..8c0e7b2298 --- /dev/null +++ b/packages/sql/clickhouse/docgen.json @@ -0,0 +1,20 @@ +{ + "$schema": "../../node_modules/@effect/docgen/schema.json", + "srcLink": "https://github.com/Effect-TS/effect/tree/main/packages/sql/clickhouse/src/", + "exclude": ["src/internal/**/*.ts"], + "examplesCompilerOptions": { + "noEmit": true, + "strict": true, + "skipLibCheck": true, + "moduleResolution": "Bundler", + "module": "ES2022", + "target": "ES2022", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "rewriteRelativeImportExtensions": true, + "allowImportingTsExtensions": true, + "paths": { + "effect": ["../../../effect/src/index.js"], + "effect/*": ["../../../effect/src/*.js"] + } + } +} diff --git a/packages/sql/clickhouse/package.json b/packages/sql/clickhouse/package.json new file mode 100644 index 0000000000..c3931de205 --- /dev/null +++ b/packages/sql/clickhouse/package.json @@ -0,0 +1,69 @@ +{ + "name": "@effect/sql-clickhouse", + "version": "0.38.1", + "type": "module", + "license": "MIT", + "description": "A Clickhouse toolkit for Effect", + "homepage": "https://effect.website", + "repository": { + "type": "git", + "url": "https://github.com/Effect-TS/effect.git", + "directory": "packages/sql/clickhouse" + }, + "bugs": { + "url": "https://github.com/Effect-TS/effect/issues" + }, + "tags": [ + "typescript", + "sql", + "database" + ], + "keywords": [ + "typescript", + "sql", + "database" + ], + "sideEffects": [], + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts", + "./*": "./src/*.ts", + "./internal/*": null, + "./*/index": null + }, + "files": [ + "src/**/*.ts", + "dist/**/*.js", + "dist/**/*.js.map", + "dist/**/*.d.ts", + "dist/**/*.d.ts.map" + ], + "publishConfig": { + "provenance": true, + "exports": { + "./package.json": "./package.json", + ".": "./dist/index.js", + "./*": "./dist/*.js", + "./internal/*": null, + "./*/index": null + } + }, + "scripts": { + "codegen": "build-utils prepare-v4", + "build": "tsc -b tsconfig.build.json && babel dist --plugins annotate-pure-calls --out-dir dist --source-maps", + "check": "tsc -b tsconfig.json", + "test": "vitest", + "coverage": "vitest --coverage" + }, + "devDependencies": { + "@effect/platform-node": "workspace:^", + "effect": "workspace:^" + }, + "peerDependencies": { + "@effect/platform-node": "workspace:^", + "effect": "workspace:^" + }, + "dependencies": { + "@clickhouse/client": "^1.6.0" + } +} diff --git a/packages/sql/clickhouse/src/ClickhouseClient.ts b/packages/sql/clickhouse/src/ClickhouseClient.ts new file mode 100644 index 0000000000..5fd860d389 --- /dev/null +++ b/packages/sql/clickhouse/src/ClickhouseClient.ts @@ -0,0 +1,425 @@ +/** + * @since 1.0.0 + */ +import * as Clickhouse from "@clickhouse/client" +import * as NodeStream from "@effect/platform-node/NodeStream" +import * as Config from "effect/config/Config" +import * as Effect from "effect/Effect" +import * as Fiber from "effect/Fiber" +import { dual } from "effect/Function" +import * as Layer from "effect/Layer" +import type * as Scope from "effect/Scope" +import * as ServiceMap from "effect/ServiceMap" +import * as Stream from "effect/stream/Stream" +import * as Duration from "effect/time/Duration" +import * as Reactivity from "effect/unstable/reactivity/Reactivity" +import * as Client from "effect/unstable/sql/SqlClient" +import type { Connection } from "effect/unstable/sql/SqlConnection" +import { SqlError } from "effect/unstable/sql/SqlError" +import type { Primitive } from "effect/unstable/sql/Statement" +import * as Statement from "effect/unstable/sql/Statement" +import * as Crypto from "node:crypto" +import type { Readable } from "node:stream" + +const ATTR_DB_SYSTEM_NAME = "db.system.name" +const ATTR_DB_NAMESPACE = "db.namespace" + +/** + * @category type ids + * @since 1.0.0 + */ +export const TypeId: TypeId = "~@effect/sql-clickhouse/ClickhouseClient" + +/** + * @category type ids + * @since 1.0.0 + */ +export type TypeId = "~@effect/sql-clickhouse/ClickhouseClient" + +/** + * @category models + * @since 1.0.0 + */ +export interface ClickhouseClient extends Client.SqlClient { + readonly [TypeId]: TypeId + readonly config: ClickhouseClientConfig + readonly param: (dataType: string, value: Statement.Primitive) => Statement.Fragment + readonly asCommand: (effect: Effect.Effect) => Effect.Effect + readonly insertQuery: (options: { + readonly table: string + readonly values: Clickhouse.InsertValues + readonly format?: Clickhouse.DataFormat + }) => Effect.Effect + readonly withQueryId: { + (queryId: string): (effect: Effect.Effect) => Effect.Effect + (effect: Effect.Effect, queryId: string): Effect.Effect + } + readonly withClickhouseSettings: { + ( + settings: NonNullable + ): (effect: Effect.Effect) => Effect.Effect + ( + effect: Effect.Effect, + settings: NonNullable + ): Effect.Effect + } +} + +/** + * @category tags + * @since 1.0.0 + */ +export const ClickhouseClient = ServiceMap.Key("@effect/sql-clickhouse/ClickhouseClient") + +/** + * @category constructors + * @since 1.0.0 + */ +export interface ClickhouseClientConfig extends Clickhouse.ClickHouseClientConfigOptions { + readonly spanAttributes?: Record | undefined + readonly transformResultNames?: ((str: string) => string) | undefined + readonly transformQueryNames?: ((str: string) => string) | undefined +} + +/** + * @category constructors + * @since 1.0.0 + */ +export const make = ( + options: ClickhouseClientConfig +): Effect.Effect => + Effect.gen(function*() { + const compiler = makeCompiler(options.transformQueryNames) + const transformRows = options.transformResultNames + ? Statement.defaultTransforms(options.transformResultNames).array + : undefined + + const client = Clickhouse.createClient(options) + + yield* Effect.acquireRelease( + Effect.tryPromise({ + try: () => client.exec({ query: "SELECT 1" }), + catch: (cause) => new SqlError({ cause, message: "ClickhouseClient: Failed to connect" }) + }), + () => Effect.promise(() => client.close()) + ).pipe( + Effect.timeoutOrElse({ + duration: Duration.seconds(5), + onTimeout: () => + Effect.fail( + new SqlError({ + message: "ClickhouseClient: Connection timeout", + cause: new Error("connection timeout") + }) + ) + }) + ) + + class ConnectionImpl implements Connection { + private conn: Clickhouse.ClickHouseClient + constructor(conn: Clickhouse.ClickHouseClient) { + this.conn = conn + } + + private runRaw(sql: string, params: ReadonlyArray, format: Clickhouse.DataFormat = "JSON") { + const paramsObj: Record = {} + for (let i = 0; i < params.length; i++) { + paramsObj[`p${i + 1}`] = params[i] + } + return Effect.withFiber | Clickhouse.CommandResult, SqlError>((fiber) => { + const method = fiber.getRef(ClientMethod) + return Effect.callback | Clickhouse.CommandResult, SqlError>((resume) => { + const queryId = fiber.getRef(QueryId) ?? Crypto.randomUUID() + const settings = fiber.getRef(ClickhouseSettings) + const controller = new AbortController() + if (method === "command") { + this.conn.command({ + query: sql, + query_params: paramsObj, + abort_signal: controller.signal, + query_id: queryId, + clickhouse_settings: settings + }).then( + (result) => resume(Effect.succeed(result)), + (cause) => resume(Effect.fail(new SqlError({ cause, message: "Failed to execute statement" }))) + ) + } else { + this.conn.query({ + query: sql, + query_params: paramsObj, + abort_signal: controller.signal, + query_id: queryId, + clickhouse_settings: settings, + format + }).then( + (result) => resume(Effect.succeed(result)), + (cause) => resume(Effect.fail(new SqlError({ cause, message: "Failed to execute statement" }))) + ) + } + return Effect.suspend(() => { + controller.abort() + return Effect.promise(() => this.conn.command({ query: `KILL QUERY WHERE query_id = '${queryId}'` })) + }) + }) + }) + } + + private run(sql: string, params: ReadonlyArray, format?: Clickhouse.DataFormat) { + return this.runRaw(sql, params, format).pipe( + Effect.flatMap((result) => { + if ("json" in result) { + return Effect.promise(() => + result.json().then( + (result) => "data" in result ? result.data : result as any, + () => [] + ) + ) + } + return Effect.succeed([]) + }) + ) + } + + execute( + sql: string, + params: ReadonlyArray, + transformRows: ((row: ReadonlyArray) => ReadonlyArray) | undefined + ) { + return transformRows + ? Effect.map(this.run(sql, params), transformRows) + : this.run(sql, params) + } + executeRaw(sql: string, params: ReadonlyArray) { + return this.runRaw(sql, params) + } + executeValues(sql: string, params: ReadonlyArray) { + return this.run(sql, params, "JSONCompact") + } + executeUnprepared(sql: string, params: ReadonlyArray, transformRows?: any) { + return this.execute(sql, params, transformRows) + } + executeStream( + sql: string, + params: ReadonlyArray, + transformRows: ((row: ReadonlyArray) => ReadonlyArray) | undefined + ) { + return this.runRaw(sql, params, "JSONEachRow").pipe( + Effect.map((result) => { + if (!("stream" in result)) { + return Stream.empty + } + return NodeStream.fromReadable>, SqlError>({ + evaluate: () => result.stream() as any, + onError: (cause) => new SqlError({ cause, message: "Failed to execute stream" }) + }) + }), + Stream.unwrap, + Stream.chunks, + Stream.mapEffect((chunk) => { + const promises: Array> = [] + for (const rows of chunk) { + for (const row of rows) { + promises.push(row.json()) + } + } + return Effect.tryPromise({ + try: () => Promise.all(promises).then((rows) => transformRows ? transformRows(rows) : rows), + catch: (cause) => new SqlError({ cause, message: "Failed to parse row" }) + }) + }), + Stream.flattenIterable + ) + } + } + + const connection = new ConnectionImpl(client) + + return Object.assign( + yield* Client.make({ + acquirer: Effect.succeed(connection), + compiler, + spanAttributes: [ + ...(options.spanAttributes ? Object.entries(options.spanAttributes) : []), + [ATTR_DB_SYSTEM_NAME, "clickhouse"], + [ATTR_DB_NAMESPACE, options.database ?? "default"] + ], + beginTransaction: "BEGIN TRANSACTION", + transformRows + }), + { + [TypeId]: TypeId as TypeId, + config: options, + param(dataType: string, value: Statement.Primitive) { + return Statement.fragment([clickhouseParam(dataType, value)]) + }, + asCommand(effect: Effect.Effect) { + return Effect.provideService(effect, ClientMethod, "command") + }, + insertQuery(options: { + readonly table: string + readonly values: Clickhouse.InsertValues + readonly format?: Clickhouse.DataFormat + }) { + return Effect.callback((resume) => { + const fiber = Fiber.getCurrent()! + const queryId = fiber.getRef(QueryId) ?? Crypto.randomUUID() + const settings = fiber.getRef(ClickhouseSettings) + const controller = new AbortController() + client.insert({ + format: "JSONEachRow", + ...options, + abort_signal: controller.signal, + query_id: queryId, + clickhouse_settings: settings + }).then( + (result) => resume(Effect.succeed(result)), + (cause) => resume(Effect.fail(new SqlError({ cause, message: "Failed to insert data" }))) + ) + return Effect.suspend(() => { + controller.abort() + return Effect.promise(() => client.command({ query: `KILL QUERY WHERE query_id = '${queryId}'` })) + }) + }) + }, + withQueryId: dual(2, (effect: Effect.Effect, queryId: string) => + Effect.provideService(effect, QueryId, queryId)), + withClickhouseSettings: dual( + 2, + ( + effect: Effect.Effect, + settings: NonNullable + ) => + Effect.provideService(effect, ClickhouseSettings, settings) + ) + } + ) + }) + +/** + * @category References + * @since 1.0.0 + */ +export const ClientMethod = ServiceMap.Reference<"query" | "command" | "insert">( + "@effect/sql-clickhouse/ClickhouseClient/ClientMethod", + { + defaultValue: () => "query" + } +) + +/** + * @category References + * @since 1.0.0 + */ +export const QueryId = ServiceMap.Reference( + "@effect/sql-clickhouse/ClickhouseClient/QueryId", + { defaultValue: () => undefined } +) + +/** + * @category References + * @since 1.0.0 + */ +export const ClickhouseSettings: ServiceMap.Reference< + NonNullable +> = ServiceMap.Reference("@effect/sql-clickhouse/ClickhouseClient/ClickhouseSettings", { + defaultValue: () => ({}) +}) + +/** + * @category layers + * @since 1.0.0 + */ +export const layerConfig = ( + config: Config.Wrap +): Layer.Layer => + Layer.effectServices( + Config.unwrap(config).asEffect().pipe( + Effect.flatMap(make), + Effect.map((client) => + ServiceMap.make(ClickhouseClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + ) + ) + ) + ).pipe(Layer.provide(Reactivity.layer)) + +/** + * @category layers + * @since 1.0.0 + */ +export const layer = ( + config: ClickhouseClientConfig +): Layer.Layer => + Layer.effectServices( + Effect.map(make(config), (client) => + ServiceMap.make(ClickhouseClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + )) + ).pipe(Layer.provide(Reactivity.layer)) + +const typeFromUnknown = (value: unknown): string => { + if (Statement.isFragment(value)) { + return typeFromUnknown(value.segments[0]) + } else if (isClickhouseParam(value)) { + return value.paramA + } else if (Array.isArray(value)) { + return `Array(${typeFromUnknown(value[0])})` + } + switch (typeof value) { + case "number": + return "Decimal" + case "bigint": + return "Int64" + case "boolean": + return "Bool" + case "object": + if (value instanceof Date) { + return "DateTime()" + } + return "String" + default: + return "String" + } +} + +/** + * @category compiler + * @since 1.0.0 + */ +export const makeCompiler = (transform?: (_: string) => string) => + Statement.makeCompiler({ + dialect: "sqlite", + placeholder(i, u) { + return `{p${i}: ${typeFromUnknown(u)}}` + }, + onIdentifier: transform ? + function(value, withoutTransform) { + return withoutTransform ? escape(value) : escape(transform(value)) + } : + escape, + onRecordUpdate() { + return ["", []] + }, + onCustom(type, placeholder) { + return [placeholder(type), [type.paramB]] + } + }) + +// compiler helpers + +const escape = Statement.defaultEscape("\"") + +/** + * @category custom types + * @since 1.0.0 + */ +export type ClickhouseCustom = ClickhouseParam + +/** + * @category custom types + * @since 1.0.0 + */ +interface ClickhouseParam extends Statement.Custom<"ClickhouseParam", string, Statement.Primitive> {} + +const clickhouseParam = Statement.custom("ClickhouseParam") +const isClickhouseParam = Statement.isCustom("ClickhouseParam") diff --git a/packages/sql/clickhouse/src/ClickhouseMigrator.ts b/packages/sql/clickhouse/src/ClickhouseMigrator.ts new file mode 100644 index 0000000000..0eb8f03cf6 --- /dev/null +++ b/packages/sql/clickhouse/src/ClickhouseMigrator.ts @@ -0,0 +1,37 @@ +/** + * @since 1.0.0 + */ +import type * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" +import * as Migrator from "effect/unstable/sql/Migrator" +import type * as Client from "effect/unstable/sql/SqlClient" +import type { SqlError } from "effect/unstable/sql/SqlError" + +/** + * @since 1.0.0 + */ +export * from "effect/unstable/sql/Migrator" + +/** + * @category constructor + * @since 1.0.0 + */ +export const run: ( + { loader, schemaDirectory, table }: Migrator.MigratorOptions +) => Effect.Effect< + ReadonlyArray, + Migrator.MigrationError | SqlError, + Client.SqlClient | R2 +> = Migrator.make({}) + +/** + * @category layers + * @since 1.0.0 + */ +export const layer = ( + options: Migrator.MigratorOptions +): Layer.Layer< + never, + Migrator.MigrationError | SqlError, + Client.SqlClient | R +> => Layer.effectDiscard(run(options)) diff --git a/packages/sql/clickhouse/src/index.ts b/packages/sql/clickhouse/src/index.ts new file mode 100644 index 0000000000..971e429099 --- /dev/null +++ b/packages/sql/clickhouse/src/index.ts @@ -0,0 +1,13 @@ +/** + * @since 1.0.0 + */ + +/** + * @since 1.0.0 + */ +export * as ClickhouseClient from "./ClickhouseClient.ts" + +/** + * @since 1.0.0 + */ +export * as ClickhouseMigrator from "./ClickhouseMigrator.ts" diff --git a/packages/sql/clickhouse/src/index.ts.tpl b/packages/sql/clickhouse/src/index.ts.tpl new file mode 100644 index 0000000000..b66408871c --- /dev/null +++ b/packages/sql/clickhouse/src/index.ts.tpl @@ -0,0 +1,3 @@ +/** + * @since 1.0.0 + */ diff --git a/packages/sql/clickhouse/test/Client.test.ts b/packages/sql/clickhouse/test/Client.test.ts new file mode 100644 index 0000000000..097065a237 --- /dev/null +++ b/packages/sql/clickhouse/test/Client.test.ts @@ -0,0 +1,6 @@ +import { describe, it } from "@effect/vitest" + +describe("ClickhouseClient", () => { + it("should work", () => { + }) +}) diff --git a/packages/sql/clickhouse/tsconfig.build.json b/packages/sql/clickhouse/tsconfig.build.json new file mode 100644 index 0000000000..e738132ff9 --- /dev/null +++ b/packages/sql/clickhouse/tsconfig.build.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "./tsconfig.src.json", + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", + "outDir": "dist", + "stripInternal": true + } +} diff --git a/packages/sql/clickhouse/tsconfig.json b/packages/sql/clickhouse/tsconfig.json new file mode 100644 index 0000000000..11922f5b68 --- /dev/null +++ b/packages/sql/clickhouse/tsconfig.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": [], + "references": [{ "path": "tsconfig.src.json" }, { "path": "tsconfig.test.json" }] +} diff --git a/packages/sql/clickhouse/tsconfig.src.json b/packages/sql/clickhouse/tsconfig.src.json new file mode 100644 index 0000000000..00f9cbaff4 --- /dev/null +++ b/packages/sql/clickhouse/tsconfig.src.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["src"], + "references": [{ "path": "../../effect/tsconfig.src.json" }, { "path": "../../platform-node/tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", + "outDir": ".tsbuildinfo/src", + "rootDir": "src", + "types": ["node"] + } +} diff --git a/packages/sql/clickhouse/tsconfig.test.json b/packages/sql/clickhouse/tsconfig.test.json new file mode 100644 index 0000000000..5cc8e5e642 --- /dev/null +++ b/packages/sql/clickhouse/tsconfig.test.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["test/**/*.ts", "test/**/*.json"], + "references": [{ "path": "tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/test.tsbuildinfo", + "outDir": ".tsbuildinfo/test", + "rootDir": "test", + "noEmit": true, + "erasableSyntaxOnly": false, + "resolveJsonModule": true, + "baseUrl": ".", + "paths": { + "@effect/sql-clickhouse": ["src/index.ts"], + "@effect/sql-clickhouse/*": ["src/*/index.ts", "src/*.ts"] + }, + "plugins": [ + { + "name": "@effect/language-service", + "namespaceImportPackages": [] + } + ] + } +} diff --git a/packages/sql/clickhouse/vitest.config.ts b/packages/sql/clickhouse/vitest.config.ts new file mode 100644 index 0000000000..c8a52c1826 --- /dev/null +++ b/packages/sql/clickhouse/vitest.config.ts @@ -0,0 +1,6 @@ +import { mergeConfig, type ViteUserConfig } from "vitest/config" +import shared from "../../../vitest.shared.ts" + +const config: ViteUserConfig = {} + +export default mergeConfig(shared, config) diff --git a/packages/sql/d1/LICENSE b/packages/sql/d1/LICENSE new file mode 100644 index 0000000000..7f6fe480f7 --- /dev/null +++ b/packages/sql/d1/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023-present The Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/sql/d1/README.md b/packages/sql/d1/README.md new file mode 100644 index 0000000000..54b8abfca9 --- /dev/null +++ b/packages/sql/d1/README.md @@ -0,0 +1,7 @@ +# `@effect/sql-d1` + +An `@effect/sql` implementation for [Cloudflare D1](https://developers.cloudflare.com/d1/). + +## Documentation + +- **API Reference**: [View the full documentation](https://effect-ts.github.io/effect/docs/sql-d1). diff --git a/packages/sql/d1/docgen.json b/packages/sql/d1/docgen.json new file mode 100644 index 0000000000..114f1a6c2f --- /dev/null +++ b/packages/sql/d1/docgen.json @@ -0,0 +1,20 @@ +{ + "$schema": "../../node_modules/@effect/docgen/schema.json", + "srcLink": "https://github.com/Effect-TS/effect/tree/main/packages/sql/d1/src/", + "exclude": ["src/internal/**/*.ts"], + "examplesCompilerOptions": { + "noEmit": true, + "strict": true, + "skipLibCheck": true, + "moduleResolution": "Bundler", + "module": "ES2022", + "target": "ES2022", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "rewriteRelativeImportExtensions": true, + "allowImportingTsExtensions": true, + "paths": { + "effect": ["../../../effect/src/index.js"], + "effect/*": ["../../../effect/src/*.js"] + } + } +} diff --git a/packages/sql/d1/package.json b/packages/sql/d1/package.json new file mode 100644 index 0000000000..4eb47b9f90 --- /dev/null +++ b/packages/sql/d1/package.json @@ -0,0 +1,72 @@ +{ + "name": "@effect/sql-d1", + "version": "0.42.1", + "type": "module", + "license": "MIT", + "description": "A Cloudflare D1 integration for Effect", + "homepage": "https://effect.website", + "repository": { + "type": "git", + "url": "https://github.com/Effect-TS/effect.git", + "directory": "packages/sql/d1" + }, + "bugs": { + "url": "https://github.com/Effect-TS/effect/issues" + }, + "tags": [ + "typescript", + "sql", + "database", + "cloudflare", + "D1" + ], + "keywords": [ + "typescript", + "sql", + "database", + "cloudflare", + "D1" + ], + "sideEffects": [], + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts", + "./*": "./src/*.ts", + "./internal/*": null, + "./*/index": null + }, + "files": [ + "src/**/*.ts", + "dist/**/*.js", + "dist/**/*.js.map", + "dist/**/*.d.ts", + "dist/**/*.d.ts.map" + ], + "publishConfig": { + "provenance": true, + "exports": { + "./package.json": "./package.json", + ".": "./dist/index.js", + "./*": "./dist/*.js", + "./internal/*": null, + "./*/index": null + } + }, + "scripts": { + "codegen": "build-utils prepare-v4", + "build": "tsc -b tsconfig.build.json && babel dist --plugins annotate-pure-calls --out-dir dist --source-maps", + "check": "tsc -b tsconfig.json", + "test": "vitest", + "coverage": "vitest --coverage" + }, + "devDependencies": { + "effect": "workspace:^", + "miniflare": "^4.20250508.0" + }, + "peerDependencies": { + "effect": "workspace:^" + }, + "dependencies": { + "@cloudflare/workers-types": "^4.20250515.0" + } +} diff --git a/packages/sql/d1/src/D1Client.ts b/packages/sql/d1/src/D1Client.ts new file mode 100644 index 0000000000..777284fa93 --- /dev/null +++ b/packages/sql/d1/src/D1Client.ts @@ -0,0 +1,216 @@ +/** + * @since 1.0.0 + */ +import type { D1Database, D1PreparedStatement } from "@cloudflare/workers-types" +import * as Cache from "effect/caching/Cache" +import * as Config from "effect/config/Config" +import * as Effect from "effect/Effect" +import { identity } from "effect/Function" +import * as Layer from "effect/Layer" +import type * as Scope from "effect/Scope" +import * as ServiceMap from "effect/ServiceMap" +import * as Stream from "effect/stream/Stream" +import * as Duration from "effect/time/Duration" +import * as Reactivity from "effect/unstable/reactivity/Reactivity" +import * as Client from "effect/unstable/sql/SqlClient" +import type { Connection } from "effect/unstable/sql/SqlConnection" +import { SqlError } from "effect/unstable/sql/SqlError" +import * as Statement from "effect/unstable/sql/Statement" + +const ATTR_DB_SYSTEM_NAME = "db.system.name" + +/** + * @category type ids + * @since 1.0.0 + */ +export const TypeId: TypeId = "~@effect/sql-d1/D1Client" + +/** + * @category type ids + * @since 1.0.0 + */ +export type TypeId = "~@effect/sql-d1/D1Client" + +/** + * @category models + * @since 1.0.0 + */ +export interface D1Client extends Client.SqlClient { + readonly [TypeId]: TypeId + readonly config: D1ClientConfig + + /** Not supported in d1 */ + readonly updateValues: never +} + +/** + * @category tags + * @since 1.0.0 + */ +export const D1Client = ServiceMap.Key("@effect/sql-d1/D1Client") + +/** + * @category models + * @since 1.0.0 + */ +export interface D1ClientConfig { + readonly db: D1Database + readonly prepareCacheSize?: number | undefined + readonly prepareCacheTTL?: Duration.DurationInput | undefined + readonly spanAttributes?: Record | undefined + + readonly transformResultNames?: ((str: string) => string) | undefined + readonly transformQueryNames?: ((str: string) => string) | undefined +} + +/** + * @category constructor + * @since 1.0.0 + */ +export const make = ( + options: D1ClientConfig +): Effect.Effect => + Effect.gen(function*() { + const compiler = Statement.makeCompilerSqlite(options.transformQueryNames) + const transformRows = options.transformResultNames ? + Statement.defaultTransforms(options.transformResultNames).array : + undefined + + const makeConnection = Effect.gen(function*() { + const db = options.db + + const prepareCache = yield* Cache.make({ + capacity: options.prepareCacheSize ?? 200, + timeToLive: options.prepareCacheTTL ?? Duration.minutes(10), + lookup: (sql: string) => + Effect.try({ + try: () => db.prepare(sql), + catch: (cause) => new SqlError({ cause, message: `Failed to prepare statement` }) + }) + }) + + const runStatement = ( + statement: D1PreparedStatement, + params: ReadonlyArray = [] + ): Effect.Effect, SqlError, never> => + Effect.tryPromise({ + try: async () => { + const response = await statement.bind(...params).all() + if (response.error) { + throw response.error + } + return response.results || [] + }, + catch: (cause) => new SqlError({ cause, message: `Failed to execute statement` }) + }) + + const runRaw = ( + sql: string, + params: ReadonlyArray = [] + ) => runStatement(db.prepare(sql), params) + + const runCached = ( + sql: string, + params: ReadonlyArray = [] + ) => Effect.flatMap(Cache.get(prepareCache, sql), (s) => runStatement(s, params)) + + const runUncached = ( + sql: string, + params: ReadonlyArray = [] + ) => runRaw(sql, params) + + const runValues = ( + sql: string, + params: ReadonlyArray + ) => + Effect.flatMap( + Cache.get(prepareCache, sql), + (statement) => + Effect.tryPromise({ + try: () => { + return statement.bind(...params).raw() as Promise< + ReadonlyArray< + ReadonlyArray + > + > + }, + catch: (cause) => new SqlError({ cause, message: `Failed to execute statement` }) + }) + ) + + return identity({ + execute(sql, params, transformRows) { + return transformRows + ? Effect.map(runCached(sql, params), transformRows) + : runCached(sql, params) + }, + executeRaw(sql, params) { + return runRaw(sql, params) + }, + executeValues(sql, params) { + return runValues(sql, params) + }, + executeUnprepared(sql, params, transformRows) { + return transformRows + ? Effect.map(runUncached(sql, params), transformRows) + : runUncached(sql, params) + }, + executeStream(_sql, _params) { + return Stream.die("executeStream not implemented") + } + }) + }) + + const connection = yield* makeConnection + const acquirer = Effect.succeed(connection) + const transactionAcquirer = Effect.die("transactions are not supported in D1") + + return Object.assign( + (yield* Client.make({ + acquirer, + compiler, + transactionAcquirer, + spanAttributes: [ + ...(options.spanAttributes ? Object.entries(options.spanAttributes) : []), + [ATTR_DB_SYSTEM_NAME, "sqlite"] + ], + transformRows + })) as D1Client, + { + [TypeId]: TypeId as TypeId, + config: options + } + ) + }) + +/** + * @category layers + * @since 1.0.0 + */ +export const layerConfig = ( + config: Config.Wrap +): Layer.Layer => + Layer.effectServices( + Config.unwrap(config).asEffect().pipe( + Effect.flatMap(make), + Effect.map((client) => + ServiceMap.make(D1Client, client).pipe( + ServiceMap.add(Client.SqlClient, client) + ) + ) + ) + ).pipe(Layer.provide(Reactivity.layer)) + +/** + * @category layers + * @since 1.0.0 + */ +export const layer = ( + config: D1ClientConfig +): Layer.Layer => + Layer.effectServices( + Effect.map(make(config), (client) => + ServiceMap.make(D1Client, client).pipe( + ServiceMap.add(Client.SqlClient, client) + )) + ).pipe(Layer.provide(Reactivity.layer)) diff --git a/packages/sql/d1/src/index.ts b/packages/sql/d1/src/index.ts new file mode 100644 index 0000000000..87118e7b40 --- /dev/null +++ b/packages/sql/d1/src/index.ts @@ -0,0 +1,8 @@ +/** + * @since 1.0.0 + */ + +/** + * @since 1.0.0 + */ +export * as D1Client from "./D1Client.ts" diff --git a/packages/sql/d1/src/index.ts.tpl b/packages/sql/d1/src/index.ts.tpl new file mode 100644 index 0000000000..b66408871c --- /dev/null +++ b/packages/sql/d1/src/index.ts.tpl @@ -0,0 +1,3 @@ +/** + * @since 1.0.0 + */ diff --git a/packages/sql/d1/test/Client.test.ts b/packages/sql/d1/test/Client.test.ts new file mode 100644 index 0000000000..e1c57576d5 --- /dev/null +++ b/packages/sql/d1/test/Client.test.ts @@ -0,0 +1,44 @@ +import { D1Client } from "@effect/sql-d1" +import { assert, describe, it } from "@effect/vitest" +import { Cause, Effect } from "effect" +import { D1Miniflare } from "./utils.ts" + +describe("Client", () => { + it.effect("should handle queries without transactions", () => + Effect.gen(function*() { + const sql = yield* D1Client.D1Client + yield* sql`CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)` + yield* sql`INSERT INTO test (name) VALUES ('hello')` + let rows = yield* sql`SELECT * FROM test` + assert.deepStrictEqual(rows, [{ id: 1, name: "hello" }]) + yield* sql`INSERT INTO test (name) VALUES ('world')` + rows = yield* sql`SELECT * FROM test` + assert.deepStrictEqual(rows, [ + { id: 1, name: "hello" }, + { id: 2, name: "world" } + ]) + }).pipe(Effect.provide(D1Miniflare.layerClient))) + + it.effect("should handle queries with params without transactions", () => + Effect.gen(function*() { + const sql = yield* D1Client.D1Client + yield* sql`CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)` + yield* sql`INSERT INTO test ${sql.insert({ name: "hello" })}` + const rows = yield* sql`SELECT * FROM test WHERE name = ${"hello"}` + assert.deepStrictEqual(rows, [{ id: 1, name: "hello" }]) + }).pipe(Effect.provide(D1Miniflare.layerClient))) + + it.effect("should defect on transactions", () => + Effect.gen(function*() { + const sql = yield* D1Client.D1Client + yield* sql`CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)` + const res = yield* sql`INSERT INTO test ${sql.insert({ name: "hello" })}`.pipe( + sql.withTransaction, + Effect.sandbox, + Effect.flip + ) + const rows = yield* sql`SELECT * FROM test` + assert.deepStrictEqual(rows, []) + assert.equal(Cause.hasDie(res), true) + }).pipe(Effect.provide(D1Miniflare.layerClient))) +}) diff --git a/packages/sql/d1/test/Resolver.test.ts b/packages/sql/d1/test/Resolver.test.ts new file mode 100644 index 0000000000..11ea603124 --- /dev/null +++ b/packages/sql/d1/test/Resolver.test.ts @@ -0,0 +1,177 @@ +import { D1Client } from "@effect/sql-d1" +import { assert, describe, it } from "@effect/vitest" +import { Cause, Effect } from "effect" +import { Iterable } from "effect/collections" +import * as Schema from "effect/schema/Schema" +import { SqlError, SqlResolver } from "effect/unstable/sql" +import { D1Miniflare } from "./utils.ts" + +const seededClient = Effect.gen(function*() { + const sql = yield* D1Client.D1Client + yield* sql`CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)` + for (const id of Iterable.range(1, 100)) { + yield* sql`INSERT INTO test ${sql.insert({ id, name: `name${id}` })}` + } + return sql +}) + +describe("Resolver", () => { + describe("ordered", () => { + it.effect("insert", () => + Effect.gen(function*() { + const batches: Array> = [] + const sql = yield* seededClient + const Insert = SqlResolver.ordered({ + Request: Schema.String, + Result: Schema.Struct({ id: Schema.Number, name: Schema.String }), + execute: (names) => { + batches.push(names) + return sql`INSERT INTO test ${sql.insert(names.map((name) => ({ name })))} RETURNING *`.asEffect() + } + }) + const execute = SqlResolver.request(Insert) + assert.deepStrictEqual( + yield* Effect.all({ + one: execute("one"), + two: SqlResolver.request("two", Insert) + }, { concurrency: "unbounded" }), + { + one: { id: 101, name: "one" }, + two: { id: 102, name: "two" } + } + ) + assert.deepStrictEqual(batches, [["one", "two"]]) + }).pipe(Effect.provide(D1Miniflare.layerClient))) + + it.effect("result length mismatch", () => + Effect.gen(function*() { + const batches: Array> = [] + const sql = yield* seededClient + const Select = SqlResolver.ordered({ + Request: Schema.Number, + Result: Schema.Struct({ id: Schema.Number, name: Schema.String }), + execute: (ids) => { + batches.push(ids) + return sql`SELECT * FROM test WHERE id IN ${sql.in(ids)}`.asEffect() + } + }) + const execute = SqlResolver.request(Select) + const error = yield* Effect.all([ + execute(1), + execute(2), + execute(3), + execute(101) + ], { concurrency: "unbounded" }).pipe( + Effect.flip + ) + assert(error instanceof SqlError.ResultLengthMismatch) + assert.strictEqual(error.actual, 3) + assert.strictEqual(error.expected, 4) + assert.deepStrictEqual(batches, [[1, 2, 3, 101]]) + }).pipe(Effect.provide(D1Miniflare.layerClient))) + }) + + describe("grouped", () => { + it.effect("find by name", () => + Effect.gen(function*() { + const sql = yield* seededClient + const FindByName = SqlResolver.grouped({ + Request: Schema.String, + RequestGroupKey: (name) => name, + Result: Schema.Struct({ id: Schema.Number, name: Schema.String }), + ResultGroupKey: (result) => result.name, + execute: (names) => sql`SELECT * FROM test WHERE name IN ${sql.in(names)}`.asEffect() + }) + const execute = SqlResolver.request(FindByName) + yield* sql`INSERT INTO test ${sql.insert({ name: "name1" })}` + assert.deepStrictEqual( + yield* Effect.all({ + one: execute("name1"), + two: execute("name2"), + three: Effect.flip(execute("name0")) + }, { concurrency: "unbounded" }), + { + one: [{ id: 1, name: "name1" }, { id: 101, name: "name1" }], + two: [{ id: 2, name: "name2" }], + three: new Cause.NoSuchElementError() + } + ) + }).pipe(Effect.provide(D1Miniflare.layerClient))) + + it.effect("using raw rows", () => + Effect.gen(function*() { + const sql = yield* seededClient + const FindByName = SqlResolver.grouped({ + Request: Schema.String, + RequestGroupKey: (name) => name, + Result: Schema.Struct({ id: Schema.Number, name: Schema.String }), + ResultGroupKey: (_, result: any) => result.name, + execute: (names) => sql`SELECT * FROM test WHERE name IN ${sql.in(names)}`.asEffect() + }) + const execute = SqlResolver.request(FindByName) + yield* sql`INSERT INTO test ${sql.insert({ name: "name1" })}` + assert.deepStrictEqual( + yield* Effect.all({ + one: execute("name1"), + two: execute("name2"), + three: Effect.flip(execute("name0")) + }, { concurrency: "unbounded" }), + { + one: [{ id: 1, name: "name1" }, { id: 101, name: "name1" }], + two: [{ id: 2, name: "name2" }], + three: new Cause.NoSuchElementError() + } + ) + }).pipe(Effect.provide(D1Miniflare.layerClient))) + }) + + describe("findById", () => { + it.effect("find by id", () => + Effect.gen(function*() { + const sql = yield* seededClient + const FindById = SqlResolver.findById({ + Id: Schema.Number, + Result: Schema.Struct({ id: Schema.Number, name: Schema.String }), + ResultId: (result) => result.id, + execute: (ids) => sql`SELECT * FROM test WHERE id IN ${sql.in(ids)}`.asEffect() + }) + const execute = SqlResolver.request(FindById) + assert.deepStrictEqual( + yield* Effect.all({ + one: execute(1), + two: execute(2), + three: Effect.flip(execute(101)) + }, { concurrency: "unbounded" }), + { + one: { id: 1, name: "name1" }, + two: { id: 2, name: "name2" }, + three: new Cause.NoSuchElementError() + } + ) + }).pipe(Effect.provide(D1Miniflare.layerClient))) + + it.effect("using raw rows", () => + Effect.gen(function*() { + const sql = yield* seededClient + const FindById = SqlResolver.findById({ + Id: Schema.Number, + Result: Schema.Struct({ id: Schema.Number, name: Schema.String }), + ResultId: (_, result: any) => result.id, + execute: (ids) => sql`SELECT * FROM test WHERE id IN ${sql.in(ids)}`.asEffect() + }) + const execute = SqlResolver.request(FindById) + assert.deepStrictEqual( + yield* Effect.all({ + one: execute(1), + two: execute(2), + three: Effect.flip(execute(101)) + }, { concurrency: "unbounded" }), + { + one: { id: 1, name: "name1" }, + two: { id: 2, name: "name2" }, + three: new Cause.NoSuchElementError() + } + ) + }).pipe(Effect.provide(D1Miniflare.layerClient))) + }) +}) diff --git a/packages/sql/d1/test/utils.ts b/packages/sql/d1/test/utils.ts new file mode 100644 index 0000000000..e0906f933e --- /dev/null +++ b/packages/sql/d1/test/utils.ts @@ -0,0 +1,39 @@ +import type { D1Database } from "@cloudflare/workers-types" +import { D1Client } from "@effect/sql-d1" +import { Effect, Layer, ServiceMap } from "effect" +import { Data } from "effect/data" +import { Miniflare } from "miniflare" + +export class MiniflareError extends Data.TaggedError("MiniflareError")<{ + cause: unknown +}> {} + +export class D1Miniflare extends ServiceMap.Key< + D1Miniflare, + Miniflare +>()("test/D1Miniflare") { + static layer = Layer.effect(this)( + Effect.acquireRelease( + Effect.try({ + try: () => + new Miniflare({ + modules: true, + d1Databases: { + DB: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + }, + script: "" + }), + catch: (cause) => new MiniflareError({ cause }) + }), + (miniflare) => Effect.promise(() => miniflare.dispose()) + ) + ) + + static layerClient = Layer.unwrap( + Effect.gen(function*() { + const miniflare = yield* D1Miniflare + const db: D1Database = yield* Effect.tryPromise(() => miniflare.getD1Database("DB")) + return D1Client.layer({ db }) + }) + ).pipe(Layer.provide(this.layer)) +} diff --git a/packages/sql/d1/tsconfig.build.json b/packages/sql/d1/tsconfig.build.json new file mode 100644 index 0000000000..e738132ff9 --- /dev/null +++ b/packages/sql/d1/tsconfig.build.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "./tsconfig.src.json", + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", + "outDir": "dist", + "stripInternal": true + } +} diff --git a/packages/sql/d1/tsconfig.json b/packages/sql/d1/tsconfig.json new file mode 100644 index 0000000000..11922f5b68 --- /dev/null +++ b/packages/sql/d1/tsconfig.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": [], + "references": [{ "path": "tsconfig.src.json" }, { "path": "tsconfig.test.json" }] +} diff --git a/packages/sql/d1/tsconfig.src.json b/packages/sql/d1/tsconfig.src.json new file mode 100644 index 0000000000..1fdbb717d9 --- /dev/null +++ b/packages/sql/d1/tsconfig.src.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["src"], + "references": [{ "path": "../../effect/tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", + "outDir": ".tsbuildinfo/src", + "rootDir": "src", + "types": ["node"] + } +} diff --git a/packages/sql/d1/tsconfig.test.json b/packages/sql/d1/tsconfig.test.json new file mode 100644 index 0000000000..6c416c454b --- /dev/null +++ b/packages/sql/d1/tsconfig.test.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["test/**/*.ts", "test/**/*.json"], + "references": [{ "path": "tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/test.tsbuildinfo", + "outDir": ".tsbuildinfo/test", + "rootDir": "test", + "noEmit": true, + "erasableSyntaxOnly": false, + "resolveJsonModule": true, + "baseUrl": ".", + "paths": { + "@effect/sql-d1": ["src/index.ts"], + "@effect/sql-d1/*": ["src/*/index.ts", "src/*.ts"] + }, + "plugins": [ + { + "name": "@effect/language-service", + "namespaceImportPackages": [] + } + ] + } +} diff --git a/packages/sql/d1/vitest.config.ts b/packages/sql/d1/vitest.config.ts new file mode 100644 index 0000000000..c8a52c1826 --- /dev/null +++ b/packages/sql/d1/vitest.config.ts @@ -0,0 +1,6 @@ +import { mergeConfig, type ViteUserConfig } from "vitest/config" +import shared from "../../../vitest.shared.ts" + +const config: ViteUserConfig = {} + +export default mergeConfig(shared, config) diff --git a/packages/sql/libsql/LICENSE b/packages/sql/libsql/LICENSE new file mode 100644 index 0000000000..8967b4b176 --- /dev/null +++ b/packages/sql/libsql/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024-present The Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/sql/libsql/README.md b/packages/sql/libsql/README.md new file mode 100644 index 0000000000..cea29b5afa --- /dev/null +++ b/packages/sql/libsql/README.md @@ -0,0 +1,7 @@ +# `@effect/sql-libsql` + +An `@effect/sql` implementation using the `@libsql/client` library. + +## Documentation + +- **API Reference**: [View the full documentation](https://effect-ts.github.io/effect/docs/sql-libsql). diff --git a/packages/sql/libsql/docgen.json b/packages/sql/libsql/docgen.json new file mode 100644 index 0000000000..dab1d4637e --- /dev/null +++ b/packages/sql/libsql/docgen.json @@ -0,0 +1,20 @@ +{ + "$schema": "../../node_modules/@effect/docgen/schema.json", + "srcLink": "https://github.com/Effect-TS/effect/tree/main/packages/sql/libsql/src/", + "exclude": ["src/internal/**/*.ts"], + "examplesCompilerOptions": { + "noEmit": true, + "strict": true, + "skipLibCheck": true, + "moduleResolution": "Bundler", + "module": "ES2022", + "target": "ES2022", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "rewriteRelativeImportExtensions": true, + "allowImportingTsExtensions": true, + "paths": { + "effect": ["../../../effect/src/index.js"], + "effect/*": ["../../../effect/src/*.js"] + } + } +} diff --git a/packages/sql/libsql/package.json b/packages/sql/libsql/package.json new file mode 100644 index 0000000000..2754b214ab --- /dev/null +++ b/packages/sql/libsql/package.json @@ -0,0 +1,70 @@ +{ + "name": "@effect/sql-libsql", + "version": "0.34.1", + "type": "module", + "license": "MIT", + "description": "A libSQL toolkit for Effect", + "homepage": "https://effect.website", + "repository": { + "type": "git", + "url": "https://github.com/Effect-TS/effect.git", + "directory": "packages/sql/libsql" + }, + "bugs": { + "url": "https://github.com/Effect-TS/effect/issues" + }, + "tags": [ + "typescript", + "sql", + "libsql", + "database" + ], + "keywords": [ + "typescript", + "sql", + "libsql", + "database" + ], + "sideEffects": [], + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts", + "./*": "./src/*.ts", + "./internal/*": null, + "./*/index": null + }, + "files": [ + "src/**/*.ts", + "dist/**/*.js", + "dist/**/*.js.map", + "dist/**/*.d.ts", + "dist/**/*.d.ts.map" + ], + "publishConfig": { + "provenance": true, + "exports": { + "./package.json": "./package.json", + ".": "./dist/index.js", + "./*": "./dist/*.js", + "./internal/*": null, + "./*/index": null + } + }, + "scripts": { + "codegen": "build-utils prepare-v4", + "build": "tsc -b tsconfig.build.json && babel dist --plugins annotate-pure-calls --out-dir dist --source-maps", + "check": "tsc -b tsconfig.json", + "test": "vitest", + "coverage": "vitest --coverage" + }, + "devDependencies": { + "effect": "workspace:^", + "testcontainers": "^11.5.1" + }, + "peerDependencies": { + "effect": "workspace:^" + }, + "dependencies": { + "@libsql/client": "^0.15.14" + } +} diff --git a/packages/sql/libsql/src/LibsqlClient.ts b/packages/sql/libsql/src/LibsqlClient.ts new file mode 100644 index 0000000000..8f53117bc0 --- /dev/null +++ b/packages/sql/libsql/src/LibsqlClient.ts @@ -0,0 +1,325 @@ +/** + * @since 1.0.0 + */ +import * as Libsql from "@libsql/client" +import * as Config from "effect/config/Config" +import * as Option from "effect/data/Option" +import * as Redacted from "effect/data/Redacted" +import * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" +import * as Scope from "effect/Scope" +import * as ServiceMap from "effect/ServiceMap" +import * as Stream from "effect/stream/Stream" +import * as Reactivity from "effect/unstable/reactivity/Reactivity" +import * as Client from "effect/unstable/sql/SqlClient" +import type { Connection } from "effect/unstable/sql/SqlConnection" +import { SqlError } from "effect/unstable/sql/SqlError" +import * as Statement from "effect/unstable/sql/Statement" + +const ATTR_DB_SYSTEM_NAME = "db.system.name" + +/** + * @category type ids + * @since 1.0.0 + */ +export const TypeId: TypeId = "~@effect/sql-libsql/LibsqlClient" + +/** + * @category type ids + * @since 1.0.0 + */ +export type TypeId = "~@effect/sql-libsql/LibsqlClient" + +/** + * @category models + * @since 1.0.0 + */ +export interface LibsqlClient extends Client.SqlClient { + readonly [TypeId]: TypeId + readonly config: LibsqlClientConfig +} + +/** + * @category tags + * @since 1.0.0 + */ +export const LibsqlClient = ServiceMap.Key("@effect/sql-libsql/LibsqlClient") + +const LibsqlTransaction = ServiceMap.Key( + "@effect/sql-libsql/LibsqlClient/LibsqlTransaction" +) + +/** + * @category models + * @since 1.0.0 + */ +export type LibsqlClientConfig = LibsqlClientConfig.Full | LibsqlClientConfig.Live + +/** + * @category models + * @since 1.0.0 + */ +export declare namespace LibsqlClientConfig { + /** + * @category models + * @since 1.0.0 + */ + export interface Base { + readonly spanAttributes?: Record | undefined + readonly transformResultNames?: ((str: string) => string) | undefined + readonly transformQueryNames?: ((str: string) => string) | undefined + } + + /** + * @category models + * @since 1.0.0 + */ + export interface Full extends Base { + /** The database URL. + * + * The client supports `libsql:`, `http:`/`https:`, `ws:`/`wss:` and `file:` URL. For more infomation, + * please refer to the project README: + * + * https://github.com/libsql/libsql-client-ts#supported-urls + */ + readonly url: string | URL + /** Authentication token for the database. */ + readonly authToken?: Redacted.Redacted | undefined + /** Encryption key for the database. */ + readonly encryptionKey?: Redacted.Redacted | undefined + /** URL of a remote server to synchronize database with. */ + readonly syncUrl?: string | URL | undefined + /** Sync interval in seconds. */ + readonly syncInterval?: number | undefined + /** Enables or disables TLS for `libsql:` URLs. + * + * By default, `libsql:` URLs use TLS. You can set this option to `false` to disable TLS. + */ + readonly tls?: boolean | undefined + /** How to convert SQLite integers to JavaScript values: + * + * - `"number"` (default): returns SQLite integers as JavaScript `number`-s (double precision floats). + * `number` cannot precisely represent integers larger than 2^53-1 in absolute value, so attempting to read + * larger integers will throw a `RangeError`. + * - `"bigint"`: returns SQLite integers as JavaScript `bigint`-s (arbitrary precision integers). Bigints can + * precisely represent all SQLite integers. + * - `"string"`: returns SQLite integers as strings. + */ + readonly intMode?: "number" | "bigint" | "string" | undefined + /** Concurrency limit. + * + * By default, the client performs up to 20 concurrent requests. You can set this option to a higher + * number to increase the concurrency limit or set it to 0 to disable concurrency limits completely. + */ + readonly concurrency?: number | undefined + } + + /** + * @category models + * @since 1.0.0 + */ + export interface Live extends Base { + readonly liveClient: Libsql.Client + } +} + +interface LibsqlConnection extends Connection { + readonly beginTransaction: Effect.Effect + readonly commit: Effect.Effect + readonly rollback: Effect.Effect +} + +/** + * @category constructor + * @since 1.0.0 + */ +export const make = ( + options: LibsqlClientConfig +): Effect.Effect => + Effect.gen(function*() { + const compiler = Statement.makeCompilerSqlite(options.transformQueryNames) + const transformRows = options.transformResultNames ? + Statement.defaultTransforms( + options.transformResultNames + ).array : + undefined + + const spanAttributes: Array<[string, unknown]> = [ + ...(options.spanAttributes ? Object.entries(options.spanAttributes) : []), + [ATTR_DB_SYSTEM_NAME, "sqlite"] + ] + + class LibsqlConnectionImpl implements LibsqlConnection { + readonly sdk: Libsql.Client | Libsql.Transaction + constructor(sdk: Libsql.Client | Libsql.Transaction) { + this.sdk = sdk + } + + run( + sql: string, + params: ReadonlyArray = [] + ) { + return Effect.map( + Effect.tryPromise({ + try: () => this.sdk.execute({ sql, args: params as Array }), + catch: (cause) => new SqlError({ cause, message: "Failed to execute statement" }) + }), + (results) => results.rows + ) + } + + runRaw( + sql: string, + params: ReadonlyArray = [] + ) { + return Effect.tryPromise({ + try: () => this.sdk.execute({ sql, args: params as Array }), + catch: (cause) => new SqlError({ cause, message: "Failed to execute statement" }) + }) + } + + execute( + sql: string, + params: ReadonlyArray, + transformRows: ((row: ReadonlyArray) => ReadonlyArray) | undefined + ) { + return transformRows + ? Effect.map(this.run(sql, params), transformRows) + : this.run(sql, params) + } + executeRaw(sql: string, params: ReadonlyArray) { + return this.runRaw(sql, params) + } + executeValues(sql: string, params: ReadonlyArray) { + return Effect.map(this.run(sql, params), (rows) => rows.map((row) => Array.from(row) as Array)) + } + executeUnprepared( + sql: string, + params: ReadonlyArray, + transformRows: ((row: ReadonlyArray) => ReadonlyArray) | undefined + ) { + return this.execute(sql, params, transformRows) + } + executeStream() { + return Stream.die("executeStream not implemented") + } + get beginTransaction() { + return Effect.map( + Effect.tryPromise({ + try: () => (this.sdk as Libsql.Client).transaction("write"), + catch: (cause) => new SqlError({ cause, message: "Failed to begin transaction" }) + }), + (tx) => new LibsqlConnectionImpl(tx) + ) + } + get commit() { + return Effect.tryPromise({ + try: () => (this.sdk as Libsql.Transaction).commit(), + catch: (cause) => new SqlError({ cause, message: "Failed to commit transaction" }) + }) + } + get rollback() { + return Effect.tryPromise({ + try: () => (this.sdk as Libsql.Transaction).rollback(), + catch: (cause) => new SqlError({ cause, message: "Failed to rollback transaction" }) + }) + } + } + + const connection = "liveClient" in options + ? new LibsqlConnectionImpl(options.liveClient) + : yield* Effect.map( + Effect.acquireRelease( + Effect.sync(() => + Libsql.createClient( + { + ...options, + authToken: Redacted.isRedacted(options.authToken) + ? Redacted.value(options.authToken) + : options.authToken, + encryptionKey: Redacted.isRedacted(options.encryptionKey) + ? Redacted.value(options.encryptionKey) + : options.encryptionKey, + url: options.url.toString(), + syncUrl: options.syncUrl?.toString() + } as Libsql.Config + ) + ), + (sdk) => Effect.sync(() => sdk.close()) + ), + (sdk) => new LibsqlConnectionImpl(sdk) + ) + const semaphore = yield* Effect.makeSemaphore(1) + + const withTransaction = Client.makeWithTransaction({ + transactionTag: LibsqlTransaction, + spanAttributes, + acquireConnection: Effect.uninterruptibleMask(Effect.fnUntraced(function*(restore) { + const scope = Scope.unsafeMake() + yield* restore(semaphore.take(1)) + yield* Scope.addFinalizer(scope, semaphore.release(1)) + const conn = yield* connection.beginTransaction + return [scope, conn] as const + })), + begin: () => Effect.void, // already begun in acquireConnection + savepoint: (conn, id) => conn.executeRaw(`SAVEPOINT effect_sql_${id};`, []), + commit: (conn) => conn.commit, + rollback: (conn) => conn.rollback, + rollbackSavepoint: (conn, id) => conn.executeRaw(`ROLLBACK TO SAVEPOINT effect_sql_${id};`, []) + }) + + const acquirer = Effect.flatMap( + Effect.serviceOption(LibsqlTransaction), + Option.match({ + onNone: () => semaphore.withPermits(1)(Effect.succeed(connection as LibsqlConnection)), + onSome: ([conn]) => Effect.succeed(conn) + }) + ) + + return Object.assign( + yield* Client.make({ + acquirer, + compiler, + spanAttributes, + transformRows + }), + { + [TypeId]: TypeId as TypeId, + config: options, + withTransaction, + sdk: connection.sdk + } + ) + }) + +/** + * @category layers + * @since 1.0.0 + */ +export const layerConfig = ( + config: Config.Wrap +): Layer.Layer => + Layer.effectServices( + Config.unwrap(config).asEffect().pipe( + Effect.flatMap(make), + Effect.map((client) => + ServiceMap.make(LibsqlClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + ) + ) + ) + ).pipe(Layer.provide(Reactivity.layer)) + +/** + * @category layers + * @since 1.0.0 + */ +export const layer = ( + config: LibsqlClientConfig +): Layer.Layer => + Layer.effectServices( + Effect.map(make(config), (client) => + ServiceMap.make(LibsqlClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + )) + ).pipe(Layer.provide(Reactivity.layer)) diff --git a/packages/sql/libsql/src/LibsqlMigrator.ts b/packages/sql/libsql/src/LibsqlMigrator.ts new file mode 100644 index 0000000000..fbe47011c6 --- /dev/null +++ b/packages/sql/libsql/src/LibsqlMigrator.ts @@ -0,0 +1,33 @@ +/** + * @since 1.0.0 + */ +import type * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" +import * as Migrator from "effect/unstable/sql/Migrator" +import type * as Client from "effect/unstable/sql/SqlClient" +import type { SqlError } from "effect/unstable/sql/SqlError" + +/** + * @since 1.0.0 + */ +export * from "effect/unstable/sql/Migrator" + +/** + * @category constructor + * @since 1.0.0 + */ +export const run: ( + options: Migrator.MigratorOptions +) => Effect.Effect< + ReadonlyArray, + Migrator.MigrationError | SqlError, + Client.SqlClient | R2 +> = Migrator.make({}) + +/** + * @category constructor + * @since 1.0.0 + */ +export const layer = ( + options: Migrator.MigratorOptions +): Layer.Layer => Layer.effectDiscard(run(options)) diff --git a/packages/sql/libsql/src/index.ts b/packages/sql/libsql/src/index.ts new file mode 100644 index 0000000000..c1feaaf61e --- /dev/null +++ b/packages/sql/libsql/src/index.ts @@ -0,0 +1,13 @@ +/** + * @since 1.0.0 + */ + +/** + * @since 1.0.0 + */ +export * as LibsqlClient from "./LibsqlClient.ts" + +/** + * @since 1.0.0 + */ +export * as LibsqlMigrator from "./LibsqlMigrator.ts" diff --git a/packages/sql/libsql/src/index.ts.tpl b/packages/sql/libsql/src/index.ts.tpl new file mode 100644 index 0000000000..b66408871c --- /dev/null +++ b/packages/sql/libsql/src/index.ts.tpl @@ -0,0 +1,3 @@ +/** + * @since 1.0.0 + */ diff --git a/packages/sql/libsql/test/Client.test.ts b/packages/sql/libsql/test/Client.test.ts new file mode 100644 index 0000000000..3d73b0fb68 --- /dev/null +++ b/packages/sql/libsql/test/Client.test.ts @@ -0,0 +1,106 @@ +import { LibsqlClient } from "@effect/sql-libsql" +import { assert, describe, layer } from "@effect/vitest" +import { Effect, Layer } from "effect" +import { LibsqlContainer } from "./util.ts" + +const Migrations = Layer.effectDiscard( + LibsqlClient.LibsqlClient.asEffect().pipe( + Effect.andThen((sql) => + Effect.acquireRelease( + sql`CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)`, + () => sql`DROP TABLE test;`.pipe(Effect.ignore) + ) + ) + ) +) + +describe("Client", () => { + layer(LibsqlContainer.layerClient, { timeout: "30 seconds" })((it) => { + it.effect("should work", () => + Effect.gen(function*() { + const sql = yield* LibsqlClient.LibsqlClient + let response = yield* sql`INSERT INTO test (name) VALUES ('hello')` + assert.deepStrictEqual(response, []) + response = yield* sql`SELECT * FROM test` + assert.deepStrictEqual(response, [{ id: 1, name: "hello" }]) + response = yield* sql`SELECT * FROM test` + assert.deepStrictEqual(yield* sql`select * from test`.values, [ + [1, "hello"] + ]) + }).pipe(Effect.provide(Migrations))) + + it.effect("should work with raw", () => + Effect.gen(function*() { + const sql = yield* LibsqlClient.LibsqlClient + let response: any + response = yield* sql`CREATE TABLE test2 (id INTEGER PRIMARY KEY, name TEXT)`.raw + yield* Effect.addFinalizer(() => sql`DROP TABLE test2;`.pipe(Effect.ignore)) + assert.deepStrictEqual(response.toJSON(), { + columnTypes: [], + columns: [], + lastInsertRowid: null, + rows: [], + rowsAffected: 0 + }) + response = yield* sql`INSERT INTO test (name) VALUES ('hello')`.raw + assert.deepStrictEqual(response.toJSON(), { + columnTypes: [], + columns: [], + lastInsertRowid: "1", + rows: [], + rowsAffected: 1 + }) + response = yield* sql`SELECT * FROM test`.raw + assert.deepStrictEqual(response.toJSON(), { + columnTypes: ["INTEGER", "TEXT"], + columns: ["id", "name"], + lastInsertRowid: null, + rows: [[1, "hello"]], + rowsAffected: 0 + }) + }).pipe(Effect.provide(Migrations))) + + it.effect("withTransaction", () => + Effect.gen(function*() { + const sql = yield* LibsqlClient.LibsqlClient + yield* sql.withTransaction(sql`INSERT INTO test (name) VALUES ('hello')`) + const rows = yield* sql`SELECT * FROM test` + assert.deepStrictEqual(rows, [{ id: 1, name: "hello" }]) + }).pipe(Effect.provide(Migrations))) + + it.effect("withTransaction rollback", () => + Effect.gen(function*() { + const sql = yield* LibsqlClient.LibsqlClient + yield* sql`INSERT INTO test (name) VALUES ('hello')`.pipe( + Effect.andThen(Effect.fail("boom")), + sql.withTransaction, + Effect.ignore + ) + const rows = yield* sql`SELECT * FROM test` + assert.deepStrictEqual(rows, []) + }).pipe(Effect.provide(Migrations))) + + it.effect("withTransaction nested", () => + Effect.gen(function*() { + const sql = yield* LibsqlClient.LibsqlClient + const stmt = sql`INSERT INTO test (name) VALUES ('hello')` + + yield* stmt.pipe(Effect.andThen(() => stmt.pipe(sql.withTransaction)), sql.withTransaction) + const rows = yield* sql<{ total_rows: number }>`select count(*) as total_rows FROM test` + assert.deepStrictEqual(rows.at(0)?.total_rows, 2) + }).pipe(Effect.provide(Migrations))) + + it.effect("withTransaction nested rollback", () => + Effect.gen(function*() { + const sql = yield* LibsqlClient.LibsqlClient + const stmt = sql`INSERT INTO test (name) VALUES ('hello')` + + yield* stmt.pipe( + Effect.andThen(() => stmt.pipe(Effect.andThen(Effect.fail("boom")), sql.withTransaction, Effect.ignore)), + sql.withTransaction + ) + const rows = yield* sql<{ total_rows: number }>`select count(*) as total_rows FROM test` + assert.deepStrictEqual(rows.at(0)?.total_rows, 1) + }).pipe(Effect.provide(Migrations))) + }) +}) diff --git a/packages/sql/libsql/test/Resolver.test.ts b/packages/sql/libsql/test/Resolver.test.ts new file mode 100644 index 0000000000..aa966a2ee7 --- /dev/null +++ b/packages/sql/libsql/test/Resolver.test.ts @@ -0,0 +1,178 @@ +import { LibsqlClient } from "@effect/sql-libsql" +import { assert, layer } from "@effect/vitest" +import { Cause, Effect, Layer } from "effect" +import { Iterable } from "effect/collections" +import * as Schema from "effect/schema/Schema" +import { SqlError, SqlResolver } from "effect/unstable/sql" +import { LibsqlContainer } from "./util.ts" + +const seededClient = Effect.gen(function*() { + const sql = yield* LibsqlClient.LibsqlClient + yield* sql`CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)` + for (const id of Iterable.range(1, 100)) { + yield* sql`INSERT INTO test ${sql.insert({ id, name: `name${id}` })}` + } + yield* Effect.addFinalizer(() => sql`DROP TABLE test;`.pipe(Effect.orDie)) + return sql +}) + +layer(LibsqlContainer.layerClient, { timeout: "30 seconds" })("Resolver", (it) => { + it.layer(Layer.empty)("ordered", (it) => { + it.effect("insert", () => + Effect.gen(function*() { + const batches: Array> = [] + const sql = yield* seededClient + const Insert = SqlResolver.ordered({ + Request: Schema.String, + Result: Schema.Struct({ id: Schema.Number, name: Schema.String }), + execute: (names) => { + batches.push(names) + return sql`INSERT INTO test ${sql.insert(names.map((name) => ({ name })))} RETURNING *` + } + }) + const execute = SqlResolver.request(Insert) + assert.deepStrictEqual( + yield* Effect.all({ + one: execute("one"), + two: execute("two") + }, { concurrency: "unbounded" }), + { + one: { id: 101, name: "one" }, + two: { id: 102, name: "two" } + } + ) + assert.deepStrictEqual(batches, [["one", "two"]]) + })) + + it.effect("result length mismatch", () => + Effect.gen(function*() { + const batches: Array> = [] + const sql = yield* seededClient + const Select = SqlResolver.ordered({ + Request: Schema.Number, + Result: Schema.Struct({ id: Schema.Number, name: Schema.String }), + execute: (ids) => { + batches.push(ids) + return sql`SELECT * FROM test WHERE id IN ${sql.in(ids)}` + } + }) + const execute = SqlResolver.request(Select) + const error = yield* Effect.all([ + execute(1), + execute(2), + execute(3), + execute(101) + ], { concurrency: "unbounded" }).pipe( + Effect.flip + ) + assert(error instanceof SqlError.ResultLengthMismatch) + assert.strictEqual(error.actual, 3) + assert.strictEqual(error.expected, 4) + assert.deepStrictEqual(batches, [[1, 2, 3, 101]]) + })) + }) + + it.layer(Layer.empty)("grouped", (it) => { + it.effect("find by name", () => + Effect.gen(function*() { + const sql = yield* seededClient + const FindByName = SqlResolver.grouped({ + Request: Schema.String, + RequestGroupKey: (name) => name, + Result: Schema.Struct({ id: Schema.Number, name: Schema.String }), + ResultGroupKey: (result) => result.name, + execute: (names) => sql`SELECT * FROM test WHERE name IN ${sql.in(names)}` + }) + yield* sql`INSERT INTO test ${sql.insert({ name: "name1" })}` + const execute = SqlResolver.request(FindByName) + assert.deepStrictEqual( + yield* Effect.all({ + one: execute("name1"), + two: execute("name2"), + three: Effect.flip(execute("name0")) + }, { concurrency: "unbounded" }), + { + one: [{ id: 1, name: "name1" }, { id: 101, name: "name1" }], + two: [{ id: 2, name: "name2" }], + three: new Cause.NoSuchElementError() + } + ) + })) + + it.effect("using raw rows", () => + Effect.gen(function*() { + const sql = yield* seededClient + const FindByName = SqlResolver.grouped({ + Request: Schema.String, + RequestGroupKey: (name) => name, + Result: Schema.Struct({ id: Schema.Number, name: Schema.String }), + ResultGroupKey: (_, result: any) => result.name, + execute: (names) => sql`SELECT * FROM test WHERE name IN ${sql.in(names)}` + }) + yield* sql`INSERT INTO test ${sql.insert({ name: "name1" })}` + const execute = SqlResolver.request(FindByName) + assert.deepStrictEqual( + yield* Effect.all({ + one: execute("name1"), + two: execute("name2"), + three: Effect.flip(execute("name0")) + }, { concurrency: "unbounded" }), + { + one: [{ id: 1, name: "name1" }, { id: 101, name: "name1" }], + two: [{ id: 2, name: "name2" }], + three: new Cause.NoSuchElementError() + } + ) + })) + }) + + it.layer(Layer.empty)("findById", (it) => { + it.effect("find by id", () => + Effect.gen(function*() { + const sql = yield* seededClient + const FindById = SqlResolver.findById({ + Id: Schema.Number, + Result: Schema.Struct({ id: Schema.Number, name: Schema.String }), + ResultId: (result) => result.id, + execute: (ids) => sql`SELECT * FROM test WHERE id IN ${sql.in(ids)}` + }) + const execute = SqlResolver.request(FindById) + assert.deepStrictEqual( + yield* Effect.all({ + one: execute(1), + two: execute(2), + three: Effect.flip(execute(101)) + }, { concurrency: "unbounded" }), + { + one: { id: 1, name: "name1" }, + two: { id: 2, name: "name2" }, + three: new Cause.NoSuchElementError() + } + ) + })) + + it.effect("using raw rows", () => + Effect.gen(function*() { + const sql = yield* seededClient + const FindById = SqlResolver.findById({ + Id: Schema.Number, + Result: Schema.Struct({ id: Schema.Number, name: Schema.String }), + ResultId: (_, result: any) => result.id, + execute: (ids) => sql`SELECT * FROM test WHERE id IN ${sql.in(ids)}` + }) + const execute = SqlResolver.request(FindById) + assert.deepStrictEqual( + yield* Effect.all({ + one: execute(1), + two: execute(2), + three: Effect.flip(execute(101)) + }, { concurrency: "unbounded" }), + { + one: { id: 1, name: "name1" }, + two: { id: 2, name: "name2" }, + three: new Cause.NoSuchElementError() + } + ) + })) + }) +}) diff --git a/packages/sql/libsql/test/util.ts b/packages/sql/libsql/test/util.ts new file mode 100644 index 0000000000..8fafba0532 --- /dev/null +++ b/packages/sql/libsql/test/util.ts @@ -0,0 +1,29 @@ +import { LibsqlClient } from "@effect/sql-libsql" +import { Effect, Layer, ServiceMap } from "effect" +import { GenericContainer, type StartedTestContainer } from "testcontainers" + +export class LibsqlContainer extends ServiceMap.Key< + LibsqlContainer, + StartedTestContainer +>()("test/LibsqlContainer") { + static layer = Layer.effect(this)( + Effect.acquireRelease( + Effect.promise(() => + new GenericContainer("ghcr.io/tursodatabase/libsql-server:main") + .withExposedPorts(8080) + .withEnvironment({ SQLD_NODE: "primary" }) + .withCommand(["sqld", "--no-welcome", "--http-listen-addr", "0.0.0.0:8080"]).start() + ), + (container) => Effect.promise(() => container.stop()) + ) + ) + + static layerClient = Layer.unwrap( + Effect.gen(function*() { + const container = yield* LibsqlContainer + return LibsqlClient.layer({ + url: `http://localhost:${container.getMappedPort(8080)}` + }) + }) + ).pipe(Layer.provide(this.layer)) +} diff --git a/packages/sql/libsql/tsconfig.build.json b/packages/sql/libsql/tsconfig.build.json new file mode 100644 index 0000000000..e738132ff9 --- /dev/null +++ b/packages/sql/libsql/tsconfig.build.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "./tsconfig.src.json", + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", + "outDir": "dist", + "stripInternal": true + } +} diff --git a/packages/sql/libsql/tsconfig.json b/packages/sql/libsql/tsconfig.json new file mode 100644 index 0000000000..11922f5b68 --- /dev/null +++ b/packages/sql/libsql/tsconfig.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": [], + "references": [{ "path": "tsconfig.src.json" }, { "path": "tsconfig.test.json" }] +} diff --git a/packages/sql/libsql/tsconfig.src.json b/packages/sql/libsql/tsconfig.src.json new file mode 100644 index 0000000000..00f9cbaff4 --- /dev/null +++ b/packages/sql/libsql/tsconfig.src.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["src"], + "references": [{ "path": "../../effect/tsconfig.src.json" }, { "path": "../../platform-node/tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", + "outDir": ".tsbuildinfo/src", + "rootDir": "src", + "types": ["node"] + } +} diff --git a/packages/sql/libsql/tsconfig.test.json b/packages/sql/libsql/tsconfig.test.json new file mode 100644 index 0000000000..9ed82478a2 --- /dev/null +++ b/packages/sql/libsql/tsconfig.test.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["test/**/*.ts", "test/**/*.json"], + "references": [{ "path": "tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/test.tsbuildinfo", + "outDir": ".tsbuildinfo/test", + "rootDir": "test", + "noEmit": true, + "erasableSyntaxOnly": false, + "resolveJsonModule": true, + "baseUrl": ".", + "paths": { + "@effect/sql-libsql": ["src/index.ts"], + "@effect/sql-libsql/*": ["src/*/index.ts", "src/*.ts"] + }, + "plugins": [ + { + "name": "@effect/language-service", + "namespaceImportPackages": [] + } + ] + } +} diff --git a/packages/sql/libsql/vitest.config.ts b/packages/sql/libsql/vitest.config.ts new file mode 100644 index 0000000000..c8a52c1826 --- /dev/null +++ b/packages/sql/libsql/vitest.config.ts @@ -0,0 +1,6 @@ +import { mergeConfig, type ViteUserConfig } from "vitest/config" +import shared from "../../../vitest.shared.ts" + +const config: ViteUserConfig = {} + +export default mergeConfig(shared, config) diff --git a/packages/sql/mssql/LICENSE b/packages/sql/mssql/LICENSE new file mode 100644 index 0000000000..7f6fe480f7 --- /dev/null +++ b/packages/sql/mssql/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023-present The Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/sql/mssql/README.md b/packages/sql/mssql/README.md new file mode 100644 index 0000000000..40a8f8bcbe --- /dev/null +++ b/packages/sql/mssql/README.md @@ -0,0 +1,7 @@ +# `@effect/sql-mssql` + +An `@effect/sql` implementation using the mssql `tedious` library. + +## Documentation + +- **API Reference**: [View the full documentation](https://effect-ts.github.io/effect/docs/sql-mssql). diff --git a/packages/sql/mssql/docgen.json b/packages/sql/mssql/docgen.json new file mode 100644 index 0000000000..114f1a6c2f --- /dev/null +++ b/packages/sql/mssql/docgen.json @@ -0,0 +1,20 @@ +{ + "$schema": "../../node_modules/@effect/docgen/schema.json", + "srcLink": "https://github.com/Effect-TS/effect/tree/main/packages/sql/d1/src/", + "exclude": ["src/internal/**/*.ts"], + "examplesCompilerOptions": { + "noEmit": true, + "strict": true, + "skipLibCheck": true, + "moduleResolution": "Bundler", + "module": "ES2022", + "target": "ES2022", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "rewriteRelativeImportExtensions": true, + "allowImportingTsExtensions": true, + "paths": { + "effect": ["../../../effect/src/index.js"], + "effect/*": ["../../../effect/src/*.js"] + } + } +} diff --git a/packages/sql/mssql/examples/docker-compose.yaml b/packages/sql/mssql/examples/docker-compose.yaml new file mode 100644 index 0000000000..f4e69e9182 --- /dev/null +++ b/packages/sql/mssql/examples/docker-compose.yaml @@ -0,0 +1,22 @@ +services: + db: + environment: + ACCEPT_EULA: "Y" + SA_PASSWORD: "Sq1Fx_password" + # mssql server image isn't available for arm64 architecture, so we use azure-sql instead + # image: mcr.microsoft.com/azure-sql-edge:1.0.4 + # If you really want to use MS SQL Server, uncomment the following line + image: mcr.microsoft.com/mssql/server + ports: + - 1433:1433 + restart: always + healthcheck: + test: + [ + "CMD-SHELL", + "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Sq1Fx_password -Q 'SELECT 1' || exit 1", + ] + interval: 10s + retries: 10 + start_period: 10s + timeout: 3s diff --git a/packages/sql/mssql/examples/migrations.ts b/packages/sql/mssql/examples/migrations.ts new file mode 100644 index 0000000000..cff5cb380c --- /dev/null +++ b/packages/sql/mssql/examples/migrations.ts @@ -0,0 +1,100 @@ +import * as DevTools from "@effect/experimental/DevTools" +import { NodeFileSystem } from "@effect/platform-node" +import { MssqlClient, MssqlMigrator, MssqlTypes, Procedure } from "@effect/sql-mssql" +import { Effect, Layer, Logger, LogLevel, Redacted, String } from "effect" +import { pipe } from "effect/Function" +import { fileURLToPath } from "node:url" + +const peopleProcedure = pipe( + Procedure.make("people_proc"), + Procedure.param()("name", MssqlTypes.VarChar), + Procedure.withRows<{ readonly id: number; readonly name: string }>(), + Procedure.compile +) + +const program = Effect.gen(function*() { + const sql = yield* MssqlClient.MssqlClient + + yield* sql` + CREATE OR ALTER PROC people_proc + @name VARCHAR(255) + AS + BEGIN + SELECT * FROM people WHERE name = @name + END + ` + + // Insert + const [inserted] = yield* sql`INSERT INTO ${sql("people")} ${ + sql.insert({ + name: "Tim", + createdAt: new Date() + }).returning("*") + }` + + console.log(inserted) + + console.log( + yield* Effect.all( + [ + sql`SELECT TOP(3) * FROM ${sql("people")}`, + sql`SELECT TOP(3) * FROM ${sql("people")}`.values, + sql`SELECT TOP(3) * FROM ${sql("people")}`.withoutTransform, + sql.call(peopleProcedure({ name: "Tim" })) + ], + { concurrency: "unbounded" } + ) + ) + + console.log( + yield* sql` + UPDATE people + SET name = data.name + ${sql.updateValues([{ ...inserted, name: "New name" }], "data").returning("*")} + WHERE people.id = data.id + ` + ) + + console.log( + yield* pipe( + sql`SELECT TOP(3) * FROM ${sql("people")}`, + Effect.zipRight( + Effect.catchAllCause( + sql.withTransaction(Effect.die("fail")), + (_) => Effect.void + ) + ), + Effect.zipRight( + sql.withTransaction(sql`SELECT TOP(3) * FROM ${sql("people")}`) + ), + sql.withTransaction + ) + ) +}) + +const SqlLive = MssqlMigrator.layer({ + loader: MssqlMigrator.fromFileSystem( + fileURLToPath(new URL("./migrations", import.meta.url)) + ) +}).pipe( + Layer.provideMerge( + MssqlClient.layer({ + database: "msdb", + server: "localhost", + username: "sa", + password: Redacted.make("Sq1Fx_password"), + transformQueryNames: String.camelToSnake, + transformResultNames: String.snakeToCamel + }) + ), + Layer.provide(NodeFileSystem.layer), + Layer.provide(DevTools.layer()), + Layer.provide(Logger.minimumLogLevel(LogLevel.All)) +) + +pipe( + program, + Effect.provide(SqlLive), + Effect.tapErrorCause(Effect.logError), + Effect.runFork +) diff --git a/packages/sql/mssql/examples/migrations/0001_create_people.ts b/packages/sql/mssql/examples/migrations/0001_create_people.ts new file mode 100644 index 0000000000..0f6e83ed9c --- /dev/null +++ b/packages/sql/mssql/examples/migrations/0001_create_people.ts @@ -0,0 +1,12 @@ +import { MssqlClient } from "@effect/sql-mssql" +import { Effect } from "effect" + +export default Effect.flatMap( + MssqlClient.MssqlClient, + (sql) => + sql`CREATE TABLE people ( + id INT IDENTITY(1,1) PRIMARY KEY, + name NVARCHAR(255) NOT NULL, + created_at DATETIME NOT NULL DEFAULT GETDATE() + )` +) diff --git a/packages/sql/mssql/package.json b/packages/sql/mssql/package.json new file mode 100644 index 0000000000..14bfe5efb9 --- /dev/null +++ b/packages/sql/mssql/package.json @@ -0,0 +1,67 @@ +{ + "name": "@effect/sql-mssql", + "version": "0.45.1", + "type": "module", + "license": "MIT", + "description": "A Microsoft SQL Server toolkit for Effect", + "homepage": "https://effect.website", + "repository": { + "type": "git", + "url": "https://github.com/Effect-TS/effect.git", + "directory": "packages/sql/mssql" + }, + "bugs": { + "url": "https://github.com/Effect-TS/effect/issues" + }, + "tags": [ + "typescript", + "sql", + "database" + ], + "keywords": [ + "typescript", + "sql", + "database" + ], + "sideEffects": [], + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts", + "./*": "./src/*.ts", + "./internal/*": null, + "./*/index": null + }, + "files": [ + "src/**/*.ts", + "dist/**/*.js", + "dist/**/*.js.map", + "dist/**/*.d.ts", + "dist/**/*.d.ts.map" + ], + "publishConfig": { + "provenance": true, + "exports": { + "./package.json": "./package.json", + ".": "./dist/index.js", + "./*": "./dist/*.js", + "./internal/*": null, + "./*/index": null + } + }, + "scripts": { + "codegen": "build-utils prepare-v4", + "build": "tsc -b tsconfig.build.json && babel dist --plugins annotate-pure-calls --out-dir dist --source-maps", + "check": "tsc -b tsconfig.json", + "test": "vitest", + "coverage": "vitest --coverage" + }, + "devDependencies": { + "effect": "workspace:^" + }, + "peerDependencies": { + "effect": "workspace:^" + }, + "dependencies": { + "tedious": "^18.3.0" + } +} diff --git a/packages/sql/mssql/src/.index.ts b/packages/sql/mssql/src/.index.ts new file mode 100644 index 0000000000..e251c89d63 --- /dev/null +++ b/packages/sql/mssql/src/.index.ts @@ -0,0 +1,10 @@ +/** + * @since 1.0.0 + */ + +export { + /** + * @since 1.0.0 + */ + TYPES as MssqlTypes +} from "tedious" diff --git a/packages/sql/mssql/src/MssqlClient.ts b/packages/sql/mssql/src/MssqlClient.ts new file mode 100644 index 0000000000..1666225373 --- /dev/null +++ b/packages/sql/mssql/src/MssqlClient.ts @@ -0,0 +1,554 @@ +/** + * @since 1.0.0 + */ +import * as Config from "effect/config/Config" +import * as Redacted from "effect/data/Redacted" +import * as Effect from "effect/Effect" +import { identity } from "effect/Function" +import * as Layer from "effect/Layer" +import * as Pool from "effect/Pool" +import * as Scope from "effect/Scope" +import * as ServiceMap from "effect/ServiceMap" +import * as Stream from "effect/stream/Stream" +import * as Duration from "effect/time/Duration" +import * as Reactivity from "effect/unstable/reactivity/Reactivity" +import * as Client from "effect/unstable/sql/SqlClient" +import type { Connection } from "effect/unstable/sql/SqlConnection" +import { SqlError } from "effect/unstable/sql/SqlError" +import * as Statement from "effect/unstable/sql/Statement" +import * as Tedious from "tedious" +import type { ConnectionOptions } from "tedious/lib/connection.ts" +import type { DataType } from "tedious/lib/data-type.ts" +import type { ParameterOptions } from "tedious/lib/request.ts" +import type { Parameter } from "./Parameter.ts" +import type * as Procedure from "./Procedure.ts" + +const ATTR_DB_SYSTEM_NAME = "db.system.name" +const ATTR_DB_NAMESPACE = "db.namespace" +const ATTR_SERVER_ADDRESS = "server.address" +const ATTR_SERVER_PORT = "server.port" + +/** + * @category type ids + * @since 1.0.0 + */ +export const TypeId: unique symbol = Symbol.for("@effect/sql-mssql/MssqlClient") + +/** + * @category type ids + * @since 1.0.0 + */ +export type TypeId = typeof TypeId + +/** + * @category models + * @since 1.0.0 + */ +export interface MssqlClient extends Client.SqlClient { + readonly [TypeId]: TypeId + + readonly config: MssqlClientConfig + + readonly param: ( + type: DataType, + value: Statement.Primitive, + options?: ParameterOptions + ) => Statement.Fragment + + readonly call: < + I extends Record>, + O extends Record>, + A extends object + >( + procedure: Procedure.ProcedureWithValues + ) => Effect.Effect, SqlError> +} + +/** + * @category tags + * @since 1.0.0 + */ +export const MssqlClient = ServiceMap.Key("@effect/sql-mssql/MssqlClient") + +/** + * @category models + * @since 1.0.0 + */ +export interface MssqlClientConfig { + readonly domain?: string | undefined + readonly server: string + readonly instanceName?: string | undefined + readonly encrypt?: boolean | undefined + readonly trustServer?: boolean | undefined + readonly port?: number | undefined + readonly authType?: string | undefined + readonly database?: string | undefined + readonly username?: string | undefined + readonly password?: Redacted.Redacted | undefined + readonly connectTimeout?: Duration.DurationInput | undefined + + readonly minConnections?: number | undefined + readonly maxConnections?: number | undefined + readonly connectionTTL?: Duration.DurationInput | undefined + + readonly parameterTypes?: Record | undefined + + readonly spanAttributes?: Record | undefined + + readonly transformResultNames?: ((str: string) => string) | undefined + readonly transformQueryNames?: ((str: string) => string) | undefined +} + +interface MssqlConnection extends Connection { + readonly call: ( + procedure: Procedure.ProcedureWithValues, + transformRows: ((rows: ReadonlyArray) => ReadonlyArray) | undefined + ) => Effect.Effect + + readonly begin: Effect.Effect + readonly commit: Effect.Effect + readonly savepoint: (name: string) => Effect.Effect + readonly rollback: (name?: string) => Effect.Effect +} + +const TransactionConnection = Client.TransactionConnection as unknown as ServiceMap.Key< + readonly [conn: MssqlConnection, counter: number], + readonly [conn: MssqlConnection, counter: number] +> + +/** + * @category constructors + * @since 1.0.0 + */ +export const make = ( + options: MssqlClientConfig +): Effect.Effect => + Effect.gen(function*() { + const parameterTypes = options.parameterTypes ?? defaultParameterTypes + const compiler = makeCompiler(options.transformQueryNames) + + const transformRows = options.transformResultNames ? + Statement.defaultTransforms( + options.transformResultNames + ).array : + undefined + const spanAttributes: ReadonlyArray<[string, unknown]> = [ + ...(options.spanAttributes ? Object.entries(options.spanAttributes) : []), + [ATTR_DB_SYSTEM_NAME, "microsoft.sql_server"], + [ATTR_DB_NAMESPACE, options.database ?? "master"], + [ATTR_SERVER_ADDRESS, options.server], + [ATTR_SERVER_PORT, options.port ?? 1433] + ] + + // eslint-disable-next-line prefer-const + let pool: Pool.Pool + + const makeConnection = Effect.gen(function*() { + const conn = new Tedious.Connection({ + options: { + port: options.port, + database: options.database, + trustServerCertificate: options.trustServer ?? true, + connectTimeout: options.connectTimeout + ? Duration.toMillis(Duration.decode(options.connectTimeout)) + : undefined, + rowCollectionOnRequestCompletion: true, + useColumnNames: false, + instanceName: options.instanceName, + encrypt: options.encrypt ?? false + } as ConnectionOptions, + server: options.server, + authentication: { + type: (options.authType as any) ?? "default", + options: { + userName: options.username, + password: options.password + ? Redacted.value(options.password) + : undefined + } + } + }) + + yield* Effect.addFinalizer(() => Effect.sync(() => conn.close())) + + yield* Effect.callback((resume) => { + conn.connect((cause) => { + if (cause) { + resume(Effect.fail(new SqlError({ cause, message: "Failed to connect" }))) + } else { + resume(Effect.void) + } + }) + }) + + const run = ( + sql: string, + values?: ReadonlyArray, + rowsAsArray = false + ) => + Effect.callback((resume) => { + const req = new Tedious.Request(sql, (cause, _rowCount, result) => { + if (cause) { + resume(Effect.fail(new SqlError({ cause, message: "Failed to execute statement" }))) + return + } + + if (rowsAsArray) { + result = result.map((row: any) => row.map((_: any) => _.value)) + } else { + result = rowsToObjects(result) + } + + resume(Effect.succeed(result)) + }) + + if (values) { + for (let i = 0, len = values.length; i < len; i++) { + const value = values[i] + const name = numberToParamName(i) + + if (isMssqlParam(value)) { + req.addParameter(name, value.paramA, value.paramB, value.paramC) + } else { + const kind = Statement.primitiveKind(value) + const type = parameterTypes[kind] + req.addParameter(name, type, value) + } + } + } + + conn.cancel() + conn.execSql(req) + }) + + const runProcedure = ( + procedure: Procedure.ProcedureWithValues, + transformRows: ((rows: ReadonlyArray) => ReadonlyArray) | undefined + ) => + Effect.callback((resume) => { + const result: Record = {} + + const req = new Tedious.Request( + escape(procedure.name), + (cause, _, rows) => { + if (cause) { + resume(Effect.fail(new SqlError({ cause, message: "Failed to execute statement" }))) + } else { + rows = rowsToObjects(rows) + if (transformRows) { + rows = transformRows(rows) as any + } + resume( + Effect.succeed({ + params: result, + rows + }) + ) + } + } + ) + + for (const name in procedure.params) { + const param = procedure.params[name] + const value = procedure.values[name] + req.addParameter(name, param.type, value, param.options) + } + + for (const name in procedure.outputParams) { + const param = procedure.outputParams[name] + req.addOutputParameter(name, param.type, undefined, param.options) + } + + req.on("returnValue", (name, value) => { + result[name] = value + }) + + conn.cancel() + conn.callProcedure(req) + }) + + const connection = identity({ + execute(sql, params, transformRows) { + return transformRows + ? Effect.map(run(sql, params), transformRows) + : run(sql, params) + }, + executeRaw(sql, params) { + return run(sql, params) + }, + executeValues(sql, params) { + return run(sql, params, true) + }, + executeUnprepared(sql, params, transformRows) { + return this.execute(sql, params, transformRows) + }, + executeStream() { + return Stream.die("executeStream not implemented") + }, + call(procedure, transformRows) { + return runProcedure(procedure, transformRows) + }, + begin: Effect.callback((resume) => { + conn.beginTransaction((cause) => { + if (cause) { + resume(Effect.fail(new SqlError({ cause, message: "Failed to begin transaction" }))) + } else { + resume(Effect.void) + } + }) + }), + commit: Effect.callback((resume) => { + conn.commitTransaction((cause) => { + if (cause) { + resume(Effect.fail(new SqlError({ cause, message: "Failed to commit transaction" }))) + } else { + resume(Effect.void) + } + }) + }), + savepoint: (name: string) => + Effect.callback((resume) => { + conn.saveTransaction((cause) => { + if (cause) { + resume(Effect.fail(new SqlError({ cause, message: "Failed to create savepoint" }))) + } else { + resume(Effect.void) + } + }, name) + }), + rollback: (name?: string) => + Effect.callback((resume) => { + conn.rollbackTransaction((cause) => { + if (cause) { + resume(Effect.fail(new SqlError({ cause, message: "Failed to rollback transaction" }))) + } else { + resume(Effect.void) + } + }, name) + }) + }) + + yield* Effect.callback((resume) => { + conn.on("error", (_) => resume(Effect.fail(_))) + }).pipe( + Effect.catch(() => Pool.invalidate(pool, connection)), + Effect.interruptible, + Effect.forkScoped + ) + + return connection + }) + + pool = yield* Pool.makeWithTTL({ + acquire: makeConnection, + min: options.minConnections ?? 1, + max: options.maxConnections ?? 10, + timeToLive: options.connectionTTL ?? Duration.minutes(45), + timeToLiveStrategy: "creation" + }) + + yield* Pool.get(pool).pipe( + Effect.tap((connection) => connection.executeUnprepared("SELECT 1", [], undefined)), + Effect.mapError(({ cause }) => new SqlError({ cause, message: "MssqlClient: Failed to connect" })), + Effect.scoped, + Effect.timeoutOrElse({ + duration: options.connectTimeout ?? Duration.seconds(5), + onTimeout: () => + Effect.fail( + new SqlError({ + message: "MssqlClient: Connection timeout", + cause: new Error("connection timeout") + }) + ) + }) + ) + + const withTransaction = Client.makeWithTransaction({ + transactionTag: TransactionConnection, + spanAttributes, + acquireConnection: Effect.gen(function*() { + const scope = Scope.unsafeMake() + const conn = yield* Scope.provide(Pool.get(pool), scope) + return [scope, conn] as const + }), + begin: (conn) => conn.begin, + savepoint: (conn, id) => conn.savepoint(`effect_sql_${id}`), + commit: (conn) => conn.commit, + rollback: (conn) => conn.rollback(), + rollbackSavepoint: (conn, id) => conn.rollback(`effect_sql_${id}`) + }) + + return identity(Object.assign( + yield* Client.make({ + acquirer: Pool.get(pool), + compiler, + spanAttributes, + transformRows + }), + { + [TypeId]: TypeId as TypeId, + config: options, + withTransaction, + param: ( + type: DataType, + value: Statement.Primitive, + options: ParameterOptions = {} + ) => Statement.fragment([mssqlParam(type, value, options)]), + call: < + I extends Record>, + O extends Record>, + A + >( + procedure: Procedure.ProcedureWithValues + ) => Effect.scoped(Effect.flatMap(Pool.get(pool), (_) => _.call(procedure, transformRows))), + withoutTransforms() { + const statement = Statement.make(Pool.get(pool), compiler.withoutTransform, spanAttributes, undefined) + const client = Object.assign( + statement, + this, + statement, + { + call: < + I extends Record>, + O extends Record>, + A + >( + procedure: Procedure.ProcedureWithValues + ) => Effect.scoped(Effect.flatMap(Pool.get(pool), (_) => _.call(procedure, undefined))) + } + ) + ;(client as any).safe = client + ;(client as any).withoutTransforms = () => client + return client + } + } + )) + }) + +/** + * @category layers + * @since 1.0.0 + */ +export const layerConfig = ( + config: Config.Wrap +): Layer.Layer => + Layer.effectServices( + Config.unwrap(config).asEffect().pipe( + Effect.flatMap(make), + Effect.map((client) => + ServiceMap.make(MssqlClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + ) + ) + ) + ).pipe(Layer.provide(Reactivity.layer)) + +/** + * @category layers + * @since 1.0.0 + */ +export const layer = ( + config: MssqlClientConfig +): Layer.Layer => + Layer.effectServices( + Effect.map(make(config), (client) => + ServiceMap.make(MssqlClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + )) + ).pipe(Layer.provide(Reactivity.layer)) + +/** + * @category compiler + * @since 1.0.0 + */ +export const makeCompiler = (transform?: (_: string) => string) => + Statement.makeCompiler({ + dialect: "mssql", + placeholder(_) { + return `@${numberToParamName(_ - 1)}` + }, + onIdentifier: transform ? + function(value, withoutTransform) { + return withoutTransform ? escape(value) : escape(transform(value)) + } : + escape, + onRecordUpdate(placeholders, valueAlias, valueColumns, values, returning) { + const returningSql = returning ? returning[0] === "*" ? "OUTPUT INSERTED.* " : `OUTPUT ${returning[0]} ` : "" + return [ + `${returningSql}FROM (values ${placeholders}) AS ${valueAlias}${valueColumns}`, + returning ? + returning[1].concat(values.flat()) : + values.flat() + ] + }, + onCustom(type, placeholder) { + switch (type.kind) { + case "MssqlParam": { + return [placeholder(undefined), [type] as any] + } + } + }, + onInsert(columns, placeholders, values, returning) { + const returningSql = returning ? returning[0] === "*" ? " OUTPUT INSERTED.*" : ` OUTPUT ${returning[0]}` : "" + return [ + `(${columns.join(",")})${returningSql} VALUES ${placeholders}`, + returning ? + returning[1].concat(values.flat()) : + values.flat() + ] + } + }) + +// compiler helpers + +const escape = (str: string) => "[" + str.replace(/\]/g, "]]").replace(/\./g, "].[") + "]" + +function numberToParamName(n: number) { + return `${Math.ceil(n + 1)}` +} + +/** + * @since 1.0.0 + */ +export const defaultParameterTypes: Record = { + string: Tedious.TYPES.VarChar, + number: Tedious.TYPES.Int, + bigint: Tedious.TYPES.BigInt, + boolean: Tedious.TYPES.Bit, + Date: Tedious.TYPES.DateTime, + Uint8Array: Tedious.TYPES.VarBinary, + Int8Array: Tedious.TYPES.VarBinary, + null: Tedious.TYPES.Bit +} + +// custom types + +type MssqlCustom = MssqlParam + +interface MssqlParam extends + Statement.Custom< + "MssqlParam", + DataType, + Statement.Primitive, + ParameterOptions + > +{} + +const mssqlParam = Statement.custom("MssqlParam") +const isMssqlParam = Statement.isCustom("MssqlParam") + +function rowsToObjects(rows: ReadonlyArray) { + const newRows = new Array(rows.length) + + for (let i = 0, len = rows.length; i < len; i++) { + const row = rows[i] + const newRow: any = {} + for (let j = 0, columnLen = row.length; j < columnLen; j++) { + const column = row[j] + newRow[column.metadata.colName] = column.value + } + newRows[i] = newRow + } + + return newRows +} diff --git a/packages/sql/mssql/src/MssqlMigrator.ts b/packages/sql/mssql/src/MssqlMigrator.ts new file mode 100644 index 0000000000..a58b8aac02 --- /dev/null +++ b/packages/sql/mssql/src/MssqlMigrator.ts @@ -0,0 +1,33 @@ +/** + * @since 1.0.0 + */ +import type * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" +import * as Migrator from "effect/unstable/sql/Migrator" +import type * as Client from "effect/unstable/sql/SqlClient" +import type { SqlError } from "effect/unstable/sql/SqlError" + +/** + * @since 1.0.0 + */ +export * from "effect/unstable/sql/Migrator" + +/** + * @category constructor + * @since 1.0.0 + */ +export const run: ( + options: Migrator.MigratorOptions +) => Effect.Effect< + ReadonlyArray, + SqlError | Migrator.MigrationError, + Client.SqlClient | R +> = Migrator.make({}) + +/** + * @category layers + * @since 1.0.0 + */ +export const layer = ( + options: Migrator.MigratorOptions +): Layer.Layer => Layer.effectDiscard(run(options)) diff --git a/packages/sql/mssql/src/Parameter.ts b/packages/sql/mssql/src/Parameter.ts new file mode 100644 index 0000000000..5bdd80a5ab --- /dev/null +++ b/packages/sql/mssql/src/Parameter.ts @@ -0,0 +1,46 @@ +/** + * @since 1.0.0 + */ +import { identity } from "effect/Function" +import type { DataType } from "tedious/lib/data-type.ts" +import type { ParameterOptions } from "tedious/lib/request.ts" + +/** + * @category type id + * @since 1.0.0 + */ +export const TypeId: TypeId = "~@effect/sql-mssql/Parameter" + +/** + * @category type id + * @since 1.0.0 + */ +export type TypeId = "~@effect/sql-mssql/Parameter" + +/** + * @category model + * @since 1.0.0 + */ +export interface Parameter { + readonly [TypeId]: (_: never) => A + readonly _tag: "Parameter" + readonly name: string + readonly type: DataType + readonly options: ParameterOptions +} + +/** + * @category constructor + * @since 1.0.0 + */ +export const make = ( + name: string, + type: DataType, + options: ParameterOptions = {} +): Parameter => ({ + [TypeId]: identity, + _tag: "Parameter", + name, + type, + options +}) diff --git a/packages/sql/mssql/src/Procedure.ts b/packages/sql/mssql/src/Procedure.ts new file mode 100644 index 0000000000..1b94033821 --- /dev/null +++ b/packages/sql/mssql/src/Procedure.ts @@ -0,0 +1,180 @@ +/** + * @since 1.0.0 + */ +import { identity } from "effect/Function" +import type { Pipeable } from "effect/interfaces/Pipeable" +import { pipeArguments } from "effect/interfaces/Pipeable" +import type { Covariant } from "effect/types/Types" +import type { Row } from "effect/unstable/sql/SqlConnection" +import type { DataType } from "tedious/lib/data-type.ts" +import type { ParameterOptions } from "tedious/lib/request.ts" +import * as Parameter from "./Parameter.ts" + +/** + * @category type id + * @since 1.0.0 + */ +export const TypeId: TypeId = "~@effect/sql-mssql/Procedure" + +/** + * @category type id + * @since 1.0.0 + */ +export type TypeId = "~@effect/sql-mssql/Procedure" + +/** + * @category model + * @since 1.0.0 + */ +export interface Procedure< + I extends Record>, + O extends Record>, + A = never +> extends Pipeable { + readonly [TypeId]: { + readonly _A: Covariant + } + readonly _tag: "Procedure" + readonly name: string + readonly params: I + readonly outputParams: O +} + +/** + * @category model + * @since 1.0.0 + */ +export interface ProcedureWithValues< + I extends Record>, + O extends Record>, + A +> extends Procedure { + readonly values: Procedure.ParametersRecord +} + +/** + * @since 1.0.0 + */ +export namespace Procedure { + /** + * @since 1.0.0 + */ + export type ParametersRecord< + A extends Record> + > = + & { + readonly [K in keyof A]: A[K] extends Parameter.Parameter ? T + : never + } + & {} + + /** + * @category model + * @since 1.0.0 + */ + export interface Result< + O extends Record>, + A + > { + readonly output: ParametersRecord + readonly rows: ReadonlyArray + } +} + +type Simplify = { [K in keyof A]: A[K] } & {} + +const procedureProto = { + [TypeId]: { + _A: identity + }, + _tag: "Procedure", + pipe() { + return pipeArguments(this, arguments) + } +} + +/** + * @category constructor + * @since 1.0.0 + */ +export const make = (name: string): Procedure<{}, {}> => { + const procedure = Object.create(procedureProto) + procedure.name = name + procedure.params = {} + procedure.outputParams = {} + return procedure +} + +/** + * @category combinator + * @since 1.0.0 + */ +export const param = () => +( + name: N, + type: T, + options?: ParameterOptions +) => +< + I extends Record>, + O extends Record> +>( + self: Procedure +): Procedure }>, O> => ({ + ...self, + params: { + ...self.params, + [name]: Parameter.make(name, type, options) + } +}) + +/** + * @category combinator + * @since 1.0.0 + */ +export const outputParam = () => +( + name: N, + type: T, + options?: ParameterOptions +) => +< + I extends Record>, + O extends Record> +>( + self: Procedure +): Procedure }>> => ({ + ...self, + outputParams: { + ...self.outputParams, + [name]: Parameter.make(name, type, options) + } +}) + +/** + * @category combinator + * @since 1.0.0 + */ +export const withRows = () => +< + I extends Record>, + O extends Record> +>( + self: Procedure +): Procedure => self as any + +/** + * @category combinator + * @since 1.0.0 + */ +export const compile = < + I extends Record>, + O extends Record>, + A +>( + self: Procedure +) => +(input: Procedure.ParametersRecord): ProcedureWithValues => ({ + ...self, + values: input +}) diff --git a/packages/sql/mssql/src/index.ts b/packages/sql/mssql/src/index.ts new file mode 100644 index 0000000000..99756f7892 --- /dev/null +++ b/packages/sql/mssql/src/index.ts @@ -0,0 +1,30 @@ +/** + * @since 1.0.0 + */ + +export { + /** + * @since 1.0.0 + */ + TYPES as MssqlTypes +} from "tedious" + +/** + * @since 1.0.0 + */ +export * as MssqlClient from "./MssqlClient.ts" + +/** + * @since 1.0.0 + */ +export * as MssqlMigrator from "./MssqlMigrator.ts" + +/** + * @since 1.0.0 + */ +export * as Parameter from "./Parameter.ts" + +/** + * @since 1.0.0 + */ +export * as Procedure from "./Procedure.ts" diff --git a/packages/sql/mssql/src/index.ts.tpl b/packages/sql/mssql/src/index.ts.tpl new file mode 100644 index 0000000000..e251c89d63 --- /dev/null +++ b/packages/sql/mssql/src/index.ts.tpl @@ -0,0 +1,10 @@ +/** + * @since 1.0.0 + */ + +export { + /** + * @since 1.0.0 + */ + TYPES as MssqlTypes +} from "tedious" diff --git a/packages/sql/mssql/test/Client.test.ts b/packages/sql/mssql/test/Client.test.ts new file mode 100644 index 0000000000..41a6d37b70 --- /dev/null +++ b/packages/sql/mssql/test/Client.test.ts @@ -0,0 +1,91 @@ +import { MssqlClient } from "@effect/sql-mssql" +import { describe, expect, it } from "@effect/vitest" +import { Effect } from "effect" +import * as Statement from "effect/unstable/sql/Statement" + +const sql = Statement.make(Effect.void as any, MssqlClient.makeCompiler(), [], undefined) + +describe("mssql", () => { + it("insert helper", () => { + const [query, params] = sql`INSERT INTO ${sql("people")} ${sql.insert({ name: "Tim", age: 10 })}`.compile() + expect(query).toEqual( + `INSERT INTO [people] ([name],[age]) VALUES (@1,@2)` + ) + expect(params).toEqual(["Tim", 10]) + }) + + it("insert helper returning", () => { + const [query, params] = sql`INSERT INTO ${sql("people")} ${sql.insert({ name: "Tim", age: 10 }).returning("*")}` + .compile() + expect(query).toEqual( + `INSERT INTO [people] ([name],[age]) OUTPUT INSERTED.* VALUES (@1,@2)` + ) + expect(params).toEqual(["Tim", 10]) + }) + + it("update helper", () => { + const [query, params] = sql`UPDATE people SET name = data.name ${ + sql.updateValues( + [{ name: "Tim" }, { name: "John" }], + "data" + ) + }`.compile() + expect(query).toEqual( + `UPDATE people SET name = data.name FROM (values (@1),(@2)) AS data([name])` + ) + expect(params).toEqual(["Tim", "John"]) + }) + + it("update helper returning", () => { + const [query, params] = sql`UPDATE people SET name = data.name ${ + sql.updateValues( + [{ name: "Tim" }, { name: "John" }], + "data" + ).returning("*") + }`.compile() + expect(query).toEqual( + `UPDATE people SET name = data.name OUTPUT INSERTED.* FROM (values (@1),(@2)) AS data([name])` + ) + expect(params).toEqual(["Tim", "John"]) + }) + + it("update single helper returning", () => { + const [query, params] = sql`UPDATE people SET ${sql.update({ name: "Tim" }).returning("*")}` + .compile() + expect(query).toEqual( + `UPDATE people SET [name] = @1 OUTPUT INSERTED.*` + ) + expect(params).toEqual(["Tim"]) + }) + + it("array helper", () => { + const [query, params] = sql`SELECT * FROM ${sql("people")} WHERE id IN ${sql.in([1, 2, "string"])}`.compile() + expect(query).toEqual(`SELECT * FROM [people] WHERE id IN (@1,@2,@3)`) + expect(params).toEqual([1, 2, "string"]) + }) + + // it("param types", () => { + // const [query, params] = sql`SELECT * FROM ${sql("people")} WHERE id = ${ + // sql.param( + // MssqlTypes.BigInt, + // 1 + // ) + // }`.compile() + // expect(query).toEqual(`SELECT * FROM [people] WHERE id = @1`) + // expect(isCustom("MssqlParam")(params[0])).toEqual(true) + // const param = params[0] as unknown as Custom< + // "MsSqlParam", + // any, + // any, + // any + // > + // expect(param.i0).toEqual(MssqlTypes.BigInt) + // expect(param.i1).toEqual(1) + // expect(param.i2).toEqual({}) + // }) + + it("escape [", () => { + const [query] = sql`SELECT * FROM ${sql("peo[]ple.te[st]ing")}`.compile() + expect(query).toEqual(`SELECT * FROM [peo[]]ple].[te[st]]ing]`) + }) +}) diff --git a/packages/sql/mssql/tsconfig.build.json b/packages/sql/mssql/tsconfig.build.json new file mode 100644 index 0000000000..e738132ff9 --- /dev/null +++ b/packages/sql/mssql/tsconfig.build.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "./tsconfig.src.json", + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", + "outDir": "dist", + "stripInternal": true + } +} diff --git a/packages/sql/mssql/tsconfig.json b/packages/sql/mssql/tsconfig.json new file mode 100644 index 0000000000..11922f5b68 --- /dev/null +++ b/packages/sql/mssql/tsconfig.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": [], + "references": [{ "path": "tsconfig.src.json" }, { "path": "tsconfig.test.json" }] +} diff --git a/packages/sql/mssql/tsconfig.src.json b/packages/sql/mssql/tsconfig.src.json new file mode 100644 index 0000000000..00f9cbaff4 --- /dev/null +++ b/packages/sql/mssql/tsconfig.src.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["src"], + "references": [{ "path": "../../effect/tsconfig.src.json" }, { "path": "../../platform-node/tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", + "outDir": ".tsbuildinfo/src", + "rootDir": "src", + "types": ["node"] + } +} diff --git a/packages/sql/mssql/tsconfig.test.json b/packages/sql/mssql/tsconfig.test.json new file mode 100644 index 0000000000..51e3152ddf --- /dev/null +++ b/packages/sql/mssql/tsconfig.test.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["test/**/*.ts", "test/**/*.json"], + "references": [{ "path": "tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/test.tsbuildinfo", + "outDir": ".tsbuildinfo/test", + "rootDir": "test", + "noEmit": true, + "erasableSyntaxOnly": false, + "resolveJsonModule": true, + "baseUrl": ".", + "paths": { + "@effect/sql-mssql": ["src/index.ts"], + "@effect/sql-mssql/*": ["src/*/index.ts", "src/*.ts"] + }, + "plugins": [ + { + "name": "@effect/language-service", + "namespaceImportPackages": [] + } + ] + } +} diff --git a/packages/sql/mssql/vitest.config.ts b/packages/sql/mssql/vitest.config.ts new file mode 100644 index 0000000000..c8a52c1826 --- /dev/null +++ b/packages/sql/mssql/vitest.config.ts @@ -0,0 +1,6 @@ +import { mergeConfig, type ViteUserConfig } from "vitest/config" +import shared from "../../../vitest.shared.ts" + +const config: ViteUserConfig = {} + +export default mergeConfig(shared, config) diff --git a/packages/sql/mysql2/LICENSE b/packages/sql/mysql2/LICENSE new file mode 100644 index 0000000000..7f6fe480f7 --- /dev/null +++ b/packages/sql/mysql2/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023-present The Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/sql/mysql2/README.md b/packages/sql/mysql2/README.md new file mode 100644 index 0000000000..9b4f3206c9 --- /dev/null +++ b/packages/sql/mysql2/README.md @@ -0,0 +1,7 @@ +# `@effect/sql-mysql2` + +An `@effect/sql` implementation using the `mysql2` library. + +## Documentation + +- **API Reference**: [View the full documentation](https://effect-ts.github.io/effect/docs/sql-mysql2). diff --git a/packages/sql/mysql2/docgen.json b/packages/sql/mysql2/docgen.json new file mode 100644 index 0000000000..167b687e4f --- /dev/null +++ b/packages/sql/mysql2/docgen.json @@ -0,0 +1,20 @@ +{ + "$schema": "../../node_modules/@effect/docgen/schema.json", + "srcLink": "https://github.com/Effect-TS/effect/tree/main/packages/sql/mysql2/src/", + "exclude": ["src/internal/**/*.ts"], + "examplesCompilerOptions": { + "noEmit": true, + "strict": true, + "skipLibCheck": true, + "moduleResolution": "Bundler", + "module": "ES2022", + "target": "ES2022", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "rewriteRelativeImportExtensions": true, + "allowImportingTsExtensions": true, + "paths": { + "effect": ["../../../effect/src/index.js"], + "effect/*": ["../../../effect/src/*.js"] + } + } +} diff --git a/packages/sql/mysql2/examples/statement-transform.ts b/packages/sql/mysql2/examples/statement-transform.ts new file mode 100644 index 0000000000..c3e547a335 --- /dev/null +++ b/packages/sql/mysql2/examples/statement-transform.ts @@ -0,0 +1,49 @@ +import * as DevTools from "@effect/experimental/DevTools" +import { SqlClient, Statement } from "effect/unstable/sql" +import { MysqlClient } from "@effect/sql-mysql2" +import { Effect, FiberRef, FiberRefs, Layer, Option, pipe, Redacted, String } from "effect" + +const currentResourceName = FiberRef.unsafeMake("") + +const SqlTracingLive = Statement.setTransformer((prev, sql, refs, span) => { + const [query, params] = prev.compile() + return Effect.succeed( + sql.unsafe( + `/* ${ + JSON.stringify({ + trace_id: span.traceId, + span_id: span.spanId, + resource_name: Option.getOrUndefined(FiberRefs.get(refs, currentResourceName)) + }) + } */ ${query}`, + params + ) + ) +}) + +const EnvLive = MysqlClient.layer({ + database: "effect_dev", + username: "effect", + password: Redacted.make("password"), + transformQueryNames: String.camelToSnake, + transformResultNames: String.snakeToCamel +}).pipe( + Layer.provide(SqlTracingLive), + Layer.provide(DevTools.layer()) +) + +const program = Effect.gen(function*() { + const sql = yield* SqlClient.SqlClient + yield* pipe( + sql`SELECT * FROM people`, + Effect.replicateEffect(50), + sql.withTransaction, + Effect.locally(currentResourceName, "GET /people") + ) +}) + +program.pipe( + Effect.provide(EnvLive), + Effect.tapErrorCause(Effect.logError), + Effect.runFork +) diff --git a/packages/sql/mysql2/package.json b/packages/sql/mysql2/package.json new file mode 100644 index 0000000000..4a4a5a603e --- /dev/null +++ b/packages/sql/mysql2/package.json @@ -0,0 +1,68 @@ +{ + "name": "@effect/sql-mysql2", + "version": "0.45.1", + "type": "module", + "license": "MIT", + "description": "A MySQL toolkit for Effect", + "homepage": "https://effect.website", + "repository": { + "type": "git", + "url": "https://github.com/Effect-TS/effect.git", + "directory": "packages/sql/mysql2" + }, + "bugs": { + "url": "https://github.com/Effect-TS/effect/issues" + }, + "tags": [ + "typescript", + "sql", + "database" + ], + "keywords": [ + "typescript", + "sql", + "database" + ], + "sideEffects": [], + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts", + "./*": "./src/*.ts", + "./internal/*": null, + "./*/index": null + }, + "files": [ + "src/**/*.ts", + "dist/**/*.js", + "dist/**/*.js.map", + "dist/**/*.d.ts", + "dist/**/*.d.ts.map" + ], + "publishConfig": { + "provenance": true, + "exports": { + "./package.json": "./package.json", + ".": "./dist/index.js", + "./*": "./dist/*.js", + "./internal/*": null, + "./*/index": null + } + }, + "scripts": { + "codegen": "build-utils prepare-v4", + "build": "tsc -b tsconfig.build.json && babel dist --plugins annotate-pure-calls --out-dir dist --source-maps", + "check": "tsc -b tsconfig.json", + "test": "vitest", + "coverage": "vitest --coverage" + }, + "devDependencies": { + "@testcontainers/mysql": "^11.5.1", + "effect": "workspace:^" + }, + "peerDependencies": { + "effect": "workspace:^" + }, + "dependencies": { + "mysql2": "^3.11.0" + } +} diff --git a/packages/sql/mysql2/src/MysqlClient.ts b/packages/sql/mysql2/src/MysqlClient.ts new file mode 100644 index 0000000000..cedaf5d27c --- /dev/null +++ b/packages/sql/mysql2/src/MysqlClient.ts @@ -0,0 +1,362 @@ +/** + * @since 1.0.0 + */ +import * as Config from "effect/config/Config" +import * as Redacted from "effect/data/Redacted" +import * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" +import type { Scope } from "effect/Scope" +import * as ServiceMap from "effect/ServiceMap" +import * as Stream from "effect/stream/Stream" +import * as Duration from "effect/time/Duration" +import * as Reactivity from "effect/unstable/reactivity/Reactivity" +import * as Client from "effect/unstable/sql/SqlClient" +import type { Connection } from "effect/unstable/sql/SqlConnection" +import { SqlError } from "effect/unstable/sql/SqlError" +import { asyncPauseResume } from "effect/unstable/sql/SqlStream" +import * as Statement from "effect/unstable/sql/Statement" +import * as Mysql from "mysql2" + +const ATTR_DB_SYSTEM_NAME = "db.system.name" +const ATTR_DB_NAMESPACE = "db.namespace" +const ATTR_SERVER_ADDRESS = "server.address" +const ATTR_SERVER_PORT = "server.port" + +/** + * @category type ids + * @since 1.0.0 + */ +export const TypeId: TypeId = "~@effect/sql-mysql2/MysqlClient" + +/** + * @category type ids + * @since 1.0.0 + */ +export type TypeId = "~@effect/sql-mysql2/MysqlClient" + +/** + * @category models + * @since 1.0.0 + */ +export interface MysqlClient extends Client.SqlClient { + readonly [TypeId]: TypeId + readonly config: MysqlClientConfig +} + +/** + * @category tags + * @since 1.0.0 + */ +export const MysqlClient = ServiceMap.Key("@effect/sql-mysql2/MysqlClient") + +/** + * @category models + * @since 1.0.0 + */ +export interface MysqlClientConfig { + /** + * Connection URI. Setting this will override the other connection options + */ + readonly url?: Redacted.Redacted | undefined + + readonly host?: string | undefined + readonly port?: number | undefined + readonly database?: string | undefined + readonly username?: string | undefined + readonly password?: Redacted.Redacted | undefined + + readonly maxConnections?: number | undefined + readonly connectionTTL?: Duration.DurationInput | undefined + + readonly poolConfig?: Mysql.PoolOptions | undefined + + readonly spanAttributes?: Record | undefined + + readonly transformResultNames?: ((str: string) => string) | undefined + readonly transformQueryNames?: ((str: string) => string) | undefined +} + +/** + * @category constructors + * @since 1.0.0 + */ +export const make = ( + options: MysqlClientConfig +): Effect.Effect => + Effect.gen(function*() { + const compiler = makeCompiler(options.transformQueryNames) + const transformRows = options.transformResultNames ? + Statement.defaultTransforms( + options.transformResultNames + ).array : + undefined + + class ConnectionImpl implements Connection { + readonly conn: Mysql.PoolConnection | Mysql.Pool + constructor(conn: Mysql.PoolConnection | Mysql.Pool) { + this.conn = conn + } + + private runRaw( + sql: string, + values?: ReadonlyArray, + rowsAsArray = false, + method: "execute" | "query" = "execute" + ) { + return Effect.callback((resume) => { + ;(this.conn as any)[method]({ + sql, + values, + rowsAsArray + }, (cause: unknown | null, results: unknown, _fields: any) => { + if (cause) { + resume(Effect.fail(new SqlError({ cause, message: "Failed to execute statement" }))) + } else { + resume(Effect.succeed(results)) + } + }) + }) + } + + private run( + sql: string, + values?: ReadonlyArray, + rowsAsArray = false, + method: "execute" | "query" = "execute" + ) { + return this.runRaw(sql, values, rowsAsArray, method).pipe( + Effect.map((results) => Array.isArray(results) ? results : []) + ) + } + + execute( + sql: string, + params: ReadonlyArray, + transformRows: ((row: ReadonlyArray) => ReadonlyArray) | undefined + ) { + return transformRows + ? Effect.map(this.run(sql, params), transformRows) + : this.run(sql, params) + } + executeRaw(sql: string, params: ReadonlyArray) { + return this.runRaw(sql, params) + } + executeValues(sql: string, params: ReadonlyArray) { + return this.run(sql, params, true) + } + executeUnprepared( + sql: string, + params: ReadonlyArray, + transformRows: ((row: ReadonlyArray) => ReadonlyArray) | undefined + ) { + return transformRows + ? Effect.map(this.run(sql, params, false, "query"), transformRows) + : this.run(sql, params, false, "query") + } + executeStream( + sql: string, + params: ReadonlyArray, + transformRows: ((row: ReadonlyArray) => ReadonlyArray) | undefined + ) { + const stream = queryStream(this.conn as any, sql, params) + return transformRows + ? Stream.mapArray(stream, (_) => transformRows(_) as any) + : stream + } + } + + const pool = options.url + ? Mysql.createPool({ + uri: Redacted.value(options.url), + multipleStatements: true, + supportBigNumbers: true, + connectionLimit: options.maxConnections!, + idleTimeout: options.connectionTTL + ? Duration.toMillis(options.connectionTTL) + : undefined as any + }) + : Mysql.createPool({ + ...(options.poolConfig ?? {}), + host: options.host, + port: options.port, + database: options.database, + user: options.username, + password: options.password + ? Redacted.value(options.password) + : undefined, + multipleStatements: true, + supportBigNumbers: true, + connectionLimit: options.maxConnections, + idleTimeout: options.connectionTTL + ? Duration.toMillis(options.connectionTTL) + : undefined + } as Mysql.PoolOptions) + + yield* Effect.acquireRelease( + Effect.callback((resume) => { + ;(pool as any).query("SELECT 1", (cause: Error) => { + if (cause) { + resume(Effect.fail( + new SqlError({ + cause, + message: "MysqlClient: Failed to connect" + }) + )) + } else { + resume(Effect.void) + } + }) + }), + () => + Effect.callback((resume) => { + pool.end(() => resume(Effect.void)) + }) + ).pipe( + Effect.timeoutOrElse({ + duration: Duration.seconds(5), + onTimeout: () => + Effect.fail( + new SqlError({ + message: "MysqlClient: Connection timeout", + cause: new Error("connection timeout") + }) + ) + }) + ) + + const poolConnection = new ConnectionImpl(pool) + + const acquireConn = Effect.acquireRelease( + Effect.callback((resume) => { + pool.getConnection((cause, conn) => { + if (cause) { + resume(Effect.fail(new SqlError({ cause, message: "Failed to acquire connection" }))) + } else { + resume(Effect.succeed(conn)) + } + }) + }), + (conn) => Effect.sync(() => conn.release()) + ) + + const transactionAcquirer = Effect.map( + acquireConn, + (conn) => new ConnectionImpl(conn) + ) + + const spanAttributes: Array<[string, unknown]> = [ + ...(options.spanAttributes ? Object.entries(options.spanAttributes) : []), + [ATTR_DB_SYSTEM_NAME, "mysql"], + [ATTR_SERVER_ADDRESS, options.host ?? "localhost"], + [ATTR_SERVER_PORT, options.port ?? 3306] + ] + + if (options.database) { + spanAttributes.push([ATTR_DB_NAMESPACE, options.database]) + } + + return Object.assign( + yield* Client.make({ + acquirer: Effect.succeed(poolConnection), + transactionAcquirer, + compiler, + spanAttributes, + transformRows + }), + { [TypeId]: TypeId as TypeId, config: options } + ) + }) + +/** + * @category layers + * @since 1.0.0 + */ +export const layerConfig = ( + config: Config.Wrap +): Layer.Layer => + Layer.effectServices( + Config.unwrap(config).asEffect().pipe( + Effect.flatMap(make), + Effect.map((client) => + ServiceMap.make(MysqlClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + ) + ) + ) + ).pipe(Layer.provide(Reactivity.layer)) + +/** + * @category layers + * @since 1.0.0 + */ +export const layer = ( + config: MysqlClientConfig +): Layer.Layer => + Layer.effectServices( + Effect.map(make(config), (client) => + ServiceMap.make(MysqlClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + )) + ).pipe(Layer.provide(Reactivity.layer)) + +/** + * @category compiler + * @since 1.0.0 + */ +export const makeCompiler = (transform?: (_: string) => string) => + Statement.makeCompiler({ + dialect: "mysql", + placeholder(_) { + return `?` + }, + onIdentifier: transform ? + function(value, withoutTransform) { + return withoutTransform ? escape(value) : escape(transform(value)) + } : + escape, + onCustom() { + return ["", []] + }, + onRecordUpdate() { + return ["", []] + } + }) + +const escape = Statement.defaultEscape("`") + +function queryStream( + conn: Mysql.PoolConnection, + sql: string, + params?: ReadonlyArray +) { + return asyncPauseResume(Effect.fnUntraced(function*(emit) { + const query = (conn as any).query(sql, params).stream() + yield* Effect.addFinalizer(() => Effect.sync(() => query.destroy())) + + let buffer: Array = [] + let taskPending = false + query.on("error", (cause: unknown) => emit.fail(new SqlError({ cause, message: "Failed to stream statement" }))) + query.on("data", (row: any) => { + buffer.push(row) + if (!taskPending) { + taskPending = true + queueMicrotask(() => { + const items = buffer + buffer = [] + emit.array(items) + taskPending = false + }) + } + }) + query.on("end", () => emit.end()) + + return { + onPause() { + query.pause() + }, + onResume() { + query.resume() + } + } + })) +} diff --git a/packages/sql/mysql2/src/MysqlMigrator.ts b/packages/sql/mysql2/src/MysqlMigrator.ts new file mode 100644 index 0000000000..73af79193d --- /dev/null +++ b/packages/sql/mysql2/src/MysqlMigrator.ts @@ -0,0 +1,90 @@ +/** + * @since 1.0.0 + */ +import type * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" +import * as Migrator from "effect/unstable/sql/Migrator" +import type * as Client from "effect/unstable/sql/SqlClient" +import type { SqlError } from "effect/unstable/sql/SqlError" + +/** + * @since 1.0.0 + */ +export * from "effect/unstable/sql/Migrator" + +/** + * @category constructor + * @since 1.0.0 + */ +export const run: ( + { loader, schemaDirectory, table }: Migrator.MigratorOptions +) => Effect.Effect< + ReadonlyArray, + Migrator.MigrationError | SqlError, + Client.SqlClient | R2 +> = Migrator.make({ + // TODO: re-add when Command module is available + // dumpSchema(path, table) { + // const mysqlDump = (args: Array) => + // Effect.gen(function*() { + // const sql = yield* MysqlClient + // const dump = yield* pipe( + // Command.make( + // "mysqldump", + // ...(sql.config.host ? ["-h", sql.config.host] : []), + // ...(sql.config.port ? ["-P", sql.config.port.toString()] : []), + // ...(sql.config.username ? ["-u", sql.config.username] : []), + // ...(sql.config.password ? [`-p${Redacted.value(sql.config.password)}`] : []), + // ...(sql.config.database ? [sql.config.database] : []), + // "--skip-comments", + // "--compact", + // ...args + // ), + // Command.env({ + // PATH: (globalThis as any).process?.env.PATH + // }), + // Command.string + // ) + // + // return dump.replace(/^\/\*.*$/gm, "") + // .replace(/\n{2,}/gm, "\n\n") + // .trim() + // }).pipe( + // Effect.mapError((error) => new Migrator.MigrationError({ reason: "failed", message: error.message })) + // ) + // + // const dumpSchema = mysqlDump(["--no-data"]) + // + // const dumpMigrations = mysqlDump(["--no-create-info", "--tables", table]) + // + // const dumpAll = Effect.map( + // Effect.all([dumpSchema, dumpMigrations], { concurrency: 2 }), + // ([schema, migrations]) => schema + "\n\n" + migrations + // ) + // + // const dumpFile = (file: string) => + // Effect.gen(function*() { + // const fs = yield* FileSystem + // const path = yield* Path + // const dump = yield* dumpAll + // yield* fs.makeDirectory(path.dirname(file), { recursive: true }) + // yield* fs.writeFileString(file, dump) + // }).pipe( + // Effect.mapError((error) => new Migrator.MigrationError({ reason: "failed", message: error.message })) + // ) + // + // return dumpFile(path) + // } +}) + +/** + * @category layers + * @since 1.0.0 + */ +export const layer = ( + options: Migrator.MigratorOptions +): Layer.Layer< + never, + Migrator.MigrationError | SqlError, + Client.SqlClient | R +> => Layer.effectDiscard(run(options)) diff --git a/packages/sql/mysql2/src/index.ts b/packages/sql/mysql2/src/index.ts new file mode 100644 index 0000000000..f83f82701f --- /dev/null +++ b/packages/sql/mysql2/src/index.ts @@ -0,0 +1,13 @@ +/** + * @since 1.0.0 + */ + +/** + * @since 1.0.0 + */ +export * as MysqlClient from "./MysqlClient.ts" + +/** + * @since 1.0.0 + */ +export * as MysqlMigrator from "./MysqlMigrator.ts" diff --git a/packages/sql/mysql2/src/index.ts.tpl b/packages/sql/mysql2/src/index.ts.tpl new file mode 100644 index 0000000000..b66408871c --- /dev/null +++ b/packages/sql/mysql2/src/index.ts.tpl @@ -0,0 +1,3 @@ +/** + * @since 1.0.0 + */ diff --git a/packages/sql/mysql2/test/Client.test.ts b/packages/sql/mysql2/test/Client.test.ts new file mode 100644 index 0000000000..ab299dc542 --- /dev/null +++ b/packages/sql/mysql2/test/Client.test.ts @@ -0,0 +1,35 @@ +import { assert, describe, it } from "@effect/vitest" +import { Effect, Layer } from "effect" +import { Logger } from "effect/logging" +import { SqlClient, Statement } from "effect/unstable/sql" +import { MysqlContainer } from "./utils.ts" + +const SqlLogger = Layer.succeed(Statement.CurrentTransformer)((statement) => { + const [query, params] = statement.compile() + return Effect.log("executing sql").pipe( + Effect.annotateLogs({ query, params }), + Effect.as(statement) + ) +}) + +describe("sql", () => { + it.effect("tranformers", () => + Effect.gen(function*() { + const logs: Array = [] + const sql = yield* SqlClient.SqlClient + const result = yield* sql<{ result: number }>`SELECT 1 + 1 AS result`.pipe( + Effect.provide(Logger.layer([ + Logger.make((log) => { + logs.push(log.message) + }) + ])) + ) + assert.deepStrictEqual(result, [{ result: 2 }]) + assert.deepStrictEqual(logs, [["executing sql"]]) + }).pipe( + Effect.provide(MysqlContainer.layerClient.pipe( + Layer.provideMerge(SqlLogger) + )), + Effect.catchTag("ContainerError", () => Effect.void) + ), { timeout: 60_000 }) +}) diff --git a/packages/sql/mysql2/test/Model.test.ts b/packages/sql/mysql2/test/Model.test.ts new file mode 100644 index 0000000000..c167637c88 --- /dev/null +++ b/packages/sql/mysql2/test/Model.test.ts @@ -0,0 +1,148 @@ +import { assert, describe, it } from "@effect/vitest" +import { Effect } from "effect" +import { Schema } from "effect/schema" +import { Model } from "effect/unstable/schema" +import { SqlClient, SqlModel } from "effect/unstable/sql" +import { MysqlContainer } from "./utils.ts" + +class User extends Model.Class("User")({ + id: Model.Generated(Schema.Int), + name: Schema.String, + age: Schema.Int +}) {} + +describe("SqlModel", () => { + it.effect("insert returns result", () => + Effect.gen(function*() { + const repo = yield* SqlModel.makeRepository(User, { + tableName: "users", + idColumn: "id", + spanPrefix: "UserRepository" + }) + const sql = yield* SqlClient.SqlClient + yield* sql`CREATE TABLE users (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), age INT)` + + const result = yield* repo.insert(User.insert.makeSync({ name: "Alice", age: 30 })) + assert.deepStrictEqual(result, new User({ id: 1, name: "Alice", age: 30 })) + }).pipe( + Effect.provide(MysqlContainer.layerClient), + Effect.catchTag("ContainerError", () => Effect.void) + ), { timeout: 60_000 }) + + it.effect("insert returns result with transforms", () => + Effect.gen(function*() { + const repo = yield* SqlModel.makeRepository(User, { + tableName: "users", + idColumn: "id", + spanPrefix: "UserRepository" + }) + const sql = yield* SqlClient.SqlClient + yield* sql`CREATE TABLE users (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), age INT)` + + const result = yield* repo.insert(User.insert.makeSync({ name: "Alice", age: 30 })) + assert.deepStrictEqual(result, new User({ id: 1, name: "Alice", age: 30 })) + }).pipe( + Effect.provide(MysqlContainer.layerClientWithTransforms), + Effect.catchTag("ContainerError", () => Effect.void) + ), { timeout: 60_000 }) + + it.effect("insertVoid", () => + Effect.gen(function*() { + const repo = yield* SqlModel.makeRepository(User, { + tableName: "users", + idColumn: "id", + spanPrefix: "UserRepository" + }) + const sql = yield* SqlClient.SqlClient + yield* sql`CREATE TABLE users (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), age INT)` + + const result = yield* repo.insertVoid(User.insert.makeSync({ name: "Alice", age: 30 })) + assert.strictEqual(result, void 0) + }).pipe( + Effect.provide(MysqlContainer.layerClient), + Effect.catchTag("ContainerError", () => Effect.void) + ), { timeout: 60_000 }) + + it.live("insert data loader returns result", () => + Effect.gen(function*() { + const repo = yield* SqlModel.makeDataLoaders(User, { + tableName: "users", + idColumn: "id", + spanPrefix: "UserRepository", + window: 10 + }) + const sql = yield* SqlClient.SqlClient + yield* sql`CREATE TABLE users (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), age INT)` + + const [alice, john] = yield* Effect.all([ + repo.insert(User.insert.makeSync({ name: "Alice", age: 30 })), + repo.insert(User.insert.makeSync({ name: "John", age: 30 })) + ], { concurrency: "unbounded" }) + assert.deepStrictEqual(alice.name, "Alice") + assert.deepStrictEqual(john.name, "John") + }).pipe( + Effect.provide(MysqlContainer.layerClient), + Effect.catchTag("ContainerError", () => Effect.void) + ), { timeout: 60_000 }) + + it.live("findById data loader", () => + Effect.gen(function*() { + const repo = yield* SqlModel.makeDataLoaders(User, { + tableName: "users", + idColumn: "id", + spanPrefix: "UserRepository", + window: 10 + }) + const sql = yield* SqlClient.SqlClient + yield* sql`CREATE TABLE users (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), age INT)` + const alice = yield* repo.insert(User.insert.makeSync({ name: "Alice", age: 30 })) + const john = yield* repo.insert(User.insert.makeSync({ name: "John", age: 30 })) + + const [alice2, john2] = yield* Effect.all([ + repo.findById(alice.id), + repo.findById(john.id) + ], { concurrency: "unbounded" }) + + assert.deepStrictEqual(alice2.name, "Alice") + assert.deepStrictEqual(john2.name, "John") + }).pipe( + Effect.provide(MysqlContainer.layerClient), + Effect.catchTag("ContainerError", () => Effect.void) + ), { timeout: 60_000 }) + + it.effect("update returns result", () => + Effect.gen(function*() { + const repo = yield* SqlModel.makeRepository(User, { + tableName: "users", + idColumn: "id", + spanPrefix: "UserRepository" + }) + const sql = yield* SqlClient.SqlClient + yield* sql`CREATE TABLE users (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), age INT)` + + let result = yield* repo.insert(User.insert.makeSync({ name: "Alice", age: 30 })) + result = yield* repo.update(User.update.makeSync({ ...result, name: "Bob" })) + assert.deepStrictEqual(result, new User({ id: 1, name: "Bob", age: 30 })) + }).pipe( + Effect.provide(MysqlContainer.layerClient), + Effect.catchTag("ContainerError", () => Effect.void) + ), { timeout: 60_000 }) + + it.effect("update returns result with transforms", () => + Effect.gen(function*() { + const repo = yield* SqlModel.makeRepository(User, { + tableName: "users", + idColumn: "id", + spanPrefix: "UserRepository" + }) + const sql = yield* SqlClient.SqlClient + yield* sql`CREATE TABLE users (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), age INT)` + + let result = yield* repo.insert(User.insert.makeSync({ name: "Alice", age: 30 })) + result = yield* repo.update(User.update.makeSync({ ...result, name: "Bob" })) + assert.deepStrictEqual(result, new User({ id: 1, name: "Bob", age: 30 })) + }).pipe( + Effect.provide(MysqlContainer.layerClientWithTransforms), + Effect.catchTag("ContainerError", () => Effect.void) + ), { timeout: 60_000 }) +}) diff --git a/packages/sql/mysql2/test/utils.ts b/packages/sql/mysql2/test/utils.ts new file mode 100644 index 0000000000..e4f3b2394b --- /dev/null +++ b/packages/sql/mysql2/test/utils.ts @@ -0,0 +1,45 @@ +import { MysqlClient } from "@effect/sql-mysql2" +import type { StartedMySqlContainer } from "@testcontainers/mysql" +import { MySqlContainer } from "@testcontainers/mysql" +import { Effect, Layer, ServiceMap } from "effect" +import { Data, Redacted } from "effect/data" +import { String } from "effect/primitives" + +export class ContainerError extends Data.TaggedError("ContainerError")<{ + cause: unknown +}> {} + +export class MysqlContainer extends ServiceMap.Key< + MysqlContainer, + StartedMySqlContainer +>()("test/MysqlContainer") { + static layer = Layer.effect(this)( + Effect.acquireRelease( + Effect.tryPromise({ + try: () => new MySqlContainer("mysql:lts").start(), + catch: (cause) => new ContainerError({ cause }) + }), + (container) => Effect.promise(() => container.stop()) + ) + ) + + static layerClient = Layer.unwrap( + Effect.gen(function*() { + const container = yield* MysqlContainer + return MysqlClient.layer({ + url: Redacted.make(container.getConnectionUri()) + }) + }) + ).pipe(Layer.provide(this.layer)) + + static layerClientWithTransforms = Layer.unwrap( + Effect.gen(function*() { + const container = yield* MysqlContainer + return MysqlClient.layer({ + url: Redacted.make(container.getConnectionUri()), + transformQueryNames: String.camelToSnake, + transformResultNames: String.snakeToCamel + }) + }) + ).pipe(Layer.provide(this.layer)) +} diff --git a/packages/sql/mysql2/tsconfig.build.json b/packages/sql/mysql2/tsconfig.build.json new file mode 100644 index 0000000000..e738132ff9 --- /dev/null +++ b/packages/sql/mysql2/tsconfig.build.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "./tsconfig.src.json", + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", + "outDir": "dist", + "stripInternal": true + } +} diff --git a/packages/sql/mysql2/tsconfig.json b/packages/sql/mysql2/tsconfig.json new file mode 100644 index 0000000000..11922f5b68 --- /dev/null +++ b/packages/sql/mysql2/tsconfig.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": [], + "references": [{ "path": "tsconfig.src.json" }, { "path": "tsconfig.test.json" }] +} diff --git a/packages/sql/mysql2/tsconfig.src.json b/packages/sql/mysql2/tsconfig.src.json new file mode 100644 index 0000000000..00f9cbaff4 --- /dev/null +++ b/packages/sql/mysql2/tsconfig.src.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["src"], + "references": [{ "path": "../../effect/tsconfig.src.json" }, { "path": "../../platform-node/tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", + "outDir": ".tsbuildinfo/src", + "rootDir": "src", + "types": ["node"] + } +} diff --git a/packages/sql/mysql2/tsconfig.test.json b/packages/sql/mysql2/tsconfig.test.json new file mode 100644 index 0000000000..5f62070abb --- /dev/null +++ b/packages/sql/mysql2/tsconfig.test.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["test/**/*.ts", "test/**/*.json"], + "references": [{ "path": "tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/test.tsbuildinfo", + "outDir": ".tsbuildinfo/test", + "rootDir": "test", + "noEmit": true, + "erasableSyntaxOnly": false, + "resolveJsonModule": true, + "baseUrl": ".", + "paths": { + "@effect/sql-mysql2": ["src/index.ts"], + "@effect/sql-mysql2/*": ["src/*/index.ts", "src/*.ts"] + }, + "plugins": [ + { + "name": "@effect/language-service", + "namespaceImportPackages": [] + } + ] + } +} diff --git a/packages/sql/mysql2/vitest.config.ts b/packages/sql/mysql2/vitest.config.ts new file mode 100644 index 0000000000..c8a52c1826 --- /dev/null +++ b/packages/sql/mysql2/vitest.config.ts @@ -0,0 +1,6 @@ +import { mergeConfig, type ViteUserConfig } from "vitest/config" +import shared from "../../../vitest.shared.ts" + +const config: ViteUserConfig = {} + +export default mergeConfig(shared, config) diff --git a/packages/sql/pg/CHANGELOG.md b/packages/sql/pg/CHANGELOG.md new file mode 100644 index 0000000000..0f880e9719 --- /dev/null +++ b/packages/sql/pg/CHANGELOG.md @@ -0,0 +1,2822 @@ +# @effect/sql-pg + +## 0.45.1 + +### Patch Changes + +- [#5397](https://github.com/Effect-TS/effect/pull/5397) [`0e46e24`](https://github.com/Effect-TS/effect/commit/0e46e24c24e9edb8bf2e29835a94013e9c34d034) Thanks @IMax153! - Avoid issues with ESM builds by removing dependency on `@opentelemetry/semantic-conventions` + +- Updated dependencies [[`8c7bb52`](https://github.com/Effect-TS/effect/commit/8c7bb52dc78850be72566decba6222870e3733d0), [`0e46e24`](https://github.com/Effect-TS/effect/commit/0e46e24c24e9edb8bf2e29835a94013e9c34d034)]: + - @effect/platform@0.90.4 + - @effect/sql@0.44.2 + +## 0.45.0 + +### Patch Changes + +- Updated dependencies [[`7813640`](https://github.com/Effect-TS/effect/commit/7813640279d9e3a3e7fc0a29bfb5c6d5fb3c270f)]: + - @effect/platform@0.90.0 + - @effect/experimental@0.54.0 + - @effect/sql@0.44.0 + +## 0.44.0 + +### Patch Changes + +- Updated dependencies [[`40c3c87`](https://github.com/Effect-TS/effect/commit/40c3c875f724264312b43002859c82bed9ad0df9), [`ed2c74a`](https://github.com/Effect-TS/effect/commit/ed2c74ae8fa4ea0dd06ea84a3e58cd32e6916104), [`073a1b8`](https://github.com/Effect-TS/effect/commit/073a1b8be5dbfa87454393ee7346f5bc36a4fd63), [`f382e99`](https://github.com/Effect-TS/effect/commit/f382e99e409838a879246250fc3994b9bf5b3c2c), [`e8c7ba5`](https://github.com/Effect-TS/effect/commit/e8c7ba5fd3eb0c3ae3039fc24c09d69391987989), [`7e10415`](https://github.com/Effect-TS/effect/commit/7e1041599ade25103428703f5d2dfd7378a09636), [`e9bdece`](https://github.com/Effect-TS/effect/commit/e9bdececdc24f60a246be5055eca71a0d49ea7f2), [`8d95eb0`](https://github.com/Effect-TS/effect/commit/8d95eb0356b1d1736204836c275d201a547d208d)]: + - effect@3.17.0 + - @effect/experimental@0.53.0 + - @effect/platform@0.89.0 + - @effect/sql@0.43.0 + +## 0.43.0 + +### Minor Changes + +- [#5192](https://github.com/Effect-TS/effect/pull/5192) [`17a5ea8`](https://github.com/Effect-TS/effect/commit/17a5ea8fa29785fe6e4c9480f2a2e9c8c59f3f38) Thanks @nikelborm! - Updated deprecated OTel Resource attributes names and values. + + Many of the attributes have undergone the process of deprecation not once, but twice. Most of the constants holding attribute names have been renamed. These are minor changes. + + Additionally, there were numerous changes to the attribute keys themselves. These changes can be considered major. + + In the `@opentelemetry/semantic-conventions` package, new attributes having ongoing discussion about them are going through a process called incubation, until a consensus about their necessity and form is reached. Otel team [recommends](https://github.com/open-telemetry/opentelemetry-js/blob/main/semantic-conventions/README.md#unstable-semconv) devs to copy them directly into their code. Luckily, it's not necessary because all of the new attribute names and values came out of this process (some of them were changed again) and are now considered stable. + + ## Reasoning for minor version bump + + | Package | Major attribute changes | Major value changes | + | -------------------------- | ----------------------------------------------------------------------------- | --------------------------------- | + | Clickhouse client | `db.system` -> `db.system.name`
`db.name` -> `db.namespace` | | + | MsSQL client | `db.system` -> `db.system.name`
`db.name` -> `db.namespace` | `mssql` -> `microsoft.sql_server` | + | MySQL client | `db.system` -> `db.system.name`
`db.name` -> `db.namespace` | | + | Pg client | `db.system` -> `db.system.name`
`db.name` -> `db.namespace` | | + | Bun SQLite client | `db.system` -> `db.system.name` | | + | Node SQLite client | `db.system` -> `db.system.name` | | + | React.Native SQLite client | `db.system` -> `db.system.name` | | + | Wasm SQLite client | `db.system` -> `db.system.name` | | + | SQLite Do client | `db.system` -> `db.system.name` | | + | LibSQL client | `db.system` -> `db.system.name` | | + | D1 client | `db.system` -> `db.system.name` | | + | Kysely client | `db.statement` -> `db.query.text` | | + | @effect/sql | `db.statement` -> `db.query.text`
`db.operation` -> `db.operation.name` | | + +### Patch Changes + +- Updated dependencies [[`f5dfabf`](https://github.com/Effect-TS/effect/commit/f5dfabf51ba481a4468c1509c537314978ef6cec), [`17a5ea8`](https://github.com/Effect-TS/effect/commit/17a5ea8fa29785fe6e4c9480f2a2e9c8c59f3f38), [`d25f22b`](https://github.com/Effect-TS/effect/commit/d25f22be7598abe977caf6cdac3b0dd78b438c48)]: + - effect@3.16.14 + - @effect/sql@0.42.0 + - @effect/platform@0.88.1 + - @effect/experimental@0.52.1 + +## 0.42.0 + +### Patch Changes + +- Updated dependencies [[`27206d7`](https://github.com/Effect-TS/effect/commit/27206d7f0558d7fe28de57bf54f1d0cc83acc92e), [`dbabf5e`](https://github.com/Effect-TS/effect/commit/dbabf5e76fa63b050d2b6c466713c7dc59f07d3c)]: + - @effect/platform@0.88.0 + - @effect/experimental@0.52.0 + - @effect/sql@0.41.0 + +## 0.41.14 + +### Patch Changes + +- Updated dependencies [[`c1c05a8`](https://github.com/Effect-TS/effect/commit/c1c05a8242fb5df7445b4a12387a60eac7726eb7), [`81fe4a2`](https://github.com/Effect-TS/effect/commit/81fe4a2c81d5e30e180a60e68c52016a27b350db)]: + - effect@3.16.13 + - @effect/experimental@0.51.14 + - @effect/platform@0.87.13 + - @effect/sql@0.40.14 + +## 0.41.13 + +### Patch Changes + +- Updated dependencies [[`32ba77a`](https://github.com/Effect-TS/effect/commit/32ba77ae304d2161362a73e8b61965332626cf2d), [`d5e25b2`](https://github.com/Effect-TS/effect/commit/d5e25b237f05670ee42b386cb40b2cb448fc11d7)]: + - @effect/platform@0.87.12 + - @effect/experimental@0.51.13 + - @effect/sql@0.40.13 + +## 0.41.12 + +### Patch Changes + +- Updated dependencies [[`001392b`](https://github.com/Effect-TS/effect/commit/001392ba8bfcad101bb034348a7415012fb12f72), [`7bfb099`](https://github.com/Effect-TS/effect/commit/7bfb099cb5528511b8d63045c4fbb4dc9cb18528)]: + - @effect/platform@0.87.11 + - @effect/experimental@0.51.12 + - @effect/sql@0.40.12 + +## 0.41.11 + +### Patch Changes + +- Updated dependencies [[`678318d`](https://github.com/Effect-TS/effect/commit/678318d2e88233156b006acda56c2d138ee3ffa0), [`678318d`](https://github.com/Effect-TS/effect/commit/678318d2e88233156b006acda56c2d138ee3ffa0)]: + - @effect/platform@0.87.10 + - @effect/experimental@0.51.11 + - @effect/sql@0.40.11 + +## 0.41.10 + +### Patch Changes + +- Updated dependencies [[`54514a2`](https://github.com/Effect-TS/effect/commit/54514a2f53166de27ad7e756dbf12194691fd4af)]: + - @effect/platform@0.87.9 + - @effect/experimental@0.51.10 + - @effect/sql@0.40.10 + +## 0.41.9 + +### Patch Changes + +- Updated dependencies [[`4ce4f82`](https://github.com/Effect-TS/effect/commit/4ce4f824f6fdef492be1d35c05a490ffce518c89)]: + - @effect/platform@0.87.8 + - @effect/experimental@0.51.9 + - @effect/sql@0.40.9 + +## 0.41.8 + +### Patch Changes + +- Updated dependencies [[`a9b617f`](https://github.com/Effect-TS/effect/commit/a9b617f125171ed76cd79ab46d7a924daf3b0e70), [`7e26e86`](https://github.com/Effect-TS/effect/commit/7e26e86524abcc93713d6ad7eee486638c98f7c2)]: + - @effect/platform@0.87.7 + - @effect/experimental@0.51.8 + - @effect/sql@0.40.8 + +## 0.41.7 + +### Patch Changes + +- Updated dependencies [[`905da99`](https://github.com/Effect-TS/effect/commit/905da996aad665057b4ca6dba1a4af44fb8835bd)]: + - effect@3.16.12 + - @effect/experimental@0.51.7 + - @effect/platform@0.87.6 + - @effect/sql@0.40.7 + +## 0.41.6 + +### Patch Changes + +- Updated dependencies [[`96c1292`](https://github.com/Effect-TS/effect/commit/96c129262835410b311a51d0bf7f58b8f6fc9a12)]: + - @effect/experimental@0.51.6 + - @effect/sql@0.40.6 + +## 0.41.5 + +### Patch Changes + +- Updated dependencies [[`2fd8676`](https://github.com/Effect-TS/effect/commit/2fd8676c803cd40000dfc3231f5daecaa0e0ebd2)]: + - @effect/platform@0.87.5 + - @effect/experimental@0.51.5 + - @effect/sql@0.40.5 + +## 0.41.4 + +### Patch Changes + +- Updated dependencies [[`e82a4fd`](https://github.com/Effect-TS/effect/commit/e82a4fd60f6528d08cef1a4aba0abe0d3ba741ad)]: + - @effect/platform@0.87.4 + - @effect/experimental@0.51.4 + - @effect/sql@0.40.4 + +## 0.41.3 + +### Patch Changes + +- Updated dependencies [[`1b6e396`](https://github.com/Effect-TS/effect/commit/1b6e396d699f3cbbc56b68f99055cf746529bb9e), [`46c3216`](https://github.com/Effect-TS/effect/commit/46c321657d93393506278327418e36f8e7a77f86)]: + - @effect/platform@0.87.3 + - @effect/sql@0.40.3 + - @effect/experimental@0.51.3 + +## 0.41.2 + +### Patch Changes + +- Updated dependencies [[`4fea68c`](https://github.com/Effect-TS/effect/commit/4fea68ca7a25a3c39a1ab68b3885534513ab0c81), [`b927954`](https://github.com/Effect-TS/effect/commit/b9279543cf5688dd8a577af80456959c615217d0), [`99590a6`](https://github.com/Effect-TS/effect/commit/99590a6ca9128eb1ede265b6670b655311995614), [`6c3e24c`](https://github.com/Effect-TS/effect/commit/6c3e24c2308f7d4a29b8f4270ab81bca22ac6bb4)]: + - @effect/platform@0.87.2 + - effect@3.16.11 + - @effect/experimental@0.51.2 + - @effect/sql@0.40.2 + +## 0.41.1 + +### Patch Changes + +- Updated dependencies [[`faad30e`](https://github.com/Effect-TS/effect/commit/faad30ec8742916be59f9db642d0fc98225b636c)]: + - effect@3.16.10 + - @effect/experimental@0.51.1 + - @effect/platform@0.87.1 + - @effect/sql@0.40.1 + +## 0.41.0 + +### Patch Changes + +- Updated dependencies [[`b5bac9a`](https://github.com/Effect-TS/effect/commit/b5bac9ac2913fcd11b02322624f03b544eef53ba)]: + - @effect/platform@0.87.0 + - @effect/experimental@0.51.0 + - @effect/sql@0.40.0 + +## 0.40.0 + +### Patch Changes + +- Updated dependencies [[`5137c70`](https://github.com/Effect-TS/effect/commit/5137c703461d8d3b363c112140a6e7f798241d07), [`c23d25c`](https://github.com/Effect-TS/effect/commit/c23d25c3e7c541f1f63b28484d8c461d86c67e99), [`5137c70`](https://github.com/Effect-TS/effect/commit/5137c703461d8d3b363c112140a6e7f798241d07), [`5137c70`](https://github.com/Effect-TS/effect/commit/5137c703461d8d3b363c112140a6e7f798241d07)]: + - effect@3.16.9 + - @effect/platform@0.86.0 + - @effect/experimental@0.50.0 + - @effect/sql@0.39.0 + +## 0.39.2 + +### Patch Changes + +- Updated dependencies [[`914a191`](https://github.com/Effect-TS/effect/commit/914a191e7cb6341a3d0e965bccd27c336cf22e44)]: + - @effect/platform@0.85.2 + - @effect/experimental@0.49.2 + - @effect/sql@0.38.2 + +## 0.39.1 + +### Patch Changes + +- Updated dependencies [[`8cb98d5`](https://github.com/Effect-TS/effect/commit/8cb98d53e68330228287ce2a2e0d8a4c86bcab3b), [`db2dd3c`](https://github.com/Effect-TS/effect/commit/db2dd3c3a8a77d791eae19e66153527e1cde4e6e)]: + - effect@3.16.8 + - @effect/experimental@0.49.1 + - @effect/platform@0.85.1 + - @effect/sql@0.38.1 + +## 0.39.0 + +### Patch Changes + +- Updated dependencies [[`93687dd`](https://github.com/Effect-TS/effect/commit/93687ddbb25ce3b324cd2b83d2ccff225e97307e), [`93687dd`](https://github.com/Effect-TS/effect/commit/93687ddbb25ce3b324cd2b83d2ccff225e97307e), [`93687dd`](https://github.com/Effect-TS/effect/commit/93687ddbb25ce3b324cd2b83d2ccff225e97307e)]: + - @effect/platform@0.85.0 + - @effect/experimental@0.49.0 + - @effect/sql@0.38.0 + +## 0.38.12 + +### Patch Changes + +- Updated dependencies [[`1bb0d8a`](https://github.com/Effect-TS/effect/commit/1bb0d8ab96782e99434356266b38251554ea0294)]: + - effect@3.16.7 + - @effect/experimental@0.48.12 + - @effect/platform@0.84.11 + - @effect/sql@0.37.12 + +## 0.38.11 + +### Patch Changes + +- Updated dependencies [[`a5f7595`](https://github.com/Effect-TS/effect/commit/a5f75956ef9a15a83c416517ef493f0ee2f5ee8a), [`a02470c`](https://github.com/Effect-TS/effect/commit/a02470c75579e91525a25adb3f21b3650d042fdd), [`bf369b2`](https://github.com/Effect-TS/effect/commit/bf369b2902a0e0b195d957c18b9efd180942cf8b), [`f891d45`](https://github.com/Effect-TS/effect/commit/f891d45adffdafd3f94a2eca23faa354e3a409a8)]: + - effect@3.16.6 + - @effect/platform@0.84.10 + - @effect/experimental@0.48.11 + - @effect/sql@0.37.11 + +## 0.38.10 + +### Patch Changes + +- Updated dependencies [[`bf418ef`](https://github.com/Effect-TS/effect/commit/bf418ef14a0f2ec965535793d5cea8fa8ba177ac)]: + - effect@3.16.5 + - @effect/experimental@0.48.10 + - @effect/platform@0.84.9 + - @effect/sql@0.37.10 + +## 0.38.9 + +### Patch Changes + +- Updated dependencies [[`8b9db77`](https://github.com/Effect-TS/effect/commit/8b9db7742846af0f58fd8e8b7acb7f4f5ff487ec)]: + - @effect/platform@0.84.8 + - @effect/experimental@0.48.9 + - @effect/sql@0.37.9 + +## 0.38.8 + +### Patch Changes + +- Updated dependencies [[`74ab9a0`](https://github.com/Effect-TS/effect/commit/74ab9a0a9e16d6e019369d256e1e24175c8bc3f3), [`770008e`](https://github.com/Effect-TS/effect/commit/770008eca3aad2899a2ed951236e575793294b28)]: + - effect@3.16.4 + - @effect/experimental@0.48.8 + - @effect/platform@0.84.7 + - @effect/sql@0.37.8 + +## 0.38.7 + +### Patch Changes + +- Updated dependencies [[`a2d57c9`](https://github.com/Effect-TS/effect/commit/a2d57c9ac596445009ca12859b78e00e5d89b936)]: + - @effect/experimental@0.48.7 + - @effect/sql@0.37.7 + +## 0.38.6 + +### Patch Changes + +- Updated dependencies [[`ceea77a`](https://github.com/Effect-TS/effect/commit/ceea77a13055f145520f763e3fce5b8ff15d728f)]: + - @effect/platform@0.84.6 + - @effect/experimental@0.48.6 + - @effect/sql@0.37.6 + +## 0.38.5 + +### Patch Changes + +- Updated dependencies [[`ec52c6a`](https://github.com/Effect-TS/effect/commit/ec52c6a2211e76972462b15b9d5a9d6d56761b7a)]: + - @effect/platform@0.84.5 + - @effect/experimental@0.48.5 + - @effect/sql@0.37.5 + +## 0.38.4 + +### Patch Changes + +- Updated dependencies [[`87722fc`](https://github.com/Effect-TS/effect/commit/87722fce693a9b49284bbddbf82d30714c688261), [`36217ee`](https://github.com/Effect-TS/effect/commit/36217eeb1337edd9ac3f9a635b80a6385d22ae8f)]: + - effect@3.16.3 + - @effect/experimental@0.48.4 + - @effect/platform@0.84.4 + - @effect/sql@0.37.4 + +## 0.38.3 + +### Patch Changes + +- Updated dependencies [[`ab7684f`](https://github.com/Effect-TS/effect/commit/ab7684f1c2a0671bf091f255d220e3a4cc7f528e)]: + - @effect/platform@0.84.3 + - @effect/experimental@0.48.3 + - @effect/sql@0.37.3 + +## 0.38.2 + +### Patch Changes + +- Updated dependencies [[`0ddf148`](https://github.com/Effect-TS/effect/commit/0ddf148a247aa87af043d276b8453a714a400897)]: + - effect@3.16.2 + - @effect/experimental@0.48.2 + - @effect/platform@0.84.2 + - @effect/sql@0.37.2 + +## 0.38.1 + +### Patch Changes + +- Updated dependencies [[`71174d0`](https://github.com/Effect-TS/effect/commit/71174d09691314a9b6b66189e456fd21e3eb6543), [`d615e6e`](https://github.com/Effect-TS/effect/commit/d615e6e5b944f6fd5e627e31752c7ca7e4e1c17d)]: + - @effect/platform@0.84.1 + - effect@3.16.1 + - @effect/experimental@0.48.1 + - @effect/sql@0.37.1 + +## 0.38.0 + +### Patch Changes + +- Updated dependencies [[`ee0bd5d`](https://github.com/Effect-TS/effect/commit/ee0bd5d24864752c54cb359f67a67dd903971ec4), [`5189800`](https://github.com/Effect-TS/effect/commit/51898004e11766b8cf6d95e960b636f6d5db79ec), [`58bfeaa`](https://github.com/Effect-TS/effect/commit/58bfeaa64ded8c88f772b184311c0c0dbac10960), [`194d748`](https://github.com/Effect-TS/effect/commit/194d7486943f56f3267ef415395ac220a4b3e634), [`918c9ea`](https://github.com/Effect-TS/effect/commit/918c9ea1a57facb154f0fb26792021f337054dee), [`9198e6f`](https://github.com/Effect-TS/effect/commit/9198e6fcc1a3ff4fefb3363004de558d8de01f40), [`2a370bf`](https://github.com/Effect-TS/effect/commit/2a370bf625fdeede5659721468eb0d527e403279), [`58ccb91`](https://github.com/Effect-TS/effect/commit/58ccb91328c8df5d49808b673738bc09df355201), [`fd47834`](https://github.com/Effect-TS/effect/commit/fd478348203fa89462b0a1d067ce4de034353df4)]: + - effect@3.16.0 + - @effect/experimental@0.48.0 + - @effect/platform@0.84.0 + - @effect/sql@0.37.0 + +## 0.37.0 + +### Patch Changes + +- Updated dependencies [[`5522520`](https://github.com/Effect-TS/effect/commit/55225206ab9af0ad60b1c0654690a8a096d625cd), [`cc5bb2b`](https://github.com/Effect-TS/effect/commit/cc5bb2b918a9450a975f702dabcea891bda382cb)]: + - @effect/platform@0.83.0 + - effect@3.15.5 + - @effect/experimental@0.47.0 + - @effect/sql@0.36.0 + +## 0.36.8 + +### Patch Changes + +- Updated dependencies [[`0617b9d`](https://github.com/Effect-TS/effect/commit/0617b9dc365f1963b36949ad7f9023ab6eb94524)]: + - @effect/platform@0.82.8 + - @effect/experimental@0.46.8 + - @effect/sql@0.35.8 + +## 0.36.7 + +### Patch Changes + +- Updated dependencies [[`f570554`](https://github.com/Effect-TS/effect/commit/f57055459524587b041340577dad85476bb35f81), [`78047e8`](https://github.com/Effect-TS/effect/commit/78047e8dfc8005b66f87afe50bb95981fea51561), [`c20b95a`](https://github.com/Effect-TS/effect/commit/c20b95a99ffe452b4774c844d397a905f713b6d6), [`94ada43`](https://github.com/Effect-TS/effect/commit/94ada430928d5685bdbef513e87562c20774a3a2)]: + - effect@3.15.4 + - @effect/platform@0.82.7 + - @effect/experimental@0.46.7 + - @effect/sql@0.35.7 + +## 0.36.6 + +### Patch Changes + +- Updated dependencies [[`618903b`](https://github.com/Effect-TS/effect/commit/618903ba9ae96e2bfe6ee31f61c4359b915f2a36)]: + - @effect/platform@0.82.6 + - @effect/experimental@0.46.6 + - @effect/sql@0.35.6 + +## 0.36.5 + +### Patch Changes + +- Updated dependencies [[`7764a07`](https://github.com/Effect-TS/effect/commit/7764a07d960c60df81f14e1dc949518f4bbe494a), [`4577f54`](https://github.com/Effect-TS/effect/commit/4577f548d67273e576cdde423bdd34a4b910766a), [`30a0d9c`](https://github.com/Effect-TS/effect/commit/30a0d9cb51c84290d51b1361d72ff5cee33c13c7)]: + - @effect/platform@0.82.5 + - effect@3.15.3 + - @effect/experimental@0.46.5 + - @effect/sql@0.35.5 + +## 0.36.4 + +### Patch Changes + +- Updated dependencies [[`d45e8a8`](https://github.com/Effect-TS/effect/commit/d45e8a8ac8227192f504e39e6d04fdcf4fb1d225), [`89657ac`](https://github.com/Effect-TS/effect/commit/89657ac2fbda9ba38ac2962ce96949e536a464f9), [`d13b68e`](https://github.com/Effect-TS/effect/commit/d13b68e3a9456d0bfee9bca8273a7b44a9c69087)]: + - @effect/platform@0.82.4 + - @effect/sql@0.35.4 + - @effect/experimental@0.46.4 + +## 0.36.3 + +### Patch Changes + +- Updated dependencies [[`b8722b8`](https://github.com/Effect-TS/effect/commit/b8722b817e2306fe8c8245f3f9e32d85b824b961), [`a328f4b`](https://github.com/Effect-TS/effect/commit/a328f4b4fe717dd53e5b04a30f387433c32f7328)]: + - effect@3.15.2 + - @effect/platform@0.82.3 + - @effect/experimental@0.46.3 + - @effect/sql@0.35.3 + +## 0.36.2 + +### Patch Changes + +- Updated dependencies [[`739a3d4`](https://github.com/Effect-TS/effect/commit/739a3d4a4565915fe2e690003f4f9085cb4422fc)]: + - @effect/platform@0.82.2 + - @effect/experimental@0.46.2 + - @effect/sql@0.35.2 + +## 0.36.1 + +### Patch Changes + +- Updated dependencies [[`787ce70`](https://github.com/Effect-TS/effect/commit/787ce7042e35b657963473c6efe47752868cd811), [`1269641`](https://github.com/Effect-TS/effect/commit/1269641a99ae43069f7648ff79ffe8729b54b348), [`1269641`](https://github.com/Effect-TS/effect/commit/1269641a99ae43069f7648ff79ffe8729b54b348)]: + - effect@3.15.1 + - @effect/experimental@0.46.1 + - @effect/platform@0.82.1 + - @effect/sql@0.35.1 + +## 0.36.0 + +### Patch Changes + +- Updated dependencies [[`c654595`](https://github.com/Effect-TS/effect/commit/c65459587b51da140b78098e81fdbfece65d53e2), [`d9f5dea`](https://github.com/Effect-TS/effect/commit/d9f5deae0f02f5de2b9fcb1cca8b142ba4bc2bba), [`49aa723`](https://github.com/Effect-TS/effect/commit/49aa7236a15e13f818c86edbca08c4af67c8dfaf), [`74c14d0`](https://github.com/Effect-TS/effect/commit/74c14d01d0cb48cf517a1b6e29a373a96ed0ff5b), [`e4f49b6`](https://github.com/Effect-TS/effect/commit/e4f49b66857e01b74ab6a9a0bc7132f44cd04cbb), [`6f02224`](https://github.com/Effect-TS/effect/commit/6f02224b3fc46a682ad2defb1a260841956c6780), [`1dcfd41`](https://github.com/Effect-TS/effect/commit/1dcfd41ff96abd706901293a00c1893cb29dd8fd), [`b21ab16`](https://github.com/Effect-TS/effect/commit/b21ab16b6f773e7ec4369db4e752c35e719f7870), [`fcf1822`](https://github.com/Effect-TS/effect/commit/fcf1822f98fcda60351d64e9d2c2c13563d7e6db), [`0061dd1`](https://github.com/Effect-TS/effect/commit/0061dd140740165e91569a684cce27a77b23229e), [`8421e6e`](https://github.com/Effect-TS/effect/commit/8421e6e49332bca8f96f482dfd48680e238b3a89), [`a9b3fb7`](https://github.com/Effect-TS/effect/commit/a9b3fb78abcfdb525318a956fd02fcadeb56143e), [`fa10f56`](https://github.com/Effect-TS/effect/commit/fa10f56b96bd9af070ba99ebc3279aa93954261e)]: + - effect@3.15.0 + - @effect/platform@0.82.0 + - @effect/experimental@0.46.0 + - @effect/sql@0.35.0 + +## 0.35.1 + +### Patch Changes + +- Updated dependencies [[`24a9ebb`](https://github.com/Effect-TS/effect/commit/24a9ebbb5af598f0bfd6ecc45307e528043fe011)]: + - effect@3.14.22 + - @effect/experimental@0.45.1 + - @effect/platform@0.81.1 + - @effect/sql@0.34.1 + +## 0.35.0 + +### Patch Changes + +- Updated dependencies [[`672920f`](https://github.com/Effect-TS/effect/commit/672920f85da8abd5f9d4ad85e29248a2aca57ed8)]: + - @effect/platform@0.81.0 + - @effect/experimental@0.45.0 + - @effect/sql@0.34.0 + +## 0.34.21 + +### Patch Changes + +- Updated dependencies [[`2f3b7d4`](https://github.com/Effect-TS/effect/commit/2f3b7d4e1fa1ef8790b0ca4da22eb88872ee31df)]: + - effect@3.14.21 + - @effect/experimental@0.44.21 + - @effect/platform@0.80.21 + - @effect/sql@0.33.21 + +## 0.34.20 + +### Patch Changes + +- Updated dependencies [[`17e2f30`](https://github.com/Effect-TS/effect/commit/17e2f3091408cf0fca9414d4af3bdf7b2765b378)]: + - effect@3.14.20 + - @effect/experimental@0.44.20 + - @effect/platform@0.80.20 + - @effect/sql@0.33.20 + +## 0.34.19 + +### Patch Changes + +- Updated dependencies [[`056a910`](https://github.com/Effect-TS/effect/commit/056a910d0a0b8b00b0dc9df4a070466b2b5c2f6c), [`e25e7bb`](https://github.com/Effect-TS/effect/commit/e25e7bbc1797733916f48f501425d9f2ef310d9f), [`3273d57`](https://github.com/Effect-TS/effect/commit/3273d572c2b3175a842677f19efeea4cd65ab016)]: + - effect@3.14.19 + - @effect/platform@0.80.19 + - @effect/experimental@0.44.19 + - @effect/sql@0.33.19 + +## 0.34.18 + +### Patch Changes + +- Updated dependencies [[`b1164d4`](https://github.com/Effect-TS/effect/commit/b1164d49a1dfdf299e9971367b6fc6be4df0ddff)]: + - effect@3.14.18 + - @effect/experimental@0.44.18 + - @effect/platform@0.80.18 + - @effect/sql@0.33.18 + +## 0.34.17 + +### Patch Changes + +- Updated dependencies [[`0b54681`](https://github.com/Effect-TS/effect/commit/0b54681cd89245e211d8f49272be0f1bf2f81813), [`41a59d5`](https://github.com/Effect-TS/effect/commit/41a59d5916a296b12b0d5ead9e859e05f40b4cce)]: + - effect@3.14.17 + - @effect/experimental@0.44.17 + - @effect/platform@0.80.17 + - @effect/sql@0.33.17 + +## 0.34.16 + +### Patch Changes + +- Updated dependencies [[`ee14444`](https://github.com/Effect-TS/effect/commit/ee144441021ec77039e43396eaf90714687bb495), [`f1c8583`](https://github.com/Effect-TS/effect/commit/f1c8583f8c3ea9415f813795ca2940a897c9ba9a)]: + - effect@3.14.16 + - @effect/platform@0.80.16 + - @effect/experimental@0.44.16 + - @effect/sql@0.33.16 + +## 0.34.15 + +### Patch Changes + +- Updated dependencies [[`239cc99`](https://github.com/Effect-TS/effect/commit/239cc995ce645946210a3c3d2cb52bd3547c0687), [`8b6c947`](https://github.com/Effect-TS/effect/commit/8b6c947eaa8e45a67ecb3c37d45cd27f3e41d165), [`c50a63b`](https://github.com/Effect-TS/effect/commit/c50a63bbecb9f560b9cae349c447eed877d1b9b6)]: + - effect@3.14.15 + - @effect/experimental@0.44.15 + - @effect/platform@0.80.15 + - @effect/sql@0.33.15 + +## 0.34.14 + +### Patch Changes + +- Updated dependencies [[`6ed8d15`](https://github.com/Effect-TS/effect/commit/6ed8d1589beb181d30abc79afebdaabc1d101538)]: + - effect@3.14.14 + - @effect/experimental@0.44.14 + - @effect/platform@0.80.14 + - @effect/sql@0.33.14 + +## 0.34.13 + +### Patch Changes + +- Updated dependencies [[`ee77788`](https://github.com/Effect-TS/effect/commit/ee77788747e7ebbde6bfa88256cde49dbbad3608), [`5fce6ba`](https://github.com/Effect-TS/effect/commit/5fce6ba19c3cc63cc0104e737e581ad989dedbf0), [`570e45f`](https://github.com/Effect-TS/effect/commit/570e45f8cb936e42ec48f67f21bb2b7252f36c0c)]: + - effect@3.14.13 + - @effect/experimental@0.44.13 + - @effect/platform@0.80.13 + - @effect/sql@0.33.13 + +## 0.34.12 + +### Patch Changes + +- Updated dependencies [[`c2ad9ee`](https://github.com/Effect-TS/effect/commit/c2ad9ee9f3c4c743390edf35ed9e85a20be33811), [`9c68654`](https://github.com/Effect-TS/effect/commit/9c686542b6eb3ea188cb70673ef2e41223633e89)]: + - effect@3.14.12 + - @effect/experimental@0.44.12 + - @effect/platform@0.80.12 + - @effect/sql@0.33.12 + +## 0.34.11 + +### Patch Changes + +- Updated dependencies [[`e536127`](https://github.com/Effect-TS/effect/commit/e536127c1e6f2fb3a542c73ae919435a629a346b)]: + - effect@3.14.11 + - @effect/experimental@0.44.11 + - @effect/platform@0.80.11 + - @effect/sql@0.33.11 + +## 0.34.10 + +### Patch Changes + +- Updated dependencies [[`bc7efa3`](https://github.com/Effect-TS/effect/commit/bc7efa3b031bb25e1ed3c8f2d3fb5e8da166cadc)]: + - effect@3.14.10 + - @effect/experimental@0.44.10 + - @effect/platform@0.80.10 + - @effect/sql@0.33.10 + +## 0.34.9 + +### Patch Changes + +- Updated dependencies [[`d78249f`](https://github.com/Effect-TS/effect/commit/d78249f0b67f63cf4baf806ff090cba33293daf0)]: + - effect@3.14.9 + - @effect/experimental@0.44.9 + - @effect/platform@0.80.9 + - @effect/sql@0.33.9 + +## 0.34.8 + +### Patch Changes + +- Updated dependencies [[`b3a2d32`](https://github.com/Effect-TS/effect/commit/b3a2d32772e6f7f20eacf2e18128e99324c4d378)]: + - effect@3.14.8 + - @effect/experimental@0.44.8 + - @effect/platform@0.80.8 + - @effect/sql@0.33.8 + +## 0.34.7 + +### Patch Changes + +- Updated dependencies [[`b542a4b`](https://github.com/Effect-TS/effect/commit/b542a4bf195be0c9af1523e1ba96c953decc4d25)]: + - effect@3.14.7 + - @effect/experimental@0.44.7 + - @effect/platform@0.80.7 + - @effect/sql@0.33.7 + +## 0.34.6 + +### Patch Changes + +- Updated dependencies [[`47618c1`](https://github.com/Effect-TS/effect/commit/47618c1ad84ebcc5a51133a3fff5aa5012d49d45), [`6077882`](https://github.com/Effect-TS/effect/commit/60778824a4794336c33807801f813f8751d1c7e4)]: + - effect@3.14.6 + - @effect/experimental@0.44.6 + - @effect/platform@0.80.6 + - @effect/sql@0.33.6 + +## 0.34.5 + +### Patch Changes + +- Updated dependencies [[`40dbfef`](https://github.com/Effect-TS/effect/commit/40dbfeff239b6e567706752114f31b2fce7de4e3), [`85fba81`](https://github.com/Effect-TS/effect/commit/85fba815ac07eb13d4227a69ac76a18e4b94df18), [`5a5ebdd`](https://github.com/Effect-TS/effect/commit/5a5ebdddfaddd259538b4599a6676281faca778e)]: + - effect@3.14.5 + - @effect/platform@0.80.5 + - @effect/experimental@0.44.5 + - @effect/sql@0.33.5 + +## 0.34.4 + +### Patch Changes + +- Updated dependencies [[`e4ba2c6`](https://github.com/Effect-TS/effect/commit/e4ba2c66a878e81b5e295d6d49aaf724b80a28ef)]: + - effect@3.14.4 + - @effect/experimental@0.44.4 + - @effect/platform@0.80.4 + - @effect/sql@0.33.4 + +## 0.34.3 + +### Patch Changes + +- Updated dependencies [[`37aa8e1`](https://github.com/Effect-TS/effect/commit/37aa8e137725a902e70cd1e468ea98b873aa5056), [`34f03d6`](https://github.com/Effect-TS/effect/commit/34f03d66875f21f266f102223a03cd14c2ed6ea6)]: + - effect@3.14.3 + - @effect/experimental@0.44.3 + - @effect/platform@0.80.3 + - @effect/sql@0.33.3 + +## 0.34.2 + +### Patch Changes + +- Updated dependencies [[`f87991b`](https://github.com/Effect-TS/effect/commit/f87991b6d8a2edfaf90b01cebda4b466992ae865), [`f87991b`](https://github.com/Effect-TS/effect/commit/f87991b6d8a2edfaf90b01cebda4b466992ae865), [`0a3e3e1`](https://github.com/Effect-TS/effect/commit/0a3e3e18eea5e0d1882f1a6c906198e6ef226a41)]: + - effect@3.14.2 + - @effect/experimental@0.44.2 + - @effect/platform@0.80.2 + - @effect/sql@0.33.2 + +## 0.34.1 + +### Patch Changes + +- Updated dependencies [[`4a274fe`](https://github.com/Effect-TS/effect/commit/4a274fe9f623182b6b902827e0e83bd89ca3b05c)]: + - effect@3.14.1 + - @effect/experimental@0.44.1 + - @effect/platform@0.80.1 + - @effect/sql@0.33.1 + +## 0.34.0 + +### Minor Changes + +- [#4469](https://github.com/Effect-TS/effect/pull/4469) [`3131f8f`](https://github.com/Effect-TS/effect/commit/3131f8fd12ba9eb31b90fa2f42bf88b12309133c) Thanks @tim-smart! - refactor of @effect/cluster packages + +### Patch Changes + +- Updated dependencies [[`1f47e4e`](https://github.com/Effect-TS/effect/commit/1f47e4e12546ab691b29bfb7b5128bb17b93baa5), [`26dd75f`](https://github.com/Effect-TS/effect/commit/26dd75f276a0d8a63eab313bd5a167d5072c9780), [`aba2d1d`](https://github.com/Effect-TS/effect/commit/aba2d1d831ea149481bd4dd755528c0afa8239ce), [`3131f8f`](https://github.com/Effect-TS/effect/commit/3131f8fd12ba9eb31b90fa2f42bf88b12309133c), [`aba2d1d`](https://github.com/Effect-TS/effect/commit/aba2d1d831ea149481bd4dd755528c0afa8239ce), [`04dff2d`](https://github.com/Effect-TS/effect/commit/04dff2d01ac68c260f29a6d4743381825c353c86), [`aba2d1d`](https://github.com/Effect-TS/effect/commit/aba2d1d831ea149481bd4dd755528c0afa8239ce), [`c7fac0c`](https://github.com/Effect-TS/effect/commit/c7fac0cd7eadcd5cc0c3a987051c5b57ad271638), [`aba2d1d`](https://github.com/Effect-TS/effect/commit/aba2d1d831ea149481bd4dd755528c0afa8239ce), [`ffaa3f3`](https://github.com/Effect-TS/effect/commit/ffaa3f3969df26610fcc02ad537340641d44e803), [`ab957c1`](https://github.com/Effect-TS/effect/commit/ab957c1fee714868f56c7ab4e802b9d449e9b666), [`35db9ce`](https://github.com/Effect-TS/effect/commit/35db9ce228f1416c8abacc6dc9c36fbd0f33ef0f), [`aba2d1d`](https://github.com/Effect-TS/effect/commit/aba2d1d831ea149481bd4dd755528c0afa8239ce), [`cf77ea9`](https://github.com/Effect-TS/effect/commit/cf77ea9ab4fc89e66a43f682a9926ccdee6c57ed), [`26dd75f`](https://github.com/Effect-TS/effect/commit/26dd75f276a0d8a63eab313bd5a167d5072c9780), [`baaab60`](https://github.com/Effect-TS/effect/commit/baaab60b737f35dfab8e4a21bce28a195d19e899)]: + - effect@3.14.0 + - @effect/experimental@0.44.0 + - @effect/platform@0.80.0 + - @effect/sql@0.33.0 + +## 0.33.4 + +### Patch Changes + +- Updated dependencies [[`5662363`](https://github.com/Effect-TS/effect/commit/566236361e270e575ef1cbf308ad1967c82a362c), [`5f1fd15`](https://github.com/Effect-TS/effect/commit/5f1fd15308ab154791580059b89877d19a2055c2), [`8bb1460`](https://github.com/Effect-TS/effect/commit/8bb1460c824f66f0f25ebd899c5e74e388089c37)]: + - @effect/platform@0.79.4 + - @effect/experimental@0.43.4 + - @effect/sql@0.32.4 + +## 0.33.3 + +### Patch Changes + +- Updated dependencies [[`0c4803f`](https://github.com/Effect-TS/effect/commit/0c4803fcc69262d11a97ce49d0e9b4288df0651f), [`6f65ac4`](https://github.com/Effect-TS/effect/commit/6f65ac4eac1489cd6ea390e18b0908670722adad)]: + - effect@3.13.12 + - @effect/experimental@0.43.3 + - @effect/platform@0.79.3 + - @effect/sql@0.32.3 + +## 0.33.2 + +### Patch Changes + +- Updated dependencies [[`fad8cca`](https://github.com/Effect-TS/effect/commit/fad8cca9bbfcc2eaeb44b97c15dbe0a1eda75315), [`4296293`](https://github.com/Effect-TS/effect/commit/4296293049414d0cf2d915a26c552b09f946b9a0), [`9c241ab`](https://github.com/Effect-TS/effect/commit/9c241abe47ccf7a5257b98a4a64a63054a12741d), [`082b0c1`](https://github.com/Effect-TS/effect/commit/082b0c1b9f4252bcdd69608f2e4a9226f953ac3f), [`be12983`](https://github.com/Effect-TS/effect/commit/be12983bc7e7537b41cd8910fc4eb7d1da56ab07), [`de88127`](https://github.com/Effect-TS/effect/commit/de88127a5a5906ccece98af74787b5ae0e65e431)]: + - effect@3.13.11 + - @effect/experimental@0.43.2 + - @effect/platform@0.79.2 + - @effect/sql@0.32.2 + +## 0.33.1 + +### Patch Changes + +- Updated dependencies [[`527c964`](https://github.com/Effect-TS/effect/commit/527c9645229f5be9714a7e60a38a9e753c4bbfb1)]: + - effect@3.13.10 + - @effect/experimental@0.43.1 + - @effect/platform@0.79.1 + - @effect/sql@0.32.1 + +## 0.33.0 + +### Patch Changes + +- Updated dependencies [[`88fe129`](https://github.com/Effect-TS/effect/commit/88fe12923740765c0335a6e6203fdcc6a463edca), [`d630249`](https://github.com/Effect-TS/effect/commit/d630249426113088abe8b382db4f14d80f2160c2), [`2976e52`](https://github.com/Effect-TS/effect/commit/2976e52538d9dc9ffdcbc84d4ac748cff9305971)]: + - @effect/platform@0.79.0 + - effect@3.13.9 + - @effect/experimental@0.43.0 + - @effect/sql@0.32.0 + +## 0.32.1 + +### Patch Changes + +- Updated dependencies [[`c65d336`](https://github.com/Effect-TS/effect/commit/c65d3362d07ec815ff3b46278314e8a31706ddc2), [`22d2ebb`](https://github.com/Effect-TS/effect/commit/22d2ebb4b11f5a44351a4736e65da391a3b647d0)]: + - effect@3.13.8 + - @effect/experimental@0.42.1 + - @effect/platform@0.78.1 + - @effect/sql@0.31.1 + +## 0.32.0 + +### Patch Changes + +- Updated dependencies [[`c5bcf53`](https://github.com/Effect-TS/effect/commit/c5bcf53b7cb49dacffdd2a6cd8eb48cc452b417e)]: + - @effect/platform@0.78.0 + - @effect/experimental@0.42.0 + - @effect/sql@0.31.0 + +## 0.31.7 + +### Patch Changes + +- Updated dependencies [[`840cc73`](https://github.com/Effect-TS/effect/commit/840cc7329908db7ca693ef47b07d4f845c29cadd), [`9bf8a74`](https://github.com/Effect-TS/effect/commit/9bf8a74b967f18d931743dd5196af326c9118e9c), [`87ba23c`](https://github.com/Effect-TS/effect/commit/87ba23c41c193503ed0c612b0d32d0b253794c64), [`f910880`](https://github.com/Effect-TS/effect/commit/f91088069057f3b4529753f5bc5532b028d726df), [`0d01480`](https://github.com/Effect-TS/effect/commit/0d014803e4f688f74386a80abd65485e1a319244)]: + - @effect/platform@0.77.7 + - effect@3.13.7 + - @effect/experimental@0.41.7 + - @effect/sql@0.30.7 + +## 0.31.6 + +### Patch Changes + +- Updated dependencies [[`3154ce4`](https://github.com/Effect-TS/effect/commit/3154ce4692fa18b804982158d3c4c8a8a5fae386)]: + - effect@3.13.6 + - @effect/experimental@0.41.6 + - @effect/platform@0.77.6 + - @effect/sql@0.30.6 + +## 0.31.5 + +### Patch Changes + +- Updated dependencies [[`367bb35`](https://github.com/Effect-TS/effect/commit/367bb35f4c2a254e1fb211d96db2474a7aed9020), [`6cf11c3`](https://github.com/Effect-TS/effect/commit/6cf11c3a75773ceec2877c85ddc760f381f0866d), [`a0acec8`](https://github.com/Effect-TS/effect/commit/a0acec851f72e19466363d24b9cc218acd00006a)]: + - effect@3.13.5 + - @effect/experimental@0.41.5 + - @effect/platform@0.77.5 + - @effect/sql@0.30.5 + +## 0.31.4 + +### Patch Changes + +- Updated dependencies [[`e0746f9`](https://github.com/Effect-TS/effect/commit/e0746f9aa398b69c6542e375910683bf17f49f46), [`17d9e89`](https://github.com/Effect-TS/effect/commit/17d9e89f9851663bdbb6c1e685601d97806114a4)]: + - @effect/platform@0.77.4 + - effect@3.13.4 + - @effect/experimental@0.41.4 + - @effect/sql@0.30.4 + +## 0.31.3 + +### Patch Changes + +- Updated dependencies [[`cc5588d`](https://github.com/Effect-TS/effect/commit/cc5588df07f9103513547cb429ce041b9436a8bd), [`623c8cd`](https://github.com/Effect-TS/effect/commit/623c8cd053ed6ee3d353aaa8778d484670fca2bb), [`00b4eb1`](https://github.com/Effect-TS/effect/commit/00b4eb1ece12a16e222e6220965bb4024d6752ac), [`f2aee98`](https://github.com/Effect-TS/effect/commit/f2aee989b0a600900ce83e7f460d02908620c80f), [`fb798eb`](https://github.com/Effect-TS/effect/commit/fb798eb9061f1191badc017d1aa649360254da20), [`2251b15`](https://github.com/Effect-TS/effect/commit/2251b1528810bb695b37ce388b653cec0c5bf80c), [`2e15c1e`](https://github.com/Effect-TS/effect/commit/2e15c1e33648add0b29fe274fbcb7294b7515085), [`a4979db`](https://github.com/Effect-TS/effect/commit/a4979db021aef16e731be64df196b72088fc4376), [`b74255a`](https://github.com/Effect-TS/effect/commit/b74255a304ad49d60bedb1a260fd697f370af27a), [`d7f6a5c`](https://github.com/Effect-TS/effect/commit/d7f6a5c7d26c1963dcd864ca62360d20d08c7b49), [`9dd8979`](https://github.com/Effect-TS/effect/commit/9dd8979e940915b1cc1b1f264f3d019c77a65a02), [`477b488`](https://github.com/Effect-TS/effect/commit/477b488284f47c5469d7fba3e4065fb7e3b6556e), [`10932cb`](https://github.com/Effect-TS/effect/commit/10932cbf58fc721ada631cebec42f773ce96d3cc), [`9f6c784`](https://github.com/Effect-TS/effect/commit/9f6c78468b3b5e9ebfc38ffdfb70702901ee977b), [`2c639ec`](https://github.com/Effect-TS/effect/commit/2c639ecee332de4266e36022c989c35ae4e02105), [`886aaa8`](https://github.com/Effect-TS/effect/commit/886aaa81e06dfd3cd9391e8ea987d8cd5ada1124)]: + - effect@3.13.3 + - @effect/experimental@0.41.3 + - @effect/platform@0.77.3 + - @effect/sql@0.30.3 + +## 0.31.2 + +### Patch Changes + +- Updated dependencies [[`31be72a`](https://github.com/Effect-TS/effect/commit/31be72ada118cb84a942e67b1663263f8db74a9f), [`3e7ce97`](https://github.com/Effect-TS/effect/commit/3e7ce97f8a41756a039cf635d0b3d9a75d781097), [`31be72a`](https://github.com/Effect-TS/effect/commit/31be72ada118cb84a942e67b1663263f8db74a9f)]: + - effect@3.13.2 + - @effect/platform@0.77.2 + - @effect/experimental@0.41.2 + - @effect/sql@0.30.2 + +## 0.31.1 + +### Patch Changes + +- Updated dependencies [[`b56a211`](https://github.com/Effect-TS/effect/commit/b56a2110569fd0ec0b57ac137743e926d49f51cc)]: + - effect@3.13.1 + - @effect/experimental@0.41.1 + - @effect/platform@0.77.1 + - @effect/sql@0.30.1 + +## 0.31.0 + +### Patch Changes + +- Updated dependencies [[`8baef83`](https://github.com/Effect-TS/effect/commit/8baef83e7ff0b7bc0738b680e1ef013065386cff), [`655bfe2`](https://github.com/Effect-TS/effect/commit/655bfe29e44cc3f0fb9b4e53038f50b891c188df), [`d90cbc2`](https://github.com/Effect-TS/effect/commit/d90cbc274e2742d18671fe65aa4764c057eb6cba), [`75632bd`](https://github.com/Effect-TS/effect/commit/75632bd44b8025101d652ccbaeef898c7086c91c), [`c874a2e`](https://github.com/Effect-TS/effect/commit/c874a2e4b17e9d71904ca8375bb77b020975cb1d), [`bf865e5`](https://github.com/Effect-TS/effect/commit/bf865e5833f77fd8f6c06944ca9d507b54488301), [`f98b2b7`](https://github.com/Effect-TS/effect/commit/f98b2b7592cf20f9d85313e7f1e964cb65878138), [`de8ce92`](https://github.com/Effect-TS/effect/commit/de8ce924923eaa4e1b761a97eb45ec967389f3d5), [`cf8b2dd`](https://github.com/Effect-TS/effect/commit/cf8b2dd112f8e092ed99d78fd728db0f91c29050), [`db426a5`](https://github.com/Effect-TS/effect/commit/db426a5fb41ab84d18e3c8753a7329b4de544245), [`6862444`](https://github.com/Effect-TS/effect/commit/6862444094906ad4f2cb077ff3b9cc0b73880c8c), [`5fc8a90`](https://github.com/Effect-TS/effect/commit/5fc8a90ba46a5fd9f3b643f0b5aeadc69d717339), [`546a492`](https://github.com/Effect-TS/effect/commit/546a492e60eb2b8b048a489a474b934ea0877005), [`65c4796`](https://github.com/Effect-TS/effect/commit/65c47966ce39055f02cf5c808daabb3ea6442b0b), [`9760fdc`](https://github.com/Effect-TS/effect/commit/9760fdc37bdaef9da8b150e46b86ddfbe2ad9221), [`5b471e7`](https://github.com/Effect-TS/effect/commit/5b471e7d4317e8ee5d72bbbd3e0c9775160949ab), [`4f810cc`](https://github.com/Effect-TS/effect/commit/4f810cc2770e9f1f266851d2cb6257112c12af49)]: + - effect@3.13.0 + - @effect/experimental@0.41.0 + - @effect/platform@0.77.0 + - @effect/sql@0.30.0 + +## 0.30.1 + +### Patch Changes + +- Updated dependencies [[`4018eae`](https://github.com/Effect-TS/effect/commit/4018eaed2733241676ddb8c52416f463a8c32e35), [`543d36d`](https://github.com/Effect-TS/effect/commit/543d36d1a11452560b01ab966a82529ad5fee8c9), [`c407726`](https://github.com/Effect-TS/effect/commit/c407726f79df4a567a9631cddd8effaa16b3535d), [`f70a65a`](https://github.com/Effect-TS/effect/commit/f70a65ac80c6635d80b12beaf4d32a9cc59fa143), [`ba409f6`](https://github.com/Effect-TS/effect/commit/ba409f69c41aeaa29e475c0630735726eaf4dbac), [`3d2e356`](https://github.com/Effect-TS/effect/commit/3d2e3565e8a43d1bdb5daee8db3b90f56d71d859)]: + - effect@3.12.12 + - @effect/platform@0.76.1 + - @effect/experimental@0.40.1 + - @effect/sql@0.29.1 + +## 0.30.0 + +### Patch Changes + +- Updated dependencies [[`b6a032f`](https://github.com/Effect-TS/effect/commit/b6a032f07bffa020a848c813881879395134fa20), [`42ddd5f`](https://github.com/Effect-TS/effect/commit/42ddd5f144ce9f9d94a036679ebbd626446d37f5), [`2fe447c`](https://github.com/Effect-TS/effect/commit/2fe447c6354d334f9c591b8a8481818f5f0e797e), [`2473ad5`](https://github.com/Effect-TS/effect/commit/2473ad5cf23582e3a41338091fa526ffe611288d)]: + - effect@3.12.11 + - @effect/platform@0.76.0 + - @effect/experimental@0.40.0 + - @effect/sql@0.29.0 + +## 0.29.4 + +### Patch Changes + +- Updated dependencies [[`e30f132`](https://github.com/Effect-TS/effect/commit/e30f132c336c9d0760bad39f82a55c7ce5159eb7), [`33fa667`](https://github.com/Effect-TS/effect/commit/33fa667c2623be1026e1ccee91bd44f73b09020a), [`87f5f28`](https://github.com/Effect-TS/effect/commit/87f5f2842e4196cb88d13f10f443ff0567e82832), [`7d57ecd`](https://github.com/Effect-TS/effect/commit/7d57ecdaf5da2345ebbf9c22df50317578bde0f5), [`4dbd170`](https://github.com/Effect-TS/effect/commit/4dbd170538e8fb7a36aa7c469c6f93b6c7000091)]: + - effect@3.12.10 + - @effect/platform@0.75.4 + - @effect/experimental@0.39.4 + - @effect/sql@0.28.4 + +## 0.29.3 + +### Patch Changes + +- Updated dependencies [[`1b4a4e9`](https://github.com/Effect-TS/effect/commit/1b4a4e904ef5227ec7d9114d4e417eca19eed940)]: + - effect@3.12.9 + - @effect/experimental@0.39.3 + - @effect/platform@0.75.3 + - @effect/sql@0.28.3 + +## 0.29.2 + +### Patch Changes + +- Updated dependencies [[`59b3cfb`](https://github.com/Effect-TS/effect/commit/59b3cfbbd5713dd9475998e95fad5534c0b21466), [`766113c`](https://github.com/Effect-TS/effect/commit/766113c0ea3512cdb887650ead8ba314236e22ee), [`bb05fb8`](https://github.com/Effect-TS/effect/commit/bb05fb83457355b1ca567228a9e041edfb6fd85d), [`712277f`](https://github.com/Effect-TS/effect/commit/712277f949052a24b46e4aa234063a6abf395c90), [`f269122`](https://github.com/Effect-TS/effect/commit/f269122508693b111142994dd48698ddc75f3d69), [`8f6006a`](https://github.com/Effect-TS/effect/commit/8f6006a610fb6d6c7b8d14209a7323338a8964ff), [`c45b559`](https://github.com/Effect-TS/effect/commit/c45b5592b5fd1189a5c932cfe05bd7d5f6d68508), [`430c846`](https://github.com/Effect-TS/effect/commit/430c846cbac05b187e3d24ac8dfee0cf22506f7c), [`7b03057`](https://github.com/Effect-TS/effect/commit/7b03057507d2dab5e6793beb9c578dedaaeb15fe), [`a9c94c8`](https://github.com/Effect-TS/effect/commit/a9c94c807755610831211a686d2fad849ab38eb4), [`107e6f0`](https://github.com/Effect-TS/effect/commit/107e6f0557a1e2d3b0dce25d62fa1e2601521752), [`c9175ae`](https://github.com/Effect-TS/effect/commit/c9175aef41cb1e3b689d0ac0a4f53d8107376b58), [`65c11b9`](https://github.com/Effect-TS/effect/commit/65c11b9266ec9447c31c26fe3ed35c73bd3b81fd), [`e386d2f`](https://github.com/Effect-TS/effect/commit/e386d2f1b3ab3ac2c14ee76de11f5963d32a3df4), [`9172efb`](https://github.com/Effect-TS/effect/commit/9172efba98bc6a82353e6ec2af61ac08f038ba64)]: + - @effect/platform@0.75.2 + - effect@3.12.8 + - @effect/experimental@0.39.2 + - @effect/sql@0.28.2 + +## 0.29.1 + +### Patch Changes + +- Updated dependencies [[`8dff1d1`](https://github.com/Effect-TS/effect/commit/8dff1d1bff76cdba643cad7f0bf864300f08bc61)]: + - effect@3.12.7 + - @effect/experimental@0.39.1 + - @effect/platform@0.75.1 + - @effect/sql@0.28.1 + +## 0.29.0 + +### Patch Changes + +- Updated dependencies [[`5e43ce5`](https://github.com/Effect-TS/effect/commit/5e43ce50bae116865906112e7f88d390739d778b), [`289c13b`](https://github.com/Effect-TS/effect/commit/289c13b38e8e35b214d46d385d05dead176c87cd), [`76eb7d0`](https://github.com/Effect-TS/effect/commit/76eb7d0fbce3c009c8f77e84c178cb15bbed9709), [`8b4e75d`](https://github.com/Effect-TS/effect/commit/8b4e75d35daea807c447ca760948a717aa66bb52), [`fc5e0f0`](https://github.com/Effect-TS/effect/commit/fc5e0f0d357a0051cfa01c1ede83ffdd3cb41ab1), [`004fd2b`](https://github.com/Effect-TS/effect/commit/004fd2bbd1459e64fb1b57f02eeb791ca5ea1ea5), [`b2a31be`](https://github.com/Effect-TS/effect/commit/b2a31be85c35d891351ce4f9a2cc93ece0c257f6), [`5514d05`](https://github.com/Effect-TS/effect/commit/5514d05b5cd586ff5868b8bd41c959e95e6c33cd), [`bf5f0ae`](https://github.com/Effect-TS/effect/commit/bf5f0ae9daa0170471678e22585e8ec14ce667bb), [`3b19bcf`](https://github.com/Effect-TS/effect/commit/3b19bcfd3aaadb6c9253428622df524537c8e626), [`b064b3b`](https://github.com/Effect-TS/effect/commit/b064b3b293615fd268cc5a5647d0981eb67750b8), [`eb264ed`](https://github.com/Effect-TS/effect/commit/eb264ed8a6e8c92a9dc7006f766c6ca2e5d29e03), [`289c13b`](https://github.com/Effect-TS/effect/commit/289c13b38e8e35b214d46d385d05dead176c87cd), [`f474678`](https://github.com/Effect-TS/effect/commit/f474678bf10b8f1c80e3dc096ddc7ecf20b2b23e), [`ee187d0`](https://github.com/Effect-TS/effect/commit/ee187d098007a402844c94d04f0cd8f07695377a)]: + - @effect/experimental@0.39.0 + - @effect/platform@0.75.0 + - effect@3.12.6 + - @effect/sql@0.28.0 + +## 0.28.0 + +### Patch Changes + +- Updated dependencies [[`bd0d489`](https://github.com/Effect-TS/effect/commit/bd0d4892b098bc4c589444af9f50259c2c02ec0f), [`a8b0ddb`](https://github.com/Effect-TS/effect/commit/a8b0ddb84710054799fc8f57485b95d00093ada1), [`8653072`](https://github.com/Effect-TS/effect/commit/86530720d7a03e118d2c5a8bf5a997cee7e7f3d6), [`507d546`](https://github.com/Effect-TS/effect/commit/507d546bd49db31000425fb5da88c434e4291bea), [`a8b0ddb`](https://github.com/Effect-TS/effect/commit/a8b0ddb84710054799fc8f57485b95d00093ada1), [`8db239b`](https://github.com/Effect-TS/effect/commit/8db239b9c869a3707f6566b9d9dbdf53c4df03fc), [`84a0911`](https://github.com/Effect-TS/effect/commit/84a091181634c3a022c94234cec7764a3aeef1be), [`84a0911`](https://github.com/Effect-TS/effect/commit/84a091181634c3a022c94234cec7764a3aeef1be), [`3179a9f`](https://github.com/Effect-TS/effect/commit/3179a9f65d23369a6a9a1f80f7750566dd28df22), [`6cb9b76`](https://github.com/Effect-TS/effect/commit/6cb9b766396d0b2ed995cf26957359713efd202e), [`1fcbe55`](https://github.com/Effect-TS/effect/commit/1fcbe55345042d8468f6a98c84081bd00b6bcf5a), [`bd0d489`](https://github.com/Effect-TS/effect/commit/bd0d4892b098bc4c589444af9f50259c2c02ec0f), [`d9a63d9`](https://github.com/Effect-TS/effect/commit/d9a63d9d385653865954cac895065360d54cc56b), [`6cb9b76`](https://github.com/Effect-TS/effect/commit/6cb9b766396d0b2ed995cf26957359713efd202e)]: + - @effect/experimental@0.38.0 + - @effect/sql@0.27.0 + - effect@3.12.5 + - @effect/platform@0.74.0 + +## 0.27.1 + +### Patch Changes + +- Updated dependencies [[`5b50ea4`](https://github.com/Effect-TS/effect/commit/5b50ea4a10cf9acd51f9624b2474d9d5ded74019), [`c170a68`](https://github.com/Effect-TS/effect/commit/c170a68b6266100774461fcd6c0e0fabb60112f2), [`a66c2eb`](https://github.com/Effect-TS/effect/commit/a66c2eb473245092cd41f04c2eb2b7b02cf53718), [`c9e5e1b`](https://github.com/Effect-TS/effect/commit/c9e5e1be17c0c84d3d4e2abc3c60215cdb56bbbe), [`7b3d58d`](https://github.com/Effect-TS/effect/commit/7b3d58d7aec2152ec282460871d3e9de45ed254d)]: + - effect@3.12.4 + - @effect/platform@0.73.1 + - @effect/experimental@0.37.1 + - @effect/sql@0.26.1 + +## 0.27.0 + +### Patch Changes + +- Updated dependencies [[`d7dac48`](https://github.com/Effect-TS/effect/commit/d7dac48a477cdfeec509dbe9f33fce6a1b02b63d), [`c110032`](https://github.com/Effect-TS/effect/commit/c110032322450a8824ba38ae24335a538cd2ce9a), [`1d7fd2b`](https://github.com/Effect-TS/effect/commit/1d7fd2b7ee8eeecc912d27adf76ed897db236dc5), [`1d7fd2b`](https://github.com/Effect-TS/effect/commit/1d7fd2b7ee8eeecc912d27adf76ed897db236dc5), [`23ac740`](https://github.com/Effect-TS/effect/commit/23ac740c7dd4610b7d265c2071b88b0968419e9a), [`8cd7319`](https://github.com/Effect-TS/effect/commit/8cd7319b6568bfc7a30ca16c104d189e37eac3a0)]: + - effect@3.12.3 + - @effect/platform@0.73.0 + - @effect/experimental@0.37.0 + - @effect/sql@0.26.0 + +## 0.26.2 + +### Patch Changes + +- Updated dependencies [[`734af82`](https://github.com/Effect-TS/effect/commit/734af82138e78b9c57a8355b1c6b80e80d38b222), [`b63c780`](https://github.com/Effect-TS/effect/commit/b63c78010893101520448ddda7019c487cf7eedd), [`212e784`](https://github.com/Effect-TS/effect/commit/212e78475f527147ec27c090bd13f789f55add7a), [`f852cb0`](https://github.com/Effect-TS/effect/commit/f852cb02040ea2f165e9b449615b8b1366add5d5), [`7276ae2`](https://github.com/Effect-TS/effect/commit/7276ae21062896adbb7508ac5b2dece95316322f), [`212e784`](https://github.com/Effect-TS/effect/commit/212e78475f527147ec27c090bd13f789f55add7a), [`212e784`](https://github.com/Effect-TS/effect/commit/212e78475f527147ec27c090bd13f789f55add7a), [`212e784`](https://github.com/Effect-TS/effect/commit/212e78475f527147ec27c090bd13f789f55add7a), [`c640d77`](https://github.com/Effect-TS/effect/commit/c640d77b33ad417876f4e8ffe8574ee6cbe5607f), [`0def088`](https://github.com/Effect-TS/effect/commit/0def0887cfdb6755729a64dfd52b3b9f46b0576c)]: + - effect@3.12.2 + - @effect/platform@0.72.2 + - @effect/experimental@0.36.2 + - @effect/sql@0.25.2 + +## 0.26.1 + +### Patch Changes + +- Updated dependencies [[`302b57d`](https://github.com/Effect-TS/effect/commit/302b57d2cbf9b9ccc17450945aeebfb33cfe8d43), [`0988083`](https://github.com/Effect-TS/effect/commit/0988083d4594938590df5a287e5b27d38526dd07), [`8b46be6`](https://github.com/Effect-TS/effect/commit/8b46be6a3b8160362ab5ea9171c5e6932505125c), [`bfe8027`](https://github.com/Effect-TS/effect/commit/bfe802734b450a4b4ee069d1125dd37995db2bff), [`16dd657`](https://github.com/Effect-TS/effect/commit/16dd657033d8afac2ffea567b3c8bb27c9b249b6), [`39db211`](https://github.com/Effect-TS/effect/commit/39db211414e90c8db8fdad7dc8ce5b4661bcfaef)]: + - effect@3.12.1 + - @effect/experimental@0.36.1 + - @effect/platform@0.72.1 + - @effect/sql@0.25.1 + +## 0.26.0 + +### Patch Changes + +- Updated dependencies [[`abb22a4`](https://github.com/Effect-TS/effect/commit/abb22a429b9c52c31e84856294f175d2064a9b4d), [`f369a89`](https://github.com/Effect-TS/effect/commit/f369a89e98bc682969803b9304adaf4557bb36c2), [`642376c`](https://github.com/Effect-TS/effect/commit/642376c63fd7d78754db991631a4d50a5dc79aa3), [`3d2b7a7`](https://github.com/Effect-TS/effect/commit/3d2b7a7e942a7157afae5b1cdbc6f3fef116428e), [`ef64c6f`](https://github.com/Effect-TS/effect/commit/ef64c6fec0d47da573c04230dde9ea729366d871), [`73f9c6f`](https://github.com/Effect-TS/effect/commit/73f9c6f2ff091512cf904cc54ab59965b86e87c8), [`17cb451`](https://github.com/Effect-TS/effect/commit/17cb4514590e8a86263f7aed009f24da8a237342), [`d801820`](https://github.com/Effect-TS/effect/commit/d80182060c2ee945d7e0e4728812abf9465a0d6a), [`e1eeb2d`](https://github.com/Effect-TS/effect/commit/e1eeb2d7064b3870041dab142f3057970699bbf1), [`c11f3a6`](https://github.com/Effect-TS/effect/commit/c11f3a60a05c3b5fc8e7ce90136728154dc505b0), [`618f7e0`](https://github.com/Effect-TS/effect/commit/618f7e092a1011e5090dca1e69b5e9285689654b), [`c0ba834`](https://github.com/Effect-TS/effect/commit/c0ba834d1995cf5a8b250e4780fd43f3e3881151), [`e1eeb2d`](https://github.com/Effect-TS/effect/commit/e1eeb2d7064b3870041dab142f3057970699bbf1)]: + - effect@3.12.0 + - @effect/platform@0.72.0 + - @effect/experimental@0.36.0 + - @effect/sql@0.25.0 + +## 0.25.3 + +### Patch Changes + +- Updated dependencies [[`39457d4`](https://github.com/Effect-TS/effect/commit/39457d4897d9bc7df8af5c05d352866bbeae82eb), [`a475cc2`](https://github.com/Effect-TS/effect/commit/a475cc25fd7c9f26b27a8e98f8fbe43cc9e6ee3e), [`199214e`](https://github.com/Effect-TS/effect/commit/199214e21c616d8a0ccd7ed5f92e944e6c580193), [`b3c160d`](https://github.com/Effect-TS/effect/commit/b3c160d7a1fdfc2d3fb2440530f1ab80efc65133)]: + - effect@3.11.10 + - @effect/experimental@0.35.3 + - @effect/platform@0.71.7 + - @effect/sql@0.24.3 + +## 0.25.2 + +### Patch Changes + +- Updated dependencies [[`1c08a0b`](https://github.com/Effect-TS/effect/commit/1c08a0b8505badcffb4d9cade5a746ea90c9557e), [`1ce703b`](https://github.com/Effect-TS/effect/commit/1ce703b041bbd7560c5c437c9b9be48f027937fd), [`1ce703b`](https://github.com/Effect-TS/effect/commit/1ce703b041bbd7560c5c437c9b9be48f027937fd)]: + - effect@3.11.9 + - @effect/experimental@0.35.2 + - @effect/platform@0.71.6 + - @effect/sql@0.24.2 + +## 0.25.1 + +### Patch Changes + +- Updated dependencies [[`05d71f8`](https://github.com/Effect-TS/effect/commit/05d71f85622305705d8316817694a09762e60865), [`e66b920`](https://github.com/Effect-TS/effect/commit/e66b9205f25ab425d30640886eb3fb2c4715bc26)]: + - @effect/platform@0.71.5 + - @effect/experimental@0.35.1 + - @effect/sql@0.24.1 + +## 0.25.0 + +### Patch Changes + +- Updated dependencies [[`909181a`](https://github.com/Effect-TS/effect/commit/909181a9ce9052a80432ccf52187e0723004bf7f), [`909181a`](https://github.com/Effect-TS/effect/commit/909181a9ce9052a80432ccf52187e0723004bf7f), [`1a6b52d`](https://github.com/Effect-TS/effect/commit/1a6b52dcf020d36e38a7bc90b648152cf5a8ccba)]: + - @effect/platform@0.71.4 + - effect@3.11.8 + - @effect/experimental@0.35.0 + - @effect/sql@0.24.0 + +## 0.24.4 + +### Patch Changes + +- Updated dependencies [[`6984508`](https://github.com/Effect-TS/effect/commit/6984508c87f1bd91213b44c19b25ab5e2dcc1ce0), [`883639c`](https://github.com/Effect-TS/effect/commit/883639cc8ce47757f1cd39439391a8028c0812fe)]: + - @effect/platform@0.71.3 + - @effect/experimental@0.34.3 + - @effect/sql@0.23.3 + +## 0.24.3 + +### Patch Changes + +- [#4143](https://github.com/Effect-TS/effect/pull/4143) [`f7f2dd6`](https://github.com/Effect-TS/effect/commit/f7f2dd6794abe3709950543ef44fab03f265a1e0) Thanks @tim-smart! - add timeout to sql connection attempts + +## 0.24.2 + +### Patch Changes + +- Updated dependencies [[`2408616`](https://github.com/Effect-TS/effect/commit/24086163b60b09cc6d0885bd565ef080dcbe866b), [`cec0b4d`](https://github.com/Effect-TS/effect/commit/cec0b4d152ef660be2ccdb0927255f2471436e6e), [`cec0b4d`](https://github.com/Effect-TS/effect/commit/cec0b4d152ef660be2ccdb0927255f2471436e6e), [`8d978c5`](https://github.com/Effect-TS/effect/commit/8d978c53f6fcc98d9d645ecba3e4b55d4297dd36), [`cec0b4d`](https://github.com/Effect-TS/effect/commit/cec0b4d152ef660be2ccdb0927255f2471436e6e), [`cec0b4d`](https://github.com/Effect-TS/effect/commit/cec0b4d152ef660be2ccdb0927255f2471436e6e)]: + - effect@3.11.7 + - @effect/platform@0.71.2 + - @effect/experimental@0.34.2 + - @effect/sql@0.23.2 + +## 0.24.1 + +### Patch Changes + +- Updated dependencies [[`1d3df5b`](https://github.com/Effect-TS/effect/commit/1d3df5bc4324e88a392c348db35fd9d029c7b25e)]: + - @effect/platform@0.71.1 + - @effect/experimental@0.34.1 + - @effect/sql@0.23.1 + +## 0.24.0 + +### Patch Changes + +- Updated dependencies [[`662d1ce`](https://github.com/Effect-TS/effect/commit/662d1ce6fb7da384a95888d5b2bb5605bdf3208d), [`c99a0f3`](https://github.com/Effect-TS/effect/commit/c99a0f376d049d3793ed33e146d9873b8a5e5b78), [`11fc401`](https://github.com/Effect-TS/effect/commit/11fc401f436f99bf4be95f56d50b0e4bdfe5edea), [`c99a0f3`](https://github.com/Effect-TS/effect/commit/c99a0f376d049d3793ed33e146d9873b8a5e5b78), [`31c62d8`](https://github.com/Effect-TS/effect/commit/31c62d83cbdcf9850a8b5331faa239601c60f78a)]: + - effect@3.11.6 + - @effect/platform@0.71.0 + - @effect/experimental@0.34.0 + - @effect/sql@0.23.0 + +## 0.23.7 + +### Patch Changes + +- Updated dependencies [[`9f5a6f7`](https://github.com/Effect-TS/effect/commit/9f5a6f701bf7ba31adccd1f1bcfa8ab5614c9be8), [`ef70ffc`](https://github.com/Effect-TS/effect/commit/ef70ffc417ec035ede40c62b7316e447cc7c1932), [`22905cf`](https://github.com/Effect-TS/effect/commit/22905cf5addfb1ff3d2a6135c52036be958ae911), [`9f5a6f7`](https://github.com/Effect-TS/effect/commit/9f5a6f701bf7ba31adccd1f1bcfa8ab5614c9be8), [`1e59e4f`](https://github.com/Effect-TS/effect/commit/1e59e4fd778da18296812a2a32f36ca8ae50f60d), [`9f5a6f7`](https://github.com/Effect-TS/effect/commit/9f5a6f701bf7ba31adccd1f1bcfa8ab5614c9be8), [`8d914e5`](https://github.com/Effect-TS/effect/commit/8d914e504e7a22d0ea628e8af265ee450ff9530f), [`03bb00f`](https://github.com/Effect-TS/effect/commit/03bb00faa74f9e168a54a8cc0828a664fbb1ab05), [`9f5a6f7`](https://github.com/Effect-TS/effect/commit/9f5a6f701bf7ba31adccd1f1bcfa8ab5614c9be8), [`14e1149`](https://github.com/Effect-TS/effect/commit/14e1149f1af5a022f06eb8c2e4ba9fec17fe7426), [`9f5a6f7`](https://github.com/Effect-TS/effect/commit/9f5a6f701bf7ba31adccd1f1bcfa8ab5614c9be8), [`9f5a6f7`](https://github.com/Effect-TS/effect/commit/9f5a6f701bf7ba31adccd1f1bcfa8ab5614c9be8)]: + - effect@3.11.5 + - @effect/experimental@0.33.7 + - @effect/platform@0.70.7 + - @effect/sql@0.22.7 + +## 0.23.6 + +### Patch Changes + +- Updated dependencies [[`9a5b8e3`](https://github.com/Effect-TS/effect/commit/9a5b8e36d184bd4967a88752cb6e755e1be263af)]: + - @effect/platform@0.70.6 + - @effect/experimental@0.33.6 + - @effect/sql@0.22.6 + +## 0.23.5 + +### Patch Changes + +- [#4090](https://github.com/Effect-TS/effect/pull/4090) [`e993627`](https://github.com/Effect-TS/effect/commit/e9936278d9b72a8b96c37cf7968d0e095069c488) Thanks @rocwang! - Add the missing dependency on @effect/experimental to @effect/sql-X + +- Updated dependencies [[`415f4c9`](https://github.com/Effect-TS/effect/commit/415f4c98321868531727a83cbaad70164f5e4c40), [`518b258`](https://github.com/Effect-TS/effect/commit/518b258a8a67ecd332a9252c35cc060f8368dee2), [`6e323a3`](https://github.com/Effect-TS/effect/commit/6e323a36faaee46b328c8e3cf60a76b3aff9907f), [`518b258`](https://github.com/Effect-TS/effect/commit/518b258a8a67ecd332a9252c35cc060f8368dee2), [`6e323a3`](https://github.com/Effect-TS/effect/commit/6e323a36faaee46b328c8e3cf60a76b3aff9907f)]: + - @effect/platform@0.70.5 + - effect@3.11.4 + - @effect/experimental@0.33.5 + - @effect/sql@0.22.5 + +## 0.23.4 + +### Patch Changes + +- Updated dependencies [[`90906f7`](https://github.com/Effect-TS/effect/commit/90906f7f154b12c7182e8f39e3c55ef3937db857), [`3862cd3`](https://github.com/Effect-TS/effect/commit/3862cd3c7f6a542ed65fb81255b3bd696ce2f567), [`3862cd3`](https://github.com/Effect-TS/effect/commit/3862cd3c7f6a542ed65fb81255b3bd696ce2f567), [`343b6aa`](https://github.com/Effect-TS/effect/commit/343b6aa6ac4a74276bfc7c63ccbf4a1d72bc1bed), [`afba339`](https://github.com/Effect-TS/effect/commit/afba339adc11dad56b5a3b7ca94487e58f34d613)]: + - effect@3.11.3 + - @effect/platform@0.70.4 + - @effect/sql@0.22.4 + +## 0.23.3 + +### Patch Changes + +- Updated dependencies [[`7044730`](https://github.com/Effect-TS/effect/commit/70447306be1aeeb7d87c230b2a96ec87b993ede9)]: + - @effect/platform@0.70.3 + - @effect/sql@0.22.3 + +## 0.23.2 + +### Patch Changes + +- Updated dependencies [[`01cee56`](https://github.com/Effect-TS/effect/commit/01cee560b58d94b24cc20e98083251b73e658b41), [`c2249ea`](https://github.com/Effect-TS/effect/commit/c2249ea13fd98ab7d9aa628787931356d8ec2860), [`1358aa5`](https://github.com/Effect-TS/effect/commit/1358aa5326eaa85ef13ee8d1fed0b4a4288ed3eb), [`1de3fe7`](https://github.com/Effect-TS/effect/commit/1de3fe7d1cbafd6391eaa38c2300b99e332cc2aa)]: + - effect@3.11.2 + - @effect/platform@0.70.2 + - @effect/sql@0.22.2 + +## 0.23.1 + +### Patch Changes + +- Updated dependencies [[`dd8a2d8`](https://github.com/Effect-TS/effect/commit/dd8a2d8e80d33b16719fc69361eaedf0b59d4620), [`a71bfef`](https://github.com/Effect-TS/effect/commit/a71bfef46f5061bb2502a61a333638a987b62273)]: + - effect@3.11.1 + - @effect/platform@0.70.1 + - @effect/sql@0.22.1 + +## 0.23.0 + +### Patch Changes + +- Updated dependencies [[`147434b`](https://github.com/Effect-TS/effect/commit/147434b03d5e1fd692dd9f126e5ab0910f3b76d3), [`6e69493`](https://github.com/Effect-TS/effect/commit/6e694930048bbaf98110f35f41566aeb9752d471), [`147434b`](https://github.com/Effect-TS/effect/commit/147434b03d5e1fd692dd9f126e5ab0910f3b76d3), [`5eff3f6`](https://github.com/Effect-TS/effect/commit/5eff3f6fa3aae7e86948a62cbfd63b8d6c3bdf92), [`d9fe79b`](https://github.com/Effect-TS/effect/commit/d9fe79bb5a3fe105d8e7a3bc2922a8ad936a5d10), [`251d189`](https://github.com/Effect-TS/effect/commit/251d189420bbba71990574e91098c499065f9a9b), [`5a259f3`](https://github.com/Effect-TS/effect/commit/5a259f3711b4369f55d885b568bdb21136155261), [`b4ce4ea`](https://github.com/Effect-TS/effect/commit/b4ce4ea7fd514a7e572f2dcd879c98f334981b0e), [`15fcc5a`](https://github.com/Effect-TS/effect/commit/15fcc5a0ea4bbf40ab48fa6a04fdda74f76f4c07), [`9bc9a47`](https://github.com/Effect-TS/effect/commit/9bc9a476800dc645903c888a68bb1d3baa3383c6), [`aadb8a4`](https://github.com/Effect-TS/effect/commit/aadb8a48d2cba197c06ec9996505510e48e4e5cb), [`1e2747c`](https://github.com/Effect-TS/effect/commit/1e2747c63a4820d1459cbbc88c71212983bd68bd), [`9264162`](https://github.com/Effect-TS/effect/commit/9264162a82783a651776fb7b87604564a63e7070), [`e0b9b09`](https://github.com/Effect-TS/effect/commit/e0b9b09e70c386b2da17d1f0a15b0511861c89e8), [`c36f3b9`](https://github.com/Effect-TS/effect/commit/c36f3b95df5ce9d71b66f22f26ce12eda8d3e848), [`672bde5`](https://github.com/Effect-TS/effect/commit/672bde5bec51c7d6f9862828e6a654cb2cb6f93d), [`aadb8a4`](https://github.com/Effect-TS/effect/commit/aadb8a48d2cba197c06ec9996505510e48e4e5cb)]: + - effect@3.11.0 + - @effect/platform@0.70.0 + - @effect/sql@0.22.0 + +## 0.22.4 + +### Patch Changes + +- Updated dependencies [[`3069614`](https://github.com/Effect-TS/effect/commit/30696149271129fc618f6f2ccd1d8f2f6c0f9cd7), [`09a5e52`](https://github.com/Effect-TS/effect/commit/09a5e522fd9b221f05d85b1d1c8a740d4973c302)]: + - effect@3.10.20 + - @effect/platform@0.69.32 + - @effect/sql@0.21.4 + +## 0.22.3 + +### Patch Changes + +- Updated dependencies [[`e6d4a37`](https://github.com/Effect-TS/effect/commit/e6d4a37c1d7e657b5ea44063a1cf586808228fe5)]: + - @effect/platform@0.69.31 + - @effect/sql@0.21.3 + +## 0.22.2 + +### Patch Changes + +- Updated dependencies []: + - @effect/sql@0.21.2 + +## 0.22.1 + +### Patch Changes + +- Updated dependencies [[`270f199`](https://github.com/Effect-TS/effect/commit/270f199b31810fd643e4c22818698adcbdb5d396)]: + - @effect/platform@0.69.30 + - @effect/sql@0.21.1 + +## 0.22.0 + +### Minor Changes + +- [#4022](https://github.com/Effect-TS/effect/pull/4022) [`1b1ba09`](https://github.com/Effect-TS/effect/commit/1b1ba099bca49ff48ffe931cc1b607314a5eaafa) Thanks @tim-smart! - allow cloning a SqlClient with transforms disabled + +### Patch Changes + +- [#4021](https://github.com/Effect-TS/effect/pull/4021) [`e9dfea3`](https://github.com/Effect-TS/effect/commit/e9dfea3f394444ebd8929e5cfe05ce740cf84d6e) Thanks @tim-smart! - add .reactive method to SqlClient interface + +- Updated dependencies [[`e9dfea3`](https://github.com/Effect-TS/effect/commit/e9dfea3f394444ebd8929e5cfe05ce740cf84d6e), [`1b1ba09`](https://github.com/Effect-TS/effect/commit/1b1ba099bca49ff48ffe931cc1b607314a5eaafa), [`24cc35e`](https://github.com/Effect-TS/effect/commit/24cc35e26d6ed4a076470bc687ffd99cc50991b3)]: + - @effect/sql@0.21.0 + - @effect/platform@0.69.29 + +## 0.21.12 + +### Patch Changes + +- [#4007](https://github.com/Effect-TS/effect/pull/4007) [`944025b`](https://github.com/Effect-TS/effect/commit/944025bc5ce139f4a85846aa689bf30ec06a8ec1) Thanks @gcanti! - Wrap JSDoc @example tags with a TypeScript fence, closes #4002 + +- Updated dependencies [[`edd72be`](https://github.com/Effect-TS/effect/commit/edd72be57b904d60c9cbffc2537901821a9da537), [`a3e2771`](https://github.com/Effect-TS/effect/commit/a3e277170a1f7cf61fd629acb60304c7e81d9498), [`944025b`](https://github.com/Effect-TS/effect/commit/944025bc5ce139f4a85846aa689bf30ec06a8ec1), [`54addee`](https://github.com/Effect-TS/effect/commit/54addee438a644bf010646c52042c7b89c5fc0a7), [`a9e00e4`](https://github.com/Effect-TS/effect/commit/a9e00e43f0b5dd22c1f9d5b78be6383daea09c20)]: + - @effect/platform@0.69.28 + - effect@3.10.19 + - @effect/sql@0.20.12 + +## 0.21.11 + +### Patch Changes + +- Updated dependencies [[`af409cf`](https://github.com/Effect-TS/effect/commit/af409cf1d2ff973be11cc079ea373eaeedca25de), [`beaccae`](https://github.com/Effect-TS/effect/commit/beaccae2d15931e9fe475fb50a0b3638243fe3f7)]: + - effect@3.10.18 + - @effect/platform@0.69.27 + - @effect/sql@0.20.11 + +## 0.21.10 + +### Patch Changes + +- Updated dependencies [[`c963886`](https://github.com/Effect-TS/effect/commit/c963886d5817986fcbd6bfa4ddf50aca8b6c8184), [`42c4ce6`](https://github.com/Effect-TS/effect/commit/42c4ce6f8d8c7d847e97757650a8ad9419a829d7)]: + - @effect/platform@0.69.26 + - effect@3.10.17 + - @effect/sql@0.20.10 + +## 0.21.9 + +### Patch Changes + +- Updated dependencies [[`320557a`](https://github.com/Effect-TS/effect/commit/320557ab18d13c5e22fc7dc0d2a157eae461012f), [`4dca30c`](https://github.com/Effect-TS/effect/commit/4dca30cfcdafe4542e236489f71d6f171a5b4e38), [`1d99867`](https://github.com/Effect-TS/effect/commit/1d998671be3cd11043f232822e91dd8c98fccfa9), [`6dae414`](https://github.com/Effect-TS/effect/commit/6dae4147991a97ec14a99289bd25fadae7541e8d), [`6b0d737`](https://github.com/Effect-TS/effect/commit/6b0d737078bf63b97891e6bc47affc04b28f9cf7), [`d8356aa`](https://github.com/Effect-TS/effect/commit/d8356aad428a0c2290db52380220f81d9ec94232), [`7b93dd6`](https://github.com/Effect-TS/effect/commit/7b93dd622e2ab79c7072d79d0d9611e446202201)]: + - @effect/platform@0.69.25 + - effect@3.10.16 + - @effect/sql@0.20.9 + +## 0.21.8 + +### Patch Changes + +- Updated dependencies [[`3cc6514`](https://github.com/Effect-TS/effect/commit/3cc6514d2dd64e010cb760cc29bfce98c349bb10)]: + - @effect/platform@0.69.24 + - @effect/sql@0.20.8 + +## 0.21.7 + +### Patch Changes + +- Updated dependencies [[`3aff4d3`](https://github.com/Effect-TS/effect/commit/3aff4d38837c213bb2987973dc4b98febb9f92d2)]: + - @effect/platform@0.69.23 + - @effect/sql@0.20.7 + +## 0.21.6 + +### Patch Changes + +- Updated dependencies [[`8398b32`](https://github.com/Effect-TS/effect/commit/8398b3208242a88239d4449910b7baf923cfe3b6), [`72e55b7`](https://github.com/Effect-TS/effect/commit/72e55b7c610784fcebdbadc592c876e23e76a986)]: + - effect@3.10.15 + - @effect/platform@0.69.22 + - @effect/sql@0.20.6 + +## 0.21.5 + +### Patch Changes + +- Updated dependencies [[`f983946`](https://github.com/Effect-TS/effect/commit/f9839467b4cad6e788297764ef9f9f0b9fd203f9), [`2d8a750`](https://github.com/Effect-TS/effect/commit/2d8a75081eb83a0a81f817fdf6f428369c5064ab)]: + - effect@3.10.14 + - @effect/platform@0.69.21 + - @effect/sql@0.20.5 + +## 0.21.4 + +### Patch Changes + +- Updated dependencies [[`995bbdf`](https://github.com/Effect-TS/effect/commit/995bbdffea2e332f203cd5b474cd6a1c77dfa6ae)]: + - effect@3.10.13 + - @effect/platform@0.69.20 + - @effect/sql@0.20.4 + +## 0.21.3 + +### Patch Changes + +- Updated dependencies [[`eb8c52d`](https://github.com/Effect-TS/effect/commit/eb8c52d8b4c5e067ebf0a81eb742f5822e6439b5)]: + - @effect/platform@0.69.19 + - @effect/sql@0.20.3 + +## 0.21.2 + +### Patch Changes + +- Updated dependencies [[`a0584ec`](https://github.com/Effect-TS/effect/commit/a0584ece92ed784bfb139e9c5a699f02d1e71c2d), [`dd14efe`](https://github.com/Effect-TS/effect/commit/dd14efe0ace255f571273aae876adea96267d7e6), [`dd14efe`](https://github.com/Effect-TS/effect/commit/dd14efe0ace255f571273aae876adea96267d7e6)]: + - @effect/platform@0.69.18 + - effect@3.10.12 + - @effect/sql@0.20.2 + +## 0.21.1 + +### Patch Changes + +- Updated dependencies [[`5eef499`](https://github.com/Effect-TS/effect/commit/5eef4998b6ccb7a5404d9e4fef85e57fa35fbb8a), [`8240b1c`](https://github.com/Effect-TS/effect/commit/8240b1c10d45312fc863cb679b1a1e8441af0c1a), [`5eef499`](https://github.com/Effect-TS/effect/commit/5eef4998b6ccb7a5404d9e4fef85e57fa35fbb8a)]: + - effect@3.10.11 + - @effect/platform@0.69.17 + - @effect/sql@0.20.1 + +## 0.21.0 + +### Patch Changes + +- Updated dependencies []: + - @effect/sql@0.20.0 + +## 0.20.0 + +### Patch Changes + +- Updated dependencies [[`cd720ae`](https://github.com/Effect-TS/effect/commit/cd720aedf7f2571edec0843d6a633e84e4832b28), [`cd720ae`](https://github.com/Effect-TS/effect/commit/cd720aedf7f2571edec0843d6a633e84e4832b28), [`cd720ae`](https://github.com/Effect-TS/effect/commit/cd720aedf7f2571edec0843d6a633e84e4832b28), [`b631f40`](https://github.com/Effect-TS/effect/commit/b631f40abbe649b2a089764585b5c39f6a695ac6), [`7d89650`](https://github.com/Effect-TS/effect/commit/7d8965036cd2ea435c8441ffec3345488baebf85)]: + - effect@3.10.10 + - @effect/platform@0.69.16 + - @effect/sql@0.19.0 + +## 0.19.5 + +### Patch Changes + +- Updated dependencies [[`8a30e1d`](https://github.com/Effect-TS/effect/commit/8a30e1dfa3a7103bf5414fc6a7fca3088d8c8c00)]: + - @effect/platform@0.69.15 + - @effect/sql@0.18.16 + +## 0.19.4 + +### Patch Changes + +- Updated dependencies [[`a123e80`](https://github.com/Effect-TS/effect/commit/a123e80f111a625428a5b5622b7f55ee1073566b), [`bd5fcd3`](https://github.com/Effect-TS/effect/commit/bd5fcd3e6b603b1e505af90d6a00627c8eca6d41), [`0289d3b`](https://github.com/Effect-TS/effect/commit/0289d3b6391031d00329365bab9791b355031fe3), [`7386b71`](https://github.com/Effect-TS/effect/commit/7386b710e5be570e17f468928a6ed19d549a3e12), [`07c493a`](https://github.com/Effect-TS/effect/commit/07c493a598e096c7810cd06def8cfa43493c46b1), [`257ab1b`](https://github.com/Effect-TS/effect/commit/257ab1b539fa6e930b7ae2583a188376372200d7), [`4211a23`](https://github.com/Effect-TS/effect/commit/4211a2355bb3af3f0e756e2aae9d293379f25662)]: + - effect@3.10.9 + - @effect/platform@0.69.14 + - @effect/sql@0.18.15 + +## 0.19.3 + +### Patch Changes + +- Updated dependencies [[`68b5c9e`](https://github.com/Effect-TS/effect/commit/68b5c9e44f34192cef26e1cadda5e661a027df41), [`9c9928d`](https://github.com/Effect-TS/effect/commit/9c9928dfeacd9ac33dc37eb0ca3d7d8c39175ada), [`6306e66`](https://github.com/Effect-TS/effect/commit/6306e6656092b350d4ede5746da6f245ec9f7e07), [`361c7f3`](https://github.com/Effect-TS/effect/commit/361c7f39a2c10ede9324847c3d3ba192a6f9b20a)]: + - effect@3.10.8 + - @effect/sql@0.18.14 + - @effect/platform@0.69.13 + +## 0.19.2 + +### Patch Changes + +- Updated dependencies [[`33f5b9f`](https://github.com/Effect-TS/effect/commit/33f5b9ffaebea4f1bd0e391b44c41fb6230e743a), [`50f0281`](https://github.com/Effect-TS/effect/commit/50f0281b0d2116726b8927a6217622d5f394f3e4)]: + - effect@3.10.7 + - @effect/platform@0.69.12 + - @effect/sql@0.18.13 + +## 0.19.1 + +### Patch Changes + +- Updated dependencies [[`ce1c21f`](https://github.com/Effect-TS/effect/commit/ce1c21ffc11902ac9ab453a51904207859d38552), [`81ddd45`](https://github.com/Effect-TS/effect/commit/81ddd45fc074b98206fafab416d9a5a28b31e07a)]: + - effect@3.10.6 + - @effect/platform@0.69.11 + - @effect/sql@0.18.12 + +## 0.19.0 + +### Minor Changes + +- [#3852](https://github.com/Effect-TS/effect/pull/3852) [`70dd4d7`](https://github.com/Effect-TS/effect/commit/70dd4d7cd2376e39244fa1729938f1b3ec55aec7) Thanks @sukovanej! - Use `layer` / `layerConfig` naming convention for the /sql-\* packages. Make `layer` constructors accept a raw config object. Add `layerConfig` constructors that accept `Config.Config<...>`. + +### Patch Changes + +- Updated dependencies [[`3a6d757`](https://github.com/Effect-TS/effect/commit/3a6d757badeebe00d8ef4d67530d073c8264dcfa), [`59d813a`](https://github.com/Effect-TS/effect/commit/59d813aa4973d1115cfc70cc3667508335f49693)]: + - effect@3.10.5 + - @effect/platform@0.69.10 + - @effect/sql@0.18.11 + +## 0.18.10 + +### Patch Changes + +- Updated dependencies [[`2367708`](https://github.com/Effect-TS/effect/commit/2367708be449f9526a2047e321302d7bfb16f18e)]: + - @effect/platform@0.69.9 + - effect@3.10.4 + - @effect/sql@0.18.10 + +## 0.18.9 + +### Patch Changes + +- Updated dependencies [[`522f7c5`](https://github.com/Effect-TS/effect/commit/522f7c518a5acfb55ef96d6796869f002cc3eaf8)]: + - @effect/platform@0.69.8 + - @effect/sql@0.18.9 + +## 0.18.8 + +### Patch Changes + +- Updated dependencies [[`690d6c5`](https://github.com/Effect-TS/effect/commit/690d6c54d2145adb0af545c447db7d4755bf3c6b), [`b9423d8`](https://github.com/Effect-TS/effect/commit/b9423d8bf8181a2389fdbce1e3c14ac6fe8d54f5), [`279fe3a`](https://github.com/Effect-TS/effect/commit/279fe3a7168fe84e520c2cc88ba189a15f03a2bc)]: + - @effect/platform@0.69.7 + - effect@3.10.3 + - @effect/sql@0.18.8 + +## 0.18.7 + +### Patch Changes + +- Updated dependencies [[`714e119`](https://github.com/Effect-TS/effect/commit/714e11945e45e5a2554ee058e6c43f82a8e309cf), [`c1afd55`](https://github.com/Effect-TS/effect/commit/c1afd55c54e61f9c432823d21b3d016f79160a37), [`42cd72a`](https://github.com/Effect-TS/effect/commit/42cd72a44ca9593e4d81fbb50e8111625fd0fb81)]: + - effect@3.10.2 + - @effect/platform@0.69.6 + - @effect/sql@0.18.7 + +## 0.18.6 + +### Patch Changes + +- Updated dependencies [[`9604d6b`](https://github.com/Effect-TS/effect/commit/9604d6b616435103dafea8b53637a9d1450b4750)]: + - effect@3.10.1 + - @effect/sql@0.18.6 + - @effect/platform@0.69.5 + +## 0.18.5 + +### Patch Changes + +- Updated dependencies [[`c86b1d7`](https://github.com/Effect-TS/effect/commit/c86b1d7cd47b66df190ef9775a475467c1abdbd6)]: + - @effect/platform@0.69.4 + - @effect/sql@0.18.5 + +## 0.18.4 + +### Patch Changes + +- Updated dependencies [[`d5fba63`](https://github.com/Effect-TS/effect/commit/d5fba6391e1005e374aa0238f13edfbd65848313), [`1eb2c30`](https://github.com/Effect-TS/effect/commit/1eb2c30ba064398db5790e376dedcfad55b7b005), [`02d413e`](https://github.com/Effect-TS/effect/commit/02d413e7b6bc1c64885969c37cc3e4e690c94d7d)]: + - @effect/platform@0.69.3 + - @effect/sql@0.18.4 + +## 0.18.3 + +### Patch Changes + +- Updated dependencies [[`e7afc47`](https://github.com/Effect-TS/effect/commit/e7afc47ce83e381c3f4aed2b2974e3b3d86a2340)]: + - @effect/platform@0.69.2 + - @effect/sql@0.18.3 + +## 0.18.2 + +### Patch Changes + +- Updated dependencies []: + - @effect/sql@0.18.2 + +## 0.18.1 + +### Patch Changes + +- Updated dependencies [[`7564f56`](https://github.com/Effect-TS/effect/commit/7564f56bb2844cf39d2b0d2d9e93cf9b2205e9a8), [`7564f56`](https://github.com/Effect-TS/effect/commit/7564f56bb2844cf39d2b0d2d9e93cf9b2205e9a8)]: + - @effect/platform@0.69.1 + - @effect/sql@0.18.1 + +## 0.18.0 + +### Patch Changes + +- Updated dependencies [[`4a01828`](https://github.com/Effect-TS/effect/commit/4a01828b66d6213e9bbe18979c893b13f7bb29bf), [`6d9de6b`](https://github.com/Effect-TS/effect/commit/6d9de6b871c5c08e6509a4e830c3d74758faa198), [`4a01828`](https://github.com/Effect-TS/effect/commit/4a01828b66d6213e9bbe18979c893b13f7bb29bf), [`c79c4c1`](https://github.com/Effect-TS/effect/commit/c79c4c178390fe61ff6dda88c9e058862349343a), [`38d30f0`](https://github.com/Effect-TS/effect/commit/38d30f08b8da62f9c3e308b9250738cb8d17bdb5), [`5821ce3`](https://github.com/Effect-TS/effect/commit/5821ce3455b47d25e0a40cae6ce22af9db5fa556)]: + - effect@3.10.0 + - @effect/platform@0.69.0 + - @effect/sql@0.18.0 + +## 0.17.0 + +### Minor Changes + +- [#3760](https://github.com/Effect-TS/effect/pull/3760) [`dacbf7d`](https://github.com/Effect-TS/effect/commit/dacbf7db59899065aee4e5dd95a6459880e09ceb) Thanks @tim-smart! - add sql-clickhouse & clickhouse dialect + +### Patch Changes + +- Updated dependencies [[`dacbf7d`](https://github.com/Effect-TS/effect/commit/dacbf7db59899065aee4e5dd95a6459880e09ceb)]: + - @effect/sql@0.17.0 + +## 0.16.6 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.68.6 + - @effect/sql@0.16.6 + +## 0.16.5 + +### Patch Changes + +- Updated dependencies [[`2036402`](https://github.com/Effect-TS/effect/commit/20364020b8b75a684791aa93d90626758023e9e9)]: + - @effect/platform@0.68.5 + - @effect/sql@0.16.5 + +## 0.16.4 + +### Patch Changes + +- Updated dependencies [[`1b1ef29`](https://github.com/Effect-TS/effect/commit/1b1ef29ae302322f69dc938f9337aa97b4c63266)]: + - @effect/platform@0.68.4 + - @effect/sql@0.16.4 + +## 0.16.3 + +### Patch Changes + +- Updated dependencies [[`61a99b2`](https://github.com/Effect-TS/effect/commit/61a99b2bf9d757870ef0c2ec9d4c877cdd364a3d), [`8c33087`](https://github.com/Effect-TS/effect/commit/8c330879425e80bed2f65e407cd59e991f0d7bec)]: + - effect@3.9.2 + - @effect/platform@0.68.3 + - @effect/sql@0.16.3 + +## 0.16.2 + +### Patch Changes + +- Updated dependencies []: + - @effect/sql@0.16.2 + - @effect/platform@0.68.2 + +## 0.16.1 + +### Patch Changes + +- Updated dependencies [[`b75ac5d`](https://github.com/Effect-TS/effect/commit/b75ac5d0909115507bedc90f18f2d34deb217769)]: + - @effect/platform@0.68.1 + - @effect/sql@0.16.1 + +## 0.16.0 + +### Patch Changes + +- Updated dependencies [[`90ceeab`](https://github.com/Effect-TS/effect/commit/90ceeab3a04051b740af18c8af8bd73ee8ec6363), [`90ceeab`](https://github.com/Effect-TS/effect/commit/90ceeab3a04051b740af18c8af8bd73ee8ec6363), [`90ceeab`](https://github.com/Effect-TS/effect/commit/90ceeab3a04051b740af18c8af8bd73ee8ec6363)]: + - @effect/platform@0.68.0 + - @effect/sql@0.16.0 + +## 0.15.2 + +### Patch Changes + +- [#3744](https://github.com/Effect-TS/effect/pull/3744) [`9fef880`](https://github.com/Effect-TS/effect/commit/9fef88016a5c36ba21537dd20bd7a9122825a05d) Thanks @tim-smart! - test sql connection as part of client construction + +## 0.15.1 + +### Patch Changes + +- Updated dependencies [[`3b2ad1d`](https://github.com/Effect-TS/effect/commit/3b2ad1d58a2e33dc1a72b7037396bd25ca1702a9)]: + - @effect/platform@0.67.1 + - effect@3.9.1 + - @effect/sql@0.15.1 + +## 0.15.0 + +### Patch Changes + +- Updated dependencies [[`ff3d1aa`](https://github.com/Effect-TS/effect/commit/ff3d1aab290b4d1173b2dfc7e4c76abb4babdc16), [`0ba66f2`](https://github.com/Effect-TS/effect/commit/0ba66f2451641fd6990e02ec1ed01c014db9dab0), [`bf77f51`](https://github.com/Effect-TS/effect/commit/bf77f51b323c383224ebf08adf77a7a6e8c9b3cd), [`016f9ad`](https://github.com/Effect-TS/effect/commit/016f9ad931a4b3d09a34e5caf13d87c5b8e9c984), [`0779681`](https://github.com/Effect-TS/effect/commit/07796813f07de035719728733096ba64ce333469), [`534129f`](https://github.com/Effect-TS/effect/commit/534129f8113ce1a8ec50828083e16da9c86326c6), [`d75140c`](https://github.com/Effect-TS/effect/commit/d75140c7a664ceda43142d999f4ff8dcd36d6dda), [`be0451c`](https://github.com/Effect-TS/effect/commit/be0451c149b6618af79cb839cdf04af2db1efb03), [`9237ac6`](https://github.com/Effect-TS/effect/commit/9237ac69bc07de5b3b60076a0ad2921c21de7457), [`be0451c`](https://github.com/Effect-TS/effect/commit/be0451c149b6618af79cb839cdf04af2db1efb03), [`5b36494`](https://github.com/Effect-TS/effect/commit/5b364942e9a9003fdb8217324f8a2d8369c969da), [`c716adb`](https://github.com/Effect-TS/effect/commit/c716adb250ebbea1d1048d818ef7fed4f621d186), [`4986391`](https://github.com/Effect-TS/effect/commit/49863919cd8628c962a712fb1df30d2983820933), [`d75140c`](https://github.com/Effect-TS/effect/commit/d75140c7a664ceda43142d999f4ff8dcd36d6dda), [`d1387ae`](https://github.com/Effect-TS/effect/commit/d1387aebd1ff01bbebde26be46d488956e4daef6)]: + - effect@3.9.0 + - @effect/platform@0.67.0 + - @effect/sql@0.15.0 + +## 0.14.1 + +### Patch Changes + +- [#3704](https://github.com/Effect-TS/effect/pull/3704) [`b00f7a0`](https://github.com/Effect-TS/effect/commit/b00f7a0a73b0f6031552ec2535a6f918a0360585) Thanks @wewelll! - accept tls options for ssl configuration of PgClient + +- Updated dependencies [[`88e85db`](https://github.com/Effect-TS/effect/commit/88e85db34bd402526e27a323e950d053fa34d232), [`f40da15`](https://github.com/Effect-TS/effect/commit/f40da15fbeb7c491840b8f409d47de79720891c3), [`8e94585`](https://github.com/Effect-TS/effect/commit/8e94585abe62753bf3af28bfae77926a7c570ac3), [`83887ca`](https://github.com/Effect-TS/effect/commit/83887ca1b1793916913d8550a4db4450cd14a044), [`5266b6c`](https://github.com/Effect-TS/effect/commit/5266b6cd86d76c3886da041c8829bca04b1a3110), [`cdead5c`](https://github.com/Effect-TS/effect/commit/cdead5c9cfd54dc6c4f215d9732f654c4a12e991), [`f40da15`](https://github.com/Effect-TS/effect/commit/f40da15fbeb7c491840b8f409d47de79720891c3), [`766a8af`](https://github.com/Effect-TS/effect/commit/766a8af307b414aca3648d91c4eab7493a5ec862)]: + - effect@3.8.5 + - @effect/platform@0.66.3 + - @effect/sql@0.14.1 + +## 0.14.0 + +### Patch Changes + +- Updated dependencies [[`f100e20`](https://github.com/Effect-TS/effect/commit/f100e2087172d7e4ab8c0d1ee9a5780b9712382a)]: + - @effect/sql@0.14.0 + +## 0.13.4 + +### Patch Changes + +- Updated dependencies []: + - @effect/sql@0.13.4 + +## 0.13.3 + +### Patch Changes + +- Updated dependencies [[`0a68746`](https://github.com/Effect-TS/effect/commit/0a68746c89651c364db2ee8c72dcfe552e1782ea), [`fd83d0e`](https://github.com/Effect-TS/effect/commit/fd83d0e548feff9ea2d53d370a0b626c4a1d940e), [`4509656`](https://github.com/Effect-TS/effect/commit/45096569d50262275ee984f44c456f5c83b62683), [`090e41c`](https://github.com/Effect-TS/effect/commit/090e41c636d720b1c7d89684a739855765ed4382)]: + - @effect/sql@0.13.3 + - @effect/platform@0.66.2 + - effect@3.8.4 + +## 0.13.2 + +### Patch Changes + +- Updated dependencies [[`3812788`](https://github.com/Effect-TS/effect/commit/3812788d79caaab8f559a62fd443018a04ac5647)]: + - @effect/platform@0.66.1 + - @effect/sql@0.13.2 + +## 0.13.1 + +### Patch Changes + +- Updated dependencies [[`d5c8e7e`](https://github.com/Effect-TS/effect/commit/d5c8e7e47373f9fd78637f24e36d6fb61ee35eb4)]: + - @effect/sql@0.13.1 + +## 0.13.0 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.66.0 + - @effect/sql@0.13.0 + +## 0.12.6 + +### Patch Changes + +- Updated dependencies [[`321b201`](https://github.com/Effect-TS/effect/commit/321b201adcb6bbbeb806b3467dd0b4cf063ccda8), [`bb5ec6b`](https://github.com/Effect-TS/effect/commit/bb5ec6b4b6a6f537394596c5a596faf52cb2aef4)]: + - @effect/platform@0.65.5 + - effect@3.8.3 + - @effect/sql@0.12.6 + +## 0.12.5 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.65.4 + - @effect/sql@0.12.5 + +## 0.12.4 + +### Patch Changes + +- Updated dependencies []: + - @effect/sql@0.12.4 + +## 0.12.3 + +### Patch Changes + +- Updated dependencies [[`f0d8ef1`](https://github.com/Effect-TS/effect/commit/f0d8ef1ce97ec2a87b09b3e24150cfeab85d6e2f)]: + - effect@3.8.2 + - @effect/platform@0.65.3 + - @effect/sql@0.12.3 + +## 0.12.2 + +### Patch Changes + +- Updated dependencies [[`10bf621`](https://github.com/Effect-TS/effect/commit/10bf6213f36d8ddb00f058a4609b85220f3d8334), [`ae36fa6`](https://github.com/Effect-TS/effect/commit/ae36fa68f754eeab9a54b6dc0f8b44db513aa2b6)]: + - effect@3.8.1 + - @effect/platform@0.65.2 + - @effect/sql@0.12.2 + +## 0.12.1 + +### Patch Changes + +- Updated dependencies [[`e44c5f2`](https://github.com/Effect-TS/effect/commit/e44c5f228215738fe4e75023c7461bf9521249cb)]: + - @effect/platform@0.65.1 + - @effect/sql@0.12.1 + +## 0.12.0 + +### Patch Changes + +- Updated dependencies [[`fcfa6ee`](https://github.com/Effect-TS/effect/commit/fcfa6ee30ffd07d998bf22799357bf58580a116f), [`bb9931b`](https://github.com/Effect-TS/effect/commit/bb9931b62e249a3b801f2cb9d097aec0c8511af7), [`5798f76`](https://github.com/Effect-TS/effect/commit/5798f7619529de33e5ba06f551806f68fedc19db), [`5f0bfa1`](https://github.com/Effect-TS/effect/commit/5f0bfa17205398d4e4818bfbcf9e1b505b3b1fc5), [`812a4e8`](https://github.com/Effect-TS/effect/commit/812a4e86e2d1aa23b477ef5829aa0e5c07784936), [`6a128f6`](https://github.com/Effect-TS/effect/commit/6a128f63f9b41fec2db70790b3bbb96cb9afa1ab), [`273565e`](https://github.com/Effect-TS/effect/commit/273565e7901639e8d0541930ab715aea9c80fbaa), [`adf7d7a`](https://github.com/Effect-TS/effect/commit/adf7d7a7dfce3a7021e9f3b0d847dc85be89d754), [`569a801`](https://github.com/Effect-TS/effect/commit/569a8017ef0a0bc203e4312867cbdd37b0effbd7), [`aa1fa53`](https://github.com/Effect-TS/effect/commit/aa1fa5301e886b9657c8eb0d38cb87cef92a8305), [`02f6b06`](https://github.com/Effect-TS/effect/commit/02f6b0660e12bee1069532a9cc18d3ab855257be), [`12b893e`](https://github.com/Effect-TS/effect/commit/12b893e63cc6dfada4aca7773b4783940e2edf25), [`bbad27e`](https://github.com/Effect-TS/effect/commit/bbad27ec0a90860593f759405caa877e7f4a655f), [`7041393`](https://github.com/Effect-TS/effect/commit/7041393cff132e96566d3f36da0483a6ff6195e4), [`e0d21a5`](https://github.com/Effect-TS/effect/commit/e0d21a54c8323728fbb75a32f4820a9996257809), [`adf7d7a`](https://github.com/Effect-TS/effect/commit/adf7d7a7dfce3a7021e9f3b0d847dc85be89d754), [`007289a`](https://github.com/Effect-TS/effect/commit/007289a52d5877f8e90e2dacf38171ff9bf603fd), [`42a8f99`](https://github.com/Effect-TS/effect/commit/42a8f99740eefdaf2c4544d2c345313f97547a36), [`eebfd29`](https://github.com/Effect-TS/effect/commit/eebfd29633fd5d38b505c5c0842036f61f05e913), [`040703d`](https://github.com/Effect-TS/effect/commit/040703d0e100cd5511e52d812c15492414262b5e)]: + - effect@3.8.0 + - @effect/platform@0.65.0 + - @effect/sql@0.12.0 + +## 0.11.3 + +### Patch Changes + +- Updated dependencies [[`ccd67df`](https://github.com/Effect-TS/effect/commit/ccd67df6b44ae7075a03759bc7866f6bc9ebb03e)]: + - @effect/sql@0.11.3 + +## 0.11.2 + +### Patch Changes + +- Updated dependencies [[`d8aff79`](https://github.com/Effect-TS/effect/commit/d8aff79d4cbedee33d0552ec43fdced007cae358), [`35a0f81`](https://github.com/Effect-TS/effect/commit/35a0f813141652d696461cd5d19fd146adaf85be), [`d8aff79`](https://github.com/Effect-TS/effect/commit/d8aff79d4cbedee33d0552ec43fdced007cae358), [`8261c5a`](https://github.com/Effect-TS/effect/commit/8261c5ae6fe86872292ec1fc1a58ab9cea2f5f51)]: + - @effect/sql@0.11.2 + - effect@3.7.3 + - @effect/platform@0.64.1 + +## 0.11.1 + +### Patch Changes + +- Updated dependencies []: + - @effect/sql@0.11.1 + +## 0.11.0 + +### Patch Changes + +- Updated dependencies [[`90ac8f6`](https://github.com/Effect-TS/effect/commit/90ac8f6f6053a2e4498f8b0cc56fe12777d02e1a), [`90ac8f6`](https://github.com/Effect-TS/effect/commit/90ac8f6f6053a2e4498f8b0cc56fe12777d02e1a), [`3791e24`](https://github.com/Effect-TS/effect/commit/3791e241636b1dfe924a56f380ebc9a7ff0827a9), [`3791e24`](https://github.com/Effect-TS/effect/commit/3791e241636b1dfe924a56f380ebc9a7ff0827a9)]: + - @effect/platform@0.64.0 + - @effect/sql@0.11.0 + +## 0.10.4 + +### Patch Changes + +- Updated dependencies []: + - @effect/sql@0.10.4 + +## 0.10.3 + +### Patch Changes + +- Updated dependencies [[`4a701c4`](https://github.com/Effect-TS/effect/commit/4a701c406da032563fedae459536c00ae5cfe3c7)]: + - @effect/platform@0.63.3 + - @effect/sql@0.10.3 + +## 0.10.2 + +### Patch Changes + +- Updated dependencies [[`8a601d7`](https://github.com/Effect-TS/effect/commit/8a601d7a1f8ffe52ac9e6d67e9282a1495fe59c9), [`353ba19`](https://github.com/Effect-TS/effect/commit/353ba19f9b2b9e959f0a00d058c6d40a4bc02db7)]: + - effect@3.7.2 + - @effect/platform@0.63.2 + - @effect/sql@0.10.2 + +## 0.10.1 + +### Patch Changes + +- [#3529](https://github.com/Effect-TS/effect/pull/3529) [`0ba81cb`](https://github.com/Effect-TS/effect/commit/0ba81cb61db7041becbb4bd5f80d656bbdfb70b5) Thanks @aniravi24! - Add `onnotice` option to `PgClient`. + +- Updated dependencies [[`79859e7`](https://github.com/Effect-TS/effect/commit/79859e71040d8edf1868b8530b90c650f4321eff), [`f6a469c`](https://github.com/Effect-TS/effect/commit/f6a469c190b9f00eee5ea0cd4d5912a0ef8b46f5), [`dcb9ec0`](https://github.com/Effect-TS/effect/commit/dcb9ec0db443894dd204d87450f779c44b9ad7f1), [`79aa6b1`](https://github.com/Effect-TS/effect/commit/79aa6b136e1f29b36f34e88cb2ff162bff2bb4ed)]: + - effect@3.7.1 + - @effect/platform@0.63.1 + - @effect/sql@0.10.1 + +## 0.10.0 + +### Patch Changes + +- Updated dependencies [[`db89601`](https://github.com/Effect-TS/effect/commit/db89601ee9c1050c4e762b7bd7ec65a6a2799dfe), [`2f456cc`](https://github.com/Effect-TS/effect/commit/2f456cce5012b9fcb6b4e039190d527813b75b92), [`8745e41`](https://github.com/Effect-TS/effect/commit/8745e41ed96e3765dc6048efc2a9afbe05c8a1e9), [`e557838`](https://github.com/Effect-TS/effect/commit/e55783886b046d3c5f33447f455f9ccf2fa75922), [`d6e7e40`](https://github.com/Effect-TS/effect/commit/d6e7e40b1e2ad0c59aa02f07344d28601b14ebdc), [`8356321`](https://github.com/Effect-TS/effect/commit/8356321598da04bd77c1001f45a4e447bec5591d), [`192f2eb`](https://github.com/Effect-TS/effect/commit/192f2ebb2c4ddbf4bfd8baedd32140b2376868f4), [`718cb70`](https://github.com/Effect-TS/effect/commit/718cb70038629a6d58d02e407760e341f7c94474), [`e9d0310`](https://github.com/Effect-TS/effect/commit/e9d03107acbf204d9304f3e8aea0816b7d3c7dfb), [`6bf28f7`](https://github.com/Effect-TS/effect/commit/6bf28f7e3b1e5e0608ff567205fea0581d11666f)]: + - effect@3.7.0 + - @effect/platform@0.63.0 + - @effect/sql@0.10.0 + +## 0.9.7 + +### Patch Changes + +- Updated dependencies [[`e809286`](https://github.com/Effect-TS/effect/commit/e8092865900608c4df7a6b7991b1c13cc1e4ca2d)]: + - effect@3.6.8 + - @effect/platform@0.62.5 + - @effect/sql@0.9.7 + +## 0.9.6 + +### Patch Changes + +- Updated dependencies [[`e7a65e3`](https://github.com/Effect-TS/effect/commit/e7a65e3c6a08636bbfce3d3af3098bf28474364d), [`50ec889`](https://github.com/Effect-TS/effect/commit/50ec8897a49b7d1fe84f63107f89d543c52f3dfc)]: + - @effect/platform@0.62.4 + - effect@3.6.7 + - @effect/sql@0.9.6 + +## 0.9.5 + +### Patch Changes + +- Updated dependencies [[`f960bf4`](https://github.com/Effect-TS/effect/commit/f960bf45239e9badac6e0ad3a602f4174cd7bbdf), [`46a575f`](https://github.com/Effect-TS/effect/commit/46a575f48a05457b782fb21f7827d338c9b59320)]: + - effect@3.6.6 + - @effect/platform@0.62.3 + - @effect/sql@0.9.5 + +## 0.9.4 + +### Patch Changes + +- Updated dependencies [[`413994c`](https://github.com/Effect-TS/effect/commit/413994c9792f16d9d57cca3ae6eb254bf93bd261), [`14a47a8`](https://github.com/Effect-TS/effect/commit/14a47a8c1f3cff2186b8fe7a919a1d773888fb5b), [`35be739`](https://github.com/Effect-TS/effect/commit/35be739a413e32ed251f775714af2f87355e8664), [`f8326cc`](https://github.com/Effect-TS/effect/commit/f8326cc1095630a3fbee3f25d6b4e74edb905903), [`0c09841`](https://github.com/Effect-TS/effect/commit/0c0984173be3d58f050b300a1a8aa89d76ba49ae), [`8dd3959`](https://github.com/Effect-TS/effect/commit/8dd3959e967ca2b38ba601d94a80f1c50e9445e0), [`2cb6ebb`](https://github.com/Effect-TS/effect/commit/2cb6ebbf782b79643befa061c6adcf0366a7b8b3), [`5e9f51e`](https://github.com/Effect-TS/effect/commit/5e9f51e4a1169018d7f59a0db444c783cc1d5794), [`83a108a`](https://github.com/Effect-TS/effect/commit/83a108a254341721d20a82633b1e1d406d2368a3), [`f2c8dbb`](https://github.com/Effect-TS/effect/commit/f2c8dbb77e196c9a36cb3bf2ae3b82ce68e9874d), [`5e9f51e`](https://github.com/Effect-TS/effect/commit/5e9f51e4a1169018d7f59a0db444c783cc1d5794)]: + - @effect/platform@0.62.2 + - effect@3.6.5 + - @effect/sql@0.9.4 + +## 0.9.3 + +### Patch Changes + +- Updated dependencies [[`c3446d3`](https://github.com/Effect-TS/effect/commit/c3446d3e57b0cbfe9341d6f2aebf5f5d6fefefe3), [`9efe0e5`](https://github.com/Effect-TS/effect/commit/9efe0e5b57ac557399be620822c21cc6e9add285)]: + - @effect/sql@0.9.3 + - @effect/platform@0.62.1 + +## 0.9.2 + +### Patch Changes + +- Updated dependencies [[`cfcfbdf`](https://github.com/Effect-TS/effect/commit/cfcfbdfe586b011a5edc28083fd5391edeee0023)]: + - @effect/sql@0.9.2 + +## 0.9.1 + +### Patch Changes + +- Updated dependencies [[`e9da539`](https://github.com/Effect-TS/effect/commit/e9da5396bba99b2ddc20c97c7955154e6da4cab5), [`4fabf75`](https://github.com/Effect-TS/effect/commit/4fabf75b44ea98b1773059bd589167d5d8f64f06)]: + - @effect/sql@0.9.1 + +## 0.9.0 + +### Minor Changes + +- [#3457](https://github.com/Effect-TS/effect/pull/3457) [`a07990d`](https://github.com/Effect-TS/effect/commit/a07990de977fb60ab4af1e8f3a2250454dedbb34) Thanks @IMax153! - Add support for executing raw SQL queries with the underlying SQL client. + + This is primarily useful when the SQL client returns special results for certain + query types. + + For example, because MySQL does not support the `RETURNING` clause, the `mysql2` + client will return a [`ResultSetHeader`](https://sidorares.github.io/node-mysql2/docs/documentation/typescript-examples#resultsetheader) + for `INSERT`, `UPDATE`, `DELETE`, and `TRUNCATE` operations. + + To gain access to the raw results of a query, you can use the `.raw` property on + the `Statement`: + + ```ts + import * as Effect from "effect/Effect" + import * as SqlClient from "effect/unstable/sql/SqlClient" + import * as MysqlClient from "effect/unstable/sql/MysqlClient" + + const DatabaseLive = MysqlClient.layer({ + database: Config.succeed("database"), + username: Config.succeed("root"), + password: Config.succeed(Redacted.make("password")) + }) + + const program = Effect.gen(function* () { + const sql = yield* SqlClient.SqlClient + + const result = yield* sql`INSERT INTO usernames VALUES ("Bob")`.raw + + console.log(result) + /** + * ResultSetHeader { + * fieldCount: 0, + * affectedRows: 1, + * insertId: 0, + * info: '', + * serverStatus: 2, + * warningStatus: 0, + * changedRows: 0 + * } + */ + }) + + program.pipe(Effect.provide(DatabaseLive), Effect.runPromise) + ``` + +### Patch Changes + +- Updated dependencies [[`8295281`](https://github.com/Effect-TS/effect/commit/8295281ae9bd7441e680402540bf3c8682ec417b), [`c940df6`](https://github.com/Effect-TS/effect/commit/c940df63800bf3c4396d91cf28ec34938642fd2c), [`00b6c6d`](https://github.com/Effect-TS/effect/commit/00b6c6d4001f5de728b7d990a1b14560b4961a63), [`a07990d`](https://github.com/Effect-TS/effect/commit/a07990de977fb60ab4af1e8f3a2250454dedbb34), [`f8d95a6`](https://github.com/Effect-TS/effect/commit/f8d95a61ad0762147933c5c32bb6d7237e18eef4)]: + - effect@3.6.4 + - @effect/sql@0.9.0 + - @effect/platform@0.62.0 + +## 0.8.7 + +### Patch Changes + +- Updated dependencies [[`04adcac`](https://github.com/Effect-TS/effect/commit/04adcace913e6fc483df266874a68005e9e04ccf)]: + - effect@3.6.3 + - @effect/platform@0.61.8 + - @effect/sql@0.8.7 + +## 0.8.6 + +### Patch Changes + +- Updated dependencies [[`17245a4`](https://github.com/Effect-TS/effect/commit/17245a4e783c19dee51529600b3b40f164fa59bc), [`630d40e`](https://github.com/Effect-TS/effect/commit/630d40eaa7eb4d2f8b6705b16d4f426bc28a7d09), [`630d40e`](https://github.com/Effect-TS/effect/commit/630d40eaa7eb4d2f8b6705b16d4f426bc28a7d09)]: + - @effect/platform@0.61.7 + - @effect/sql@0.8.6 + +## 0.8.5 + +### Patch Changes + +- Updated dependencies [[`d829b57`](https://github.com/Effect-TS/effect/commit/d829b576357f2e3b203ab7e107a1492de903a106), [`fd4b2f6`](https://github.com/Effect-TS/effect/commit/fd4b2f6516b325740dde615f1cf0229edf13ca0c)]: + - @effect/platform@0.61.6 + - effect@3.6.2 + - @effect/sql@0.8.5 + +## 0.8.4 + +### Patch Changes + +- Updated dependencies [[`056b710`](https://github.com/Effect-TS/effect/commit/056b7108978e70612176c23991916f678d947f38)]: + - @effect/platform@0.61.5 + - @effect/sql@0.8.4 + +## 0.8.3 + +### Patch Changes + +- Updated dependencies [[`e7cb109`](https://github.com/Effect-TS/effect/commit/e7cb109d0754207024a64d55b6bd2a674dd8ed7d)]: + - @effect/platform@0.61.4 + - @effect/sql@0.8.3 + +## 0.8.2 + +### Patch Changes + +- [#3398](https://github.com/Effect-TS/effect/pull/3398) [`45dbb9f`](https://github.com/Effect-TS/effect/commit/45dbb9ffeaf93d9e4df99d0cd4920e41ba9a3978) Thanks @sukovanej! - Add `listen` / `notify` to `PgClient`. + +- Updated dependencies [[`510a34d`](https://github.com/Effect-TS/effect/commit/510a34d4cc5d2f51347a53847f6c7db84d2b17c6), [`fb9f786`](https://github.com/Effect-TS/effect/commit/fb9f7867f0c895e63f9ef23e8d0941248c42179d), [`45dbb9f`](https://github.com/Effect-TS/effect/commit/45dbb9ffeaf93d9e4df99d0cd4920e41ba9a3978)]: + - effect@3.6.1 + - @effect/platform@0.61.3 + - @effect/sql@0.8.2 + +## 0.8.1 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.61.2 + - @effect/sql@0.8.1 + +## 0.8.0 + +### Patch Changes + +- Updated dependencies [[`42d0706`](https://github.com/Effect-TS/effect/commit/42d07067e9823ceb8977eff9672d9a290941dad5), [`11223bf`](https://github.com/Effect-TS/effect/commit/11223bf9cbf5b822e0bf9a9fb2b35b2ad88af692)]: + - @effect/sql@0.8.0 + - @effect/platform@0.61.1 + +## 0.7.0 + +### Patch Changes + +- Updated dependencies [[`1e0fe80`](https://github.com/Effect-TS/effect/commit/1e0fe802b36c257971296617473ce0abe730e8dc), [`8135294`](https://github.com/Effect-TS/effect/commit/8135294b591ea94fde7e6f94a504608f0e630520), [`cd255a4`](https://github.com/Effect-TS/effect/commit/cd255a48872d8fb924cf713ef73f0883a9cc6987), [`3845646`](https://github.com/Effect-TS/effect/commit/3845646828e98f3c7cda1217f6cfe5f642ac0603), [`2d09078`](https://github.com/Effect-TS/effect/commit/2d09078c5948b37fc2f79ef858fe4ca3e4814085), [`4bce5a0`](https://github.com/Effect-TS/effect/commit/4bce5a0274203550ccf117d830721891b0a3d182), [`4ddbff0`](https://github.com/Effect-TS/effect/commit/4ddbff0bb4e3ffddfeb509c59835b83245fb975e), [`e74cc38`](https://github.com/Effect-TS/effect/commit/e74cc38cb420a320c4d7ef98180f19d452a8b316), [`bb069b4`](https://github.com/Effect-TS/effect/commit/bb069b49ef291c532a02c1e8e74271f6d1bb32ec), [`cd255a4`](https://github.com/Effect-TS/effect/commit/cd255a48872d8fb924cf713ef73f0883a9cc6987), [`7d02174`](https://github.com/Effect-TS/effect/commit/7d02174af3bcbf054e5cdddb821c91d0f47e8285)]: + - effect@3.6.0 + - @effect/platform@0.61.0 + - @effect/sql@0.7.0 + +## 0.6.3 + +### Patch Changes + +- [#3365](https://github.com/Effect-TS/effect/pull/3365) [`f0d1824`](https://github.com/Effect-TS/effect/commit/f0d1824b175d7be14b8a5f701f5972cbe3ed6999) Thanks @sukovanej! - Add `socket` option to `PgClient`. + +- [#3364](https://github.com/Effect-TS/effect/pull/3364) [`16b2202`](https://github.com/Effect-TS/effect/commit/16b2202f9a42e622251972e317cf574ef655047a) Thanks @sukovanej! - Add `applicationName` name option configuring `connection.application_name`. + +- Updated dependencies [[`6359644`](https://github.com/Effect-TS/effect/commit/635964446323cf55d4060559337e710e4a24496e), [`7f41e42`](https://github.com/Effect-TS/effect/commit/7f41e428830bf3043b8be0d28dcd235d5747c942), [`f566fd1`](https://github.com/Effect-TS/effect/commit/f566fd1d7eea531a0d981dd24037f14a603a1273)]: + - effect@3.5.9 + - @effect/platform@0.60.3 + - @effect/sql@0.6.3 + +## 0.6.2 + +### Patch Changes + +- Updated dependencies [[`eb4d014`](https://github.com/Effect-TS/effect/commit/eb4d014c559e1b4c95b3fb9295fe77593c17ed7a), [`1ba640c`](https://github.com/Effect-TS/effect/commit/1ba640c702f187a866023bf043c26e25cce941ef), [`c8c71bd`](https://github.com/Effect-TS/effect/commit/c8c71bd20eb87d23133dac6156b83bb08941597c), [`a26ce58`](https://github.com/Effect-TS/effect/commit/a26ce581ca7d407e1e81439b58c8045b3fa65231), [`fc20f73`](https://github.com/Effect-TS/effect/commit/fc20f73c69e577981cb64714de2adc97e1004dae)]: + - @effect/platform@0.60.2 + - effect@3.5.8 + - @effect/sql@0.6.2 + +## 0.6.1 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.60.1 + - @effect/sql@0.6.1 + +## 0.6.0 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.60.0 + - @effect/sql@0.6.0 + +## 0.5.3 + +### Patch Changes + +- [#3310](https://github.com/Effect-TS/effect/pull/3310) [`99bddcf`](https://github.com/Effect-TS/effect/commit/99bddcfb3d6eab4d489d055404e26ad81afe52fc) Thanks @fubhy! - Added additional pure annotations to improve tree-shakeability + +- Updated dependencies [[`3afcc93`](https://github.com/Effect-TS/effect/commit/3afcc93413a3d910beb69e4ce9ae120e4adaffd5), [`99bddcf`](https://github.com/Effect-TS/effect/commit/99bddcfb3d6eab4d489d055404e26ad81afe52fc)]: + - effect@3.5.7 + - @effect/platform@0.59.3 + - @effect/sql@0.5.3 + +## 0.5.2 + +### Patch Changes + +- Updated dependencies [[`cc327a1`](https://github.com/Effect-TS/effect/commit/cc327a1bccd22a4ee27ec7e58b53205e93b23e2c), [`4bfe4fb`](https://github.com/Effect-TS/effect/commit/4bfe4fb5c82f597c9beea9baa92e772593598b60), [`2b14d18`](https://github.com/Effect-TS/effect/commit/2b14d181462cad8359da4fa6bc6dfda0f742c398)]: + - effect@3.5.6 + - @effect/platform@0.59.2 + - @effect/sql@0.5.2 + +## 0.5.1 + +### Patch Changes + +- Updated dependencies [[`a9d7800`](https://github.com/Effect-TS/effect/commit/a9d7800f6a253192b653d77778b0674f39b1ca39), [`fcecff7`](https://github.com/Effect-TS/effect/commit/fcecff7f7e12b295a252f124861b801c73072151), [`adbf753`](https://github.com/Effect-TS/effect/commit/adbf75340a9db15dc5cadc66e911a8978a195a65), [`adbf753`](https://github.com/Effect-TS/effect/commit/adbf75340a9db15dc5cadc66e911a8978a195a65)]: + - effect@3.5.5 + - @effect/platform@0.59.1 + - @effect/sql@0.5.1 + +## 0.5.0 + +### Minor Changes + +- [#3260](https://github.com/Effect-TS/effect/pull/3260) [`53c0db0`](https://github.com/Effect-TS/effect/commit/53c0db06872d5b5edea2a706e83249908385325c) Thanks @tim-smart! - replace /platform RefailError with use of the "cause" property + +### Patch Changes + +- Updated dependencies [[`53c0db0`](https://github.com/Effect-TS/effect/commit/53c0db06872d5b5edea2a706e83249908385325c), [`ed0dde4`](https://github.com/Effect-TS/effect/commit/ed0dde4888e6f1a97ad5bba06b755d26a6a1c52e), [`ada68b3`](https://github.com/Effect-TS/effect/commit/ada68b3e61c67907c2a281c024c84d818186ca4c), [`ca775ce`](https://github.com/Effect-TS/effect/commit/ca775cec53baebc1a43d9b8852a3ac6726178498), [`5be9cc0`](https://github.com/Effect-TS/effect/commit/5be9cc044025a9541b9b7acefa2d3fc05fa1301b), [`203658f`](https://github.com/Effect-TS/effect/commit/203658f8001c132b25764ab70344b171683b554c), [`eb1c4d4`](https://github.com/Effect-TS/effect/commit/eb1c4d44e54b9d8d201a366d1ff94face2a6dcd3)]: + - @effect/platform@0.59.0 + - @effect/sql@0.5.0 + - effect@3.5.4 + +## 0.4.27 + +### Patch Changes + +- Updated dependencies [[`edb0da3`](https://github.com/Effect-TS/effect/commit/edb0da383746d760f35d8582f5fb0cc0eeca9217), [`a1db40a`](https://github.com/Effect-TS/effect/commit/a1db40a650ab842e778654f0d88e80f2ef4fd6f3), [`c8d3fb0`](https://github.com/Effect-TS/effect/commit/c8d3fb0fe23585f6efb724af51fbab3ba1ad6e83), [`dabd028`](https://github.com/Effect-TS/effect/commit/dabd028decf9b7983ca16ebe0f48c05c11a84b68), [`786b2ab`](https://github.com/Effect-TS/effect/commit/786b2ab29d525c877bb84035dac9e2d6499339d1), [`fc57354`](https://github.com/Effect-TS/effect/commit/fc573547d41667016fce05eaee75960fcc6dce4d)]: + - effect@3.5.3 + - @effect/platform@0.58.27 + - @effect/sql@0.4.27 + +## 0.4.26 + +### Patch Changes + +- Updated dependencies [[`639208e`](https://github.com/Effect-TS/effect/commit/639208eeb8a44622994f832bc2d45d06ab636bc8), [`6684b4c`](https://github.com/Effect-TS/effect/commit/6684b4c27d77a7fcc7af2e261a450edf971b62b5), [`6684b4c`](https://github.com/Effect-TS/effect/commit/6684b4c27d77a7fcc7af2e261a450edf971b62b5), [`6684b4c`](https://github.com/Effect-TS/effect/commit/6684b4c27d77a7fcc7af2e261a450edf971b62b5)]: + - effect@3.5.2 + - @effect/platform@0.58.26 + - @effect/sql@0.4.26 + +## 0.4.25 + +### Patch Changes + +- Updated dependencies [[`0623fca`](https://github.com/Effect-TS/effect/commit/0623fca41679b0e3c5a10dd0f8985f91670bd721)]: + - @effect/platform@0.58.25 + - @effect/sql@0.4.25 + +## 0.4.24 + +### Patch Changes + +- Updated dependencies [[`55fdd76`](https://github.com/Effect-TS/effect/commit/55fdd761ee95afd73b6a892c13fee92b36c02837)]: + - effect@3.5.1 + - @effect/platform@0.58.24 + - @effect/sql@0.4.24 + +## 0.4.23 + +### Patch Changes + +- Updated dependencies [[`a1f5b83`](https://github.com/Effect-TS/effect/commit/a1f5b831a1bc7535988b370d68d0b3eb1123e0ce), [`a1f5b83`](https://github.com/Effect-TS/effect/commit/a1f5b831a1bc7535988b370d68d0b3eb1123e0ce), [`a1f5b83`](https://github.com/Effect-TS/effect/commit/a1f5b831a1bc7535988b370d68d0b3eb1123e0ce), [`60bc3d0`](https://github.com/Effect-TS/effect/commit/60bc3d0867b13e48b24dc22604b4dd2e7b2c1ca4), [`5ab348f`](https://github.com/Effect-TS/effect/commit/5ab348f265db3d283aa091ddca6d2d49137c16f2), [`60bc3d0`](https://github.com/Effect-TS/effect/commit/60bc3d0867b13e48b24dc22604b4dd2e7b2c1ca4), [`3e04bf8`](https://github.com/Effect-TS/effect/commit/3e04bf8a7127e956cadb7684a8f4c661df57663b), [`e7fc45f`](https://github.com/Effect-TS/effect/commit/e7fc45f0c7002aafdaec7878149ac064cd104ea3), [`a1f5b83`](https://github.com/Effect-TS/effect/commit/a1f5b831a1bc7535988b370d68d0b3eb1123e0ce), [`4626de5`](https://github.com/Effect-TS/effect/commit/4626de59c25b384216faa0be87bf0b8cd36357d0), [`f01e7db`](https://github.com/Effect-TS/effect/commit/f01e7db317827255d7901f523f2e28b43298e8df), [`60bc3d0`](https://github.com/Effect-TS/effect/commit/60bc3d0867b13e48b24dc22604b4dd2e7b2c1ca4), [`79d2d91`](https://github.com/Effect-TS/effect/commit/79d2d91464d95dde0e9444d43e7a7f309f05d6e6), [`ac71f37`](https://github.com/Effect-TS/effect/commit/ac71f378f2413e5aa91c95f649ffe898d6a26114), [`8432360`](https://github.com/Effect-TS/effect/commit/8432360ce68614a419bb328083a4109d0fc8aa93), [`e4bf1bf`](https://github.com/Effect-TS/effect/commit/e4bf1bf2b4a970eacd77c9b77b5ea8c68bc84498), [`13cb861`](https://github.com/Effect-TS/effect/commit/13cb861a5eded15c55c6cdcf6a8acde8320367a6), [`79d2d91`](https://github.com/Effect-TS/effect/commit/79d2d91464d95dde0e9444d43e7a7f309f05d6e6), [`e7fc45f`](https://github.com/Effect-TS/effect/commit/e7fc45f0c7002aafdaec7878149ac064cd104ea3), [`9f66825`](https://github.com/Effect-TS/effect/commit/9f66825f1fce0fe8d10420c285f7dc4c71e8af8d)]: + - effect@3.5.0 + - @effect/platform@0.58.23 + - @effect/sql@0.4.23 + +## 0.4.22 + +### Patch Changes + +- Updated dependencies [[`7af137c`](https://github.com/Effect-TS/effect/commit/7af137c9433f6e74959b3887561ec1e6f12e10ee), [`ee4b3dc`](https://github.com/Effect-TS/effect/commit/ee4b3dc5f68d19dc3ae1c2d12901c5b8ffbebabb), [`366f2ee`](https://github.com/Effect-TS/effect/commit/366f2ee3fb6f712a44e8f84fc188612e5ecc016d), [`366f2ee`](https://github.com/Effect-TS/effect/commit/366f2ee3fb6f712a44e8f84fc188612e5ecc016d), [`097d25c`](https://github.com/Effect-TS/effect/commit/097d25cb5d13c049e01789651be56b09620186ef)]: + - effect@3.4.9 + - @effect/platform@0.58.22 + - @effect/sql@0.4.22 + +## 0.4.21 + +### Patch Changes + +- Updated dependencies [[`a435e0f`](https://github.com/Effect-TS/effect/commit/a435e0fc5378b33a49bcec92ee235df6f16a2419), [`b5554db`](https://github.com/Effect-TS/effect/commit/b5554db36c4dd6f64fa5e6a62a29b2759c54217a), [`a9c4fb3`](https://github.com/Effect-TS/effect/commit/a9c4fb3bf3c6e92cd1c142b0605fddf7eb3c697c)]: + - effect@3.4.8 + - @effect/platform@0.58.21 + - @effect/sql@0.4.21 + +## 0.4.20 + +### Patch Changes + +- Updated dependencies [[`a5737d6`](https://github.com/Effect-TS/effect/commit/a5737d6db2b921605c332eabbc5402ee3d17357b)]: + - effect@3.4.7 + - @effect/platform@0.58.20 + - @effect/sql@0.4.20 + +## 0.4.19 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.58.19 + - @effect/sql@0.4.19 + +## 0.4.18 + +### Patch Changes + +- Updated dependencies [[`7f8900a`](https://github.com/Effect-TS/effect/commit/7f8900a1de9addeb0d371103a2c5c2aa3e4ff95e)]: + - @effect/platform@0.58.18 + - @effect/sql@0.4.18 + +## 0.4.17 + +### Patch Changes + +- Updated dependencies [[`5c0ceb0`](https://github.com/Effect-TS/effect/commit/5c0ceb00826cce9e50bf9d41d83e191d5352c030), [`5c0ceb0`](https://github.com/Effect-TS/effect/commit/5c0ceb00826cce9e50bf9d41d83e191d5352c030), [`33735b1`](https://github.com/Effect-TS/effect/commit/33735b16b41bd26929d8f4754c190925db6323b7), [`5c0ceb0`](https://github.com/Effect-TS/effect/commit/5c0ceb00826cce9e50bf9d41d83e191d5352c030), [`139d4b3`](https://github.com/Effect-TS/effect/commit/139d4b39fb3bff2eeaa7c0c809c581da42425a83)]: + - effect@3.4.6 + - @effect/platform@0.58.17 + - @effect/sql@0.4.17 + +## 0.4.16 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.58.16 + - @effect/sql@0.4.16 + +## 0.4.15 + +### Patch Changes + +- Updated dependencies [[`baa90df`](https://github.com/Effect-TS/effect/commit/baa90df9663f5f37d7b6814dad25142d53dbc720)]: + - @effect/platform@0.58.15 + - @effect/sql@0.4.15 + +## 0.4.14 + +### Patch Changes + +- Updated dependencies [[`52a87c7`](https://github.com/Effect-TS/effect/commit/52a87c7a0b9536398deaf8ec507e53a82c607219), [`6d2280e`](https://github.com/Effect-TS/effect/commit/6d2280e9497c95cb0e965ca462c825345074eedf)]: + - @effect/platform@0.58.14 + - @effect/sql@0.4.14 + +## 0.4.13 + +### Patch Changes + +- Updated dependencies [[`a047af9`](https://github.com/Effect-TS/effect/commit/a047af99447dfffc729e9c8ef0ca143537927e91), [`dbd53ea`](https://github.com/Effect-TS/effect/commit/dbd53ea363c71a24449cb068251054c3a1acf864)]: + - effect@3.4.5 + - @effect/platform@0.58.13 + - @effect/sql@0.4.13 + +## 0.4.12 + +### Patch Changes + +- Updated dependencies [[`74e0ad2`](https://github.com/Effect-TS/effect/commit/74e0ad23b4c36f41b7fd10856b20f8b701bc4044), [`74e0ad2`](https://github.com/Effect-TS/effect/commit/74e0ad23b4c36f41b7fd10856b20f8b701bc4044), [`72638e3`](https://github.com/Effect-TS/effect/commit/72638e3d99f0e93a24febf6c225256ce92d4a20b), [`d7dde2b`](https://github.com/Effect-TS/effect/commit/d7dde2b4af08b37af859d4c327c1f5c6f00cf9d9), [`9b2fc3b`](https://github.com/Effect-TS/effect/commit/9b2fc3b9dfd304a2bd0508ef2313cfc54357be0c)]: + - @effect/platform@0.58.12 + - effect@3.4.4 + - @effect/sql@0.4.12 + +## 0.4.11 + +### Patch Changes + +- Updated dependencies [[`a5b95b5`](https://github.com/Effect-TS/effect/commit/a5b95b548284e4798654ae7ce6883fa49108f0ea), [`5e29579`](https://github.com/Effect-TS/effect/commit/5e29579187cb8420ea4930b3999fec984f8999f4)]: + - @effect/platform@0.58.11 + - @effect/sql@0.4.11 + +## 0.4.10 + +### Patch Changes + +- [#3079](https://github.com/Effect-TS/effect/pull/3079) [`bbdd365`](https://github.com/Effect-TS/effect/commit/bbdd36567706c94cdec45bacea825941c347b6cd) Thanks @tim-smart! - update dependencies + +- [#3079](https://github.com/Effect-TS/effect/pull/3079) [`bbdd365`](https://github.com/Effect-TS/effect/commit/bbdd36567706c94cdec45bacea825941c347b6cd) Thanks @tim-smart! - update to typescript 5.5 + +- Updated dependencies [[`a48ee84`](https://github.com/Effect-TS/effect/commit/a48ee845ac21bbde9baf938af9e97a98322211c9), [`c342739`](https://github.com/Effect-TS/effect/commit/c3427396226e1ad7b95b40595a23f9bdff3e3365), [`8898e5e`](https://github.com/Effect-TS/effect/commit/8898e5e238622f6337583d91ee23609c1f5ccdf7), [`a48ee84`](https://github.com/Effect-TS/effect/commit/a48ee845ac21bbde9baf938af9e97a98322211c9), [`a48ee84`](https://github.com/Effect-TS/effect/commit/a48ee845ac21bbde9baf938af9e97a98322211c9), [`ff78636`](https://github.com/Effect-TS/effect/commit/ff786367c522975f40f0f179a0ecdfcfab7ecbdb), [`c86bd4e`](https://github.com/Effect-TS/effect/commit/c86bd4e134c23146c216f9ff97e03781d55991b6), [`bbdd365`](https://github.com/Effect-TS/effect/commit/bbdd36567706c94cdec45bacea825941c347b6cd), [`ab3180f`](https://github.com/Effect-TS/effect/commit/ab3180f827041d0ea3b2d72254a1a8683e99e056), [`bbdd365`](https://github.com/Effect-TS/effect/commit/bbdd36567706c94cdec45bacea825941c347b6cd)]: + - @effect/platform@0.58.10 + - effect@3.4.3 + - @effect/sql@0.4.10 + +## 0.4.9 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.58.9 + - @effect/sql@0.4.9 + +## 0.4.8 + +### Patch Changes + +- Updated dependencies [[`3da1497`](https://github.com/Effect-TS/effect/commit/3da1497b5c9cc886d300258bc928fd68a4fefe6f)]: + - effect@3.4.2 + - @effect/platform@0.58.8 + - @effect/sql@0.4.8 + +## 0.4.7 + +### Patch Changes + +- Updated dependencies [[`027004a`](https://github.com/Effect-TS/effect/commit/027004a897f654791e75faa28eefb50dd0244b6e)]: + - @effect/platform@0.58.7 + - @effect/sql@0.4.7 + +## 0.4.6 + +### Patch Changes + +- Updated dependencies [[`66a1910`](https://github.com/Effect-TS/effect/commit/66a19109ff90c4252123b8809b8c8a74681dba6a), [`2e8e252`](https://github.com/Effect-TS/effect/commit/2e8e2520cac712f0eb644553bd476429ebd674e4)]: + - effect@3.4.1 + - @effect/platform@0.58.6 + - @effect/sql@0.4.6 + +## 0.4.5 + +### Patch Changes + +- Updated dependencies [[`37a07a2`](https://github.com/Effect-TS/effect/commit/37a07a2d8d1ce09ab965c0ada84a3fae9a6aba05)]: + - @effect/platform@0.58.5 + - @effect/sql@0.4.5 + +## 0.4.4 + +### Patch Changes + +- Updated dependencies [[`b77fb0a`](https://github.com/Effect-TS/effect/commit/b77fb0a811ec1ad0e794917077c9a90824515db8)]: + - @effect/platform@0.58.4 + - @effect/sql@0.4.4 + +## 0.4.3 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.58.3 + - @effect/sql@0.4.3 + +## 0.4.2 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.58.2 + - @effect/sql@0.4.2 + +## 0.4.1 + +### Patch Changes + +- Updated dependencies [[`5a248aa`](https://github.com/Effect-TS/effect/commit/5a248aa5ab2db3f7131ebc79bb9871a76de57973)]: + - @effect/platform@0.58.1 + - @effect/sql@0.4.1 + +## 0.4.0 + +### Minor Changes + +- [#3035](https://github.com/Effect-TS/effect/pull/3035) [`d33d8b0`](https://github.com/Effect-TS/effect/commit/d33d8b050b8e3c87dcde9587083e6c1cf733f72b) Thanks @tim-smart! - restructure sql modules to have flat imports + +### Patch Changes + +- Updated dependencies [[`c0ce180`](https://github.com/Effect-TS/effect/commit/c0ce180861ad0938053c0e6145e813fa6404df3b), [`d33d8b0`](https://github.com/Effect-TS/effect/commit/d33d8b050b8e3c87dcde9587083e6c1cf733f72b), [`63dd0c3`](https://github.com/Effect-TS/effect/commit/63dd0c3af45876c1caad7d03356c74daf551c628), [`61707b6`](https://github.com/Effect-TS/effect/commit/61707b6ffc7397c2ba0dce22512b44955724f60f), [`9c1b5b3`](https://github.com/Effect-TS/effect/commit/9c1b5b39e6c19604ce834f072a114ad392c50a06), [`a35faf8`](https://github.com/Effect-TS/effect/commit/a35faf8d116f94899bfc03feab33b004c8ddfdf7), [`ff73c0c`](https://github.com/Effect-TS/effect/commit/ff73c0cacd66132bfad2e5211b3eae347729c667), [`984d516`](https://github.com/Effect-TS/effect/commit/984d516ccd9412dc41188f6a46b748dd20dd5848), [`8c3b8a2`](https://github.com/Effect-TS/effect/commit/8c3b8a2ce208eab753b6206a51605a424f104e98), [`017e2f9`](https://github.com/Effect-TS/effect/commit/017e2f9b371ce24ea4945e5d7390c934ad3c39cf), [`91bf8a2`](https://github.com/Effect-TS/effect/commit/91bf8a2e9d1959393b3cf7366cc1d584d3e666b7), [`c6a4a26`](https://github.com/Effect-TS/effect/commit/c6a4a266606575fd2c7165940c4072ad4c57d01f)]: + - effect@3.4.0 + - @effect/sql@0.4.0 + - @effect/platform@0.58.0 + +## 0.3.19 + +### Patch Changes + +- Updated dependencies [[`3ba7ea1`](https://github.com/Effect-TS/effect/commit/3ba7ea1c3c2923e85bf2f17e41176f8f8796d203)]: + - @effect/platform@0.57.8 + - @effect/sql@0.3.18 + +## 0.3.18 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.57.7 + - @effect/sql@0.3.17 + +## 0.3.17 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.57.6 + - @effect/sql@0.3.16 + +## 0.3.16 + +### Patch Changes + +- Updated dependencies [[`b8ea6aa`](https://github.com/Effect-TS/effect/commit/b8ea6aa479006358042b4256ee0a1c5cfbe57acb)]: + - @effect/platform@0.57.5 + - @effect/sql@0.3.15 + +## 0.3.15 + +### Patch Changes + +- Updated dependencies [[`6c89408`](https://github.com/Effect-TS/effect/commit/6c89408cd7b9204ec4c5828a46cd5312d8afb5e7)]: + - effect@3.3.5 + - @effect/platform@0.57.4 + - @effect/sql@0.3.14 + +## 0.3.14 + +### Patch Changes + +- Updated dependencies [[`a67b8fe`](https://github.com/Effect-TS/effect/commit/a67b8fe2ace08419424811b5f0d9a5378eaea352)]: + - effect@3.3.4 + - @effect/platform@0.57.3 + - @effect/sql@0.3.13 + +## 0.3.13 + +### Patch Changes + +- Updated dependencies [[`06ede85`](https://github.com/Effect-TS/effect/commit/06ede85d6e84710e6622463be95ff3927fb30dad), [`7204ca5`](https://github.com/Effect-TS/effect/commit/7204ca5761c2b1d27999a624db23aa10b6e0504d)]: + - effect@3.3.3 + - @effect/platform@0.57.2 + - @effect/sql@0.3.12 + +## 0.3.12 + +### Patch Changes + +- Updated dependencies [[`07e12ec`](https://github.com/Effect-TS/effect/commit/07e12ecdb0e20b9763bd9e9058e567a7c8862efc), [`3572646`](https://github.com/Effect-TS/effect/commit/3572646d5e0804f85bc7f64633fb95722533f9dd), [`1aed347`](https://github.com/Effect-TS/effect/commit/1aed347a125ed3847ec90863424810d6759cbc85), [`df4bf4b`](https://github.com/Effect-TS/effect/commit/df4bf4b62e7b316c6647da0271fc5544a84e7ba2), [`f085f92`](https://github.com/Effect-TS/effect/commit/f085f92dfa204afb41823ffc27d437225137643d)]: + - @effect/platform@0.57.1 + - effect@3.3.2 + - @effect/sql@0.3.11 + +## 0.3.11 + +### Patch Changes + +- Updated dependencies [[`eb98c5b`](https://github.com/Effect-TS/effect/commit/eb98c5b79ab50aa0cde239bd4e660dd19dbab612), [`184fed8`](https://github.com/Effect-TS/effect/commit/184fed83ac36cba05a75a5a8013f740f9f696e3b), [`4d3fbe8`](https://github.com/Effect-TS/effect/commit/4d3fbe82e8cec13ccd0cd0b2096deac6818fb59a), [`6068e07`](https://github.com/Effect-TS/effect/commit/6068e073d4cc8b3c8583583fd5eb3efe43f7d5ba), [`3a77e20`](https://github.com/Effect-TS/effect/commit/3a77e209783933bac3aaddba1b05ff6a9ac72b36)]: + - effect@3.3.1 + - @effect/platform@0.57.0 + - @effect/sql@0.3.10 + +## 0.3.10 + +### Patch Changes + +- Updated dependencies [[`2b9ddfc`](https://github.com/Effect-TS/effect/commit/2b9ddfcbac505d98551e764a43923854907ca5c1), [`1f4ac00`](https://github.com/Effect-TS/effect/commit/1f4ac00a91c336c9c9c9b8c3ed9ceb9920ebc9bd), [`9305b76`](https://github.com/Effect-TS/effect/commit/9305b764cceeae4f16564435ae7172f79c2bf822), [`0f40d98`](https://github.com/Effect-TS/effect/commit/0f40d989da10f68df3ecd72b36849401ad679bfb), [`188f0a5`](https://github.com/Effect-TS/effect/commit/188f0a5c57ed0d7c9e5852e0c1c998f1b95810a1), [`b761ef0`](https://github.com/Effect-TS/effect/commit/b761ef00eaf6c67b7ffe34798b98aae5347ab376), [`b53f69b`](https://github.com/Effect-TS/effect/commit/b53f69bff1452a487b21198cd83961f844e02d36), [`0f40d98`](https://github.com/Effect-TS/effect/commit/0f40d989da10f68df3ecd72b36849401ad679bfb), [`5bd549e`](https://github.com/Effect-TS/effect/commit/5bd549e4bd7144727db438ecca6b8dc9b3ef7e22), [`67f160a`](https://github.com/Effect-TS/effect/commit/67f160a213de0219a565d4bf653b3cbf24f58e8f)]: + - @effect/platform@0.56.0 + - effect@3.3.0 + - @effect/sql@0.3.9 + +## 0.3.9 + +### Patch Changes + +- Updated dependencies [[`a67d602`](https://github.com/Effect-TS/effect/commit/a67d60276f96cd20b76145b4cee13efca6c6158a)]: + - @effect/platform@0.55.7 + - @effect/sql@0.3.8 + +## 0.3.8 + +### Patch Changes + +- Updated dependencies [[`8c5d280`](https://github.com/Effect-TS/effect/commit/8c5d280c0402284a4e58372867a15a431cb99461), [`6ba6d26`](https://github.com/Effect-TS/effect/commit/6ba6d269f5891e6b11aa35c5281dde4bf3273004), [`3f28bf2`](https://github.com/Effect-TS/effect/commit/3f28bf274333611906175446b772243f34f1b6d5), [`5817820`](https://github.com/Effect-TS/effect/commit/58178204a770d1a78c06945ef438f9fffbb50afa), [`799aa20`](https://github.com/Effect-TS/effect/commit/799aa20b4f618736ba33a5297fda90a75d4c26c6)]: + - effect@3.2.9 + - @effect/platform@0.55.6 + - @effect/sql@0.3.7 + +## 0.3.7 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.55.5 + - @effect/sql@0.3.6 + +## 0.3.6 + +### Patch Changes + +- Updated dependencies [[`fb91f17`](https://github.com/Effect-TS/effect/commit/fb91f17098b48497feca9ec976feb87e4a82451b)]: + - effect@3.2.8 + - @effect/platform@0.55.4 + - @effect/sql@0.3.5 + +## 0.3.5 + +### Patch Changes + +- Updated dependencies [[`6801fca`](https://github.com/Effect-TS/effect/commit/6801fca44366be3ee1b6b99f54bd4f38a1b5e4f4)]: + - effect@3.2.7 + - @effect/platform@0.55.3 + - @effect/sql@0.3.4 + +## 0.3.4 + +### Patch Changes + +- Updated dependencies [[`2c2280b`](https://github.com/Effect-TS/effect/commit/2c2280b98a11fc002663c55792a4fa5781cd5fb6), [`cc8ac50`](https://github.com/Effect-TS/effect/commit/cc8ac5080daba8622ca2ff5dab5c37ddfab732ba)]: + - @effect/platform@0.55.2 + - effect@3.2.6 + - @effect/sql@0.3.3 + +## 0.3.3 + +### Patch Changes + +- Updated dependencies [[`3e86ced`](https://github.com/Effect-TS/effect/commit/3e86cedfa2507dbf5475c1cb10e0018d00e5593d)]: + - @effect/sql@0.3.2 + +## 0.3.2 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.55.1 + - @effect/sql@0.3.1 + +## 0.3.1 + +### Patch Changes + +- [#2838](https://github.com/Effect-TS/effect/pull/2838) [`bf66289`](https://github.com/Effect-TS/effect/commit/bf662893dca07351b249e4ec1d1a9d0108d6f9e1) Thanks @tim-smart! - allow additional span attributes to be passed to sql clients + +## 0.3.0 + +### Minor Changes + +- [#2833](https://github.com/Effect-TS/effect/pull/2833) [`af0543c`](https://github.com/Effect-TS/effect/commit/af0543cbe62e9b9c0bd0ecb1ce2e5814b2c3caaa) Thanks @tim-smart! - remove file system migrator from web sql implementations + +### Patch Changes + +- Updated dependencies [[`af0543c`](https://github.com/Effect-TS/effect/commit/af0543cbe62e9b9c0bd0ecb1ce2e5814b2c3caaa), [`608b01f`](https://github.com/Effect-TS/effect/commit/608b01fc342dbae2a642b308a67b84ead530ecea), [`031c712`](https://github.com/Effect-TS/effect/commit/031c7122a24ac42e48d6a434646b4f5d279d7442), [`a44e532`](https://github.com/Effect-TS/effect/commit/a44e532cf3a6a498b12a5aacf8124aa267e24ba0), [`5133ca9`](https://github.com/Effect-TS/effect/commit/5133ca9dc4b8da0e28951316da9ab55dfbe0fbb9)]: + - @effect/sql@0.3.0 + - effect@3.2.5 + - @effect/platform@0.55.0 + +## 0.2.17 + +### Patch Changes + +- Updated dependencies [[`1af94df`](https://github.com/Effect-TS/effect/commit/1af94df6b74aeb4f6ebcbe80e074b4cb252e62e3), [`1af94df`](https://github.com/Effect-TS/effect/commit/1af94df6b74aeb4f6ebcbe80e074b4cb252e62e3), [`c07e0ce`](https://github.com/Effect-TS/effect/commit/c07e0cea8ce165887e2c9dfa5d669eba9b2fb798), [`e313a01`](https://github.com/Effect-TS/effect/commit/e313a01b7e80f6cb7704055a190e5623c9d22c6d), [`1af94df`](https://github.com/Effect-TS/effect/commit/1af94df6b74aeb4f6ebcbe80e074b4cb252e62e3)]: + - effect@3.2.4 + - @effect/platform@0.54.0 + - @effect/sql@0.2.17 + +## 0.2.16 + +### Patch Changes + +- Updated dependencies [[`45578e8`](https://github.com/Effect-TS/effect/commit/45578e8faa80ae33d23e08f6f19467f818b7788f)]: + - effect@3.2.3 + - @effect/platform@0.53.14 + - @effect/sql@0.2.16 + +## 0.2.15 + +### Patch Changes + +- [#2783](https://github.com/Effect-TS/effect/pull/2783) [`5fb0b33`](https://github.com/Effect-TS/effect/commit/5fb0b338e06d01efca43ba67de42099c96e8adc5) Thanks @giacomoran! - Replace Postgres.js parsed options in `PgClient.config` + +- Updated dependencies [[`5d9266e`](https://github.com/Effect-TS/effect/commit/5d9266e8c740746ac9e186c3df6090a1b57fbe2a), [`9f8122e`](https://github.com/Effect-TS/effect/commit/9f8122e78884ab47c5e5f364d86eee1d1543cc61), [`6a6f670`](https://github.com/Effect-TS/effect/commit/6a6f6706b8613c8c7c10971b8d81a0f9e440a6f2), [`c1eaef9`](https://github.com/Effect-TS/effect/commit/c1eaef910420dae416923d172ee58d219e921d0f)]: + - effect@3.2.2 + - @effect/platform@0.53.13 + - @effect/sql@0.2.15 + +## 0.2.14 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.53.12 + - @effect/sql@0.2.14 + +## 0.2.13 + +### Patch Changes + +- Updated dependencies [[`c1e991d`](https://github.com/Effect-TS/effect/commit/c1e991dd5ba87901cd0e05697a8b4a267e7e954a)]: + - effect@3.2.1 + - @effect/platform@0.53.11 + - @effect/sql@0.2.13 + +## 0.2.12 + +### Patch Changes + +- Updated dependencies [[`146cadd`](https://github.com/Effect-TS/effect/commit/146cadd9d004634a3ff85c480bf92cf975c853e2), [`7135748`](https://github.com/Effect-TS/effect/commit/713574813a0f64085db0b5240ba39e7a0a7c137e), [`7135748`](https://github.com/Effect-TS/effect/commit/713574813a0f64085db0b5240ba39e7a0a7c137e), [`963b4e7`](https://github.com/Effect-TS/effect/commit/963b4e7ac87e2468feb6a344f7ab4ee4ad711198), [`64c9414`](https://github.com/Effect-TS/effect/commit/64c9414e960e82058ca09bbb3976d6fbef303a8e), [`7135748`](https://github.com/Effect-TS/effect/commit/713574813a0f64085db0b5240ba39e7a0a7c137e), [`2cbb76b`](https://github.com/Effect-TS/effect/commit/2cbb76bb52500a3f4bf27d1c91482518cbea56d7), [`870c5fa`](https://github.com/Effect-TS/effect/commit/870c5fa52cd61e745e8e828d38c3f09f00737553), [`146cadd`](https://github.com/Effect-TS/effect/commit/146cadd9d004634a3ff85c480bf92cf975c853e2), [`7135748`](https://github.com/Effect-TS/effect/commit/713574813a0f64085db0b5240ba39e7a0a7c137e), [`64c9414`](https://github.com/Effect-TS/effect/commit/64c9414e960e82058ca09bbb3976d6fbef303a8e)]: + - effect@3.2.0 + - @effect/platform@0.53.10 + - @effect/sql@0.2.12 + +## 0.2.11 + +### Patch Changes + +- Updated dependencies [[`17fc22e`](https://github.com/Effect-TS/effect/commit/17fc22e132593c5caa563705a4748ba0f04a853c), [`810f222`](https://github.com/Effect-TS/effect/commit/810f222268792b13067c7a7bf317b93a9bb8917b), [`596aaea`](https://github.com/Effect-TS/effect/commit/596aaea022648b2e06fb1ec22f1652043d6fe64e)]: + - @effect/platform@0.53.9 + - effect@3.1.6 + - @effect/sql@0.2.11 + +## 0.2.10 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.53.8 + - @effect/sql@0.2.10 + +## 0.2.9 + +### Patch Changes + +- [#2712](https://github.com/Effect-TS/effect/pull/2712) [`01b4553`](https://github.com/Effect-TS/effect/commit/01b4553df4d2a7c5824a112f405a49f8fcfebbf4) Thanks [@vecerek](https://github.com/vecerek)! - Use constants from `@opentelemetry/semantic-conventions` as span attribute names instead of hard-coded values + +- Updated dependencies [[`01b4553`](https://github.com/Effect-TS/effect/commit/01b4553df4d2a7c5824a112f405a49f8fcfebbf4)]: + - @effect/sql@0.2.9 + - @effect/platform@0.53.7 + +## 0.2.8 + +### Patch Changes + +- Updated dependencies [[`6ac4847`](https://github.com/Effect-TS/effect/commit/6ac48479447c01a4f35d655552af93e47e562610), [`6ac4847`](https://github.com/Effect-TS/effect/commit/6ac48479447c01a4f35d655552af93e47e562610)]: + - @effect/platform@0.53.6 + - effect@3.1.5 + - @effect/sql@0.2.8 + +## 0.2.7 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.53.5 + - @effect/sql@0.2.7 + +## 0.2.6 + +### Patch Changes + +- Updated dependencies [[`e41e911`](https://github.com/Effect-TS/effect/commit/e41e91122fa6dd12fc81e50dcad0db891be67146)]: + - effect@3.1.4 + - @effect/platform@0.53.4 + - @effect/sql@0.2.6 + +## 0.2.5 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.53.3 + - @effect/sql@0.2.5 + +## 0.2.4 + +### Patch Changes + +- Updated dependencies [[`1f6dc96`](https://github.com/Effect-TS/effect/commit/1f6dc96f51c7bb9c8d11415358308604ba7c7c8e)]: + - effect@3.1.3 + - @effect/platform@0.53.2 + - @effect/sql@0.2.4 + +## 0.2.3 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.53.1 + - @effect/sql@0.2.3 + +## 0.2.2 + +### Patch Changes + +- Updated dependencies [[`d57fbbb`](https://github.com/Effect-TS/effect/commit/d57fbbbd6c466936213a671fc3cd2390064f864e)]: + - @effect/platform@0.53.0 + - @effect/sql@0.2.2 + +## 0.2.1 + +### Patch Changes + +- Updated dependencies [[`5866c62`](https://github.com/Effect-TS/effect/commit/5866c621d7eb4cc84e4ba972bfdfd219734cd45d)]: + - @effect/platform@0.52.3 + - @effect/sql@0.2.1 + +## 0.2.0 + +### Minor Changes + +- [#2693](https://github.com/Effect-TS/effect/pull/2693) [`0724274`](https://github.com/Effect-TS/effect/commit/07242746ed8a3b0383631108360a0ad4f6e062f0) Thanks [@tim-smart](https://github.com/tim-smart)! - make @effect/sql dialect agnostic + + All of the client implementations now share the same Context.Tag. This means you can create + services that support multiple SQL flavors. + + You can now use the `@effect/sql` package to access the client apis: + + ```ts + import * as Sql from "effect/unstable/sql" + import { Effect } from "effect" + + Effect.gen(function* () { + const sql = yield* Sql.client.Client + yield* sql`SELECT * FROM users` + }) + ``` + + If you need a functionality that is specific to a implementation, you can use the tag from the + implementation package: + + ```ts + import * as Sqlite from "@effect/sql-sqlite-node" + import { Effect } from "effect" + + Effect.gen(function* () { + const sql = yield* Sqlite.client.SqliteClient + const dump = yield* sql.export + }) + ``` + + If you need to run a different query depending on the dialect, you can use the `sql.onDialect` api: + + ```ts + import * as Sql from "effect/unstable/sql" + import { Effect } from "effect" + + Effect.gen(function* () { + const sql = yield* Sql.client.Client + yield* sql.onDialect({ + sqlite: () => sql`SELECT * FROM sqlite_master`, + mysql: () => sql`SHOW TABLES`, + mssql: () => sql`SELECT * FROM sys.tables`, + pg: () => sql`SELECT * FROM pg_catalog.pg_tables` + }) + }) + ``` + +### Patch Changes + +- [#2693](https://github.com/Effect-TS/effect/pull/2693) [`0724274`](https://github.com/Effect-TS/effect/commit/07242746ed8a3b0383631108360a0ad4f6e062f0) Thanks [@tim-smart](https://github.com/tim-smart)! - add .returning helper to insert and update apis + +- Updated dependencies [[`0724274`](https://github.com/Effect-TS/effect/commit/07242746ed8a3b0383631108360a0ad4f6e062f0), [`0724274`](https://github.com/Effect-TS/effect/commit/07242746ed8a3b0383631108360a0ad4f6e062f0)]: + - @effect/sql@0.2.0 + +## 0.1.17 + +### Patch Changes + +- [#2683](https://github.com/Effect-TS/effect/pull/2683) [`0f88814`](https://github.com/Effect-TS/effect/commit/0f88814f4df38c6dad10a257980171b9360cb29f) Thanks [@giacomoran](https://github.com/giacomoran)! - add `prepare` and `types` to `PgClientConfig` + +- Updated dependencies [[`2e1cdf6`](https://github.com/Effect-TS/effect/commit/2e1cdf67d141281288fffe9a5c10d1379a800513), [`d3cf2d8`](https://github.com/Effect-TS/effect/commit/d3cf2d80038310ccc0a6a015d13d86291a953b41), [`56ec8dd`](https://github.com/Effect-TS/effect/commit/56ec8ddc3495f11a1ca8acc59098d9a2f5ced615)]: + - @effect/platform@0.52.2 + - effect@3.1.2 + - @effect/sql@0.1.17 + +## 0.1.16 + +### Patch Changes + +- Updated dependencies [[`e5e56d1`](https://github.com/Effect-TS/effect/commit/e5e56d138dbed3204636f605229c6685f89659fc)]: + - effect@3.1.1 + - @effect/platform@0.52.1 + - @effect/sql@0.1.16 + +## 0.1.15 + +### Patch Changes + +- Updated dependencies [[`9deab0a`](https://github.com/Effect-TS/effect/commit/9deab0aec9e99501f9441843e34df9afa10c5be9), [`7719b8a`](https://github.com/Effect-TS/effect/commit/7719b8a7350c14e952ffe685bfd5308773b3e271)]: + - @effect/platform@0.52.0 + - @effect/sql@0.1.15 + +## 0.1.14 + +### Patch Changes + +- Updated dependencies [[`c3c12c6`](https://github.com/Effect-TS/effect/commit/c3c12c6625633fe80e79f9db75a3b8cf8ca8b11d), [`ba64ea6`](https://github.com/Effect-TS/effect/commit/ba64ea6757810c5e74cad3863a7d19d4d38af66b), [`b5de2d2`](https://github.com/Effect-TS/effect/commit/b5de2d2ce5b1afe8be90827bf898a95cec40eb2b), [`a1c7ab8`](https://github.com/Effect-TS/effect/commit/a1c7ab8ffedacd18c1fc784f4ff5844f79498b83), [`a023f28`](https://github.com/Effect-TS/effect/commit/a023f28336f3865687d9a30c1883e36909906d85), [`0ec93cb`](https://github.com/Effect-TS/effect/commit/0ec93cb4f166e7401c171c2f8e8276ce958d9a57), [`1c9454d`](https://github.com/Effect-TS/effect/commit/1c9454d532eae79b9f759aea77f59332cc6d18ed), [`a023f28`](https://github.com/Effect-TS/effect/commit/a023f28336f3865687d9a30c1883e36909906d85), [`92d56db`](https://github.com/Effect-TS/effect/commit/92d56dbb3f33e36636c2a2f1030c56492e39cf4d)]: + - effect@3.1.0 + - @effect/platform@0.51.0 + - @effect/sql@0.1.14 + +## 0.1.13 + +### Patch Changes + +- Updated dependencies [[`16039a0`](https://github.com/Effect-TS/effect/commit/16039a08f04f11545e2fdf40952788a8f9cef04f), [`557707b`](https://github.com/Effect-TS/effect/commit/557707bc9e5f230c8964d2757012075c34339b5c), [`d1d33e1`](https://github.com/Effect-TS/effect/commit/d1d33e10b25109f44b5ab1c6e4d778a59c0d3eeb), [`f4ed306`](https://github.com/Effect-TS/effect/commit/f4ed3068a70b50302d078a30d18ca3cfd2bc679c), [`661004f`](https://github.com/Effect-TS/effect/commit/661004f4bf5f8b25f5a0678c21a3a822188ce461), [`e79cb83`](https://github.com/Effect-TS/effect/commit/e79cb83d3b19098bc40a3012e2a059b8426306c2)]: + - @effect/platform@0.50.8 + - effect@3.0.8 + - @effect/sql@0.1.13 + +## 0.1.12 + +### Patch Changes + +- Updated dependencies [[`18de56b`](https://github.com/Effect-TS/effect/commit/18de56b4a6b6d1f99230dfabf9147d59ea4dd759)]: + - effect@3.0.7 + - @effect/platform@0.50.7 + - @effect/sql@0.1.12 + +## 0.1.11 + +### Patch Changes + +- [#2621](https://github.com/Effect-TS/effect/pull/2621) [`f363af0`](https://github.com/Effect-TS/effect/commit/f363af08df9426a8bc629d80ef57d8b7e243ffa6) Thanks [@tim-smart](https://github.com/tim-smart)! - add sql transaction tracing spans + +- [#2621](https://github.com/Effect-TS/effect/pull/2621) [`f363af0`](https://github.com/Effect-TS/effect/commit/f363af08df9426a8bc629d80ef57d8b7e243ffa6) Thanks [@tim-smart](https://github.com/tim-smart)! - update sql span attributes to follow semantic conventions + +- [#2621](https://github.com/Effect-TS/effect/pull/2621) [`f363af0`](https://github.com/Effect-TS/effect/commit/f363af08df9426a8bc629d80ef57d8b7e243ffa6) Thanks [@tim-smart](https://github.com/tim-smart)! - add sql`...`.unprepared, to run a query without trying to PREPARE it + +- Updated dependencies [[`ffe4f4e`](https://github.com/Effect-TS/effect/commit/ffe4f4e95db35fff6869e360b072e3837befa0a1), [`027418e`](https://github.com/Effect-TS/effect/commit/027418edaa6aa6c0ae4861b95832827b45adace4), [`f363af0`](https://github.com/Effect-TS/effect/commit/f363af08df9426a8bc629d80ef57d8b7e243ffa6), [`ac1898e`](https://github.com/Effect-TS/effect/commit/ac1898eb7bc96880f911c276048e2ea3d6fe9c50), [`ffe4f4e`](https://github.com/Effect-TS/effect/commit/ffe4f4e95db35fff6869e360b072e3837befa0a1), [`f363af0`](https://github.com/Effect-TS/effect/commit/f363af08df9426a8bc629d80ef57d8b7e243ffa6), [`f363af0`](https://github.com/Effect-TS/effect/commit/f363af08df9426a8bc629d80ef57d8b7e243ffa6)]: + - effect@3.0.6 + - @effect/sql@0.1.11 + - @effect/platform@0.50.6 + +## 0.1.10 + +### Patch Changes + +- Updated dependencies [[`6222404`](https://github.com/Effect-TS/effect/commit/62224044678751829ed2f128e05133a91c6b0569), [`868ed2a`](https://github.com/Effect-TS/effect/commit/868ed2a8fe94ee7f4206a6070f29dcf2a5ba1dc3)]: + - effect@3.0.5 + - @effect/platform@0.50.5 + - @effect/sql@0.1.10 + +## 0.1.9 + +### Patch Changes + +- Updated dependencies [[`9a24667`](https://github.com/Effect-TS/effect/commit/9a246672008a2b668d43fbfd2fe5508c54b2b920)]: + - effect@3.0.4 + - @effect/platform@0.50.4 + - @effect/sql@0.1.9 + +## 0.1.8 + +### Patch Changes + +- Updated dependencies [[`b3b51a2`](https://github.com/Effect-TS/effect/commit/b3b51a2ea0c6ab92a363db46ebaa7e1176d089f5)]: + - @effect/platform@0.50.3 + - @effect/sql@0.1.8 + +## 0.1.7 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.50.2 + - @effect/sql@0.1.7 + +## 0.1.6 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.50.1 + - @effect/sql@0.1.6 + +## 0.1.5 + +### Patch Changes + +- Updated dependencies [[`6f38dff`](https://github.com/Effect-TS/effect/commit/6f38dff41ffa34532cc2f25b90446550c5730bb6), [`a7b4b84`](https://github.com/Effect-TS/effect/commit/a7b4b84bd5a25f51aba922f9259c3a58c98c6a4e), [`a3b0e6c`](https://github.com/Effect-TS/effect/commit/a3b0e6c490772e6d44b5d98dcf2729c4d5310ecc), [`6f38dff`](https://github.com/Effect-TS/effect/commit/6f38dff41ffa34532cc2f25b90446550c5730bb6)]: + - @effect/platform@0.50.0 + - effect@3.0.3 + - @effect/sql@0.1.5 + +## 0.1.4 + +### Patch Changes + +- [#2562](https://github.com/Effect-TS/effect/pull/2562) [`2cecdbd`](https://github.com/Effect-TS/effect/commit/2cecdbd1cf30befce4e84796ccd953ea55ecfb86) Thanks [@fubhy](https://github.com/fubhy)! - Added provenance publishing + +- Updated dependencies [[`2cecdbd`](https://github.com/Effect-TS/effect/commit/2cecdbd1cf30befce4e84796ccd953ea55ecfb86)]: + - @effect/platform@0.49.4 + - effect@3.0.2 + - @effect/sql@0.1.4 + +## 0.1.3 + +### Patch Changes + +- Updated dependencies [[`8d39d65`](https://github.com/Effect-TS/effect/commit/8d39d6554af548228ad767112ce2e0b1f68fa8e1)]: + - @effect/platform@0.49.3 + - @effect/sql@0.1.3 + +## 0.1.2 + +### Patch Changes + +- Updated dependencies [[`5ef0a1a`](https://github.com/Effect-TS/effect/commit/5ef0a1ae9b773fa2481550cb0d43ff7a0e03cd44)]: + - @effect/platform@0.49.2 + - @effect/sql@0.1.2 + +## 0.1.1 + +### Patch Changes + +- Updated dependencies [[`3da0cfa`](https://github.com/Effect-TS/effect/commit/3da0cfa12c407fd930dc480be1ecc9217a8058f8), [`570e8d8`](https://github.com/Effect-TS/effect/commit/570e8d87e7c0e9ad4cd2686462fdb9b4812f7716), [`87c5687`](https://github.com/Effect-TS/effect/commit/87c5687de0782dab177b7861217fa3b040046282), [`f838c15`](https://github.com/Effect-TS/effect/commit/f838c15ca83938a5ee9bfec49deb025564a570ff), [`8edacca`](https://github.com/Effect-TS/effect/commit/8edacca37f8e37c01a63fec332b06d9361efaa7b)]: + - effect@3.0.1 + - @effect/platform@0.49.1 + - @effect/sql@0.1.1 + +## 0.1.0 + +### Minor Changes + +- [#2104](https://github.com/Effect-TS/effect/pull/2104) [`1499974`](https://github.com/Effect-TS/effect/commit/14999741d2e19c1747f6a7e19d68977f6429cdb8) Thanks [@IMax153](https://github.com/IMax153)! - initial @effect/sql release + +- [#2207](https://github.com/Effect-TS/effect/pull/2207) [`2fb7d9c`](https://github.com/Effect-TS/effect/commit/2fb7d9ca15037ff62a578bb9fe5732da5f4f317d) Thanks [@github-actions](https://github.com/apps/github-actions)! - Release Effect 3.0 🎉 + +### Patch Changes + +- Updated dependencies [[`1b5f0c7`](https://github.com/Effect-TS/effect/commit/1b5f0c77e7fd477a0026071e82129a948227f4b3), [`d50a652`](https://github.com/Effect-TS/effect/commit/d50a652479f4d1d64f48da05c79fa847e6e51548), [`9a3bd47`](https://github.com/Effect-TS/effect/commit/9a3bd47ebd0750c7e498162734f6d21895de0cb2), [`1499974`](https://github.com/Effect-TS/effect/commit/14999741d2e19c1747f6a7e19d68977f6429cdb8), [`6460414`](https://github.com/Effect-TS/effect/commit/6460414351a45fb8e0a457c63f3653422efee766), [`cf69f46`](https://github.com/Effect-TS/effect/commit/cf69f46690058d71eeada03cfb40dc744573e9e4), [`cf69f46`](https://github.com/Effect-TS/effect/commit/cf69f46690058d71eeada03cfb40dc744573e9e4), [`be9d025`](https://github.com/Effect-TS/effect/commit/be9d025e42355260ace02dd135851a8935a4deba), [`78b767c`](https://github.com/Effect-TS/effect/commit/78b767c2b1625186e17131761a0edbac25d21850), [`aa4a3b5`](https://github.com/Effect-TS/effect/commit/aa4a3b550da1c1020265ac389ed3f309388994a2), [`1499974`](https://github.com/Effect-TS/effect/commit/14999741d2e19c1747f6a7e19d68977f6429cdb8), [`1b5f0c7`](https://github.com/Effect-TS/effect/commit/1b5f0c77e7fd477a0026071e82129a948227f4b3), [`5c2b561`](https://github.com/Effect-TS/effect/commit/5c2b5614f583b88784ed68126ae939832fb3c092), [`6c6087a`](https://github.com/Effect-TS/effect/commit/6c6087a4a897b64252346426660782d31c13f769), [`a18f594`](https://github.com/Effect-TS/effect/commit/a18f5948f1439a147232448b2c443472fda0eceb), [`1499974`](https://github.com/Effect-TS/effect/commit/14999741d2e19c1747f6a7e19d68977f6429cdb8), [`2f96d93`](https://github.com/Effect-TS/effect/commit/2f96d938b90f8c19377583279e3c7afd9b509c50), [`5a2314b`](https://github.com/Effect-TS/effect/commit/5a2314b70ec79c2c02b51cef45a5ddec8327daa1), [`25d74f8`](https://github.com/Effect-TS/effect/commit/25d74f8c4d2dd4a9e5ec57ce2f20d36dedd25343), [`6c6087a`](https://github.com/Effect-TS/effect/commit/6c6087a4a897b64252346426660782d31c13f769), [`271b79f`](https://github.com/Effect-TS/effect/commit/271b79fc0b66a6c11e07a8779ff8800493a7eac2), [`1b5f0c7`](https://github.com/Effect-TS/effect/commit/1b5f0c77e7fd477a0026071e82129a948227f4b3), [`2fb7d9c`](https://github.com/Effect-TS/effect/commit/2fb7d9ca15037ff62a578bb9fe5732da5f4f317d), [`53d1c2a`](https://github.com/Effect-TS/effect/commit/53d1c2a77559081fbb89667e343346375c6d6650), [`e7e1bbe`](https://github.com/Effect-TS/effect/commit/e7e1bbe68486fdf31c8f84b0880522d39adcaad3), [`10c169e`](https://github.com/Effect-TS/effect/commit/10c169eadc874e91b4defca3f467b4e6a50fd8f3), [`6424181`](https://github.com/Effect-TS/effect/commit/64241815fe6a939e91e6947253e7dceea1306aa8)]: + - effect@3.0.0 + - @effect/sql@0.1.0 + - @effect/platform@0.49.0 diff --git a/packages/sql/pg/LICENSE b/packages/sql/pg/LICENSE new file mode 100644 index 0000000000..7f6fe480f7 --- /dev/null +++ b/packages/sql/pg/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023-present The Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/sql/pg/README.md b/packages/sql/pg/README.md new file mode 100644 index 0000000000..6fb7e52f4a --- /dev/null +++ b/packages/sql/pg/README.md @@ -0,0 +1,7 @@ +# `@effect/sql-pg` + +An `@effect/sql` implementation using the `postgres.js` library. + +## Documentation + +- **API Reference**: [View the full documentation](https://effect-ts.github.io/effect/docs/sql-pg). diff --git a/packages/sql/pg/docgen.json b/packages/sql/pg/docgen.json new file mode 100644 index 0000000000..157f30fc70 --- /dev/null +++ b/packages/sql/pg/docgen.json @@ -0,0 +1,20 @@ +{ + "$schema": "../../node_modules/@effect/docgen/schema.json", + "srcLink": "https://github.com/Effect-TS/effect/tree/main/packages/sql/pg/src/", + "exclude": ["src/internal/**/*.ts"], + "examplesCompilerOptions": { + "noEmit": true, + "strict": true, + "skipLibCheck": true, + "moduleResolution": "Bundler", + "module": "ES2022", + "target": "ES2022", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "rewriteRelativeImportExtensions": true, + "allowImportingTsExtensions": true, + "paths": { + "effect": ["../../../effect/src/index.js"], + "effect/*": ["../../../effect/src/*.js"] + } + } +} diff --git a/packages/sql/pg/examples/listen-notify.ts b/packages/sql/pg/examples/listen-notify.ts new file mode 100644 index 0000000000..692af8bc35 --- /dev/null +++ b/packages/sql/pg/examples/listen-notify.ts @@ -0,0 +1,30 @@ +import { PgClient } from "@effect/sql-pg" +import { Console, Effect, Stream } from "effect" + +const program = Effect.gen(function*() { + const sql = yield* PgClient.PgClient + + // start listening for notifications on the channel + yield* sql.listen("channel_name").pipe( + Stream.tap((message) => Console.log("Received message", message)), + Stream.runDrain, + Effect.forkScoped + ) + + // send 5 notifications to the channel + yield* sql.notify("channel_name", "Hello, world!").pipe( + Effect.tap(() => Effect.sleep("1 second")), + Effect.replicateEffect(5) + ) +}).pipe(Effect.scoped) + +const PgLive = PgClient.layer({ + database: "postgres", + username: "postgres" +}) + +program.pipe( + Effect.provide(PgLive), + Effect.tapErrorCause(Effect.logError), + Effect.runFork +) diff --git a/packages/sql/pg/examples/resolver.ts b/packages/sql/pg/examples/resolver.ts new file mode 100644 index 0000000000..bce3441223 --- /dev/null +++ b/packages/sql/pg/examples/resolver.ts @@ -0,0 +1,87 @@ +import * as DevTools from "@effect/experimental/DevTools" +import { SqlClient, SqlResolver } from "effect/unstable/sql" +import { PgClient } from "@effect/sql-pg" +import { Effect, Layer, String } from "effect" +import * as Schema from "effect/Schema" + +class Person extends Schema.Class("Person")({ + id: Schema.Number, + name: Schema.String, + createdAt: Schema.DateFromSelf +}) {} + +const InsertPersonSchema = Schema.Struct(Person.fields).pipe( + Schema.omit("id", "createdAt") +) + +const program = Effect.gen(function*() { + const sql = yield* SqlClient.SqlClient + + yield* sql`TRUNCATE TABLE people RESTART IDENTITY CASCADE` + + const Insert = yield* SqlResolver.ordered("InsertPerson", { + Request: InsertPersonSchema, + Result: Person, + execute: (requests) => sql`INSERT INTO people ${sql.insert(requests)} RETURNING people.*` + }) + + const GetById = yield* SqlResolver.findById("GetPersonById", { + Id: Schema.Number, + Result: Person, + ResultId: (result) => result.id, + execute: (ids) => sql`SELECT * FROM people WHERE id IN ${sql.in(ids)}` + }) + + const GetByName = yield* SqlResolver.grouped("GetPersonByName", { + Request: Schema.String, + RequestGroupKey: (_) => _, + Result: Person, + ResultGroupKey: (_) => _.name, + execute: (ids) => sql<{}>`SELECT * FROM people WHERE name IN ${sql.in(ids)}` + }) + + const inserted = yield* sql.withTransaction( + Effect.all( + [ + Insert.execute({ name: "John Doe" }), + Insert.execute({ name: "Joe Bloggs" }) + ], + { batching: true } + ) + ) + + yield* sql`SELECT * FROM people`.pipe( + Effect.andThen(Effect.fail("boom")), + sql.withTransaction, + Effect.ignore + ) + + console.log( + yield* Effect.all( + [GetById.execute(inserted[0].id), GetById.execute(inserted[1].id)], + { batching: true } + ) + ) + + console.log( + yield* Effect.forEach( + ["John Doe", "Joe Bloggs", "John Doe"], + (id) => GetByName.execute(id), + { batching: true } + ) + ) +}) + +const PgLive = PgClient.layer({ + database: "effect_pg_dev", + transformQueryNames: String.camelToSnake, + transformResultNames: String.snakeToCamel +}) + +program.pipe( + Effect.provide(PgLive.pipe( + Layer.provide(DevTools.layer()) + )), + Effect.tapErrorCause(Effect.logError), + Effect.runFork +) diff --git a/packages/sql/pg/package.json b/packages/sql/pg/package.json new file mode 100644 index 0000000000..81ce0ae29c --- /dev/null +++ b/packages/sql/pg/package.json @@ -0,0 +1,71 @@ +{ + "name": "@effect/sql-pg", + "version": "0.45.1", + "type": "module", + "license": "MIT", + "description": "A PostgreSQL toolkit for Effect", + "homepage": "https://effect.website", + "repository": { + "type": "git", + "url": "https://github.com/Effect-TS/effect.git", + "directory": "packages/sql/pg" + }, + "bugs": { + "url": "https://github.com/Effect-TS/effect/issues" + }, + "tags": [ + "typescript", + "sql", + "database" + ], + "keywords": [ + "typescript", + "sql", + "database" + ], + "sideEffects": [], + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts", + "./*": "./src/*.ts", + "./internal/*": null, + "./*/index": null + }, + "files": [ + "src/**/*.ts", + "dist/**/*.js", + "dist/**/*.js.map", + "dist/**/*.d.ts", + "dist/**/*.d.ts.map" + ], + "publishConfig": { + "provenance": true, + "exports": { + "./package.json": "./package.json", + ".": "./dist/index.js", + "./*": "./dist/*.js", + "./internal/*": null, + "./*/index": null + } + }, + "scripts": { + "codegen": "build-utils prepare-v4", + "build": "tsc -b tsconfig.build.json && babel dist --plugins annotate-pure-calls --out-dir dist --source-maps", + "check": "tsc -b tsconfig.json", + "test": "vitest", + "coverage": "vitest --coverage" + }, + "devDependencies": { + "@testcontainers/postgresql": "^11.5.1", + "@types/pg": "^8.15.5", + "@types/pg-cursor": "^2.7.2", + "effect": "workspace:^" + }, + "peerDependencies": { + "effect": "workspace:^" + }, + "dependencies": { + "pg": "^8.16.3", + "pg-cursor": "^2.15.3" + } +} diff --git a/packages/sql/pg/src/PgClient.ts b/packages/sql/pg/src/PgClient.ts new file mode 100644 index 0000000000..50f37a1135 --- /dev/null +++ b/packages/sql/pg/src/PgClient.ts @@ -0,0 +1,419 @@ +/** + * @since 1.0.0 + */ +import * as Arr from "effect/collections/Array" +import * as Config from "effect/config/Config" +import * as Redacted from "effect/data/Redacted" +import * as Effect from "effect/Effect" +import * as Fiber from "effect/Fiber" +import * as Layer from "effect/Layer" +import * as Queue from "effect/Queue" +import * as RcRef from "effect/RcRef" +import * as Scope from "effect/Scope" +import * as ServiceMap from "effect/ServiceMap" +import * as Channel from "effect/stream/Channel" +import * as Pull from "effect/stream/Pull" +import * as Stream from "effect/stream/Stream" +import * as Duration from "effect/time/Duration" +import * as Reactivity from "effect/unstable/reactivity/Reactivity" +import * as Client from "effect/unstable/sql/SqlClient" +import type { Connection } from "effect/unstable/sql/SqlConnection" +import { SqlError } from "effect/unstable/sql/SqlError" +import type { Custom, Fragment, Primitive } from "effect/unstable/sql/Statement" +import * as Statement from "effect/unstable/sql/Statement" +import type { ConnectionOptions } from "node:tls" +import * as Pg from "pg" +import Cursor from "pg-cursor" + +const ATTR_DB_SYSTEM_NAME = "db.system.name" +const ATTR_DB_NAMESPACE = "db.namespace" +const ATTR_SERVER_ADDRESS = "server.address" +const ATTR_SERVER_PORT = "server.port" + +/** + * @category type ids + * @since 1.0.0 + */ +export const TypeId: TypeId = "~@effect/sql-pg/PgClient" + +/** + * @category type ids + * @since 1.0.0 + */ +export type TypeId = "~@effect/sql-pg/PgClient" + +/** + * @category models + * @since 1.0.0 + */ +export interface PgClient extends Client.SqlClient { + readonly [TypeId]: TypeId + readonly config: PgClientConfig + readonly json: (_: unknown) => Fragment + readonly listen: (channel: string) => Stream.Stream + readonly notify: (channel: string, payload: string) => Effect.Effect +} + +/** + * @category tags + * @since 1.0.0 + */ +export const PgClient = ServiceMap.Key("@effect/sql-pg/PgClient") + +/** + * @category constructors + * @since 1.0.0 + */ +export interface PgClientConfig { + readonly url?: Redacted.Redacted | undefined + + readonly host?: string | undefined + readonly port?: number | undefined + readonly path?: string | undefined + readonly ssl?: boolean | ConnectionOptions | undefined + readonly database?: string | undefined + readonly username?: string | undefined + readonly password?: Redacted.Redacted | undefined + + readonly idleTimeout?: Duration.DurationInput | undefined + readonly connectTimeout?: Duration.DurationInput | undefined + + readonly maxConnections?: number | undefined + readonly minConnections?: number | undefined + readonly connectionTTL?: Duration.DurationInput | undefined + + readonly applicationName?: string | undefined + readonly spanAttributes?: Record | undefined + + readonly transformResultNames?: ((str: string) => string) | undefined + readonly transformQueryNames?: ((str: string) => string) | undefined + readonly transformJson?: boolean | undefined + readonly types?: Pg.CustomTypesConfig | undefined +} + +/** + * @category constructors + * @since 1.0.0 + */ +export const make = ( + options: PgClientConfig +): Effect.Effect => + Effect.gen(function*() { + const compiler = makeCompiler( + options.transformQueryNames, + options.transformJson + ) + const transformRows = options.transformResultNames ? + Statement.defaultTransforms( + options.transformResultNames, + options.transformJson + ).array : + undefined + + const pool = new Pg.Pool({ + connectionString: options.url ? Redacted.value(options.url) : undefined, + user: options.username, + host: options.host, + database: options.database, + password: options.password ? Redacted.value(options.password) : undefined, + ssl: options.ssl, + port: options.port, + connectionTimeoutMillis: options.connectTimeout ? Duration.toMillis(options.connectTimeout) : undefined, + idleTimeoutMillis: options.idleTimeout ? Duration.toMillis(options.idleTimeout) : undefined, + max: options.maxConnections, + min: options.minConnections, + maxLifetimeSeconds: options.connectionTTL ? Duration.toSeconds(options.connectionTTL) : undefined, + application_name: options.applicationName ?? "@effect/sql-pg", + types: options.types + }) + + pool.on("error", (_err) => { + }) + + yield* Effect.acquireRelease( + Effect.tryPromise({ + try: () => pool.query("SELECT 1"), + catch: (cause) => new SqlError({ cause, message: "PgClient: Failed to connect" }) + }), + () => + Effect.promise(() => pool.end()).pipe( + Effect.interruptible, + Effect.timeoutOption(1000) + ) + ).pipe( + Effect.timeoutOrElse({ + duration: options.connectTimeout ?? Duration.seconds(5), + onTimeout: () => + Effect.fail( + new SqlError({ + cause: new Error("Connection timed out"), + message: "PgClient: Connection timed out" + }) + ) + }) + ) + + class ConnectionImpl implements Connection { + readonly pg: Pg.Pool | Pg.PoolClient + constructor(pg: Pg.Pool | Pg.PoolClient) { + this.pg = pg + } + + private run(query: string, params: ReadonlyArray) { + return Effect.callback, SqlError>((resume) => { + this.pg.query(query, params as any, (err, result) => { + if (err) { + resume(Effect.fail(new SqlError({ cause: err, message: "Failed to execute statement" }))) + } else { + resume(Effect.succeed(result.rows)) + } + }) + }) + } + + execute( + sql: string, + params: ReadonlyArray, + transformRows: (
(row: ReadonlyArray) => ReadonlyArray) | undefined + ) { + return transformRows + ? Effect.map(this.run(sql, params), transformRows) + : this.run(sql, params) + } + executeRaw(sql: string, params: ReadonlyArray) { + return Effect.callback((resume) => { + this.pg.query(sql, params as any, (err, result) => { + if (err) { + resume(Effect.fail(new SqlError({ cause: err, message: "Failed to execute statement" }))) + } else { + resume(Effect.succeed(result)) + } + }) + }) + } + executeWithoutTransform(sql: string, params: ReadonlyArray) { + return this.run(sql, params) + } + executeValues(sql: string, params: ReadonlyArray) { + return Effect.callback, SqlError>((resume) => { + this.pg.query( + { + text: sql, + rowMode: "array", + values: params as Array + }, + (err, result) => { + if (err) { + resume(Effect.fail(new SqlError({ cause: err, message: "Failed to execute statement" }))) + } else { + resume(Effect.succeed(result.rows)) + } + } + ) + }) + } + executeUnprepared( + sql: string, + params: ReadonlyArray, + transformRows: ((row: ReadonlyArray) => ReadonlyArray) | undefined + ) { + return this.execute(sql, params, transformRows) + } + executeStream( + sql: string, + params: ReadonlyArray, + transformRows: ((row: ReadonlyArray) => ReadonlyArray) | undefined + ) { + // eslint-disable-next-line @typescript-eslint/no-this-alias + const self = this + return Stream.fromChannel(Channel.fromTransform(Effect.fnUntraced(function*(_, scope) { + const cursor = self.pg.query(new Cursor(sql, params as any)) + yield* Scope.addFinalizer(scope, Effect.sync(() => cursor.close())) + return Effect.callback, SqlError | Pull.Halt>((resume) => { + cursor.read(128, (err, rows) => { + if (err) { + resume(Effect.fail(new SqlError({ cause: err, message: "Failed to execute statement" }))) + } else if (Arr.isNonEmptyArray(rows)) { + resume(Effect.succeed(transformRows ? transformRows(rows) as any : rows)) + } else { + resume(Pull.haltVoid) + } + }) + }) + }))) + } + } + + const reserveRaw = Effect.callback((resume) => { + const fiber = Fiber.getCurrent()! + const scope = ServiceMap.unsafeGet(fiber.services, Scope.Scope) + pool.connect((err, client, release) => { + if (err) { + resume(Effect.fail(new SqlError({ cause: err, message: "Failed to acquire connection for transaction" }))) + } else { + resume(Effect.as(Scope.addFinalizer(scope, Effect.sync(release)), client!)) + } + }) + }) + const reserve = Effect.map(reserveRaw, (client) => new ConnectionImpl(client)) + + const listenClient = yield* RcRef.make({ + acquire: reserveRaw + }) + + return Object.assign( + yield* Client.make({ + acquirer: Effect.succeed(new ConnectionImpl(pool)), + transactionAcquirer: reserve, + compiler, + spanAttributes: [ + ...(options.spanAttributes ? Object.entries(options.spanAttributes) : []), + [ATTR_DB_SYSTEM_NAME, "postgresql"], + [ATTR_DB_NAMESPACE, options.database ?? options.username ?? "postgres"], + [ATTR_SERVER_ADDRESS, options.host ?? "localhost"], + [ATTR_SERVER_PORT, options.port ?? 5432] + ], + transformRows + }), + { + [TypeId]: TypeId as TypeId, + config: { + ...options, + host: pool.options.host, + port: pool.options.port, + username: pool.options.user, + password: typeof pool.options.password === "string" ? Redacted.make(pool.options.password) : undefined, + database: pool.options.database + }, + json: (_: unknown) => Statement.fragment([PgJson(_)]), + listen: (channel: string) => + Stream.callback(Effect.fnUntraced(function*(queue) { + const client = yield* RcRef.get(listenClient) + function onNotification(msg: Pg.Notification) { + if (msg.channel === channel && msg.payload) { + Queue.unsafeOffer(queue, msg.payload) + } + } + yield* Effect.addFinalizer(() => + Effect.promise(() => { + client.off("notification", onNotification) + return client.query(`UNLISTEN ${Pg.escapeIdentifier(channel)}`) + }) + ) + yield* Effect.tryPromise({ + try: () => client.query(`LISTEN ${Pg.escapeIdentifier(channel)}`), + catch: (cause) => new SqlError({ cause, message: "Failed to listen" }) + }) + client.on("notification", onNotification) + })), + notify: (channel: string, payload: string) => + Effect.callback((resume) => { + pool.query(`NOTIFY ${Pg.escapeIdentifier(channel)}, $1`, [payload], (err) => { + if (err) { + resume(Effect.fail(new SqlError({ cause: err, message: "Failed to notify" }))) + } else { + resume(Effect.void) + } + }) + }) + } + ) + }) + +/** + * @category layers + * @since 1.0.0 + */ +export const layerConfig = ( + config: Config.Wrap +): Layer.Layer => + Layer.effectServices( + Config.unwrap(config).asEffect().pipe( + Effect.flatMap(make), + Effect.map((client) => + ServiceMap.make(PgClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + ) + ) + ) + ).pipe(Layer.provide(Reactivity.layer)) + +/** + * @category layers + * @since 1.0.0 + */ +export const layer = ( + config: PgClientConfig +): Layer.Layer => + Layer.effectServices( + Effect.map(make(config), (client) => + ServiceMap.make(PgClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + )) + ).pipe(Layer.provide(Reactivity.layer)) + +/** + * @category constructor + * @since 1.0.0 + */ +export const makeCompiler = ( + transform?: (_: string) => string, + transformJson = true +): Statement.Compiler => { + const transformValue = transformJson && transform + ? Statement.defaultTransforms(transform).value + : undefined + + return Statement.makeCompiler({ + dialect: "pg", + placeholder(_) { + return `$${_}` + }, + onIdentifier: transform ? + function(value, withoutTransform) { + return withoutTransform ? escape(value) : escape(transform(value)) + } : + escape, + onRecordUpdate(placeholders, valueAlias, valueColumns, values, returning) { + return [ + `(values ${placeholders}) AS ${valueAlias}${valueColumns}${returning ? ` RETURNING ${returning[0]}` : ""}`, + returning ? + values.flat().concat(returning[1]) : + values.flat() + ] + }, + onCustom(type, placeholder, withoutTransform) { + switch (type.kind) { + case "PgJson": { + return [ + placeholder(undefined), + [ + withoutTransform || transformValue === undefined + ? type.paramA + : transformValue(type.paramA) + ] + ] + } + } + } + }) +} + +const escape = Statement.defaultEscape("\"") + +/** + * @category custom types + * @since 1.0.0 + */ +export type PgCustom = PgJson + +/** + * @category custom types + * @since 1.0.0 + */ +interface PgJson extends Custom<"PgJson", unknown> {} +/** + * @category custom types + * @since 1.0.0 + */ +const PgJson = Statement.custom("PgJson") diff --git a/packages/sql/pg/src/PgMigrator.ts b/packages/sql/pg/src/PgMigrator.ts new file mode 100644 index 0000000000..114aaa1e1f --- /dev/null +++ b/packages/sql/pg/src/PgMigrator.ts @@ -0,0 +1,94 @@ +/** + * @since 1.0.0 + */ +import type * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" +import * as Migrator from "effect/unstable/sql/Migrator" +import type * as Client from "effect/unstable/sql/SqlClient" +import type { SqlError } from "effect/unstable/sql/SqlError" + +/** + * @since 1.0.0 + */ +export * from "effect/unstable/sql/Migrator" + +/** + * @category constructor + * @since 1.0.0 + */ +export const run: ( + options: Migrator.MigratorOptions +) => Effect.Effect< + ReadonlyArray, + Migrator.MigrationError | SqlError, + Client.SqlClient | R2 +> = Migrator.make({ + // TODO: Wait for Command module + // dumpSchema(path, table) { + // const pgDump = (args: Array) => + // Effect.gen(function*() { + // const sql = yield* PgClient + // const dump = yield* pipe( + // Command.make("pg_dump", ...args, "--no-owner", "--no-privileges"), + // Command.env({ + // PATH: (globalThis as any).process?.env.PATH, + // PGHOST: sql.config.host, + // PGPORT: sql.config.port?.toString(), + // PGUSER: sql.config.username, + // PGPASSWORD: sql.config.password + // ? Redacted.value(sql.config.password) + // : undefined, + // PGDATABASE: sql.config.database, + // PGSSLMODE: sql.config.ssl ? "require" : "prefer" + // }), + // Command.string + // ) + // + // return dump.replace(/^--.*$/gm, "") + // .replace(/^SET .*$/gm, "") + // .replace(/^SELECT pg_catalog\..*$/gm, "") + // .replace(/\n{2,}/gm, "\n\n") + // .trim() + // }).pipe( + // Effect.mapError((error) => new Migrator.MigrationError({ reason: "failed", message: error.message })) + // ) + // + // const pgDumpSchema = pgDump(["--schema-only"]) + // + // const pgDumpMigrations = pgDump([ + // "--column-inserts", + // "--data-only", + // `--table=${table}` + // ]) + // + // const pgDumpAll = Effect.map( + // Effect.all([pgDumpSchema, pgDumpMigrations], { concurrency: 2 }), + // ([schema, migrations]) => schema + "\n\n" + migrations + // ) + // + // const pgDumpFile = (path: string) => + // Effect.gen(function*() { + // const fs = yield* FileSystem + // const path_ = yield* Path + // const dump = yield* pgDumpAll + // yield* fs.makeDirectory(path_.dirname(path), { recursive: true }) + // yield* fs.writeFileString(path, dump) + // }).pipe( + // Effect.mapError((error) => new Migrator.MigrationError({ reason: "failed", message: error.message })) + // ) + // + // return pgDumpFile(path) + // } +}) + +/** + * @category layers + * @since 1.0.0 + */ +export const layer = ( + options: Migrator.MigratorOptions +): Layer.Layer< + never, + Migrator.MigrationError | SqlError, + Client.SqlClient | R +> => Layer.effectDiscard(run(options)) diff --git a/packages/sql/pg/src/index.ts b/packages/sql/pg/src/index.ts new file mode 100644 index 0000000000..2af227b0eb --- /dev/null +++ b/packages/sql/pg/src/index.ts @@ -0,0 +1,13 @@ +/** + * @since 1.0.0 + */ + +/** + * @since 1.0.0 + */ +export * as PgClient from "./PgClient.ts" + +/** + * @since 1.0.0 + */ +export * as PgMigrator from "./PgMigrator.ts" diff --git a/packages/sql/pg/src/index.ts.tpl b/packages/sql/pg/src/index.ts.tpl new file mode 100644 index 0000000000..b66408871c --- /dev/null +++ b/packages/sql/pg/src/index.ts.tpl @@ -0,0 +1,3 @@ +/** + * @since 1.0.0 + */ diff --git a/packages/sql/pg/test/Client.test.ts b/packages/sql/pg/test/Client.test.ts new file mode 100644 index 0000000000..9e2feaae14 --- /dev/null +++ b/packages/sql/pg/test/Client.test.ts @@ -0,0 +1,272 @@ +import { PgClient } from "@effect/sql-pg" +import { assert, expect, it } from "@effect/vitest" +import { Effect } from "effect" +import { String } from "effect/primitives" +import * as Statement from "effect/unstable/sql/Statement" +import { PgContainer } from "./utils.ts" + +const compilerTransform = PgClient.makeCompiler(String.camelToSnake) +const transformsNested = Statement.defaultTransforms(String.snakeToCamel) +const transforms = Statement.defaultTransforms(String.snakeToCamel, false) + +it.layer(PgContainer.layerClient, { timeout: "30 seconds" })("PgClient", (it) => { + it.effect("insert helper", () => + Effect.gen(function*() { + const sql = yield* PgClient.PgClient + const [query, params] = sql`INSERT INTO people ${sql.insert({ name: "Tim", age: 10 })}`.compile() + expect(query).toEqual(`INSERT INTO people ("name","age") VALUES ($1,$2)`) + expect(params).toEqual(["Tim", 10]) + })) + + it.effect("updateValues helper", () => + Effect.gen(function*() { + const sql = yield* PgClient.PgClient + const [query, params] = sql`UPDATE people SET name = data.name FROM ${ + sql.updateValues( + [{ name: "Tim" }, { name: "John" }], + "data" + ) + }`.compile() + expect(query).toEqual( + `UPDATE people SET name = data.name FROM (values ($1),($2)) AS data("name")` + ) + expect(params).toEqual(["Tim", "John"]) + })) + + it.effect("updateValues helper returning", () => + Effect.gen(function*() { + const sql = yield* PgClient.PgClient + const [query, params] = sql`UPDATE people SET name = data.name FROM ${ + sql.updateValues( + [{ name: "Tim" }, { name: "John" }], + "data" + ).returning("*") + }`.compile() + expect(query).toEqual( + `UPDATE people SET name = data.name FROM (values ($1),($2)) AS data("name") RETURNING *` + ) + expect(params).toEqual(["Tim", "John"]) + })) + + it.effect("update helper", () => + Effect.gen(function*() { + const sql = yield* PgClient.PgClient + let result = sql`UPDATE people SET ${sql.update({ name: "Tim" })}`.compile() + expect(result[0]).toEqual(`UPDATE people SET "name" = $1`) + expect(result[1]).toEqual(["Tim"]) + + result = sql`UPDATE people SET ${sql.update({ name: "Tim", age: 10 }, ["age"])}`.compile() + expect(result[0]).toEqual(`UPDATE people SET "name" = $1`) + expect(result[1]).toEqual(["Tim"]) + })) + + it.effect("update helper returning", () => + Effect.gen(function*() { + const sql = yield* PgClient.PgClient + const result = sql`UPDATE people SET ${sql.update({ name: "Tim" }).returning("*")}`.compile() + expect(result[0]).toEqual(`UPDATE people SET "name" = $1 RETURNING *`) + expect(result[1]).toEqual(["Tim"]) + })) + + it.effect("array helper", () => + Effect.gen(function*() { + const sql = yield* PgClient.PgClient + const [query, params] = sql`SELECT * FROM ${sql("people")} WHERE id IN ${sql.in([1, 2, "string"])}`.compile() + expect(query).toEqual(`SELECT * FROM "people" WHERE id IN ($1,$2,$3)`) + expect(params).toEqual([1, 2, "string"]) + })) + + it.effect("array helper with column", () => + Effect.gen(function*() { + const sql = yield* PgClient.PgClient + let result = sql`SELECT * FROM ${sql("people")} WHERE ${sql.in("id", [1, 2, "string"])}`.compile() + expect(result[0]).toEqual(`SELECT * FROM "people" WHERE "id" IN ($1,$2,$3)`) + expect(result[1]).toEqual([1, 2, "string"]) + + result = sql`SELECT * FROM ${sql("people")} WHERE ${sql.in("id", [])}`.compile() + expect(result[0]).toEqual(`SELECT * FROM "people" WHERE 1=0`) + expect(result[1]).toEqual([]) + })) + + it.effect("and", () => + Effect.gen(function*() { + const sql = yield* PgClient.PgClient + const now = new Date() + const result = sql`SELECT * FROM ${sql("people")} WHERE ${ + sql.and([ + sql.in("name", ["Tim", "John"]), + sql`created_at < ${now}` + ]) + }`.compile() + expect(result[0]).toEqual(`SELECT * FROM "people" WHERE ("name" IN ($1,$2) AND created_at < $3)`) + expect(result[1]).toEqual(["Tim", "John", now]) + })) + + it.effect("json", () => + Effect.gen(function*() { + const sql = yield* PgClient.PgClient + const [query, params] = sql`SELECT ${sql.json({ a: 1 })}`.compile() + expect(query).toEqual(`SELECT $1`) + expect(params.length).toEqual(1) + })) + + it.effect("json transform", () => + Effect.gen(function*() { + const sql = yield* PgClient.PgClient + const [query, params] = compilerTransform.compile( + sql`SELECT ${sql.json({ aKey: 1 })}`, + false + ) + expect(query).toEqual(`SELECT $1`) + expect(params).toEqual([{ a_key: 1 }]) + })) + + it("transform nested", () => { + assert.deepEqual( + transformsNested.array([ + { + a_key: 1, + nested: [{ b_key: 2 }], + arr_primitive: [1, "2", true] + } + ]) as any, + [ + { + aKey: 1, + nested: [{ bKey: 2 }], + arrPrimitive: [1, "2", true] + } + ] + ) + }) + + it("transform non nested", () => { + assert.deepEqual( + transforms.array([ + { + a_key: 1, + nested: [{ b_key: 2 }], + arr_primitive: [1, "2", true] + } + ]) as any, + [ + { + aKey: 1, + nested: [{ b_key: 2 }], + arrPrimitive: [1, "2", true] + } + ] + ) + + assert.deepEqual( + transforms.array([ + { + json_field: { + test_value: [1, true, null, "text"], + test_nested: { + test_value: [1, true, null, "text"] + } + } + } + ]) as any, + [ + { + jsonField: { + test_value: [1, true, null, "text"], + test_nested: { + test_value: [1, true, null, "text"] + } + } + } + ] + ) + }) + + it.effect("insert fragments", () => + Effect.gen(function*() { + const sql = yield* PgClient.PgClient + const [query, params] = sql`INSERT INTO people ${ + sql.insert({ + name: "Tim", + age: 10, + json: sql.json({ a: 1 }) + }) + }`.compile() + assert.strictEqual( + query, + "INSERT INTO people (\"name\",\"age\",\"json\") VALUES ($1,$2,$3)" + ) + assert.lengthOf(params, 3) + })) + + it.effect("update fragments", () => + Effect.gen(function*() { + const sql = yield* PgClient.PgClient + const now = new Date() + const [query, params] = sql`UPDATE people SET json = data.json FROM ${ + sql.updateValues( + [{ json: sql.json({ a: 1 }) }, { json: sql.json({ b: 1 }) }], + "data" + ) + } WHERE created_at > ${now}`.compile() + assert.strictEqual( + query, + `UPDATE people SET json = data.json FROM (values ($1),($2)) AS data("json") WHERE created_at > $3` + ) + assert.lengthOf(params, 3) + })) + + it.effect("onDialect", () => + Effect.gen(function*() { + const sql = yield* PgClient.PgClient + assert.strictEqual( + sql.onDialect({ + sqlite: () => "A", + pg: () => "B", + mysql: () => "C", + mssql: () => "D", + clickhouse: () => "E" + }), + "B" + ) + assert.strictEqual( + sql.onDialectOrElse({ + orElse: () => "A", + pg: () => "B" + }), + "B" + ) + })) + + it.effect("identifier transform", () => + Effect.gen(function*() { + const sql = yield* PgClient.PgClient + const [query] = compilerTransform.compile( + sql`SELECT * from ${sql("peopleTest")}`, + false + ) + expect(query).toEqual(`SELECT * from "people_test"`) + })) +}) + +it.layer(PgContainer.layerClientWithTransforms, { timeout: "30 seconds" })("PgClient transforms", (it) => { + it.effect("insert helper", () => + Effect.gen(function*() { + const sql = yield* PgClient.PgClient + yield* sql`CREATE TABLE people (first_name TEXT, age INT)` + yield* sql`INSERT INTO people ${sql.insert({ firstName: "Tim", age: 10 })}` + const people = yield* sql<{ + firstName: string + age: number + }>`SELECT * FROM people` + expect(people).toEqual([{ firstName: "Tim", age: 10 }]) + })) + + it.effect("insert helper withoutTransforms", () => + Effect.gen(function*() { + const sql = (yield* PgClient.PgClient).withoutTransforms() + const [query, params] = sql`INSERT INTO people ${sql.insert({ first_name: "Tim", age: 10 })}`.compile() + expect(query).toEqual(`INSERT INTO people ("first_name","age") VALUES ($1,$2)`) + expect(params).toEqual(["Tim", 10]) + })) +}) diff --git a/packages/sql/pg/test/utils.ts b/packages/sql/pg/test/utils.ts new file mode 100644 index 0000000000..bece5b3d4d --- /dev/null +++ b/packages/sql/pg/test/utils.ts @@ -0,0 +1,41 @@ +import { PgClient } from "@effect/sql-pg" +import { PostgreSqlContainer } from "@testcontainers/postgresql" +import { Effect, Layer, ServiceMap } from "effect" +import { Data, Redacted } from "effect/data" +import { String } from "effect/primitives" + +export class ContainerError extends Data.TaggedError("ContainerError")<{ + cause: unknown +}> {} + +export class PgContainer extends ServiceMap.Key()("test/PgContainer", { + make: Effect.acquireRelease( + Effect.tryPromise({ + try: () => new PostgreSqlContainer("postgres:alpine").start(), + catch: (cause) => new ContainerError({ cause }) + }), + (container) => Effect.promise(() => container.stop()) + ) +}) { + static layer = Layer.effect(this)(this.make) + + static layerClient = Layer.unwrap( + Effect.gen(function*() { + const container = yield* PgContainer + return PgClient.layer({ + url: Redacted.make(container.getConnectionUri()) + }) + }) + ).pipe(Layer.provide(this.layer)) + + static layerClientWithTransforms = Layer.unwrap( + Effect.gen(function*() { + const container = yield* PgContainer + return PgClient.layer({ + url: Redacted.make(container.getConnectionUri()), + transformResultNames: String.snakeToCamel, + transformQueryNames: String.camelToSnake + }) + }) + ).pipe(Layer.provide(this.layer)) +} diff --git a/packages/sql/pg/tsconfig.build.json b/packages/sql/pg/tsconfig.build.json new file mode 100644 index 0000000000..e738132ff9 --- /dev/null +++ b/packages/sql/pg/tsconfig.build.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "./tsconfig.src.json", + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", + "outDir": "dist", + "stripInternal": true + } +} diff --git a/packages/sql/pg/tsconfig.json b/packages/sql/pg/tsconfig.json new file mode 100644 index 0000000000..11922f5b68 --- /dev/null +++ b/packages/sql/pg/tsconfig.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": [], + "references": [{ "path": "tsconfig.src.json" }, { "path": "tsconfig.test.json" }] +} diff --git a/packages/sql/pg/tsconfig.src.json b/packages/sql/pg/tsconfig.src.json new file mode 100644 index 0000000000..4395091604 --- /dev/null +++ b/packages/sql/pg/tsconfig.src.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["src"], + "references": [ + { "path": "../../effect/tsconfig.src.json" }, + { "path": "../../platform-node-shared/tsconfig.src.json" } + ], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", + "outDir": ".tsbuildinfo/src", + "rootDir": "src", + "types": ["node"] + } +} diff --git a/packages/sql/pg/tsconfig.test.json b/packages/sql/pg/tsconfig.test.json new file mode 100644 index 0000000000..8187f5ca51 --- /dev/null +++ b/packages/sql/pg/tsconfig.test.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["test/**/*.ts", "test/**/*.json"], + "references": [{ "path": "tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/test.tsbuildinfo", + "outDir": ".tsbuildinfo/test", + "rootDir": "test", + "noEmit": true, + "erasableSyntaxOnly": false, + "resolveJsonModule": true, + "baseUrl": ".", + "paths": { + "@effect/sql-pg": ["src/index.ts"], + "@effect/sql-pg/*": ["src/*/index.ts", "src/*.ts"] + }, + "plugins": [ + { + "name": "@effect/language-service", + "namespaceImportPackages": [] + } + ] + } +} diff --git a/packages/sql/pg/vitest.config.ts b/packages/sql/pg/vitest.config.ts new file mode 100644 index 0000000000..c8a52c1826 --- /dev/null +++ b/packages/sql/pg/vitest.config.ts @@ -0,0 +1,6 @@ +import { mergeConfig, type ViteUserConfig } from "vitest/config" +import shared from "../../../vitest.shared.ts" + +const config: ViteUserConfig = {} + +export default mergeConfig(shared, config) diff --git a/packages/sql/sqlite-bun/LICENSE b/packages/sql/sqlite-bun/LICENSE new file mode 100644 index 0000000000..7f6fe480f7 --- /dev/null +++ b/packages/sql/sqlite-bun/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023-present The Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/sql/sqlite-bun/README.md b/packages/sql/sqlite-bun/README.md new file mode 100644 index 0000000000..4062c8c4c7 --- /dev/null +++ b/packages/sql/sqlite-bun/README.md @@ -0,0 +1,7 @@ +# `@effect/sql-sqlite-bun` + +An `@effect/sql` implementation using the `bun:sqlite` library. + +## Documentation + +- **API Reference**: [View the full documentation](https://effect-ts.github.io/effect/docs/sql-sqlite-bun). diff --git a/packages/sql/sqlite-bun/docgen.json b/packages/sql/sqlite-bun/docgen.json new file mode 100644 index 0000000000..8a5d70b590 --- /dev/null +++ b/packages/sql/sqlite-bun/docgen.json @@ -0,0 +1,20 @@ +{ + "$schema": "../../node_modules/@effect/docgen/schema.json", + "srcLink": "https://github.com/Effect-TS/effect/tree/main/packages/sql/sqlite-bun/src/", + "exclude": ["src/internal/**/*.ts"], + "examplesCompilerOptions": { + "noEmit": true, + "strict": true, + "skipLibCheck": true, + "moduleResolution": "Bundler", + "module": "ES2022", + "target": "ES2022", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "rewriteRelativeImportExtensions": true, + "allowImportingTsExtensions": true, + "paths": { + "effect": ["../../../effect/src/index.js"], + "effect/*": ["../../../effect/src/*.js"] + } + } +} diff --git a/packages/sql/sqlite-bun/examples/Client.test.ts b/packages/sql/sqlite-bun/examples/Client.test.ts new file mode 100644 index 0000000000..2fcdcae32f --- /dev/null +++ b/packages/sql/sqlite-bun/examples/Client.test.ts @@ -0,0 +1,31 @@ +import { BunFileSystem } from "@effect/platform-bun" +import { describe, expect, test } from "bun:test" +import { Effect, pipe } from "effect" +import { FileSystem } from "effect/platform" +import { Reactivity } from "effect/unstable/reactivity" +import { SqliteClient } from "../src/index.ts" + +const makeClient = Effect.gen(function*() { + const fs = yield* FileSystem.FileSystem + const dir = yield* fs.makeTempDirectoryScoped() + return yield* SqliteClient.make({ + filename: dir + "/test.db" + }) +}).pipe(Effect.provide([BunFileSystem.layer, Reactivity.layer])) + +describe("Client", () => { + test("works", () => + Effect.gen(function*() { + const sql = yield* makeClient + yield* sql`CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)` + yield* sql`INSERT INTO test (name) VALUES ('hello')` + let rows = yield* sql`SELECT * FROM test` + expect(rows).toEqual([{ id: 1, name: "hello" }]) + yield* pipe(sql`INSERT INTO test (name) VALUES ('world')`, sql.withTransaction) + rows = yield* sql`SELECT * FROM test` + expect(rows).toEqual([ + { id: 1, name: "hello" }, + { id: 2, name: "world" } + ]) + }).pipe(Effect.scoped, Effect.runPromise)) +}) diff --git a/packages/sql/sqlite-bun/package.json b/packages/sql/sqlite-bun/package.json new file mode 100644 index 0000000000..f47f08cbec --- /dev/null +++ b/packages/sql/sqlite-bun/package.json @@ -0,0 +1,66 @@ +{ + "name": "@effect/sql-sqlite-bun", + "version": "0.45.1", + "type": "module", + "license": "MIT", + "description": "A SQLite toolkit for Effect", + "homepage": "https://effect.website", + "repository": { + "type": "git", + "url": "https://github.com/Effect-TS/effect.git", + "directory": "packages/sql/sqlite-bun" + }, + "bugs": { + "url": "https://github.com/Effect-TS/effect/issues" + }, + "tags": [ + "typescript", + "sql", + "database" + ], + "keywords": [ + "typescript", + "sql", + "database" + ], + "sideEffects": [], + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts", + "./*": "./src/*.ts", + "./internal/*": null, + "./*/index": null + }, + "files": [ + "src/**/*.ts", + "dist/**/*.js", + "dist/**/*.js.map", + "dist/**/*.d.ts", + "dist/**/*.d.ts.map" + ], + "publishConfig": { + "provenance": true, + "exports": { + "./package.json": "./package.json", + ".": "./dist/index.js", + "./*": "./dist/*.js", + "./internal/*": null, + "./*/index": null + } + }, + "scripts": { + "codegen": "build-utils prepare-v4", + "build": "tsc -b tsconfig.build.json && babel dist --plugins annotate-pure-calls --out-dir dist --source-maps", + "check": "tsc -b tsconfig.json", + "test": "vitest", + "coverage": "vitest --coverage" + }, + "devDependencies": { + "@types/bun": "^1.2.21", + "effect": "workspace:^", + "@effect/platform-bun": "workspace:^" + }, + "peerDependencies": { + "effect": "workspace:^" + } +} diff --git a/packages/sql/sqlite-bun/src/SqliteClient.ts b/packages/sql/sqlite-bun/src/SqliteClient.ts new file mode 100644 index 0000000000..13624b053d --- /dev/null +++ b/packages/sql/sqlite-bun/src/SqliteClient.ts @@ -0,0 +1,216 @@ +/** + * @since 1.0.0 + */ +import { Database } from "bun:sqlite" +import * as Config from "effect/config/Config" +import * as Effect from "effect/Effect" +import * as Fiber from "effect/Fiber" +import { identity } from "effect/Function" +import * as Layer from "effect/Layer" +import * as Scope from "effect/Scope" +import * as ServiceMap from "effect/ServiceMap" +import * as Stream from "effect/stream/Stream" +import * as Reactivity from "effect/unstable/reactivity/Reactivity" +import * as Client from "effect/unstable/sql/SqlClient" +import type { Connection } from "effect/unstable/sql/SqlConnection" +import { SqlError } from "effect/unstable/sql/SqlError" +import * as Statement from "effect/unstable/sql/Statement" + +const ATTR_DB_SYSTEM_NAME = "db.system.name" + +/** + * @category type ids + * @since 1.0.0 + */ +export const TypeId: TypeId = "~@effect/sql-sqlite-bun/SqliteClient" + +/** + * @category type ids + * @since 1.0.0 + */ +export type TypeId = "~@effect/sql-sqlite-bun/SqliteClient" + +/** + * @category models + * @since 1.0.0 + */ +export interface SqliteClient extends Client.SqlClient { + readonly [TypeId]: TypeId + readonly config: SqliteClientConfig + readonly export: Effect.Effect + readonly loadExtension: (path: string) => Effect.Effect + + /** Not supported in sqlite */ + readonly updateValues: never +} + +/** + * @category tags + * @since 1.0.0 + */ +export const SqliteClient = ServiceMap.Key("@effect/sql-sqlite-bun/Client") + +/** + * @category models + * @since 1.0.0 + */ +export interface SqliteClientConfig { + readonly filename: string + readonly readonly?: boolean | undefined + readonly create?: boolean | undefined + readonly readwrite?: boolean | undefined + readonly disableWAL?: boolean | undefined + + readonly spanAttributes?: Record | undefined + + readonly transformResultNames?: ((str: string) => string) | undefined + readonly transformQueryNames?: ((str: string) => string) | undefined +} + +interface SqliteConnection extends Connection { + readonly export: Effect.Effect + readonly loadExtension: (path: string) => Effect.Effect +} + +/** + * @category constructor + * @since 1.0.0 + */ +export const make = ( + options: SqliteClientConfig +): Effect.Effect => + Effect.gen(function*() { + const compiler = Statement.makeCompilerSqlite(options.transformQueryNames) + const transformRows = options.transformResultNames ? + Statement.defaultTransforms( + options.transformResultNames + ).array : + undefined + + const makeConnection = Effect.gen(function*() { + const db = new Database(options.filename, { + readonly: options.readonly, + readwrite: options.readwrite ?? true, + create: options.create ?? true + } as any) + yield* Effect.addFinalizer(() => Effect.sync(() => db.close())) + + if (options.disableWAL !== true) { + db.run("PRAGMA journal_mode = WAL;") + } + + const run = ( + sql: string, + params: ReadonlyArray = [] + ) => + Effect.try({ + try: () => (db.query(sql).all(...(params as any)) ?? []) as Array, + catch: (cause) => new SqlError({ cause, message: "Failed to execute statement" }) + }) + + const runValues = ( + sql: string, + params: ReadonlyArray = [] + ) => + Effect.try({ + try: () => (db.query(sql).values(...(params as any)) ?? []) as Array, + catch: (cause) => new SqlError({ cause, message: "Failed to execute statement" }) + }) + + return identity({ + execute(sql, params, transformRows) { + return transformRows + ? Effect.map(run(sql, params), transformRows) + : run(sql, params) + }, + executeRaw(sql, params) { + return run(sql, params) + }, + executeValues(sql, params) { + return runValues(sql, params) + }, + executeUnprepared(sql, params, transformRows) { + return this.execute(sql, params, transformRows) + }, + executeStream(_sql, _params) { + return Stream.die("executeStream not implemented") + }, + export: Effect.try({ + try: () => db.serialize(), + catch: (cause) => new SqlError({ cause, message: "Failed to export database" }) + }), + loadExtension: (path) => + Effect.try({ + try: () => db.loadExtension(path), + catch: (cause) => new SqlError({ cause, message: "Failed to load extension" }) + }) + }) + }) + + const semaphore = yield* Effect.makeSemaphore(1) + const connection = yield* makeConnection + + const acquirer = semaphore.withPermits(1)(Effect.succeed(connection)) + const transactionAcquirer = Effect.uninterruptibleMask((restore) => { + const fiber = Fiber.getCurrent()! + const scope = ServiceMap.unsafeGet(fiber.services, Scope.Scope) + return Effect.as( + Effect.tap( + restore(semaphore.take(1)), + () => Scope.addFinalizer(scope, semaphore.release(1)) + ), + connection + ) + }) + + return Object.assign( + (yield* Client.make({ + acquirer, + compiler, + transactionAcquirer, + spanAttributes: [ + ...(options.spanAttributes ? Object.entries(options.spanAttributes) : []), + [ATTR_DB_SYSTEM_NAME, "sqlite"] + ], + transformRows + })) as SqliteClient, + { + [TypeId]: TypeId as TypeId, + config: options, + export: Effect.flatMap(acquirer, (_) => _.export), + loadExtension: (path: string) => Effect.flatMap(acquirer, (_) => _.loadExtension(path)) + } + ) + }) + +/** + * @category layers + * @since 1.0.0 + */ +export const layerConfig = ( + config: Config.Wrap +): Layer.Layer => + Layer.effectServices( + Config.unwrap(config).asEffect().pipe( + Effect.flatMap(make), + Effect.map((client) => + ServiceMap.make(SqliteClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + ) + ) + ) + ).pipe(Layer.provide(Reactivity.layer)) + +/** + * @category layers + * @since 1.0.0 + */ +export const layer = ( + config: SqliteClientConfig +): Layer.Layer => + Layer.effectServices( + Effect.map(make(config), (client) => + ServiceMap.make(SqliteClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + )) + ).pipe(Layer.provide(Reactivity.layer)) diff --git a/packages/sql/sqlite-bun/src/SqliteMigrator.ts b/packages/sql/sqlite-bun/src/SqliteMigrator.ts new file mode 100644 index 0000000000..203069125c --- /dev/null +++ b/packages/sql/sqlite-bun/src/SqliteMigrator.ts @@ -0,0 +1,79 @@ +/** + * @since 1.0.0 + */ +import type * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" +import * as Migrator from "effect/unstable/sql/Migrator" +import type * as Client from "effect/unstable/sql/SqlClient" +import type { SqlError } from "effect/unstable/sql/SqlError" + +/** + * @since 1.0.0 + */ +export * from "effect/unstable/sql/Migrator" + +/** + * @category constructor + * @since 1.0.0 + */ +export const run: ( + options: Migrator.MigratorOptions +) => Effect.Effect< + ReadonlyArray, + Migrator.MigrationError | SqlError, + Client.SqlClient | R2 +> = Migrator.make({ + // dumpSchema(path, table) { + // const dump = (args: Array) => + // Effect.gen(function*() { + // const sql = yield* SqliteClient + // const dump = yield* pipe( + // Command.make("sqlite3", (sql as SqliteClient).config.filename, ...args), + // Command.string + // ) + // return dump.replace(/^create table sqlite_sequence\(.*$/im, "") + // .replace(/\n{2,}/gm, "\n\n") + // .trim() + // }).pipe( + // Effect.mapError((error) => new Migrator.MigrationError({ reason: "failed", message: error.message })) + // ) + // + // const dumpSchema = dump([".schema"]) + // + // const dumpMigrations = dump([ + // "--cmd", + // `.mode insert ${table}`, + // `select * from ${table}` + // ]) + // + // const dumpAll = Effect.map( + // Effect.all([dumpSchema, dumpMigrations], { concurrency: 2 }), + // ([schema, migrations]) => schema + "\n\n" + migrations + // ) + // + // const dumpFile = (file: string) => + // Effect.gen(function*() { + // const fs = yield* FileSystem + // const path = yield* Path + // const dump = yield* dumpAll + // yield* fs.makeDirectory(path.dirname(file), { recursive: true }) + // yield* fs.writeFileString(file, dump) + // }).pipe( + // Effect.mapError((error) => new Migrator.MigrationError({ reason: "failed", message: error.message })) + // ) + // + // return dumpFile(path) + // } +}) + +/** + * @category constructor + * @since 1.0.0 + */ +export const layer = ( + options: Migrator.MigratorOptions +): Layer.Layer< + never, + SqlError | Migrator.MigrationError, + Client.SqlClient | R +> => Layer.effectDiscard(run(options)) diff --git a/packages/sql/sqlite-bun/src/index.ts b/packages/sql/sqlite-bun/src/index.ts new file mode 100644 index 0000000000..09e759128f --- /dev/null +++ b/packages/sql/sqlite-bun/src/index.ts @@ -0,0 +1,13 @@ +/** + * @since 1.0.0 + */ + +/** + * @since 1.0.0 + */ +export * as SqliteClient from "./SqliteClient.ts" + +/** + * @since 1.0.0 + */ +export * as SqliteMigrator from "./SqliteMigrator.ts" diff --git a/packages/sql/sqlite-bun/src/index.ts.tpl b/packages/sql/sqlite-bun/src/index.ts.tpl new file mode 100644 index 0000000000..b66408871c --- /dev/null +++ b/packages/sql/sqlite-bun/src/index.ts.tpl @@ -0,0 +1,3 @@ +/** + * @since 1.0.0 + */ diff --git a/packages/sql/sqlite-bun/test/Client.test.ts b/packages/sql/sqlite-bun/test/Client.test.ts new file mode 100644 index 0000000000..fc3285a360 --- /dev/null +++ b/packages/sql/sqlite-bun/test/Client.test.ts @@ -0,0 +1,6 @@ +import { describe, it } from "@effect/vitest" +import { Effect } from "effect" + +describe("Client", () => { + it.effect("should work", () => Effect.void) +}) diff --git a/packages/sql/sqlite-bun/tsconfig.build.json b/packages/sql/sqlite-bun/tsconfig.build.json new file mode 100644 index 0000000000..e738132ff9 --- /dev/null +++ b/packages/sql/sqlite-bun/tsconfig.build.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "./tsconfig.src.json", + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", + "outDir": "dist", + "stripInternal": true + } +} diff --git a/packages/sql/sqlite-bun/tsconfig.examples.json b/packages/sql/sqlite-bun/tsconfig.examples.json new file mode 100644 index 0000000000..5a3b211008 --- /dev/null +++ b/packages/sql/sqlite-bun/tsconfig.examples.json @@ -0,0 +1,26 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["examples/**/*.ts"], + "references": [{ "path": "tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/examples.tsbuildinfo", + "outDir": ".tsbuildinfo/examples", + "rootDir": "examples", + "noEmit": true, + "erasableSyntaxOnly": false, + "resolveJsonModule": true, + "baseUrl": ".", + "paths": { + "@effect/sql-sqlite-bun": ["src/index.ts"], + "@effect/sql-sqlite-bun/*": ["src/*/index.ts", "src/*.ts"] + }, + "types": ["bun"], + "plugins": [ + { + "name": "@effect/language-service", + "namespaceImportPackages": [] + } + ] + } +} diff --git a/packages/sql/sqlite-bun/tsconfig.json b/packages/sql/sqlite-bun/tsconfig.json new file mode 100644 index 0000000000..27caf10ef7 --- /dev/null +++ b/packages/sql/sqlite-bun/tsconfig.json @@ -0,0 +1,10 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": [], + "references": [ + { "path": "tsconfig.src.json" }, + { "path": "tsconfig.test.json" }, + { "path": "tsconfig.examples.json" } + ] +} diff --git a/packages/sql/sqlite-bun/tsconfig.src.json b/packages/sql/sqlite-bun/tsconfig.src.json new file mode 100644 index 0000000000..27dc04db57 --- /dev/null +++ b/packages/sql/sqlite-bun/tsconfig.src.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["src"], + "references": [{ "path": "../../effect/tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", + "outDir": ".tsbuildinfo/src", + "rootDir": "src", + "types": ["bun"] + } +} diff --git a/packages/sql/sqlite-bun/tsconfig.test.json b/packages/sql/sqlite-bun/tsconfig.test.json new file mode 100644 index 0000000000..b371257819 --- /dev/null +++ b/packages/sql/sqlite-bun/tsconfig.test.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["test/**/*.ts", "test/**/*.json"], + "references": [{ "path": "tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/test.tsbuildinfo", + "outDir": ".tsbuildinfo/test", + "rootDir": "test", + "noEmit": true, + "erasableSyntaxOnly": false, + "resolveJsonModule": true, + "baseUrl": ".", + "paths": { + "@effect/sql-sqlite-bun": ["src/index.ts"], + "@effect/sql-sqlite-bun/*": ["src/*/index.ts", "src/*.ts"] + }, + "plugins": [ + { + "name": "@effect/language-service", + "namespaceImportPackages": [] + } + ] + } +} diff --git a/packages/sql/sqlite-bun/vitest.config.ts b/packages/sql/sqlite-bun/vitest.config.ts new file mode 100644 index 0000000000..c8a52c1826 --- /dev/null +++ b/packages/sql/sqlite-bun/vitest.config.ts @@ -0,0 +1,6 @@ +import { mergeConfig, type ViteUserConfig } from "vitest/config" +import shared from "../../../vitest.shared.ts" + +const config: ViteUserConfig = {} + +export default mergeConfig(shared, config) diff --git a/packages/sql/sqlite-do/LICENSE b/packages/sql/sqlite-do/LICENSE new file mode 100644 index 0000000000..7f6fe480f7 --- /dev/null +++ b/packages/sql/sqlite-do/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023-present The Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/sql/sqlite-do/README.md b/packages/sql/sqlite-do/README.md new file mode 100644 index 0000000000..e3c47c190a --- /dev/null +++ b/packages/sql/sqlite-do/README.md @@ -0,0 +1,7 @@ +# `@effect/sql-sqlite-do` + +An `@effect/sql` implementation for Cloudflare Durable Objects sqlite storage. + +## Documentation + +- **API Reference**: [View the full documentation](https://effect-ts.github.io/effect/docs/sql-sqlite-do). diff --git a/packages/sql/sqlite-do/docgen.json b/packages/sql/sqlite-do/docgen.json new file mode 100644 index 0000000000..fbd9b4217c --- /dev/null +++ b/packages/sql/sqlite-do/docgen.json @@ -0,0 +1,20 @@ +{ + "$schema": "../../node_modules/@effect/docgen/schema.json", + "srcLink": "https://github.com/Effect-TS/effect/tree/main/packages/sql/do/src/", + "exclude": ["src/internal/**/*.ts"], + "examplesCompilerOptions": { + "noEmit": true, + "strict": true, + "skipLibCheck": true, + "moduleResolution": "Bundler", + "module": "ES2022", + "target": "ES2022", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "rewriteRelativeImportExtensions": true, + "allowImportingTsExtensions": true, + "paths": { + "effect": ["../../../effect/src/index.js"], + "effect/*": ["../../../effect/src/*.js"] + } + } +} diff --git a/packages/sql/sqlite-do/package.json b/packages/sql/sqlite-do/package.json new file mode 100644 index 0000000000..033973f745 --- /dev/null +++ b/packages/sql/sqlite-do/package.json @@ -0,0 +1,65 @@ +{ + "name": "@effect/sql-sqlite-do", + "version": "0.22.1", + "type": "module", + "license": "MIT", + "description": "A SQLite toolkit for Effect", + "homepage": "https://effect.website", + "repository": { + "type": "git", + "url": "https://github.com/Effect-TS/effect.git", + "directory": "packages/sql/sqlite-do" + }, + "bugs": { + "url": "https://github.com/Effect-TS/effect/issues" + }, + "tags": [ + "typescript", + "sql", + "database" + ], + "keywords": [ + "typescript", + "sql", + "database" + ], + "sideEffects": [], + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts", + "./*": "./src/*.ts", + "./internal/*": null, + "./*/index": null + }, + "files": [ + "src/**/*.ts", + "dist/**/*.js", + "dist/**/*.js.map", + "dist/**/*.d.ts", + "dist/**/*.d.ts.map" + ], + "publishConfig": { + "provenance": true, + "exports": { + "./package.json": "./package.json", + ".": "./dist/index.js", + "./*": "./dist/*.js", + "./internal/*": null, + "./*/index": null + } + }, + "scripts": { + "codegen": "build-utils prepare-v4", + "build": "tsc -b tsconfig.build.json && babel dist --plugins annotate-pure-calls --out-dir dist --source-maps", + "check": "tsc -b tsconfig.json", + "test": "vitest", + "coverage": "vitest --coverage" + }, + "devDependencies": { + "@cloudflare/workers-types": "^4.20250515.0", + "effect": "workspace:^" + }, + "peerDependencies": { + "effect": "workspace:^" + } +} diff --git a/packages/sql/sqlite-do/src/SqliteClient.ts b/packages/sql/sqlite-do/src/SqliteClient.ts new file mode 100644 index 0000000000..64cf72a702 --- /dev/null +++ b/packages/sql/sqlite-do/src/SqliteClient.ts @@ -0,0 +1,216 @@ +/** + * @since 1.0.0 + */ +import type { SqlStorage } from "@cloudflare/workers-types" +import * as Config from "effect/config/Config" +import * as Effect from "effect/Effect" +import * as Fiber from "effect/Fiber" +import { identity } from "effect/Function" +import * as Layer from "effect/Layer" +import * as Scope from "effect/Scope" +import * as ServiceMap from "effect/ServiceMap" +import * as Stream from "effect/stream/Stream" +import * as Reactivity from "effect/unstable/reactivity/Reactivity" +import * as Client from "effect/unstable/sql/SqlClient" +import type { Connection } from "effect/unstable/sql/SqlConnection" +import { SqlError } from "effect/unstable/sql/SqlError" +import * as Statement from "effect/unstable/sql/Statement" + +const ATTR_DB_SYSTEM_NAME = "db.system.name" + +/** + * @category type ids + * @since 1.0.0 + */ +export const TypeId: TypeId = "~@effect/sql-sqlite-do/SqliteClient" + +/** + * @category type ids + * @since 1.0.0 + */ +export type TypeId = "~@effect/sql-sqlite-do/SqliteClient" + +/** + * @category models + * @since 1.0.0 + */ +export interface SqliteClient extends Client.SqlClient { + readonly [TypeId]: TypeId + readonly config: SqliteClientConfig + + /** Not supported in sqlite */ + readonly updateValues: never +} + +/** + * @category tags + * @since 1.0.0 + */ +export const SqliteClient = ServiceMap.Key("@effect/sql-sqlite-do/SqliteClient") + +/** + * @category models + * @since 1.0.0 + */ +export interface SqliteClientConfig { + readonly db: SqlStorage + readonly spanAttributes?: Record | undefined + + readonly transformResultNames?: ((str: string) => string) | undefined + readonly transformQueryNames?: ((str: string) => string) | undefined +} + +/** + * @category constructor + * @since 1.0.0 + */ +export const make = ( + options: SqliteClientConfig +): Effect.Effect => + Effect.gen(function*() { + const compiler = Statement.makeCompilerSqlite(options.transformQueryNames) + const transformRows = options.transformResultNames + ? Statement.defaultTransforms(options.transformResultNames).array + : undefined + + const makeConnection = Effect.gen(function*() { + const db = options.db + + function* runIterator( + sql: string, + params: ReadonlyArray = [] + ) { + const cursor = db.exec(sql, ...params) + const columns = cursor.columnNames + for (const result of cursor.raw()) { + const obj: any = {} + for (let i = 0; i < columns.length; i++) { + const value = result[i] + obj[columns[i]] = value instanceof ArrayBuffer ? new Uint8Array(value) : value + } + yield obj + } + } + + const runStatement = ( + sql: string, + params: ReadonlyArray = [] + ): Effect.Effect, SqlError, never> => + Effect.try({ + try: () => Array.from(runIterator(sql, params)), + catch: (cause) => new SqlError({ cause, message: `Failed to execute statement` }) + }) + + const runValues = ( + sql: string, + params: ReadonlyArray = [] + ): Effect.Effect, SqlError, never> => + Effect.try({ + try: () => + Array.from(db.exec(sql, ...params).raw(), (row) => { + for (let i = 0; i < row.length; i++) { + const value = row[i] + if (value instanceof ArrayBuffer) { + row[i] = new Uint8Array(value) as any + } + } + return row + }), + catch: (cause) => new SqlError({ cause, message: `Failed to execute statement` }) + }) + + return identity({ + execute(sql, params, transformRows) { + return transformRows + ? Effect.map(runStatement(sql, params), transformRows) + : runStatement(sql, params) + }, + executeRaw(sql, params) { + return runStatement(sql, params) + }, + executeValues(sql, params) { + return runValues(sql, params) + }, + executeUnprepared(sql, params, transformRows) { + return transformRows + ? Effect.map(runStatement(sql, params), transformRows) + : runStatement(sql, params) + }, + executeStream(sql, params, transformRows) { + return Stream.suspend(() => { + const iterator = runIterator(sql, params) + return Stream.fromIteratorSucceed(iterator, 128) + }).pipe( + transformRows + ? Stream.mapArray((chunk) => transformRows(chunk) as any) + : identity + ) + } + }) + }) + + const semaphore = yield* Effect.makeSemaphore(1) + const connection = yield* makeConnection + + const acquirer = semaphore.withPermits(1)(Effect.succeed(connection)) + const transactionAcquirer = Effect.uninterruptibleMask((restore) => { + const fiber = Fiber.getCurrent()! + const scope = ServiceMap.unsafeGet(fiber.services, Scope.Scope) + return Effect.as( + Effect.tap( + restore(semaphore.take(1)), + () => Scope.addFinalizer(scope, semaphore.release(1)) + ), + connection + ) + }) + + return Object.assign( + (yield* Client.make({ + acquirer, + compiler, + transactionAcquirer, + spanAttributes: [ + ...(options.spanAttributes ? Object.entries(options.spanAttributes) : []), + [ATTR_DB_SYSTEM_NAME, "sqlite"] + ], + transformRows + })) as SqliteClient, + { + [TypeId]: TypeId as TypeId, + config: options + } + ) + }) + +/** + * @category layers + * @since 1.0.0 + */ +export const layerConfig = ( + config: Config.Wrap +): Layer.Layer => + Layer.effectServices( + Config.unwrap(config).asEffect().pipe( + Effect.flatMap(make), + Effect.map((client) => + ServiceMap.make(SqliteClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + ) + ) + ) + ).pipe(Layer.provide(Reactivity.layer)) + +/** + * @category layers + * @since 1.0.0 + */ +export const layer = ( + config: SqliteClientConfig +): Layer.Layer => + Layer.effectServices( + Effect.map(make(config), (client) => + ServiceMap.make(SqliteClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + )) + ).pipe(Layer.provide(Reactivity.layer)) diff --git a/packages/sql/sqlite-do/src/SqliteMigrator.ts b/packages/sql/sqlite-do/src/SqliteMigrator.ts new file mode 100644 index 0000000000..06920a0872 --- /dev/null +++ b/packages/sql/sqlite-do/src/SqliteMigrator.ts @@ -0,0 +1,33 @@ +/** + * @since 1.0.0 + */ +import type * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" +import * as Migrator from "effect/unstable/sql/Migrator" +import type * as Client from "effect/unstable/sql/SqlClient" +import type { SqlError } from "effect/unstable/sql/SqlError" + +/** + * @since 1.0.0 + */ +export * from "effect/unstable/sql/Migrator" + +/** + * @category constructor + * @since 1.0.0 + */ +export const run: ( + { loader, schemaDirectory, table }: Migrator.MigratorOptions +) => Effect.Effect< + ReadonlyArray, + Migrator.MigrationError | SqlError, + Client.SqlClient | R2 +> = Migrator.make({}) + +/** + * @category constructor + * @since 1.0.0 + */ +export const layer = ( + options: Migrator.MigratorOptions +): Layer.Layer => Layer.effectDiscard(run(options)) diff --git a/packages/sql/sqlite-do/src/index.ts b/packages/sql/sqlite-do/src/index.ts new file mode 100644 index 0000000000..09e759128f --- /dev/null +++ b/packages/sql/sqlite-do/src/index.ts @@ -0,0 +1,13 @@ +/** + * @since 1.0.0 + */ + +/** + * @since 1.0.0 + */ +export * as SqliteClient from "./SqliteClient.ts" + +/** + * @since 1.0.0 + */ +export * as SqliteMigrator from "./SqliteMigrator.ts" diff --git a/packages/sql/sqlite-do/src/index.ts.tpl b/packages/sql/sqlite-do/src/index.ts.tpl new file mode 100644 index 0000000000..b66408871c --- /dev/null +++ b/packages/sql/sqlite-do/src/index.ts.tpl @@ -0,0 +1,3 @@ +/** + * @since 1.0.0 + */ diff --git a/packages/sql/sqlite-do/test/Client.test.ts b/packages/sql/sqlite-do/test/Client.test.ts new file mode 100644 index 0000000000..fc3285a360 --- /dev/null +++ b/packages/sql/sqlite-do/test/Client.test.ts @@ -0,0 +1,6 @@ +import { describe, it } from "@effect/vitest" +import { Effect } from "effect" + +describe("Client", () => { + it.effect("should work", () => Effect.void) +}) diff --git a/packages/sql/sqlite-do/tsconfig.build.json b/packages/sql/sqlite-do/tsconfig.build.json new file mode 100644 index 0000000000..e738132ff9 --- /dev/null +++ b/packages/sql/sqlite-do/tsconfig.build.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "./tsconfig.src.json", + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", + "outDir": "dist", + "stripInternal": true + } +} diff --git a/packages/sql/sqlite-do/tsconfig.json b/packages/sql/sqlite-do/tsconfig.json new file mode 100644 index 0000000000..11922f5b68 --- /dev/null +++ b/packages/sql/sqlite-do/tsconfig.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": [], + "references": [{ "path": "tsconfig.src.json" }, { "path": "tsconfig.test.json" }] +} diff --git a/packages/sql/sqlite-do/tsconfig.src.json b/packages/sql/sqlite-do/tsconfig.src.json new file mode 100644 index 0000000000..1fdbb717d9 --- /dev/null +++ b/packages/sql/sqlite-do/tsconfig.src.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["src"], + "references": [{ "path": "../../effect/tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", + "outDir": ".tsbuildinfo/src", + "rootDir": "src", + "types": ["node"] + } +} diff --git a/packages/sql/sqlite-do/tsconfig.test.json b/packages/sql/sqlite-do/tsconfig.test.json new file mode 100644 index 0000000000..bf18788888 --- /dev/null +++ b/packages/sql/sqlite-do/tsconfig.test.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["test/**/*.ts", "test/**/*.json"], + "references": [{ "path": "tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/test.tsbuildinfo", + "outDir": ".tsbuildinfo/test", + "rootDir": "test", + "noEmit": true, + "erasableSyntaxOnly": false, + "resolveJsonModule": true, + "baseUrl": ".", + "paths": { + "@effect/sql-do": ["src/index.ts"], + "@effect/sql-do/*": ["src/*/index.ts", "src/*.ts"] + }, + "plugins": [ + { + "name": "@effect/language-service", + "namespaceImportPackages": [] + } + ] + } +} diff --git a/packages/sql/sqlite-do/vitest.config.ts b/packages/sql/sqlite-do/vitest.config.ts new file mode 100644 index 0000000000..c8a52c1826 --- /dev/null +++ b/packages/sql/sqlite-do/vitest.config.ts @@ -0,0 +1,6 @@ +import { mergeConfig, type ViteUserConfig } from "vitest/config" +import shared from "../../../vitest.shared.ts" + +const config: ViteUserConfig = {} + +export default mergeConfig(shared, config) diff --git a/packages/sql/sqlite-node/CHANGELOG.md b/packages/sql/sqlite-node/CHANGELOG.md new file mode 100644 index 0000000000..3a51378f02 --- /dev/null +++ b/packages/sql/sqlite-node/CHANGELOG.md @@ -0,0 +1,2815 @@ +# @effect/sql-sqlite-node + +## 0.45.1 + +### Patch Changes + +- [#5397](https://github.com/Effect-TS/effect/pull/5397) [`0e46e24`](https://github.com/Effect-TS/effect/commit/0e46e24c24e9edb8bf2e29835a94013e9c34d034) Thanks @IMax153! - Avoid issues with ESM builds by removing dependency on `@opentelemetry/semantic-conventions` + +- Updated dependencies [[`8c7bb52`](https://github.com/Effect-TS/effect/commit/8c7bb52dc78850be72566decba6222870e3733d0), [`0e46e24`](https://github.com/Effect-TS/effect/commit/0e46e24c24e9edb8bf2e29835a94013e9c34d034)]: + - @effect/platform@0.90.4 + - @effect/sql@0.44.2 + +## 0.45.0 + +### Patch Changes + +- Updated dependencies [[`7813640`](https://github.com/Effect-TS/effect/commit/7813640279d9e3a3e7fc0a29bfb5c6d5fb3c270f)]: + - @effect/platform@0.90.0 + - @effect/experimental@0.54.0 + - @effect/sql@0.44.0 + +## 0.44.0 + +### Patch Changes + +- Updated dependencies [[`40c3c87`](https://github.com/Effect-TS/effect/commit/40c3c875f724264312b43002859c82bed9ad0df9), [`ed2c74a`](https://github.com/Effect-TS/effect/commit/ed2c74ae8fa4ea0dd06ea84a3e58cd32e6916104), [`073a1b8`](https://github.com/Effect-TS/effect/commit/073a1b8be5dbfa87454393ee7346f5bc36a4fd63), [`f382e99`](https://github.com/Effect-TS/effect/commit/f382e99e409838a879246250fc3994b9bf5b3c2c), [`e8c7ba5`](https://github.com/Effect-TS/effect/commit/e8c7ba5fd3eb0c3ae3039fc24c09d69391987989), [`7e10415`](https://github.com/Effect-TS/effect/commit/7e1041599ade25103428703f5d2dfd7378a09636), [`e9bdece`](https://github.com/Effect-TS/effect/commit/e9bdececdc24f60a246be5055eca71a0d49ea7f2), [`8d95eb0`](https://github.com/Effect-TS/effect/commit/8d95eb0356b1d1736204836c275d201a547d208d)]: + - effect@3.17.0 + - @effect/experimental@0.53.0 + - @effect/platform@0.89.0 + - @effect/sql@0.43.0 + +## 0.43.0 + +### Minor Changes + +- [#5192](https://github.com/Effect-TS/effect/pull/5192) [`17a5ea8`](https://github.com/Effect-TS/effect/commit/17a5ea8fa29785fe6e4c9480f2a2e9c8c59f3f38) Thanks @nikelborm! - Updated deprecated OTel Resource attributes names and values. + + Many of the attributes have undergone the process of deprecation not once, but twice. Most of the constants holding attribute names have been renamed. These are minor changes. + + Additionally, there were numerous changes to the attribute keys themselves. These changes can be considered major. + + In the `@opentelemetry/semantic-conventions` package, new attributes having ongoing discussion about them are going through a process called incubation, until a consensus about their necessity and form is reached. Otel team [recommends](https://github.com/open-telemetry/opentelemetry-js/blob/main/semantic-conventions/README.md#unstable-semconv) devs to copy them directly into their code. Luckily, it's not necessary because all of the new attribute names and values came out of this process (some of them were changed again) and are now considered stable. + + ## Reasoning for minor version bump + + | Package | Major attribute changes | Major value changes | + | -------------------------- | ----------------------------------------------------------------------------- | --------------------------------- | + | Clickhouse client | `db.system` -> `db.system.name`
`db.name` -> `db.namespace` | | + | MsSQL client | `db.system` -> `db.system.name`
`db.name` -> `db.namespace` | `mssql` -> `microsoft.sql_server` | + | MySQL client | `db.system` -> `db.system.name`
`db.name` -> `db.namespace` | | + | Pg client | `db.system` -> `db.system.name`
`db.name` -> `db.namespace` | | + | Bun SQLite client | `db.system` -> `db.system.name` | | + | Node SQLite client | `db.system` -> `db.system.name` | | + | React.Native SQLite client | `db.system` -> `db.system.name` | | + | Wasm SQLite client | `db.system` -> `db.system.name` | | + | SQLite Do client | `db.system` -> `db.system.name` | | + | LibSQL client | `db.system` -> `db.system.name` | | + | D1 client | `db.system` -> `db.system.name` | | + | Kysely client | `db.statement` -> `db.query.text` | | + | @effect/sql | `db.statement` -> `db.query.text`
`db.operation` -> `db.operation.name` | | + +### Patch Changes + +- Updated dependencies [[`f5dfabf`](https://github.com/Effect-TS/effect/commit/f5dfabf51ba481a4468c1509c537314978ef6cec), [`17a5ea8`](https://github.com/Effect-TS/effect/commit/17a5ea8fa29785fe6e4c9480f2a2e9c8c59f3f38), [`d25f22b`](https://github.com/Effect-TS/effect/commit/d25f22be7598abe977caf6cdac3b0dd78b438c48)]: + - effect@3.16.14 + - @effect/sql@0.42.0 + - @effect/platform@0.88.1 + - @effect/experimental@0.52.1 + +## 0.42.0 + +### Patch Changes + +- Updated dependencies [[`27206d7`](https://github.com/Effect-TS/effect/commit/27206d7f0558d7fe28de57bf54f1d0cc83acc92e), [`dbabf5e`](https://github.com/Effect-TS/effect/commit/dbabf5e76fa63b050d2b6c466713c7dc59f07d3c)]: + - @effect/platform@0.88.0 + - @effect/experimental@0.52.0 + - @effect/sql@0.41.0 + +## 0.41.14 + +### Patch Changes + +- Updated dependencies [[`c1c05a8`](https://github.com/Effect-TS/effect/commit/c1c05a8242fb5df7445b4a12387a60eac7726eb7), [`81fe4a2`](https://github.com/Effect-TS/effect/commit/81fe4a2c81d5e30e180a60e68c52016a27b350db)]: + - effect@3.16.13 + - @effect/experimental@0.51.14 + - @effect/platform@0.87.13 + - @effect/sql@0.40.14 + +## 0.41.13 + +### Patch Changes + +- Updated dependencies [[`32ba77a`](https://github.com/Effect-TS/effect/commit/32ba77ae304d2161362a73e8b61965332626cf2d), [`d5e25b2`](https://github.com/Effect-TS/effect/commit/d5e25b237f05670ee42b386cb40b2cb448fc11d7)]: + - @effect/platform@0.87.12 + - @effect/experimental@0.51.13 + - @effect/sql@0.40.13 + +## 0.41.12 + +### Patch Changes + +- Updated dependencies [[`001392b`](https://github.com/Effect-TS/effect/commit/001392ba8bfcad101bb034348a7415012fb12f72), [`7bfb099`](https://github.com/Effect-TS/effect/commit/7bfb099cb5528511b8d63045c4fbb4dc9cb18528)]: + - @effect/platform@0.87.11 + - @effect/experimental@0.51.12 + - @effect/sql@0.40.12 + +## 0.41.11 + +### Patch Changes + +- Updated dependencies [[`678318d`](https://github.com/Effect-TS/effect/commit/678318d2e88233156b006acda56c2d138ee3ffa0), [`678318d`](https://github.com/Effect-TS/effect/commit/678318d2e88233156b006acda56c2d138ee3ffa0)]: + - @effect/platform@0.87.10 + - @effect/experimental@0.51.11 + - @effect/sql@0.40.11 + +## 0.41.10 + +### Patch Changes + +- Updated dependencies [[`54514a2`](https://github.com/Effect-TS/effect/commit/54514a2f53166de27ad7e756dbf12194691fd4af)]: + - @effect/platform@0.87.9 + - @effect/experimental@0.51.10 + - @effect/sql@0.40.10 + +## 0.41.9 + +### Patch Changes + +- Updated dependencies [[`4ce4f82`](https://github.com/Effect-TS/effect/commit/4ce4f824f6fdef492be1d35c05a490ffce518c89)]: + - @effect/platform@0.87.8 + - @effect/experimental@0.51.9 + - @effect/sql@0.40.9 + +## 0.41.8 + +### Patch Changes + +- Updated dependencies [[`a9b617f`](https://github.com/Effect-TS/effect/commit/a9b617f125171ed76cd79ab46d7a924daf3b0e70), [`7e26e86`](https://github.com/Effect-TS/effect/commit/7e26e86524abcc93713d6ad7eee486638c98f7c2)]: + - @effect/platform@0.87.7 + - @effect/experimental@0.51.8 + - @effect/sql@0.40.8 + +## 0.41.7 + +### Patch Changes + +- Updated dependencies [[`905da99`](https://github.com/Effect-TS/effect/commit/905da996aad665057b4ca6dba1a4af44fb8835bd)]: + - effect@3.16.12 + - @effect/experimental@0.51.7 + - @effect/platform@0.87.6 + - @effect/sql@0.40.7 + +## 0.41.6 + +### Patch Changes + +- Updated dependencies [[`96c1292`](https://github.com/Effect-TS/effect/commit/96c129262835410b311a51d0bf7f58b8f6fc9a12)]: + - @effect/experimental@0.51.6 + - @effect/sql@0.40.6 + +## 0.41.5 + +### Patch Changes + +- Updated dependencies [[`2fd8676`](https://github.com/Effect-TS/effect/commit/2fd8676c803cd40000dfc3231f5daecaa0e0ebd2)]: + - @effect/platform@0.87.5 + - @effect/experimental@0.51.5 + - @effect/sql@0.40.5 + +## 0.41.4 + +### Patch Changes + +- Updated dependencies [[`e82a4fd`](https://github.com/Effect-TS/effect/commit/e82a4fd60f6528d08cef1a4aba0abe0d3ba741ad)]: + - @effect/platform@0.87.4 + - @effect/experimental@0.51.4 + - @effect/sql@0.40.4 + +## 0.41.3 + +### Patch Changes + +- Updated dependencies [[`1b6e396`](https://github.com/Effect-TS/effect/commit/1b6e396d699f3cbbc56b68f99055cf746529bb9e), [`46c3216`](https://github.com/Effect-TS/effect/commit/46c321657d93393506278327418e36f8e7a77f86)]: + - @effect/platform@0.87.3 + - @effect/sql@0.40.3 + - @effect/experimental@0.51.3 + +## 0.41.2 + +### Patch Changes + +- Updated dependencies [[`4fea68c`](https://github.com/Effect-TS/effect/commit/4fea68ca7a25a3c39a1ab68b3885534513ab0c81), [`b927954`](https://github.com/Effect-TS/effect/commit/b9279543cf5688dd8a577af80456959c615217d0), [`99590a6`](https://github.com/Effect-TS/effect/commit/99590a6ca9128eb1ede265b6670b655311995614), [`6c3e24c`](https://github.com/Effect-TS/effect/commit/6c3e24c2308f7d4a29b8f4270ab81bca22ac6bb4)]: + - @effect/platform@0.87.2 + - effect@3.16.11 + - @effect/experimental@0.51.2 + - @effect/sql@0.40.2 + +## 0.41.1 + +### Patch Changes + +- Updated dependencies [[`faad30e`](https://github.com/Effect-TS/effect/commit/faad30ec8742916be59f9db642d0fc98225b636c)]: + - effect@3.16.10 + - @effect/experimental@0.51.1 + - @effect/platform@0.87.1 + - @effect/sql@0.40.1 + +## 0.41.0 + +### Patch Changes + +- Updated dependencies [[`b5bac9a`](https://github.com/Effect-TS/effect/commit/b5bac9ac2913fcd11b02322624f03b544eef53ba)]: + - @effect/platform@0.87.0 + - @effect/experimental@0.51.0 + - @effect/sql@0.40.0 + +## 0.40.0 + +### Patch Changes + +- Updated dependencies [[`5137c70`](https://github.com/Effect-TS/effect/commit/5137c703461d8d3b363c112140a6e7f798241d07), [`c23d25c`](https://github.com/Effect-TS/effect/commit/c23d25c3e7c541f1f63b28484d8c461d86c67e99), [`5137c70`](https://github.com/Effect-TS/effect/commit/5137c703461d8d3b363c112140a6e7f798241d07), [`5137c70`](https://github.com/Effect-TS/effect/commit/5137c703461d8d3b363c112140a6e7f798241d07)]: + - effect@3.16.9 + - @effect/platform@0.86.0 + - @effect/experimental@0.50.0 + - @effect/sql@0.39.0 + +## 0.39.2 + +### Patch Changes + +- Updated dependencies [[`914a191`](https://github.com/Effect-TS/effect/commit/914a191e7cb6341a3d0e965bccd27c336cf22e44)]: + - @effect/platform@0.85.2 + - @effect/experimental@0.49.2 + - @effect/sql@0.38.2 + +## 0.39.1 + +### Patch Changes + +- Updated dependencies [[`8cb98d5`](https://github.com/Effect-TS/effect/commit/8cb98d53e68330228287ce2a2e0d8a4c86bcab3b), [`db2dd3c`](https://github.com/Effect-TS/effect/commit/db2dd3c3a8a77d791eae19e66153527e1cde4e6e)]: + - effect@3.16.8 + - @effect/experimental@0.49.1 + - @effect/platform@0.85.1 + - @effect/sql@0.38.1 + +## 0.39.0 + +### Patch Changes + +- Updated dependencies [[`93687dd`](https://github.com/Effect-TS/effect/commit/93687ddbb25ce3b324cd2b83d2ccff225e97307e), [`93687dd`](https://github.com/Effect-TS/effect/commit/93687ddbb25ce3b324cd2b83d2ccff225e97307e), [`93687dd`](https://github.com/Effect-TS/effect/commit/93687ddbb25ce3b324cd2b83d2ccff225e97307e)]: + - @effect/platform@0.85.0 + - @effect/experimental@0.49.0 + - @effect/sql@0.38.0 + +## 0.38.12 + +### Patch Changes + +- Updated dependencies [[`1bb0d8a`](https://github.com/Effect-TS/effect/commit/1bb0d8ab96782e99434356266b38251554ea0294)]: + - effect@3.16.7 + - @effect/experimental@0.48.12 + - @effect/platform@0.84.11 + - @effect/sql@0.37.12 + +## 0.38.11 + +### Patch Changes + +- Updated dependencies [[`a5f7595`](https://github.com/Effect-TS/effect/commit/a5f75956ef9a15a83c416517ef493f0ee2f5ee8a), [`a02470c`](https://github.com/Effect-TS/effect/commit/a02470c75579e91525a25adb3f21b3650d042fdd), [`bf369b2`](https://github.com/Effect-TS/effect/commit/bf369b2902a0e0b195d957c18b9efd180942cf8b), [`f891d45`](https://github.com/Effect-TS/effect/commit/f891d45adffdafd3f94a2eca23faa354e3a409a8)]: + - effect@3.16.6 + - @effect/platform@0.84.10 + - @effect/experimental@0.48.11 + - @effect/sql@0.37.11 + +## 0.38.10 + +### Patch Changes + +- Updated dependencies [[`bf418ef`](https://github.com/Effect-TS/effect/commit/bf418ef14a0f2ec965535793d5cea8fa8ba177ac)]: + - effect@3.16.5 + - @effect/experimental@0.48.10 + - @effect/platform@0.84.9 + - @effect/sql@0.37.10 + +## 0.38.9 + +### Patch Changes + +- Updated dependencies [[`8b9db77`](https://github.com/Effect-TS/effect/commit/8b9db7742846af0f58fd8e8b7acb7f4f5ff487ec)]: + - @effect/platform@0.84.8 + - @effect/experimental@0.48.9 + - @effect/sql@0.37.9 + +## 0.38.8 + +### Patch Changes + +- Updated dependencies [[`74ab9a0`](https://github.com/Effect-TS/effect/commit/74ab9a0a9e16d6e019369d256e1e24175c8bc3f3), [`770008e`](https://github.com/Effect-TS/effect/commit/770008eca3aad2899a2ed951236e575793294b28)]: + - effect@3.16.4 + - @effect/experimental@0.48.8 + - @effect/platform@0.84.7 + - @effect/sql@0.37.8 + +## 0.38.7 + +### Patch Changes + +- Updated dependencies [[`a2d57c9`](https://github.com/Effect-TS/effect/commit/a2d57c9ac596445009ca12859b78e00e5d89b936)]: + - @effect/experimental@0.48.7 + - @effect/sql@0.37.7 + +## 0.38.6 + +### Patch Changes + +- Updated dependencies [[`ceea77a`](https://github.com/Effect-TS/effect/commit/ceea77a13055f145520f763e3fce5b8ff15d728f)]: + - @effect/platform@0.84.6 + - @effect/experimental@0.48.6 + - @effect/sql@0.37.6 + +## 0.38.5 + +### Patch Changes + +- Updated dependencies [[`ec52c6a`](https://github.com/Effect-TS/effect/commit/ec52c6a2211e76972462b15b9d5a9d6d56761b7a)]: + - @effect/platform@0.84.5 + - @effect/experimental@0.48.5 + - @effect/sql@0.37.5 + +## 0.38.4 + +### Patch Changes + +- Updated dependencies [[`87722fc`](https://github.com/Effect-TS/effect/commit/87722fce693a9b49284bbddbf82d30714c688261), [`36217ee`](https://github.com/Effect-TS/effect/commit/36217eeb1337edd9ac3f9a635b80a6385d22ae8f)]: + - effect@3.16.3 + - @effect/experimental@0.48.4 + - @effect/platform@0.84.4 + - @effect/sql@0.37.4 + +## 0.38.3 + +### Patch Changes + +- Updated dependencies [[`ab7684f`](https://github.com/Effect-TS/effect/commit/ab7684f1c2a0671bf091f255d220e3a4cc7f528e)]: + - @effect/platform@0.84.3 + - @effect/experimental@0.48.3 + - @effect/sql@0.37.3 + +## 0.38.2 + +### Patch Changes + +- Updated dependencies [[`0ddf148`](https://github.com/Effect-TS/effect/commit/0ddf148a247aa87af043d276b8453a714a400897)]: + - effect@3.16.2 + - @effect/experimental@0.48.2 + - @effect/platform@0.84.2 + - @effect/sql@0.37.2 + +## 0.38.1 + +### Patch Changes + +- Updated dependencies [[`71174d0`](https://github.com/Effect-TS/effect/commit/71174d09691314a9b6b66189e456fd21e3eb6543), [`d615e6e`](https://github.com/Effect-TS/effect/commit/d615e6e5b944f6fd5e627e31752c7ca7e4e1c17d)]: + - @effect/platform@0.84.1 + - effect@3.16.1 + - @effect/experimental@0.48.1 + - @effect/sql@0.37.1 + +## 0.38.0 + +### Patch Changes + +- Updated dependencies [[`ee0bd5d`](https://github.com/Effect-TS/effect/commit/ee0bd5d24864752c54cb359f67a67dd903971ec4), [`5189800`](https://github.com/Effect-TS/effect/commit/51898004e11766b8cf6d95e960b636f6d5db79ec), [`58bfeaa`](https://github.com/Effect-TS/effect/commit/58bfeaa64ded8c88f772b184311c0c0dbac10960), [`194d748`](https://github.com/Effect-TS/effect/commit/194d7486943f56f3267ef415395ac220a4b3e634), [`918c9ea`](https://github.com/Effect-TS/effect/commit/918c9ea1a57facb154f0fb26792021f337054dee), [`9198e6f`](https://github.com/Effect-TS/effect/commit/9198e6fcc1a3ff4fefb3363004de558d8de01f40), [`2a370bf`](https://github.com/Effect-TS/effect/commit/2a370bf625fdeede5659721468eb0d527e403279), [`58ccb91`](https://github.com/Effect-TS/effect/commit/58ccb91328c8df5d49808b673738bc09df355201), [`fd47834`](https://github.com/Effect-TS/effect/commit/fd478348203fa89462b0a1d067ce4de034353df4)]: + - effect@3.16.0 + - @effect/experimental@0.48.0 + - @effect/platform@0.84.0 + - @effect/sql@0.37.0 + +## 0.37.0 + +### Patch Changes + +- Updated dependencies [[`5522520`](https://github.com/Effect-TS/effect/commit/55225206ab9af0ad60b1c0654690a8a096d625cd), [`cc5bb2b`](https://github.com/Effect-TS/effect/commit/cc5bb2b918a9450a975f702dabcea891bda382cb)]: + - @effect/platform@0.83.0 + - effect@3.15.5 + - @effect/experimental@0.47.0 + - @effect/sql@0.36.0 + +## 0.36.8 + +### Patch Changes + +- Updated dependencies [[`0617b9d`](https://github.com/Effect-TS/effect/commit/0617b9dc365f1963b36949ad7f9023ab6eb94524)]: + - @effect/platform@0.82.8 + - @effect/experimental@0.46.8 + - @effect/sql@0.35.8 + +## 0.36.7 + +### Patch Changes + +- Updated dependencies [[`f570554`](https://github.com/Effect-TS/effect/commit/f57055459524587b041340577dad85476bb35f81), [`78047e8`](https://github.com/Effect-TS/effect/commit/78047e8dfc8005b66f87afe50bb95981fea51561), [`c20b95a`](https://github.com/Effect-TS/effect/commit/c20b95a99ffe452b4774c844d397a905f713b6d6), [`94ada43`](https://github.com/Effect-TS/effect/commit/94ada430928d5685bdbef513e87562c20774a3a2)]: + - effect@3.15.4 + - @effect/platform@0.82.7 + - @effect/experimental@0.46.7 + - @effect/sql@0.35.7 + +## 0.36.6 + +### Patch Changes + +- Updated dependencies [[`618903b`](https://github.com/Effect-TS/effect/commit/618903ba9ae96e2bfe6ee31f61c4359b915f2a36)]: + - @effect/platform@0.82.6 + - @effect/experimental@0.46.6 + - @effect/sql@0.35.6 + +## 0.36.5 + +### Patch Changes + +- Updated dependencies [[`7764a07`](https://github.com/Effect-TS/effect/commit/7764a07d960c60df81f14e1dc949518f4bbe494a), [`4577f54`](https://github.com/Effect-TS/effect/commit/4577f548d67273e576cdde423bdd34a4b910766a), [`30a0d9c`](https://github.com/Effect-TS/effect/commit/30a0d9cb51c84290d51b1361d72ff5cee33c13c7)]: + - @effect/platform@0.82.5 + - effect@3.15.3 + - @effect/experimental@0.46.5 + - @effect/sql@0.35.5 + +## 0.36.4 + +### Patch Changes + +- Updated dependencies [[`d45e8a8`](https://github.com/Effect-TS/effect/commit/d45e8a8ac8227192f504e39e6d04fdcf4fb1d225), [`89657ac`](https://github.com/Effect-TS/effect/commit/89657ac2fbda9ba38ac2962ce96949e536a464f9), [`d13b68e`](https://github.com/Effect-TS/effect/commit/d13b68e3a9456d0bfee9bca8273a7b44a9c69087)]: + - @effect/platform@0.82.4 + - @effect/sql@0.35.4 + - @effect/experimental@0.46.4 + +## 0.36.3 + +### Patch Changes + +- Updated dependencies [[`b8722b8`](https://github.com/Effect-TS/effect/commit/b8722b817e2306fe8c8245f3f9e32d85b824b961), [`a328f4b`](https://github.com/Effect-TS/effect/commit/a328f4b4fe717dd53e5b04a30f387433c32f7328)]: + - effect@3.15.2 + - @effect/platform@0.82.3 + - @effect/experimental@0.46.3 + - @effect/sql@0.35.3 + +## 0.36.2 + +### Patch Changes + +- Updated dependencies [[`739a3d4`](https://github.com/Effect-TS/effect/commit/739a3d4a4565915fe2e690003f4f9085cb4422fc)]: + - @effect/platform@0.82.2 + - @effect/experimental@0.46.2 + - @effect/sql@0.35.2 + +## 0.36.1 + +### Patch Changes + +- Updated dependencies [[`787ce70`](https://github.com/Effect-TS/effect/commit/787ce7042e35b657963473c6efe47752868cd811), [`1269641`](https://github.com/Effect-TS/effect/commit/1269641a99ae43069f7648ff79ffe8729b54b348), [`1269641`](https://github.com/Effect-TS/effect/commit/1269641a99ae43069f7648ff79ffe8729b54b348)]: + - effect@3.15.1 + - @effect/experimental@0.46.1 + - @effect/platform@0.82.1 + - @effect/sql@0.35.1 + +## 0.36.0 + +### Patch Changes + +- Updated dependencies [[`c654595`](https://github.com/Effect-TS/effect/commit/c65459587b51da140b78098e81fdbfece65d53e2), [`d9f5dea`](https://github.com/Effect-TS/effect/commit/d9f5deae0f02f5de2b9fcb1cca8b142ba4bc2bba), [`49aa723`](https://github.com/Effect-TS/effect/commit/49aa7236a15e13f818c86edbca08c4af67c8dfaf), [`74c14d0`](https://github.com/Effect-TS/effect/commit/74c14d01d0cb48cf517a1b6e29a373a96ed0ff5b), [`e4f49b6`](https://github.com/Effect-TS/effect/commit/e4f49b66857e01b74ab6a9a0bc7132f44cd04cbb), [`6f02224`](https://github.com/Effect-TS/effect/commit/6f02224b3fc46a682ad2defb1a260841956c6780), [`1dcfd41`](https://github.com/Effect-TS/effect/commit/1dcfd41ff96abd706901293a00c1893cb29dd8fd), [`b21ab16`](https://github.com/Effect-TS/effect/commit/b21ab16b6f773e7ec4369db4e752c35e719f7870), [`fcf1822`](https://github.com/Effect-TS/effect/commit/fcf1822f98fcda60351d64e9d2c2c13563d7e6db), [`0061dd1`](https://github.com/Effect-TS/effect/commit/0061dd140740165e91569a684cce27a77b23229e), [`8421e6e`](https://github.com/Effect-TS/effect/commit/8421e6e49332bca8f96f482dfd48680e238b3a89), [`a9b3fb7`](https://github.com/Effect-TS/effect/commit/a9b3fb78abcfdb525318a956fd02fcadeb56143e), [`fa10f56`](https://github.com/Effect-TS/effect/commit/fa10f56b96bd9af070ba99ebc3279aa93954261e)]: + - effect@3.15.0 + - @effect/platform@0.82.0 + - @effect/experimental@0.46.0 + - @effect/sql@0.35.0 + +## 0.35.1 + +### Patch Changes + +- Updated dependencies [[`24a9ebb`](https://github.com/Effect-TS/effect/commit/24a9ebbb5af598f0bfd6ecc45307e528043fe011)]: + - effect@3.14.22 + - @effect/experimental@0.45.1 + - @effect/platform@0.81.1 + - @effect/sql@0.34.1 + +## 0.35.0 + +### Patch Changes + +- Updated dependencies [[`672920f`](https://github.com/Effect-TS/effect/commit/672920f85da8abd5f9d4ad85e29248a2aca57ed8)]: + - @effect/platform@0.81.0 + - @effect/experimental@0.45.0 + - @effect/sql@0.34.0 + +## 0.34.21 + +### Patch Changes + +- Updated dependencies [[`2f3b7d4`](https://github.com/Effect-TS/effect/commit/2f3b7d4e1fa1ef8790b0ca4da22eb88872ee31df)]: + - effect@3.14.21 + - @effect/experimental@0.44.21 + - @effect/platform@0.80.21 + - @effect/sql@0.33.21 + +## 0.34.20 + +### Patch Changes + +- Updated dependencies [[`17e2f30`](https://github.com/Effect-TS/effect/commit/17e2f3091408cf0fca9414d4af3bdf7b2765b378)]: + - effect@3.14.20 + - @effect/experimental@0.44.20 + - @effect/platform@0.80.20 + - @effect/sql@0.33.20 + +## 0.34.19 + +### Patch Changes + +- Updated dependencies [[`056a910`](https://github.com/Effect-TS/effect/commit/056a910d0a0b8b00b0dc9df4a070466b2b5c2f6c), [`e25e7bb`](https://github.com/Effect-TS/effect/commit/e25e7bbc1797733916f48f501425d9f2ef310d9f), [`3273d57`](https://github.com/Effect-TS/effect/commit/3273d572c2b3175a842677f19efeea4cd65ab016)]: + - effect@3.14.19 + - @effect/platform@0.80.19 + - @effect/experimental@0.44.19 + - @effect/sql@0.33.19 + +## 0.34.18 + +### Patch Changes + +- Updated dependencies [[`b1164d4`](https://github.com/Effect-TS/effect/commit/b1164d49a1dfdf299e9971367b6fc6be4df0ddff)]: + - effect@3.14.18 + - @effect/experimental@0.44.18 + - @effect/platform@0.80.18 + - @effect/sql@0.33.18 + +## 0.34.17 + +### Patch Changes + +- Updated dependencies [[`0b54681`](https://github.com/Effect-TS/effect/commit/0b54681cd89245e211d8f49272be0f1bf2f81813), [`41a59d5`](https://github.com/Effect-TS/effect/commit/41a59d5916a296b12b0d5ead9e859e05f40b4cce)]: + - effect@3.14.17 + - @effect/experimental@0.44.17 + - @effect/platform@0.80.17 + - @effect/sql@0.33.17 + +## 0.34.16 + +### Patch Changes + +- Updated dependencies [[`ee14444`](https://github.com/Effect-TS/effect/commit/ee144441021ec77039e43396eaf90714687bb495), [`f1c8583`](https://github.com/Effect-TS/effect/commit/f1c8583f8c3ea9415f813795ca2940a897c9ba9a)]: + - effect@3.14.16 + - @effect/platform@0.80.16 + - @effect/experimental@0.44.16 + - @effect/sql@0.33.16 + +## 0.34.15 + +### Patch Changes + +- Updated dependencies [[`239cc99`](https://github.com/Effect-TS/effect/commit/239cc995ce645946210a3c3d2cb52bd3547c0687), [`8b6c947`](https://github.com/Effect-TS/effect/commit/8b6c947eaa8e45a67ecb3c37d45cd27f3e41d165), [`c50a63b`](https://github.com/Effect-TS/effect/commit/c50a63bbecb9f560b9cae349c447eed877d1b9b6)]: + - effect@3.14.15 + - @effect/experimental@0.44.15 + - @effect/platform@0.80.15 + - @effect/sql@0.33.15 + +## 0.34.14 + +### Patch Changes + +- Updated dependencies [[`6ed8d15`](https://github.com/Effect-TS/effect/commit/6ed8d1589beb181d30abc79afebdaabc1d101538)]: + - effect@3.14.14 + - @effect/experimental@0.44.14 + - @effect/platform@0.80.14 + - @effect/sql@0.33.14 + +## 0.34.13 + +### Patch Changes + +- Updated dependencies [[`ee77788`](https://github.com/Effect-TS/effect/commit/ee77788747e7ebbde6bfa88256cde49dbbad3608), [`5fce6ba`](https://github.com/Effect-TS/effect/commit/5fce6ba19c3cc63cc0104e737e581ad989dedbf0), [`570e45f`](https://github.com/Effect-TS/effect/commit/570e45f8cb936e42ec48f67f21bb2b7252f36c0c)]: + - effect@3.14.13 + - @effect/experimental@0.44.13 + - @effect/platform@0.80.13 + - @effect/sql@0.33.13 + +## 0.34.12 + +### Patch Changes + +- Updated dependencies [[`c2ad9ee`](https://github.com/Effect-TS/effect/commit/c2ad9ee9f3c4c743390edf35ed9e85a20be33811), [`9c68654`](https://github.com/Effect-TS/effect/commit/9c686542b6eb3ea188cb70673ef2e41223633e89)]: + - effect@3.14.12 + - @effect/experimental@0.44.12 + - @effect/platform@0.80.12 + - @effect/sql@0.33.12 + +## 0.34.11 + +### Patch Changes + +- Updated dependencies [[`e536127`](https://github.com/Effect-TS/effect/commit/e536127c1e6f2fb3a542c73ae919435a629a346b)]: + - effect@3.14.11 + - @effect/experimental@0.44.11 + - @effect/platform@0.80.11 + - @effect/sql@0.33.11 + +## 0.34.10 + +### Patch Changes + +- Updated dependencies [[`bc7efa3`](https://github.com/Effect-TS/effect/commit/bc7efa3b031bb25e1ed3c8f2d3fb5e8da166cadc)]: + - effect@3.14.10 + - @effect/experimental@0.44.10 + - @effect/platform@0.80.10 + - @effect/sql@0.33.10 + +## 0.34.9 + +### Patch Changes + +- Updated dependencies [[`d78249f`](https://github.com/Effect-TS/effect/commit/d78249f0b67f63cf4baf806ff090cba33293daf0)]: + - effect@3.14.9 + - @effect/experimental@0.44.9 + - @effect/platform@0.80.9 + - @effect/sql@0.33.9 + +## 0.34.8 + +### Patch Changes + +- Updated dependencies [[`b3a2d32`](https://github.com/Effect-TS/effect/commit/b3a2d32772e6f7f20eacf2e18128e99324c4d378)]: + - effect@3.14.8 + - @effect/experimental@0.44.8 + - @effect/platform@0.80.8 + - @effect/sql@0.33.8 + +## 0.34.7 + +### Patch Changes + +- Updated dependencies [[`b542a4b`](https://github.com/Effect-TS/effect/commit/b542a4bf195be0c9af1523e1ba96c953decc4d25)]: + - effect@3.14.7 + - @effect/experimental@0.44.7 + - @effect/platform@0.80.7 + - @effect/sql@0.33.7 + +## 0.34.6 + +### Patch Changes + +- Updated dependencies [[`47618c1`](https://github.com/Effect-TS/effect/commit/47618c1ad84ebcc5a51133a3fff5aa5012d49d45), [`6077882`](https://github.com/Effect-TS/effect/commit/60778824a4794336c33807801f813f8751d1c7e4)]: + - effect@3.14.6 + - @effect/experimental@0.44.6 + - @effect/platform@0.80.6 + - @effect/sql@0.33.6 + +## 0.34.5 + +### Patch Changes + +- Updated dependencies [[`40dbfef`](https://github.com/Effect-TS/effect/commit/40dbfeff239b6e567706752114f31b2fce7de4e3), [`85fba81`](https://github.com/Effect-TS/effect/commit/85fba815ac07eb13d4227a69ac76a18e4b94df18), [`5a5ebdd`](https://github.com/Effect-TS/effect/commit/5a5ebdddfaddd259538b4599a6676281faca778e)]: + - effect@3.14.5 + - @effect/platform@0.80.5 + - @effect/experimental@0.44.5 + - @effect/sql@0.33.5 + +## 0.34.4 + +### Patch Changes + +- Updated dependencies [[`e4ba2c6`](https://github.com/Effect-TS/effect/commit/e4ba2c66a878e81b5e295d6d49aaf724b80a28ef)]: + - effect@3.14.4 + - @effect/experimental@0.44.4 + - @effect/platform@0.80.4 + - @effect/sql@0.33.4 + +## 0.34.3 + +### Patch Changes + +- Updated dependencies [[`37aa8e1`](https://github.com/Effect-TS/effect/commit/37aa8e137725a902e70cd1e468ea98b873aa5056), [`34f03d6`](https://github.com/Effect-TS/effect/commit/34f03d66875f21f266f102223a03cd14c2ed6ea6)]: + - effect@3.14.3 + - @effect/experimental@0.44.3 + - @effect/platform@0.80.3 + - @effect/sql@0.33.3 + +## 0.34.2 + +### Patch Changes + +- Updated dependencies [[`f87991b`](https://github.com/Effect-TS/effect/commit/f87991b6d8a2edfaf90b01cebda4b466992ae865), [`f87991b`](https://github.com/Effect-TS/effect/commit/f87991b6d8a2edfaf90b01cebda4b466992ae865), [`0a3e3e1`](https://github.com/Effect-TS/effect/commit/0a3e3e18eea5e0d1882f1a6c906198e6ef226a41)]: + - effect@3.14.2 + - @effect/experimental@0.44.2 + - @effect/platform@0.80.2 + - @effect/sql@0.33.2 + +## 0.34.1 + +### Patch Changes + +- Updated dependencies [[`4a274fe`](https://github.com/Effect-TS/effect/commit/4a274fe9f623182b6b902827e0e83bd89ca3b05c)]: + - effect@3.14.1 + - @effect/experimental@0.44.1 + - @effect/platform@0.80.1 + - @effect/sql@0.33.1 + +## 0.34.0 + +### Minor Changes + +- [#4469](https://github.com/Effect-TS/effect/pull/4469) [`3131f8f`](https://github.com/Effect-TS/effect/commit/3131f8fd12ba9eb31b90fa2f42bf88b12309133c) Thanks @tim-smart! - refactor of @effect/cluster packages + +### Patch Changes + +- Updated dependencies [[`1f47e4e`](https://github.com/Effect-TS/effect/commit/1f47e4e12546ab691b29bfb7b5128bb17b93baa5), [`26dd75f`](https://github.com/Effect-TS/effect/commit/26dd75f276a0d8a63eab313bd5a167d5072c9780), [`aba2d1d`](https://github.com/Effect-TS/effect/commit/aba2d1d831ea149481bd4dd755528c0afa8239ce), [`3131f8f`](https://github.com/Effect-TS/effect/commit/3131f8fd12ba9eb31b90fa2f42bf88b12309133c), [`aba2d1d`](https://github.com/Effect-TS/effect/commit/aba2d1d831ea149481bd4dd755528c0afa8239ce), [`04dff2d`](https://github.com/Effect-TS/effect/commit/04dff2d01ac68c260f29a6d4743381825c353c86), [`aba2d1d`](https://github.com/Effect-TS/effect/commit/aba2d1d831ea149481bd4dd755528c0afa8239ce), [`c7fac0c`](https://github.com/Effect-TS/effect/commit/c7fac0cd7eadcd5cc0c3a987051c5b57ad271638), [`aba2d1d`](https://github.com/Effect-TS/effect/commit/aba2d1d831ea149481bd4dd755528c0afa8239ce), [`ffaa3f3`](https://github.com/Effect-TS/effect/commit/ffaa3f3969df26610fcc02ad537340641d44e803), [`ab957c1`](https://github.com/Effect-TS/effect/commit/ab957c1fee714868f56c7ab4e802b9d449e9b666), [`35db9ce`](https://github.com/Effect-TS/effect/commit/35db9ce228f1416c8abacc6dc9c36fbd0f33ef0f), [`aba2d1d`](https://github.com/Effect-TS/effect/commit/aba2d1d831ea149481bd4dd755528c0afa8239ce), [`cf77ea9`](https://github.com/Effect-TS/effect/commit/cf77ea9ab4fc89e66a43f682a9926ccdee6c57ed), [`26dd75f`](https://github.com/Effect-TS/effect/commit/26dd75f276a0d8a63eab313bd5a167d5072c9780), [`baaab60`](https://github.com/Effect-TS/effect/commit/baaab60b737f35dfab8e4a21bce28a195d19e899)]: + - effect@3.14.0 + - @effect/experimental@0.44.0 + - @effect/platform@0.80.0 + - @effect/sql@0.33.0 + +## 0.33.4 + +### Patch Changes + +- Updated dependencies [[`5662363`](https://github.com/Effect-TS/effect/commit/566236361e270e575ef1cbf308ad1967c82a362c), [`5f1fd15`](https://github.com/Effect-TS/effect/commit/5f1fd15308ab154791580059b89877d19a2055c2), [`8bb1460`](https://github.com/Effect-TS/effect/commit/8bb1460c824f66f0f25ebd899c5e74e388089c37)]: + - @effect/platform@0.79.4 + - @effect/experimental@0.43.4 + - @effect/sql@0.32.4 + +## 0.33.3 + +### Patch Changes + +- Updated dependencies [[`0c4803f`](https://github.com/Effect-TS/effect/commit/0c4803fcc69262d11a97ce49d0e9b4288df0651f), [`6f65ac4`](https://github.com/Effect-TS/effect/commit/6f65ac4eac1489cd6ea390e18b0908670722adad)]: + - effect@3.13.12 + - @effect/experimental@0.43.3 + - @effect/platform@0.79.3 + - @effect/sql@0.32.3 + +## 0.33.2 + +### Patch Changes + +- Updated dependencies [[`fad8cca`](https://github.com/Effect-TS/effect/commit/fad8cca9bbfcc2eaeb44b97c15dbe0a1eda75315), [`4296293`](https://github.com/Effect-TS/effect/commit/4296293049414d0cf2d915a26c552b09f946b9a0), [`9c241ab`](https://github.com/Effect-TS/effect/commit/9c241abe47ccf7a5257b98a4a64a63054a12741d), [`082b0c1`](https://github.com/Effect-TS/effect/commit/082b0c1b9f4252bcdd69608f2e4a9226f953ac3f), [`be12983`](https://github.com/Effect-TS/effect/commit/be12983bc7e7537b41cd8910fc4eb7d1da56ab07), [`de88127`](https://github.com/Effect-TS/effect/commit/de88127a5a5906ccece98af74787b5ae0e65e431)]: + - effect@3.13.11 + - @effect/experimental@0.43.2 + - @effect/platform@0.79.2 + - @effect/sql@0.32.2 + +## 0.33.1 + +### Patch Changes + +- Updated dependencies [[`527c964`](https://github.com/Effect-TS/effect/commit/527c9645229f5be9714a7e60a38a9e753c4bbfb1)]: + - effect@3.13.10 + - @effect/experimental@0.43.1 + - @effect/platform@0.79.1 + - @effect/sql@0.32.1 + +## 0.33.0 + +### Patch Changes + +- Updated dependencies [[`88fe129`](https://github.com/Effect-TS/effect/commit/88fe12923740765c0335a6e6203fdcc6a463edca), [`d630249`](https://github.com/Effect-TS/effect/commit/d630249426113088abe8b382db4f14d80f2160c2), [`2976e52`](https://github.com/Effect-TS/effect/commit/2976e52538d9dc9ffdcbc84d4ac748cff9305971)]: + - @effect/platform@0.79.0 + - effect@3.13.9 + - @effect/experimental@0.43.0 + - @effect/sql@0.32.0 + +## 0.32.1 + +### Patch Changes + +- Updated dependencies [[`c65d336`](https://github.com/Effect-TS/effect/commit/c65d3362d07ec815ff3b46278314e8a31706ddc2), [`22d2ebb`](https://github.com/Effect-TS/effect/commit/22d2ebb4b11f5a44351a4736e65da391a3b647d0)]: + - effect@3.13.8 + - @effect/experimental@0.42.1 + - @effect/platform@0.78.1 + - @effect/sql@0.31.1 + +## 0.32.0 + +### Patch Changes + +- Updated dependencies [[`c5bcf53`](https://github.com/Effect-TS/effect/commit/c5bcf53b7cb49dacffdd2a6cd8eb48cc452b417e)]: + - @effect/platform@0.78.0 + - @effect/experimental@0.42.0 + - @effect/sql@0.31.0 + +## 0.31.7 + +### Patch Changes + +- Updated dependencies [[`840cc73`](https://github.com/Effect-TS/effect/commit/840cc7329908db7ca693ef47b07d4f845c29cadd), [`9bf8a74`](https://github.com/Effect-TS/effect/commit/9bf8a74b967f18d931743dd5196af326c9118e9c), [`87ba23c`](https://github.com/Effect-TS/effect/commit/87ba23c41c193503ed0c612b0d32d0b253794c64), [`f910880`](https://github.com/Effect-TS/effect/commit/f91088069057f3b4529753f5bc5532b028d726df), [`0d01480`](https://github.com/Effect-TS/effect/commit/0d014803e4f688f74386a80abd65485e1a319244)]: + - @effect/platform@0.77.7 + - effect@3.13.7 + - @effect/experimental@0.41.7 + - @effect/sql@0.30.7 + +## 0.31.6 + +### Patch Changes + +- Updated dependencies [[`3154ce4`](https://github.com/Effect-TS/effect/commit/3154ce4692fa18b804982158d3c4c8a8a5fae386)]: + - effect@3.13.6 + - @effect/experimental@0.41.6 + - @effect/platform@0.77.6 + - @effect/sql@0.30.6 + +## 0.31.5 + +### Patch Changes + +- Updated dependencies [[`367bb35`](https://github.com/Effect-TS/effect/commit/367bb35f4c2a254e1fb211d96db2474a7aed9020), [`6cf11c3`](https://github.com/Effect-TS/effect/commit/6cf11c3a75773ceec2877c85ddc760f381f0866d), [`a0acec8`](https://github.com/Effect-TS/effect/commit/a0acec851f72e19466363d24b9cc218acd00006a)]: + - effect@3.13.5 + - @effect/experimental@0.41.5 + - @effect/platform@0.77.5 + - @effect/sql@0.30.5 + +## 0.31.4 + +### Patch Changes + +- Updated dependencies [[`e0746f9`](https://github.com/Effect-TS/effect/commit/e0746f9aa398b69c6542e375910683bf17f49f46), [`17d9e89`](https://github.com/Effect-TS/effect/commit/17d9e89f9851663bdbb6c1e685601d97806114a4)]: + - @effect/platform@0.77.4 + - effect@3.13.4 + - @effect/experimental@0.41.4 + - @effect/sql@0.30.4 + +## 0.31.3 + +### Patch Changes + +- Updated dependencies [[`cc5588d`](https://github.com/Effect-TS/effect/commit/cc5588df07f9103513547cb429ce041b9436a8bd), [`623c8cd`](https://github.com/Effect-TS/effect/commit/623c8cd053ed6ee3d353aaa8778d484670fca2bb), [`00b4eb1`](https://github.com/Effect-TS/effect/commit/00b4eb1ece12a16e222e6220965bb4024d6752ac), [`f2aee98`](https://github.com/Effect-TS/effect/commit/f2aee989b0a600900ce83e7f460d02908620c80f), [`fb798eb`](https://github.com/Effect-TS/effect/commit/fb798eb9061f1191badc017d1aa649360254da20), [`2251b15`](https://github.com/Effect-TS/effect/commit/2251b1528810bb695b37ce388b653cec0c5bf80c), [`2e15c1e`](https://github.com/Effect-TS/effect/commit/2e15c1e33648add0b29fe274fbcb7294b7515085), [`a4979db`](https://github.com/Effect-TS/effect/commit/a4979db021aef16e731be64df196b72088fc4376), [`b74255a`](https://github.com/Effect-TS/effect/commit/b74255a304ad49d60bedb1a260fd697f370af27a), [`d7f6a5c`](https://github.com/Effect-TS/effect/commit/d7f6a5c7d26c1963dcd864ca62360d20d08c7b49), [`9dd8979`](https://github.com/Effect-TS/effect/commit/9dd8979e940915b1cc1b1f264f3d019c77a65a02), [`477b488`](https://github.com/Effect-TS/effect/commit/477b488284f47c5469d7fba3e4065fb7e3b6556e), [`10932cb`](https://github.com/Effect-TS/effect/commit/10932cbf58fc721ada631cebec42f773ce96d3cc), [`9f6c784`](https://github.com/Effect-TS/effect/commit/9f6c78468b3b5e9ebfc38ffdfb70702901ee977b), [`2c639ec`](https://github.com/Effect-TS/effect/commit/2c639ecee332de4266e36022c989c35ae4e02105), [`886aaa8`](https://github.com/Effect-TS/effect/commit/886aaa81e06dfd3cd9391e8ea987d8cd5ada1124)]: + - effect@3.13.3 + - @effect/experimental@0.41.3 + - @effect/platform@0.77.3 + - @effect/sql@0.30.3 + +## 0.31.2 + +### Patch Changes + +- Updated dependencies [[`31be72a`](https://github.com/Effect-TS/effect/commit/31be72ada118cb84a942e67b1663263f8db74a9f), [`3e7ce97`](https://github.com/Effect-TS/effect/commit/3e7ce97f8a41756a039cf635d0b3d9a75d781097), [`31be72a`](https://github.com/Effect-TS/effect/commit/31be72ada118cb84a942e67b1663263f8db74a9f)]: + - effect@3.13.2 + - @effect/platform@0.77.2 + - @effect/experimental@0.41.2 + - @effect/sql@0.30.2 + +## 0.31.1 + +### Patch Changes + +- Updated dependencies [[`b56a211`](https://github.com/Effect-TS/effect/commit/b56a2110569fd0ec0b57ac137743e926d49f51cc)]: + - effect@3.13.1 + - @effect/experimental@0.41.1 + - @effect/platform@0.77.1 + - @effect/sql@0.30.1 + +## 0.31.0 + +### Patch Changes + +- Updated dependencies [[`8baef83`](https://github.com/Effect-TS/effect/commit/8baef83e7ff0b7bc0738b680e1ef013065386cff), [`655bfe2`](https://github.com/Effect-TS/effect/commit/655bfe29e44cc3f0fb9b4e53038f50b891c188df), [`d90cbc2`](https://github.com/Effect-TS/effect/commit/d90cbc274e2742d18671fe65aa4764c057eb6cba), [`75632bd`](https://github.com/Effect-TS/effect/commit/75632bd44b8025101d652ccbaeef898c7086c91c), [`c874a2e`](https://github.com/Effect-TS/effect/commit/c874a2e4b17e9d71904ca8375bb77b020975cb1d), [`bf865e5`](https://github.com/Effect-TS/effect/commit/bf865e5833f77fd8f6c06944ca9d507b54488301), [`f98b2b7`](https://github.com/Effect-TS/effect/commit/f98b2b7592cf20f9d85313e7f1e964cb65878138), [`de8ce92`](https://github.com/Effect-TS/effect/commit/de8ce924923eaa4e1b761a97eb45ec967389f3d5), [`cf8b2dd`](https://github.com/Effect-TS/effect/commit/cf8b2dd112f8e092ed99d78fd728db0f91c29050), [`db426a5`](https://github.com/Effect-TS/effect/commit/db426a5fb41ab84d18e3c8753a7329b4de544245), [`6862444`](https://github.com/Effect-TS/effect/commit/6862444094906ad4f2cb077ff3b9cc0b73880c8c), [`5fc8a90`](https://github.com/Effect-TS/effect/commit/5fc8a90ba46a5fd9f3b643f0b5aeadc69d717339), [`546a492`](https://github.com/Effect-TS/effect/commit/546a492e60eb2b8b048a489a474b934ea0877005), [`65c4796`](https://github.com/Effect-TS/effect/commit/65c47966ce39055f02cf5c808daabb3ea6442b0b), [`9760fdc`](https://github.com/Effect-TS/effect/commit/9760fdc37bdaef9da8b150e46b86ddfbe2ad9221), [`5b471e7`](https://github.com/Effect-TS/effect/commit/5b471e7d4317e8ee5d72bbbd3e0c9775160949ab), [`4f810cc`](https://github.com/Effect-TS/effect/commit/4f810cc2770e9f1f266851d2cb6257112c12af49)]: + - effect@3.13.0 + - @effect/experimental@0.41.0 + - @effect/platform@0.77.0 + - @effect/sql@0.30.0 + +## 0.30.1 + +### Patch Changes + +- Updated dependencies [[`4018eae`](https://github.com/Effect-TS/effect/commit/4018eaed2733241676ddb8c52416f463a8c32e35), [`543d36d`](https://github.com/Effect-TS/effect/commit/543d36d1a11452560b01ab966a82529ad5fee8c9), [`c407726`](https://github.com/Effect-TS/effect/commit/c407726f79df4a567a9631cddd8effaa16b3535d), [`f70a65a`](https://github.com/Effect-TS/effect/commit/f70a65ac80c6635d80b12beaf4d32a9cc59fa143), [`ba409f6`](https://github.com/Effect-TS/effect/commit/ba409f69c41aeaa29e475c0630735726eaf4dbac), [`3d2e356`](https://github.com/Effect-TS/effect/commit/3d2e3565e8a43d1bdb5daee8db3b90f56d71d859)]: + - effect@3.12.12 + - @effect/platform@0.76.1 + - @effect/experimental@0.40.1 + - @effect/sql@0.29.1 + +## 0.30.0 + +### Patch Changes + +- Updated dependencies [[`b6a032f`](https://github.com/Effect-TS/effect/commit/b6a032f07bffa020a848c813881879395134fa20), [`42ddd5f`](https://github.com/Effect-TS/effect/commit/42ddd5f144ce9f9d94a036679ebbd626446d37f5), [`2fe447c`](https://github.com/Effect-TS/effect/commit/2fe447c6354d334f9c591b8a8481818f5f0e797e), [`2473ad5`](https://github.com/Effect-TS/effect/commit/2473ad5cf23582e3a41338091fa526ffe611288d)]: + - effect@3.12.11 + - @effect/platform@0.76.0 + - @effect/experimental@0.40.0 + - @effect/sql@0.29.0 + +## 0.29.4 + +### Patch Changes + +- Updated dependencies [[`e30f132`](https://github.com/Effect-TS/effect/commit/e30f132c336c9d0760bad39f82a55c7ce5159eb7), [`33fa667`](https://github.com/Effect-TS/effect/commit/33fa667c2623be1026e1ccee91bd44f73b09020a), [`87f5f28`](https://github.com/Effect-TS/effect/commit/87f5f2842e4196cb88d13f10f443ff0567e82832), [`7d57ecd`](https://github.com/Effect-TS/effect/commit/7d57ecdaf5da2345ebbf9c22df50317578bde0f5), [`4dbd170`](https://github.com/Effect-TS/effect/commit/4dbd170538e8fb7a36aa7c469c6f93b6c7000091)]: + - effect@3.12.10 + - @effect/platform@0.75.4 + - @effect/experimental@0.39.4 + - @effect/sql@0.28.4 + +## 0.29.3 + +### Patch Changes + +- Updated dependencies [[`1b4a4e9`](https://github.com/Effect-TS/effect/commit/1b4a4e904ef5227ec7d9114d4e417eca19eed940)]: + - effect@3.12.9 + - @effect/experimental@0.39.3 + - @effect/platform@0.75.3 + - @effect/sql@0.28.3 + +## 0.29.2 + +### Patch Changes + +- Updated dependencies [[`59b3cfb`](https://github.com/Effect-TS/effect/commit/59b3cfbbd5713dd9475998e95fad5534c0b21466), [`766113c`](https://github.com/Effect-TS/effect/commit/766113c0ea3512cdb887650ead8ba314236e22ee), [`bb05fb8`](https://github.com/Effect-TS/effect/commit/bb05fb83457355b1ca567228a9e041edfb6fd85d), [`712277f`](https://github.com/Effect-TS/effect/commit/712277f949052a24b46e4aa234063a6abf395c90), [`f269122`](https://github.com/Effect-TS/effect/commit/f269122508693b111142994dd48698ddc75f3d69), [`8f6006a`](https://github.com/Effect-TS/effect/commit/8f6006a610fb6d6c7b8d14209a7323338a8964ff), [`c45b559`](https://github.com/Effect-TS/effect/commit/c45b5592b5fd1189a5c932cfe05bd7d5f6d68508), [`430c846`](https://github.com/Effect-TS/effect/commit/430c846cbac05b187e3d24ac8dfee0cf22506f7c), [`7b03057`](https://github.com/Effect-TS/effect/commit/7b03057507d2dab5e6793beb9c578dedaaeb15fe), [`a9c94c8`](https://github.com/Effect-TS/effect/commit/a9c94c807755610831211a686d2fad849ab38eb4), [`107e6f0`](https://github.com/Effect-TS/effect/commit/107e6f0557a1e2d3b0dce25d62fa1e2601521752), [`c9175ae`](https://github.com/Effect-TS/effect/commit/c9175aef41cb1e3b689d0ac0a4f53d8107376b58), [`65c11b9`](https://github.com/Effect-TS/effect/commit/65c11b9266ec9447c31c26fe3ed35c73bd3b81fd), [`e386d2f`](https://github.com/Effect-TS/effect/commit/e386d2f1b3ab3ac2c14ee76de11f5963d32a3df4), [`9172efb`](https://github.com/Effect-TS/effect/commit/9172efba98bc6a82353e6ec2af61ac08f038ba64)]: + - @effect/platform@0.75.2 + - effect@3.12.8 + - @effect/experimental@0.39.2 + - @effect/sql@0.28.2 + +## 0.29.1 + +### Patch Changes + +- Updated dependencies [[`8dff1d1`](https://github.com/Effect-TS/effect/commit/8dff1d1bff76cdba643cad7f0bf864300f08bc61)]: + - effect@3.12.7 + - @effect/experimental@0.39.1 + - @effect/platform@0.75.1 + - @effect/sql@0.28.1 + +## 0.29.0 + +### Patch Changes + +- Updated dependencies [[`5e43ce5`](https://github.com/Effect-TS/effect/commit/5e43ce50bae116865906112e7f88d390739d778b), [`289c13b`](https://github.com/Effect-TS/effect/commit/289c13b38e8e35b214d46d385d05dead176c87cd), [`76eb7d0`](https://github.com/Effect-TS/effect/commit/76eb7d0fbce3c009c8f77e84c178cb15bbed9709), [`8b4e75d`](https://github.com/Effect-TS/effect/commit/8b4e75d35daea807c447ca760948a717aa66bb52), [`fc5e0f0`](https://github.com/Effect-TS/effect/commit/fc5e0f0d357a0051cfa01c1ede83ffdd3cb41ab1), [`004fd2b`](https://github.com/Effect-TS/effect/commit/004fd2bbd1459e64fb1b57f02eeb791ca5ea1ea5), [`b2a31be`](https://github.com/Effect-TS/effect/commit/b2a31be85c35d891351ce4f9a2cc93ece0c257f6), [`5514d05`](https://github.com/Effect-TS/effect/commit/5514d05b5cd586ff5868b8bd41c959e95e6c33cd), [`bf5f0ae`](https://github.com/Effect-TS/effect/commit/bf5f0ae9daa0170471678e22585e8ec14ce667bb), [`3b19bcf`](https://github.com/Effect-TS/effect/commit/3b19bcfd3aaadb6c9253428622df524537c8e626), [`b064b3b`](https://github.com/Effect-TS/effect/commit/b064b3b293615fd268cc5a5647d0981eb67750b8), [`eb264ed`](https://github.com/Effect-TS/effect/commit/eb264ed8a6e8c92a9dc7006f766c6ca2e5d29e03), [`289c13b`](https://github.com/Effect-TS/effect/commit/289c13b38e8e35b214d46d385d05dead176c87cd), [`f474678`](https://github.com/Effect-TS/effect/commit/f474678bf10b8f1c80e3dc096ddc7ecf20b2b23e), [`ee187d0`](https://github.com/Effect-TS/effect/commit/ee187d098007a402844c94d04f0cd8f07695377a)]: + - @effect/experimental@0.39.0 + - @effect/platform@0.75.0 + - effect@3.12.6 + - @effect/sql@0.28.0 + +## 0.28.0 + +### Patch Changes + +- Updated dependencies [[`bd0d489`](https://github.com/Effect-TS/effect/commit/bd0d4892b098bc4c589444af9f50259c2c02ec0f), [`a8b0ddb`](https://github.com/Effect-TS/effect/commit/a8b0ddb84710054799fc8f57485b95d00093ada1), [`8653072`](https://github.com/Effect-TS/effect/commit/86530720d7a03e118d2c5a8bf5a997cee7e7f3d6), [`507d546`](https://github.com/Effect-TS/effect/commit/507d546bd49db31000425fb5da88c434e4291bea), [`a8b0ddb`](https://github.com/Effect-TS/effect/commit/a8b0ddb84710054799fc8f57485b95d00093ada1), [`8db239b`](https://github.com/Effect-TS/effect/commit/8db239b9c869a3707f6566b9d9dbdf53c4df03fc), [`84a0911`](https://github.com/Effect-TS/effect/commit/84a091181634c3a022c94234cec7764a3aeef1be), [`84a0911`](https://github.com/Effect-TS/effect/commit/84a091181634c3a022c94234cec7764a3aeef1be), [`3179a9f`](https://github.com/Effect-TS/effect/commit/3179a9f65d23369a6a9a1f80f7750566dd28df22), [`6cb9b76`](https://github.com/Effect-TS/effect/commit/6cb9b766396d0b2ed995cf26957359713efd202e), [`1fcbe55`](https://github.com/Effect-TS/effect/commit/1fcbe55345042d8468f6a98c84081bd00b6bcf5a), [`bd0d489`](https://github.com/Effect-TS/effect/commit/bd0d4892b098bc4c589444af9f50259c2c02ec0f), [`d9a63d9`](https://github.com/Effect-TS/effect/commit/d9a63d9d385653865954cac895065360d54cc56b), [`6cb9b76`](https://github.com/Effect-TS/effect/commit/6cb9b766396d0b2ed995cf26957359713efd202e)]: + - @effect/experimental@0.38.0 + - @effect/sql@0.27.0 + - effect@3.12.5 + - @effect/platform@0.74.0 + +## 0.27.1 + +### Patch Changes + +- Updated dependencies [[`5b50ea4`](https://github.com/Effect-TS/effect/commit/5b50ea4a10cf9acd51f9624b2474d9d5ded74019), [`c170a68`](https://github.com/Effect-TS/effect/commit/c170a68b6266100774461fcd6c0e0fabb60112f2), [`a66c2eb`](https://github.com/Effect-TS/effect/commit/a66c2eb473245092cd41f04c2eb2b7b02cf53718), [`c9e5e1b`](https://github.com/Effect-TS/effect/commit/c9e5e1be17c0c84d3d4e2abc3c60215cdb56bbbe), [`7b3d58d`](https://github.com/Effect-TS/effect/commit/7b3d58d7aec2152ec282460871d3e9de45ed254d)]: + - effect@3.12.4 + - @effect/platform@0.73.1 + - @effect/experimental@0.37.1 + - @effect/sql@0.26.1 + +## 0.27.0 + +### Patch Changes + +- Updated dependencies [[`d7dac48`](https://github.com/Effect-TS/effect/commit/d7dac48a477cdfeec509dbe9f33fce6a1b02b63d), [`c110032`](https://github.com/Effect-TS/effect/commit/c110032322450a8824ba38ae24335a538cd2ce9a), [`1d7fd2b`](https://github.com/Effect-TS/effect/commit/1d7fd2b7ee8eeecc912d27adf76ed897db236dc5), [`1d7fd2b`](https://github.com/Effect-TS/effect/commit/1d7fd2b7ee8eeecc912d27adf76ed897db236dc5), [`23ac740`](https://github.com/Effect-TS/effect/commit/23ac740c7dd4610b7d265c2071b88b0968419e9a), [`8cd7319`](https://github.com/Effect-TS/effect/commit/8cd7319b6568bfc7a30ca16c104d189e37eac3a0)]: + - effect@3.12.3 + - @effect/platform@0.73.0 + - @effect/experimental@0.37.0 + - @effect/sql@0.26.0 + +## 0.26.2 + +### Patch Changes + +- Updated dependencies [[`734af82`](https://github.com/Effect-TS/effect/commit/734af82138e78b9c57a8355b1c6b80e80d38b222), [`b63c780`](https://github.com/Effect-TS/effect/commit/b63c78010893101520448ddda7019c487cf7eedd), [`212e784`](https://github.com/Effect-TS/effect/commit/212e78475f527147ec27c090bd13f789f55add7a), [`f852cb0`](https://github.com/Effect-TS/effect/commit/f852cb02040ea2f165e9b449615b8b1366add5d5), [`7276ae2`](https://github.com/Effect-TS/effect/commit/7276ae21062896adbb7508ac5b2dece95316322f), [`212e784`](https://github.com/Effect-TS/effect/commit/212e78475f527147ec27c090bd13f789f55add7a), [`212e784`](https://github.com/Effect-TS/effect/commit/212e78475f527147ec27c090bd13f789f55add7a), [`212e784`](https://github.com/Effect-TS/effect/commit/212e78475f527147ec27c090bd13f789f55add7a), [`c640d77`](https://github.com/Effect-TS/effect/commit/c640d77b33ad417876f4e8ffe8574ee6cbe5607f), [`0def088`](https://github.com/Effect-TS/effect/commit/0def0887cfdb6755729a64dfd52b3b9f46b0576c)]: + - effect@3.12.2 + - @effect/platform@0.72.2 + - @effect/experimental@0.36.2 + - @effect/sql@0.25.2 + +## 0.26.1 + +### Patch Changes + +- Updated dependencies [[`302b57d`](https://github.com/Effect-TS/effect/commit/302b57d2cbf9b9ccc17450945aeebfb33cfe8d43), [`0988083`](https://github.com/Effect-TS/effect/commit/0988083d4594938590df5a287e5b27d38526dd07), [`8b46be6`](https://github.com/Effect-TS/effect/commit/8b46be6a3b8160362ab5ea9171c5e6932505125c), [`bfe8027`](https://github.com/Effect-TS/effect/commit/bfe802734b450a4b4ee069d1125dd37995db2bff), [`16dd657`](https://github.com/Effect-TS/effect/commit/16dd657033d8afac2ffea567b3c8bb27c9b249b6), [`39db211`](https://github.com/Effect-TS/effect/commit/39db211414e90c8db8fdad7dc8ce5b4661bcfaef)]: + - effect@3.12.1 + - @effect/experimental@0.36.1 + - @effect/platform@0.72.1 + - @effect/sql@0.25.1 + +## 0.26.0 + +### Patch Changes + +- Updated dependencies [[`abb22a4`](https://github.com/Effect-TS/effect/commit/abb22a429b9c52c31e84856294f175d2064a9b4d), [`f369a89`](https://github.com/Effect-TS/effect/commit/f369a89e98bc682969803b9304adaf4557bb36c2), [`642376c`](https://github.com/Effect-TS/effect/commit/642376c63fd7d78754db991631a4d50a5dc79aa3), [`3d2b7a7`](https://github.com/Effect-TS/effect/commit/3d2b7a7e942a7157afae5b1cdbc6f3fef116428e), [`ef64c6f`](https://github.com/Effect-TS/effect/commit/ef64c6fec0d47da573c04230dde9ea729366d871), [`73f9c6f`](https://github.com/Effect-TS/effect/commit/73f9c6f2ff091512cf904cc54ab59965b86e87c8), [`17cb451`](https://github.com/Effect-TS/effect/commit/17cb4514590e8a86263f7aed009f24da8a237342), [`d801820`](https://github.com/Effect-TS/effect/commit/d80182060c2ee945d7e0e4728812abf9465a0d6a), [`e1eeb2d`](https://github.com/Effect-TS/effect/commit/e1eeb2d7064b3870041dab142f3057970699bbf1), [`c11f3a6`](https://github.com/Effect-TS/effect/commit/c11f3a60a05c3b5fc8e7ce90136728154dc505b0), [`618f7e0`](https://github.com/Effect-TS/effect/commit/618f7e092a1011e5090dca1e69b5e9285689654b), [`c0ba834`](https://github.com/Effect-TS/effect/commit/c0ba834d1995cf5a8b250e4780fd43f3e3881151), [`e1eeb2d`](https://github.com/Effect-TS/effect/commit/e1eeb2d7064b3870041dab142f3057970699bbf1)]: + - effect@3.12.0 + - @effect/platform@0.72.0 + - @effect/experimental@0.36.0 + - @effect/sql@0.25.0 + +## 0.25.3 + +### Patch Changes + +- Updated dependencies [[`39457d4`](https://github.com/Effect-TS/effect/commit/39457d4897d9bc7df8af5c05d352866bbeae82eb), [`a475cc2`](https://github.com/Effect-TS/effect/commit/a475cc25fd7c9f26b27a8e98f8fbe43cc9e6ee3e), [`199214e`](https://github.com/Effect-TS/effect/commit/199214e21c616d8a0ccd7ed5f92e944e6c580193), [`b3c160d`](https://github.com/Effect-TS/effect/commit/b3c160d7a1fdfc2d3fb2440530f1ab80efc65133)]: + - effect@3.11.10 + - @effect/experimental@0.35.3 + - @effect/platform@0.71.7 + - @effect/sql@0.24.3 + +## 0.25.2 + +### Patch Changes + +- Updated dependencies [[`1c08a0b`](https://github.com/Effect-TS/effect/commit/1c08a0b8505badcffb4d9cade5a746ea90c9557e), [`1ce703b`](https://github.com/Effect-TS/effect/commit/1ce703b041bbd7560c5c437c9b9be48f027937fd), [`1ce703b`](https://github.com/Effect-TS/effect/commit/1ce703b041bbd7560c5c437c9b9be48f027937fd)]: + - effect@3.11.9 + - @effect/experimental@0.35.2 + - @effect/platform@0.71.6 + - @effect/sql@0.24.2 + +## 0.25.1 + +### Patch Changes + +- Updated dependencies [[`05d71f8`](https://github.com/Effect-TS/effect/commit/05d71f85622305705d8316817694a09762e60865), [`e66b920`](https://github.com/Effect-TS/effect/commit/e66b9205f25ab425d30640886eb3fb2c4715bc26)]: + - @effect/platform@0.71.5 + - @effect/experimental@0.35.1 + - @effect/sql@0.24.1 + +## 0.25.0 + +### Patch Changes + +- Updated dependencies [[`909181a`](https://github.com/Effect-TS/effect/commit/909181a9ce9052a80432ccf52187e0723004bf7f), [`909181a`](https://github.com/Effect-TS/effect/commit/909181a9ce9052a80432ccf52187e0723004bf7f), [`1a6b52d`](https://github.com/Effect-TS/effect/commit/1a6b52dcf020d36e38a7bc90b648152cf5a8ccba)]: + - @effect/platform@0.71.4 + - effect@3.11.8 + - @effect/experimental@0.35.0 + - @effect/sql@0.24.0 + +## 0.24.3 + +### Patch Changes + +- Updated dependencies [[`6984508`](https://github.com/Effect-TS/effect/commit/6984508c87f1bd91213b44c19b25ab5e2dcc1ce0), [`883639c`](https://github.com/Effect-TS/effect/commit/883639cc8ce47757f1cd39439391a8028c0812fe)]: + - @effect/platform@0.71.3 + - @effect/experimental@0.34.3 + - @effect/sql@0.23.3 + +## 0.24.2 + +### Patch Changes + +- Updated dependencies [[`2408616`](https://github.com/Effect-TS/effect/commit/24086163b60b09cc6d0885bd565ef080dcbe866b), [`cec0b4d`](https://github.com/Effect-TS/effect/commit/cec0b4d152ef660be2ccdb0927255f2471436e6e), [`cec0b4d`](https://github.com/Effect-TS/effect/commit/cec0b4d152ef660be2ccdb0927255f2471436e6e), [`8d978c5`](https://github.com/Effect-TS/effect/commit/8d978c53f6fcc98d9d645ecba3e4b55d4297dd36), [`cec0b4d`](https://github.com/Effect-TS/effect/commit/cec0b4d152ef660be2ccdb0927255f2471436e6e), [`cec0b4d`](https://github.com/Effect-TS/effect/commit/cec0b4d152ef660be2ccdb0927255f2471436e6e)]: + - effect@3.11.7 + - @effect/platform@0.71.2 + - @effect/experimental@0.34.2 + - @effect/sql@0.23.2 + +## 0.24.1 + +### Patch Changes + +- Updated dependencies [[`1d3df5b`](https://github.com/Effect-TS/effect/commit/1d3df5bc4324e88a392c348db35fd9d029c7b25e)]: + - @effect/platform@0.71.1 + - @effect/experimental@0.34.1 + - @effect/sql@0.23.1 + +## 0.24.0 + +### Patch Changes + +- Updated dependencies [[`662d1ce`](https://github.com/Effect-TS/effect/commit/662d1ce6fb7da384a95888d5b2bb5605bdf3208d), [`c99a0f3`](https://github.com/Effect-TS/effect/commit/c99a0f376d049d3793ed33e146d9873b8a5e5b78), [`11fc401`](https://github.com/Effect-TS/effect/commit/11fc401f436f99bf4be95f56d50b0e4bdfe5edea), [`c99a0f3`](https://github.com/Effect-TS/effect/commit/c99a0f376d049d3793ed33e146d9873b8a5e5b78), [`31c62d8`](https://github.com/Effect-TS/effect/commit/31c62d83cbdcf9850a8b5331faa239601c60f78a)]: + - effect@3.11.6 + - @effect/platform@0.71.0 + - @effect/experimental@0.34.0 + - @effect/sql@0.23.0 + +## 0.23.7 + +### Patch Changes + +- Updated dependencies [[`9f5a6f7`](https://github.com/Effect-TS/effect/commit/9f5a6f701bf7ba31adccd1f1bcfa8ab5614c9be8), [`ef70ffc`](https://github.com/Effect-TS/effect/commit/ef70ffc417ec035ede40c62b7316e447cc7c1932), [`22905cf`](https://github.com/Effect-TS/effect/commit/22905cf5addfb1ff3d2a6135c52036be958ae911), [`9f5a6f7`](https://github.com/Effect-TS/effect/commit/9f5a6f701bf7ba31adccd1f1bcfa8ab5614c9be8), [`1e59e4f`](https://github.com/Effect-TS/effect/commit/1e59e4fd778da18296812a2a32f36ca8ae50f60d), [`9f5a6f7`](https://github.com/Effect-TS/effect/commit/9f5a6f701bf7ba31adccd1f1bcfa8ab5614c9be8), [`8d914e5`](https://github.com/Effect-TS/effect/commit/8d914e504e7a22d0ea628e8af265ee450ff9530f), [`03bb00f`](https://github.com/Effect-TS/effect/commit/03bb00faa74f9e168a54a8cc0828a664fbb1ab05), [`9f5a6f7`](https://github.com/Effect-TS/effect/commit/9f5a6f701bf7ba31adccd1f1bcfa8ab5614c9be8), [`14e1149`](https://github.com/Effect-TS/effect/commit/14e1149f1af5a022f06eb8c2e4ba9fec17fe7426), [`9f5a6f7`](https://github.com/Effect-TS/effect/commit/9f5a6f701bf7ba31adccd1f1bcfa8ab5614c9be8), [`9f5a6f7`](https://github.com/Effect-TS/effect/commit/9f5a6f701bf7ba31adccd1f1bcfa8ab5614c9be8)]: + - effect@3.11.5 + - @effect/experimental@0.33.7 + - @effect/platform@0.70.7 + - @effect/sql@0.22.7 + +## 0.23.6 + +### Patch Changes + +- Updated dependencies [[`9a5b8e3`](https://github.com/Effect-TS/effect/commit/9a5b8e36d184bd4967a88752cb6e755e1be263af)]: + - @effect/platform@0.70.6 + - @effect/experimental@0.33.6 + - @effect/sql@0.22.6 + +## 0.23.5 + +### Patch Changes + +- [#4090](https://github.com/Effect-TS/effect/pull/4090) [`e993627`](https://github.com/Effect-TS/effect/commit/e9936278d9b72a8b96c37cf7968d0e095069c488) Thanks @rocwang! - Add the missing dependency on @effect/experimental to @effect/sql-X + +- Updated dependencies [[`415f4c9`](https://github.com/Effect-TS/effect/commit/415f4c98321868531727a83cbaad70164f5e4c40), [`518b258`](https://github.com/Effect-TS/effect/commit/518b258a8a67ecd332a9252c35cc060f8368dee2), [`6e323a3`](https://github.com/Effect-TS/effect/commit/6e323a36faaee46b328c8e3cf60a76b3aff9907f), [`518b258`](https://github.com/Effect-TS/effect/commit/518b258a8a67ecd332a9252c35cc060f8368dee2), [`6e323a3`](https://github.com/Effect-TS/effect/commit/6e323a36faaee46b328c8e3cf60a76b3aff9907f)]: + - @effect/platform@0.70.5 + - effect@3.11.4 + - @effect/experimental@0.33.5 + - @effect/sql@0.22.5 + +## 0.23.4 + +### Patch Changes + +- Updated dependencies [[`90906f7`](https://github.com/Effect-TS/effect/commit/90906f7f154b12c7182e8f39e3c55ef3937db857), [`3862cd3`](https://github.com/Effect-TS/effect/commit/3862cd3c7f6a542ed65fb81255b3bd696ce2f567), [`3862cd3`](https://github.com/Effect-TS/effect/commit/3862cd3c7f6a542ed65fb81255b3bd696ce2f567), [`343b6aa`](https://github.com/Effect-TS/effect/commit/343b6aa6ac4a74276bfc7c63ccbf4a1d72bc1bed), [`afba339`](https://github.com/Effect-TS/effect/commit/afba339adc11dad56b5a3b7ca94487e58f34d613)]: + - effect@3.11.3 + - @effect/platform@0.70.4 + - @effect/sql@0.22.4 + +## 0.23.3 + +### Patch Changes + +- Updated dependencies [[`7044730`](https://github.com/Effect-TS/effect/commit/70447306be1aeeb7d87c230b2a96ec87b993ede9)]: + - @effect/platform@0.70.3 + - @effect/sql@0.22.3 + +## 0.23.2 + +### Patch Changes + +- Updated dependencies [[`01cee56`](https://github.com/Effect-TS/effect/commit/01cee560b58d94b24cc20e98083251b73e658b41), [`c2249ea`](https://github.com/Effect-TS/effect/commit/c2249ea13fd98ab7d9aa628787931356d8ec2860), [`1358aa5`](https://github.com/Effect-TS/effect/commit/1358aa5326eaa85ef13ee8d1fed0b4a4288ed3eb), [`1de3fe7`](https://github.com/Effect-TS/effect/commit/1de3fe7d1cbafd6391eaa38c2300b99e332cc2aa)]: + - effect@3.11.2 + - @effect/platform@0.70.2 + - @effect/sql@0.22.2 + +## 0.23.1 + +### Patch Changes + +- Updated dependencies [[`dd8a2d8`](https://github.com/Effect-TS/effect/commit/dd8a2d8e80d33b16719fc69361eaedf0b59d4620), [`a71bfef`](https://github.com/Effect-TS/effect/commit/a71bfef46f5061bb2502a61a333638a987b62273)]: + - effect@3.11.1 + - @effect/platform@0.70.1 + - @effect/sql@0.22.1 + +## 0.23.0 + +### Patch Changes + +- Updated dependencies [[`147434b`](https://github.com/Effect-TS/effect/commit/147434b03d5e1fd692dd9f126e5ab0910f3b76d3), [`6e69493`](https://github.com/Effect-TS/effect/commit/6e694930048bbaf98110f35f41566aeb9752d471), [`147434b`](https://github.com/Effect-TS/effect/commit/147434b03d5e1fd692dd9f126e5ab0910f3b76d3), [`5eff3f6`](https://github.com/Effect-TS/effect/commit/5eff3f6fa3aae7e86948a62cbfd63b8d6c3bdf92), [`d9fe79b`](https://github.com/Effect-TS/effect/commit/d9fe79bb5a3fe105d8e7a3bc2922a8ad936a5d10), [`251d189`](https://github.com/Effect-TS/effect/commit/251d189420bbba71990574e91098c499065f9a9b), [`5a259f3`](https://github.com/Effect-TS/effect/commit/5a259f3711b4369f55d885b568bdb21136155261), [`b4ce4ea`](https://github.com/Effect-TS/effect/commit/b4ce4ea7fd514a7e572f2dcd879c98f334981b0e), [`15fcc5a`](https://github.com/Effect-TS/effect/commit/15fcc5a0ea4bbf40ab48fa6a04fdda74f76f4c07), [`9bc9a47`](https://github.com/Effect-TS/effect/commit/9bc9a476800dc645903c888a68bb1d3baa3383c6), [`aadb8a4`](https://github.com/Effect-TS/effect/commit/aadb8a48d2cba197c06ec9996505510e48e4e5cb), [`1e2747c`](https://github.com/Effect-TS/effect/commit/1e2747c63a4820d1459cbbc88c71212983bd68bd), [`9264162`](https://github.com/Effect-TS/effect/commit/9264162a82783a651776fb7b87604564a63e7070), [`e0b9b09`](https://github.com/Effect-TS/effect/commit/e0b9b09e70c386b2da17d1f0a15b0511861c89e8), [`c36f3b9`](https://github.com/Effect-TS/effect/commit/c36f3b95df5ce9d71b66f22f26ce12eda8d3e848), [`672bde5`](https://github.com/Effect-TS/effect/commit/672bde5bec51c7d6f9862828e6a654cb2cb6f93d), [`aadb8a4`](https://github.com/Effect-TS/effect/commit/aadb8a48d2cba197c06ec9996505510e48e4e5cb)]: + - effect@3.11.0 + - @effect/platform@0.70.0 + - @effect/sql@0.22.0 + +## 0.22.4 + +### Patch Changes + +- Updated dependencies [[`3069614`](https://github.com/Effect-TS/effect/commit/30696149271129fc618f6f2ccd1d8f2f6c0f9cd7), [`09a5e52`](https://github.com/Effect-TS/effect/commit/09a5e522fd9b221f05d85b1d1c8a740d4973c302)]: + - effect@3.10.20 + - @effect/platform@0.69.32 + - @effect/sql@0.21.4 + +## 0.22.3 + +### Patch Changes + +- Updated dependencies [[`e6d4a37`](https://github.com/Effect-TS/effect/commit/e6d4a37c1d7e657b5ea44063a1cf586808228fe5)]: + - @effect/platform@0.69.31 + - @effect/sql@0.21.3 + +## 0.22.2 + +### Patch Changes + +- Updated dependencies []: + - @effect/sql@0.21.2 + +## 0.22.1 + +### Patch Changes + +- Updated dependencies [[`270f199`](https://github.com/Effect-TS/effect/commit/270f199b31810fd643e4c22818698adcbdb5d396)]: + - @effect/platform@0.69.30 + - @effect/sql@0.21.1 + +## 0.22.0 + +### Minor Changes + +- [#4022](https://github.com/Effect-TS/effect/pull/4022) [`1b1ba09`](https://github.com/Effect-TS/effect/commit/1b1ba099bca49ff48ffe931cc1b607314a5eaafa) Thanks @tim-smart! - allow cloning a SqlClient with transforms disabled + +### Patch Changes + +- [#4021](https://github.com/Effect-TS/effect/pull/4021) [`e9dfea3`](https://github.com/Effect-TS/effect/commit/e9dfea3f394444ebd8929e5cfe05ce740cf84d6e) Thanks @tim-smart! - add .reactive method to SqlClient interface + +- Updated dependencies [[`e9dfea3`](https://github.com/Effect-TS/effect/commit/e9dfea3f394444ebd8929e5cfe05ce740cf84d6e), [`1b1ba09`](https://github.com/Effect-TS/effect/commit/1b1ba099bca49ff48ffe931cc1b607314a5eaafa), [`24cc35e`](https://github.com/Effect-TS/effect/commit/24cc35e26d6ed4a076470bc687ffd99cc50991b3)]: + - @effect/sql@0.21.0 + - @effect/platform@0.69.29 + +## 0.21.12 + +### Patch Changes + +- Updated dependencies [[`edd72be`](https://github.com/Effect-TS/effect/commit/edd72be57b904d60c9cbffc2537901821a9da537), [`a3e2771`](https://github.com/Effect-TS/effect/commit/a3e277170a1f7cf61fd629acb60304c7e81d9498), [`944025b`](https://github.com/Effect-TS/effect/commit/944025bc5ce139f4a85846aa689bf30ec06a8ec1), [`54addee`](https://github.com/Effect-TS/effect/commit/54addee438a644bf010646c52042c7b89c5fc0a7), [`a9e00e4`](https://github.com/Effect-TS/effect/commit/a9e00e43f0b5dd22c1f9d5b78be6383daea09c20)]: + - @effect/platform@0.69.28 + - effect@3.10.19 + - @effect/sql@0.20.12 + +## 0.21.11 + +### Patch Changes + +- Updated dependencies [[`af409cf`](https://github.com/Effect-TS/effect/commit/af409cf1d2ff973be11cc079ea373eaeedca25de), [`beaccae`](https://github.com/Effect-TS/effect/commit/beaccae2d15931e9fe475fb50a0b3638243fe3f7)]: + - effect@3.10.18 + - @effect/platform@0.69.27 + - @effect/sql@0.20.11 + +## 0.21.10 + +### Patch Changes + +- Updated dependencies [[`c963886`](https://github.com/Effect-TS/effect/commit/c963886d5817986fcbd6bfa4ddf50aca8b6c8184), [`42c4ce6`](https://github.com/Effect-TS/effect/commit/42c4ce6f8d8c7d847e97757650a8ad9419a829d7)]: + - @effect/platform@0.69.26 + - effect@3.10.17 + - @effect/sql@0.20.10 + +## 0.21.9 + +### Patch Changes + +- Updated dependencies [[`320557a`](https://github.com/Effect-TS/effect/commit/320557ab18d13c5e22fc7dc0d2a157eae461012f), [`4dca30c`](https://github.com/Effect-TS/effect/commit/4dca30cfcdafe4542e236489f71d6f171a5b4e38), [`1d99867`](https://github.com/Effect-TS/effect/commit/1d998671be3cd11043f232822e91dd8c98fccfa9), [`6dae414`](https://github.com/Effect-TS/effect/commit/6dae4147991a97ec14a99289bd25fadae7541e8d), [`6b0d737`](https://github.com/Effect-TS/effect/commit/6b0d737078bf63b97891e6bc47affc04b28f9cf7), [`d8356aa`](https://github.com/Effect-TS/effect/commit/d8356aad428a0c2290db52380220f81d9ec94232), [`7b93dd6`](https://github.com/Effect-TS/effect/commit/7b93dd622e2ab79c7072d79d0d9611e446202201)]: + - @effect/platform@0.69.25 + - effect@3.10.16 + - @effect/sql@0.20.9 + +## 0.21.8 + +### Patch Changes + +- Updated dependencies [[`3cc6514`](https://github.com/Effect-TS/effect/commit/3cc6514d2dd64e010cb760cc29bfce98c349bb10)]: + - @effect/platform@0.69.24 + - @effect/sql@0.20.8 + +## 0.21.7 + +### Patch Changes + +- Updated dependencies [[`3aff4d3`](https://github.com/Effect-TS/effect/commit/3aff4d38837c213bb2987973dc4b98febb9f92d2)]: + - @effect/platform@0.69.23 + - @effect/sql@0.20.7 + +## 0.21.6 + +### Patch Changes + +- Updated dependencies [[`8398b32`](https://github.com/Effect-TS/effect/commit/8398b3208242a88239d4449910b7baf923cfe3b6), [`72e55b7`](https://github.com/Effect-TS/effect/commit/72e55b7c610784fcebdbadc592c876e23e76a986)]: + - effect@3.10.15 + - @effect/platform@0.69.22 + - @effect/sql@0.20.6 + +## 0.21.5 + +### Patch Changes + +- Updated dependencies [[`f983946`](https://github.com/Effect-TS/effect/commit/f9839467b4cad6e788297764ef9f9f0b9fd203f9), [`2d8a750`](https://github.com/Effect-TS/effect/commit/2d8a75081eb83a0a81f817fdf6f428369c5064ab)]: + - effect@3.10.14 + - @effect/platform@0.69.21 + - @effect/sql@0.20.5 + +## 0.21.4 + +### Patch Changes + +- Updated dependencies [[`995bbdf`](https://github.com/Effect-TS/effect/commit/995bbdffea2e332f203cd5b474cd6a1c77dfa6ae)]: + - effect@3.10.13 + - @effect/platform@0.69.20 + - @effect/sql@0.20.4 + +## 0.21.3 + +### Patch Changes + +- Updated dependencies [[`eb8c52d`](https://github.com/Effect-TS/effect/commit/eb8c52d8b4c5e067ebf0a81eb742f5822e6439b5)]: + - @effect/platform@0.69.19 + - @effect/sql@0.20.3 + +## 0.21.2 + +### Patch Changes + +- Updated dependencies [[`a0584ec`](https://github.com/Effect-TS/effect/commit/a0584ece92ed784bfb139e9c5a699f02d1e71c2d), [`dd14efe`](https://github.com/Effect-TS/effect/commit/dd14efe0ace255f571273aae876adea96267d7e6), [`dd14efe`](https://github.com/Effect-TS/effect/commit/dd14efe0ace255f571273aae876adea96267d7e6)]: + - @effect/platform@0.69.18 + - effect@3.10.12 + - @effect/sql@0.20.2 + +## 0.21.1 + +### Patch Changes + +- Updated dependencies [[`5eef499`](https://github.com/Effect-TS/effect/commit/5eef4998b6ccb7a5404d9e4fef85e57fa35fbb8a), [`8240b1c`](https://github.com/Effect-TS/effect/commit/8240b1c10d45312fc863cb679b1a1e8441af0c1a), [`5eef499`](https://github.com/Effect-TS/effect/commit/5eef4998b6ccb7a5404d9e4fef85e57fa35fbb8a)]: + - effect@3.10.11 + - @effect/platform@0.69.17 + - @effect/sql@0.20.1 + +## 0.21.0 + +### Patch Changes + +- Updated dependencies []: + - @effect/sql@0.20.0 + +## 0.20.0 + +### Patch Changes + +- Updated dependencies [[`cd720ae`](https://github.com/Effect-TS/effect/commit/cd720aedf7f2571edec0843d6a633e84e4832b28), [`cd720ae`](https://github.com/Effect-TS/effect/commit/cd720aedf7f2571edec0843d6a633e84e4832b28), [`cd720ae`](https://github.com/Effect-TS/effect/commit/cd720aedf7f2571edec0843d6a633e84e4832b28), [`b631f40`](https://github.com/Effect-TS/effect/commit/b631f40abbe649b2a089764585b5c39f6a695ac6), [`7d89650`](https://github.com/Effect-TS/effect/commit/7d8965036cd2ea435c8441ffec3345488baebf85)]: + - effect@3.10.10 + - @effect/platform@0.69.16 + - @effect/sql@0.19.0 + +## 0.19.5 + +### Patch Changes + +- Updated dependencies [[`8a30e1d`](https://github.com/Effect-TS/effect/commit/8a30e1dfa3a7103bf5414fc6a7fca3088d8c8c00)]: + - @effect/platform@0.69.15 + - @effect/sql@0.18.16 + +## 0.19.4 + +### Patch Changes + +- Updated dependencies [[`a123e80`](https://github.com/Effect-TS/effect/commit/a123e80f111a625428a5b5622b7f55ee1073566b), [`bd5fcd3`](https://github.com/Effect-TS/effect/commit/bd5fcd3e6b603b1e505af90d6a00627c8eca6d41), [`0289d3b`](https://github.com/Effect-TS/effect/commit/0289d3b6391031d00329365bab9791b355031fe3), [`7386b71`](https://github.com/Effect-TS/effect/commit/7386b710e5be570e17f468928a6ed19d549a3e12), [`07c493a`](https://github.com/Effect-TS/effect/commit/07c493a598e096c7810cd06def8cfa43493c46b1), [`257ab1b`](https://github.com/Effect-TS/effect/commit/257ab1b539fa6e930b7ae2583a188376372200d7), [`4211a23`](https://github.com/Effect-TS/effect/commit/4211a2355bb3af3f0e756e2aae9d293379f25662)]: + - effect@3.10.9 + - @effect/platform@0.69.14 + - @effect/sql@0.18.15 + +## 0.19.3 + +### Patch Changes + +- Updated dependencies [[`68b5c9e`](https://github.com/Effect-TS/effect/commit/68b5c9e44f34192cef26e1cadda5e661a027df41), [`9c9928d`](https://github.com/Effect-TS/effect/commit/9c9928dfeacd9ac33dc37eb0ca3d7d8c39175ada), [`6306e66`](https://github.com/Effect-TS/effect/commit/6306e6656092b350d4ede5746da6f245ec9f7e07), [`361c7f3`](https://github.com/Effect-TS/effect/commit/361c7f39a2c10ede9324847c3d3ba192a6f9b20a)]: + - effect@3.10.8 + - @effect/sql@0.18.14 + - @effect/platform@0.69.13 + +## 0.19.2 + +### Patch Changes + +- Updated dependencies [[`33f5b9f`](https://github.com/Effect-TS/effect/commit/33f5b9ffaebea4f1bd0e391b44c41fb6230e743a), [`50f0281`](https://github.com/Effect-TS/effect/commit/50f0281b0d2116726b8927a6217622d5f394f3e4)]: + - effect@3.10.7 + - @effect/platform@0.69.12 + - @effect/sql@0.18.13 + +## 0.19.1 + +### Patch Changes + +- Updated dependencies [[`ce1c21f`](https://github.com/Effect-TS/effect/commit/ce1c21ffc11902ac9ab453a51904207859d38552), [`81ddd45`](https://github.com/Effect-TS/effect/commit/81ddd45fc074b98206fafab416d9a5a28b31e07a)]: + - effect@3.10.6 + - @effect/platform@0.69.11 + - @effect/sql@0.18.12 + +## 0.19.0 + +### Minor Changes + +- [#3852](https://github.com/Effect-TS/effect/pull/3852) [`70dd4d7`](https://github.com/Effect-TS/effect/commit/70dd4d7cd2376e39244fa1729938f1b3ec55aec7) Thanks @sukovanej! - Use `layer` / `layerConfig` naming convention for the /sql-\* packages. Make `layer` constructors accept a raw config object. Add `layerConfig` constructors that accept `Config.Config<...>`. + +### Patch Changes + +- Updated dependencies [[`3a6d757`](https://github.com/Effect-TS/effect/commit/3a6d757badeebe00d8ef4d67530d073c8264dcfa), [`59d813a`](https://github.com/Effect-TS/effect/commit/59d813aa4973d1115cfc70cc3667508335f49693)]: + - effect@3.10.5 + - @effect/platform@0.69.10 + - @effect/sql@0.18.11 + +## 0.18.10 + +### Patch Changes + +- Updated dependencies [[`2367708`](https://github.com/Effect-TS/effect/commit/2367708be449f9526a2047e321302d7bfb16f18e)]: + - @effect/platform@0.69.9 + - effect@3.10.4 + - @effect/sql@0.18.10 + +## 0.18.9 + +### Patch Changes + +- Updated dependencies [[`522f7c5`](https://github.com/Effect-TS/effect/commit/522f7c518a5acfb55ef96d6796869f002cc3eaf8)]: + - @effect/platform@0.69.8 + - @effect/sql@0.18.9 + +## 0.18.8 + +### Patch Changes + +- Updated dependencies [[`690d6c5`](https://github.com/Effect-TS/effect/commit/690d6c54d2145adb0af545c447db7d4755bf3c6b), [`b9423d8`](https://github.com/Effect-TS/effect/commit/b9423d8bf8181a2389fdbce1e3c14ac6fe8d54f5), [`279fe3a`](https://github.com/Effect-TS/effect/commit/279fe3a7168fe84e520c2cc88ba189a15f03a2bc)]: + - @effect/platform@0.69.7 + - effect@3.10.3 + - @effect/sql@0.18.8 + +## 0.18.7 + +### Patch Changes + +- Updated dependencies [[`714e119`](https://github.com/Effect-TS/effect/commit/714e11945e45e5a2554ee058e6c43f82a8e309cf), [`c1afd55`](https://github.com/Effect-TS/effect/commit/c1afd55c54e61f9c432823d21b3d016f79160a37), [`42cd72a`](https://github.com/Effect-TS/effect/commit/42cd72a44ca9593e4d81fbb50e8111625fd0fb81)]: + - effect@3.10.2 + - @effect/platform@0.69.6 + - @effect/sql@0.18.7 + +## 0.18.6 + +### Patch Changes + +- Updated dependencies [[`9604d6b`](https://github.com/Effect-TS/effect/commit/9604d6b616435103dafea8b53637a9d1450b4750)]: + - effect@3.10.1 + - @effect/sql@0.18.6 + - @effect/platform@0.69.5 + +## 0.18.5 + +### Patch Changes + +- Updated dependencies [[`c86b1d7`](https://github.com/Effect-TS/effect/commit/c86b1d7cd47b66df190ef9775a475467c1abdbd6)]: + - @effect/platform@0.69.4 + - @effect/sql@0.18.5 + +## 0.18.4 + +### Patch Changes + +- Updated dependencies [[`d5fba63`](https://github.com/Effect-TS/effect/commit/d5fba6391e1005e374aa0238f13edfbd65848313), [`1eb2c30`](https://github.com/Effect-TS/effect/commit/1eb2c30ba064398db5790e376dedcfad55b7b005), [`02d413e`](https://github.com/Effect-TS/effect/commit/02d413e7b6bc1c64885969c37cc3e4e690c94d7d)]: + - @effect/platform@0.69.3 + - @effect/sql@0.18.4 + +## 0.18.3 + +### Patch Changes + +- Updated dependencies [[`e7afc47`](https://github.com/Effect-TS/effect/commit/e7afc47ce83e381c3f4aed2b2974e3b3d86a2340)]: + - @effect/platform@0.69.2 + - @effect/sql@0.18.3 + +## 0.18.2 + +### Patch Changes + +- Updated dependencies []: + - @effect/sql@0.18.2 + +## 0.18.1 + +### Patch Changes + +- Updated dependencies [[`7564f56`](https://github.com/Effect-TS/effect/commit/7564f56bb2844cf39d2b0d2d9e93cf9b2205e9a8), [`7564f56`](https://github.com/Effect-TS/effect/commit/7564f56bb2844cf39d2b0d2d9e93cf9b2205e9a8)]: + - @effect/platform@0.69.1 + - @effect/sql@0.18.1 + +## 0.18.0 + +### Patch Changes + +- Updated dependencies [[`4a01828`](https://github.com/Effect-TS/effect/commit/4a01828b66d6213e9bbe18979c893b13f7bb29bf), [`6d9de6b`](https://github.com/Effect-TS/effect/commit/6d9de6b871c5c08e6509a4e830c3d74758faa198), [`4a01828`](https://github.com/Effect-TS/effect/commit/4a01828b66d6213e9bbe18979c893b13f7bb29bf), [`c79c4c1`](https://github.com/Effect-TS/effect/commit/c79c4c178390fe61ff6dda88c9e058862349343a), [`38d30f0`](https://github.com/Effect-TS/effect/commit/38d30f08b8da62f9c3e308b9250738cb8d17bdb5), [`5821ce3`](https://github.com/Effect-TS/effect/commit/5821ce3455b47d25e0a40cae6ce22af9db5fa556)]: + - effect@3.10.0 + - @effect/platform@0.69.0 + - @effect/sql@0.18.0 + +## 0.17.0 + +### Patch Changes + +- Updated dependencies [[`dacbf7d`](https://github.com/Effect-TS/effect/commit/dacbf7db59899065aee4e5dd95a6459880e09ceb)]: + - @effect/sql@0.17.0 + +## 0.16.6 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.68.6 + - @effect/sql@0.16.6 + +## 0.16.5 + +### Patch Changes + +- Updated dependencies [[`2036402`](https://github.com/Effect-TS/effect/commit/20364020b8b75a684791aa93d90626758023e9e9)]: + - @effect/platform@0.68.5 + - @effect/sql@0.16.5 + +## 0.16.4 + +### Patch Changes + +- Updated dependencies [[`1b1ef29`](https://github.com/Effect-TS/effect/commit/1b1ef29ae302322f69dc938f9337aa97b4c63266)]: + - @effect/platform@0.68.4 + - @effect/sql@0.16.4 + +## 0.16.3 + +### Patch Changes + +- Updated dependencies [[`61a99b2`](https://github.com/Effect-TS/effect/commit/61a99b2bf9d757870ef0c2ec9d4c877cdd364a3d), [`8c33087`](https://github.com/Effect-TS/effect/commit/8c330879425e80bed2f65e407cd59e991f0d7bec)]: + - effect@3.9.2 + - @effect/platform@0.68.3 + - @effect/sql@0.16.3 + +## 0.16.2 + +### Patch Changes + +- Updated dependencies []: + - @effect/sql@0.16.2 + - @effect/platform@0.68.2 + +## 0.16.1 + +### Patch Changes + +- Updated dependencies [[`b75ac5d`](https://github.com/Effect-TS/effect/commit/b75ac5d0909115507bedc90f18f2d34deb217769)]: + - @effect/platform@0.68.1 + - @effect/sql@0.16.1 + +## 0.16.0 + +### Patch Changes + +- Updated dependencies [[`90ceeab`](https://github.com/Effect-TS/effect/commit/90ceeab3a04051b740af18c8af8bd73ee8ec6363), [`90ceeab`](https://github.com/Effect-TS/effect/commit/90ceeab3a04051b740af18c8af8bd73ee8ec6363), [`90ceeab`](https://github.com/Effect-TS/effect/commit/90ceeab3a04051b740af18c8af8bd73ee8ec6363)]: + - @effect/platform@0.68.0 + - @effect/sql@0.16.0 + +## 0.15.1 + +### Patch Changes + +- Updated dependencies [[`3b2ad1d`](https://github.com/Effect-TS/effect/commit/3b2ad1d58a2e33dc1a72b7037396bd25ca1702a9)]: + - @effect/platform@0.67.1 + - effect@3.9.1 + - @effect/sql@0.15.1 + +## 0.15.0 + +### Patch Changes + +- Updated dependencies [[`ff3d1aa`](https://github.com/Effect-TS/effect/commit/ff3d1aab290b4d1173b2dfc7e4c76abb4babdc16), [`0ba66f2`](https://github.com/Effect-TS/effect/commit/0ba66f2451641fd6990e02ec1ed01c014db9dab0), [`bf77f51`](https://github.com/Effect-TS/effect/commit/bf77f51b323c383224ebf08adf77a7a6e8c9b3cd), [`016f9ad`](https://github.com/Effect-TS/effect/commit/016f9ad931a4b3d09a34e5caf13d87c5b8e9c984), [`0779681`](https://github.com/Effect-TS/effect/commit/07796813f07de035719728733096ba64ce333469), [`534129f`](https://github.com/Effect-TS/effect/commit/534129f8113ce1a8ec50828083e16da9c86326c6), [`d75140c`](https://github.com/Effect-TS/effect/commit/d75140c7a664ceda43142d999f4ff8dcd36d6dda), [`be0451c`](https://github.com/Effect-TS/effect/commit/be0451c149b6618af79cb839cdf04af2db1efb03), [`9237ac6`](https://github.com/Effect-TS/effect/commit/9237ac69bc07de5b3b60076a0ad2921c21de7457), [`be0451c`](https://github.com/Effect-TS/effect/commit/be0451c149b6618af79cb839cdf04af2db1efb03), [`5b36494`](https://github.com/Effect-TS/effect/commit/5b364942e9a9003fdb8217324f8a2d8369c969da), [`c716adb`](https://github.com/Effect-TS/effect/commit/c716adb250ebbea1d1048d818ef7fed4f621d186), [`4986391`](https://github.com/Effect-TS/effect/commit/49863919cd8628c962a712fb1df30d2983820933), [`d75140c`](https://github.com/Effect-TS/effect/commit/d75140c7a664ceda43142d999f4ff8dcd36d6dda), [`d1387ae`](https://github.com/Effect-TS/effect/commit/d1387aebd1ff01bbebde26be46d488956e4daef6)]: + - effect@3.9.0 + - @effect/platform@0.67.0 + - @effect/sql@0.15.0 + +## 0.14.1 + +### Patch Changes + +- Updated dependencies [[`88e85db`](https://github.com/Effect-TS/effect/commit/88e85db34bd402526e27a323e950d053fa34d232), [`f40da15`](https://github.com/Effect-TS/effect/commit/f40da15fbeb7c491840b8f409d47de79720891c3), [`8e94585`](https://github.com/Effect-TS/effect/commit/8e94585abe62753bf3af28bfae77926a7c570ac3), [`83887ca`](https://github.com/Effect-TS/effect/commit/83887ca1b1793916913d8550a4db4450cd14a044), [`5266b6c`](https://github.com/Effect-TS/effect/commit/5266b6cd86d76c3886da041c8829bca04b1a3110), [`cdead5c`](https://github.com/Effect-TS/effect/commit/cdead5c9cfd54dc6c4f215d9732f654c4a12e991), [`f40da15`](https://github.com/Effect-TS/effect/commit/f40da15fbeb7c491840b8f409d47de79720891c3), [`766a8af`](https://github.com/Effect-TS/effect/commit/766a8af307b414aca3648d91c4eab7493a5ec862)]: + - effect@3.8.5 + - @effect/platform@0.66.3 + - @effect/sql@0.14.1 + +## 0.14.0 + +### Patch Changes + +- Updated dependencies [[`f100e20`](https://github.com/Effect-TS/effect/commit/f100e2087172d7e4ab8c0d1ee9a5780b9712382a)]: + - @effect/sql@0.14.0 + +## 0.13.4 + +### Patch Changes + +- Updated dependencies []: + - @effect/sql@0.13.4 + +## 0.13.3 + +### Patch Changes + +- Updated dependencies [[`0a68746`](https://github.com/Effect-TS/effect/commit/0a68746c89651c364db2ee8c72dcfe552e1782ea), [`fd83d0e`](https://github.com/Effect-TS/effect/commit/fd83d0e548feff9ea2d53d370a0b626c4a1d940e), [`4509656`](https://github.com/Effect-TS/effect/commit/45096569d50262275ee984f44c456f5c83b62683), [`090e41c`](https://github.com/Effect-TS/effect/commit/090e41c636d720b1c7d89684a739855765ed4382)]: + - @effect/sql@0.13.3 + - @effect/platform@0.66.2 + - effect@3.8.4 + +## 0.13.2 + +### Patch Changes + +- Updated dependencies [[`3812788`](https://github.com/Effect-TS/effect/commit/3812788d79caaab8f559a62fd443018a04ac5647)]: + - @effect/platform@0.66.1 + - @effect/sql@0.13.2 + +## 0.13.1 + +### Patch Changes + +- Updated dependencies [[`d5c8e7e`](https://github.com/Effect-TS/effect/commit/d5c8e7e47373f9fd78637f24e36d6fb61ee35eb4)]: + - @effect/sql@0.13.1 + +## 0.13.0 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.66.0 + - @effect/sql@0.13.0 + +## 0.12.6 + +### Patch Changes + +- Updated dependencies [[`321b201`](https://github.com/Effect-TS/effect/commit/321b201adcb6bbbeb806b3467dd0b4cf063ccda8), [`bb5ec6b`](https://github.com/Effect-TS/effect/commit/bb5ec6b4b6a6f537394596c5a596faf52cb2aef4)]: + - @effect/platform@0.65.5 + - effect@3.8.3 + - @effect/sql@0.12.6 + +## 0.12.5 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.65.4 + - @effect/sql@0.12.5 + +## 0.12.4 + +### Patch Changes + +- Updated dependencies []: + - @effect/sql@0.12.4 + +## 0.12.3 + +### Patch Changes + +- Updated dependencies [[`f0d8ef1`](https://github.com/Effect-TS/effect/commit/f0d8ef1ce97ec2a87b09b3e24150cfeab85d6e2f)]: + - effect@3.8.2 + - @effect/platform@0.65.3 + - @effect/sql@0.12.3 + +## 0.12.2 + +### Patch Changes + +- [#3607](https://github.com/Effect-TS/effect/pull/3607) [`e38b3dc`](https://github.com/Effect-TS/effect/commit/e38b3dcacd93c7ae594ec8aca5d3dbda2a7a07ca) Thanks @thewilkybarkid! - Return raw SQL query results in sql-sqlite-node + + ```ts + response = yield * sql`INSERT INTO test (name) VALUES ('hello')`.raw + assert.deepStrictEqual(response, { changes: 1, lastInsertRowid: 1 }) + ``` + +- Updated dependencies [[`10bf621`](https://github.com/Effect-TS/effect/commit/10bf6213f36d8ddb00f058a4609b85220f3d8334), [`ae36fa6`](https://github.com/Effect-TS/effect/commit/ae36fa68f754eeab9a54b6dc0f8b44db513aa2b6)]: + - effect@3.8.1 + - @effect/platform@0.65.2 + - @effect/sql@0.12.2 + +## 0.12.1 + +### Patch Changes + +- Updated dependencies [[`e44c5f2`](https://github.com/Effect-TS/effect/commit/e44c5f228215738fe4e75023c7461bf9521249cb)]: + - @effect/platform@0.65.1 + - @effect/sql@0.12.1 + +## 0.12.0 + +### Patch Changes + +- Updated dependencies [[`fcfa6ee`](https://github.com/Effect-TS/effect/commit/fcfa6ee30ffd07d998bf22799357bf58580a116f), [`bb9931b`](https://github.com/Effect-TS/effect/commit/bb9931b62e249a3b801f2cb9d097aec0c8511af7), [`5798f76`](https://github.com/Effect-TS/effect/commit/5798f7619529de33e5ba06f551806f68fedc19db), [`5f0bfa1`](https://github.com/Effect-TS/effect/commit/5f0bfa17205398d4e4818bfbcf9e1b505b3b1fc5), [`812a4e8`](https://github.com/Effect-TS/effect/commit/812a4e86e2d1aa23b477ef5829aa0e5c07784936), [`6a128f6`](https://github.com/Effect-TS/effect/commit/6a128f63f9b41fec2db70790b3bbb96cb9afa1ab), [`273565e`](https://github.com/Effect-TS/effect/commit/273565e7901639e8d0541930ab715aea9c80fbaa), [`adf7d7a`](https://github.com/Effect-TS/effect/commit/adf7d7a7dfce3a7021e9f3b0d847dc85be89d754), [`569a801`](https://github.com/Effect-TS/effect/commit/569a8017ef0a0bc203e4312867cbdd37b0effbd7), [`aa1fa53`](https://github.com/Effect-TS/effect/commit/aa1fa5301e886b9657c8eb0d38cb87cef92a8305), [`02f6b06`](https://github.com/Effect-TS/effect/commit/02f6b0660e12bee1069532a9cc18d3ab855257be), [`12b893e`](https://github.com/Effect-TS/effect/commit/12b893e63cc6dfada4aca7773b4783940e2edf25), [`bbad27e`](https://github.com/Effect-TS/effect/commit/bbad27ec0a90860593f759405caa877e7f4a655f), [`7041393`](https://github.com/Effect-TS/effect/commit/7041393cff132e96566d3f36da0483a6ff6195e4), [`e0d21a5`](https://github.com/Effect-TS/effect/commit/e0d21a54c8323728fbb75a32f4820a9996257809), [`adf7d7a`](https://github.com/Effect-TS/effect/commit/adf7d7a7dfce3a7021e9f3b0d847dc85be89d754), [`007289a`](https://github.com/Effect-TS/effect/commit/007289a52d5877f8e90e2dacf38171ff9bf603fd), [`42a8f99`](https://github.com/Effect-TS/effect/commit/42a8f99740eefdaf2c4544d2c345313f97547a36), [`eebfd29`](https://github.com/Effect-TS/effect/commit/eebfd29633fd5d38b505c5c0842036f61f05e913), [`040703d`](https://github.com/Effect-TS/effect/commit/040703d0e100cd5511e52d812c15492414262b5e)]: + - effect@3.8.0 + - @effect/platform@0.65.0 + - @effect/sql@0.12.0 + +## 0.11.3 + +### Patch Changes + +- Updated dependencies [[`ccd67df`](https://github.com/Effect-TS/effect/commit/ccd67df6b44ae7075a03759bc7866f6bc9ebb03e)]: + - @effect/sql@0.11.3 + +## 0.11.2 + +### Patch Changes + +- Updated dependencies [[`d8aff79`](https://github.com/Effect-TS/effect/commit/d8aff79d4cbedee33d0552ec43fdced007cae358), [`35a0f81`](https://github.com/Effect-TS/effect/commit/35a0f813141652d696461cd5d19fd146adaf85be), [`d8aff79`](https://github.com/Effect-TS/effect/commit/d8aff79d4cbedee33d0552ec43fdced007cae358), [`8261c5a`](https://github.com/Effect-TS/effect/commit/8261c5ae6fe86872292ec1fc1a58ab9cea2f5f51)]: + - @effect/sql@0.11.2 + - effect@3.7.3 + - @effect/platform@0.64.1 + +## 0.11.1 + +### Patch Changes + +- Updated dependencies []: + - @effect/sql@0.11.1 + +## 0.11.0 + +### Patch Changes + +- Updated dependencies [[`90ac8f6`](https://github.com/Effect-TS/effect/commit/90ac8f6f6053a2e4498f8b0cc56fe12777d02e1a), [`90ac8f6`](https://github.com/Effect-TS/effect/commit/90ac8f6f6053a2e4498f8b0cc56fe12777d02e1a), [`3791e24`](https://github.com/Effect-TS/effect/commit/3791e241636b1dfe924a56f380ebc9a7ff0827a9), [`3791e24`](https://github.com/Effect-TS/effect/commit/3791e241636b1dfe924a56f380ebc9a7ff0827a9)]: + - @effect/platform@0.64.0 + - @effect/sql@0.11.0 + +## 0.10.4 + +### Patch Changes + +- Updated dependencies []: + - @effect/sql@0.10.4 + +## 0.10.3 + +### Patch Changes + +- Updated dependencies [[`4a701c4`](https://github.com/Effect-TS/effect/commit/4a701c406da032563fedae459536c00ae5cfe3c7)]: + - @effect/platform@0.63.3 + - @effect/sql@0.10.3 + +## 0.10.2 + +### Patch Changes + +- Updated dependencies [[`8a601d7`](https://github.com/Effect-TS/effect/commit/8a601d7a1f8ffe52ac9e6d67e9282a1495fe59c9), [`353ba19`](https://github.com/Effect-TS/effect/commit/353ba19f9b2b9e959f0a00d058c6d40a4bc02db7)]: + - effect@3.7.2 + - @effect/platform@0.63.2 + - @effect/sql@0.10.2 + +## 0.10.1 + +### Patch Changes + +- Updated dependencies [[`79859e7`](https://github.com/Effect-TS/effect/commit/79859e71040d8edf1868b8530b90c650f4321eff), [`f6a469c`](https://github.com/Effect-TS/effect/commit/f6a469c190b9f00eee5ea0cd4d5912a0ef8b46f5), [`dcb9ec0`](https://github.com/Effect-TS/effect/commit/dcb9ec0db443894dd204d87450f779c44b9ad7f1), [`79aa6b1`](https://github.com/Effect-TS/effect/commit/79aa6b136e1f29b36f34e88cb2ff162bff2bb4ed)]: + - effect@3.7.1 + - @effect/platform@0.63.1 + - @effect/sql@0.10.1 + +## 0.10.0 + +### Patch Changes + +- Updated dependencies [[`db89601`](https://github.com/Effect-TS/effect/commit/db89601ee9c1050c4e762b7bd7ec65a6a2799dfe), [`2f456cc`](https://github.com/Effect-TS/effect/commit/2f456cce5012b9fcb6b4e039190d527813b75b92), [`8745e41`](https://github.com/Effect-TS/effect/commit/8745e41ed96e3765dc6048efc2a9afbe05c8a1e9), [`e557838`](https://github.com/Effect-TS/effect/commit/e55783886b046d3c5f33447f455f9ccf2fa75922), [`d6e7e40`](https://github.com/Effect-TS/effect/commit/d6e7e40b1e2ad0c59aa02f07344d28601b14ebdc), [`8356321`](https://github.com/Effect-TS/effect/commit/8356321598da04bd77c1001f45a4e447bec5591d), [`192f2eb`](https://github.com/Effect-TS/effect/commit/192f2ebb2c4ddbf4bfd8baedd32140b2376868f4), [`718cb70`](https://github.com/Effect-TS/effect/commit/718cb70038629a6d58d02e407760e341f7c94474), [`e9d0310`](https://github.com/Effect-TS/effect/commit/e9d03107acbf204d9304f3e8aea0816b7d3c7dfb), [`6bf28f7`](https://github.com/Effect-TS/effect/commit/6bf28f7e3b1e5e0608ff567205fea0581d11666f)]: + - effect@3.7.0 + - @effect/platform@0.63.0 + - @effect/sql@0.10.0 + +## 0.9.7 + +### Patch Changes + +- Updated dependencies [[`e809286`](https://github.com/Effect-TS/effect/commit/e8092865900608c4df7a6b7991b1c13cc1e4ca2d)]: + - effect@3.6.8 + - @effect/platform@0.62.5 + - @effect/sql@0.9.7 + +## 0.9.6 + +### Patch Changes + +- Updated dependencies [[`e7a65e3`](https://github.com/Effect-TS/effect/commit/e7a65e3c6a08636bbfce3d3af3098bf28474364d), [`50ec889`](https://github.com/Effect-TS/effect/commit/50ec8897a49b7d1fe84f63107f89d543c52f3dfc)]: + - @effect/platform@0.62.4 + - effect@3.6.7 + - @effect/sql@0.9.6 + +## 0.9.5 + +### Patch Changes + +- Updated dependencies [[`f960bf4`](https://github.com/Effect-TS/effect/commit/f960bf45239e9badac6e0ad3a602f4174cd7bbdf), [`46a575f`](https://github.com/Effect-TS/effect/commit/46a575f48a05457b782fb21f7827d338c9b59320)]: + - effect@3.6.6 + - @effect/platform@0.62.3 + - @effect/sql@0.9.5 + +## 0.9.4 + +### Patch Changes + +- Updated dependencies [[`413994c`](https://github.com/Effect-TS/effect/commit/413994c9792f16d9d57cca3ae6eb254bf93bd261), [`14a47a8`](https://github.com/Effect-TS/effect/commit/14a47a8c1f3cff2186b8fe7a919a1d773888fb5b), [`35be739`](https://github.com/Effect-TS/effect/commit/35be739a413e32ed251f775714af2f87355e8664), [`f8326cc`](https://github.com/Effect-TS/effect/commit/f8326cc1095630a3fbee3f25d6b4e74edb905903), [`0c09841`](https://github.com/Effect-TS/effect/commit/0c0984173be3d58f050b300a1a8aa89d76ba49ae), [`8dd3959`](https://github.com/Effect-TS/effect/commit/8dd3959e967ca2b38ba601d94a80f1c50e9445e0), [`2cb6ebb`](https://github.com/Effect-TS/effect/commit/2cb6ebbf782b79643befa061c6adcf0366a7b8b3), [`5e9f51e`](https://github.com/Effect-TS/effect/commit/5e9f51e4a1169018d7f59a0db444c783cc1d5794), [`83a108a`](https://github.com/Effect-TS/effect/commit/83a108a254341721d20a82633b1e1d406d2368a3), [`f2c8dbb`](https://github.com/Effect-TS/effect/commit/f2c8dbb77e196c9a36cb3bf2ae3b82ce68e9874d), [`5e9f51e`](https://github.com/Effect-TS/effect/commit/5e9f51e4a1169018d7f59a0db444c783cc1d5794)]: + - @effect/platform@0.62.2 + - effect@3.6.5 + - @effect/sql@0.9.4 + +## 0.9.3 + +### Patch Changes + +- Updated dependencies [[`c3446d3`](https://github.com/Effect-TS/effect/commit/c3446d3e57b0cbfe9341d6f2aebf5f5d6fefefe3), [`9efe0e5`](https://github.com/Effect-TS/effect/commit/9efe0e5b57ac557399be620822c21cc6e9add285)]: + - @effect/sql@0.9.3 + - @effect/platform@0.62.1 + +## 0.9.2 + +### Patch Changes + +- Updated dependencies [[`cfcfbdf`](https://github.com/Effect-TS/effect/commit/cfcfbdfe586b011a5edc28083fd5391edeee0023)]: + - @effect/sql@0.9.2 + +## 0.9.1 + +### Patch Changes + +- Updated dependencies [[`e9da539`](https://github.com/Effect-TS/effect/commit/e9da5396bba99b2ddc20c97c7955154e6da4cab5), [`4fabf75`](https://github.com/Effect-TS/effect/commit/4fabf75b44ea98b1773059bd589167d5d8f64f06)]: + - @effect/sql@0.9.1 + +## 0.9.0 + +### Minor Changes + +- [#3457](https://github.com/Effect-TS/effect/pull/3457) [`a07990d`](https://github.com/Effect-TS/effect/commit/a07990de977fb60ab4af1e8f3a2250454dedbb34) Thanks @IMax153! - Add support for executing raw SQL queries with the underlying SQL client. + + This is primarily useful when the SQL client returns special results for certain + query types. + + For example, because MySQL does not support the `RETURNING` clause, the `mysql2` + client will return a [`ResultSetHeader`](https://sidorares.github.io/node-mysql2/docs/documentation/typescript-examples#resultsetheader) + for `INSERT`, `UPDATE`, `DELETE`, and `TRUNCATE` operations. + + To gain access to the raw results of a query, you can use the `.raw` property on + the `Statement`: + + ```ts + import * as Effect from "effect/Effect" + import * as SqlClient from "effect/unstable/sql/SqlClient" + import * as MysqlClient from "effect/unstable/sql/MysqlClient" + + const DatabaseLive = MysqlClient.layer({ + database: Config.succeed("database"), + username: Config.succeed("root"), + password: Config.succeed(Redacted.make("password")) + }) + + const program = Effect.gen(function* () { + const sql = yield* SqlClient.SqlClient + + const result = yield* sql`INSERT INTO usernames VALUES ("Bob")`.raw + + console.log(result) + /** + * ResultSetHeader { + * fieldCount: 0, + * affectedRows: 1, + * insertId: 0, + * info: '', + * serverStatus: 2, + * warningStatus: 0, + * changedRows: 0 + * } + */ + }) + + program.pipe(Effect.provide(DatabaseLive), Effect.runPromise) + ``` + +### Patch Changes + +- Updated dependencies [[`8295281`](https://github.com/Effect-TS/effect/commit/8295281ae9bd7441e680402540bf3c8682ec417b), [`c940df6`](https://github.com/Effect-TS/effect/commit/c940df63800bf3c4396d91cf28ec34938642fd2c), [`00b6c6d`](https://github.com/Effect-TS/effect/commit/00b6c6d4001f5de728b7d990a1b14560b4961a63), [`a07990d`](https://github.com/Effect-TS/effect/commit/a07990de977fb60ab4af1e8f3a2250454dedbb34), [`f8d95a6`](https://github.com/Effect-TS/effect/commit/f8d95a61ad0762147933c5c32bb6d7237e18eef4)]: + - effect@3.6.4 + - @effect/sql@0.9.0 + - @effect/platform@0.62.0 + +## 0.8.7 + +### Patch Changes + +- Updated dependencies [[`04adcac`](https://github.com/Effect-TS/effect/commit/04adcace913e6fc483df266874a68005e9e04ccf)]: + - effect@3.6.3 + - @effect/platform@0.61.8 + - @effect/sql@0.8.7 + +## 0.8.6 + +### Patch Changes + +- Updated dependencies [[`17245a4`](https://github.com/Effect-TS/effect/commit/17245a4e783c19dee51529600b3b40f164fa59bc), [`630d40e`](https://github.com/Effect-TS/effect/commit/630d40eaa7eb4d2f8b6705b16d4f426bc28a7d09), [`630d40e`](https://github.com/Effect-TS/effect/commit/630d40eaa7eb4d2f8b6705b16d4f426bc28a7d09)]: + - @effect/platform@0.61.7 + - @effect/sql@0.8.6 + +## 0.8.5 + +### Patch Changes + +- Updated dependencies [[`d829b57`](https://github.com/Effect-TS/effect/commit/d829b576357f2e3b203ab7e107a1492de903a106), [`fd4b2f6`](https://github.com/Effect-TS/effect/commit/fd4b2f6516b325740dde615f1cf0229edf13ca0c)]: + - @effect/platform@0.61.6 + - effect@3.6.2 + - @effect/sql@0.8.5 + +## 0.8.4 + +### Patch Changes + +- Updated dependencies [[`056b710`](https://github.com/Effect-TS/effect/commit/056b7108978e70612176c23991916f678d947f38)]: + - @effect/platform@0.61.5 + - @effect/sql@0.8.4 + +## 0.8.3 + +### Patch Changes + +- Updated dependencies [[`e7cb109`](https://github.com/Effect-TS/effect/commit/e7cb109d0754207024a64d55b6bd2a674dd8ed7d)]: + - @effect/platform@0.61.4 + - @effect/sql@0.8.3 + +## 0.8.2 + +### Patch Changes + +- Updated dependencies [[`510a34d`](https://github.com/Effect-TS/effect/commit/510a34d4cc5d2f51347a53847f6c7db84d2b17c6), [`fb9f786`](https://github.com/Effect-TS/effect/commit/fb9f7867f0c895e63f9ef23e8d0941248c42179d), [`45dbb9f`](https://github.com/Effect-TS/effect/commit/45dbb9ffeaf93d9e4df99d0cd4920e41ba9a3978)]: + - effect@3.6.1 + - @effect/platform@0.61.3 + - @effect/sql@0.8.2 + +## 0.8.1 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.61.2 + - @effect/sql@0.8.1 + +## 0.8.0 + +### Patch Changes + +- Updated dependencies [[`42d0706`](https://github.com/Effect-TS/effect/commit/42d07067e9823ceb8977eff9672d9a290941dad5), [`11223bf`](https://github.com/Effect-TS/effect/commit/11223bf9cbf5b822e0bf9a9fb2b35b2ad88af692)]: + - @effect/sql@0.8.0 + - @effect/platform@0.61.1 + +## 0.7.0 + +### Patch Changes + +- Updated dependencies [[`1e0fe80`](https://github.com/Effect-TS/effect/commit/1e0fe802b36c257971296617473ce0abe730e8dc), [`8135294`](https://github.com/Effect-TS/effect/commit/8135294b591ea94fde7e6f94a504608f0e630520), [`cd255a4`](https://github.com/Effect-TS/effect/commit/cd255a48872d8fb924cf713ef73f0883a9cc6987), [`3845646`](https://github.com/Effect-TS/effect/commit/3845646828e98f3c7cda1217f6cfe5f642ac0603), [`2d09078`](https://github.com/Effect-TS/effect/commit/2d09078c5948b37fc2f79ef858fe4ca3e4814085), [`4bce5a0`](https://github.com/Effect-TS/effect/commit/4bce5a0274203550ccf117d830721891b0a3d182), [`4ddbff0`](https://github.com/Effect-TS/effect/commit/4ddbff0bb4e3ffddfeb509c59835b83245fb975e), [`e74cc38`](https://github.com/Effect-TS/effect/commit/e74cc38cb420a320c4d7ef98180f19d452a8b316), [`bb069b4`](https://github.com/Effect-TS/effect/commit/bb069b49ef291c532a02c1e8e74271f6d1bb32ec), [`cd255a4`](https://github.com/Effect-TS/effect/commit/cd255a48872d8fb924cf713ef73f0883a9cc6987), [`7d02174`](https://github.com/Effect-TS/effect/commit/7d02174af3bcbf054e5cdddb821c91d0f47e8285)]: + - effect@3.6.0 + - @effect/platform@0.61.0 + - @effect/sql@0.7.0 + +## 0.6.3 + +### Patch Changes + +- Updated dependencies [[`6359644`](https://github.com/Effect-TS/effect/commit/635964446323cf55d4060559337e710e4a24496e), [`7f41e42`](https://github.com/Effect-TS/effect/commit/7f41e428830bf3043b8be0d28dcd235d5747c942), [`f566fd1`](https://github.com/Effect-TS/effect/commit/f566fd1d7eea531a0d981dd24037f14a603a1273)]: + - effect@3.5.9 + - @effect/platform@0.60.3 + - @effect/sql@0.6.3 + +## 0.6.2 + +### Patch Changes + +- Updated dependencies [[`eb4d014`](https://github.com/Effect-TS/effect/commit/eb4d014c559e1b4c95b3fb9295fe77593c17ed7a), [`1ba640c`](https://github.com/Effect-TS/effect/commit/1ba640c702f187a866023bf043c26e25cce941ef), [`c8c71bd`](https://github.com/Effect-TS/effect/commit/c8c71bd20eb87d23133dac6156b83bb08941597c), [`a26ce58`](https://github.com/Effect-TS/effect/commit/a26ce581ca7d407e1e81439b58c8045b3fa65231), [`fc20f73`](https://github.com/Effect-TS/effect/commit/fc20f73c69e577981cb64714de2adc97e1004dae)]: + - @effect/platform@0.60.2 + - effect@3.5.8 + - @effect/sql@0.6.2 + +## 0.6.1 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.60.1 + - @effect/sql@0.6.1 + +## 0.6.0 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.60.0 + - @effect/sql@0.6.0 + +## 0.5.3 + +### Patch Changes + +- [#3310](https://github.com/Effect-TS/effect/pull/3310) [`99bddcf`](https://github.com/Effect-TS/effect/commit/99bddcfb3d6eab4d489d055404e26ad81afe52fc) Thanks @fubhy! - Added additional pure annotations to improve tree-shakeability + +- Updated dependencies [[`3afcc93`](https://github.com/Effect-TS/effect/commit/3afcc93413a3d910beb69e4ce9ae120e4adaffd5), [`99bddcf`](https://github.com/Effect-TS/effect/commit/99bddcfb3d6eab4d489d055404e26ad81afe52fc)]: + - effect@3.5.7 + - @effect/platform@0.59.3 + - @effect/sql@0.5.3 + +## 0.5.2 + +### Patch Changes + +- Updated dependencies [[`cc327a1`](https://github.com/Effect-TS/effect/commit/cc327a1bccd22a4ee27ec7e58b53205e93b23e2c), [`4bfe4fb`](https://github.com/Effect-TS/effect/commit/4bfe4fb5c82f597c9beea9baa92e772593598b60), [`2b14d18`](https://github.com/Effect-TS/effect/commit/2b14d181462cad8359da4fa6bc6dfda0f742c398)]: + - effect@3.5.6 + - @effect/platform@0.59.2 + - @effect/sql@0.5.2 + +## 0.5.1 + +### Patch Changes + +- Updated dependencies [[`a9d7800`](https://github.com/Effect-TS/effect/commit/a9d7800f6a253192b653d77778b0674f39b1ca39), [`fcecff7`](https://github.com/Effect-TS/effect/commit/fcecff7f7e12b295a252f124861b801c73072151), [`adbf753`](https://github.com/Effect-TS/effect/commit/adbf75340a9db15dc5cadc66e911a8978a195a65), [`adbf753`](https://github.com/Effect-TS/effect/commit/adbf75340a9db15dc5cadc66e911a8978a195a65)]: + - effect@3.5.5 + - @effect/platform@0.59.1 + - @effect/sql@0.5.1 + +## 0.5.0 + +### Minor Changes + +- [#3260](https://github.com/Effect-TS/effect/pull/3260) [`53c0db0`](https://github.com/Effect-TS/effect/commit/53c0db06872d5b5edea2a706e83249908385325c) Thanks @tim-smart! - replace /platform RefailError with use of the "cause" property + +### Patch Changes + +- [#3253](https://github.com/Effect-TS/effect/pull/3253) [`ed0dde4`](https://github.com/Effect-TS/effect/commit/ed0dde4888e6f1a97ad5bba06b755d26a6a1c52e) Thanks @tim-smart! - update dependencies + +- Updated dependencies [[`53c0db0`](https://github.com/Effect-TS/effect/commit/53c0db06872d5b5edea2a706e83249908385325c), [`ed0dde4`](https://github.com/Effect-TS/effect/commit/ed0dde4888e6f1a97ad5bba06b755d26a6a1c52e), [`ada68b3`](https://github.com/Effect-TS/effect/commit/ada68b3e61c67907c2a281c024c84d818186ca4c), [`ca775ce`](https://github.com/Effect-TS/effect/commit/ca775cec53baebc1a43d9b8852a3ac6726178498), [`5be9cc0`](https://github.com/Effect-TS/effect/commit/5be9cc044025a9541b9b7acefa2d3fc05fa1301b), [`203658f`](https://github.com/Effect-TS/effect/commit/203658f8001c132b25764ab70344b171683b554c), [`eb1c4d4`](https://github.com/Effect-TS/effect/commit/eb1c4d44e54b9d8d201a366d1ff94face2a6dcd3)]: + - @effect/platform@0.59.0 + - @effect/sql@0.5.0 + - effect@3.5.4 + +## 0.4.27 + +### Patch Changes + +- Updated dependencies [[`edb0da3`](https://github.com/Effect-TS/effect/commit/edb0da383746d760f35d8582f5fb0cc0eeca9217), [`a1db40a`](https://github.com/Effect-TS/effect/commit/a1db40a650ab842e778654f0d88e80f2ef4fd6f3), [`c8d3fb0`](https://github.com/Effect-TS/effect/commit/c8d3fb0fe23585f6efb724af51fbab3ba1ad6e83), [`dabd028`](https://github.com/Effect-TS/effect/commit/dabd028decf9b7983ca16ebe0f48c05c11a84b68), [`786b2ab`](https://github.com/Effect-TS/effect/commit/786b2ab29d525c877bb84035dac9e2d6499339d1), [`fc57354`](https://github.com/Effect-TS/effect/commit/fc573547d41667016fce05eaee75960fcc6dce4d)]: + - effect@3.5.3 + - @effect/platform@0.58.27 + - @effect/sql@0.4.27 + +## 0.4.26 + +### Patch Changes + +- Updated dependencies [[`639208e`](https://github.com/Effect-TS/effect/commit/639208eeb8a44622994f832bc2d45d06ab636bc8), [`6684b4c`](https://github.com/Effect-TS/effect/commit/6684b4c27d77a7fcc7af2e261a450edf971b62b5), [`6684b4c`](https://github.com/Effect-TS/effect/commit/6684b4c27d77a7fcc7af2e261a450edf971b62b5), [`6684b4c`](https://github.com/Effect-TS/effect/commit/6684b4c27d77a7fcc7af2e261a450edf971b62b5)]: + - effect@3.5.2 + - @effect/platform@0.58.26 + - @effect/sql@0.4.26 + +## 0.4.25 + +### Patch Changes + +- Updated dependencies [[`0623fca`](https://github.com/Effect-TS/effect/commit/0623fca41679b0e3c5a10dd0f8985f91670bd721)]: + - @effect/platform@0.58.25 + - @effect/sql@0.4.25 + +## 0.4.24 + +### Patch Changes + +- Updated dependencies [[`55fdd76`](https://github.com/Effect-TS/effect/commit/55fdd761ee95afd73b6a892c13fee92b36c02837)]: + - effect@3.5.1 + - @effect/platform@0.58.24 + - @effect/sql@0.4.24 + +## 0.4.23 + +### Patch Changes + +- Updated dependencies [[`a1f5b83`](https://github.com/Effect-TS/effect/commit/a1f5b831a1bc7535988b370d68d0b3eb1123e0ce), [`a1f5b83`](https://github.com/Effect-TS/effect/commit/a1f5b831a1bc7535988b370d68d0b3eb1123e0ce), [`a1f5b83`](https://github.com/Effect-TS/effect/commit/a1f5b831a1bc7535988b370d68d0b3eb1123e0ce), [`60bc3d0`](https://github.com/Effect-TS/effect/commit/60bc3d0867b13e48b24dc22604b4dd2e7b2c1ca4), [`5ab348f`](https://github.com/Effect-TS/effect/commit/5ab348f265db3d283aa091ddca6d2d49137c16f2), [`60bc3d0`](https://github.com/Effect-TS/effect/commit/60bc3d0867b13e48b24dc22604b4dd2e7b2c1ca4), [`3e04bf8`](https://github.com/Effect-TS/effect/commit/3e04bf8a7127e956cadb7684a8f4c661df57663b), [`e7fc45f`](https://github.com/Effect-TS/effect/commit/e7fc45f0c7002aafdaec7878149ac064cd104ea3), [`a1f5b83`](https://github.com/Effect-TS/effect/commit/a1f5b831a1bc7535988b370d68d0b3eb1123e0ce), [`4626de5`](https://github.com/Effect-TS/effect/commit/4626de59c25b384216faa0be87bf0b8cd36357d0), [`f01e7db`](https://github.com/Effect-TS/effect/commit/f01e7db317827255d7901f523f2e28b43298e8df), [`60bc3d0`](https://github.com/Effect-TS/effect/commit/60bc3d0867b13e48b24dc22604b4dd2e7b2c1ca4), [`79d2d91`](https://github.com/Effect-TS/effect/commit/79d2d91464d95dde0e9444d43e7a7f309f05d6e6), [`ac71f37`](https://github.com/Effect-TS/effect/commit/ac71f378f2413e5aa91c95f649ffe898d6a26114), [`8432360`](https://github.com/Effect-TS/effect/commit/8432360ce68614a419bb328083a4109d0fc8aa93), [`e4bf1bf`](https://github.com/Effect-TS/effect/commit/e4bf1bf2b4a970eacd77c9b77b5ea8c68bc84498), [`13cb861`](https://github.com/Effect-TS/effect/commit/13cb861a5eded15c55c6cdcf6a8acde8320367a6), [`79d2d91`](https://github.com/Effect-TS/effect/commit/79d2d91464d95dde0e9444d43e7a7f309f05d6e6), [`e7fc45f`](https://github.com/Effect-TS/effect/commit/e7fc45f0c7002aafdaec7878149ac064cd104ea3), [`9f66825`](https://github.com/Effect-TS/effect/commit/9f66825f1fce0fe8d10420c285f7dc4c71e8af8d)]: + - effect@3.5.0 + - @effect/platform@0.58.23 + - @effect/sql@0.4.23 + +## 0.4.22 + +### Patch Changes + +- Updated dependencies [[`7af137c`](https://github.com/Effect-TS/effect/commit/7af137c9433f6e74959b3887561ec1e6f12e10ee), [`ee4b3dc`](https://github.com/Effect-TS/effect/commit/ee4b3dc5f68d19dc3ae1c2d12901c5b8ffbebabb), [`366f2ee`](https://github.com/Effect-TS/effect/commit/366f2ee3fb6f712a44e8f84fc188612e5ecc016d), [`366f2ee`](https://github.com/Effect-TS/effect/commit/366f2ee3fb6f712a44e8f84fc188612e5ecc016d), [`097d25c`](https://github.com/Effect-TS/effect/commit/097d25cb5d13c049e01789651be56b09620186ef)]: + - effect@3.4.9 + - @effect/platform@0.58.22 + - @effect/sql@0.4.22 + +## 0.4.21 + +### Patch Changes + +- Updated dependencies [[`a435e0f`](https://github.com/Effect-TS/effect/commit/a435e0fc5378b33a49bcec92ee235df6f16a2419), [`b5554db`](https://github.com/Effect-TS/effect/commit/b5554db36c4dd6f64fa5e6a62a29b2759c54217a), [`a9c4fb3`](https://github.com/Effect-TS/effect/commit/a9c4fb3bf3c6e92cd1c142b0605fddf7eb3c697c)]: + - effect@3.4.8 + - @effect/platform@0.58.21 + - @effect/sql@0.4.21 + +## 0.4.20 + +### Patch Changes + +- Updated dependencies [[`a5737d6`](https://github.com/Effect-TS/effect/commit/a5737d6db2b921605c332eabbc5402ee3d17357b)]: + - effect@3.4.7 + - @effect/platform@0.58.20 + - @effect/sql@0.4.20 + +## 0.4.19 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.58.19 + - @effect/sql@0.4.19 + +## 0.4.18 + +### Patch Changes + +- Updated dependencies [[`7f8900a`](https://github.com/Effect-TS/effect/commit/7f8900a1de9addeb0d371103a2c5c2aa3e4ff95e)]: + - @effect/platform@0.58.18 + - @effect/sql@0.4.18 + +## 0.4.17 + +### Patch Changes + +- Updated dependencies [[`5c0ceb0`](https://github.com/Effect-TS/effect/commit/5c0ceb00826cce9e50bf9d41d83e191d5352c030), [`5c0ceb0`](https://github.com/Effect-TS/effect/commit/5c0ceb00826cce9e50bf9d41d83e191d5352c030), [`33735b1`](https://github.com/Effect-TS/effect/commit/33735b16b41bd26929d8f4754c190925db6323b7), [`5c0ceb0`](https://github.com/Effect-TS/effect/commit/5c0ceb00826cce9e50bf9d41d83e191d5352c030), [`139d4b3`](https://github.com/Effect-TS/effect/commit/139d4b39fb3bff2eeaa7c0c809c581da42425a83)]: + - effect@3.4.6 + - @effect/platform@0.58.17 + - @effect/sql@0.4.17 + +## 0.4.16 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.58.16 + - @effect/sql@0.4.16 + +## 0.4.15 + +### Patch Changes + +- Updated dependencies [[`baa90df`](https://github.com/Effect-TS/effect/commit/baa90df9663f5f37d7b6814dad25142d53dbc720)]: + - @effect/platform@0.58.15 + - @effect/sql@0.4.15 + +## 0.4.14 + +### Patch Changes + +- Updated dependencies [[`52a87c7`](https://github.com/Effect-TS/effect/commit/52a87c7a0b9536398deaf8ec507e53a82c607219), [`6d2280e`](https://github.com/Effect-TS/effect/commit/6d2280e9497c95cb0e965ca462c825345074eedf)]: + - @effect/platform@0.58.14 + - @effect/sql@0.4.14 + +## 0.4.13 + +### Patch Changes + +- Updated dependencies [[`a047af9`](https://github.com/Effect-TS/effect/commit/a047af99447dfffc729e9c8ef0ca143537927e91), [`dbd53ea`](https://github.com/Effect-TS/effect/commit/dbd53ea363c71a24449cb068251054c3a1acf864)]: + - effect@3.4.5 + - @effect/platform@0.58.13 + - @effect/sql@0.4.13 + +## 0.4.12 + +### Patch Changes + +- Updated dependencies [[`74e0ad2`](https://github.com/Effect-TS/effect/commit/74e0ad23b4c36f41b7fd10856b20f8b701bc4044), [`74e0ad2`](https://github.com/Effect-TS/effect/commit/74e0ad23b4c36f41b7fd10856b20f8b701bc4044), [`72638e3`](https://github.com/Effect-TS/effect/commit/72638e3d99f0e93a24febf6c225256ce92d4a20b), [`d7dde2b`](https://github.com/Effect-TS/effect/commit/d7dde2b4af08b37af859d4c327c1f5c6f00cf9d9), [`9b2fc3b`](https://github.com/Effect-TS/effect/commit/9b2fc3b9dfd304a2bd0508ef2313cfc54357be0c)]: + - @effect/platform@0.58.12 + - effect@3.4.4 + - @effect/sql@0.4.12 + +## 0.4.11 + +### Patch Changes + +- Updated dependencies [[`a5b95b5`](https://github.com/Effect-TS/effect/commit/a5b95b548284e4798654ae7ce6883fa49108f0ea), [`5e29579`](https://github.com/Effect-TS/effect/commit/5e29579187cb8420ea4930b3999fec984f8999f4)]: + - @effect/platform@0.58.11 + - @effect/sql@0.4.11 + +## 0.4.10 + +### Patch Changes + +- [#3079](https://github.com/Effect-TS/effect/pull/3079) [`bbdd365`](https://github.com/Effect-TS/effect/commit/bbdd36567706c94cdec45bacea825941c347b6cd) Thanks @tim-smart! - update dependencies + +- [#3079](https://github.com/Effect-TS/effect/pull/3079) [`bbdd365`](https://github.com/Effect-TS/effect/commit/bbdd36567706c94cdec45bacea825941c347b6cd) Thanks @tim-smart! - update to typescript 5.5 + +- Updated dependencies [[`a48ee84`](https://github.com/Effect-TS/effect/commit/a48ee845ac21bbde9baf938af9e97a98322211c9), [`c342739`](https://github.com/Effect-TS/effect/commit/c3427396226e1ad7b95b40595a23f9bdff3e3365), [`8898e5e`](https://github.com/Effect-TS/effect/commit/8898e5e238622f6337583d91ee23609c1f5ccdf7), [`a48ee84`](https://github.com/Effect-TS/effect/commit/a48ee845ac21bbde9baf938af9e97a98322211c9), [`a48ee84`](https://github.com/Effect-TS/effect/commit/a48ee845ac21bbde9baf938af9e97a98322211c9), [`ff78636`](https://github.com/Effect-TS/effect/commit/ff786367c522975f40f0f179a0ecdfcfab7ecbdb), [`c86bd4e`](https://github.com/Effect-TS/effect/commit/c86bd4e134c23146c216f9ff97e03781d55991b6), [`bbdd365`](https://github.com/Effect-TS/effect/commit/bbdd36567706c94cdec45bacea825941c347b6cd), [`ab3180f`](https://github.com/Effect-TS/effect/commit/ab3180f827041d0ea3b2d72254a1a8683e99e056), [`bbdd365`](https://github.com/Effect-TS/effect/commit/bbdd36567706c94cdec45bacea825941c347b6cd)]: + - @effect/platform@0.58.10 + - effect@3.4.3 + - @effect/sql@0.4.10 + +## 0.4.9 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.58.9 + - @effect/sql@0.4.9 + +## 0.4.8 + +### Patch Changes + +- Updated dependencies [[`3da1497`](https://github.com/Effect-TS/effect/commit/3da1497b5c9cc886d300258bc928fd68a4fefe6f)]: + - effect@3.4.2 + - @effect/platform@0.58.8 + - @effect/sql@0.4.8 + +## 0.4.7 + +### Patch Changes + +- Updated dependencies [[`027004a`](https://github.com/Effect-TS/effect/commit/027004a897f654791e75faa28eefb50dd0244b6e)]: + - @effect/platform@0.58.7 + - @effect/sql@0.4.7 + +## 0.4.6 + +### Patch Changes + +- Updated dependencies [[`66a1910`](https://github.com/Effect-TS/effect/commit/66a19109ff90c4252123b8809b8c8a74681dba6a), [`2e8e252`](https://github.com/Effect-TS/effect/commit/2e8e2520cac712f0eb644553bd476429ebd674e4)]: + - effect@3.4.1 + - @effect/platform@0.58.6 + - @effect/sql@0.4.6 + +## 0.4.5 + +### Patch Changes + +- Updated dependencies [[`37a07a2`](https://github.com/Effect-TS/effect/commit/37a07a2d8d1ce09ab965c0ada84a3fae9a6aba05)]: + - @effect/platform@0.58.5 + - @effect/sql@0.4.5 + +## 0.4.4 + +### Patch Changes + +- Updated dependencies [[`b77fb0a`](https://github.com/Effect-TS/effect/commit/b77fb0a811ec1ad0e794917077c9a90824515db8)]: + - @effect/platform@0.58.4 + - @effect/sql@0.4.4 + +## 0.4.3 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.58.3 + - @effect/sql@0.4.3 + +## 0.4.2 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.58.2 + - @effect/sql@0.4.2 + +## 0.4.1 + +### Patch Changes + +- Updated dependencies [[`5a248aa`](https://github.com/Effect-TS/effect/commit/5a248aa5ab2db3f7131ebc79bb9871a76de57973)]: + - @effect/platform@0.58.1 + - @effect/sql@0.4.1 + +## 0.4.0 + +### Minor Changes + +- [#3035](https://github.com/Effect-TS/effect/pull/3035) [`d33d8b0`](https://github.com/Effect-TS/effect/commit/d33d8b050b8e3c87dcde9587083e6c1cf733f72b) Thanks @tim-smart! - restructure sql modules to have flat imports + +### Patch Changes + +- Updated dependencies [[`c0ce180`](https://github.com/Effect-TS/effect/commit/c0ce180861ad0938053c0e6145e813fa6404df3b), [`d33d8b0`](https://github.com/Effect-TS/effect/commit/d33d8b050b8e3c87dcde9587083e6c1cf733f72b), [`63dd0c3`](https://github.com/Effect-TS/effect/commit/63dd0c3af45876c1caad7d03356c74daf551c628), [`61707b6`](https://github.com/Effect-TS/effect/commit/61707b6ffc7397c2ba0dce22512b44955724f60f), [`9c1b5b3`](https://github.com/Effect-TS/effect/commit/9c1b5b39e6c19604ce834f072a114ad392c50a06), [`a35faf8`](https://github.com/Effect-TS/effect/commit/a35faf8d116f94899bfc03feab33b004c8ddfdf7), [`ff73c0c`](https://github.com/Effect-TS/effect/commit/ff73c0cacd66132bfad2e5211b3eae347729c667), [`984d516`](https://github.com/Effect-TS/effect/commit/984d516ccd9412dc41188f6a46b748dd20dd5848), [`8c3b8a2`](https://github.com/Effect-TS/effect/commit/8c3b8a2ce208eab753b6206a51605a424f104e98), [`017e2f9`](https://github.com/Effect-TS/effect/commit/017e2f9b371ce24ea4945e5d7390c934ad3c39cf), [`91bf8a2`](https://github.com/Effect-TS/effect/commit/91bf8a2e9d1959393b3cf7366cc1d584d3e666b7), [`c6a4a26`](https://github.com/Effect-TS/effect/commit/c6a4a266606575fd2c7165940c4072ad4c57d01f)]: + - effect@3.4.0 + - @effect/sql@0.4.0 + - @effect/platform@0.58.0 + +## 0.3.19 + +### Patch Changes + +- Updated dependencies [[`3ba7ea1`](https://github.com/Effect-TS/effect/commit/3ba7ea1c3c2923e85bf2f17e41176f8f8796d203)]: + - @effect/platform@0.57.8 + - @effect/sql@0.3.18 + +## 0.3.18 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.57.7 + - @effect/sql@0.3.17 + +## 0.3.17 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.57.6 + - @effect/sql@0.3.16 + +## 0.3.16 + +### Patch Changes + +- Updated dependencies [[`b8ea6aa`](https://github.com/Effect-TS/effect/commit/b8ea6aa479006358042b4256ee0a1c5cfbe57acb)]: + - @effect/platform@0.57.5 + - @effect/sql@0.3.15 + +## 0.3.15 + +### Patch Changes + +- Updated dependencies [[`6c89408`](https://github.com/Effect-TS/effect/commit/6c89408cd7b9204ec4c5828a46cd5312d8afb5e7)]: + - effect@3.3.5 + - @effect/platform@0.57.4 + - @effect/sql@0.3.14 + +## 0.3.14 + +### Patch Changes + +- Updated dependencies [[`a67b8fe`](https://github.com/Effect-TS/effect/commit/a67b8fe2ace08419424811b5f0d9a5378eaea352)]: + - effect@3.3.4 + - @effect/platform@0.57.3 + - @effect/sql@0.3.13 + +## 0.3.13 + +### Patch Changes + +- Updated dependencies [[`06ede85`](https://github.com/Effect-TS/effect/commit/06ede85d6e84710e6622463be95ff3927fb30dad), [`7204ca5`](https://github.com/Effect-TS/effect/commit/7204ca5761c2b1d27999a624db23aa10b6e0504d)]: + - effect@3.3.3 + - @effect/platform@0.57.2 + - @effect/sql@0.3.12 + +## 0.3.12 + +### Patch Changes + +- Updated dependencies [[`07e12ec`](https://github.com/Effect-TS/effect/commit/07e12ecdb0e20b9763bd9e9058e567a7c8862efc), [`3572646`](https://github.com/Effect-TS/effect/commit/3572646d5e0804f85bc7f64633fb95722533f9dd), [`1aed347`](https://github.com/Effect-TS/effect/commit/1aed347a125ed3847ec90863424810d6759cbc85), [`df4bf4b`](https://github.com/Effect-TS/effect/commit/df4bf4b62e7b316c6647da0271fc5544a84e7ba2), [`f085f92`](https://github.com/Effect-TS/effect/commit/f085f92dfa204afb41823ffc27d437225137643d)]: + - @effect/platform@0.57.1 + - effect@3.3.2 + - @effect/sql@0.3.11 + +## 0.3.11 + +### Patch Changes + +- Updated dependencies [[`eb98c5b`](https://github.com/Effect-TS/effect/commit/eb98c5b79ab50aa0cde239bd4e660dd19dbab612), [`184fed8`](https://github.com/Effect-TS/effect/commit/184fed83ac36cba05a75a5a8013f740f9f696e3b), [`4d3fbe8`](https://github.com/Effect-TS/effect/commit/4d3fbe82e8cec13ccd0cd0b2096deac6818fb59a), [`6068e07`](https://github.com/Effect-TS/effect/commit/6068e073d4cc8b3c8583583fd5eb3efe43f7d5ba), [`3a77e20`](https://github.com/Effect-TS/effect/commit/3a77e209783933bac3aaddba1b05ff6a9ac72b36)]: + - effect@3.3.1 + - @effect/platform@0.57.0 + - @effect/sql@0.3.10 + +## 0.3.10 + +### Patch Changes + +- Updated dependencies [[`2b9ddfc`](https://github.com/Effect-TS/effect/commit/2b9ddfcbac505d98551e764a43923854907ca5c1), [`1f4ac00`](https://github.com/Effect-TS/effect/commit/1f4ac00a91c336c9c9c9b8c3ed9ceb9920ebc9bd), [`9305b76`](https://github.com/Effect-TS/effect/commit/9305b764cceeae4f16564435ae7172f79c2bf822), [`0f40d98`](https://github.com/Effect-TS/effect/commit/0f40d989da10f68df3ecd72b36849401ad679bfb), [`188f0a5`](https://github.com/Effect-TS/effect/commit/188f0a5c57ed0d7c9e5852e0c1c998f1b95810a1), [`b761ef0`](https://github.com/Effect-TS/effect/commit/b761ef00eaf6c67b7ffe34798b98aae5347ab376), [`b53f69b`](https://github.com/Effect-TS/effect/commit/b53f69bff1452a487b21198cd83961f844e02d36), [`0f40d98`](https://github.com/Effect-TS/effect/commit/0f40d989da10f68df3ecd72b36849401ad679bfb), [`5bd549e`](https://github.com/Effect-TS/effect/commit/5bd549e4bd7144727db438ecca6b8dc9b3ef7e22), [`67f160a`](https://github.com/Effect-TS/effect/commit/67f160a213de0219a565d4bf653b3cbf24f58e8f)]: + - @effect/platform@0.56.0 + - effect@3.3.0 + - @effect/sql@0.3.9 + +## 0.3.9 + +### Patch Changes + +- [#2860](https://github.com/Effect-TS/effect/pull/2860) [`e50e01d`](https://github.com/Effect-TS/effect/commit/e50e01db54958c74946ac0e7dbba8c461671ccae) Thanks @tim-smart! - fix .values for non-reader statements + +- [#2932](https://github.com/Effect-TS/effect/pull/2932) [`fd8d860`](https://github.com/Effect-TS/effect/commit/fd8d8604320e69405226e47b62fc7d7656bd643a) Thanks @tim-smart! - update @effect/sql dependencies + +- Updated dependencies [[`a67d602`](https://github.com/Effect-TS/effect/commit/a67d60276f96cd20b76145b4cee13efca6c6158a)]: + - @effect/platform@0.55.7 + - @effect/sql@0.3.8 + +## 0.3.8 + +### Patch Changes + +- Updated dependencies [[`8c5d280`](https://github.com/Effect-TS/effect/commit/8c5d280c0402284a4e58372867a15a431cb99461), [`6ba6d26`](https://github.com/Effect-TS/effect/commit/6ba6d269f5891e6b11aa35c5281dde4bf3273004), [`3f28bf2`](https://github.com/Effect-TS/effect/commit/3f28bf274333611906175446b772243f34f1b6d5), [`5817820`](https://github.com/Effect-TS/effect/commit/58178204a770d1a78c06945ef438f9fffbb50afa), [`799aa20`](https://github.com/Effect-TS/effect/commit/799aa20b4f618736ba33a5297fda90a75d4c26c6)]: + - effect@3.2.9 + - @effect/platform@0.55.6 + - @effect/sql@0.3.7 + +## 0.3.7 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.55.5 + - @effect/sql@0.3.6 + +## 0.3.6 + +### Patch Changes + +- Updated dependencies [[`fb91f17`](https://github.com/Effect-TS/effect/commit/fb91f17098b48497feca9ec976feb87e4a82451b)]: + - effect@3.2.8 + - @effect/platform@0.55.4 + - @effect/sql@0.3.5 + +## 0.3.5 + +### Patch Changes + +- Updated dependencies [[`6801fca`](https://github.com/Effect-TS/effect/commit/6801fca44366be3ee1b6b99f54bd4f38a1b5e4f4)]: + - effect@3.2.7 + - @effect/platform@0.55.3 + - @effect/sql@0.3.4 + +## 0.3.4 + +### Patch Changes + +- Updated dependencies [[`2c2280b`](https://github.com/Effect-TS/effect/commit/2c2280b98a11fc002663c55792a4fa5781cd5fb6), [`cc8ac50`](https://github.com/Effect-TS/effect/commit/cc8ac5080daba8622ca2ff5dab5c37ddfab732ba)]: + - @effect/platform@0.55.2 + - effect@3.2.6 + - @effect/sql@0.3.3 + +## 0.3.3 + +### Patch Changes + +- Updated dependencies [[`3e86ced`](https://github.com/Effect-TS/effect/commit/3e86cedfa2507dbf5475c1cb10e0018d00e5593d)]: + - @effect/sql@0.3.2 + +## 0.3.2 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.55.1 + - @effect/sql@0.3.1 + +## 0.3.1 + +### Patch Changes + +- [#2838](https://github.com/Effect-TS/effect/pull/2838) [`bf66289`](https://github.com/Effect-TS/effect/commit/bf662893dca07351b249e4ec1d1a9d0108d6f9e1) Thanks @tim-smart! - allow additional span attributes to be passed to sql clients + +## 0.3.0 + +### Minor Changes + +- [#2833](https://github.com/Effect-TS/effect/pull/2833) [`af0543c`](https://github.com/Effect-TS/effect/commit/af0543cbe62e9b9c0bd0ecb1ce2e5814b2c3caaa) Thanks @tim-smart! - remove file system migrator from web sql implementations + +### Patch Changes + +- Updated dependencies [[`af0543c`](https://github.com/Effect-TS/effect/commit/af0543cbe62e9b9c0bd0ecb1ce2e5814b2c3caaa), [`608b01f`](https://github.com/Effect-TS/effect/commit/608b01fc342dbae2a642b308a67b84ead530ecea), [`031c712`](https://github.com/Effect-TS/effect/commit/031c7122a24ac42e48d6a434646b4f5d279d7442), [`a44e532`](https://github.com/Effect-TS/effect/commit/a44e532cf3a6a498b12a5aacf8124aa267e24ba0), [`5133ca9`](https://github.com/Effect-TS/effect/commit/5133ca9dc4b8da0e28951316da9ab55dfbe0fbb9)]: + - @effect/sql@0.3.0 + - effect@3.2.5 + - @effect/platform@0.55.0 + +## 0.2.18 + +### Patch Changes + +- Updated dependencies [[`1af94df`](https://github.com/Effect-TS/effect/commit/1af94df6b74aeb4f6ebcbe80e074b4cb252e62e3), [`1af94df`](https://github.com/Effect-TS/effect/commit/1af94df6b74aeb4f6ebcbe80e074b4cb252e62e3), [`c07e0ce`](https://github.com/Effect-TS/effect/commit/c07e0cea8ce165887e2c9dfa5d669eba9b2fb798), [`e313a01`](https://github.com/Effect-TS/effect/commit/e313a01b7e80f6cb7704055a190e5623c9d22c6d), [`1af94df`](https://github.com/Effect-TS/effect/commit/1af94df6b74aeb4f6ebcbe80e074b4cb252e62e3)]: + - effect@3.2.4 + - @effect/platform@0.54.0 + - @effect/sql@0.2.17 + +## 0.2.17 + +### Patch Changes + +- [#2803](https://github.com/Effect-TS/effect/pull/2803) [`5af633e`](https://github.com/Effect-TS/effect/commit/5af633eb5ff6560a64d87263d1692bb9c75f7b3c) Thanks @tim-smart! - update dependencies + +- Updated dependencies [[`45578e8`](https://github.com/Effect-TS/effect/commit/45578e8faa80ae33d23e08f6f19467f818b7788f)]: + - effect@3.2.3 + - @effect/platform@0.53.14 + - @effect/sql@0.2.16 + +## 0.2.16 + +### Patch Changes + +- Updated dependencies [[`5d9266e`](https://github.com/Effect-TS/effect/commit/5d9266e8c740746ac9e186c3df6090a1b57fbe2a), [`9f8122e`](https://github.com/Effect-TS/effect/commit/9f8122e78884ab47c5e5f364d86eee1d1543cc61), [`6a6f670`](https://github.com/Effect-TS/effect/commit/6a6f6706b8613c8c7c10971b8d81a0f9e440a6f2), [`c1eaef9`](https://github.com/Effect-TS/effect/commit/c1eaef910420dae416923d172ee58d219e921d0f)]: + - effect@3.2.2 + - @effect/platform@0.53.13 + - @effect/sql@0.2.15 + +## 0.2.15 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.53.12 + - @effect/sql@0.2.14 + +## 0.2.14 + +### Patch Changes + +- Updated dependencies [[`c1e991d`](https://github.com/Effect-TS/effect/commit/c1e991dd5ba87901cd0e05697a8b4a267e7e954a)]: + - effect@3.2.1 + - @effect/platform@0.53.11 + - @effect/sql@0.2.13 + +## 0.2.13 + +### Patch Changes + +- Updated dependencies [[`146cadd`](https://github.com/Effect-TS/effect/commit/146cadd9d004634a3ff85c480bf92cf975c853e2), [`7135748`](https://github.com/Effect-TS/effect/commit/713574813a0f64085db0b5240ba39e7a0a7c137e), [`7135748`](https://github.com/Effect-TS/effect/commit/713574813a0f64085db0b5240ba39e7a0a7c137e), [`963b4e7`](https://github.com/Effect-TS/effect/commit/963b4e7ac87e2468feb6a344f7ab4ee4ad711198), [`64c9414`](https://github.com/Effect-TS/effect/commit/64c9414e960e82058ca09bbb3976d6fbef303a8e), [`7135748`](https://github.com/Effect-TS/effect/commit/713574813a0f64085db0b5240ba39e7a0a7c137e), [`2cbb76b`](https://github.com/Effect-TS/effect/commit/2cbb76bb52500a3f4bf27d1c91482518cbea56d7), [`870c5fa`](https://github.com/Effect-TS/effect/commit/870c5fa52cd61e745e8e828d38c3f09f00737553), [`146cadd`](https://github.com/Effect-TS/effect/commit/146cadd9d004634a3ff85c480bf92cf975c853e2), [`7135748`](https://github.com/Effect-TS/effect/commit/713574813a0f64085db0b5240ba39e7a0a7c137e), [`64c9414`](https://github.com/Effect-TS/effect/commit/64c9414e960e82058ca09bbb3976d6fbef303a8e)]: + - effect@3.2.0 + - @effect/platform@0.53.10 + - @effect/sql@0.2.12 + +## 0.2.12 + +### Patch Changes + +- Updated dependencies [[`17fc22e`](https://github.com/Effect-TS/effect/commit/17fc22e132593c5caa563705a4748ba0f04a853c), [`810f222`](https://github.com/Effect-TS/effect/commit/810f222268792b13067c7a7bf317b93a9bb8917b), [`596aaea`](https://github.com/Effect-TS/effect/commit/596aaea022648b2e06fb1ec22f1652043d6fe64e)]: + - @effect/platform@0.53.9 + - effect@3.1.6 + - @effect/sql@0.2.11 + +## 0.2.11 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.53.8 + - @effect/sql@0.2.10 + +## 0.2.10 + +### Patch Changes + +- [#2712](https://github.com/Effect-TS/effect/pull/2712) [`01b4553`](https://github.com/Effect-TS/effect/commit/01b4553df4d2a7c5824a112f405a49f8fcfebbf4) Thanks [@vecerek](https://github.com/vecerek)! - Use constants from `@opentelemetry/semantic-conventions` as span attribute names instead of hard-coded values + +- Updated dependencies [[`01b4553`](https://github.com/Effect-TS/effect/commit/01b4553df4d2a7c5824a112f405a49f8fcfebbf4)]: + - @effect/sql@0.2.9 + - @effect/platform@0.53.7 + +## 0.2.9 + +### Patch Changes + +- [#2749](https://github.com/Effect-TS/effect/pull/2749) [`fdb7203`](https://github.com/Effect-TS/effect/commit/fdb7203ac0d41dde9951048c1c967d80add92ae5) Thanks [@tim-smart](https://github.com/tim-smart)! - add backup api to sqlite-node client + +## 0.2.8 + +### Patch Changes + +- Updated dependencies [[`6ac4847`](https://github.com/Effect-TS/effect/commit/6ac48479447c01a4f35d655552af93e47e562610), [`6ac4847`](https://github.com/Effect-TS/effect/commit/6ac48479447c01a4f35d655552af93e47e562610)]: + - @effect/platform@0.53.6 + - effect@3.1.5 + - @effect/sql@0.2.8 + +## 0.2.7 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.53.5 + - @effect/sql@0.2.7 + +## 0.2.6 + +### Patch Changes + +- Updated dependencies [[`e41e911`](https://github.com/Effect-TS/effect/commit/e41e91122fa6dd12fc81e50dcad0db891be67146)]: + - effect@3.1.4 + - @effect/platform@0.53.4 + - @effect/sql@0.2.6 + +## 0.2.5 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.53.3 + - @effect/sql@0.2.5 + +## 0.2.4 + +### Patch Changes + +- Updated dependencies [[`1f6dc96`](https://github.com/Effect-TS/effect/commit/1f6dc96f51c7bb9c8d11415358308604ba7c7c8e)]: + - effect@3.1.3 + - @effect/platform@0.53.2 + - @effect/sql@0.2.4 + +## 0.2.3 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.53.1 + - @effect/sql@0.2.3 + +## 0.2.2 + +### Patch Changes + +- Updated dependencies [[`d57fbbb`](https://github.com/Effect-TS/effect/commit/d57fbbbd6c466936213a671fc3cd2390064f864e)]: + - @effect/platform@0.53.0 + - @effect/sql@0.2.2 + +## 0.2.1 + +### Patch Changes + +- Updated dependencies [[`5866c62`](https://github.com/Effect-TS/effect/commit/5866c621d7eb4cc84e4ba972bfdfd219734cd45d)]: + - @effect/platform@0.52.3 + - @effect/sql@0.2.1 + +## 0.2.0 + +### Minor Changes + +- [#2693](https://github.com/Effect-TS/effect/pull/2693) [`0724274`](https://github.com/Effect-TS/effect/commit/07242746ed8a3b0383631108360a0ad4f6e062f0) Thanks [@tim-smart](https://github.com/tim-smart)! - make @effect/sql dialect agnostic + + All of the client implementations now share the same Context.Tag. This means you can create + services that support multiple SQL flavors. + + You can now use the `@effect/sql` package to access the client apis: + + ```ts + import * as Sql from "effect/unstable/sql" + import { Effect } from "effect" + + Effect.gen(function* () { + const sql = yield* Sql.client.Client + yield* sql`SELECT * FROM users` + }) + ``` + + If you need a functionality that is specific to a implementation, you can use the tag from the + implementation package: + + ```ts + import * as Sqlite from "@effect/sql-sqlite-node" + import { Effect } from "effect" + + Effect.gen(function* () { + const sql = yield* Sqlite.client.SqliteClient + const dump = yield* sql.export + }) + ``` + + If you need to run a different query depending on the dialect, you can use the `sql.onDialect` api: + + ```ts + import * as Sql from "effect/unstable/sql" + import { Effect } from "effect" + + Effect.gen(function* () { + const sql = yield* Sql.client.Client + yield* sql.onDialect({ + sqlite: () => sql`SELECT * FROM sqlite_master`, + mysql: () => sql`SHOW TABLES`, + mssql: () => sql`SELECT * FROM sys.tables`, + pg: () => sql`SELECT * FROM pg_catalog.pg_tables` + }) + }) + ``` + +### Patch Changes + +- [#2693](https://github.com/Effect-TS/effect/pull/2693) [`0724274`](https://github.com/Effect-TS/effect/commit/07242746ed8a3b0383631108360a0ad4f6e062f0) Thanks [@tim-smart](https://github.com/tim-smart)! - add .returning helper to insert and update apis + +- Updated dependencies [[`0724274`](https://github.com/Effect-TS/effect/commit/07242746ed8a3b0383631108360a0ad4f6e062f0), [`0724274`](https://github.com/Effect-TS/effect/commit/07242746ed8a3b0383631108360a0ad4f6e062f0)]: + - @effect/sql@0.2.0 + +## 0.1.17 + +### Patch Changes + +- Updated dependencies [[`2e1cdf6`](https://github.com/Effect-TS/effect/commit/2e1cdf67d141281288fffe9a5c10d1379a800513), [`d3cf2d8`](https://github.com/Effect-TS/effect/commit/d3cf2d80038310ccc0a6a015d13d86291a953b41), [`56ec8dd`](https://github.com/Effect-TS/effect/commit/56ec8ddc3495f11a1ca8acc59098d9a2f5ced615)]: + - @effect/platform@0.52.2 + - effect@3.1.2 + - @effect/sql@0.1.17 + +## 0.1.16 + +### Patch Changes + +- Updated dependencies [[`e5e56d1`](https://github.com/Effect-TS/effect/commit/e5e56d138dbed3204636f605229c6685f89659fc)]: + - effect@3.1.1 + - @effect/platform@0.52.1 + - @effect/sql@0.1.16 + +## 0.1.15 + +### Patch Changes + +- Updated dependencies [[`9deab0a`](https://github.com/Effect-TS/effect/commit/9deab0aec9e99501f9441843e34df9afa10c5be9), [`7719b8a`](https://github.com/Effect-TS/effect/commit/7719b8a7350c14e952ffe685bfd5308773b3e271)]: + - @effect/platform@0.52.0 + - @effect/sql@0.1.15 + +## 0.1.14 + +### Patch Changes + +- Updated dependencies [[`c3c12c6`](https://github.com/Effect-TS/effect/commit/c3c12c6625633fe80e79f9db75a3b8cf8ca8b11d), [`ba64ea6`](https://github.com/Effect-TS/effect/commit/ba64ea6757810c5e74cad3863a7d19d4d38af66b), [`b5de2d2`](https://github.com/Effect-TS/effect/commit/b5de2d2ce5b1afe8be90827bf898a95cec40eb2b), [`a1c7ab8`](https://github.com/Effect-TS/effect/commit/a1c7ab8ffedacd18c1fc784f4ff5844f79498b83), [`a023f28`](https://github.com/Effect-TS/effect/commit/a023f28336f3865687d9a30c1883e36909906d85), [`0ec93cb`](https://github.com/Effect-TS/effect/commit/0ec93cb4f166e7401c171c2f8e8276ce958d9a57), [`1c9454d`](https://github.com/Effect-TS/effect/commit/1c9454d532eae79b9f759aea77f59332cc6d18ed), [`a023f28`](https://github.com/Effect-TS/effect/commit/a023f28336f3865687d9a30c1883e36909906d85), [`92d56db`](https://github.com/Effect-TS/effect/commit/92d56dbb3f33e36636c2a2f1030c56492e39cf4d)]: + - effect@3.1.0 + - @effect/platform@0.51.0 + - @effect/sql@0.1.14 + +## 0.1.13 + +### Patch Changes + +- [#2656](https://github.com/Effect-TS/effect/pull/2656) [`557707b`](https://github.com/Effect-TS/effect/commit/557707bc9e5f230c8964d2757012075c34339b5c) Thanks [@tim-smart](https://github.com/tim-smart)! - update dependencies + +- Updated dependencies [[`16039a0`](https://github.com/Effect-TS/effect/commit/16039a08f04f11545e2fdf40952788a8f9cef04f), [`557707b`](https://github.com/Effect-TS/effect/commit/557707bc9e5f230c8964d2757012075c34339b5c), [`d1d33e1`](https://github.com/Effect-TS/effect/commit/d1d33e10b25109f44b5ab1c6e4d778a59c0d3eeb), [`f4ed306`](https://github.com/Effect-TS/effect/commit/f4ed3068a70b50302d078a30d18ca3cfd2bc679c), [`661004f`](https://github.com/Effect-TS/effect/commit/661004f4bf5f8b25f5a0678c21a3a822188ce461), [`e79cb83`](https://github.com/Effect-TS/effect/commit/e79cb83d3b19098bc40a3012e2a059b8426306c2)]: + - @effect/platform@0.50.8 + - effect@3.0.8 + - @effect/sql@0.1.13 + +## 0.1.12 + +### Patch Changes + +- Updated dependencies [[`18de56b`](https://github.com/Effect-TS/effect/commit/18de56b4a6b6d1f99230dfabf9147d59ea4dd759)]: + - effect@3.0.7 + - @effect/platform@0.50.7 + - @effect/sql@0.1.12 + +## 0.1.11 + +### Patch Changes + +- [#2621](https://github.com/Effect-TS/effect/pull/2621) [`f363af0`](https://github.com/Effect-TS/effect/commit/f363af08df9426a8bc629d80ef57d8b7e243ffa6) Thanks [@tim-smart](https://github.com/tim-smart)! - add sql transaction tracing spans + +- [#2621](https://github.com/Effect-TS/effect/pull/2621) [`f363af0`](https://github.com/Effect-TS/effect/commit/f363af08df9426a8bc629d80ef57d8b7e243ffa6) Thanks [@tim-smart](https://github.com/tim-smart)! - update sql span attributes to follow semantic conventions + +- [#2621](https://github.com/Effect-TS/effect/pull/2621) [`f363af0`](https://github.com/Effect-TS/effect/commit/f363af08df9426a8bc629d80ef57d8b7e243ffa6) Thanks [@tim-smart](https://github.com/tim-smart)! - add sql`...`.unprepared, to run a query without trying to PREPARE it + +- Updated dependencies [[`ffe4f4e`](https://github.com/Effect-TS/effect/commit/ffe4f4e95db35fff6869e360b072e3837befa0a1), [`027418e`](https://github.com/Effect-TS/effect/commit/027418edaa6aa6c0ae4861b95832827b45adace4), [`f363af0`](https://github.com/Effect-TS/effect/commit/f363af08df9426a8bc629d80ef57d8b7e243ffa6), [`ac1898e`](https://github.com/Effect-TS/effect/commit/ac1898eb7bc96880f911c276048e2ea3d6fe9c50), [`ffe4f4e`](https://github.com/Effect-TS/effect/commit/ffe4f4e95db35fff6869e360b072e3837befa0a1), [`f363af0`](https://github.com/Effect-TS/effect/commit/f363af08df9426a8bc629d80ef57d8b7e243ffa6), [`f363af0`](https://github.com/Effect-TS/effect/commit/f363af08df9426a8bc629d80ef57d8b7e243ffa6)]: + - effect@3.0.6 + - @effect/sql@0.1.11 + - @effect/platform@0.50.6 + +## 0.1.10 + +### Patch Changes + +- Updated dependencies [[`6222404`](https://github.com/Effect-TS/effect/commit/62224044678751829ed2f128e05133a91c6b0569), [`868ed2a`](https://github.com/Effect-TS/effect/commit/868ed2a8fe94ee7f4206a6070f29dcf2a5ba1dc3)]: + - effect@3.0.5 + - @effect/platform@0.50.5 + - @effect/sql@0.1.10 + +## 0.1.9 + +### Patch Changes + +- Updated dependencies [[`9a24667`](https://github.com/Effect-TS/effect/commit/9a246672008a2b668d43fbfd2fe5508c54b2b920)]: + - effect@3.0.4 + - @effect/platform@0.50.4 + - @effect/sql@0.1.9 + +## 0.1.8 + +### Patch Changes + +- Updated dependencies [[`b3b51a2`](https://github.com/Effect-TS/effect/commit/b3b51a2ea0c6ab92a363db46ebaa7e1176d089f5)]: + - @effect/platform@0.50.3 + - @effect/sql@0.1.8 + +## 0.1.7 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.50.2 + - @effect/sql@0.1.7 + +## 0.1.6 + +### Patch Changes + +- Updated dependencies []: + - @effect/platform@0.50.1 + - @effect/sql@0.1.6 + +## 0.1.5 + +### Patch Changes + +- Updated dependencies [[`6f38dff`](https://github.com/Effect-TS/effect/commit/6f38dff41ffa34532cc2f25b90446550c5730bb6), [`a7b4b84`](https://github.com/Effect-TS/effect/commit/a7b4b84bd5a25f51aba922f9259c3a58c98c6a4e), [`a3b0e6c`](https://github.com/Effect-TS/effect/commit/a3b0e6c490772e6d44b5d98dcf2729c4d5310ecc), [`6f38dff`](https://github.com/Effect-TS/effect/commit/6f38dff41ffa34532cc2f25b90446550c5730bb6)]: + - @effect/platform@0.50.0 + - effect@3.0.3 + - @effect/sql@0.1.5 + +## 0.1.4 + +### Patch Changes + +- [#2562](https://github.com/Effect-TS/effect/pull/2562) [`2cecdbd`](https://github.com/Effect-TS/effect/commit/2cecdbd1cf30befce4e84796ccd953ea55ecfb86) Thanks [@fubhy](https://github.com/fubhy)! - Added provenance publishing + +- Updated dependencies [[`2cecdbd`](https://github.com/Effect-TS/effect/commit/2cecdbd1cf30befce4e84796ccd953ea55ecfb86)]: + - @effect/platform@0.49.4 + - effect@3.0.2 + - @effect/sql@0.1.4 + +## 0.1.3 + +### Patch Changes + +- Updated dependencies [[`8d39d65`](https://github.com/Effect-TS/effect/commit/8d39d6554af548228ad767112ce2e0b1f68fa8e1)]: + - @effect/platform@0.49.3 + - @effect/sql@0.1.3 + +## 0.1.2 + +### Patch Changes + +- Updated dependencies [[`5ef0a1a`](https://github.com/Effect-TS/effect/commit/5ef0a1ae9b773fa2481550cb0d43ff7a0e03cd44)]: + - @effect/platform@0.49.2 + - @effect/sql@0.1.2 + +## 0.1.1 + +### Patch Changes + +- Updated dependencies [[`3da0cfa`](https://github.com/Effect-TS/effect/commit/3da0cfa12c407fd930dc480be1ecc9217a8058f8), [`570e8d8`](https://github.com/Effect-TS/effect/commit/570e8d87e7c0e9ad4cd2686462fdb9b4812f7716), [`87c5687`](https://github.com/Effect-TS/effect/commit/87c5687de0782dab177b7861217fa3b040046282), [`f838c15`](https://github.com/Effect-TS/effect/commit/f838c15ca83938a5ee9bfec49deb025564a570ff), [`8edacca`](https://github.com/Effect-TS/effect/commit/8edacca37f8e37c01a63fec332b06d9361efaa7b)]: + - effect@3.0.1 + - @effect/platform@0.49.1 + - @effect/sql@0.1.1 + +## 0.1.0 + +### Minor Changes + +- [#2104](https://github.com/Effect-TS/effect/pull/2104) [`1499974`](https://github.com/Effect-TS/effect/commit/14999741d2e19c1747f6a7e19d68977f6429cdb8) Thanks [@IMax153](https://github.com/IMax153)! - initial @effect/sql release + +- [#2207](https://github.com/Effect-TS/effect/pull/2207) [`2fb7d9c`](https://github.com/Effect-TS/effect/commit/2fb7d9ca15037ff62a578bb9fe5732da5f4f317d) Thanks [@github-actions](https://github.com/apps/github-actions)! - Release Effect 3.0 🎉 + +### Patch Changes + +- [#2529](https://github.com/Effect-TS/effect/pull/2529) [`78b767c`](https://github.com/Effect-TS/effect/commit/78b767c2b1625186e17131761a0edbac25d21850) Thanks [@fubhy](https://github.com/fubhy)! - Renamed `ReadonlyArray` and `ReadonlyRecord` modules for better discoverability. + +- Updated dependencies [[`1b5f0c7`](https://github.com/Effect-TS/effect/commit/1b5f0c77e7fd477a0026071e82129a948227f4b3), [`d50a652`](https://github.com/Effect-TS/effect/commit/d50a652479f4d1d64f48da05c79fa847e6e51548), [`9a3bd47`](https://github.com/Effect-TS/effect/commit/9a3bd47ebd0750c7e498162734f6d21895de0cb2), [`1499974`](https://github.com/Effect-TS/effect/commit/14999741d2e19c1747f6a7e19d68977f6429cdb8), [`6460414`](https://github.com/Effect-TS/effect/commit/6460414351a45fb8e0a457c63f3653422efee766), [`cf69f46`](https://github.com/Effect-TS/effect/commit/cf69f46690058d71eeada03cfb40dc744573e9e4), [`cf69f46`](https://github.com/Effect-TS/effect/commit/cf69f46690058d71eeada03cfb40dc744573e9e4), [`be9d025`](https://github.com/Effect-TS/effect/commit/be9d025e42355260ace02dd135851a8935a4deba), [`78b767c`](https://github.com/Effect-TS/effect/commit/78b767c2b1625186e17131761a0edbac25d21850), [`aa4a3b5`](https://github.com/Effect-TS/effect/commit/aa4a3b550da1c1020265ac389ed3f309388994a2), [`1499974`](https://github.com/Effect-TS/effect/commit/14999741d2e19c1747f6a7e19d68977f6429cdb8), [`1b5f0c7`](https://github.com/Effect-TS/effect/commit/1b5f0c77e7fd477a0026071e82129a948227f4b3), [`5c2b561`](https://github.com/Effect-TS/effect/commit/5c2b5614f583b88784ed68126ae939832fb3c092), [`6c6087a`](https://github.com/Effect-TS/effect/commit/6c6087a4a897b64252346426660782d31c13f769), [`a18f594`](https://github.com/Effect-TS/effect/commit/a18f5948f1439a147232448b2c443472fda0eceb), [`1499974`](https://github.com/Effect-TS/effect/commit/14999741d2e19c1747f6a7e19d68977f6429cdb8), [`2f96d93`](https://github.com/Effect-TS/effect/commit/2f96d938b90f8c19377583279e3c7afd9b509c50), [`5a2314b`](https://github.com/Effect-TS/effect/commit/5a2314b70ec79c2c02b51cef45a5ddec8327daa1), [`25d74f8`](https://github.com/Effect-TS/effect/commit/25d74f8c4d2dd4a9e5ec57ce2f20d36dedd25343), [`6c6087a`](https://github.com/Effect-TS/effect/commit/6c6087a4a897b64252346426660782d31c13f769), [`271b79f`](https://github.com/Effect-TS/effect/commit/271b79fc0b66a6c11e07a8779ff8800493a7eac2), [`1b5f0c7`](https://github.com/Effect-TS/effect/commit/1b5f0c77e7fd477a0026071e82129a948227f4b3), [`2fb7d9c`](https://github.com/Effect-TS/effect/commit/2fb7d9ca15037ff62a578bb9fe5732da5f4f317d), [`53d1c2a`](https://github.com/Effect-TS/effect/commit/53d1c2a77559081fbb89667e343346375c6d6650), [`e7e1bbe`](https://github.com/Effect-TS/effect/commit/e7e1bbe68486fdf31c8f84b0880522d39adcaad3), [`10c169e`](https://github.com/Effect-TS/effect/commit/10c169eadc874e91b4defca3f467b4e6a50fd8f3), [`6424181`](https://github.com/Effect-TS/effect/commit/64241815fe6a939e91e6947253e7dceea1306aa8)]: + - effect@3.0.0 + - @effect/sql@0.1.0 + - @effect/platform@0.49.0 diff --git a/packages/sql/sqlite-node/LICENSE b/packages/sql/sqlite-node/LICENSE new file mode 100644 index 0000000000..7f6fe480f7 --- /dev/null +++ b/packages/sql/sqlite-node/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023-present The Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/sql/sqlite-node/README.md b/packages/sql/sqlite-node/README.md new file mode 100644 index 0000000000..30e2311ca2 --- /dev/null +++ b/packages/sql/sqlite-node/README.md @@ -0,0 +1,7 @@ +# `@effect/sql-sqlite-node` + +An `@effect/sql` implementation using the `better-sqlite3` library. + +## Documentation + +- **API Reference**: [View the full documentation](https://effect-ts.github.io/effect/docs/sql-sqlite-node). diff --git a/packages/sql/sqlite-node/docgen.json b/packages/sql/sqlite-node/docgen.json new file mode 100644 index 0000000000..a2ca5490f8 --- /dev/null +++ b/packages/sql/sqlite-node/docgen.json @@ -0,0 +1,20 @@ +{ + "$schema": "../../node_modules/@effect/docgen/schema.json", + "srcLink": "https://github.com/Effect-TS/effect/tree/main/packages/sql/sqlite-node/src/", + "exclude": ["src/internal/**/*.ts"], + "examplesCompilerOptions": { + "noEmit": true, + "strict": true, + "skipLibCheck": true, + "moduleResolution": "Bundler", + "module": "ES2022", + "target": "ES2022", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "rewriteRelativeImportExtensions": true, + "allowImportingTsExtensions": true, + "paths": { + "effect": ["../../../effect/src/index.js"], + "effect/*": ["../../../effect/src/*.js"] + } + } +} diff --git a/packages/sql/sqlite-node/package.json b/packages/sql/sqlite-node/package.json new file mode 100644 index 0000000000..9235dc22ce --- /dev/null +++ b/packages/sql/sqlite-node/package.json @@ -0,0 +1,69 @@ +{ + "name": "@effect/sql-sqlite-node", + "version": "0.45.1", + "type": "module", + "license": "MIT", + "description": "A SQLite toolkit for Effect", + "homepage": "https://effect.website", + "repository": { + "type": "git", + "url": "https://github.com/Effect-TS/effect.git", + "directory": "packages/sql/sqlite-node" + }, + "bugs": { + "url": "https://github.com/Effect-TS/effect/issues" + }, + "tags": [ + "typescript", + "sql", + "database" + ], + "keywords": [ + "typescript", + "sql", + "database" + ], + "sideEffects": [], + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts", + "./*": "./src/*.ts", + "./internal/*": null, + "./*/index": null + }, + "files": [ + "src/**/*.ts", + "dist/**/*.js", + "dist/**/*.js.map", + "dist/**/*.d.ts", + "dist/**/*.d.ts.map" + ], + "publishConfig": { + "provenance": true, + "exports": { + "./package.json": "./package.json", + ".": "./dist/index.js", + "./*": "./dist/*.js", + "./internal/*": null, + "./*/index": null + } + }, + "scripts": { + "codegen": "build-utils prepare-v4", + "build": "tsc -b tsconfig.build.json && babel dist --plugins annotate-pure-calls --out-dir dist --source-maps", + "check": "tsc -b tsconfig.json", + "test": "vitest", + "coverage": "vitest --coverage" + }, + "devDependencies": { + "@effect/platform-node": "workspace:^", + "@types/better-sqlite3": "^7.6.13", + "effect": "workspace:^" + }, + "peerDependencies": { + "effect": "workspace:^" + }, + "dependencies": { + "better-sqlite3": "^12.2.0" + } +} diff --git a/packages/sql/sqlite-node/src/SqliteClient.ts b/packages/sql/sqlite-node/src/SqliteClient.ts new file mode 100644 index 0000000000..8592506b9f --- /dev/null +++ b/packages/sql/sqlite-node/src/SqliteClient.ts @@ -0,0 +1,281 @@ +/** + * @since 1.0.0 + */ +import Sqlite from "better-sqlite3" +import * as Cache from "effect/caching/Cache" +import * as Config from "effect/config/Config" +import * as Effect from "effect/Effect" +import * as Fiber from "effect/Fiber" +import { identity } from "effect/Function" +import * as Layer from "effect/Layer" +import * as Scope from "effect/Scope" +import * as ServiceMap from "effect/ServiceMap" +import * as Stream from "effect/stream/Stream" +import * as Duration from "effect/time/Duration" +import * as Reactivity from "effect/unstable/reactivity/Reactivity" +import * as Client from "effect/unstable/sql/SqlClient" +import type { Connection } from "effect/unstable/sql/SqlConnection" +import { SqlError } from "effect/unstable/sql/SqlError" +import * as Statement from "effect/unstable/sql/Statement" + +const ATTR_DB_SYSTEM_NAME = "db.system.name" + +/** + * @category type ids + * @since 1.0.0 + */ +export const TypeId: TypeId = "~@effect/sql-sqlite-node/SqliteClient" + +/** + * @category type ids + * @since 1.0.0 + */ +export type TypeId = "~@effect/sql-sqlite-node/SqliteClient" + +/** + * @category models + * @since 1.0.0 + */ +export interface SqliteClient extends Client.SqlClient { + readonly [TypeId]: TypeId + readonly config: SqliteClientConfig + readonly export: Effect.Effect + readonly backup: (destination: string) => Effect.Effect + readonly loadExtension: (path: string) => Effect.Effect + + /** Not supported in sqlite */ + readonly updateValues: never +} + +/** + * @category models + * @since 1.0.0 + */ +export interface BackupMetadata { + readonly totalPages: number + readonly remainingPages: number +} + +/** + * @category tags + * @since 1.0.0 + */ +export const SqliteClient = ServiceMap.Key("@effect/sql-sqlite-node/SqliteClient") + +/** + * @category models + * @since 1.0.0 + */ +export interface SqliteClientConfig { + readonly filename: string + readonly readonly?: boolean | undefined + readonly prepareCacheSize?: number | undefined + readonly prepareCacheTTL?: Duration.DurationInput | undefined + readonly disableWAL?: boolean | undefined + readonly spanAttributes?: Record | undefined + + readonly transformResultNames?: ((str: string) => string) | undefined + readonly transformQueryNames?: ((str: string) => string) | undefined +} + +interface SqliteConnection extends Connection { + readonly export: Effect.Effect + readonly backup: (destination: string) => Effect.Effect + readonly loadExtension: (path: string) => Effect.Effect +} + +/** + * @category constructor + * @since 1.0.0 + */ +export const make = ( + options: SqliteClientConfig +): Effect.Effect => + Effect.gen(function*() { + const compiler = Statement.makeCompilerSqlite(options.transformQueryNames) + const transformRows = options.transformResultNames ? + Statement.defaultTransforms( + options.transformResultNames + ).array : + undefined + + const makeConnection = Effect.gen(function*() { + const scope = yield* Effect.scope + const db = new Sqlite(options.filename, { + readonly: options.readonly ?? false + }) + yield* Scope.addFinalizer(scope, Effect.sync(() => db.close())) + + if (options.disableWAL !== true) { + db.pragma("journal_mode = WAL") + } + + const prepareCache = yield* Cache.make({ + capacity: options.prepareCacheSize ?? 200, + timeToLive: options.prepareCacheTTL ?? Duration.minutes(10), + lookup: (sql: string) => + Effect.try({ + try: () => db.prepare(sql), + catch: (cause) => new SqlError({ cause, message: "Failed to prepare statement " }) + }) + }) + + const runStatement = ( + statement: Sqlite.Statement, + params: ReadonlyArray, + raw: boolean + ) => + Effect.withFiber, SqlError>((fiber) => { + if (ServiceMap.get(fiber.services, Client.SafeIntegers)) { + statement.safeIntegers(true) + } + try { + if (statement.reader) { + return Effect.succeed(statement.all(...params)) + } + const result = statement.run(...params) + return Effect.succeed(raw ? result as unknown as ReadonlyArray : []) + } catch (cause) { + return Effect.fail(new SqlError({ cause, message: "Failed to execute statement" })) + } + }) + + const run = ( + sql: string, + params: ReadonlyArray, + raw = false + ) => + Effect.flatMap( + Cache.get(prepareCache, sql), + (s) => runStatement(s, params, raw) + ) + + const runValues = ( + sql: string, + params: ReadonlyArray + ) => + Effect.acquireUseRelease( + Cache.get(prepareCache, sql), + (statement) => + Effect.try({ + try: () => { + if (statement.reader) { + statement.raw(true) + return statement.all(...params) as ReadonlyArray< + ReadonlyArray + > + } + statement.run(...params) + return [] + }, + catch: (cause) => new SqlError({ cause, message: "Failed to execute statement" }) + }), + (statement) => Effect.sync(() => statement.reader && statement.raw(false)) + ) + + return identity({ + execute(sql, params, transformRows) { + return transformRows + ? Effect.map(run(sql, params), transformRows) + : run(sql, params) + }, + executeRaw(sql, params) { + return run(sql, params, true) + }, + executeValues(sql, params) { + return runValues(sql, params) + }, + executeUnprepared(sql, params, transformRows) { + const effect = runStatement(db.prepare(sql), params ?? [], false) + return transformRows ? Effect.map(effect, transformRows) : effect + }, + executeStream(_sql, _params) { + return Stream.die("executeStream not implemented") + }, + export: Effect.try({ + try: () => db.serialize(), + catch: (cause) => new SqlError({ cause, message: "Failed to export database" }) + }), + backup(destination) { + return Effect.tryPromise({ + try: () => db.backup(destination), + catch: (cause) => new SqlError({ cause, message: "Failed to backup database" }) + }) + }, + loadExtension(path) { + return Effect.try({ + try: () => db.loadExtension(path), + catch: (cause) => new SqlError({ cause, message: "Failed to load extension" }) + }) + } + }) + }) + + const semaphore = yield* Effect.makeSemaphore(1) + const connection = yield* makeConnection + + const acquirer = semaphore.withPermits(1)(Effect.succeed(connection)) + const transactionAcquirer = Effect.uninterruptibleMask((restore) => { + const fiber = Fiber.getCurrent()! + const scope = ServiceMap.unsafeGet(fiber.services, Scope.Scope) + return Effect.as( + Effect.tap( + restore(semaphore.take(1)), + () => Scope.addFinalizer(scope, semaphore.release(1)) + ), + connection + ) + }) + + return Object.assign( + (yield* Client.make({ + acquirer, + compiler, + transactionAcquirer, + spanAttributes: [ + ...(options.spanAttributes ? Object.entries(options.spanAttributes) : []), + [ATTR_DB_SYSTEM_NAME, "sqlite"] + ], + transformRows + })) as SqliteClient, + { + [TypeId]: TypeId as TypeId, + config: options, + export: Effect.flatMap(acquirer, (_) => _.export), + backup: (destination: string) => Effect.flatMap(acquirer, (_) => _.backup(destination)), + loadExtension: (path: string) => Effect.flatMap(acquirer, (_) => _.loadExtension(path)) + } + ) + }) + +/** + * @category layers + * @since 1.0.0 + */ +export const layerConfig = ( + config: Config.Wrap +): Layer.Layer => + Layer.effectServices( + Config.unwrap(config).asEffect().pipe( + Effect.flatMap(make), + Effect.map((client) => + ServiceMap.make(SqliteClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + ) + ) + ) + ).pipe(Layer.provide(Reactivity.layer)) + +/** + * @category layers + * @since 1.0.0 + */ +export const layer = ( + config: SqliteClientConfig +): Layer.Layer => + Layer.effectServices( + Effect.map(make(config), (client) => + ServiceMap.make(SqliteClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + )) + ).pipe(Layer.provide(Reactivity.layer)) diff --git a/packages/sql/sqlite-node/src/SqliteMigrator.ts b/packages/sql/sqlite-node/src/SqliteMigrator.ts new file mode 100644 index 0000000000..68ab34d8a7 --- /dev/null +++ b/packages/sql/sqlite-node/src/SqliteMigrator.ts @@ -0,0 +1,79 @@ +/** + * @since 1.0.0 + */ +import type * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" +import * as Migrator from "effect/unstable/sql/Migrator" +import type * as Client from "effect/unstable/sql/SqlClient" +import type { SqlError } from "effect/unstable/sql/SqlError" + +/** + * @since 1.0.0 + */ +export * from "effect/unstable/sql/Migrator" + +/** + * @category constructor + * @since 1.0.0 + */ +export const run: ( + options: Migrator.MigratorOptions +) => Effect.Effect< + ReadonlyArray, + Migrator.MigrationError | SqlError, + Client.SqlClient | R2 +> = Migrator.make({ + // dumpSchema(path, table) { + // const dump = (args: Array) => + // Effect.gen(function*() { + // const sql = yield* SqliteClient + // const dump = yield* pipe( + // Command.make("sqlite3", sql.config.filename, ...args), + // Command.string + // ) + // return dump.replace(/^create table sqlite_sequence\(.*$/im, "") + // .replace(/\n{2,}/gm, "\n\n") + // .trim() + // }).pipe( + // Effect.mapError((error) => new Migrator.MigrationError({ reason: "failed", message: error.message })) + // ) + // + // const dumpSchema = dump([".schema"]) + // + // const dumpMigrations = dump([ + // "--cmd", + // `.mode insert ${table}`, + // `select * from ${table}` + // ]) + // + // const dumpAll = Effect.map( + // Effect.all([dumpSchema, dumpMigrations], { concurrency: 2 }), + // ([schema, migrations]) => schema + "\n\n" + migrations + // ) + // + // const dumpFile = (file: string) => + // Effect.gen(function*() { + // const fs = yield* FileSystem + // const path = yield* Path + // const dump = yield* dumpAll + // yield* fs.makeDirectory(path.dirname(file), { recursive: true }) + // yield* fs.writeFileString(file, dump) + // }).pipe( + // Effect.mapError((error) => new Migrator.MigrationError({ reason: "failed", message: error.message })) + // ) + // + // return dumpFile(path) + // } +}) + +/** + * @category constructor + * @since 1.0.0 + */ +export const layer = ( + options: Migrator.MigratorOptions +): Layer.Layer< + never, + Migrator.MigrationError | SqlError, + Client.SqlClient | R +> => Layer.effectDiscard(run(options)) diff --git a/packages/sql/sqlite-node/src/index.ts b/packages/sql/sqlite-node/src/index.ts new file mode 100644 index 0000000000..09e759128f --- /dev/null +++ b/packages/sql/sqlite-node/src/index.ts @@ -0,0 +1,13 @@ +/** + * @since 1.0.0 + */ + +/** + * @since 1.0.0 + */ +export * as SqliteClient from "./SqliteClient.ts" + +/** + * @since 1.0.0 + */ +export * as SqliteMigrator from "./SqliteMigrator.ts" diff --git a/packages/sql/sqlite-node/src/index.ts.tpl b/packages/sql/sqlite-node/src/index.ts.tpl new file mode 100644 index 0000000000..b66408871c --- /dev/null +++ b/packages/sql/sqlite-node/src/index.ts.tpl @@ -0,0 +1,3 @@ +/** + * @since 1.0.0 + */ diff --git a/packages/sql/sqlite-node/test/Client.test.ts b/packages/sql/sqlite-node/test/Client.test.ts new file mode 100644 index 0000000000..c6a79f800e --- /dev/null +++ b/packages/sql/sqlite-node/test/Client.test.ts @@ -0,0 +1,76 @@ +import { NodeFileSystem } from "@effect/platform-node" +import { SqliteClient } from "@effect/sql-sqlite-node" +import { assert, describe, it } from "@effect/vitest" +import { Effect } from "effect" +import { FileSystem } from "effect/platform" +import { Reactivity } from "effect/unstable/reactivity" + +const makeClient = Effect.gen(function*() { + const fs = yield* FileSystem.FileSystem + const dir = yield* fs.makeTempDirectoryScoped() + return yield* SqliteClient.make({ + filename: dir + "/test.db" + }) +}).pipe(Effect.provide([NodeFileSystem.layer, Reactivity.layer])) + +describe("Client", () => { + it.effect("should work", () => + Effect.gen(function*() { + const sql = yield* makeClient + let response + response = yield* sql`CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)` + assert.deepStrictEqual(response, []) + response = yield* sql`INSERT INTO test (name) VALUES ('hello')` + assert.deepStrictEqual(response, []) + response = yield* sql`SELECT * FROM test` + assert.deepStrictEqual(response, [{ id: 1, name: "hello" }]) + response = yield* sql`INSERT INTO test (name) VALUES ('world')`.pipe(sql.withTransaction) + assert.deepStrictEqual(response, []) + response = yield* sql`SELECT * FROM test` + assert.deepStrictEqual(response, [ + { id: 1, name: "hello" }, + { id: 2, name: "world" } + ]) + })) + + it.effect("should work with raw", () => + Effect.gen(function*() { + const sql = yield* makeClient + let response + response = yield* sql`CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)`.raw + assert.deepStrictEqual(response, { changes: 0, lastInsertRowid: 0 }) + response = yield* sql`INSERT INTO test (name) VALUES ('hello')`.raw + assert.deepStrictEqual(response, { changes: 1, lastInsertRowid: 1 }) + response = yield* sql`SELECT * FROM test`.raw + assert.deepStrictEqual(response, [{ id: 1, name: "hello" }]) + response = yield* sql`INSERT INTO test (name) VALUES ('world')`.raw.pipe(sql.withTransaction) + assert.deepStrictEqual(response, { changes: 1, lastInsertRowid: 2 }) + response = yield* sql`SELECT * FROM test` + assert.deepStrictEqual(response, [ + { id: 1, name: "hello" }, + { id: 2, name: "world" } + ]) + })) + + it.effect("withTransaction", () => + Effect.gen(function*() { + const sql = yield* makeClient + yield* sql`CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)` + yield* sql.withTransaction(sql`INSERT INTO test (name) VALUES ('hello')`) + const rows = yield* sql`SELECT * FROM test` + assert.deepStrictEqual(rows, [{ id: 1, name: "hello" }]) + })) + + it.effect("withTransaction rollback", () => + Effect.gen(function*() { + const sql = yield* makeClient + yield* sql`CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)` + yield* sql`INSERT INTO test (name) VALUES ('hello')`.pipe( + Effect.andThen(Effect.fail("boom")), + sql.withTransaction, + Effect.ignore + ) + const rows = yield* sql`SELECT * FROM test` + assert.deepStrictEqual(rows, []) + })) +}) diff --git a/packages/sql/sqlite-node/test/Resolver.test.ts b/packages/sql/sqlite-node/test/Resolver.test.ts new file mode 100644 index 0000000000..8bd3981491 --- /dev/null +++ b/packages/sql/sqlite-node/test/Resolver.test.ts @@ -0,0 +1,186 @@ +import { NodeFileSystem } from "@effect/platform-node" +import { SqliteClient } from "@effect/sql-sqlite-node" +import { assert, describe, it } from "@effect/vitest" +import { Cause, Effect } from "effect" +import { Iterable } from "effect/collections" +import { FileSystem } from "effect/platform" +import { Schema } from "effect/schema" +import { Reactivity } from "effect/unstable/reactivity" +import { SqlError, SqlResolver } from "effect/unstable/sql" + +const makeClient = Effect.gen(function*() { + const fs = yield* FileSystem.FileSystem + const dir = yield* fs.makeTempDirectoryScoped() + return yield* SqliteClient.make({ + filename: dir + "/test.db" + }) +}).pipe(Effect.provide([NodeFileSystem.layer, Reactivity.layer])) + +const seededClient = Effect.gen(function*() { + const sql = yield* makeClient + yield* sql`CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)` + for (const id of Iterable.range(1, 100)) { + yield* sql`INSERT INTO test ${sql.insert({ id, name: `name${id}` })}` + } + return sql +}) + +describe("Resolver", () => { + describe("ordered", () => { + it.effect("insert", () => + Effect.gen(function*() { + const batches: Array> = [] + const sql = yield* seededClient + const Insert = SqlResolver.ordered({ + Request: Schema.String, + Result: Schema.Struct({ id: Schema.Number, name: Schema.String }), + execute: (names) => { + batches.push(names) + return sql`INSERT INTO test ${sql.insert(names.map((name) => ({ name })))} RETURNING *` + } + }) + const execute = SqlResolver.request(Insert) + assert.deepStrictEqual( + yield* Effect.all({ + one: execute("one"), + two: execute("two") + }, { concurrency: "unbounded" }), + { + one: { id: 101, name: "one" }, + two: { id: 102, name: "two" } + } + ) + assert.deepStrictEqual(batches, [["one", "two"]]) + })) + + it.effect("result length mismatch", () => + Effect.gen(function*() { + const batches: Array> = [] + const sql = yield* seededClient + const Select = SqlResolver.ordered({ + Request: Schema.Number, + Result: Schema.Struct({ id: Schema.Number, name: Schema.String }), + execute: (ids) => { + batches.push(ids) + return sql`SELECT * FROM test WHERE id IN ${sql.in(ids)}` + } + }) + const execute = SqlResolver.request(Select) + const error = yield* Effect.all([ + execute(1), + execute(2), + execute(3), + execute(101) + ], { concurrency: "unbounded" }) + .pipe(Effect.flip) + assert(error instanceof SqlError.ResultLengthMismatch) + assert.strictEqual(error.actual, 3) + assert.strictEqual(error.expected, 4) + assert.deepStrictEqual(batches, [[1, 2, 3, 101]]) + })) + }) + + describe("grouped", () => { + it.effect("find by name", () => + Effect.gen(function*() { + const sql = yield* seededClient + const FindByName = SqlResolver.grouped({ + Request: Schema.String, + RequestGroupKey: (name) => name, + Result: Schema.Struct({ id: Schema.Number, name: Schema.String }), + ResultGroupKey: (result) => result.name, + execute: (names) => sql`SELECT * FROM test WHERE name IN ${sql.in(names)}` + }) + yield* sql`INSERT INTO test ${sql.insert({ name: "name1" })}` + const execute = SqlResolver.request(FindByName) + assert.deepStrictEqual( + yield* Effect.all({ + one: execute("name1"), + two: execute("name2"), + three: Effect.flip(execute("name0")) + }, { concurrency: "unbounded" }), + { + one: [{ id: 1, name: "name1" }, { id: 101, name: "name1" }], + two: [{ id: 2, name: "name2" }], + three: new Cause.NoSuchElementError() + } + ) + })) + + it.effect("using raw rows", () => + Effect.gen(function*() { + const sql = yield* seededClient + const FindByName = SqlResolver.grouped({ + Request: Schema.String, + RequestGroupKey: (name) => name, + Result: Schema.Struct({ id: Schema.Number, name: Schema.String }), + ResultGroupKey: (_, result: any) => result.name, + execute: (names) => sql`SELECT * FROM test WHERE name IN ${sql.in(names)}` + }) + yield* sql`INSERT INTO test ${sql.insert({ name: "name1" })}` + const execute = SqlResolver.request(FindByName) + assert.deepStrictEqual( + yield* Effect.all({ + one: execute("name1"), + two: execute("name2"), + three: Effect.flip(execute("name0")) + }, { concurrency: "unbounded" }), + { + one: [{ id: 1, name: "name1" }, { id: 101, name: "name1" }], + two: [{ id: 2, name: "name2" }], + three: new Cause.NoSuchElementError() + } + ) + })) + }) + + describe("findById", () => { + it.effect("find by id", () => + Effect.gen(function*() { + const sql = yield* seededClient + const FindById = SqlResolver.findById({ + Id: Schema.Number, + Result: Schema.Struct({ id: Schema.Number, name: Schema.String }), + ResultId: (result) => result.id, + execute: (ids) => sql`SELECT * FROM test WHERE id IN ${sql.in(ids)}` + }) + const execute = SqlResolver.request(FindById) + assert.deepStrictEqual( + yield* Effect.all({ + one: execute(1), + two: execute(2), + three: Effect.flip(execute(101)) + }, { concurrency: "unbounded" }), + { + one: { id: 1, name: "name1" }, + two: { id: 2, name: "name2" }, + three: new Cause.NoSuchElementError() + } + ) + })) + + it.effect("using raw rows", () => + Effect.gen(function*() { + const sql = yield* seededClient + const FindById = SqlResolver.findById({ + Id: Schema.Number, + Result: Schema.Struct({ id: Schema.Number, name: Schema.String }), + ResultId: (_, result: any) => result.id, + execute: (ids) => sql`SELECT * FROM test WHERE id IN ${sql.in(ids)}` + }) + const execute = SqlResolver.request(FindById) + assert.deepStrictEqual( + yield* Effect.all({ + one: execute(1), + two: execute(2), + three: Effect.flip(execute(101)) + }, { concurrency: "unbounded" }), + { + one: { id: 1, name: "name1" }, + two: { id: 2, name: "name2" }, + three: new Cause.NoSuchElementError() + } + ) + })) + }) +}) diff --git a/packages/sql/sqlite-node/tsconfig.build.json b/packages/sql/sqlite-node/tsconfig.build.json new file mode 100644 index 0000000000..e738132ff9 --- /dev/null +++ b/packages/sql/sqlite-node/tsconfig.build.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "./tsconfig.src.json", + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", + "outDir": "dist", + "stripInternal": true + } +} diff --git a/packages/sql/sqlite-node/tsconfig.json b/packages/sql/sqlite-node/tsconfig.json new file mode 100644 index 0000000000..11922f5b68 --- /dev/null +++ b/packages/sql/sqlite-node/tsconfig.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": [], + "references": [{ "path": "tsconfig.src.json" }, { "path": "tsconfig.test.json" }] +} diff --git a/packages/sql/sqlite-node/tsconfig.src.json b/packages/sql/sqlite-node/tsconfig.src.json new file mode 100644 index 0000000000..1fdbb717d9 --- /dev/null +++ b/packages/sql/sqlite-node/tsconfig.src.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["src"], + "references": [{ "path": "../../effect/tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", + "outDir": ".tsbuildinfo/src", + "rootDir": "src", + "types": ["node"] + } +} diff --git a/packages/sql/sqlite-node/tsconfig.test.json b/packages/sql/sqlite-node/tsconfig.test.json new file mode 100644 index 0000000000..61204e1748 --- /dev/null +++ b/packages/sql/sqlite-node/tsconfig.test.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["test/**/*.ts", "test/**/*.json"], + "references": [{ "path": "tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/test.tsbuildinfo", + "outDir": ".tsbuildinfo/test", + "rootDir": "test", + "noEmit": true, + "erasableSyntaxOnly": false, + "resolveJsonModule": true, + "baseUrl": ".", + "paths": { + "@effect/sql-sqlite-node": ["src/index.ts"], + "@effect/sql-sqlite-node/*": ["src/*/index.ts", "src/*.ts"] + }, + "plugins": [ + { + "name": "@effect/language-service", + "namespaceImportPackages": [] + } + ] + } +} diff --git a/packages/sql/sqlite-node/vitest.config.ts b/packages/sql/sqlite-node/vitest.config.ts new file mode 100644 index 0000000000..c8a52c1826 --- /dev/null +++ b/packages/sql/sqlite-node/vitest.config.ts @@ -0,0 +1,6 @@ +import { mergeConfig, type ViteUserConfig } from "vitest/config" +import shared from "../../../vitest.shared.ts" + +const config: ViteUserConfig = {} + +export default mergeConfig(shared, config) diff --git a/packages/sql/sqlite-react-native/LICENSE b/packages/sql/sqlite-react-native/LICENSE new file mode 100644 index 0000000000..7f6fe480f7 --- /dev/null +++ b/packages/sql/sqlite-react-native/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023-present The Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/sql/sqlite-react-native/README.md b/packages/sql/sqlite-react-native/README.md new file mode 100644 index 0000000000..867a22142f --- /dev/null +++ b/packages/sql/sqlite-react-native/README.md @@ -0,0 +1,7 @@ +# `@effect/sql-sqlite-react-native` + +An `@effect/sql` implementation using the `react-native-quick-sqlite` library. + +## Documentation + +- **API Reference**: [View the full documentation](https://effect-ts.github.io/effect/docs/sql-sqlite-react-native). diff --git a/packages/sql/sqlite-react-native/docgen.json b/packages/sql/sqlite-react-native/docgen.json new file mode 100644 index 0000000000..2a9dd3acbc --- /dev/null +++ b/packages/sql/sqlite-react-native/docgen.json @@ -0,0 +1,20 @@ +{ + "$schema": "../../node_modules/@effect/docgen/schema.json", + "srcLink": "https://github.com/Effect-TS/effect/tree/main/packages/sql/sqlite-react-native/src/", + "exclude": ["src/internal/**/*.ts"], + "examplesCompilerOptions": { + "noEmit": true, + "strict": true, + "skipLibCheck": true, + "moduleResolution": "Bundler", + "module": "ES2022", + "target": "ES2022", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "rewriteRelativeImportExtensions": true, + "allowImportingTsExtensions": true, + "paths": { + "effect": ["../../../effect/src/index.js"], + "effect/*": ["../../../effect/src/*.js"] + } + } +} diff --git a/packages/sql/sqlite-react-native/package.json b/packages/sql/sqlite-react-native/package.json new file mode 100644 index 0000000000..1f64497726 --- /dev/null +++ b/packages/sql/sqlite-react-native/package.json @@ -0,0 +1,66 @@ +{ + "name": "@effect/sql-sqlite-react-native", + "version": "0.47.1", + "type": "module", + "license": "MIT", + "description": "A SQLite toolkit for Effect", + "homepage": "https://effect.website", + "repository": { + "type": "git", + "url": "https://github.com/Effect-TS/effect.git", + "directory": "packages/sql/sqlite-react-native" + }, + "bugs": { + "url": "https://github.com/Effect-TS/effect/issues" + }, + "tags": [ + "typescript", + "sql", + "database" + ], + "keywords": [ + "typescript", + "sql", + "database" + ], + "sideEffects": [], + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts", + "./*": "./src/*.ts", + "./internal/*": null, + "./*/index": null + }, + "files": [ + "src/**/*.ts", + "dist/**/*.js", + "dist/**/*.js.map", + "dist/**/*.d.ts", + "dist/**/*.d.ts.map" + ], + "publishConfig": { + "provenance": true, + "exports": { + "./package.json": "./package.json", + ".": "./dist/index.js", + "./*": "./dist/*.js", + "./internal/*": null, + "./*/index": null + } + }, + "scripts": { + "codegen": "build-utils prepare-v4", + "build": "tsc -b tsconfig.build.json && babel dist --plugins annotate-pure-calls --out-dir dist --source-maps", + "check": "tsc -b tsconfig.json", + "test": "vitest", + "coverage": "vitest --coverage" + }, + "devDependencies": { + "@op-engineering/op-sqlite": "15.0.1", + "effect": "workspace:^" + }, + "peerDependencies": { + "@op-engineering/op-sqlite": "7.1.0", + "effect": "workspace:^" + } +} diff --git a/packages/sql/sqlite-react-native/src/SqliteClient.ts b/packages/sql/sqlite-react-native/src/SqliteClient.ts new file mode 100644 index 0000000000..08b6ab71d9 --- /dev/null +++ b/packages/sql/sqlite-react-native/src/SqliteClient.ts @@ -0,0 +1,218 @@ +/** + * @since 1.0.0 + */ +import * as Sqlite from "@op-engineering/op-sqlite" +import * as Config from "effect/config/Config" +import * as Effect from "effect/Effect" +import * as Fiber from "effect/Fiber" +import { constFalse, identity } from "effect/Function" +import * as Layer from "effect/Layer" +import * as Scope from "effect/Scope" +import * as ServiceMap from "effect/ServiceMap" +import * as Stream from "effect/stream/Stream" +import * as Reactivity from "effect/unstable/reactivity/Reactivity" +import * as Client from "effect/unstable/sql/SqlClient" +import type { Connection } from "effect/unstable/sql/SqlConnection" +import { SqlError } from "effect/unstable/sql/SqlError" +import * as Statement from "effect/unstable/sql/Statement" + +const ATTR_DB_SYSTEM_NAME = "db.system.name" + +/** + * @category type ids + * @since 1.0.0 + */ +export const TypeId: TypeId = "~@effect/sql-sqlite-react-native/SqliteClient" + +/** + * @category type ids + * @since 1.0.0 + */ +export type TypeId = "~@effect/sql-sqlite-react-native/SqliteClient" + +/** + * @category models + * @since 1.0.0 + */ +export interface SqliteClient extends Client.SqlClient { + readonly [TypeId]: TypeId + readonly config: SqliteClientConfig + + /** Not supported in sqlite */ + readonly updateValues: never +} + +/** + * @category tags + * @since 1.0.0 + */ +export const SqliteClient = ServiceMap.Key("@effect/sql-sqlite-react-native/SqliteClient") + +/** + * @category models + * @since 1.0.0 + */ +export interface SqliteClientConfig { + readonly filename: string + readonly location?: string | undefined + readonly encryptionKey?: string | undefined + readonly spanAttributes?: Record | undefined + readonly transformResultNames?: ((str: string) => string) | undefined + readonly transformQueryNames?: ((str: string) => string) | undefined +} + +/** + * @category fiber refs + * @since 1.0.0 + */ +export const AsyncQuery = ServiceMap.Reference( + "@effect/sql-sqlite-react-native/Client/asyncQuery", + { defaultValue: constFalse } +) + +/** + * @category fiber refs + * @since 1.0.0 + */ +export const withAsyncQuery = (effect: Effect.Effect) => + Effect.provideService(effect, AsyncQuery, true) + +interface SqliteConnection extends Connection {} + +/** + * @category constructor + * @since 1.0.0 + */ +export const make = ( + options: SqliteClientConfig +): Effect.Effect => + Effect.gen(function*() { + const clientOptions: Parameters[0] = { + name: options.filename + } + if (options.location) { + clientOptions.location = options.location + } + if (options.encryptionKey) { + clientOptions.encryptionKey = options.encryptionKey + } + + const compiler = Statement.makeCompilerSqlite(options.transformQueryNames) + const transformRows = options.transformResultNames ? + Statement.defaultTransforms(options.transformResultNames).array : + undefined + + const makeConnection = Effect.gen(function*() { + const db = Sqlite.open(clientOptions) + yield* Effect.addFinalizer(() => Effect.sync(() => db.close())) + + const run = ( + sql: string, + params: ReadonlyArray = [], + values = false + ) => + Effect.withFiber, SqlError>((fiber) => { + if (fiber.getRef(AsyncQuery)) { + return Effect.map( + Effect.tryPromise({ + try: () => db.execute(sql, params as Array), + catch: (cause) => new SqlError({ cause, message: "Failed to execute statement (async)" }) + }), + (result) => values ? result.rawRows ?? [] : result.rows + ) + } + return Effect.try({ + try: () => { + const result = db.executeSync(sql, params as Array) + return values ? result.rawRows ?? [] : result.rows + }, + catch: (cause) => new SqlError({ cause, message: "Failed to execute statement" }) + }) + }) + + return identity({ + execute(sql, params, transformRows) { + return transformRows + ? Effect.map(run(sql, params), transformRows) + : run(sql, params) + }, + executeRaw(sql, params) { + return run(sql, params) + }, + executeValues(sql, params) { + return run(sql, params, true) + }, + executeUnprepared(sql, params, transformRows) { + return this.execute(sql, params, transformRows) + }, + executeStream() { + return Stream.die("executeStream not implemented") + } + }) + }) + + const semaphore = yield* Effect.makeSemaphore(1) + const connection = yield* makeConnection + + const acquirer = semaphore.withPermits(1)(Effect.succeed(connection)) + const transactionAcquirer = Effect.uninterruptibleMask((restore) => { + const fiber = Fiber.getCurrent()! + const scope = ServiceMap.unsafeGet(fiber.services, Scope.Scope) + return Effect.as( + Effect.tap( + restore(semaphore.take(1)), + () => Scope.addFinalizer(scope, semaphore.release(1)) + ), + connection + ) + }) + + return Object.assign( + (yield* Client.make({ + acquirer, + compiler, + transactionAcquirer, + spanAttributes: [ + ...(options.spanAttributes ? Object.entries(options.spanAttributes) : []), + [ATTR_DB_SYSTEM_NAME, "sqlite"] + ], + transformRows + })) as SqliteClient, + { + [TypeId]: TypeId, + config: options + } + ) + }) + +/** + * @category layers + * @since 1.0.0 + */ +export const layerConfig = ( + config: Config.Wrap +): Layer.Layer => + Layer.effectServices( + Config.unwrap(config).asEffect().pipe( + Effect.flatMap(make), + Effect.map((client) => + ServiceMap.make(SqliteClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + ) + ) + ) + ).pipe(Layer.provide(Reactivity.layer)) + +/** + * @category layers + * @since 1.0.0 + */ +export const layer = ( + config: SqliteClientConfig +): Layer.Layer => + Layer.effectServices( + Effect.map(make(config), (client) => + ServiceMap.make(SqliteClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + )) + ).pipe(Layer.provide(Reactivity.layer)) diff --git a/packages/sql/sqlite-react-native/src/SqliteMigrator.ts b/packages/sql/sqlite-react-native/src/SqliteMigrator.ts new file mode 100644 index 0000000000..a8f92d36cb --- /dev/null +++ b/packages/sql/sqlite-react-native/src/SqliteMigrator.ts @@ -0,0 +1,33 @@ +/** + * @since 1.0.0 + */ +import type * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" +import * as Migrator from "effect/unstable/sql/Migrator" +import type * as Client from "effect/unstable/sql/SqlClient" +import type { SqlError } from "effect/unstable/sql/SqlError" + +/** + * @since 1.0.0 + */ +export * from "effect/unstable/sql/Migrator" + +/** + * @category constructor + * @since 1.0.0 + */ +export const run: ( + options: Migrator.MigratorOptions +) => Effect.Effect< + ReadonlyArray, + SqlError | Migrator.MigrationError, + Client.SqlClient | R +> = Migrator.make({}) + +/** + * @category constructor + * @since 1.0.0 + */ +export const layer = ( + options: Migrator.MigratorOptions +): Layer.Layer => Layer.effectDiscard(run(options)) diff --git a/packages/sql/sqlite-react-native/src/index.ts b/packages/sql/sqlite-react-native/src/index.ts new file mode 100644 index 0000000000..09e759128f --- /dev/null +++ b/packages/sql/sqlite-react-native/src/index.ts @@ -0,0 +1,13 @@ +/** + * @since 1.0.0 + */ + +/** + * @since 1.0.0 + */ +export * as SqliteClient from "./SqliteClient.ts" + +/** + * @since 1.0.0 + */ +export * as SqliteMigrator from "./SqliteMigrator.ts" diff --git a/packages/sql/sqlite-react-native/src/index.ts.tpl b/packages/sql/sqlite-react-native/src/index.ts.tpl new file mode 100644 index 0000000000..b66408871c --- /dev/null +++ b/packages/sql/sqlite-react-native/src/index.ts.tpl @@ -0,0 +1,3 @@ +/** + * @since 1.0.0 + */ diff --git a/packages/sql/sqlite-react-native/test/Client.test.ts b/packages/sql/sqlite-react-native/test/Client.test.ts new file mode 100644 index 0000000000..fc3285a360 --- /dev/null +++ b/packages/sql/sqlite-react-native/test/Client.test.ts @@ -0,0 +1,6 @@ +import { describe, it } from "@effect/vitest" +import { Effect } from "effect" + +describe("Client", () => { + it.effect("should work", () => Effect.void) +}) diff --git a/packages/sql/sqlite-react-native/tsconfig.build.json b/packages/sql/sqlite-react-native/tsconfig.build.json new file mode 100644 index 0000000000..e738132ff9 --- /dev/null +++ b/packages/sql/sqlite-react-native/tsconfig.build.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "./tsconfig.src.json", + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", + "outDir": "dist", + "stripInternal": true + } +} diff --git a/packages/sql/sqlite-react-native/tsconfig.json b/packages/sql/sqlite-react-native/tsconfig.json new file mode 100644 index 0000000000..11922f5b68 --- /dev/null +++ b/packages/sql/sqlite-react-native/tsconfig.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": [], + "references": [{ "path": "tsconfig.src.json" }, { "path": "tsconfig.test.json" }] +} diff --git a/packages/sql/sqlite-react-native/tsconfig.src.json b/packages/sql/sqlite-react-native/tsconfig.src.json new file mode 100644 index 0000000000..74e3e3a4d0 --- /dev/null +++ b/packages/sql/sqlite-react-native/tsconfig.src.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["src"], + "references": [{ "path": "../../effect/tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", + "outDir": ".tsbuildinfo/src", + "rootDir": "src", + "types": ["node"], + "moduleResolution": "nodenext" + } +} diff --git a/packages/sql/sqlite-react-native/tsconfig.test.json b/packages/sql/sqlite-react-native/tsconfig.test.json new file mode 100644 index 0000000000..52e7329748 --- /dev/null +++ b/packages/sql/sqlite-react-native/tsconfig.test.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["test/**/*.ts", "test/**/*.json"], + "references": [{ "path": "tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/test.tsbuildinfo", + "outDir": ".tsbuildinfo/test", + "rootDir": "test", + "noEmit": true, + "erasableSyntaxOnly": false, + "resolveJsonModule": true, + "baseUrl": ".", + "paths": { + "@effect/sql-react-native": ["src/index.ts"], + "@effect/sql-react-native/*": ["src/*/index.ts", "src/*.ts"] + }, + "plugins": [ + { + "name": "@effect/language-service", + "namespaceImportPackages": [] + } + ] + } +} diff --git a/packages/sql/sqlite-react-native/vitest.config.ts b/packages/sql/sqlite-react-native/vitest.config.ts new file mode 100644 index 0000000000..c8a52c1826 --- /dev/null +++ b/packages/sql/sqlite-react-native/vitest.config.ts @@ -0,0 +1,6 @@ +import { mergeConfig, type ViteUserConfig } from "vitest/config" +import shared from "../../../vitest.shared.ts" + +const config: ViteUserConfig = {} + +export default mergeConfig(shared, config) diff --git a/packages/sql/sqlite-wasm/LICENSE b/packages/sql/sqlite-wasm/LICENSE new file mode 100644 index 0000000000..7f6fe480f7 --- /dev/null +++ b/packages/sql/sqlite-wasm/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023-present The Contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/sql/sqlite-wasm/README.md b/packages/sql/sqlite-wasm/README.md new file mode 100644 index 0000000000..68aa1a3180 --- /dev/null +++ b/packages/sql/sqlite-wasm/README.md @@ -0,0 +1,7 @@ +# `@effect/sql-sqlite-wasm` + +An `@effect/sql` implementation using the `@sqlite.org/sqlite-wasm` library. + +## Documentation + +- **API Reference**: [View the full documentation](https://effect-ts.github.io/effect/docs/sql-sqlite-wasm). diff --git a/packages/sql/sqlite-wasm/docgen.json b/packages/sql/sqlite-wasm/docgen.json new file mode 100644 index 0000000000..fbd9b4217c --- /dev/null +++ b/packages/sql/sqlite-wasm/docgen.json @@ -0,0 +1,20 @@ +{ + "$schema": "../../node_modules/@effect/docgen/schema.json", + "srcLink": "https://github.com/Effect-TS/effect/tree/main/packages/sql/do/src/", + "exclude": ["src/internal/**/*.ts"], + "examplesCompilerOptions": { + "noEmit": true, + "strict": true, + "skipLibCheck": true, + "moduleResolution": "Bundler", + "module": "ES2022", + "target": "ES2022", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "rewriteRelativeImportExtensions": true, + "allowImportingTsExtensions": true, + "paths": { + "effect": ["../../../effect/src/index.js"], + "effect/*": ["../../../effect/src/*.js"] + } + } +} diff --git a/packages/sql/sqlite-wasm/package.json b/packages/sql/sqlite-wasm/package.json new file mode 100644 index 0000000000..c24c1be0d9 --- /dev/null +++ b/packages/sql/sqlite-wasm/package.json @@ -0,0 +1,66 @@ +{ + "name": "@effect/sql-sqlite-wasm", + "version": "0.45.1", + "type": "module", + "license": "MIT", + "description": "A SQLite toolkit for Effect", + "homepage": "https://effect.website", + "repository": { + "type": "git", + "url": "https://github.com/Effect-TS/effect.git", + "directory": "packages/sql/sqlite-wasm" + }, + "bugs": { + "url": "https://github.com/Effect-TS/effect/issues" + }, + "tags": [ + "typescript", + "sql", + "database" + ], + "keywords": [ + "typescript", + "sql", + "database" + ], + "sideEffects": [], + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts", + "./*": "./src/*.ts", + "./internal/*": null, + "./*/index": null + }, + "files": [ + "src/**/*.ts", + "dist/**/*.js", + "dist/**/*.js.map", + "dist/**/*.d.ts", + "dist/**/*.d.ts.map" + ], + "publishConfig": { + "provenance": true, + "exports": { + "./package.json": "./package.json", + ".": "./dist/index.js", + "./*": "./dist/*.js", + "./internal/*": null, + "./*/index": null + } + }, + "scripts": { + "codegen": "build-utils prepare-v4", + "build": "tsc -b tsconfig.build.json && babel dist --plugins annotate-pure-calls --out-dir dist --source-maps", + "check": "tsc -b tsconfig.json", + "test": "vitest", + "coverage": "vitest --coverage" + }, + "devDependencies": { + "@effect/wa-sqlite": "^0.2.1", + "effect": "workspace:^" + }, + "peerDependencies": { + "@effect/wa-sqlite": "^0.1.2", + "effect": "workspace:^" + } +} diff --git a/packages/sql/sqlite-wasm/src/OpfsWorker.ts b/packages/sql/sqlite-wasm/src/OpfsWorker.ts new file mode 100644 index 0000000000..b7d910e03e --- /dev/null +++ b/packages/sql/sqlite-wasm/src/OpfsWorker.ts @@ -0,0 +1,101 @@ +/** + * @since 1.0.0 + */ +/// +import * as WaSqlite from "@effect/wa-sqlite" +import SQLiteESMFactory from "@effect/wa-sqlite/dist/wa-sqlite.mjs" +import { AccessHandlePoolVFS } from "@effect/wa-sqlite/src/examples/AccessHandlePoolVFS.js" +import * as Effect from "effect/Effect" +import { SqlError } from "effect/unstable/sql/SqlError" +import type { OpfsWorkerMessage } from "./internal/opfsWorker.ts" + +/** + * @category models + * @since 1.0.0 + */ +export interface OpfsWorkerConfig { + readonly port: EventTarget & Pick + readonly dbName: string +} + +/** + * @category constructor + * @since 1.0.0 + */ +export const run = ( + options: OpfsWorkerConfig +): Effect.Effect => + Effect.gen(function*() { + const factory = yield* Effect.promise(() => SQLiteESMFactory()) + const sqlite3 = WaSqlite.Factory(factory) + const vfs = yield* Effect.promise(() => AccessHandlePoolVFS.create("opfs", factory)) + sqlite3.vfs_register(vfs, false) + const db = yield* Effect.acquireRelease( + Effect.try({ + try: () => sqlite3.open_v2(options.dbName, undefined, "opfs"), + catch: (cause) => new SqlError({ cause, message: "Failed to open database" }) + }), + (db) => Effect.sync(() => sqlite3.close(db)) + ) + + return yield* Effect.callback((resume) => { + const onMessage = (event: any) => { + let messageId: number + const message = event.data as OpfsWorkerMessage + try { + switch (message[0]) { + case "close": { + options.port.close() + return resume(Effect.void) + } + case "import": { + const [, id, data] = message + messageId = id + sqlite3.deserialize(db, "main", data, data.length, data.length, 1 | 2) + options.port.postMessage([id, void 0, void 0]) + return + } + case "export": { + const [, id] = message + messageId = id + const data = sqlite3.serialize(db, "main") + options.port.postMessage([id, undefined, data], [data.buffer]) + return + } + case "update_hook": { + messageId = -1 + sqlite3.update_hook(db, (_op, _db, table, rowid) => { + if (!table) return + options.port.postMessage(["update_hook", table, Number(rowid)]) + }) + return + } + default: { + const [id, sql, params] = message + messageId = id + const results: Array = [] + let columns: Array | undefined + for (const stmt of sqlite3.statements(db, sql)) { + sqlite3.bind_collection(stmt, params as any) + while (sqlite3.step(stmt) === WaSqlite.SQLITE_ROW) { + columns = columns ?? sqlite3.column_names(stmt) + const row = sqlite3.row(stmt) + results.push(row) + } + } + options.port.postMessage([id, undefined, [columns, results]]) + return + } + } + } catch (e: any) { + const message = "message" in e ? e.message : String(e) + options.port.postMessage([messageId!, message, undefined]) + } + } + options.port.addEventListener("message", onMessage) + options.port.postMessage(["ready", undefined, undefined]) + return Effect.sync(() => { + options.port.removeEventListener("message", onMessage) + }) + }) + }).pipe(Effect.scoped) diff --git a/packages/sql/sqlite-wasm/src/SqliteClient.ts b/packages/sql/sqlite-wasm/src/SqliteClient.ts new file mode 100644 index 0000000000..eb80d22b81 --- /dev/null +++ b/packages/sql/sqlite-wasm/src/SqliteClient.ts @@ -0,0 +1,501 @@ +/** + * @since 1.0.0 + */ +import * as WaSqlite from "@effect/wa-sqlite" +import SQLiteESMFactory from "@effect/wa-sqlite/dist/wa-sqlite.mjs" +import { MemoryVFS } from "@effect/wa-sqlite/src/examples/MemoryVFS.js" +import * as Config from "effect/config/Config" +import * as Deferred from "effect/Deferred" +import * as Effect from "effect/Effect" +import * as Exit from "effect/Exit" +import * as Fiber from "effect/Fiber" +import { identity } from "effect/Function" +import * as Layer from "effect/Layer" +import * as Scope from "effect/Scope" +import * as ScopedRef from "effect/ScopedRef" +import * as ServiceMap from "effect/ServiceMap" +import * as Stream from "effect/stream/Stream" +import * as Reactivity from "effect/unstable/reactivity/Reactivity" +import * as Client from "effect/unstable/sql/SqlClient" +import type { Connection } from "effect/unstable/sql/SqlConnection" +import { SqlError } from "effect/unstable/sql/SqlError" +import * as Statement from "effect/unstable/sql/Statement" +import type { OpfsWorkerMessage } from "./internal/opfsWorker.ts" + +const ATTR_DB_SYSTEM_NAME = "db.system.name" + +/** + * @category type ids + * @since 1.0.0 + */ +export const TypeId: TypeId = "~@effect/sql-sqlite-wasm/SqliteClient" + +/** + * @category type ids + * @since 1.0.0 + */ +export type TypeId = "~@effect/sql-sqlite-wasm/SqliteClient" + +/** + * @category models + * @since 1.0.0 + */ +export interface SqliteClient extends Client.SqlClient { + readonly [TypeId]: TypeId + readonly config: SqliteClientMemoryConfig + readonly export: Effect.Effect + readonly import: (data: Uint8Array) => Effect.Effect + + /** Not supported in sqlite */ + readonly updateValues: never +} + +/** + * @category tags + * @since 1.0.0 + */ +export const SqliteClient = ServiceMap.Key("@effect/sql-sqlite-wasm/SqliteClient") + +/** + * @category models + * @since 1.0.0 + */ +export interface SqliteClientMemoryConfig { + readonly installReactivityHooks?: boolean + readonly spanAttributes?: Record + readonly transformResultNames?: (str: string) => string + readonly transformQueryNames?: (str: string) => string +} + +/** + * @category models + * @since 1.0.0 + */ +export interface SqliteClientConfig { + readonly worker: Effect.Effect + readonly installReactivityHooks?: boolean + readonly spanAttributes?: Record + readonly transformResultNames?: (str: string) => string + readonly transformQueryNames?: (str: string) => string +} + +interface SqliteConnection extends Connection { + readonly export: Effect.Effect + readonly import: (data: Uint8Array) => Effect.Effect +} + +const initModule = Effect.runSync( + Effect.cached(Effect.promise(() => SQLiteESMFactory())) +) + +const initEffect = Effect.runSync( + Effect.cached(initModule.pipe(Effect.map((module) => WaSqlite.Factory(module)))) +) + +const registered = new Set() + +/** + * @category constructor + * @since 1.0.0 + */ +export const makeMemory = ( + options: SqliteClientMemoryConfig +): Effect.Effect => + Effect.gen(function*() { + const reactivity = yield* Reactivity.Reactivity + const compiler = Statement.makeCompilerSqlite(options.transformQueryNames) + const transformRows = options.transformResultNames ? + Statement.defaultTransforms( + options.transformResultNames + ).array : + undefined + + const makeConnection = Effect.gen(function*() { + const sqlite3 = yield* initEffect + + if (registered.has("memory-vfs") === false) { + registered.add("memory-vfs") + const module = yield* initModule + // @ts-expect-error + const vfs = new MemoryVFS("memory-vfs", module) + sqlite3.vfs_register(vfs as any, false) + } + const db = yield* Effect.acquireRelease( + Effect.try({ + try: () => sqlite3.open_v2(":memory:", undefined, "memory-vfs"), + catch: (cause) => new SqlError({ cause, message: "Failed to open database" }) + }), + (db) => Effect.sync(() => sqlite3.close(db)) + ) + + if (options.installReactivityHooks) { + sqlite3.update_hook(db, (_op, _db, table, rowid) => { + if (!table) return + const id = String(Number(rowid)) + reactivity.unsafeInvalidate({ [table]: [id] }) + }) + } + + const run = ( + sql: string, + params: ReadonlyArray = [], + rowMode: "object" | "array" = "object" + ) => + Effect.try({ + try: () => { + const results: Array = [] + for (const stmt of sqlite3.statements(db, sql)) { + let columns: Array | undefined + sqlite3.bind_collection(stmt, params as any) + while (sqlite3.step(stmt) === WaSqlite.SQLITE_ROW) { + columns = columns ?? sqlite3.column_names(stmt) + const row = sqlite3.row(stmt) + if (rowMode === "object") { + const obj: Record = {} + for (let i = 0; i < columns.length; i++) { + obj[columns[i]] = row[i] + } + results.push(obj) + } else { + results.push(row) + } + } + } + return results + }, + catch: (cause) => new SqlError({ cause, message: "Failed to execute statement" }) + }) + + return identity({ + execute(sql, params, transformRows) { + return transformRows + ? Effect.map(run(sql, params), transformRows) + : run(sql, params) + }, + executeRaw(sql, params) { + return run(sql, params) + }, + executeValues(sql, params) { + return run(sql, params, "array") + }, + executeUnprepared(sql, params, transformRows) { + return this.execute(sql, params, transformRows) + }, + executeStream(sql, params, transformRows) { + function* stream() { + for (const stmt of sqlite3.statements(db, sql)) { + let columns: Array | undefined + sqlite3.bind_collection(stmt, params as any) + while (sqlite3.step(stmt) === WaSqlite.SQLITE_ROW) { + columns = columns ?? sqlite3.column_names(stmt) + const row = sqlite3.row(stmt) + const obj: Record = {} + for (let i = 0; i < columns.length; i++) { + obj[columns[i]] = row[i] + } + yield obj + } + } + } + return Stream.suspend(() => Stream.fromIteratorSucceed(stream()[Symbol.iterator]())).pipe( + transformRows + ? Stream.mapArray((chunk) => transformRows(chunk) as any) + : identity, + Stream.mapError((cause) => new SqlError({ cause, message: "Failed to execute statement" })) + ) + }, + export: Effect.try({ + try: () => sqlite3.serialize(db, "main"), + catch: (cause) => new SqlError({ cause, message: "Failed to export database" }) + }), + import(data) { + return Effect.try({ + try: () => sqlite3.deserialize(db, "main", data, data.length, data.length, 1 | 2), + catch: (cause) => new SqlError({ cause, message: "Failed to import database" }) + }) + } + }) + }) + + const semaphore = yield* Effect.makeSemaphore(1) + const connection = yield* makeConnection + + const acquirer = semaphore.withPermits(1)(Effect.succeed(connection)) + const transactionAcquirer = Effect.uninterruptibleMask((restore) => { + const fiber = Fiber.getCurrent()! + const scope = ServiceMap.unsafeGet(fiber.services, Scope.Scope) + return Effect.as( + Effect.tap( + restore(semaphore.take(1)), + () => Scope.addFinalizer(scope, semaphore.release(1)) + ), + connection + ) + }) + + return Object.assign( + (yield* Client.make({ + acquirer, + compiler, + transactionAcquirer, + spanAttributes: [ + ...(options.spanAttributes ? Object.entries(options.spanAttributes) : []), + [ATTR_DB_SYSTEM_NAME, "sqlite"] + ], + transformRows + })) as SqliteClient, + { + [TypeId]: TypeId as TypeId, + config: options, + export: semaphore.withPermits(1)(connection.export), + import(data: Uint8Array) { + return semaphore.withPermits(1)(connection.import(data)) + } + } + ) + }) + +/** + * @category constructor + * @since 1.0.0 + */ +export const make = ( + options: SqliteClientConfig +): Effect.Effect => + Effect.gen(function*() { + const reactivity = yield* Reactivity.Reactivity + const compiler = Statement.makeCompilerSqlite(options.transformQueryNames) + const transformRows = options.transformResultNames ? + Statement.defaultTransforms(options.transformResultNames).array : + undefined + const pending = new Map) => void>() + + const makeConnection = Effect.gen(function*() { + let currentId = 0 + const scope = yield* Effect.scope + const readyDeferred = yield* Deferred.make() + + const worker = yield* options.worker + const port = "port" in worker ? worker.port : worker + const postMessage = (message: OpfsWorkerMessage, transferables?: ReadonlyArray) => + port.postMessage(message, transferables as any) + + yield* Scope.addFinalizer(scope, Effect.sync(() => postMessage(["close"]))) + + const onMessage = (event: any) => { + const [id, error, results] = event.data + if (id === "ready") { + Deferred.unsafeDone(readyDeferred, Exit.void) + return + } else if (id === "update_hook") { + reactivity.unsafeInvalidate({ [error]: [results] }) + return + } else { + const resume = pending.get(id) + if (!resume) return + pending.delete(id) + if (error) { + resume(Exit.fail(new SqlError({ cause: error as string, message: "Failed to execute statement" }))) + } else { + resume(Exit.succeed(results)) + } + } + } + port.addEventListener("message", onMessage) + + function onError() { + Effect.runFork(ScopedRef.set(connectionRef, makeConnection)) + } + if ("onerror" in worker) { + worker.addEventListener("error", onError) + } + + yield* Scope.addFinalizer( + scope, + Effect.sync(() => { + worker.removeEventListener("message", onMessage) + worker.removeEventListener("error", onError) + }) + ) + + yield* Deferred.await(readyDeferred) + + if (options.installReactivityHooks) { + postMessage(["update_hook"]) + } + + const send = (id: number, message: OpfsWorkerMessage, transferables?: ReadonlyArray) => + Effect.callback((resume) => { + pending.set(id, resume) + postMessage(message, transferables) + }) + + const run = ( + sql: string, + params: ReadonlyArray = [], + rowMode: "object" | "array" = "object" + ): Effect.Effect, SqlError, never> => { + const rows = Effect.withFiber<[Array, Array], SqlError>((fiber) => { + const id = currentId++ + return send(id, [id, sql, params], fiber.getRef(Transferables)) + }) + return rowMode === "object" + ? Effect.map(rows, extractObject) + : Effect.map(rows, extractRows) + } + + return identity({ + execute(sql, params, transformRows) { + return transformRows + ? Effect.map(run(sql, params), transformRows) + : run(sql, params) + }, + executeRaw(sql, params) { + return run(sql, params) + }, + executeValues(sql, params) { + return run(sql, params, "array") + }, + executeUnprepared(sql, params, transformRows) { + return this.execute(sql, params, transformRows) + }, + executeStream() { + return Stream.die("executeStream not implemented") + }, + export: Effect.suspend(() => { + const id = currentId++ + return send(id, ["export", id]) + }), + import(data) { + return Effect.suspend(() => { + const id = currentId++ + return send(id, ["import", id, data], [data.buffer]) + }) + } + }) + }) + + const connectionRef = yield* ScopedRef.fromAcquire(makeConnection) + + const semaphore = yield* Effect.makeSemaphore(1) + const acquirer = semaphore.withPermits(1)(ScopedRef.get(connectionRef)) + const transactionAcquirer = Effect.uninterruptibleMask(Effect.fnUntraced(function*(restore) { + const fiber = Fiber.getCurrent()! + const scope = ServiceMap.unsafeGet(fiber.services, Scope.Scope) + yield* restore(semaphore.take(1)) + yield* Scope.addFinalizer(scope, semaphore.release(1)) + return yield* ScopedRef.get(connectionRef) + })) + + return Object.assign( + (yield* Client.make({ + acquirer, + compiler, + transactionAcquirer, + spanAttributes: [ + ...(options.spanAttributes ? Object.entries(options.spanAttributes) : []), + [ATTR_DB_SYSTEM_NAME, "sqlite"] + ], + transformRows + })) as SqliteClient, + { + [TypeId]: TypeId as TypeId, + config: options, + export: Effect.flatMap(acquirer, (connection) => connection.export), + import(data: Uint8Array) { + return Effect.flatMap(acquirer, (connection) => connection.import(data)) + } + } + ) + }) + +function rowToObject(columns: Array, row: Array) { + const obj: Record = {} + for (let i = 0; i < columns.length; i++) { + obj[columns[i]] = row[i] + } + return obj +} +const extractObject = (rows: [Array, Array]) => rows[1].map((row) => rowToObject(rows[0], row)) +const extractRows = (rows: [Array, Array]) => rows[1] + +/** + * @category tranferables + * @since 1.0.0 + */ +export const Transferables = ServiceMap.Reference>( + "@effect/sql-sqlite-wasm/currentTransferables", + { defaultValue: () => [] } +) + +/** + * @category tranferables + * @since 1.0.0 + */ +export const withTransferables = + (transferables: ReadonlyArray) => (effect: Effect.Effect): Effect.Effect => + Effect.provideService(effect, Transferables, transferables) + +/** + * @category layers + * @since 1.0.0 + */ +export const layerMemoryConfig = ( + config: Config.Wrap +): Layer.Layer => + Layer.effectServices( + Config.unwrap(config).asEffect().pipe( + Effect.flatMap(makeMemory), + Effect.map((client) => + ServiceMap.make(SqliteClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + ) + ) + ) + ).pipe(Layer.provide(Reactivity.layer)) + +/** + * @category layers + * @since 1.0.0 + */ +export const layerMemory = ( + config: SqliteClientMemoryConfig +): Layer.Layer => + Layer.effectServices( + Effect.map(makeMemory(config), (client) => + ServiceMap.make(SqliteClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + )) + ).pipe(Layer.provide(Reactivity.layer)) + +/** + * @category layers + * @since 1.0.0 + */ +export const layer = ( + config: SqliteClientConfig +): Layer.Layer => + Layer.effectServices( + Effect.map(make(config), (client) => + ServiceMap.make(SqliteClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + )) + ).pipe(Layer.provide(Reactivity.layer)) + +/** + * @category layers + * @since 1.0.0 + */ +export const layerConfig = ( + config: Config.Wrap +): Layer.Layer => + Layer.effectServices( + Config.unwrap(config).asEffect().pipe( + Effect.flatMap(make), + Effect.map((client) => + ServiceMap.make(SqliteClient, client).pipe( + ServiceMap.add(Client.SqlClient, client) + ) + ) + ) + ).pipe(Layer.provide(Reactivity.layer)) diff --git a/packages/sql/sqlite-wasm/src/SqliteMigrator.ts b/packages/sql/sqlite-wasm/src/SqliteMigrator.ts new file mode 100644 index 0000000000..a8f92d36cb --- /dev/null +++ b/packages/sql/sqlite-wasm/src/SqliteMigrator.ts @@ -0,0 +1,33 @@ +/** + * @since 1.0.0 + */ +import type * as Effect from "effect/Effect" +import * as Layer from "effect/Layer" +import * as Migrator from "effect/unstable/sql/Migrator" +import type * as Client from "effect/unstable/sql/SqlClient" +import type { SqlError } from "effect/unstable/sql/SqlError" + +/** + * @since 1.0.0 + */ +export * from "effect/unstable/sql/Migrator" + +/** + * @category constructor + * @since 1.0.0 + */ +export const run: ( + options: Migrator.MigratorOptions +) => Effect.Effect< + ReadonlyArray, + SqlError | Migrator.MigrationError, + Client.SqlClient | R +> = Migrator.make({}) + +/** + * @category constructor + * @since 1.0.0 + */ +export const layer = ( + options: Migrator.MigratorOptions +): Layer.Layer => Layer.effectDiscard(run(options)) diff --git a/packages/sql/sqlite-wasm/src/index.ts b/packages/sql/sqlite-wasm/src/index.ts new file mode 100644 index 0000000000..35dc3bfef0 --- /dev/null +++ b/packages/sql/sqlite-wasm/src/index.ts @@ -0,0 +1,14 @@ +/** + * @since 1.0.0 + */ +export * as OpfsWorker from "./OpfsWorker.ts" + +/** + * @since 1.0.0 + */ +export * as SqliteClient from "./SqliteClient.ts" + +/** + * @since 1.0.0 + */ +export * as SqliteMigrator from "./SqliteMigrator.ts" diff --git a/packages/sql/sqlite-wasm/src/internal/opfsWorker.ts b/packages/sql/sqlite-wasm/src/internal/opfsWorker.ts new file mode 100644 index 0000000000..938d21b7ff --- /dev/null +++ b/packages/sql/sqlite-wasm/src/internal/opfsWorker.ts @@ -0,0 +1,9 @@ +import type { Primitive } from "effect/unstable/sql/Statement" + +/** @internal */ +export type OpfsWorkerMessage = + | [id: number, sql: string, params: ReadonlyArray] + | ["import", id: number, data: Uint8Array] + | ["export", id: number] + | ["update_hook"] + | ["close"] diff --git a/packages/sql/sqlite-wasm/src/sqlite-wasm.d.ts b/packages/sql/sqlite-wasm/src/sqlite-wasm.d.ts new file mode 100644 index 0000000000..063a2d5e92 --- /dev/null +++ b/packages/sql/sqlite-wasm/src/sqlite-wasm.d.ts @@ -0,0 +1,17 @@ +/** + * @since 1.0.0 + */ +declare module "@effect/wa-sqlite/src/examples/IDBBatchAtomicVFS.js" { + export class IDBBatchAtomicVFS { + static async create(name: string, module: any, options?: any): Promise + } +} + +/** + * @since 1.0.0 + */ +declare module "@effect/wa-sqlite/src/examples/AccessHandlePoolVFS.js" { + export class AccessHandlePoolVFS { + static async create(name: string, module: any, options?: any): Promise + } +} diff --git a/packages/sql/sqlite-wasm/test/Client.test.ts b/packages/sql/sqlite-wasm/test/Client.test.ts new file mode 100644 index 0000000000..fc3285a360 --- /dev/null +++ b/packages/sql/sqlite-wasm/test/Client.test.ts @@ -0,0 +1,6 @@ +import { describe, it } from "@effect/vitest" +import { Effect } from "effect" + +describe("Client", () => { + it.effect("should work", () => Effect.void) +}) diff --git a/packages/sql/sqlite-wasm/tsconfig.build.json b/packages/sql/sqlite-wasm/tsconfig.build.json new file mode 100644 index 0000000000..e738132ff9 --- /dev/null +++ b/packages/sql/sqlite-wasm/tsconfig.build.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "./tsconfig.src.json", + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/build.tsbuildinfo", + "outDir": "dist", + "stripInternal": true + } +} diff --git a/packages/sql/sqlite-wasm/tsconfig.json b/packages/sql/sqlite-wasm/tsconfig.json new file mode 100644 index 0000000000..11922f5b68 --- /dev/null +++ b/packages/sql/sqlite-wasm/tsconfig.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": [], + "references": [{ "path": "tsconfig.src.json" }, { "path": "tsconfig.test.json" }] +} diff --git a/packages/sql/sqlite-wasm/tsconfig.src.json b/packages/sql/sqlite-wasm/tsconfig.src.json new file mode 100644 index 0000000000..32fc919ea5 --- /dev/null +++ b/packages/sql/sqlite-wasm/tsconfig.src.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["src"], + "references": [{ "path": "../../effect/tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", + "outDir": ".tsbuildinfo/src", + "rootDir": "src", + "types": ["node"], + "allowSyntheticDefaultImports": true + } +} diff --git a/packages/sql/sqlite-wasm/tsconfig.test.json b/packages/sql/sqlite-wasm/tsconfig.test.json new file mode 100644 index 0000000000..8f4ca6419c --- /dev/null +++ b/packages/sql/sqlite-wasm/tsconfig.test.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + "extends": "../../../tsconfig.base.jsonc", + "include": ["test/**/*.ts", "test/**/*.json"], + "references": [{ "path": "tsconfig.src.json" }], + "compilerOptions": { + "tsBuildInfoFile": ".tsbuildinfo/test.tsbuildinfo", + "outDir": ".tsbuildinfo/test", + "rootDir": "test", + "noEmit": true, + "erasableSyntaxOnly": false, + "resolveJsonModule": true, + "baseUrl": ".", + "paths": { + "@effect/sql-sqlite-wasm": ["src/index.ts"], + "@effect/sql-sqlite-wasm/*": ["src/*/index.ts", "src/*.ts"] + }, + "plugins": [ + { + "name": "@effect/language-service", + "namespaceImportPackages": [] + } + ] + } +} diff --git a/packages/sql/sqlite-wasm/vitest.config.ts b/packages/sql/sqlite-wasm/vitest.config.ts new file mode 100644 index 0000000000..c8a52c1826 --- /dev/null +++ b/packages/sql/sqlite-wasm/vitest.config.ts @@ -0,0 +1,6 @@ +import { mergeConfig, type ViteUserConfig } from "vitest/config" +import shared from "../../../vitest.shared.ts" + +const config: ViteUserConfig = {} + +export default mergeConfig(shared, config) diff --git a/packages/vitest/package.json b/packages/vitest/package.json index 350f298d8a..2845dfd975 100644 --- a/packages/vitest/package.json +++ b/packages/vitest/package.json @@ -49,7 +49,7 @@ "vitest": "^3.0.0" }, "devDependencies": { - "@types/node": "^24.0.14", + "@types/node": "^24.3.0", "effect": "workspace:^", "vitest": "^3.2.4" } diff --git a/packages/vitest/src/internal/internal.ts b/packages/vitest/src/internal/internal.ts index b36687eecc..041b2b13f5 100644 --- a/packages/vitest/src/internal/internal.ts +++ b/packages/vitest/src/internal/internal.ts @@ -26,7 +26,7 @@ const runPromise: ( const exit = yield* Effect.exit(effect) if (Exit.isFailure(exit)) { const errors = Cause.prettyErrors(exit.cause) - for (let i = 1; i < errors.length; i++) { + for (let i = 0; i < errors.length; i++) { yield* Effect.logError(errors[i]) } } diff --git a/patches/@op-engineering__op-sqlite.patch b/patches/@op-engineering__op-sqlite.patch new file mode 100644 index 0000000000..cb7a1e418a --- /dev/null +++ b/patches/@op-engineering__op-sqlite.patch @@ -0,0 +1,22 @@ +diff --git a/lib/typescript/src/functions.d.ts b/lib/typescript/src/functions.d.ts +index 16719484f3bd013d318317b91269f6920fcc2be8..6c658a8c25699e84cd46ee4c6592d6fe6b7ac83b 100644 +--- a/lib/typescript/src/functions.d.ts ++++ b/lib/typescript/src/functions.d.ts +@@ -1,4 +1,4 @@ +-import { type DB, type OPSQLiteProxy } from './index'; ++import { type DB, type OPSQLiteProxy } from './index.ts'; + declare global { + var __OPSQLiteProxy: object | undefined; + } +diff --git a/lib/typescript/src/index.d.ts b/lib/typescript/src/index.d.ts +index 157a5ab559f37ca7ec63556a96e697b1f7cfd687..7eaf1fea35951291472840a88f029c8f3ebccfd6 100644 +--- a/lib/typescript/src/index.d.ts ++++ b/lib/typescript/src/index.d.ts +@@ -1,5 +1,5 @@ +-export { Storage } from './Storage'; +-export * from './functions'; ++export { Storage } from './Storage.ts'; ++export * from './functions.ts'; + export type Scalar = string | number | boolean | null | ArrayBuffer | ArrayBufferView; + /** + * Object returned by SQL Query executions { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8d2eef68b4..da698a04a5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -23,29 +23,32 @@ patchedDependencies: '@changesets/get-github-info@0.6.0': hash: 1387c42d40315dc7805094fb3085da092ec802de277560db46fb53567ba583ec path: patches/@changesets__get-github-info@0.6.0.patch + '@op-engineering/op-sqlite': + hash: 633e2e7df06e7cfe942bfed907d736ce3b18b45b33a40e3170d3d8be7c605c32 + path: patches/@op-engineering__op-sqlite.patch importers: .: devDependencies: '@babel/cli': - specifier: ^7.28.0 - version: 7.28.0(@babel/core@7.28.0) + specifier: ^7.28.3 + version: 7.28.3(@babel/core@7.28.3) '@babel/core': - specifier: ^7.28.0 - version: 7.28.0 + specifier: ^7.28.3 + version: 7.28.3 '@babel/plugin-transform-export-namespace-from': specifier: ^7.24.7 - version: 7.27.1(@babel/core@7.28.0) + version: 7.27.1(@babel/core@7.28.3) '@babel/plugin-transform-modules-commonjs': specifier: ^7.24.8 - version: 7.27.1(@babel/core@7.28.0) + version: 7.27.1(@babel/core@7.28.3) '@changesets/changelog-github': specifier: ^0.5.0 version: 0.5.1 '@changesets/cli': - specifier: ^2.29.5 - version: 2.29.5 + specifier: ^2.29.6 + version: 2.29.6(@types/node@24.3.0) '@edge-runtime/vm': specifier: ^5.0.0 version: 5.0.0 @@ -54,37 +57,37 @@ importers: version: 0.8.9 '@effect/docgen': specifier: https://pkg.pr.new/Effect-TS/docgen/@effect/docgen@49e99a2 - version: https://pkg.pr.new/Effect-TS/docgen/@effect/docgen@49e99a2(tsx@4.20.3)(typescript@5.8.3) + version: https://pkg.pr.new/Effect-TS/docgen/@effect/docgen@49e99a2(tsx@4.20.5)(typescript@5.9.2) '@effect/eslint-plugin': specifier: ^0.3.2 version: 0.3.2 '@effect/language-service': - specifier: ^0.28.3 - version: 0.28.3 + specifier: ^0.36.0 + version: 0.36.0 '@effect/vitest': specifier: workspace:^ version: link:packages/vitest '@eslint/js': - specifier: ^9.31.0 - version: 9.31.0 + specifier: ^9.34.0 + version: 9.34.0 '@rollup/plugin-node-resolve': specifier: ^16.0.1 - version: 16.0.1(rollup@4.45.1) + version: 16.0.1(rollup@4.48.1) '@rollup/plugin-replace': specifier: ^6.0.2 - version: 6.0.2(rollup@4.45.1) + version: 6.0.2(rollup@4.48.1) '@rollup/plugin-terser': specifier: ^0.4.4 - version: 0.4.4(rollup@4.45.1) + version: 0.4.4(rollup@4.48.1) '@types/jscodeshift': specifier: ^17.3.0 version: 17.3.0 '@types/node': - specifier: ^24.1.0 - version: 24.1.0 + specifier: ^24.3.0 + version: 24.3.0 '@vitest/browser': specifier: ^3.2.4 - version: 3.2.4(playwright@1.54.1)(vite@7.0.5(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3))(vitest@3.2.4) + version: 3.2.4(playwright@1.55.0)(vite@7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1))(vitest@3.2.4) '@vitest/coverage-v8': specifier: ^3.2.4 version: 3.2.4(@vitest/browser@3.2.4)(vitest@3.2.4) @@ -99,40 +102,40 @@ importers: version: 0.14.2 babel-plugin-annotate-pure-calls: specifier: ^0.5.0 - version: 0.5.0(@babel/core@7.28.0) + version: 0.5.0(@babel/core@7.28.3) eslint: - specifier: ^9.31.0 - version: 9.31.0 + specifier: ^9.34.0 + version: 9.34.0 eslint-import-resolver-typescript: specifier: ^4.4.4 - version: 4.4.4(eslint-plugin-import-x@4.16.1(@typescript-eslint/utils@8.38.0(eslint@9.31.0)(typescript@5.8.3))(eslint@9.31.0))(eslint@9.31.0) + version: 4.4.4(eslint-plugin-import-x@4.16.1(@typescript-eslint/utils@8.41.0(eslint@9.34.0)(typescript@5.9.2))(eslint@9.34.0))(eslint@9.34.0) eslint-plugin-import-x: specifier: ^4.16.1 - version: 4.16.1(@typescript-eslint/utils@8.38.0(eslint@9.31.0)(typescript@5.8.3))(eslint@9.31.0) + version: 4.16.1(@typescript-eslint/utils@8.41.0(eslint@9.34.0)(typescript@5.9.2))(eslint@9.34.0) eslint-plugin-local-rules: specifier: ^3.0.2 version: 3.0.2 eslint-plugin-simple-import-sort: specifier: ^12.1.1 - version: 12.1.1(eslint@9.31.0) + version: 12.1.1(eslint@9.34.0) eslint-plugin-sort-destructure-keys: specifier: ^2.0.0 - version: 2.0.0(eslint@9.31.0) + version: 2.0.0(eslint@9.34.0) glob: specifier: ^11.0.3 version: 11.0.3 i18next: - specifier: ^25.3.2 - version: 25.3.2(typescript@5.8.3) + specifier: ^25.4.2 + version: 25.4.2(typescript@5.9.2) jscodeshift: specifier: ^17.1.2 version: 17.3.0 madge: specifier: ^8.0.0 - version: 8.0.0(typescript@5.8.3) + version: 8.0.0(typescript@5.9.2) playwright: - specifier: ^1.54.1 - version: 1.54.1 + specifier: ^1.55.0 + version: 1.55.0 prettier: specifier: ^3.6.2 version: 3.6.2 @@ -140,17 +143,17 @@ importers: specifier: ^6.0.1 version: 6.0.1 rollup: - specifier: ^4.45.1 - version: 4.45.1 + specifier: ^4.48.1 + version: 4.48.1 rollup-plugin-bundle-stats: - specifier: ^4.21.0 - version: 4.21.0(core-js@3.44.0)(rollup@4.45.1)(vite@7.0.5(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3)) + specifier: ^4.21.3 + version: 4.21.3(core-js@3.45.1)(rolldown@1.0.0-beta.34)(rollup@4.48.1)(vite@7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1)) rollup-plugin-esbuild: specifier: ^6.2.1 - version: 6.2.1(esbuild@0.25.8)(rollup@4.45.1) + version: 6.2.1(esbuild@0.25.9)(rollup@4.48.1) rollup-plugin-visualizer: specifier: ^6.0.3 - version: 6.0.3(rollup@4.45.1) + version: 6.0.3(rolldown@1.0.0-beta.34)(rollup@4.48.1) terser: specifier: ^5.43.1 version: 5.43.1 @@ -159,28 +162,31 @@ importers: version: 3.3.0 tstyche: specifier: 4.3.0 - version: 4.3.0(typescript@5.8.3) + version: 4.3.0(typescript@5.9.2) tsx: - specifier: ^4.20.3 - version: 4.20.3 + specifier: ^4.20.5 + version: 4.20.5 typescript: - specifier: ^5.8.3 - version: 5.8.3 + specifier: ^5.9.2 + version: 5.9.2 typescript-eslint: - specifier: ^8.38.0 - version: 8.38.0(eslint@9.31.0)(typescript@5.8.3) + specifier: ^8.41.0 + version: 8.41.0(eslint@9.34.0)(typescript@5.9.2) vite: - specifier: ^7.0.5 - version: 7.0.5(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3) + specifier: ^7.1.3 + version: 7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1) + vite-tsconfig-paths: + specifier: ^5.1.4 + version: 5.1.4(typescript@5.9.2)(vite@7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1)) vitest: specifier: ^3.2.4 - version: 3.2.4(@edge-runtime/vm@5.0.0)(@types/node@24.1.0)(@vitest/browser@3.2.4)(terser@5.43.1)(tsx@4.20.3) + version: 3.2.4(@edge-runtime/vm@5.0.0)(@types/node@24.3.0)(@vitest/browser@3.2.4)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1) vitest-websocket-mock: specifier: ^0.5.0 version: 0.5.0(vitest@3.2.4) zod: - specifier: ^4.0.7 - version: 4.0.7 + specifier: ^4.1.3 + version: 4.1.3 packages/effect: dependencies: @@ -199,10 +205,13 @@ importers: multipasta: specifier: ^0.2.7 version: 0.2.7 + uuid: + specifier: ^11.1.0 + version: 11.1.0 devDependencies: '@types/node': - specifier: ^24.0.14 - version: 24.1.0 + specifier: ^24.3.0 + version: 24.3.0 ajv: specifier: ^8.17.1 version: 8.17.1 @@ -216,11 +225,11 @@ importers: specifier: ^10.1.1 version: 10.1.1 tinybench: - specifier: ^4.0.1 - version: 4.0.1 + specifier: ^5.0.1 + version: 5.0.1 valibot: specifier: ^1.1.0 - version: 1.1.0(typescript@5.8.3) + version: 1.1.0(typescript@5.9.2) packages/platform-bun: dependencies: @@ -229,8 +238,8 @@ importers: version: link:../platform-node-shared devDependencies: '@types/bun': - specifier: ^1.2.18 - version: 1.2.19(@types/react@19.1.8) + specifier: ^1.2.21 + version: 1.2.21(@types/react@19.1.11) effect: specifier: workspace:^ version: link:../effect @@ -244,12 +253,18 @@ importers: specifier: ^4.0.7 version: 4.0.7 undici: - specifier: ^7.11.0 - version: 7.12.0 + specifier: ^7.15.0 + version: 7.15.0 devDependencies: + '@testcontainers/mysql': + specifier: ^11.5.1 + version: 11.5.1 + '@testcontainers/postgresql': + specifier: ^11.5.1 + version: 11.5.1 '@types/node': - specifier: ^24.0.14 - version: 24.1.0 + specifier: ^24.3.0 + version: 24.3.0 effect: specifier: workspace:^ version: link:../effect @@ -264,8 +279,8 @@ importers: version: 8.18.3 devDependencies: '@types/node': - specifier: ^24.0.14 - version: 24.1.0 + specifier: ^24.3.0 + version: 24.3.0 effect: specifier: workspace:^ version: link:../effect @@ -273,17 +288,156 @@ importers: specifier: ^7.4.3 version: 7.4.3 + packages/sql/clickhouse: + dependencies: + '@clickhouse/client': + specifier: ^1.6.0 + version: 1.12.1 + devDependencies: + '@effect/platform-node': + specifier: workspace:^ + version: link:../../platform-node + effect: + specifier: workspace:^ + version: link:../../effect + + packages/sql/d1: + dependencies: + '@cloudflare/workers-types': + specifier: ^4.20250515.0 + version: 4.20250826.0 + devDependencies: + effect: + specifier: workspace:^ + version: link:../../effect + miniflare: + specifier: ^4.20250508.0 + version: 4.20250823.0 + + packages/sql/libsql: + dependencies: + '@libsql/client': + specifier: ^0.15.14 + version: 0.15.14 + devDependencies: + effect: + specifier: workspace:^ + version: link:../../effect + testcontainers: + specifier: ^11.5.1 + version: 11.5.1 + + packages/sql/mssql: + dependencies: + tedious: + specifier: ^18.3.0 + version: 18.6.1 + devDependencies: + effect: + specifier: workspace:^ + version: link:../../effect + + packages/sql/mysql2: + dependencies: + mysql2: + specifier: ^3.11.0 + version: 3.14.3 + devDependencies: + '@testcontainers/mysql': + specifier: ^11.5.1 + version: 11.5.1 + effect: + specifier: workspace:^ + version: link:../../effect + + packages/sql/pg: + dependencies: + pg: + specifier: ^8.16.3 + version: 8.16.3 + pg-cursor: + specifier: ^2.15.3 + version: 2.15.3(pg@8.16.3) + devDependencies: + '@testcontainers/postgresql': + specifier: ^11.5.1 + version: 11.5.1 + '@types/pg': + specifier: ^8.15.5 + version: 8.15.5 + '@types/pg-cursor': + specifier: ^2.7.2 + version: 2.7.2 + effect: + specifier: workspace:^ + version: link:../../effect + + packages/sql/sqlite-bun: + devDependencies: + '@effect/platform-bun': + specifier: workspace:^ + version: link:../../platform-bun + '@types/bun': + specifier: ^1.2.21 + version: 1.2.21(@types/react@19.1.11) + effect: + specifier: workspace:^ + version: link:../../effect + + packages/sql/sqlite-do: + devDependencies: + '@cloudflare/workers-types': + specifier: ^4.20250515.0 + version: 4.20250826.0 + effect: + specifier: workspace:^ + version: link:../../effect + + packages/sql/sqlite-node: + dependencies: + better-sqlite3: + specifier: ^12.2.0 + version: 12.2.0 + devDependencies: + '@effect/platform-node': + specifier: workspace:^ + version: link:../../platform-node + '@types/better-sqlite3': + specifier: ^7.6.13 + version: 7.6.13 + effect: + specifier: workspace:^ + version: link:../../effect + + packages/sql/sqlite-react-native: + devDependencies: + '@op-engineering/op-sqlite': + specifier: 15.0.1 + version: 15.0.1(patch_hash=633e2e7df06e7cfe942bfed907d736ce3b18b45b33a40e3170d3d8be7c605c32)(react-native@0.81.0(@babel/core@7.28.3)(@react-native/metro-config@0.81.0(@babel/core@7.28.3))(@types/react@19.1.11)(react@19.1.1))(react@19.1.1) + effect: + specifier: workspace:^ + version: link:../../effect + + packages/sql/sqlite-wasm: + devDependencies: + '@effect/wa-sqlite': + specifier: ^0.2.1 + version: 0.2.1 + effect: + specifier: workspace:^ + version: link:../../effect + packages/vitest: devDependencies: '@types/node': - specifier: ^24.0.14 - version: 24.1.0 + specifier: ^24.3.0 + version: 24.3.0 effect: specifier: workspace:^ version: link:../effect vitest: specifier: ^3.2.4 - version: 3.2.4(@edge-runtime/vm@5.0.0)(@types/node@24.1.0)(@vitest/browser@3.2.4)(terser@5.43.1)(tsx@4.20.3) + version: 3.2.4(@edge-runtime/vm@5.0.0)(@types/node@24.3.0)(@vitest/browser@3.2.4)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1) scratchpad: dependencies: @@ -293,6 +447,39 @@ importers: '@effect/platform-node': specifier: workspace:* version: link:../packages/platform-node + '@effect/sql-clickhouse': + specifier: workspace:* + version: link:../packages/sql/clickhouse + '@effect/sql-d1': + specifier: workspace:* + version: link:../packages/sql/d1 + '@effect/sql-libsql': + specifier: workspace:* + version: link:../packages/sql/libsql + '@effect/sql-mssql': + specifier: workspace:* + version: link:../packages/sql/mssql + '@effect/sql-mysql2': + specifier: workspace:* + version: link:../packages/sql/mysql2 + '@effect/sql-pg': + specifier: workspace:* + version: link:../packages/sql/pg + '@effect/sql-sqlite-bun': + specifier: workspace:* + version: link:../packages/sql/sqlite-bun + '@effect/sql-sqlite-do': + specifier: workspace:* + version: link:../packages/sql/sqlite-do + '@effect/sql-sqlite-node': + specifier: workspace:* + version: link:../packages/sql/sqlite-node + '@effect/sql-sqlite-react-native': + specifier: workspace:* + version: link:../packages/sql/sqlite-react-native + '@effect/sql-sqlite-wasm': + specifier: workspace:* + version: link:../packages/sql/sqlite-wasm effect: specifier: workspace:* version: link:../packages/effect @@ -309,8 +496,76 @@ packages: '@ark/util@0.46.0': resolution: {integrity: sha512-JPy/NGWn/lvf1WmGCPw2VGpBg5utZraE84I7wli18EDF3p3zc/e9WolT35tINeZO3l7C77SjqRJeAUoT0CvMRg==} - '@babel/cli@7.28.0': - resolution: {integrity: sha512-CYrZG7FagtE8ReKDBfItxnrEBf2khq2eTMnPuqO8UVN0wzhp1eMX1wfda8b1a32l2aqYLwRRIOGNovm8FVzmMw==} + '@azure-rest/core-client@2.5.0': + resolution: {integrity: sha512-KMVIPxG6ygcQ1M2hKHahF7eddKejYsWTjoLIfTWiqnaj42dBkYzj4+S8rK9xxmlOaEHKZHcMrRbm0NfN4kgwHw==} + engines: {node: '>=20.0.0'} + + '@azure/abort-controller@2.1.2': + resolution: {integrity: sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==} + engines: {node: '>=18.0.0'} + + '@azure/core-auth@1.10.0': + resolution: {integrity: sha512-88Djs5vBvGbHQHf5ZZcaoNHo6Y8BKZkt3cw2iuJIQzLEgH4Ox6Tm4hjFhbqOxyYsgIG/eJbFEHpxRIfEEWv5Ow==} + engines: {node: '>=20.0.0'} + + '@azure/core-client@1.10.0': + resolution: {integrity: sha512-O4aP3CLFNodg8eTHXECaH3B3CjicfzkxVtnrfLkOq0XNP7TIECGfHpK/C6vADZkWP75wzmdBnsIA8ksuJMk18g==} + engines: {node: '>=20.0.0'} + + '@azure/core-http-compat@2.3.0': + resolution: {integrity: sha512-qLQujmUypBBG0gxHd0j6/Jdmul6ttl24c8WGiLXIk7IHXdBlfoBqW27hyz3Xn6xbfdyVSarl1Ttbk0AwnZBYCw==} + engines: {node: '>=18.0.0'} + + '@azure/core-lro@2.7.2': + resolution: {integrity: sha512-0YIpccoX8m/k00O7mDDMdJpbr6mf1yWo2dfmxt5A8XVZVVMz2SSKaEbMCeJRvgQ0IaSlqhjT47p4hVIRRy90xw==} + engines: {node: '>=18.0.0'} + + '@azure/core-paging@1.6.2': + resolution: {integrity: sha512-YKWi9YuCU04B55h25cnOYZHxXYtEvQEbKST5vqRga7hWY9ydd3FZHdeQF8pyh+acWZvppw13M/LMGx0LABUVMA==} + engines: {node: '>=18.0.0'} + + '@azure/core-rest-pipeline@1.22.0': + resolution: {integrity: sha512-OKHmb3/Kpm06HypvB3g6Q3zJuvyXcpxDpCS1PnU8OV6AJgSFaee/covXBcPbWc6XDDxtEPlbi3EMQ6nUiPaQtw==} + engines: {node: '>=20.0.0'} + + '@azure/core-tracing@1.3.0': + resolution: {integrity: sha512-+XvmZLLWPe67WXNZo9Oc9CrPj/Tm8QnHR92fFAFdnbzwNdCH1h+7UdpaQgRSBsMY+oW1kHXNUZQLdZ1gHX3ROw==} + engines: {node: '>=20.0.0'} + + '@azure/core-util@1.13.0': + resolution: {integrity: sha512-o0psW8QWQ58fq3i24Q1K2XfS/jYTxr7O1HRcyUE9bV9NttLU+kYOH82Ixj8DGlMTOWgxm1Sss2QAfKK5UkSPxw==} + engines: {node: '>=20.0.0'} + + '@azure/identity@4.11.1': + resolution: {integrity: sha512-0ZdsLRaOyLxtCYgyuqyWqGU5XQ9gGnjxgfoNTt1pvELGkkUFrMATABZFIq8gusM7N1qbqpVtwLOhk0d/3kacLg==} + engines: {node: '>=20.0.0'} + + '@azure/keyvault-common@2.0.0': + resolution: {integrity: sha512-wRLVaroQtOqfg60cxkzUkGKrKMsCP6uYXAOomOIysSMyt1/YM0eUn9LqieAWM8DLcU4+07Fio2YGpPeqUbpP9w==} + engines: {node: '>=18.0.0'} + + '@azure/keyvault-keys@4.10.0': + resolution: {integrity: sha512-eDT7iXoBTRZ2n3fLiftuGJFD+yjkiB1GNqzU2KbY1TLYeXeSPVTVgn2eJ5vmRTZ11978jy2Kg2wI7xa9Tyr8ag==} + engines: {node: '>=18.0.0'} + + '@azure/logger@1.3.0': + resolution: {integrity: sha512-fCqPIfOcLE+CGqGPd66c8bZpwAji98tZ4JI9i/mlTNTlsIWslCfpg48s/ypyLxZTump5sypjrKn2/kY7q8oAbA==} + engines: {node: '>=20.0.0'} + + '@azure/msal-browser@4.21.1': + resolution: {integrity: sha512-qGtzX3HJfJsOVeDcVrFZAYZoxLRjrW2lXzXqijgiBA5EtM9ud7F/EYgKKQ9TJU/WtE46szuZtQZx5vD4pEiknA==} + engines: {node: '>=0.8.0'} + + '@azure/msal-common@15.12.0': + resolution: {integrity: sha512-4ucXbjVw8KJ5QBgnGJUeA07c8iznwlk5ioHIhI4ASXcXgcf2yRFhWzYOyWg/cI49LC9ekpFJeQtO3zjDTbl6TQ==} + engines: {node: '>=0.8.0'} + + '@azure/msal-node@3.7.3': + resolution: {integrity: sha512-MoJxkKM/YpChfq4g2o36tElyzNUMG8mfD6u8NbuaPAsqfGpaw249khAcJYNoIOigUzRw45OjXCOrexE6ImdUxg==} + engines: {node: '>=16'} + + '@babel/cli@7.28.3': + resolution: {integrity: sha512-n1RU5vuCX0CsaqaXm9I0KUCNKNQMy5epmzl/xdSSm70bSqhg9GWhgeosypyQLc0bK24+Xpk1WGzZlI9pJtkZdg==} engines: {node: '>=6.9.0'} hasBin: true peerDependencies: @@ -324,12 +579,12 @@ packages: resolution: {integrity: sha512-60X7qkglvrap8mn1lh2ebxXdZYtUcpd7gsmy9kLaBJ4i/WdY8PqTSdxyA8qraikqKQK5C1KRBKXqznrVapyNaw==} engines: {node: '>=6.9.0'} - '@babel/core@7.28.0': - resolution: {integrity: sha512-UlLAnTPrFdNGoFtbSXwcGFQBtQZJCNjaN6hQNP3UPvuNXT1i82N26KL3dZeIpNalWywr9IuQuncaAfUaS1g6sQ==} + '@babel/core@7.28.3': + resolution: {integrity: sha512-yDBHV9kQNcr2/sUr9jghVyz9C3Y5G2zUM2H2lo+9mKv4sFgbA8s8Z9t8D1jiTkGoO/NoIfKMyKWr4s6CN23ZwQ==} engines: {node: '>=6.9.0'} - '@babel/generator@7.28.0': - resolution: {integrity: sha512-lJjzvrbEeWrhB4P3QBsH7tey117PjLZnDbLiQEKjQ/fNJTjuq4HSqgFA+UNSwZT8D7dxxbnuSBMsa1lrWzKlQg==} + '@babel/generator@7.28.3': + resolution: {integrity: sha512-3lSpxGgvnmZznmBkCRnVREPUFJv2wrv9iAoFDvADJc0ypmdOxdUtcLeBgBJ6zE0PMeTKnxeQzyk0xTBq4Ep7zw==} engines: {node: '>=6.9.0'} '@babel/helper-annotate-as-pure@7.27.3': @@ -340,12 +595,23 @@ packages: resolution: {integrity: sha512-2+1thGUUWWjLTYTHZWK1n8Yga0ijBz1XAhUXcKy81rd5g6yh7hGqMp45v7cadSbEHc9G3OTv45SyneRN3ps4DQ==} engines: {node: '>=6.9.0'} - '@babel/helper-create-class-features-plugin@7.27.1': - resolution: {integrity: sha512-QwGAmuvM17btKU5VqXfb+Giw4JcN0hjuufz3DYnpeVDvZLAObloM77bhMXiqry3Iio+Ai4phVRDwl6WU10+r5A==} + '@babel/helper-create-class-features-plugin@7.28.3': + resolution: {integrity: sha512-V9f6ZFIYSLNEbuGA/92uOvYsGCJNsuA8ESZ4ldc09bWk/j8H8TKiPw8Mk1eG6olpnO0ALHJmYfZvF4MEE4gajg==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0 + '@babel/helper-create-regexp-features-plugin@7.27.1': + resolution: {integrity: sha512-uVDC72XVf8UbrH5qQTc18Agb8emwjTiZrQE11Nv3CuBEZmVvTwwE9CBUEvHku06gQCAyYf8Nv6ja1IN+6LMbxQ==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0 + + '@babel/helper-define-polyfill-provider@0.6.5': + resolution: {integrity: sha512-uJnGFcPsWQK8fvjgGP5LZUZZsYGIoPeRjSF5PGwrelYgq7Q15/Ft9NGFp1zglwgIv//W0uG4BevRuSJRyylZPg==} + peerDependencies: + '@babel/core': ^7.4.0 || ^8.0.0-0 <8.0.0 + '@babel/helper-globals@7.28.0': resolution: {integrity: sha512-+W6cISkXFa1jXsDEdYA8HeevQT/FULhxzR99pxphltZcVaugps53THCeiWA8SguxxpSp3gKPiuYfSWopkLQ4hw==} engines: {node: '>=6.9.0'} @@ -358,8 +624,8 @@ packages: resolution: {integrity: sha512-0gSFWUPNXNopqtIPQvlD5WgXYI5GY2kP2cCvoT8kczjbfcfuIljTbcWrulD1CIPIX2gt1wghbDy08yE1p+/r3w==} engines: {node: '>=6.9.0'} - '@babel/helper-module-transforms@7.27.3': - resolution: {integrity: sha512-dSOvYwvyLsWBeIRyOeHXp5vPj5l1I011r52FM1+r1jCERv+aFXYk4whgQccYEGYxK2H3ZAIA8nuPkQ0HaUo3qg==} + '@babel/helper-module-transforms@7.28.3': + resolution: {integrity: sha512-gytXUbs8k2sXS9PnQptz5o0QnpLL51SwASIORY6XaBKF88nsOT0Zw9szLqlSGQDP/4TljBAD5y98p2U1fqkdsw==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0 @@ -372,6 +638,12 @@ packages: resolution: {integrity: sha512-1gn1Up5YXka3YYAHGKpbideQ5Yjf1tDa9qYcgysz+cNCXukyLl6DjPXhD3VRwSb8c0J9tA4b2+rHEZtc6R0tlw==} engines: {node: '>=6.9.0'} + '@babel/helper-remap-async-to-generator@7.27.1': + resolution: {integrity: sha512-7fiA521aVw8lSPeI4ZOD3vRFkoqkJcS+z4hFo82bFSH/2tNd6eJ5qCVMS5OzDmZh/kaHQeBaeyxK6wljcPtveA==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0 + '@babel/helper-replace-supers@7.27.1': resolution: {integrity: sha512-7EHz6qDZc8RYS5ElPoShMheWvEgERonFCs7IAonWLLUTXW59DP14bCZt89/GKyreYn8g3S83m21FelHKbeDCKA==} engines: {node: '>=6.9.0'} @@ -394,39 +666,181 @@ packages: resolution: {integrity: sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==} engines: {node: '>=6.9.0'} - '@babel/helpers@7.27.6': - resolution: {integrity: sha512-muE8Tt8M22638HU31A3CgfSUciwz1fhATfoVai05aPXGor//CdWDCbnlY1yvBPo07njuVOCNGCSp/GTt12lIug==} + '@babel/helper-wrap-function@7.28.3': + resolution: {integrity: sha512-zdf983tNfLZFletc0RRXYrHrucBEg95NIFMkn6K9dbeMYnsgHaSBGcQqdsCSStG2PYwRre0Qc2NNSCXbG+xc6g==} engines: {node: '>=6.9.0'} - '@babel/parser@7.28.0': - resolution: {integrity: sha512-jVZGvOxOuNSsuQuLRTh13nU0AogFlw32w/MT+LV6D3sP5WdbW61E77RnkbaO2dUvmPAYrBDJXGn5gGS6tH4j8g==} + '@babel/helpers@7.28.3': + resolution: {integrity: sha512-PTNtvUQihsAsDHMOP5pfobP8C6CM4JWXmP8DrEIt46c3r2bf87Ua1zoqevsMo9g+tWDwgWrFP5EIxuBx5RudAw==} + engines: {node: '>=6.9.0'} + + '@babel/parser@7.28.3': + resolution: {integrity: sha512-7+Ey1mAgYqFAx2h0RuoxcQT5+MlG3GTV0TQrgr7/ZliKsm/MNDxVVutlWaziMq7wJNAz8MTqz55XLpWvva6StA==} engines: {node: '>=6.0.0'} hasBin: true + '@babel/plugin-proposal-export-default-from@7.27.1': + resolution: {integrity: sha512-hjlsMBl1aJc5lp8MoCDEZCiYzlgdRAShOjAfRw6X+GlpLpUPU7c3XNLsKFZbQk/1cRzBlJ7CXg3xJAJMrFa1Uw==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-async-generators@7.8.4': + resolution: {integrity: sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-bigint@7.8.3': + resolution: {integrity: sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-class-properties@7.12.13': + resolution: {integrity: sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-class-static-block@7.14.5': + resolution: {integrity: sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-dynamic-import@7.8.3': + resolution: {integrity: sha512-5gdGbFon+PszYzqs83S3E5mpi7/y/8M9eC90MRTZfduQOYW76ig6SOSPNe41IG5LoP3FGBn2N0RjVDSQiS94kQ==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-export-default-from@7.27.1': + resolution: {integrity: sha512-eBC/3KSekshx19+N40MzjWqJd7KTEdOoLesAfa4IDFI8eRz5a47i5Oszus6zG/cwIXN63YhgLOMSSNJx49sENg==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-flow@7.27.1': resolution: {integrity: sha512-p9OkPbZ5G7UT1MofwYFigGebnrzGJacoBSQM0/6bi/PUMVE+qlWDD/OalvQKbwgQzU6dl0xAv6r4X7Jme0RYxA==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-import-attributes@7.27.1': + resolution: {integrity: sha512-oFT0FrKHgF53f4vOsZGi2Hh3I35PfSmVs4IBFLFj4dnafP+hIWDLg3VyKmUHfLoLHlyxY4C7DGtmHuJgn+IGww==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-import-meta@7.10.4': + resolution: {integrity: sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-json-strings@7.8.3': + resolution: {integrity: sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==} + peerDependencies: + '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-jsx@7.27.1': resolution: {integrity: sha512-y8YTNIeKoyhGd9O0Jiyzyyqk8gdjnumGTQPsz0xOZOQ2RmkVJeZ1vmmfIvFEKqucBG6axJGBZDE/7iI5suUI/w==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-logical-assignment-operators@7.10.4': + resolution: {integrity: sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-nullish-coalescing-operator@7.8.3': + resolution: {integrity: sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-numeric-separator@7.10.4': + resolution: {integrity: sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-object-rest-spread@7.8.3': + resolution: {integrity: sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-optional-catch-binding@7.8.3': + resolution: {integrity: sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-optional-chaining@7.8.3': + resolution: {integrity: sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-private-property-in-object@7.14.5': + resolution: {integrity: sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-syntax-top-level-await@7.14.5': + resolution: {integrity: sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-typescript@7.27.1': resolution: {integrity: sha512-xfYCBMxveHrRMnAWl1ZlPXOZjzkN82THFvLhQhFXFt81Z5HnN+EtUkZhv/zcKpmT3fzmWZB0ywiBrbC3vogbwQ==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-arrow-functions@7.27.1': + resolution: {integrity: sha512-8Z4TGic6xW70FKThA5HYEKKyBpOOsucTOD1DjU3fZxDg+K3zBJcXMFnt/4yQiZnf5+MiOMSXQ9PaEK/Ilh1DeA==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-transform-async-generator-functions@7.28.0': + resolution: {integrity: sha512-BEOdvX4+M765icNPZeidyADIvQ1m1gmunXufXxvRESy/jNNyfovIqUyE7MVgGBjWktCoJlzvFA1To2O4ymIO3Q==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-transform-async-to-generator@7.27.1': + resolution: {integrity: sha512-NREkZsZVJS4xmTr8qzE5y8AfIPqsdQfRuUiLRTEzb7Qii8iFWCyDKaUV2c0rCuh4ljDZ98ALHP/PetiBV2nddA==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-transform-block-scoping@7.28.0': + resolution: {integrity: sha512-gKKnwjpdx5sER/wl0WN0efUBFzF/56YZO0RJrSYP4CljXnP31ByY7fol89AzomdlLNzI36AvOTmYHsnZTCkq8Q==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-class-properties@7.27.1': resolution: {integrity: sha512-D0VcalChDMtuRvJIu3U/fwWjf8ZMykz5iZsg77Nuj821vCKI3zCyRLwRdWbsuJ/uRwZhZ002QtCqIkwC/ZkvbA==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-classes@7.28.3': + resolution: {integrity: sha512-DoEWC5SuxuARF2KdKmGUq3ghfPMO6ZzR12Dnp5gubwbeWJo4dbNWXJPVlwvh4Zlq6Z7YVvL8VFxeSOJgjsx4Sg==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-transform-computed-properties@7.27.1': + resolution: {integrity: sha512-lj9PGWvMTVksbWiDT2tW68zGS/cyo4AkZ/QTp0sQT0mjPopCmrSkzxeXkznjqBxzDI6TclZhOJbBmbBLjuOZUw==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-transform-destructuring@7.28.0': + resolution: {integrity: sha512-v1nrSMBiKcodhsyJ4Gf+Z0U/yawmJDBOTpEB3mcQY52r9RIyPneGyAS/yM6seP/8I+mWI3elOMtT5dB8GJVs+A==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-export-namespace-from@7.27.1': resolution: {integrity: sha512-tQvHWSZ3/jH2xuq/vZDy0jNn+ZdXJeM8gHvX4lnJmsc3+50yPlWdZXIc5ay+umX+2/tJIqHqiEqcJvxlmIvRvQ==} engines: {node: '>=6.9.0'} @@ -439,36 +853,156 @@ packages: peerDependencies: '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-for-of@7.27.1': + resolution: {integrity: sha512-BfbWFFEJFQzLCQ5N8VocnCtA8J1CLkNTe2Ms2wocj75dd6VpiqS5Z5quTYcUoo4Yq+DN0rtikODccuv7RU81sw==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-transform-function-name@7.27.1': + resolution: {integrity: sha512-1bQeydJF9Nr1eBCMMbC+hdwmRlsv5XYOMu03YSWFwNs0HsAmtSxxF1fyuYPqemVldVyFmlCU7w8UE14LupUSZQ==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-transform-literals@7.27.1': + resolution: {integrity: sha512-0HCFSepIpLTkLcsi86GG3mTUzxV5jpmbv97hTETW3yzrAij8aqlD36toB1D0daVFJM8NK6GvKO0gslVQmm+zZA==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-transform-logical-assignment-operators@7.27.1': + resolution: {integrity: sha512-SJvDs5dXxiae4FbSL1aBJlG4wvl594N6YEVVn9e3JGulwioy6z3oPjx/sQBO3Y4NwUu5HNix6KJ3wBZoewcdbw==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-modules-commonjs@7.27.1': resolution: {integrity: sha512-OJguuwlTYlN0gBZFRPqwOGNWssZjfIUdS7HMYtN8c1KmwpwHFBwTeFZrg9XZa+DFTitWOW5iTAG7tyCUPsCCyw==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-named-capturing-groups-regex@7.27.1': + resolution: {integrity: sha512-SstR5JYy8ddZvD6MhV0tM/j16Qds4mIpJTOd1Yu9J9pJjH93bxHECF7pgtc28XvkzTD6Pxcm/0Z73Hvk7kb3Ng==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0 + '@babel/plugin-transform-nullish-coalescing-operator@7.27.1': resolution: {integrity: sha512-aGZh6xMo6q9vq1JGcw58lZ1Z0+i0xB2x0XaauNIUXd6O1xXc3RwoWEBlsTQrY4KQ9Jf0s5rgD6SiNkaUdJegTA==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-numeric-separator@7.27.1': + resolution: {integrity: sha512-fdPKAcujuvEChxDBJ5c+0BTaS6revLV7CJL08e4m3de8qJfNIuCc2nc7XJYOjBoTMJeqSmwXJ0ypE14RCjLwaw==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-transform-object-rest-spread@7.28.0': + resolution: {integrity: sha512-9VNGikXxzu5eCiQjdE4IZn8sb9q7Xsk5EXLDBKUYg1e/Tve8/05+KJEtcxGxAgCY5t/BpKQM+JEL/yT4tvgiUA==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-transform-optional-catch-binding@7.27.1': + resolution: {integrity: sha512-txEAEKzYrHEX4xSZN4kJ+OfKXFVSWKB2ZxM9dpcE3wT7smwkNmXo5ORRlVzMVdJbD+Q8ILTgSD7959uj+3Dm3Q==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-optional-chaining@7.27.1': resolution: {integrity: sha512-BQmKPPIuc8EkZgNKsv0X4bPmOoayeu4F1YCwx2/CfmDSXDbp7GnzlUH+/ul5VGfRg1AoFPsrIThlEBj2xb4CAg==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-parameters@7.27.7': + resolution: {integrity: sha512-qBkYTYCb76RRxUM6CcZA5KRu8K4SM8ajzVeUgVdMVO9NN9uI/GaVmBg/WKJJGnNokV9SY8FxNOVWGXzqzUidBg==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-private-methods@7.27.1': resolution: {integrity: sha512-10FVt+X55AjRAYI9BrdISN9/AQWHqldOeZDUoLyif1Kn05a56xVBXb8ZouL8pZ9jem8QpXaOt8TS7RHUIS+GPA==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-private-property-in-object@7.27.1': + resolution: {integrity: sha512-5J+IhqTi1XPa0DXF83jYOaARrX+41gOewWbkPyjMNRDqgOCqdffGh8L3f/Ek5utaEBZExjSAzcyjmV9SSAWObQ==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-transform-react-display-name@7.28.0': + resolution: {integrity: sha512-D6Eujc2zMxKjfa4Zxl4GHMsmhKKZ9VpcqIchJLvwTxad9zWIYulwYItBovpDOoNLISpcZSXoDJ5gaGbQUDqViA==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-transform-react-jsx-self@7.27.1': + resolution: {integrity: sha512-6UzkCs+ejGdZ5mFFC/OCUrv028ab2fp1znZmCZjAOBKiBK2jXD1O+BPSfX8X2qjJ75fZBMSnQn3Rq2mrBJK2mw==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-transform-react-jsx-source@7.27.1': + resolution: {integrity: sha512-zbwoTsBruTeKB9hSq73ha66iFeJHuaFkUbwvqElnygoNbj/jHRsSeokowZFN3CZ64IvEqcmmkVe89OPXc7ldAw==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-transform-react-jsx@7.27.1': + resolution: {integrity: sha512-2KH4LWGSrJIkVf5tSiBFYuXDAoWRq2MMwgivCf+93dd0GQi8RXLjKA/0EvRnVV5G0hrHczsquXuD01L8s6dmBw==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-transform-regenerator@7.28.3': + resolution: {integrity: sha512-K3/M/a4+ESb5LEldjQb+XSrpY0nF+ZBFlTCbSnKaYAMfD8v33O6PMs4uYnOk19HlcsI8WMu3McdFPTiQHF/1/A==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-transform-runtime@7.28.3': + resolution: {integrity: sha512-Y6ab1kGqZ0u42Zv/4a7l0l72n9DKP/MKoKWaUSBylrhNZO2prYuqFOLbn5aW5SIFXwSH93yfjbgllL8lxuGKLg==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-transform-shorthand-properties@7.27.1': + resolution: {integrity: sha512-N/wH1vcn4oYawbJ13Y/FxcQrWk63jhfNa7jef0ih7PHSIHX2LB7GWE1rkPrOnka9kwMxb6hMl19p7lidA+EHmQ==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-transform-spread@7.27.1': + resolution: {integrity: sha512-kpb3HUqaILBJcRFVhFUs6Trdd4mkrzcGXss+6/mxUd273PfbWqSDHRzMT2234gIg2QYfAjvXLSquP1xECSg09Q==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/plugin-transform-sticky-regex@7.27.1': + resolution: {integrity: sha512-lhInBO5bi/Kowe2/aLdBAawijx+q1pQzicSgnkB6dUPc1+RC8QmJHKf2OjvU+NZWitguJHEaEmbV6VWEouT58g==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-typescript@7.28.0': resolution: {integrity: sha512-4AEiDEBPIZvLQaWlc9liCavE0xRM0dNca41WtBeM3jgFptfUOSG9z0uteLhq6+3rq+WB6jIvUwKDTpXEHPJ2Vg==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-unicode-regex@7.27.1': + resolution: {integrity: sha512-xvINq24TRojDuyt6JGtHmkVkrfVV3FPT16uytxImLeBZqW3/H52yN+kM1MGuyPkIQxrzKwPHs5U/MP3qKyzkGw==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + '@babel/preset-flow@7.27.1': resolution: {integrity: sha512-ez3a2it5Fn6P54W8QkbfIyyIbxlXvcxyWHHvno1Wg0Ej5eiJY5hBb8ExttoIOJJk7V2dZE6prP7iby5q2aQ0Lg==} engines: {node: '>=6.9.0'} @@ -481,51 +1015,54 @@ packages: peerDependencies: '@babel/core': ^7.0.0-0 - '@babel/register@7.27.1': - resolution: {integrity: sha512-K13lQpoV54LATKkzBpBAEu1GGSIRzxR9f4IN4V8DCDgiUMo2UDGagEZr3lPeVNJPLkWUi5JE4hCHKneVTwQlYQ==} + '@babel/register@7.28.3': + resolution: {integrity: sha512-CieDOtd8u208eI49bYl4z1J22ySFw87IGwE+IswFEExH7e3rLgKb0WNQeumnacQ1+VoDJLYI5QFA3AJZuyZQfA==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 - '@babel/runtime@7.27.6': - resolution: {integrity: sha512-vbavdySgbTTrmFE+EsiqUTzlOr5bzlnJtUv9PynGCAKvfQqjIXbvFdumPM/GxMDfyuGMJaJAU6TO4zc1Jf1i8Q==} + '@babel/runtime@7.28.3': + resolution: {integrity: sha512-9uIQ10o0WGdpP6GDhXcdOJPJuDgFtIDtN/9+ArJQ2NAfAmiuhTQdzkaTGR33v43GYS2UrSA0eX2pPPHoFVvpxA==} engines: {node: '>=6.9.0'} '@babel/template@7.27.2': resolution: {integrity: sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw==} engines: {node: '>=6.9.0'} - '@babel/traverse@7.28.0': - resolution: {integrity: sha512-mGe7UK5wWyh0bKRfupsUchrQGqvDbZDbKJw+kcRGSmdHVYrv+ltd0pnpDTVpiTqnaBru9iEvA8pz8W46v0Amwg==} + '@babel/traverse@7.28.3': + resolution: {integrity: sha512-7w4kZYHneL3A6NP2nxzHvT3HCZ7puDZZjFMqDpBPECub79sTtSO5CGXDkKrTQq8ksAwfD/XI2MRFX23njdDaIQ==} engines: {node: '>=6.9.0'} - '@babel/types@7.28.1': - resolution: {integrity: sha512-x0LvFTekgSX+83TI28Y9wYPUfzrnl2aT5+5QLnO6v7mSJYtEEevuDRN0F0uSHRk1G1IWZC43o00Y0xDDrpBGPQ==} + '@babel/types@7.28.2': + resolution: {integrity: sha512-ruv7Ae4J5dUYULmeXw1gmb7rYRz57OWCPM57pHojnLq/3Z1CK2lNSLTCVjxVk1F/TZHwOZZrOWi0ur95BbLxNQ==} engines: {node: '>=6.9.0'} + '@balena/dockerignore@1.0.2': + resolution: {integrity: sha512-wMue2Sy4GAVTk6Ic4tJVcnfdau+gx2EnG7S+uAEe+TWJFqE4YoWN4/H8MSLj4eYJKxGg26lZwboEniNiNwZQ6Q==} + '@bcoe/v8-coverage@1.0.2': resolution: {integrity: sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==} engines: {node: '>=18'} - '@bundle-stats/cli-utils@4.21.0': - resolution: {integrity: sha512-N0vMeNaaDxAh4SdXky4p1w8INlfj3XzJh2WZ7pMuLG8cQYQeYYwFTUrwVc1dblRzqRgxhs5xOnl7DQHGCcMc1w==} + '@bundle-stats/cli-utils@4.21.3': + resolution: {integrity: sha512-xyJDpT7mXfaUP/1YIBEkiFKetOOVo85Cq03H9CRMe91X0V11jyHy66sbfFreEKGJpQTTtaCIQmIkGpDSXRg8/A==} engines: {node: '>= 14.0'} - '@bundle-stats/html-templates@4.21.0': - resolution: {integrity: sha512-DZuJbkU3QOGVxfYGa8iKf0Jz8PNcJd1O/Rqdsv83nhvPNJlYbCYS8/hf33WAkJduVYAAQxGtAHcNskpycCg3vg==} + '@bundle-stats/html-templates@4.21.3': + resolution: {integrity: sha512-M7HJ3W6o5Bb+dze+Fghv70WWHhypKKwAfJENZICl2Opmq8qsQ9L91DdvfnrGBJe9wS2fQwIUCRE2J3InU5BoFg==} - '@bundle-stats/plugin-webpack-filter@4.21.0': - resolution: {integrity: sha512-ag0olZlQy7muYvLEcfc5T8ZsbMnTHKE92scp5lyC34qu+ZfJ8akeOPrAG/IaiCSdJb18m+NF70TbXbowT04WFg==} + '@bundle-stats/plugin-webpack-filter@4.21.3': + resolution: {integrity: sha512-eTpk5y3uSmqSw+c7C62hsSfDUSCes/XfBTzk5jRH1KujtDjlXu5QDTzzM72CbuuoQD1MOqoZ4Gn16t/zcNnicw==} engines: {node: '>= 14.0'} peerDependencies: core-js: ^3.0.0 - '@bundle-stats/plugin-webpack-validate@4.21.0': - resolution: {integrity: sha512-Xj6IctKCDLuo3dSZpn2d4m1u6A1oJK8pqIVvIYfcNSNx3KgRTYd3gRhWcHlhh2pODugtJt5GasMqSCK2STkltA==} + '@bundle-stats/plugin-webpack-validate@4.21.3': + resolution: {integrity: sha512-yIn0KEAvyHtGF36CrlfXMmcdy8JhEsstNLeswpFKO/sLJI9fz9zC37GtbFDcNHLyFv9t1CqzzYnJjYPYxG7uEw==} engines: {node: '>= 14.0'} - '@bundle-stats/utils@4.21.0': - resolution: {integrity: sha512-nHDgVgQHNlUBgWr5ReAEbQx+EKAZtmrlvEOcZvrzbT0PEUNovPxeW+TqU/15No+i+CJTSqENLLXMQ5x+lWG2FQ==} + '@bundle-stats/utils@4.21.3': + resolution: {integrity: sha512-o8F/Jbeai2WDWeypluuP0s2uL6AuZROUerTeB+W0sp0bOxbRc3OkkkQEckRHuQmI7OQ5c5JElrs5Ia/NuOs6+g==} engines: {node: '>= 14.0'} peerDependencies: core-js: ^3.0.0 @@ -543,8 +1080,8 @@ packages: '@changesets/changelog-github@0.5.1': resolution: {integrity: sha512-BVuHtF+hrhUScSoHnJwTELB4/INQxVFc+P/Qdt20BLiBFIHFJDDUaGsZw+8fQeJTRP5hJZrzpt3oZWh0G19rAQ==} - '@changesets/cli@2.29.5': - resolution: {integrity: sha512-0j0cPq3fgxt2dPdFsg4XvO+6L66RC0pZybT9F4dG5TBrLA3jA/1pNkdTXH9IBBVHkgsKrNKenI3n1mPyPlIydg==} + '@changesets/cli@2.29.6': + resolution: {integrity: sha512-6qCcVsIG1KQLhpQ5zE8N0PckIx4+9QlHK3z6/lwKnw7Tir71Bjw8BeOZaxA/4Jt00pcgCnCSWZnyuZf5Il05QQ==} hasBin: true '@changesets/config@3.1.1': @@ -592,6 +1129,50 @@ packages: '@changesets/write@0.4.0': resolution: {integrity: sha512-CdTLvIOPiCNuH71pyDu3rA+Q0n65cmAbXnwWH84rKGiFumFzkmHNT8KHTMEchcxN+Kl8I54xGUhJ7l3E7X396Q==} + '@clickhouse/client-common@1.12.1': + resolution: {integrity: sha512-ccw1N6hB4+MyaAHIaWBwGZ6O2GgMlO99FlMj0B0UEGfjxM9v5dYVYql6FpP19rMwrVAroYs/IgX2vyZEBvzQLg==} + + '@clickhouse/client@1.12.1': + resolution: {integrity: sha512-7ORY85rphRazqHzImNXMrh4vsaPrpetFoTWpZYueCO2bbO6PXYDXp/GQ4DgxnGIqbWB/Di1Ai+Xuwq2o7DJ36A==} + engines: {node: '>=16'} + + '@cloudflare/workerd-darwin-64@1.20250823.0': + resolution: {integrity: sha512-yRLJc1cQNqQYcDViOk7kpTXnR5XuBP7B/Ms5KBdlQ6eTr2Vsg9mfKqWKInjzY8/Cx+p+Sic2Tbld42gcYkiM2A==} + engines: {node: '>=16'} + cpu: [x64] + os: [darwin] + + '@cloudflare/workerd-darwin-arm64@1.20250823.0': + resolution: {integrity: sha512-KJnikUe6J29Ga1QMPKNCc8eHD56DdBlu5XE5LoBH/AYRrbS5UI1d5F844hUWoFKJb8KRaPIH9F849HZWfNa1vw==} + engines: {node: '>=16'} + cpu: [arm64] + os: [darwin] + + '@cloudflare/workerd-linux-64@1.20250823.0': + resolution: {integrity: sha512-4QFXq4eDWEAK5QjGxRe0XUTBax1Fgarc08HETL6q0y/KPZp2nOTLfjLjklTn/qEiztafNFoJEIwhkiknHeOi/g==} + engines: {node: '>=16'} + cpu: [x64] + os: [linux] + + '@cloudflare/workerd-linux-arm64@1.20250823.0': + resolution: {integrity: sha512-sODSrSVe4W/maoBu76qb0sJGBhxhSM2Q2tg/+G7q1IPgRZSzArMKIPrW6nBnmBrrG1O0X6aoAdID6w5hfuEM4g==} + engines: {node: '>=16'} + cpu: [arm64] + os: [linux] + + '@cloudflare/workerd-windows-64@1.20250823.0': + resolution: {integrity: sha512-WaNqUOXUnrcEI+i2NI4+okA9CrJMI9n2XTfVtDg/pLvcA/ZPTz23MEFMZU1splr4SslS1th1NBO38RMPnDB4rA==} + engines: {node: '>=16'} + cpu: [x64] + os: [win32] + + '@cloudflare/workers-types@4.20250826.0': + resolution: {integrity: sha512-nAbTVI81wFSxbESRbfGRlfL4WYNvq8T46yr1ukypHL8O2xnbZfQnQhC7ftSBmDqov8HqQSdqcz9jCgLjVh61SQ==} + + '@cspotcode/source-map-support@0.8.1': + resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} + engines: {node: '>=12'} + '@dependents/detective-less@4.1.0': resolution: {integrity: sha512-KrkT6qO5NxqNfy68sBl6CTSoJ4SNDIS5iQArkibhlbGU4LaDukZ3q2HIkh8aUKDio6o4itU4xDR7t82Y2eP1Bg==} engines: {node: '>=14'} @@ -627,8 +1208,8 @@ packages: '@effect/eslint-plugin@0.3.2': resolution: {integrity: sha512-c4Vs9t3r54A4Zpl+wo8+PGzZz3JWYsip41H+UrebRLjQ2Hk/ap63IeCgN/HWcYtxtyhRopjp7gW9nOQ2Snbl+g==} - '@effect/language-service@0.28.3': - resolution: {integrity: sha512-C7feKBiRkvH7zy9mO67P1lRkdI/brXdv9FF0Jc0JYz7q/Sytgz2c1aqelid9fodh0ee+PTO5bd3OaCpIDu/7qA==} + '@effect/language-service@0.36.0': + resolution: {integrity: sha512-KoE5e+7vhcd29fBTDBvttWHv1z1KPg9Ji2DyhD0hETBaoM9IsFymboD6WqpDoGH1QZRr6CmTD3DfaZUs8K6Mrg==} hasBin: true '@effect/markdown-toc@0.1.0': @@ -636,6 +1217,9 @@ packages: engines: {node: '>=0.10.0'} hasBin: true + '@effect/wa-sqlite@0.2.1': + resolution: {integrity: sha512-vMnGIHKWSIFnDf7+n7lP2vyXPzORJotkaRI8LKyJw3eNjsvFopHYVaaGSeMSSVTm/w45pC5T4JdLrD6nxSR4oQ==} + '@emnapi/core@1.4.5': resolution: {integrity: sha512-XsLw1dEOpkSX/WucdqUhPWP7hDxSvZiY+fsUC14h+FtQ2Ifni4znbBt8punRX+Uj2JG/uDb8nEHVKvrVlvdZ5Q==} @@ -645,158 +1229,158 @@ packages: '@emnapi/wasi-threads@1.0.4': resolution: {integrity: sha512-PJR+bOmMOPH8AtcTGAyYNiuJ3/Fcoj2XN/gBEWzDIKh254XO+mM9XoXHk5GNEhodxeMznbg7BlRojVbKN+gC6g==} - '@esbuild/aix-ppc64@0.25.8': - resolution: {integrity: sha512-urAvrUedIqEiFR3FYSLTWQgLu5tb+m0qZw0NBEasUeo6wuqatkMDaRT+1uABiGXEu5vqgPd7FGE1BhsAIy9QVA==} + '@esbuild/aix-ppc64@0.25.9': + resolution: {integrity: sha512-OaGtL73Jck6pBKjNIe24BnFE6agGl+6KxDtTfHhy1HmhthfKouEcOhqpSL64K4/0WCtbKFLOdzD/44cJ4k9opA==} engines: {node: '>=18'} cpu: [ppc64] os: [aix] - '@esbuild/android-arm64@0.25.8': - resolution: {integrity: sha512-OD3p7LYzWpLhZEyATcTSJ67qB5D+20vbtr6vHlHWSQYhKtzUYrETuWThmzFpZtFsBIxRvhO07+UgVA9m0i/O1w==} + '@esbuild/android-arm64@0.25.9': + resolution: {integrity: sha512-IDrddSmpSv51ftWslJMvl3Q2ZT98fUSL2/rlUXuVqRXHCs5EUF1/f+jbjF5+NG9UffUDMCiTyh8iec7u8RlTLg==} engines: {node: '>=18'} cpu: [arm64] os: [android] - '@esbuild/android-arm@0.25.8': - resolution: {integrity: sha512-RONsAvGCz5oWyePVnLdZY/HHwA++nxYWIX1atInlaW6SEkwq6XkP3+cb825EUcRs5Vss/lGh/2YxAb5xqc07Uw==} + '@esbuild/android-arm@0.25.9': + resolution: {integrity: sha512-5WNI1DaMtxQ7t7B6xa572XMXpHAaI/9Hnhk8lcxF4zVN4xstUgTlvuGDorBguKEnZO70qwEcLpfifMLoxiPqHQ==} engines: {node: '>=18'} cpu: [arm] os: [android] - '@esbuild/android-x64@0.25.8': - resolution: {integrity: sha512-yJAVPklM5+4+9dTeKwHOaA+LQkmrKFX96BM0A/2zQrbS6ENCmxc4OVoBs5dPkCCak2roAD+jKCdnmOqKszPkjA==} + '@esbuild/android-x64@0.25.9': + resolution: {integrity: sha512-I853iMZ1hWZdNllhVZKm34f4wErd4lMyeV7BLzEExGEIZYsOzqDWDf+y082izYUE8gtJnYHdeDpN/6tUdwvfiw==} engines: {node: '>=18'} cpu: [x64] os: [android] - '@esbuild/darwin-arm64@0.25.8': - resolution: {integrity: sha512-Jw0mxgIaYX6R8ODrdkLLPwBqHTtYHJSmzzd+QeytSugzQ0Vg4c5rDky5VgkoowbZQahCbsv1rT1KW72MPIkevw==} + '@esbuild/darwin-arm64@0.25.9': + resolution: {integrity: sha512-XIpIDMAjOELi/9PB30vEbVMs3GV1v2zkkPnuyRRURbhqjyzIINwj+nbQATh4H9GxUgH1kFsEyQMxwiLFKUS6Rg==} engines: {node: '>=18'} cpu: [arm64] os: [darwin] - '@esbuild/darwin-x64@0.25.8': - resolution: {integrity: sha512-Vh2gLxxHnuoQ+GjPNvDSDRpoBCUzY4Pu0kBqMBDlK4fuWbKgGtmDIeEC081xi26PPjn+1tct+Bh8FjyLlw1Zlg==} + '@esbuild/darwin-x64@0.25.9': + resolution: {integrity: sha512-jhHfBzjYTA1IQu8VyrjCX4ApJDnH+ez+IYVEoJHeqJm9VhG9Dh2BYaJritkYK3vMaXrf7Ogr/0MQ8/MeIefsPQ==} engines: {node: '>=18'} cpu: [x64] os: [darwin] - '@esbuild/freebsd-arm64@0.25.8': - resolution: {integrity: sha512-YPJ7hDQ9DnNe5vxOm6jaie9QsTwcKedPvizTVlqWG9GBSq+BuyWEDazlGaDTC5NGU4QJd666V0yqCBL2oWKPfA==} + '@esbuild/freebsd-arm64@0.25.9': + resolution: {integrity: sha512-z93DmbnY6fX9+KdD4Ue/H6sYs+bhFQJNCPZsi4XWJoYblUqT06MQUdBCpcSfuiN72AbqeBFu5LVQTjfXDE2A6Q==} engines: {node: '>=18'} cpu: [arm64] os: [freebsd] - '@esbuild/freebsd-x64@0.25.8': - resolution: {integrity: sha512-MmaEXxQRdXNFsRN/KcIimLnSJrk2r5H8v+WVafRWz5xdSVmWLoITZQXcgehI2ZE6gioE6HirAEToM/RvFBeuhw==} + '@esbuild/freebsd-x64@0.25.9': + resolution: {integrity: sha512-mrKX6H/vOyo5v71YfXWJxLVxgy1kyt1MQaD8wZJgJfG4gq4DpQGpgTB74e5yBeQdyMTbgxp0YtNj7NuHN0PoZg==} engines: {node: '>=18'} cpu: [x64] os: [freebsd] - '@esbuild/linux-arm64@0.25.8': - resolution: {integrity: sha512-WIgg00ARWv/uYLU7lsuDK00d/hHSfES5BzdWAdAig1ioV5kaFNrtK8EqGcUBJhYqotlUByUKz5Qo6u8tt7iD/w==} + '@esbuild/linux-arm64@0.25.9': + resolution: {integrity: sha512-BlB7bIcLT3G26urh5Dmse7fiLmLXnRlopw4s8DalgZ8ef79Jj4aUcYbk90g8iCa2467HX8SAIidbL7gsqXHdRw==} engines: {node: '>=18'} cpu: [arm64] os: [linux] - '@esbuild/linux-arm@0.25.8': - resolution: {integrity: sha512-FuzEP9BixzZohl1kLf76KEVOsxtIBFwCaLupVuk4eFVnOZfU+Wsn+x5Ryam7nILV2pkq2TqQM9EZPsOBuMC+kg==} + '@esbuild/linux-arm@0.25.9': + resolution: {integrity: sha512-HBU2Xv78SMgaydBmdor38lg8YDnFKSARg1Q6AT0/y2ezUAKiZvc211RDFHlEZRFNRVhcMamiToo7bDx3VEOYQw==} engines: {node: '>=18'} cpu: [arm] os: [linux] - '@esbuild/linux-ia32@0.25.8': - resolution: {integrity: sha512-A1D9YzRX1i+1AJZuFFUMP1E9fMaYY+GnSQil9Tlw05utlE86EKTUA7RjwHDkEitmLYiFsRd9HwKBPEftNdBfjg==} + '@esbuild/linux-ia32@0.25.9': + resolution: {integrity: sha512-e7S3MOJPZGp2QW6AK6+Ly81rC7oOSerQ+P8L0ta4FhVi+/j/v2yZzx5CqqDaWjtPFfYz21Vi1S0auHrap3Ma3A==} engines: {node: '>=18'} cpu: [ia32] os: [linux] - '@esbuild/linux-loong64@0.25.8': - resolution: {integrity: sha512-O7k1J/dwHkY1RMVvglFHl1HzutGEFFZ3kNiDMSOyUrB7WcoHGf96Sh+64nTRT26l3GMbCW01Ekh/ThKM5iI7hQ==} + '@esbuild/linux-loong64@0.25.9': + resolution: {integrity: sha512-Sbe10Bnn0oUAB2AalYztvGcK+o6YFFA/9829PhOCUS9vkJElXGdphz0A3DbMdP8gmKkqPmPcMJmJOrI3VYB1JQ==} engines: {node: '>=18'} cpu: [loong64] os: [linux] - '@esbuild/linux-mips64el@0.25.8': - resolution: {integrity: sha512-uv+dqfRazte3BzfMp8PAQXmdGHQt2oC/y2ovwpTteqrMx2lwaksiFZ/bdkXJC19ttTvNXBuWH53zy/aTj1FgGw==} + '@esbuild/linux-mips64el@0.25.9': + resolution: {integrity: sha512-YcM5br0mVyZw2jcQeLIkhWtKPeVfAerES5PvOzaDxVtIyZ2NUBZKNLjC5z3/fUlDgT6w89VsxP2qzNipOaaDyA==} engines: {node: '>=18'} cpu: [mips64el] os: [linux] - '@esbuild/linux-ppc64@0.25.8': - resolution: {integrity: sha512-GyG0KcMi1GBavP5JgAkkstMGyMholMDybAf8wF5A70CALlDM2p/f7YFE7H92eDeH/VBtFJA5MT4nRPDGg4JuzQ==} + '@esbuild/linux-ppc64@0.25.9': + resolution: {integrity: sha512-++0HQvasdo20JytyDpFvQtNrEsAgNG2CY1CLMwGXfFTKGBGQT3bOeLSYE2l1fYdvML5KUuwn9Z8L1EWe2tzs1w==} engines: {node: '>=18'} cpu: [ppc64] os: [linux] - '@esbuild/linux-riscv64@0.25.8': - resolution: {integrity: sha512-rAqDYFv3yzMrq7GIcen3XP7TUEG/4LK86LUPMIz6RT8A6pRIDn0sDcvjudVZBiiTcZCY9y2SgYX2lgK3AF+1eg==} + '@esbuild/linux-riscv64@0.25.9': + resolution: {integrity: sha512-uNIBa279Y3fkjV+2cUjx36xkx7eSjb8IvnL01eXUKXez/CBHNRw5ekCGMPM0BcmqBxBcdgUWuUXmVWwm4CH9kg==} engines: {node: '>=18'} cpu: [riscv64] os: [linux] - '@esbuild/linux-s390x@0.25.8': - resolution: {integrity: sha512-Xutvh6VjlbcHpsIIbwY8GVRbwoviWT19tFhgdA7DlenLGC/mbc3lBoVb7jxj9Z+eyGqvcnSyIltYUrkKzWqSvg==} + '@esbuild/linux-s390x@0.25.9': + resolution: {integrity: sha512-Mfiphvp3MjC/lctb+7D287Xw1DGzqJPb/J2aHHcHxflUo+8tmN/6d4k6I2yFR7BVo5/g7x2Monq4+Yew0EHRIA==} engines: {node: '>=18'} cpu: [s390x] os: [linux] - '@esbuild/linux-x64@0.25.8': - resolution: {integrity: sha512-ASFQhgY4ElXh3nDcOMTkQero4b1lgubskNlhIfJrsH5OKZXDpUAKBlNS0Kx81jwOBp+HCeZqmoJuihTv57/jvQ==} + '@esbuild/linux-x64@0.25.9': + resolution: {integrity: sha512-iSwByxzRe48YVkmpbgoxVzn76BXjlYFXC7NvLYq+b+kDjyyk30J0JY47DIn8z1MO3K0oSl9fZoRmZPQI4Hklzg==} engines: {node: '>=18'} cpu: [x64] os: [linux] - '@esbuild/netbsd-arm64@0.25.8': - resolution: {integrity: sha512-d1KfruIeohqAi6SA+gENMuObDbEjn22olAR7egqnkCD9DGBG0wsEARotkLgXDu6c4ncgWTZJtN5vcgxzWRMzcw==} + '@esbuild/netbsd-arm64@0.25.9': + resolution: {integrity: sha512-9jNJl6FqaUG+COdQMjSCGW4QiMHH88xWbvZ+kRVblZsWrkXlABuGdFJ1E9L7HK+T0Yqd4akKNa/lO0+jDxQD4Q==} engines: {node: '>=18'} cpu: [arm64] os: [netbsd] - '@esbuild/netbsd-x64@0.25.8': - resolution: {integrity: sha512-nVDCkrvx2ua+XQNyfrujIG38+YGyuy2Ru9kKVNyh5jAys6n+l44tTtToqHjino2My8VAY6Lw9H7RI73XFi66Cg==} + '@esbuild/netbsd-x64@0.25.9': + resolution: {integrity: sha512-RLLdkflmqRG8KanPGOU7Rpg829ZHu8nFy5Pqdi9U01VYtG9Y0zOG6Vr2z4/S+/3zIyOxiK6cCeYNWOFR9QP87g==} engines: {node: '>=18'} cpu: [x64] os: [netbsd] - '@esbuild/openbsd-arm64@0.25.8': - resolution: {integrity: sha512-j8HgrDuSJFAujkivSMSfPQSAa5Fxbvk4rgNAS5i3K+r8s1X0p1uOO2Hl2xNsGFppOeHOLAVgYwDVlmxhq5h+SQ==} + '@esbuild/openbsd-arm64@0.25.9': + resolution: {integrity: sha512-YaFBlPGeDasft5IIM+CQAhJAqS3St3nJzDEgsgFixcfZeyGPCd6eJBWzke5piZuZ7CtL656eOSYKk4Ls2C0FRQ==} engines: {node: '>=18'} cpu: [arm64] os: [openbsd] - '@esbuild/openbsd-x64@0.25.8': - resolution: {integrity: sha512-1h8MUAwa0VhNCDp6Af0HToI2TJFAn1uqT9Al6DJVzdIBAd21m/G0Yfc77KDM3uF3T/YaOgQq3qTJHPbTOInaIQ==} + '@esbuild/openbsd-x64@0.25.9': + resolution: {integrity: sha512-1MkgTCuvMGWuqVtAvkpkXFmtL8XhWy+j4jaSO2wxfJtilVCi0ZE37b8uOdMItIHz4I6z1bWWtEX4CJwcKYLcuA==} engines: {node: '>=18'} cpu: [x64] os: [openbsd] - '@esbuild/openharmony-arm64@0.25.8': - resolution: {integrity: sha512-r2nVa5SIK9tSWd0kJd9HCffnDHKchTGikb//9c7HX+r+wHYCpQrSgxhlY6KWV1nFo1l4KFbsMlHk+L6fekLsUg==} + '@esbuild/openharmony-arm64@0.25.9': + resolution: {integrity: sha512-4Xd0xNiMVXKh6Fa7HEJQbrpP3m3DDn43jKxMjxLLRjWnRsfxjORYJlXPO4JNcXtOyfajXorRKY9NkOpTHptErg==} engines: {node: '>=18'} cpu: [arm64] os: [openharmony] - '@esbuild/sunos-x64@0.25.8': - resolution: {integrity: sha512-zUlaP2S12YhQ2UzUfcCuMDHQFJyKABkAjvO5YSndMiIkMimPmxA+BYSBikWgsRpvyxuRnow4nS5NPnf9fpv41w==} + '@esbuild/sunos-x64@0.25.9': + resolution: {integrity: sha512-WjH4s6hzo00nNezhp3wFIAfmGZ8U7KtrJNlFMRKxiI9mxEK1scOMAaa9i4crUtu+tBr+0IN6JCuAcSBJZfnphw==} engines: {node: '>=18'} cpu: [x64] os: [sunos] - '@esbuild/win32-arm64@0.25.8': - resolution: {integrity: sha512-YEGFFWESlPva8hGL+zvj2z/SaK+pH0SwOM0Nc/d+rVnW7GSTFlLBGzZkuSU9kFIGIo8q9X3ucpZhu8PDN5A2sQ==} + '@esbuild/win32-arm64@0.25.9': + resolution: {integrity: sha512-mGFrVJHmZiRqmP8xFOc6b84/7xa5y5YvR1x8djzXpJBSv/UsNK6aqec+6JDjConTgvvQefdGhFDAs2DLAds6gQ==} engines: {node: '>=18'} cpu: [arm64] os: [win32] - '@esbuild/win32-ia32@0.25.8': - resolution: {integrity: sha512-hiGgGC6KZ5LZz58OL/+qVVoZiuZlUYlYHNAmczOm7bs2oE1XriPFi5ZHHrS8ACpV5EjySrnoCKmcbQMN+ojnHg==} + '@esbuild/win32-ia32@0.25.9': + resolution: {integrity: sha512-b33gLVU2k11nVx1OhX3C8QQP6UHQK4ZtN56oFWvVXvz2VkDoe6fbG8TOgHFxEvqeqohmRnIHe5A1+HADk4OQww==} engines: {node: '>=18'} cpu: [ia32] os: [win32] - '@esbuild/win32-x64@0.25.8': - resolution: {integrity: sha512-cn3Yr7+OaaZq1c+2pe+8yxC8E144SReCQjN6/2ynubzYjvyqZjTXfQJpAcQpsdJq3My7XADANiYGHoFC69pLQw==} + '@esbuild/win32-x64@0.25.9': + resolution: {integrity: sha512-PPOl1mi6lpLNQxnGoyAfschAodRFYXJ+9fs6WHXz7CSWKbOqiMZsubC+BQsVKuul+3vKLuwTHsS2c2y9EoKwxQ==} engines: {node: '>=18'} cpu: [x64] os: [win32] @@ -815,30 +1399,39 @@ packages: resolution: {integrity: sha512-ENIdc4iLu0d93HeYirvKmrzshzofPw6VkZRKQGe9Nv46ZnWUzcF1xV01dcvEg/1wXUR61OmmlSfyeyO7EvjLxQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@eslint/config-helpers@0.3.0': - resolution: {integrity: sha512-ViuymvFmcJi04qdZeDc2whTHryouGcDlaxPqarTD0ZE10ISpxGUVZGZDx4w01upyIynL3iu6IXH2bS1NhclQMw==} + '@eslint/config-helpers@0.3.1': + resolution: {integrity: sha512-xR93k9WhrDYpXHORXpxVL5oHj3Era7wo6k/Wd8/IsQNnZUTzkGS29lyn3nAT05v6ltUuTFVCCYDEGfy2Or/sPA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@eslint/core@0.15.1': - resolution: {integrity: sha512-bkOp+iumZCCbt1K1CmWf0R9pM5yKpDv+ZXtvSyQpudrI9kuFLp+bM2WOPXImuD/ceQuaa8f5pj93Y7zyECIGNA==} + '@eslint/core@0.15.2': + resolution: {integrity: sha512-78Md3/Rrxh83gCxoUc0EiciuOHsIITzLy53m3d9UyiW8y9Dj2D29FeETqyKA+BRK76tnTp6RXWb3pCay8Oyomg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@eslint/eslintrc@3.3.1': resolution: {integrity: sha512-gtF186CXhIl1p4pJNGZw8Yc6RlshoePRvE0X91oPGb3vZ8pM3qOS9W9NGPat9LziaBV7XrJWGylNQXkGcnM3IQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@eslint/js@9.31.0': - resolution: {integrity: sha512-LOm5OVt7D4qiKCqoiPbA7LWmI+tbw1VbTUowBcUMgQSuM6poJufkFkYDcQpo5KfgD39TnNySV26QjOh7VFpSyw==} + '@eslint/js@9.34.0': + resolution: {integrity: sha512-EoyvqQnBNsV1CWaEJ559rxXL4c8V92gxirbawSmVUOWXlsRxxQXl6LmCpdUblgxgSkDIqKnhzba2SjRTI/A5Rw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@eslint/object-schema@2.1.6': resolution: {integrity: sha512-RBMg5FRL0I0gs51M/guSAj5/e14VQ4tpZnQNWwuDT66P14I43ItmPfIZRhO9fUVIPOAQXU47atlywZ/czoqFPA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@eslint/plugin-kit@0.3.4': - resolution: {integrity: sha512-Ul5l+lHEcw3L5+k8POx6r74mxEYKG5kOb6Xpy2gCRW6zweT6TEhAf8vhxGgjhqrd/VO/Dirhsb+1hNpD1ue9hw==} + '@eslint/plugin-kit@0.3.5': + resolution: {integrity: sha512-Z5kJ+wU3oA7MMIqVR9tyZRtjYPr4OC004Q4Rw7pgOKUOKkJfZ3O24nz3WYfGRpMDNmcOi3TwQOmgm7B7Tpii0w==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@grpc/grpc-js@1.13.4': + resolution: {integrity: sha512-GsFaMXCkMqkKIvwCQjCrwH+GHbPKBjhwo/8ZuUkWHqbI73Kky9I+pQltrlT0+MWpedCoosda53lgjYfyEPgxBg==} + engines: {node: '>=12.10.0'} + + '@grpc/proto-loader@0.7.15': + resolution: {integrity: sha512-tMXdRCfYVixjuFK+Hk0Q1s38gV9zDiDJfWL3h1rv4Qc39oILCu1TRTDt7+fGUI8K4G1Fj125Hx/ru3azECWTyQ==} + engines: {node: '>=6'} + hasBin: true + '@humanfs/core@0.19.1': resolution: {integrity: sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==} engines: {node: '>=18.18.0'} @@ -859,6 +1452,120 @@ packages: resolution: {integrity: sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==} engines: {node: '>=18.18'} + '@img/sharp-darwin-arm64@0.33.5': + resolution: {integrity: sha512-UT4p+iz/2H4twwAoLCqfA9UH5pI6DggwKEGuaPy7nCVQ8ZsiY5PIcrRvD1DzuY3qYL07NtIQcWnBSY/heikIFQ==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [arm64] + os: [darwin] + + '@img/sharp-darwin-x64@0.33.5': + resolution: {integrity: sha512-fyHac4jIc1ANYGRDxtiqelIbdWkIuQaI84Mv45KvGRRxSAa7o7d1ZKAOBaYbnepLC1WqxfpimdeWfvqqSGwR2Q==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [x64] + os: [darwin] + + '@img/sharp-libvips-darwin-arm64@1.0.4': + resolution: {integrity: sha512-XblONe153h0O2zuFfTAbQYAX2JhYmDHeWikp1LM9Hul9gVPjFY427k6dFEcOL72O01QxQsWi761svJ/ev9xEDg==} + cpu: [arm64] + os: [darwin] + + '@img/sharp-libvips-darwin-x64@1.0.4': + resolution: {integrity: sha512-xnGR8YuZYfJGmWPvmlunFaWJsb9T/AO2ykoP3Fz/0X5XV2aoYBPkX6xqCQvUTKKiLddarLaxpzNe+b1hjeWHAQ==} + cpu: [x64] + os: [darwin] + + '@img/sharp-libvips-linux-arm64@1.0.4': + resolution: {integrity: sha512-9B+taZ8DlyyqzZQnoeIvDVR/2F4EbMepXMc/NdVbkzsJbzkUjhXv/70GQJ7tdLA4YJgNP25zukcxpX2/SueNrA==} + cpu: [arm64] + os: [linux] + + '@img/sharp-libvips-linux-arm@1.0.5': + resolution: {integrity: sha512-gvcC4ACAOPRNATg/ov8/MnbxFDJqf/pDePbBnuBDcjsI8PssmjoKMAz4LtLaVi+OnSb5FK/yIOamqDwGmXW32g==} + cpu: [arm] + os: [linux] + + '@img/sharp-libvips-linux-s390x@1.0.4': + resolution: {integrity: sha512-u7Wz6ntiSSgGSGcjZ55im6uvTrOxSIS8/dgoVMoiGE9I6JAfU50yH5BoDlYA1tcuGS7g/QNtetJnxA6QEsCVTA==} + cpu: [s390x] + os: [linux] + + '@img/sharp-libvips-linux-x64@1.0.4': + resolution: {integrity: sha512-MmWmQ3iPFZr0Iev+BAgVMb3ZyC4KeFc3jFxnNbEPas60e1cIfevbtuyf9nDGIzOaW9PdnDciJm+wFFaTlj5xYw==} + cpu: [x64] + os: [linux] + + '@img/sharp-libvips-linuxmusl-arm64@1.0.4': + resolution: {integrity: sha512-9Ti+BbTYDcsbp4wfYib8Ctm1ilkugkA/uscUn6UXK1ldpC1JjiXbLfFZtRlBhjPZ5o1NCLiDbg8fhUPKStHoTA==} + cpu: [arm64] + os: [linux] + + '@img/sharp-libvips-linuxmusl-x64@1.0.4': + resolution: {integrity: sha512-viYN1KX9m+/hGkJtvYYp+CCLgnJXwiQB39damAO7WMdKWlIhmYTfHjwSbQeUK/20vY154mwezd9HflVFM1wVSw==} + cpu: [x64] + os: [linux] + + '@img/sharp-linux-arm64@0.33.5': + resolution: {integrity: sha512-JMVv+AMRyGOHtO1RFBiJy/MBsgz0x4AWrT6QoEVVTyh1E39TrCUpTRI7mx9VksGX4awWASxqCYLCV4wBZHAYxA==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [arm64] + os: [linux] + + '@img/sharp-linux-arm@0.33.5': + resolution: {integrity: sha512-JTS1eldqZbJxjvKaAkxhZmBqPRGmxgu+qFKSInv8moZ2AmT5Yib3EQ1c6gp493HvrvV8QgdOXdyaIBrhvFhBMQ==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [arm] + os: [linux] + + '@img/sharp-linux-s390x@0.33.5': + resolution: {integrity: sha512-y/5PCd+mP4CA/sPDKl2961b+C9d+vPAveS33s6Z3zfASk2j5upL6fXVPZi7ztePZ5CuH+1kW8JtvxgbuXHRa4Q==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [s390x] + os: [linux] + + '@img/sharp-linux-x64@0.33.5': + resolution: {integrity: sha512-opC+Ok5pRNAzuvq1AG0ar+1owsu842/Ab+4qvU879ippJBHvyY5n2mxF1izXqkPYlGuP/M556uh53jRLJmzTWA==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [x64] + os: [linux] + + '@img/sharp-linuxmusl-arm64@0.33.5': + resolution: {integrity: sha512-XrHMZwGQGvJg2V/oRSUfSAfjfPxO+4DkiRh6p2AFjLQztWUuY/o8Mq0eMQVIY7HJ1CDQUJlxGGZRw1a5bqmd1g==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [arm64] + os: [linux] + + '@img/sharp-linuxmusl-x64@0.33.5': + resolution: {integrity: sha512-WT+d/cgqKkkKySYmqoZ8y3pxx7lx9vVejxW/W4DOFMYVSkErR+w7mf2u8m/y4+xHe7yY9DAXQMWQhpnMuFfScw==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [x64] + os: [linux] + + '@img/sharp-wasm32@0.33.5': + resolution: {integrity: sha512-ykUW4LVGaMcU9lu9thv85CbRMAwfeadCJHRsg2GmeRa/cJxsVY9Rbd57JcMxBkKHag5U/x7TSBpScF4U8ElVzg==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [wasm32] + + '@img/sharp-win32-ia32@0.33.5': + resolution: {integrity: sha512-T36PblLaTwuVJ/zw/LaH0PdZkRz5rd3SmMHX8GSmR7vtNSP5Z6bQkExdSK7xGWyxLw4sUknBuugTelgw2faBbQ==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [ia32] + os: [win32] + + '@img/sharp-win32-x64@0.33.5': + resolution: {integrity: sha512-MpY/o8/8kj+EcnxwvrP4aTJSWw/aZ7JIGR4aBeZkZw5B7/Jn+tY9/VNwtcoGmdT7GfggGIU4kygOMSbYnOrAbg==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [x64] + os: [win32] + + '@inquirer/external-editor@1.0.1': + resolution: {integrity: sha512-Oau4yL24d2B5IL4ma4UpbQigkVhzPDXLoqy1ggK4gnHg/stmkffJE4oOXHXF3uz0UEpywG68KcyXsyYpA1Re/Q==} + engines: {node: '>=18'} + peerDependencies: + '@types/node': '>=18' + peerDependenciesMeta: + '@types/node': + optional: true + '@isaacs/balanced-match@4.0.1': resolution: {integrity: sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==} engines: {node: 20 || >=22} @@ -875,25 +1582,127 @@ packages: resolution: {integrity: sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==} engines: {node: '>=18.0.0'} + '@isaacs/ttlcache@1.4.1': + resolution: {integrity: sha512-RQgQ4uQ+pLbqXfOmieB91ejmLwvSgv9nLx6sT6sD83s7umBypgg+OIBOBbEUiJXrfpnp9j0mRhYYdzp9uqq3lA==} + engines: {node: '>=12'} + + '@istanbuljs/load-nyc-config@1.1.0': + resolution: {integrity: sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==} + engines: {node: '>=8'} + '@istanbuljs/schema@0.1.3': resolution: {integrity: sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==} engines: {node: '>=8'} - '@jridgewell/gen-mapping@0.3.12': - resolution: {integrity: sha512-OuLGC46TjB5BbN1dH8JULVVZY4WTdkF7tV9Ys6wLL1rubZnCMstOhNHueU5bLCrnRuDhKPDM4g6sw4Bel5Gzqg==} + '@jest/create-cache-key-function@29.7.0': + resolution: {integrity: sha512-4QqS3LY5PBmTRHj9sAg1HLoPzqAI0uOX6wI/TRqHIcOxlFidy6YEmCQJk6FSZjNLGCeubDMfmkWL+qaLKhSGQA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + '@jest/environment@29.7.0': + resolution: {integrity: sha512-aQIfHDq33ExsN4jP1NWGXhxgQ/wixs60gDiKO+XVMd8Mn0NWPWgc34ZQDTb2jKaUWQ7MuwoitXAsN2XVXNMpAw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + '@jest/fake-timers@29.7.0': + resolution: {integrity: sha512-q4DH1Ha4TTFPdxLsqDXK1d3+ioSL7yL5oCMJZgDYm6i+6CygW5E5xVr/D1HdsGxjt1ZWSfUAs9OxSB/BNelWrQ==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + '@jest/schemas@29.6.3': + resolution: {integrity: sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + '@jest/transform@29.7.0': + resolution: {integrity: sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + '@jest/types@29.6.3': + resolution: {integrity: sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + '@jridgewell/gen-mapping@0.3.13': + resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==} '@jridgewell/resolve-uri@3.1.2': resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} engines: {node: '>=6.0.0'} - '@jridgewell/source-map@0.3.10': - resolution: {integrity: sha512-0pPkgz9dY+bijgistcTTJ5mR+ocqRXLuhXHYdzoMmmoJ2C9S46RCm2GMUbatPEUK9Yjy26IrAy8D/M00lLkv+Q==} + '@jridgewell/source-map@0.3.11': + resolution: {integrity: sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==} - '@jridgewell/sourcemap-codec@1.5.4': - resolution: {integrity: sha512-VT2+G1VQs/9oz078bLrYbecdZKs912zQlkelYpuf+SXF+QvZDYJlbx/LSx+meSAwdDFnF8FVXW92AVjjkVmgFw==} + '@jridgewell/sourcemap-codec@1.5.5': + resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==} - '@jridgewell/trace-mapping@0.3.29': - resolution: {integrity: sha512-uw6guiW/gcAGPDhLmd77/6lW8QLeiV5RUTsAX46Db6oLhGaVj4lhnPwb184s1bkc8kdVg/+h988dro8GRDpmYQ==} + '@jridgewell/trace-mapping@0.3.30': + resolution: {integrity: sha512-GQ7Nw5G2lTu/BtHTKfXhKHok2WGetd4XYcVKGx00SjAk8GMwgJM3zr6zORiPGuOE+/vkc90KtTosSSvaCjKb2Q==} + + '@jridgewell/trace-mapping@0.3.9': + resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} + + '@js-joda/core@5.6.5': + resolution: {integrity: sha512-3zwefSMwHpu8iVUW8YYz227sIv6UFqO31p1Bf1ZH/Vom7CmNyUsXjDBlnNzcuhmOL1XfxZ3nvND42kR23XlbcQ==} + + '@js-sdsl/ordered-map@4.4.2': + resolution: {integrity: sha512-iUKgm52T8HOE/makSxjqoWhe95ZJA1/G1sYsGev2JDKUSS14KAgg1LHb+Ba+IPow0xflbnSkOsZcO08C7w1gYw==} + + '@libsql/client@0.15.14': + resolution: {integrity: sha512-oXeFYcSyAsYWvpWVmynrwNwb+NHNHtMfSIVdfQTF1B9RsgDXQE5YCDP3SS0i1FA8nuLWy2trFDVwP1b2LNdNPQ==} + + '@libsql/core@0.15.14': + resolution: {integrity: sha512-b2eVQma78Ss+edIIFi7LnhhyUy5hAJjYvrSAD5RFdO/YKP2rEvNAT1pIn2Li7NrqcsMmoEQWlpUWH4fWMdXtpQ==} + + '@libsql/darwin-arm64@0.5.20': + resolution: {integrity: sha512-faHM2FX26xruO4w76YkW+lA28yKcTIzNiGvK9Q8+8sCuC7cn3KdMO6KJ84c6fJQwtwG+F4hxIoy95U5FYge3bg==} + cpu: [arm64] + os: [darwin] + + '@libsql/darwin-x64@0.5.20': + resolution: {integrity: sha512-19l0oEW/r2kZxDJg+w53C0kq7eFFKpeKDEjV/FAAkBfQwJoGqS4sep9u1fK1X3KzOF5rB8cVyIrQGk+6ibzUeQ==} + cpu: [x64] + os: [darwin] + + '@libsql/hrana-client@0.7.0': + resolution: {integrity: sha512-OF8fFQSkbL7vJY9rfuegK1R7sPgQ6kFMkDamiEccNUvieQ+3urzfDFI616oPl8V7T9zRmnTkSjMOImYCAVRVuw==} + + '@libsql/isomorphic-fetch@0.3.1': + resolution: {integrity: sha512-6kK3SUK5Uu56zPq/Las620n5aS9xJq+jMBcNSOmjhNf/MUvdyji4vrMTqD7ptY7/4/CAVEAYDeotUz60LNQHtw==} + engines: {node: '>=18.0.0'} + + '@libsql/isomorphic-ws@0.1.5': + resolution: {integrity: sha512-DtLWIH29onUYR00i0GlQ3UdcTRC6EP4u9w/h9LxpUZJWRMARk6dQwZ6Jkd+QdwVpuAOrdxt18v0K2uIYR3fwFg==} + + '@libsql/linux-arm-gnueabihf@0.5.20': + resolution: {integrity: sha512-vfw5/R00ysWG0iMLxqV8I5mVnHwjofxuLAL9i6wwdexIIXusG1ExSIOP8/W6xvjPXetgzEVRo4A7zr1S6SGBBg==} + cpu: [arm] + os: [linux] + + '@libsql/linux-arm-musleabihf@0.5.20': + resolution: {integrity: sha512-VGqyvg0k3bg0JMMHCR0XrqBseFU9syWRxEbC0Aluipkw5Xsb+DSr9cNvMtGUbGDg2pEfkY/DDa9hTlst6K7P5w==} + cpu: [arm] + os: [linux] + + '@libsql/linux-arm64-gnu@0.5.20': + resolution: {integrity: sha512-Wq6oF4goWp20G/LBmI6rdFY716bb81VCzyglkkAwqMwdJeIsaC0DRvD62nx1OSbSZmZMRDobqoe2ZP8BvMvXyQ==} + cpu: [arm64] + os: [linux] + + '@libsql/linux-arm64-musl@0.5.20': + resolution: {integrity: sha512-Xb112/q3/Z6lKKhwJgR2QVRYtRQblEB69VbStIVjKKw5RZv+r77ZSOHfsR3RHL+R66VN431+DLJBV0+B+AImQw==} + cpu: [arm64] + os: [linux] + + '@libsql/linux-x64-gnu@0.5.20': + resolution: {integrity: sha512-fHUaOYx7cVqbqPLqOIArfPsuWnu+jk9ETR0gt/8rH1J6pW5qhdDWn3B35Hk/ZmzNacBFSWZnHxxhWnZMWYVnVA==} + cpu: [x64] + os: [linux] + + '@libsql/linux-x64-musl@0.5.20': + resolution: {integrity: sha512-EpT1Va1L/y2w0Sj75lxRmaTyX/MD32eKpZiz++3mrE2zRTYAURo9GEbglvSC6Y5aRnLcHPx6XmR25wigRb8WZg==} + cpu: [x64] + os: [linux] + + '@libsql/win32-x64-msvc@0.5.20': + resolution: {integrity: sha512-3/G5/SZWXmOCaNwEwDdiXEpjeY7NGx1khPjON1yi3BViKrb2TJiiHHn6zpCN7+ZWNibQFZylkETSTURRlealNA==} + cpu: [x64] + os: [win32] '@manypkg/find-root@1.1.0': resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==} @@ -934,6 +1743,12 @@ packages: '@napi-rs/wasm-runtime@0.2.12': resolution: {integrity: sha512-ZVWUcfwY4E/yPitQJl481FjFo3K22D6qF0DuFH6Y/nbnE11GY5uguDxZMGXPQ8WQ0128MXQD7TnfHyK4oWoIJQ==} + '@napi-rs/wasm-runtime@1.0.3': + resolution: {integrity: sha512-rZxtMsLwjdXkMUGC3WwsPwLNVqVqnTJT6MNIB6e+5fhMcSCPP0AOsNWuMQ5mdCq6HNjs/ZeWAEchpqeprqBD2Q==} + + '@neon-rs/load@0.0.4': + resolution: {integrity: sha512-kTPhdZyTQxB+2wpiRcFWrDcejc4JI6tkPuS7UZCG4l6Zvc5kU/gGQ/ozvHTh1XR5tS+UlfAfGuPajjzQjCiHCw==} + '@nicolo-ribaudo/chokidar-2@2.1.8-no-fsevents.3': resolution: {integrity: sha512-s88O1aVtXftvp5bCPB7WnmXc5IwOZZ7YPuwNPt+GtOOXpPvad1LfbmjYv+qII7zP6RU2QGnqve27dnLycEnyEQ==} @@ -949,6 +1764,19 @@ packages: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} + '@op-engineering/op-sqlite@15.0.1': + resolution: {integrity: sha512-86tIMm/5OERUIguUq81YdRETlSsMzPdj9XYVdPA19fzNMT+Ptf5Vl5awLMEdvXPvOP9vyef5FealT+3llYwG8w==} + peerDependencies: + react: '*' + react-native: '*' + + '@oxc-project/runtime@0.82.3': + resolution: {integrity: sha512-LNh5GlJvYHAnMurO+EyA8jJwN1rki7l3PSHuosDh2I7h00T6/u9rCkUjg/SvPmT1CZzvhuW0y+gf7jcqUy/Usg==} + engines: {node: '>=6.9.0'} + + '@oxc-project/types@0.82.3': + resolution: {integrity: sha512-6nCUxBnGX0c6qfZW5MaF6/fmu5dHJDMiMPaioKHKs5mi5+8/FHQ7WGjgQIz1zxpmceMYfdIXkOaLYE+ejbuOtA==} + '@pkgjs/parseargs@0.11.0': resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} engines: {node: '>=14'} @@ -956,6 +1784,188 @@ packages: '@polka/url@1.0.0-next.29': resolution: {integrity: sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww==} + '@poppinss/colors@4.1.5': + resolution: {integrity: sha512-FvdDqtcRCtz6hThExcFOgW0cWX+xwSMWcRuQe5ZEb2m7cVQOAVZOIMt+/v9RxGiD9/OY16qJBXK4CVKWAPalBw==} + + '@poppinss/dumper@0.6.4': + resolution: {integrity: sha512-iG0TIdqv8xJ3Lt9O8DrPRxw1MRLjNpoqiSGU03P/wNLP/s0ra0udPJ1J2Tx5M0J3H/cVyEgpbn8xUKRY9j59kQ==} + + '@poppinss/exception@1.2.2': + resolution: {integrity: sha512-m7bpKCD4QMlFCjA/nKTs23fuvoVFoA83brRKmObCUNmi/9tVu8Ve3w4YQAnJu4q3Tjf5fr685HYIC/IA2zHRSg==} + + '@protobufjs/aspromise@1.1.2': + resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==} + + '@protobufjs/base64@1.1.2': + resolution: {integrity: sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==} + + '@protobufjs/codegen@2.0.4': + resolution: {integrity: sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==} + + '@protobufjs/eventemitter@1.1.0': + resolution: {integrity: sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==} + + '@protobufjs/fetch@1.1.0': + resolution: {integrity: sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==} + + '@protobufjs/float@1.0.2': + resolution: {integrity: sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==} + + '@protobufjs/inquire@1.1.0': + resolution: {integrity: sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==} + + '@protobufjs/path@1.1.2': + resolution: {integrity: sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==} + + '@protobufjs/pool@1.1.0': + resolution: {integrity: sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==} + + '@protobufjs/utf8@1.1.0': + resolution: {integrity: sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==} + + '@react-native/assets-registry@0.81.0': + resolution: {integrity: sha512-rZs8ziQ1YRV3Z5Mw5AR7YcgI3q1Ya9NIx6nyuZAT9wDSSjspSi+bww+Hargh/a4JfV2Ajcxpn9X9UiFJr1ddPw==} + engines: {node: '>= 20.19.4'} + + '@react-native/babel-plugin-codegen@0.81.0': + resolution: {integrity: sha512-MEMlW91+2Kk9GiObRP1Nc6oTdiyvmSEbPMSC6kzUzDyouxnh5/x28uyNySmB2nb6ivcbmQ0lxaU059+CZSkKXQ==} + engines: {node: '>= 20.19.4'} + + '@react-native/babel-preset@0.81.0': + resolution: {integrity: sha512-RKMgCUGsso/2b32kgg24lB68LJ6qr2geLoSQTbisY6Usye0uXeXCgbZZDbILIX9upL4uzU4staMldRZ0v08F1g==} + engines: {node: '>= 20.19.4'} + peerDependencies: + '@babel/core': '*' + + '@react-native/codegen@0.81.0': + resolution: {integrity: sha512-gPFutgtj8YqbwKKt3YpZKamUBGd9YZJV51Jq2aiDZ9oThkg1frUBa20E+Jdi7jKn982wjBMxAklAR85QGQ4xMA==} + engines: {node: '>= 20.19.4'} + peerDependencies: + '@babel/core': '*' + + '@react-native/community-cli-plugin@0.81.0': + resolution: {integrity: sha512-n04ACkCaLR54NmA/eWiDpjC16pHr7+yrbjQ6OEdRoXbm5EfL8FEre2kDAci7pfFdiSMpxdRULDlKpfQ+EV/GAQ==} + engines: {node: '>= 20.19.4'} + peerDependencies: + '@react-native-community/cli': '*' + '@react-native/metro-config': '*' + peerDependenciesMeta: + '@react-native-community/cli': + optional: true + + '@react-native/debugger-frontend@0.81.0': + resolution: {integrity: sha512-N/8uL2CGQfwiQRYFUNfmaYxRDSoSeOmFb56rb0PDnP3XbS5+X9ee7X4bdnukNHLGfkRdH7sVjlB8M5zE8XJOhw==} + engines: {node: '>= 20.19.4'} + + '@react-native/dev-middleware@0.81.0': + resolution: {integrity: sha512-J/HeC/+VgRyGECPPr9rAbe5S0OL6MCIrvrC/kgNKSME5+ZQLCiTpt3pdAoAMXwXiF9a02Nmido0DnyM1acXTIA==} + engines: {node: '>= 20.19.4'} + + '@react-native/gradle-plugin@0.81.0': + resolution: {integrity: sha512-LGNtPXO1RKLws5ORRb4Q4YULi2qxM4qZRuARtwqM/1f2wyZVggqapoV0OXlaXaz+GiEd2ll3ROE4CcLN6J93jg==} + engines: {node: '>= 20.19.4'} + + '@react-native/js-polyfills@0.81.0': + resolution: {integrity: sha512-whXZWIogzoGpqdyTjqT89M6DXmlOkWqNpWoVOAwVi8XFCMO+L7WTk604okIgO6gdGZcP1YtFpQf9JusbKrv/XA==} + engines: {node: '>= 20.19.4'} + + '@react-native/metro-babel-transformer@0.81.0': + resolution: {integrity: sha512-Mwovr4jJ3JTnbHEQLhdcMvS82LjijpqCydXl1aH2N16WVCrE5oSNFiqTt6NpZBw9zkJX7nijsY+xeCy6m+KK3Q==} + engines: {node: '>= 20.19.4'} + peerDependencies: + '@babel/core': '*' + + '@react-native/metro-config@0.81.0': + resolution: {integrity: sha512-5eqLP4TCERHGRYDJSZa//O98CGDFNNEwHVvhs65Msfy6hAoSdw5pAAuTrsQwmbTBp0Fkvu7Bx8BZDhiferZsHg==} + engines: {node: '>= 20.19.4'} + + '@react-native/normalize-colors@0.81.0': + resolution: {integrity: sha512-3gEu/29uFgz+81hpUgdlOojM4rjHTIPwxpfygFNY60V6ywZih3eLDTS8kAjNZfPFHQbcYrNorJzwnL5yFF/uLw==} + + '@react-native/virtualized-lists@0.81.0': + resolution: {integrity: sha512-p14QC5INHkbMZ96158sUxkSwN6zp138W11G+CRGoLJY4Q9WRJBCe7wHR5Owyy3XczQXrIih/vxAXwgYeZ2XByg==} + engines: {node: '>= 20.19.4'} + peerDependencies: + '@types/react': ^19.1.0 + react: '*' + react-native: '*' + peerDependenciesMeta: + '@types/react': + optional: true + + '@rolldown/binding-android-arm64@1.0.0-beta.34': + resolution: {integrity: sha512-jf5GNe5jP3Sr1Tih0WKvg2bzvh5T/1TA0fn1u32xSH7ca/p5t+/QRr4VRFCV/na5vjwKEhwWrChsL2AWlY+eoA==} + cpu: [arm64] + os: [android] + + '@rolldown/binding-darwin-arm64@1.0.0-beta.34': + resolution: {integrity: sha512-2F/TqH4QuJQ34tgWxqBjFL3XV1gMzeQgUO8YRtCPGBSP0GhxtoFzsp7KqmQEothsxztlv+KhhT9Dbg3HHwHViQ==} + cpu: [arm64] + os: [darwin] + + '@rolldown/binding-darwin-x64@1.0.0-beta.34': + resolution: {integrity: sha512-E1QuFslgLWbHQ8Qli/AqUKdfg0pockQPwRxVbhNQ74SciZEZpzLaujkdmOLSccMlSXDfFCF8RPnMoRAzQ9JV8Q==} + cpu: [x64] + os: [darwin] + + '@rolldown/binding-freebsd-x64@1.0.0-beta.34': + resolution: {integrity: sha512-VS8VInNCwnkpI9WeQaWu3kVBq9ty6g7KrHdLxYMzeqz24+w9hg712TcWdqzdY6sn+24lUoMD9jTZrZ/qfVpk0g==} + cpu: [x64] + os: [freebsd] + + '@rolldown/binding-linux-arm-gnueabihf@1.0.0-beta.34': + resolution: {integrity: sha512-4St4emjcnULnxJYb/5ZDrH/kK/j6PcUgc3eAqH5STmTrcF+I9m/X2xvSF2a2bWv1DOQhxBewThu0KkwGHdgu5w==} + cpu: [arm] + os: [linux] + + '@rolldown/binding-linux-arm64-gnu@1.0.0-beta.34': + resolution: {integrity: sha512-a737FTqhFUoWfnebS2SnQ2BS50p0JdukdkUBwy2J06j4hZ6Eej0zEB8vTfAqoCjn8BQKkXBy+3Sx0IRkgwz1gA==} + cpu: [arm64] + os: [linux] + + '@rolldown/binding-linux-arm64-musl@1.0.0-beta.34': + resolution: {integrity: sha512-NH+FeQWKyuw0k+PbXqpFWNfvD8RPvfJk766B/njdaWz4TmiEcSB0Nb6guNw1rBpM1FmltQYb3fFnTumtC6pRfA==} + cpu: [arm64] + os: [linux] + + '@rolldown/binding-linux-x64-gnu@1.0.0-beta.34': + resolution: {integrity: sha512-Q3RSCivp8pNadYK8ke3hLnQk08BkpZX9BmMjgwae2FWzdxhxxUiUzd9By7kneUL0vRQ4uRnhD9VkFQ+Haeqdvw==} + cpu: [x64] + os: [linux] + + '@rolldown/binding-linux-x64-musl@1.0.0-beta.34': + resolution: {integrity: sha512-wDd/HrNcVoBhWWBUW3evJHoo7GJE/RofssBy3Dsiip05YUBmokQVrYAyrboOY4dzs/lJ7HYeBtWQ9hj8wlyF0A==} + cpu: [x64] + os: [linux] + + '@rolldown/binding-openharmony-arm64@1.0.0-beta.34': + resolution: {integrity: sha512-dH3FTEV6KTNWpYSgjSXZzeX7vLty9oBYn6R3laEdhwZftQwq030LKL+5wyQdlbX5pnbh4h127hpv3Hl1+sj8dg==} + cpu: [arm64] + os: [openharmony] + + '@rolldown/binding-wasm32-wasi@1.0.0-beta.34': + resolution: {integrity: sha512-y5BUf+QtO0JsIDKA51FcGwvhJmv89BYjUl8AmN7jqD6k/eU55mH6RJYnxwCsODq5m7KSSTigVb6O7/GqB8wbPw==} + engines: {node: '>=14.0.0'} + cpu: [wasm32] + + '@rolldown/binding-win32-arm64-msvc@1.0.0-beta.34': + resolution: {integrity: sha512-ga5hFhdTwpaNxEiuxZHWnD3ed0GBAzbgzS5tRHpe0ObptxM1a9Xrq6TVfNQirBLwb5Y7T/FJmJi3pmdLy95ljg==} + cpu: [arm64] + os: [win32] + + '@rolldown/binding-win32-ia32-msvc@1.0.0-beta.34': + resolution: {integrity: sha512-4/MBp9T9eRnZskxWr8EXD/xHvLhdjWaeX/qY9LPRG1JdCGV3DphkLTy5AWwIQ5jhAy2ZNJR5z2fYRlpWU0sIyQ==} + cpu: [ia32] + os: [win32] + + '@rolldown/binding-win32-x64-msvc@1.0.0-beta.34': + resolution: {integrity: sha512-7O5iUBX6HSBKlQU4WykpUoEmb0wQmonb6ziKFr3dJTHud2kzDnWMqk344T0qm3uGv9Ddq6Re/94pInxo1G2d4w==} + cpu: [x64] + os: [win32] + + '@rolldown/pluginutils@1.0.0-beta.34': + resolution: {integrity: sha512-LyAREkZHP5pMom7c24meKmJCdhf2hEyvam2q0unr3or9ydwDL+DJ8chTF6Av/RFPb3rH8UFBdMzO5MxTZW97oA==} + '@rollup/plugin-node-resolve@16.0.1': resolution: {integrity: sha512-tk5YCxJWIG81umIvNkSod2qK5KyQW19qcBF/B78n1bjtOON6gzKoVeSzAE8yHCZEDmqkHKkxplExA8KzdJLJpA==} engines: {node: '>=14.0.0'} @@ -992,111 +2002,133 @@ packages: rollup: optional: true - '@rollup/rollup-android-arm-eabi@4.45.1': - resolution: {integrity: sha512-NEySIFvMY0ZQO+utJkgoMiCAjMrGvnbDLHvcmlA33UXJpYBCvlBEbMMtV837uCkS+plG2umfhn0T5mMAxGrlRA==} + '@rollup/rollup-android-arm-eabi@4.48.1': + resolution: {integrity: sha512-rGmb8qoG/zdmKoYELCBwu7vt+9HxZ7Koos3pD0+sH5fR3u3Wb/jGcpnqxcnWsPEKDUyzeLSqksN8LJtgXjqBYw==} cpu: [arm] os: [android] - '@rollup/rollup-android-arm64@4.45.1': - resolution: {integrity: sha512-ujQ+sMXJkg4LRJaYreaVx7Z/VMgBBd89wGS4qMrdtfUFZ+TSY5Rs9asgjitLwzeIbhwdEhyj29zhst3L1lKsRQ==} + '@rollup/rollup-android-arm64@4.48.1': + resolution: {integrity: sha512-4e9WtTxrk3gu1DFE+imNJr4WsL13nWbD/Y6wQcyku5qadlKHY3OQ3LJ/INrrjngv2BJIHnIzbqMk1GTAC2P8yQ==} cpu: [arm64] os: [android] - '@rollup/rollup-darwin-arm64@4.45.1': - resolution: {integrity: sha512-FSncqHvqTm3lC6Y13xncsdOYfxGSLnP+73k815EfNmpewPs+EyM49haPS105Rh4aF5mJKywk9X0ogzLXZzN9lA==} + '@rollup/rollup-darwin-arm64@4.48.1': + resolution: {integrity: sha512-+XjmyChHfc4TSs6WUQGmVf7Hkg8ferMAE2aNYYWjiLzAS/T62uOsdfnqv+GHRjq7rKRnYh4mwWb4Hz7h/alp8A==} cpu: [arm64] os: [darwin] - '@rollup/rollup-darwin-x64@4.45.1': - resolution: {integrity: sha512-2/vVn/husP5XI7Fsf/RlhDaQJ7x9zjvC81anIVbr4b/f0xtSmXQTFcGIQ/B1cXIYM6h2nAhJkdMHTnD7OtQ9Og==} + '@rollup/rollup-darwin-x64@4.48.1': + resolution: {integrity: sha512-upGEY7Ftw8M6BAJyGwnwMw91rSqXTcOKZnnveKrVWsMTF8/k5mleKSuh7D4v4IV1pLxKAk3Tbs0Lo9qYmii5mQ==} cpu: [x64] os: [darwin] - '@rollup/rollup-freebsd-arm64@4.45.1': - resolution: {integrity: sha512-4g1kaDxQItZsrkVTdYQ0bxu4ZIQ32cotoQbmsAnW1jAE4XCMbcBPDirX5fyUzdhVCKgPcrwWuucI8yrVRBw2+g==} + '@rollup/rollup-freebsd-arm64@4.48.1': + resolution: {integrity: sha512-P9ViWakdoynYFUOZhqq97vBrhuvRLAbN/p2tAVJvhLb8SvN7rbBnJQcBu8e/rQts42pXGLVhfsAP0k9KXWa3nQ==} cpu: [arm64] os: [freebsd] - '@rollup/rollup-freebsd-x64@4.45.1': - resolution: {integrity: sha512-L/6JsfiL74i3uK1Ti2ZFSNsp5NMiM4/kbbGEcOCps99aZx3g8SJMO1/9Y0n/qKlWZfn6sScf98lEOUe2mBvW9A==} + '@rollup/rollup-freebsd-x64@4.48.1': + resolution: {integrity: sha512-VLKIwIpnBya5/saccM8JshpbxfyJt0Dsli0PjXozHwbSVaHTvWXJH1bbCwPXxnMzU4zVEfgD1HpW3VQHomi2AQ==} cpu: [x64] os: [freebsd] - '@rollup/rollup-linux-arm-gnueabihf@4.45.1': - resolution: {integrity: sha512-RkdOTu2jK7brlu+ZwjMIZfdV2sSYHK2qR08FUWcIoqJC2eywHbXr0L8T/pONFwkGukQqERDheaGTeedG+rra6Q==} + '@rollup/rollup-linux-arm-gnueabihf@4.48.1': + resolution: {integrity: sha512-3zEuZsXfKaw8n/yF7t8N6NNdhyFw3s8xJTqjbTDXlipwrEHo4GtIKcMJr5Ed29leLpB9AugtAQpAHW0jvtKKaQ==} cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm-musleabihf@4.45.1': - resolution: {integrity: sha512-3kJ8pgfBt6CIIr1o+HQA7OZ9mp/zDk3ctekGl9qn/pRBgrRgfwiffaUmqioUGN9hv0OHv2gxmvdKOkARCtRb8Q==} + '@rollup/rollup-linux-arm-musleabihf@4.48.1': + resolution: {integrity: sha512-leo9tOIlKrcBmmEypzunV/2w946JeLbTdDlwEZ7OnnsUyelZ72NMnT4B2vsikSgwQifjnJUbdXzuW4ToN1wV+Q==} cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm64-gnu@4.45.1': - resolution: {integrity: sha512-k3dOKCfIVixWjG7OXTCOmDfJj3vbdhN0QYEqB+OuGArOChek22hn7Uy5A/gTDNAcCy5v2YcXRJ/Qcnm4/ma1xw==} + '@rollup/rollup-linux-arm64-gnu@4.48.1': + resolution: {integrity: sha512-Vy/WS4z4jEyvnJm+CnPfExIv5sSKqZrUr98h03hpAMbE2aI0aD2wvK6GiSe8Gx2wGp3eD81cYDpLLBqNb2ydwQ==} cpu: [arm64] os: [linux] - '@rollup/rollup-linux-arm64-musl@4.45.1': - resolution: {integrity: sha512-PmI1vxQetnM58ZmDFl9/Uk2lpBBby6B6rF4muJc65uZbxCs0EA7hhKCk2PKlmZKuyVSHAyIw3+/SiuMLxKxWog==} + '@rollup/rollup-linux-arm64-musl@4.48.1': + resolution: {integrity: sha512-x5Kzn7XTwIssU9UYqWDB9VpLpfHYuXw5c6bJr4Mzv9kIv242vmJHbI5PJJEnmBYitUIfoMCODDhR7KoZLot2VQ==} cpu: [arm64] os: [linux] - '@rollup/rollup-linux-loongarch64-gnu@4.45.1': - resolution: {integrity: sha512-9UmI0VzGmNJ28ibHW2GpE2nF0PBQqsyiS4kcJ5vK+wuwGnV5RlqdczVocDSUfGX/Na7/XINRVoUgJyFIgipoRg==} + '@rollup/rollup-linux-loongarch64-gnu@4.48.1': + resolution: {integrity: sha512-yzCaBbwkkWt/EcgJOKDUdUpMHjhiZT/eDktOPWvSRpqrVE04p0Nd6EGV4/g7MARXXeOqstflqsKuXVM3H9wOIQ==} cpu: [loong64] os: [linux] - '@rollup/rollup-linux-powerpc64le-gnu@4.45.1': - resolution: {integrity: sha512-7nR2KY8oEOUTD3pBAxIBBbZr0U7U+R9HDTPNy+5nVVHDXI4ikYniH1oxQz9VoB5PbBU1CZuDGHkLJkd3zLMWsg==} + '@rollup/rollup-linux-ppc64-gnu@4.48.1': + resolution: {integrity: sha512-UK0WzWUjMAJccHIeOpPhPcKBqax7QFg47hwZTp6kiMhQHeOYJeaMwzeRZe1q5IiTKsaLnHu9s6toSYVUlZ2QtQ==} cpu: [ppc64] os: [linux] - '@rollup/rollup-linux-riscv64-gnu@4.45.1': - resolution: {integrity: sha512-nlcl3jgUultKROfZijKjRQLUu9Ma0PeNv/VFHkZiKbXTBQXhpytS8CIj5/NfBeECZtY2FJQubm6ltIxm/ftxpw==} + '@rollup/rollup-linux-riscv64-gnu@4.48.1': + resolution: {integrity: sha512-3NADEIlt+aCdCbWVZ7D3tBjBX1lHpXxcvrLt/kdXTiBrOds8APTdtk2yRL2GgmnSVeX4YS1JIf0imFujg78vpw==} cpu: [riscv64] os: [linux] - '@rollup/rollup-linux-riscv64-musl@4.45.1': - resolution: {integrity: sha512-HJV65KLS51rW0VY6rvZkiieiBnurSzpzore1bMKAhunQiECPuxsROvyeaot/tcK3A3aGnI+qTHqisrpSgQrpgA==} + '@rollup/rollup-linux-riscv64-musl@4.48.1': + resolution: {integrity: sha512-euuwm/QTXAMOcyiFCcrx0/S2jGvFlKJ2Iro8rsmYL53dlblp3LkUQVFzEidHhvIPPvcIsxDhl2wkBE+I6YVGzA==} cpu: [riscv64] os: [linux] - '@rollup/rollup-linux-s390x-gnu@4.45.1': - resolution: {integrity: sha512-NITBOCv3Qqc6hhwFt7jLV78VEO/il4YcBzoMGGNxznLgRQf43VQDae0aAzKiBeEPIxnDrACiMgbqjuihx08OOw==} + '@rollup/rollup-linux-s390x-gnu@4.48.1': + resolution: {integrity: sha512-w8mULUjmPdWLJgmTYJx/W6Qhln1a+yqvgwmGXcQl2vFBkWsKGUBRbtLRuKJUln8Uaimf07zgJNxOhHOvjSQmBQ==} cpu: [s390x] os: [linux] - '@rollup/rollup-linux-x64-gnu@4.45.1': - resolution: {integrity: sha512-+E/lYl6qu1zqgPEnTrs4WysQtvc/Sh4fC2nByfFExqgYrqkKWp1tWIbe+ELhixnenSpBbLXNi6vbEEJ8M7fiHw==} + '@rollup/rollup-linux-x64-gnu@4.48.1': + resolution: {integrity: sha512-90taWXCWxTbClWuMZD0DKYohY1EovA+W5iytpE89oUPmT5O1HFdf8cuuVIylE6vCbrGdIGv85lVRzTcpTRZ+kA==} cpu: [x64] os: [linux] - '@rollup/rollup-linux-x64-musl@4.45.1': - resolution: {integrity: sha512-a6WIAp89p3kpNoYStITT9RbTbTnqarU7D8N8F2CV+4Cl9fwCOZraLVuVFvlpsW0SbIiYtEnhCZBPLoNdRkjQFw==} + '@rollup/rollup-linux-x64-musl@4.48.1': + resolution: {integrity: sha512-2Gu29SkFh1FfTRuN1GR1afMuND2GKzlORQUP3mNMJbqdndOg7gNsa81JnORctazHRokiDzQ5+MLE5XYmZW5VWg==} cpu: [x64] os: [linux] - '@rollup/rollup-win32-arm64-msvc@4.45.1': - resolution: {integrity: sha512-T5Bi/NS3fQiJeYdGvRpTAP5P02kqSOpqiopwhj0uaXB6nzs5JVi2XMJb18JUSKhCOX8+UE1UKQufyD6Or48dJg==} + '@rollup/rollup-win32-arm64-msvc@4.48.1': + resolution: {integrity: sha512-6kQFR1WuAO50bxkIlAVeIYsz3RUx+xymwhTo9j94dJ+kmHe9ly7muH23sdfWduD0BA8pD9/yhonUvAjxGh34jQ==} cpu: [arm64] os: [win32] - '@rollup/rollup-win32-ia32-msvc@4.45.1': - resolution: {integrity: sha512-lxV2Pako3ujjuUe9jiU3/s7KSrDfH6IgTSQOnDWr9aJ92YsFd7EurmClK0ly/t8dzMkDtd04g60WX6yl0sGfdw==} + '@rollup/rollup-win32-ia32-msvc@4.48.1': + resolution: {integrity: sha512-RUyZZ/mga88lMI3RlXFs4WQ7n3VyU07sPXmMG7/C1NOi8qisUg57Y7LRarqoGoAiopmGmChUhSwfpvQ3H5iGSQ==} cpu: [ia32] os: [win32] - '@rollup/rollup-win32-x64-msvc@4.45.1': - resolution: {integrity: sha512-M/fKi4sasCdM8i0aWJjCSFm2qEnYRR8AMLG2kxp6wD13+tMGA4Z1tVAuHkNRjud5SW2EM3naLuK35w9twvf6aA==} + '@rollup/rollup-win32-x64-msvc@4.48.1': + resolution: {integrity: sha512-8a/caCUN4vkTChxkaIJcMtwIVcBhi4X2PQRoT+yCK3qRYaZ7cURrmJFL5Ux9H9RaMIXj9RuihckdmkBX3zZsgg==} cpu: [x64] os: [win32] + '@sinclair/typebox@0.27.8': + resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} + + '@sindresorhus/is@7.0.2': + resolution: {integrity: sha512-d9xRovfKNz1SKieM0qJdO+PQonjnnIfSNWfHYnBSJ9hkjm0ZPw6HlxscDXYstp3z+7V2GOFHc+J0CYrYTjqCJw==} + engines: {node: '>=18'} + + '@sinonjs/commons@3.0.1': + resolution: {integrity: sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==} + + '@sinonjs/fake-timers@10.3.0': + resolution: {integrity: sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==} + + '@speed-highlight/core@1.2.7': + resolution: {integrity: sha512-0dxmVj4gxg3Jg879kvFS/msl4s9F3T9UXC1InxgOf7t5NvcPD97u/WTA5vL/IxWHMn7qSxBozqrnnE2wvl1m8g==} + '@standard-schema/spec@1.0.0': resolution: {integrity: sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA==} - '@testing-library/dom@10.4.0': - resolution: {integrity: sha512-pemlzrSESWbdAloYml3bAJMEfNh1Z7EduzqPKprCH5S341frlpYnUEW0H72dLxa6IsYr+mPno20GiSm+h9dEdQ==} + '@testcontainers/mysql@11.5.1': + resolution: {integrity: sha512-znonzVMlcCLQ6t7zDH0TOEcbGkz6iwIk5x5ZP5GqEdN0z3GLUu/jEF7yQUtfCY+PbVnCkigRg4WYS4bt6+zhyA==} + + '@testcontainers/postgresql@11.5.1': + resolution: {integrity: sha512-6P1QYIKRkktSVwTuwU0Pke5WbXTkvpLleyQcgknJPbZwhaIsCrhnbZlVzj2g/e+Nf9Lmdy1F2OAai+vUrBq0AQ==} + + '@testing-library/dom@10.4.1': + resolution: {integrity: sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg==} engines: {node: '>=18'} '@testing-library/user-event@14.6.1': @@ -1127,8 +2159,23 @@ packages: '@types/aria-query@5.0.4': resolution: {integrity: sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==} - '@types/bun@1.2.19': - resolution: {integrity: sha512-d9ZCmrH3CJ2uYKXQIUuZ/pUnTqIvLDS0SK7pFmbx8ma+ziH/FRMoAq5bYpRG7y+w1gl+HgyNZbtqgMq4W4e2Lg==} + '@types/babel__core@7.20.5': + resolution: {integrity: sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==} + + '@types/babel__generator@7.27.0': + resolution: {integrity: sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg==} + + '@types/babel__template@7.4.4': + resolution: {integrity: sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==} + + '@types/babel__traverse@7.28.0': + resolution: {integrity: sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q==} + + '@types/better-sqlite3@7.6.13': + resolution: {integrity: sha512-NMv9ASNARoKksWtsq/SHakpYAYnhBrQgGD8zkLYk/jaK8jUGn08CfEdTRgYhMypUQAfzSP8W6gNLe0q19/t4VA==} + + '@types/bun@1.2.21': + resolution: {integrity: sha512-NiDnvEqmbfQ6dmZ3EeUO577s4P5bf4HCTXtI6trMc6f6RzirY5IrF3aIookuSpyslFzrnvv2lmEWv5HyC1X79A==} '@types/chai@5.2.2': resolution: {integrity: sha512-8kB30R7Hwqf40JPiKhVzodJs2Qc1ZJ5zuT3uzw5Hq/dhNCl3G3l83jfpdI1e20BP348+fV7VIL/+FxaXkqBmWg==} @@ -1136,9 +2183,27 @@ packages: '@types/deep-eql@4.0.2': resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==} + '@types/docker-modem@3.0.6': + resolution: {integrity: sha512-yKpAGEuKRSS8wwx0joknWxsmLha78wNMe9R2S3UNsVOkZded8UqOrV8KoeDXoXsjndxwyF3eIhyClGbO1SEhEg==} + + '@types/dockerode@3.3.43': + resolution: {integrity: sha512-YCi0aKKpKeC9dhKTbuglvsWDnAyuIITd6CCJSTKiAdbDzPH4RWu0P9IK2XkJHdyplH6mzYtDYO+gB06JlzcPxg==} + '@types/estree@1.0.8': resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==} + '@types/graceful-fs@4.1.9': + resolution: {integrity: sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==} + + '@types/istanbul-lib-coverage@2.0.6': + resolution: {integrity: sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==} + + '@types/istanbul-lib-report@3.0.3': + resolution: {integrity: sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA==} + + '@types/istanbul-reports@3.0.4': + resolution: {integrity: sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ==} + '@types/jscodeshift@17.3.0': resolution: {integrity: sha512-ogvGG8VQQqAQQ096uRh+d6tBHrYuZjsumHirKtvBa5qEyTMN3IQJ7apo+sw9lxaB/iKWIhbbLlF3zmAWk9XQIg==} @@ -1148,62 +2213,92 @@ packages: '@types/node@12.20.55': resolution: {integrity: sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==} - '@types/node@24.1.0': - resolution: {integrity: sha512-ut5FthK5moxFKH2T1CUOC6ctR67rQRvvHdFLCD2Ql6KXmMuCrjsSsRI9UsLCm9M18BMwClv4pn327UvB7eeO1w==} + '@types/node@18.19.123': + resolution: {integrity: sha512-K7DIaHnh0mzVxreCR9qwgNxp3MH9dltPNIEddW9MYUlcKAzm+3grKNSTe2vCJHI1FaLpvpL5JGJrz1UZDKYvDg==} - '@types/react@19.1.8': - resolution: {integrity: sha512-AwAfQ2Wa5bCx9WP8nZL2uMZWod7J7/JSplxbTmBQ5ms6QpqNYm672H0Vu9ZVKVngQ+ii4R/byguVEUZQyeg44g==} + '@types/node@24.3.0': + resolution: {integrity: sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow==} + + '@types/pg-cursor@2.7.2': + resolution: {integrity: sha512-m3xT8bVFCvx98LuzbvXyuCdT/Hjdd/v8ml4jL4K1QF70Y8clOfCFdgoaEB1FWdcSwcpoFYZTJQaMD9/GQ27efQ==} + + '@types/pg@8.15.5': + resolution: {integrity: sha512-LF7lF6zWEKxuT3/OR8wAZGzkg4ENGXFNyiV/JeOt9z5B+0ZVwbql9McqX5c/WStFq1GaGso7H1AzP/qSzmlCKQ==} + + '@types/react@19.1.11': + resolution: {integrity: sha512-lr3jdBw/BGj49Eps7EvqlUaoeA0xpj3pc0RoJkHpYaCHkVK7i28dKyImLQb3JVlqs3aYSXf7qYuWOW/fgZnTXQ==} + + '@types/readable-stream@4.0.21': + resolution: {integrity: sha512-19eKVv9tugr03IgfXlA9UVUVRbW6IuqRO5B92Dl4a6pT7K8uaGrNS0GkxiZD0BOk6PLuXl5FhWl//eX/pzYdTQ==} '@types/resolve@1.20.2': resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} + '@types/ssh2-streams@0.1.12': + resolution: {integrity: sha512-Sy8tpEmCce4Tq0oSOYdfqaBpA3hDM8SoxoFh5vzFsu2oL+znzGz8oVWW7xb4K920yYMUY+PIG31qZnFMfPWNCg==} + + '@types/ssh2@0.5.52': + resolution: {integrity: sha512-lbLLlXxdCZOSJMCInKH2+9V/77ET2J6NPQHpFI0kda61Dd1KglJs+fPQBchizmzYSOJBgdTajhPqBO1xxLywvg==} + + '@types/ssh2@1.15.5': + resolution: {integrity: sha512-N1ASjp/nXH3ovBHddRJpli4ozpk6UdDYIX4RJWFa9L1YKnzdhTlVmiGHm4DZnj/jLbqZpes4aeR30EFGQtvhQQ==} + + '@types/stack-utils@2.0.3': + resolution: {integrity: sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==} + '@types/ws@8.18.1': resolution: {integrity: sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==} - '@typescript-eslint/eslint-plugin@8.38.0': - resolution: {integrity: sha512-CPoznzpuAnIOl4nhj4tRr4gIPj5AfKgkiJmGQDaq+fQnRJTYlcBjbX3wbciGmpoPf8DREufuPRe1tNMZnGdanA==} + '@types/yargs-parser@21.0.3': + resolution: {integrity: sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==} + + '@types/yargs@17.0.33': + resolution: {integrity: sha512-WpxBCKWPLr4xSsHgz511rFJAM+wS28w2zEO1QDNY5zM/S8ok70NNfztH0xwhqKyaK0OHCbN98LDAZuy1ctxDkA==} + + '@typescript-eslint/eslint-plugin@8.41.0': + resolution: {integrity: sha512-8fz6oa6wEKZrhXWro/S3n2eRJqlRcIa6SlDh59FXJ5Wp5XRZ8B9ixpJDcjadHq47hMx0u+HW6SNa6LjJQ6NLtw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - '@typescript-eslint/parser': ^8.38.0 + '@typescript-eslint/parser': ^8.41.0 eslint: ^8.57.0 || ^9.0.0 - typescript: '>=4.8.4 <5.9.0' + typescript: '>=4.8.4 <6.0.0' - '@typescript-eslint/parser@8.38.0': - resolution: {integrity: sha512-Zhy8HCvBUEfBECzIl1PKqF4p11+d0aUJS1GeUiuqK9WmOug8YCmC4h4bjyBvMyAMI9sbRczmrYL5lKg/YMbrcQ==} + '@typescript-eslint/parser@8.41.0': + resolution: {integrity: sha512-gTtSdWX9xiMPA/7MV9STjJOOYtWwIJIYxkQxnSV1U3xcE+mnJSH3f6zI0RYP+ew66WSlZ5ed+h0VCxsvdC1jJg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 - typescript: '>=4.8.4 <5.9.0' + typescript: '>=4.8.4 <6.0.0' - '@typescript-eslint/project-service@8.38.0': - resolution: {integrity: sha512-dbK7Jvqcb8c9QfH01YB6pORpqX1mn5gDZc9n63Ak/+jD67oWXn3Gs0M6vddAN+eDXBCS5EmNWzbSxsn9SzFWWg==} + '@typescript-eslint/project-service@8.41.0': + resolution: {integrity: sha512-b8V9SdGBQzQdjJ/IO3eDifGpDBJfvrNTp2QD9P2BeqWTGrRibgfgIlBSw6z3b6R7dPzg752tOs4u/7yCLxksSQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - typescript: '>=4.8.4 <5.9.0' + typescript: '>=4.8.4 <6.0.0' - '@typescript-eslint/scope-manager@8.38.0': - resolution: {integrity: sha512-WJw3AVlFFcdT9Ri1xs/lg8LwDqgekWXWhH3iAF+1ZM+QPd7oxQ6jvtW/JPwzAScxitILUIFs0/AnQ/UWHzbATQ==} + '@typescript-eslint/scope-manager@8.41.0': + resolution: {integrity: sha512-n6m05bXn/Cd6DZDGyrpXrELCPVaTnLdPToyhBoFkLIMznRUQUEQdSp96s/pcWSQdqOhrgR1mzJ+yItK7T+WPMQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/tsconfig-utils@8.38.0': - resolution: {integrity: sha512-Lum9RtSE3EroKk/bYns+sPOodqb2Fv50XOl/gMviMKNvanETUuUcC9ObRbzrJ4VSd2JalPqgSAavwrPiPvnAiQ==} + '@typescript-eslint/tsconfig-utils@8.41.0': + resolution: {integrity: sha512-TDhxYFPUYRFxFhuU5hTIJk+auzM/wKvWgoNYOPcOf6i4ReYlOoYN8q1dV5kOTjNQNJgzWN3TUUQMtlLOcUgdUw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - typescript: '>=4.8.4 <5.9.0' + typescript: '>=4.8.4 <6.0.0' - '@typescript-eslint/type-utils@8.38.0': - resolution: {integrity: sha512-c7jAvGEZVf0ao2z+nnz8BUaHZD09Agbh+DY7qvBQqLiz8uJzRgVPj5YvOh8I8uEiH8oIUGIfHzMwUcGVco/SJg==} + '@typescript-eslint/type-utils@8.41.0': + resolution: {integrity: sha512-63qt1h91vg3KsjVVonFJWjgSK7pZHSQFKH6uwqxAH9bBrsyRhO6ONoKyXxyVBzG1lJnFAJcKAcxLS54N1ee1OQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 - typescript: '>=4.8.4 <5.9.0' + typescript: '>=4.8.4 <6.0.0' '@typescript-eslint/types@5.62.0': resolution: {integrity: sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - '@typescript-eslint/types@8.38.0': - resolution: {integrity: sha512-wzkUfX3plUqij4YwWaJyqhiPE5UCRVlFpKn1oCRn2O1bJ592XxWJj8ROQ3JD5MYXLORW84063z3tZTb/cs4Tyw==} + '@typescript-eslint/types@8.41.0': + resolution: {integrity: sha512-9EwxsWdVqh42afLbHP90n2VdHaWU/oWgbH2P0CfcNfdKL7CuKpwMQGjwev56vWu9cSKU7FWSu6r9zck6CVfnag==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@typescript-eslint/typescript-estree@5.62.0': @@ -1215,27 +2310,31 @@ packages: typescript: optional: true - '@typescript-eslint/typescript-estree@8.38.0': - resolution: {integrity: sha512-fooELKcAKzxux6fA6pxOflpNS0jc+nOQEEOipXFNjSlBS6fqrJOVY/whSn70SScHrcJ2LDsxWrneFoWYSVfqhQ==} + '@typescript-eslint/typescript-estree@8.41.0': + resolution: {integrity: sha512-D43UwUYJmGhuwHfY7MtNKRZMmfd8+p/eNSfFe6tH5mbVDto+VQCayeAt35rOx3Cs6wxD16DQtIKw/YXxt5E0UQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - typescript: '>=4.8.4 <5.9.0' + typescript: '>=4.8.4 <6.0.0' - '@typescript-eslint/utils@8.38.0': - resolution: {integrity: sha512-hHcMA86Hgt+ijJlrD8fX0j1j8w4C92zue/8LOPAFioIno+W0+L7KqE8QZKCcPGc/92Vs9x36w/4MPTJhqXdyvg==} + '@typescript-eslint/utils@8.41.0': + resolution: {integrity: sha512-udbCVstxZ5jiPIXrdH+BZWnPatjlYwJuJkDA4Tbo3WyYLh8NvB+h/bKeSZHDOFKfphsZYJQqaFtLeXEqurQn1A==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 - typescript: '>=4.8.4 <5.9.0' + typescript: '>=4.8.4 <6.0.0' '@typescript-eslint/visitor-keys@5.62.0': resolution: {integrity: sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - '@typescript-eslint/visitor-keys@8.38.0': - resolution: {integrity: sha512-pWrTcoFNWuwHlA9CvlfSsGWs14JxfN1TH25zM5L7o0pRLhsoZkDnTsXfQRJBEWJoV5DL0jf+Z+sxiud+K0mq1g==} + '@typescript-eslint/visitor-keys@8.41.0': + resolution: {integrity: sha512-+GeGMebMCy0elMNg67LRNoVnUFPIm37iu5CmHESVx56/9Jsfdpsvbv605DQ81Pi/x11IdKUsS5nzgTYbCQU9fg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@typespec/ts-http-runtime@0.3.0': + resolution: {integrity: sha512-sOx1PKSuFwnIl7z4RN0Ls7N9AQawmR9r66eI5rFCzLDIs8HTIYrIpH9QjYWoX0lkgGrkLxXhi4QnK7MizPRrIg==} + engines: {node: '>=20.0.0'} + '@unrs/resolver-binding-android-arm-eabi@1.11.1': resolution: {integrity: sha512-ppLRUgHVaGRWUx0R0Ut06Mjo9gBaBkg3v/8AxusGLhsIotbBLuRk51rAzqLC8gq6NyyAojEXglNjzf6R948DNw==} cpu: [arm] @@ -1389,22 +2488,46 @@ packages: peerDependencies: vitest: 3.2.4 + abort-controller@3.0.0: + resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==} + engines: {node: '>=6.5'} + + accepts@1.3.8: + resolution: {integrity: sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==} + engines: {node: '>= 0.6'} + acorn-jsx@5.3.2: resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} peerDependencies: acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 + acorn-walk@8.3.2: + resolution: {integrity: sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==} + engines: {node: '>=0.4.0'} + + acorn@8.14.0: + resolution: {integrity: sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==} + engines: {node: '>=0.4.0'} + hasBin: true + acorn@8.15.0: resolution: {integrity: sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==} engines: {node: '>=0.4.0'} hasBin: true + agent-base@7.1.4: + resolution: {integrity: sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==} + engines: {node: '>= 14'} + ajv@6.12.6: resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==} ajv@8.17.1: resolution: {integrity: sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==} + anser@1.4.10: + resolution: {integrity: sha512-hCv9AqTQ8ycjpSd3upOJd7vFwW1JaoYQ7tpham03GJ1ca8/65rqn0RpaWpItOAd6ylW9wAw6luXYPJIyPFVOww==} + ansi-colors@4.1.3: resolution: {integrity: sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==} engines: {node: '>=6'} @@ -1413,8 +2536,8 @@ packages: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} - ansi-regex@6.1.0: - resolution: {integrity: sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==} + ansi-regex@6.2.0: + resolution: {integrity: sha512-TKY5pyBkHyADOPYlRT9Lx6F544mPl0vS5Ew7BJ45hA08Q+t3GjbueLliBWN3sMICk6+y7HdyxSzC4bWS8baBdg==} engines: {node: '>=12'} ansi-styles@4.3.0: @@ -1429,6 +2552,10 @@ packages: resolution: {integrity: sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==} engines: {node: '>=12'} + ansis@4.1.0: + resolution: {integrity: sha512-BGcItUBWSMRgOCe+SVZJ+S7yTRG0eGt9cXAHev72yuGcY23hnLA7Bky5L/xLyPINoSN95geovfBkqoTlNZYa7w==} + engines: {node: '>=14'} + any-promise@1.3.0: resolution: {integrity: sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==} @@ -1439,6 +2566,14 @@ packages: app-module-path@2.2.0: resolution: {integrity: sha512-gkco+qxENJV+8vFcDiiFhuoSvRXb2a/QPqpSoWhVz829VNJfOTnELbBmPmNKFxf3xdNnw4DWCkzkDaavcX/1YQ==} + archiver-utils@5.0.2: + resolution: {integrity: sha512-wuLJMmIBQYCsGZgYLTy5FIB2pF6Lfb6cXMSF8Qywwk3t20zWnAi7zLcQFdKQmIB8wyZpY5ER38x08GbwtR2cLA==} + engines: {node: '>= 14'} + + archiver@7.0.1: + resolution: {integrity: sha512-ZcbTaIqJOfCc03QwD468Unz/5Ir8ATtvAHsK+FdXbDIbGfihqh9mrvdcYunQzqn4HrvWWaFyaxJhGZagaJJpPQ==} + engines: {node: '>= 14'} + argparse@1.0.10: resolution: {integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==} @@ -1455,6 +2590,12 @@ packages: resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} engines: {node: '>=8'} + asap@2.0.6: + resolution: {integrity: sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==} + + asn1@0.2.6: + resolution: {integrity: sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==} + assertion-error@2.0.1: resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} engines: {node: '>=12'} @@ -1471,35 +2612,140 @@ packages: resolution: {integrity: sha512-6t10qk83GOG8p0vKmaCr8eiilZwO171AvbROMtvvNiwrTly62t+7XkA8RdIIVbpMhCASAsxgAzdRSwh6nw/5Dg==} engines: {node: '>=4'} - ast-v8-to-istanbul@0.3.3: - resolution: {integrity: sha512-MuXMrSLVVoA6sYN/6Hke18vMzrT4TZNbZIj/hvh0fnYFpO+/kFXcLIaiPwXXWaQUPg4yJD8fj+lfJ7/1EBconw==} + ast-v8-to-istanbul@0.3.4: + resolution: {integrity: sha512-cxrAnZNLBnQwBPByK4CeDaw5sWZtMilJE/Q3iDA0aamgaIVNDF9T6K2/8DfYDZEejZ2jNnDrG9m8MY72HFd0KA==} + + async-limiter@1.0.1: + resolution: {integrity: sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==} + + async-lock@1.4.1: + resolution: {integrity: sha512-Az2ZTpuytrtqENulXwO3GGv1Bztugx6TT37NIo7imr/Qo0gsYiGtSdBa2B6fsXhTpVZDNfu1Qn3pk531e3q+nQ==} + + async@3.2.6: + resolution: {integrity: sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==} autolinker@0.28.1: resolution: {integrity: sha512-zQAFO1Dlsn69eXaO6+7YZc+v84aquQKbwpzCE3L0stj56ERn9hutFxPopViLjo9G+rWwjozRhgS5KJ25Xy19cQ==} + aws-ssl-profiles@1.1.2: + resolution: {integrity: sha512-NZKeq9AfyQvEeNlN0zSYAaWrmBffJh3IELMZfRpJVWgrpEbtEpnjvzqBPf+mxoI287JohRDoa+/nsfqqiZmF6g==} + engines: {node: '>= 6.0.0'} + + b4a@1.6.7: + resolution: {integrity: sha512-OnAYlL5b7LEkALw87fUVafQw5rVR9RjwGd4KUwNQ6DrrNmaVaUCgLipfVlzrPQ4tWOR9P0IXGNOx50jYCCdSJg==} + + babel-jest@29.7.0: + resolution: {integrity: sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + peerDependencies: + '@babel/core': ^7.8.0 + babel-plugin-annotate-pure-calls@0.5.0: resolution: {integrity: sha512-bWlaZl2qsJKHv9BJgF1g6bQ04wK/7Topq9g59I795W9jpx9lNs9N5LK5NjlEBCDhHncrO0vcoAMuHJR3oWnTeQ==} engines: {node: '>=18'} peerDependencies: '@babel/core': ^7.0.0 + babel-plugin-istanbul@6.1.1: + resolution: {integrity: sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==} + engines: {node: '>=8'} + + babel-plugin-jest-hoist@29.6.3: + resolution: {integrity: sha512-ESAc/RJvGTFEzRwOTT4+lNDk/GNHMkKbNzsvT0qKRfDyyYTskxB5rnU2njIDYVxXCBHHEI1c0YwHob3WaYujOg==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + babel-plugin-polyfill-corejs2@0.4.14: + resolution: {integrity: sha512-Co2Y9wX854ts6U8gAAPXfn0GmAyctHuK8n0Yhfjd6t30g7yvKjspvvOo9yG+z52PZRgFErt7Ka2pYnXCjLKEpg==} + peerDependencies: + '@babel/core': ^7.4.0 || ^8.0.0-0 <8.0.0 + + babel-plugin-polyfill-corejs3@0.13.0: + resolution: {integrity: sha512-U+GNwMdSFgzVmfhNm8GJUX88AadB3uo9KpJqS3FaqNIPKgySuvMb+bHPsOmmuWyIcuqZj/pzt1RUIUZns4y2+A==} + peerDependencies: + '@babel/core': ^7.4.0 || ^8.0.0-0 <8.0.0 + + babel-plugin-polyfill-regenerator@0.6.5: + resolution: {integrity: sha512-ISqQ2frbiNU9vIJkzg7dlPpznPZ4jOiUQ1uSmB0fEHeowtN3COYRsXr/xexn64NpU13P06jc/L5TgiJXOgrbEg==} + peerDependencies: + '@babel/core': ^7.4.0 || ^8.0.0-0 <8.0.0 + + babel-plugin-syntax-hermes-parser@0.29.1: + resolution: {integrity: sha512-2WFYnoWGdmih1I1J5eIqxATOeycOqRwYxAQBu3cUu/rhwInwHUg7k60AFNbuGjSDL8tje5GDrAnxzRLcu2pYcA==} + + babel-plugin-transform-flow-enums@0.0.2: + resolution: {integrity: sha512-g4aaCrDDOsWjbm0PUUeVnkcVd6AKJsVc/MbnPhEotEpkeJQP6b8nzewohQi7+QS8UyPehOhGWn0nOwjvWpmMvQ==} + + babel-preset-current-node-syntax@1.2.0: + resolution: {integrity: sha512-E/VlAEzRrsLEb2+dv8yp3bo4scof3l9nR4lrld+Iy5NyVqgVYUJnDAmunkhPMisRI32Qc4iRiz425d8vM++2fg==} + peerDependencies: + '@babel/core': ^7.0.0 || ^8.0.0-0 + + babel-preset-jest@29.6.3: + resolution: {integrity: sha512-0B3bhxR6snWXJZtR/RliHTDPRgn1sNHOR0yVtq/IiQFyuOVjFS+wuio/R4gSNkyYmKmJB4wGZv2NZanmKmTnNA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + peerDependencies: + '@babel/core': ^7.0.0 + balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} + bare-events@2.6.1: + resolution: {integrity: sha512-AuTJkq9XmE6Vk0FJVNq5QxETrSA/vKHarWVBG5l/JbdCL1prJemiyJqUS0jrlXO0MftuPq4m3YVYhoNc5+aE/g==} + + bare-fs@4.2.1: + resolution: {integrity: sha512-mELROzV0IhqilFgsl1gyp48pnZsaV9xhQapHLDsvn4d4ZTfbFhcghQezl7FTEDNBcGqLUnNI3lUlm6ecrLWdFA==} + engines: {bare: '>=1.16.0'} + peerDependencies: + bare-buffer: '*' + peerDependenciesMeta: + bare-buffer: + optional: true + + bare-os@3.6.2: + resolution: {integrity: sha512-T+V1+1srU2qYNBmJCXZkUY5vQ0B4FSlL3QDROnKQYOqeiQR8UbjNHlPa+TIbM4cuidiN9GaTaOZgSEgsvPbh5A==} + engines: {bare: '>=1.14.0'} + + bare-path@3.0.0: + resolution: {integrity: sha512-tyfW2cQcB5NN8Saijrhqn0Zh7AnFNsnczRcuWODH0eYAXBsJ5gVxAUuNr7tsHSC6IZ77cA0SitzT+s47kot8Mw==} + + bare-stream@2.7.0: + resolution: {integrity: sha512-oyXQNicV1y8nc2aKffH+BUHFRXmx6VrPzlnaEvMhram0nPBrKcEdcyBg5r08D0i8VxngHFAiVyn1QKXpSG0B8A==} + peerDependencies: + bare-buffer: '*' + bare-events: '*' + peerDependenciesMeta: + bare-buffer: + optional: true + bare-events: + optional: true + base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} + bcrypt-pbkdf@1.0.2: + resolution: {integrity: sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==} + better-path-resolve@1.0.0: resolution: {integrity: sha512-pbnl5XzGBdrFU/wT4jqmJVPn2B6UHPBOhzMQkY/SPUPB6QtUXtmBHBIwCbXJol93mOpGMnQyP/+BB19q04xj7g==} engines: {node: '>=4'} + better-sqlite3@12.2.0: + resolution: {integrity: sha512-eGbYq2CT+tos1fBwLQ/tkBt9J5M3JEHjku4hbvQUePCckkvVf14xWj+1m7dGoK81M/fOjFT7yM9UMeKT/+vFLQ==} + engines: {node: 20.x || 22.x || 23.x || 24.x} + binary-extensions@2.3.0: resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} engines: {node: '>=8'} + bindings@1.5.0: + resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==} + bl@4.1.0: resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} + bl@6.1.2: + resolution: {integrity: sha512-6J3oG82fpJ71WF4l0W6XslkwAPMr+Zcp+AmdxJ0L8LsXNzFeO8GYesV2J9AzGArBjrsb2xR50Ocbn/CL1B44TA==} + brace-expansion@1.1.12: resolution: {integrity: sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==} @@ -1510,43 +2756,88 @@ packages: resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} engines: {node: '>=8'} - browserslist@4.25.1: - resolution: {integrity: sha512-KGj0KoOMXLpSNkkEI6Z6mShmQy0bc1I+T7K9N81k4WWMrfz+6fQ6es80B/YLAeRoKvjYE1YSHHOW1qe9xIVzHw==} + browserslist@4.25.3: + resolution: {integrity: sha512-cDGv1kkDI4/0e5yON9yM5G/0A5u8sf5TnmdX5C9qHzI9PPu++sQ9zjm1k9NiOrf3riY4OkK0zSGqfvJyJsgCBQ==} engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true + bser@2.1.1: + resolution: {integrity: sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==} + + buffer-crc32@1.0.0: + resolution: {integrity: sha512-Db1SbgBS/fg/392AblrMJk97KggmvYhr4pB5ZIMTWtaivCPMWLkmb7m21cJvpvgK+J3nsU2CmmixNBZx4vFj/w==} + engines: {node: '>=8.0.0'} + + buffer-equal-constant-time@1.0.1: + resolution: {integrity: sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==} + buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} buffer@5.7.1: resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} - bun-types@1.2.19: - resolution: {integrity: sha512-uAOTaZSPuYsWIXRpj7o56Let0g/wjihKCkeRqUBhlLVM/Bt+Fj9xTo+LhC1OV1XDaGkz4hNC80et5xgy+9KTHQ==} + buffer@6.0.3: + resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==} + + buildcheck@0.0.6: + resolution: {integrity: sha512-8f9ZJCUXyT1M35Jx7MkBgmBMo3oHTTBIPLiY9xyL0pl3T5RwcPEY8cUHr5LBNfu/fk6c2T4DJZuVM/8ZZT2D2A==} + engines: {node: '>=10.0.0'} + + bun-types@1.2.21: + resolution: {integrity: sha512-sa2Tj77Ijc/NTLS0/Odjq/qngmEPZfbfnOERi0KRUYhT9R8M4VBioWVmMWE5GrYbKMc+5lVybXygLdibHaqVqw==} peerDependencies: '@types/react': ^19 + bundle-name@4.1.0: + resolution: {integrity: sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q==} + engines: {node: '>=18'} + + byline@5.0.0: + resolution: {integrity: sha512-s6webAy+R4SR8XVuJWt2V2rGvhnrhxN+9S15GNuTK3wKPOXFF6RNc+8ug2XhH+2s4f+uudG4kUVYmYOQWL2g0Q==} + engines: {node: '>=0.10.0'} + cac@6.7.14: resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} engines: {node: '>=8'} + caller-callsite@2.0.0: + resolution: {integrity: sha512-JuG3qI4QOftFsZyOn1qq87fq5grLIyk1JYd5lJmdA+fG7aQ9pA/i3JIJGcO3q0MrRcHlOt1U+ZeHW8Dq9axALQ==} + engines: {node: '>=4'} + + caller-path@2.0.0: + resolution: {integrity: sha512-MCL3sf6nCSXOwCTzvPKhN18TU7AHTvdtam8DAogxcrJ8Rjfbbg7Lgng64H9Iy+vUV6VGFClN/TyxBkAebLRR4A==} + engines: {node: '>=4'} + + callsites@2.0.0: + resolution: {integrity: sha512-ksWePWBloaWPxJYQ8TL0JHvtci6G5QTKwQ95RcWAa/lzoAKuAOflGdAK92hpHXjkwb8zLxoLNUoNYZgVsaJzvQ==} + engines: {node: '>=4'} + callsites@3.1.0: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} - caniuse-lite@1.0.30001727: - resolution: {integrity: sha512-pB68nIHmbN6L/4C6MH1DokyR3bYqFwjaSs/sWDHGj4CTcFtQUQMuJftVwWkXq7mNWOybD3KhUv3oWHoGxgP14Q==} + camelcase@5.3.1: + resolution: {integrity: sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==} + engines: {node: '>=6'} - chai@5.2.1: - resolution: {integrity: sha512-5nFxhUrX0PqtyogoYOA8IPswy5sZFTOsBFl/9bNsmDLgsxYTzSZQJDPppDnZPTQbzSEm0hqGjWPzRemQCYbD6A==} + camelcase@6.3.0: + resolution: {integrity: sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==} + engines: {node: '>=10'} + + caniuse-lite@1.0.30001737: + resolution: {integrity: sha512-BiloLiXtQNrY5UyF0+1nSJLXUENuhka2pzy2Fx5pGxqavdrxSCW4U6Pn/PoG3Efspi2frRbHpBV2XsrPE6EDlw==} + + chai@5.3.3: + resolution: {integrity: sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==} engines: {node: '>=18'} chalk@4.1.2: resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} engines: {node: '>=10'} - chardet@0.7.0: - resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==} + chardet@2.1.0: + resolution: {integrity: sha512-bNFETTG/pM5ryzQ9Ad0lJOTa6HWD/YsScAR3EnCPZRPlQh77JocYktSHOUHelyhm8IARL+o4c4F1bP5KVOjiRA==} check-error@2.1.1: resolution: {integrity: sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==} @@ -1556,10 +2847,24 @@ packages: resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} engines: {node: '>= 8.10.0'} + chownr@1.1.4: + resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==} + chownr@3.0.0: resolution: {integrity: sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==} engines: {node: '>=18'} + chrome-launcher@0.15.2: + resolution: {integrity: sha512-zdLEwNo3aUVzIhKhTtXfxhdvZhUghrnmkvcAq2NoDd+LeOHKf03H5jwZ8T/STsAlzyALkBVK552iaG1fGf1xVQ==} + engines: {node: '>=12.13.0'} + hasBin: true + + chromium-edge-launcher@0.2.0: + resolution: {integrity: sha512-JfJjUnq25y9yg4FABRRVPmBGWPZZi+AQXT4mxupb67766/0UlhG8PAZCz6xzEMXTbW3CsSoE8PcCWA49n35mKg==} + + ci-info@2.0.0: + resolution: {integrity: sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==} + ci-info@3.9.0: resolution: {integrity: sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==} engines: {node: '>=8'} @@ -1591,10 +2896,21 @@ packages: color-name@1.1.4: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} + color-string@1.9.1: + resolution: {integrity: sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==} + + color@4.2.3: + resolution: {integrity: sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==} + engines: {node: '>=12.5.0'} + commander@10.0.1: resolution: {integrity: sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==} engines: {node: '>=14'} + commander@12.1.0: + resolution: {integrity: sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==} + engines: {node: '>=18'} + commander@2.20.3: resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} @@ -1613,6 +2929,10 @@ packages: commondir@1.0.1: resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} + compress-commons@6.0.2: + resolution: {integrity: sha512-6FqVXeETqWPoGcfzrXb37E50NP0LXT8kAMu5ooZayhWWdgEY4lBEEcbQNXtkuKQsGduxiIcI4gOTsxTmuq/bSg==} + engines: {node: '>= 14'} + concat-map@0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} @@ -1623,15 +2943,43 @@ packages: concat-with-sourcemaps@1.1.0: resolution: {integrity: sha512-4gEjHJFT9e+2W/77h/DS5SGUgwDaOwprX8L/gl5+3ixnzkVJJsZWDSelmN3Oilw3LNDZjZV0yqH1hLG3k6nghg==} + connect@3.7.0: + resolution: {integrity: sha512-ZqRXc+tZukToSNmh5C2iWMSoV3X1YUcPbqEM4DkEG5tNQXrQUZCNVGGv3IuicnkMtPfGf3Xtp8WCXs295iQ1pQ==} + engines: {node: '>= 0.10.0'} + convert-source-map@2.0.0: resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} - core-js@3.44.0: - resolution: {integrity: sha512-aFCtd4l6GvAXwVEh3XbbVqJGHDJt0OZRa+5ePGx3LLwi12WfexqQxcsohb2wgsa/92xtl19Hd66G/L+TaAxDMw==} + cookie@1.0.2: + resolution: {integrity: sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==} + engines: {node: '>=18'} + + core-js-compat@3.45.1: + resolution: {integrity: sha512-tqTt5T4PzsMIZ430XGviK4vzYSoeNJ6CXODi6c/voxOT6IZqBht5/EKaSNnYiEjjRYxjVz7DQIsOsY0XNi8PIA==} + + core-js@3.45.1: + resolution: {integrity: sha512-L4NPsJlCfZsPeXukyzHFlg/i7IIVwHSItR0wg0FLNqYClJ4MQYTYLbC7EkjKYRLZF2iof2MUgN0EGy7MdQFChg==} core-util-is@1.0.3: resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} + cosmiconfig@5.2.1: + resolution: {integrity: sha512-H65gsXo1SKjf8zmrJ67eJk8aIRKV5ff2D4uKZIBZShbhGSpEmsQOPW/SKMKYhSTrqR7ufy6RP69rPogdaPh/kA==} + engines: {node: '>=4'} + + cpu-features@0.0.10: + resolution: {integrity: sha512-9IkYqtX3YHPCzoVg1Py+o9057a3i0fp7S530UWokCSaFVTc7CwXPRiOjRjBQQ18ZCNafx78YfnG+HALxtVmOGA==} + engines: {node: '>=10.0.0'} + + crc-32@1.2.2: + resolution: {integrity: sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==} + engines: {node: '>=0.8'} + hasBin: true + + crc32-stream@6.0.0: + resolution: {integrity: sha512-piICUB6ei4IlTv1+653yq5+KoqfBYmj9bw6LqXoOneTMDXk5nM1qt12mFW1caG3LlJXEKW1Bp0WggEmIfQB34g==} + engines: {node: '>= 14'} + cross-spawn@7.0.6: resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} engines: {node: '>= 8'} @@ -1639,9 +2987,21 @@ packages: csstype@3.1.3: resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==} + data-uri-to-buffer@4.0.1: + resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==} + engines: {node: '>= 12'} + dataloader@1.4.0: resolution: {integrity: sha512-68s5jYdlvasItOJnCuI2Q9s4q98g0pCyL3HrcKJu8KNugUl8ahgmZYg38ysLTgQjjXX3H8CJLkAvWrclWfcalw==} + debug@2.6.9: + resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + debug@4.4.1: resolution: {integrity: sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==} engines: {node: '>=6.0'} @@ -1651,6 +3011,10 @@ packages: supports-color: optional: true + decompress-response@6.0.0: + resolution: {integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==} + engines: {node: '>=10'} + deep-eql@5.0.2: resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==} engines: {node: '>=6'} @@ -1666,6 +3030,14 @@ packages: resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} engines: {node: '>=0.10.0'} + default-browser-id@5.0.0: + resolution: {integrity: sha512-A6p/pu/6fyBcA1TRz/GqWYPViplrftcW2gZC9q79ngNCKAeR/X3gcEdXQHl4KNXV+3wgIJ1CPkJQ3IHM6lcsyA==} + engines: {node: '>=18'} + + default-browser@5.2.1: + resolution: {integrity: sha512-WY/3TUME0x3KPYdRRxEJJvXRHV4PyPoUsxtZa78lwItwRQRHhd2U9xOscaT/YTf8uCXIAjeJOFBVEh/7FtD8Xg==} + engines: {node: '>=18'} + defaults@1.0.4: resolution: {integrity: sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==} @@ -1673,6 +3045,18 @@ packages: resolution: {integrity: sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==} engines: {node: '>=8'} + define-lazy-prop@3.0.0: + resolution: {integrity: sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==} + engines: {node: '>=12'} + + denque@2.1.0: + resolution: {integrity: sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==} + engines: {node: '>=0.10'} + + depd@2.0.0: + resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==} + engines: {node: '>= 0.8'} + dependency-tree@10.0.9: resolution: {integrity: sha512-dwc59FRIsht+HfnTVM0BCjJaEWxdq2YAvEDy4/Hn6CwS3CBWMtFnL3aZGAkQn3XCYxk/YcTDE4jX2Q7bFTwCjA==} engines: {node: '>=14'} @@ -1682,10 +3066,18 @@ packages: resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} engines: {node: '>=6'} + destroy@1.2.0: + resolution: {integrity: sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==} + engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16} + detect-indent@6.1.0: resolution: {integrity: sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==} engines: {node: '>=8'} + detect-libc@2.0.2: + resolution: {integrity: sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==} + engines: {node: '>=8'} + detect-libc@2.0.4: resolution: {integrity: sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==} engines: {node: '>=8'} @@ -1731,6 +3123,18 @@ packages: resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} engines: {node: '>=8'} + docker-compose@1.2.0: + resolution: {integrity: sha512-wIU1eHk3Op7dFgELRdmOYlPYS4gP8HhH1ZmZa13QZF59y0fblzFDFmKPhyc05phCy2hze9OEvNZAsoljrs+72w==} + engines: {node: '>= 6.0.0'} + + docker-modem@5.0.6: + resolution: {integrity: sha512-ens7BiayssQz/uAxGzH8zGXCtiV24rRWXdjNha5V4zSOcxmAZsfGVm/PPFbwQdqEkDnhG+SyR9E3zSHUbOKXBQ==} + engines: {node: '>= 8.0'} + + dockerode@4.0.7: + resolution: {integrity: sha512-R+rgrSRTRdU5mH14PZTCPZtW/zw3HDWNTS/1ZAQpL/5Upe/ye5K9WQkIysu4wBoiMwKynsz0a8qWuGsHgEvSAA==} + engines: {node: '>= 8.0'} + doctrine@3.0.0: resolution: {integrity: sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==} engines: {node: '>=6.0.0'} @@ -1745,8 +3149,14 @@ packages: eastasianwidth@0.2.0: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} - electron-to-chromium@1.5.190: - resolution: {integrity: sha512-k4McmnB2091YIsdCgkS0fMVMPOJgxl93ltFzaryXqwip1AaxeDqKCGLxkXODDA5Ab/D+tV5EL5+aTx76RvLRxw==} + ecdsa-sig-formatter@1.0.11: + resolution: {integrity: sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==} + + ee-first@1.1.1: + resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==} + + electron-to-chromium@1.5.209: + resolution: {integrity: sha512-Xoz0uMrim9ZETCQt8UgM5FxQF9+imA7PBpokoGcZloA1uw2LeHzTlip5cb5KOAsXZLjh/moN2vReN3ZjJmjI9A==} emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} @@ -1754,19 +3164,39 @@ packages: emoji-regex@9.2.2: resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} - enhanced-resolve@5.18.2: - resolution: {integrity: sha512-6Jw4sE1maoRJo3q8MsSIn2onJFbLTOjY9hlx4DZXmOKvLRd1Ok2kXmAGXaafL2+ijsJZ1ClYbl/pmqr9+k4iUQ==} + encodeurl@1.0.2: + resolution: {integrity: sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==} + engines: {node: '>= 0.8'} + + encodeurl@2.0.0: + resolution: {integrity: sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==} + engines: {node: '>= 0.8'} + + end-of-stream@1.4.5: + resolution: {integrity: sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==} + + enhanced-resolve@5.18.3: + resolution: {integrity: sha512-d4lC8xfavMeBjzGr2vECC3fsGXziXZQyJxD868h2M/mBI3PwAuODxAkLkq5HYuvrPYcUtiLzsTo8U3PgX3Ocww==} engines: {node: '>=10.13.0'} enquirer@2.4.1: resolution: {integrity: sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==} engines: {node: '>=8.6'} + error-ex@1.3.2: + resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==} + + error-stack-parser-es@1.0.5: + resolution: {integrity: sha512-5qucVt2XcuGMcEGgWI7i+yZpmpByQ8J1lHhcL7PwqCwu9FPP3VUXzT4ltHe5i2z9dePwEHcDVOAfSnHsOlCXRA==} + + error-stack-parser@2.1.4: + resolution: {integrity: sha512-Sk5V6wVazPhq5MhpO+AUxJn5x7XSXGl1R93Vn7i+zS15KDVxQijejNCrz8340/2bgLBjR9GtEG8ZVKONDjcqGQ==} + es-module-lexer@1.7.0: resolution: {integrity: sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==} - esbuild@0.25.8: - resolution: {integrity: sha512-vVC0USHGtMi8+R4Kz8rt6JhEWLxsv9Rnu/lGYbPR8u47B+DCBksq9JarW0zOO7bs37hyOK1l2/oqtbciutL5+Q==} + esbuild@0.25.9: + resolution: {integrity: sha512-CRbODhYyQx3qp7ZEwzxOk4JBqmD/seJrzPa/cGjY1VtIn5E09Oi9/dB4JwctnfZ8Q8iT7rioVv5k/FNT/uf54g==} engines: {node: '>=18'} hasBin: true @@ -1774,6 +3204,13 @@ packages: resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} engines: {node: '>=6'} + escape-html@1.0.3: + resolution: {integrity: sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==} + + escape-string-regexp@2.0.0: + resolution: {integrity: sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==} + engines: {node: '>=8'} + escape-string-regexp@4.0.0: resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} engines: {node: '>=10'} @@ -1844,8 +3281,8 @@ packages: resolution: {integrity: sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - eslint@9.31.0: - resolution: {integrity: sha512-QldCVh/ztyKJJZLr4jXNUByx3gR+TDYZCRXEktiZoUR3PGy4qCmSbkxcIle8GEwGpb5JBZazlaJ/CxLidXdEbQ==} + eslint@9.34.0: + resolution: {integrity: sha512-RNCHRX5EwdrESy3Jc9o8ie8Bog+PeYvvSR8sDGoZxNFTvZ4dlxUB3WzQ3bQMztFrSRODGrLLj8g6OFuGY/aiQg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} hasBin: true peerDependencies: @@ -1885,14 +3322,37 @@ packages: resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} engines: {node: '>=0.10.0'} + etag@1.8.1: + resolution: {integrity: sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==} + engines: {node: '>= 0.6'} + + event-target-shim@5.0.1: + resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==} + engines: {node: '>=6'} + + events@3.3.0: + resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} + engines: {node: '>=0.8.x'} + + exit-hook@2.2.1: + resolution: {integrity: sha512-eNTPlAD67BmP31LDINZ3U7HSF8l57TxOY2PmBJ1shpCvpnxBF93mWCE8YHBnXs8qiUZJc9WDcWIeC3a2HIAMfw==} + engines: {node: '>=6'} + expand-range@1.8.2: resolution: {integrity: sha512-AFASGfIlnIbkKPQwX1yHaDjFvh/1gyKJODme52V6IORh69uEYgZp0o9C+qsIGNVEiuuhQU0CSSl++Rlegg1qvA==} engines: {node: '>=0.10.0'} + expand-template@2.0.3: + resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==} + engines: {node: '>=6'} + expect-type@1.2.2: resolution: {integrity: sha512-JhFGDVJ7tmDJItKhYgJCGLOWjuK9vPxiXoUFLwLDc99NlmklilbiQJwoctZtt13+xMw91MCk/REan6MWHqDjyA==} engines: {node: '>=12.0.0'} + exponential-backoff@3.1.2: + resolution: {integrity: sha512-8QxYTVXUkuy7fIIoitQkPwGonB8F3Zj8eEO8Sqg9Zv/bkI7RJAzowee4gr81Hak/dUTpA2Z7VfQgoijjPNlUZA==} + extend-shallow@2.0.1: resolution: {integrity: sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==} engines: {node: '>=0.10.0'} @@ -1900,10 +3360,6 @@ packages: extendable-error@0.1.7: resolution: {integrity: sha512-UOiS2in6/Q0FK0R0q6UY9vYpQ21mr/Qn1KOnte7vsACuNJf514WvCCUHSRCPcgjPT2bAhNIJdlE6bVap1GKmeg==} - external-editor@3.1.0: - resolution: {integrity: sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==} - engines: {node: '>=4'} - fast-check@4.2.0: resolution: {integrity: sha512-buxrKEaSseOwFjt6K1REcGMeFOrb0wk3cXifeMAG8yahcE9kV20PjQn1OdzPGL6OBFTbYXfjleNBARf/aCfV1A==} engines: {node: '>=12.17.0'} @@ -1914,6 +3370,9 @@ packages: fast-diff@1.3.0: resolution: {integrity: sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==} + fast-fifo@1.3.2: + resolution: {integrity: sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==} + fast-glob@3.3.3: resolution: {integrity: sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==} engines: {node: '>=8.6.0'} @@ -1924,24 +3383,35 @@ packages: fast-levenshtein@2.0.6: resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} - fast-uri@3.0.6: - resolution: {integrity: sha512-Atfo14OibSv5wAp4VWNsFYE1AchQRTv9cBGWET4pZWHzYshFSS9NQI6I57rdKn9croWVMbYFbLhJ+yJvmZIIHw==} + fast-uri@3.1.0: + resolution: {integrity: sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==} fastq@1.19.1: resolution: {integrity: sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==} - fdir@6.4.6: - resolution: {integrity: sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w==} + fb-watchman@2.0.2: + resolution: {integrity: sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==} + + fdir@6.5.0: + resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} + engines: {node: '>=12.0.0'} peerDependencies: picomatch: ^3 || ^4 peerDependenciesMeta: picomatch: optional: true + fetch-blob@3.2.0: + resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==} + engines: {node: ^12.20 || >= 14.13} + file-entry-cache@8.0.0: resolution: {integrity: sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==} engines: {node: '>=16.0.0'} + file-uri-to-path@1.0.0: + resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==} + filing-cabinet@4.2.0: resolution: {integrity: sha512-YZ21ryzRcyqxpyKggdYSoXx//d3sCJzM3lsYoaeg/FyXdADGJrUl+BW1KIglaVLJN5BBcMtWylkygY8zBp2MrQ==} engines: {node: '>=14'} @@ -1955,6 +3425,10 @@ packages: resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} engines: {node: '>=8'} + finalhandler@1.1.2: + resolution: {integrity: sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==} + engines: {node: '>= 0.8'} + find-cache-dir@2.1.0: resolution: {integrity: sha512-Tq6PixE0w/VMFfCgbONnkiQIVol/JJL7nRMi20fqzA4NRs9AfeqMGeRdPi3wIhYkxjeBaWh2rxwapn5Tu3IqOQ==} engines: {node: '>=6'} @@ -1985,8 +3459,11 @@ packages: flatted@3.3.3: resolution: {integrity: sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==} - flow-parser@0.277.0: - resolution: {integrity: sha512-VSmZNRzdayHfb1st+A6cyhqRJfdHy6pEq7p3AET8E3p59D2YFj91n+gjALFR2CuLrGmZM6VR+x/L8OrV+vmwvw==} + flow-enums-runtime@0.0.6: + resolution: {integrity: sha512-3PYnM29RFXwvAN6Pc/scUfkI7RwhQ/xqyLUyPNlXUp9S40zI8nup9tUSrTLSVnWGBN38FNiGWbwZOB6uR4OGdw==} + + flow-parser@0.279.0: + resolution: {integrity: sha512-41VremrzImoLcZuqY18U86ojcVy2Stuq4VnjdAcxHjGanvx3VmKVUITIVMt2PM1RvmRJtgtJWvCxVpQ1E9OGDw==} engines: {node: '>=0.4.0'} for-in@1.0.2: @@ -1997,6 +3474,17 @@ packages: resolution: {integrity: sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==} engines: {node: '>=14'} + formdata-polyfill@4.0.10: + resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==} + engines: {node: '>=12.20.0'} + + fresh@0.5.2: + resolution: {integrity: sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==} + engines: {node: '>= 0.6'} + + fs-constants@1.0.0: + resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} + fs-extra@7.0.1: resolution: {integrity: sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==} engines: {node: '>=6 <7 || >=8'} @@ -2024,6 +3512,9 @@ packages: function-bind@1.1.2: resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} + generate-function@2.3.1: + resolution: {integrity: sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ==} + gensync@1.0.0-beta.2: resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} engines: {node: '>=6.9.0'} @@ -2039,9 +3530,20 @@ packages: get-own-enumerable-property-symbols@3.0.2: resolution: {integrity: sha512-I0UBV/XOz1XkIJHEUDMZAbzCThU/H8DxmSfmdGcKPnVhu2VfFqr34jr9777IyaTYvxjedWhqVIilEDsCdP5G6g==} + get-package-type@0.1.0: + resolution: {integrity: sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==} + engines: {node: '>=8.0.0'} + + get-port@7.1.0: + resolution: {integrity: sha512-QB9NKEeDg3xxVwCCwJQ9+xycaz6pBB6iQ76wiWMl1927n0Kir6alPiP+yuiICLLU4jpMe08dXfpebuQppFA2zw==} + engines: {node: '>=16'} + get-tsconfig@4.10.1: resolution: {integrity: sha512-auHyJ4AgMz7vgS8Hp3N6HXSmlMdUyhSUrfBF16w153rxtLIEOE+HGqaBppczZvnHLqQJfiHotCYpNhl0lUROFQ==} + github-from-package@0.0.0: + resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==} + glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -2050,6 +3552,9 @@ packages: resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==} engines: {node: '>=10.13.0'} + glob-to-regexp@0.4.1: + resolution: {integrity: sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==} + glob@10.4.5: resolution: {integrity: sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==} hasBin: true @@ -2075,6 +3580,9 @@ packages: resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} engines: {node: '>=10'} + globrex@0.1.2: + resolution: {integrity: sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==} + gonzales-pe@4.3.0: resolution: {integrity: sha512-otgSPpUmdWJ43VXyiNgEYE4luzHCL2pz4wQ0OnDluC6Eg4Ko3Vexy/SrSynglw/eR+OhkzmqFCZa/OFa/RgAOQ==} engines: {node: '>=0.6.0'} @@ -2102,23 +3610,41 @@ packages: resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} engines: {node: '>= 0.4'} + hermes-estree@0.29.1: + resolution: {integrity: sha512-jl+x31n4/w+wEqm0I2r4CMimukLbLQEYpisys5oCre611CI5fc9TxhqkBBCJ1edDG4Kza0f7CgNz8xVMLZQOmQ==} + + hermes-parser@0.29.1: + resolution: {integrity: sha512-xBHWmUtRC5e/UL0tI7Ivt2riA/YBq9+SiYFU7C1oBa/j2jYGlIF9043oak1F47ihuDIxQ5nbsKueYJDRY02UgA==} + html-escaper@2.0.2: resolution: {integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==} + http-errors@2.0.0: + resolution: {integrity: sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==} + engines: {node: '>= 0.8'} + + http-proxy-agent@7.0.2: + resolution: {integrity: sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==} + engines: {node: '>= 14'} + + https-proxy-agent@7.0.6: + resolution: {integrity: sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==} + engines: {node: '>= 14'} + human-id@4.1.1: resolution: {integrity: sha512-3gKm/gCSUipeLsRYZbbdA1BD83lBoWUkZ7G9VFrhWPAU76KwYo5KR8V28bpoPm/ygy0x5/GCbpRQdY7VLYCoIg==} hasBin: true - i18next@25.3.2: - resolution: {integrity: sha512-JSnbZDxRVbphc5jiptxr3o2zocy5dEqpVm9qCGdJwRNO+9saUJS0/u4LnM/13C23fUEWxAylPqKU/NpMV/IjqA==} + i18next@25.4.2: + resolution: {integrity: sha512-gD4T25a6ovNXsfXY1TwHXXXLnD/K2t99jyYMCSimSCBnBRJVQr5j+VAaU83RJCPzrTGhVQ6dqIga66xO2rtd5g==} peerDependencies: typescript: ^5 peerDependenciesMeta: typescript: optional: true - iconv-lite@0.4.24: - resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} + iconv-lite@0.6.3: + resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==} engines: {node: '>=0.10.0'} ieee754@1.2.1: @@ -2132,9 +3658,18 @@ packages: resolution: {integrity: sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==} engines: {node: '>= 4'} + image-size@1.2.1: + resolution: {integrity: sha512-rH+46sQJ2dlwfjfhCyNx5thzrv+dtmBIhPHk0zgRUukHzZ/kRueTJXoYYsclBaKcSMBWuGbOFXtioLpzTb5euw==} + engines: {node: '>=16.x'} + hasBin: true + immer@10.1.1: resolution: {integrity: sha512-s2MPrmjovJcoMaHtx6K11Ra7oD05NT97w1IC5zpMkT6Atjr7H8LjaDd81iIxUYpMKSRRNMJE703M1Fhr/TctHw==} + import-fresh@2.0.0: + resolution: {integrity: sha512-eZ5H8rcgYazHbKC3PG4ClHNykCSxtAhxSSEM+2mb+7evD2CKF5V7c0dNum7AdpDh0ZdICwZY9sRSn8f+KH96sg==} + engines: {node: '>=4'} + import-fresh@3.3.1: resolution: {integrity: sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==} engines: {node: '>=6'} @@ -2157,6 +3692,15 @@ packages: resolution: {integrity: sha512-X7rqawQBvfdjS10YU1y1YVreA3SsLrW9dX2CewP2EbBJM4ypVNLDkO5y04gejPwKIY9lR+7r9gn3rFPt/kmWFg==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + invariant@2.2.4: + resolution: {integrity: sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==} + + is-arrayish@0.2.1: + resolution: {integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==} + + is-arrayish@0.3.2: + resolution: {integrity: sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==} + is-binary-path@2.1.0: resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} engines: {node: '>=8'} @@ -2171,11 +3715,20 @@ packages: resolution: {integrity: sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==} engines: {node: '>= 0.4'} + is-directory@0.3.1: + resolution: {integrity: sha512-yVChGzahRFvbkscn2MlwGismPO12i9+znNruC5gVEntG3qu0xQMzsGg/JFbrsqDOHtHFPci+V5aP5T9I+yeKqw==} + engines: {node: '>=0.10.0'} + is-docker@2.2.1: resolution: {integrity: sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==} engines: {node: '>=8'} hasBin: true + is-docker@3.0.0: + resolution: {integrity: sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + hasBin: true + is-extendable@0.1.1: resolution: {integrity: sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==} engines: {node: '>=0.10.0'} @@ -2196,6 +3749,11 @@ packages: resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} engines: {node: '>=0.10.0'} + is-inside-container@1.0.0: + resolution: {integrity: sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==} + engines: {node: '>=14.16'} + hasBin: true + is-interactive@1.0.0: resolution: {integrity: sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==} engines: {node: '>=8'} @@ -2223,6 +3781,9 @@ packages: resolution: {integrity: sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==} engines: {node: '>=0.10.0'} + is-property@1.0.2: + resolution: {integrity: sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g==} + is-regexp@1.0.0: resolution: {integrity: sha512-7zjFAPO4/gwyQAAgRRmqeEeyIICSdmCqa3tsVHMdBzaXXRiqopZL4Cyghg/XulGWrtABTpbnYYzzIRffLkP4oA==} engines: {node: '>=0.10.0'} @@ -2230,6 +3791,10 @@ packages: is-relative-path@1.0.2: resolution: {integrity: sha512-i1h+y50g+0hRbBD+dbnInl3JlJ702aar58snAeX+MxBAPvzXGej7sYoPMhlnykabt0ZzCJNBEyzMlekuQZN7fA==} + is-stream@2.0.1: + resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==} + engines: {node: '>=8'} + is-subdir@1.2.0: resolution: {integrity: sha512-2AT6j+gXe/1ueqbW6fLZJiIw3F8iXGJtt0yDrZaBhAZEG1raiTxKWU+IPqMCzQAXOUCKdA4UDMgacKH25XG2Cw==} engines: {node: '>=4'} @@ -2253,6 +3818,10 @@ packages: resolution: {integrity: sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==} engines: {node: '>=8'} + is-wsl@3.1.0: + resolution: {integrity: sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw==} + engines: {node: '>=16'} + isarray@1.0.0: resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} @@ -2275,6 +3844,10 @@ packages: resolution: {integrity: sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==} engines: {node: '>=8'} + istanbul-lib-instrument@5.2.1: + resolution: {integrity: sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==} + engines: {node: '>=8'} + istanbul-lib-report@3.0.1: resolution: {integrity: sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==} engines: {node: '>=10'} @@ -2283,8 +3856,8 @@ packages: resolution: {integrity: sha512-yg2d+Em4KizZC5niWhQaIomgf5WlL4vOOjZ5xGCmF8SnPE/mDWWXgvRExdcpCgh9lLRRa1/fSYp2ymmbJ1pI+A==} engines: {node: '>=10'} - istanbul-reports@3.1.7: - resolution: {integrity: sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==} + istanbul-reports@3.2.0: + resolution: {integrity: sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==} engines: {node: '>=8'} jackspeak@3.4.3: @@ -2294,6 +3867,48 @@ packages: resolution: {integrity: sha512-zptv57P3GpL+O0I7VdMJNBZCu+BPHVQUk55Ft8/QCJjTVxrnJHuVuX/0Bl2A6/+2oyR/ZMEuFKwmzqqZ/U5nPQ==} engines: {node: 20 || >=22} + jest-environment-node@29.7.0: + resolution: {integrity: sha512-DOSwCRqXirTOyheM+4d5YZOrWcdu0LNZ87ewUoywbcb2XR4wKgqiG8vNeYwhjFMbEkfju7wx2GYH0P2gevGvFw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-get-type@29.6.3: + resolution: {integrity: sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-haste-map@29.7.0: + resolution: {integrity: sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-message-util@29.7.0: + resolution: {integrity: sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-mock@29.7.0: + resolution: {integrity: sha512-ITOMZn+UkYS4ZFh83xYAOzWStloNzJFO2s8DWrE4lhtGD+AorgnbkiKERe4wQVBydIGPx059g6riW5Btp6Llnw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-regex-util@29.6.3: + resolution: {integrity: sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-util@29.7.0: + resolution: {integrity: sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-validate@29.7.0: + resolution: {integrity: sha512-ZB7wHqaRGVw/9hST/OuFUReG7M8vKeq0/J2egIGLdvjHCmYqGARhzXmtgi+gVeZ5uXFF219aOc3Ls2yLg27tkw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-worker@29.7.0: + resolution: {integrity: sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + js-base64@3.7.8: + resolution: {integrity: sha512-hNngCeKxIUQiEUN3GPJOkz4wF/YvdUdbNL9hsBcMQTkKzboD7T/q3OYOuuPZLUE6dBxSGpwhk5mwuDud7JVAow==} + + js-md4@0.3.2: + resolution: {integrity: sha512-/GDnfQYsltsjRswQhN9fhv3EMw2sCpUdrdxyWDOUK7eyD++r3gRhzgiQgc/x4MAv2i1iuQ4lxO5mvqM3vj4bwA==} + js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} @@ -2308,6 +3923,9 @@ packages: resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} hasBin: true + jsc-safe-url@0.2.4: + resolution: {integrity: sha512-0wM3YBWtYePOjfyXQH5MWQ8H7sdk5EXSwZvmSLKk2RboVQ2Bu239jycHDz5J/8Blf3K0Qnoy2b6xD+z10MFB+Q==} + jscodeshift@17.3.0: resolution: {integrity: sha512-LjFrGOIORqXBU+jwfC9nbkjmQfFldtMIoS6d9z2LG/lkmyNXsJAySPT+2SWXJEoE68/bCWcxKpXH37npftgmow==} engines: {node: '>=16'} @@ -2318,6 +3936,11 @@ packages: '@babel/preset-env': optional: true + jsesc@3.0.2: + resolution: {integrity: sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==} + engines: {node: '>=6'} + hasBin: true + jsesc@3.1.0: resolution: {integrity: sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==} engines: {node: '>=6'} @@ -2326,6 +3949,9 @@ packages: json-buffer@3.0.1: resolution: {integrity: sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==} + json-parse-better-errors@1.0.2: + resolution: {integrity: sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==} + json-schema-traverse@0.4.1: resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} @@ -2343,6 +3969,16 @@ packages: jsonfile@4.0.0: resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==} + jsonwebtoken@9.0.2: + resolution: {integrity: sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==} + engines: {node: '>=12', npm: '>=6'} + + jwa@1.4.2: + resolution: {integrity: sha512-eeH5JO+21J78qMvTIDdBXidBd6nG2kZjg5Ohz/1fpa28Z4CcsWUzJ1ZZyFq/3z3N17aZy+ZuBoHljASbL1WfOw==} + + jws@3.2.2: + resolution: {integrity: sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==} + keyv@4.5.4: resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} @@ -2358,14 +3994,34 @@ packages: resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} engines: {node: '>=0.10.0'} + kleur@4.1.5: + resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} + engines: {node: '>=6'} + lazy-cache@2.0.2: resolution: {integrity: sha512-7vp2Acd2+Kz4XkzxGxaB1FWOi8KjWIWsgdfD5MCb86DWvlLqhRPM+d6Pro3iNEL5VT9mstz5hKAlcd+QR6H3aA==} engines: {node: '>=0.10.0'} + lazystream@1.0.1: + resolution: {integrity: sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==} + engines: {node: '>= 0.6.3'} + + leven@3.1.0: + resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==} + engines: {node: '>=6'} + levn@0.4.1: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} engines: {node: '>= 0.8.0'} + libsql@0.5.20: + resolution: {integrity: sha512-hkWCsiwTbNsrKeWqPh91ZZEcLDo0+WUnFv2QzITD33F7Er9KOlr7N2SGfNjAbnkciN+iPJ7g108Jkno1JFmzTw==} + cpu: [x64, arm64, wasm32, arm] + os: [darwin, linux, win32] + + lighthouse-logger@1.4.2: + resolution: {integrity: sha512-gPWxznF6TKmUHrOQjlVo2UbaL2EJ71mb2CCeRs/2qBpi4L/g4LUVc9+3lKQ6DTUZwJswfM7ainGrLO1+fOqa2g==} + list-item@1.1.1: resolution: {integrity: sha512-S3D0WZ4J6hyM8o5SNKWaMYB1ALSacPZ2nHGEuCjmHZ+dc03gFeNZoNDcqfcnO4vDhTZmNrqrpYZCdXsRh22bzw==} engines: {node: '>=0.10.0'} @@ -2385,9 +4041,36 @@ packages: lodash._reinterpolate@3.0.0: resolution: {integrity: sha512-xYHt68QRoYGjeeM/XOE1uJtvXQAgvszfBhjV4yvsQH0u2i9I6cI6c6/eG4Hh3UAOVn0y/xAXwmTzEay49Q//HA==} + lodash.camelcase@4.3.0: + resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==} + + lodash.debounce@4.0.8: + resolution: {integrity: sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==} + + lodash.includes@4.3.0: + resolution: {integrity: sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==} + + lodash.isboolean@3.0.3: + resolution: {integrity: sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==} + + lodash.isinteger@4.0.4: + resolution: {integrity: sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==} + + lodash.isnumber@3.0.3: + resolution: {integrity: sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==} + + lodash.isplainobject@4.0.6: + resolution: {integrity: sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==} + + lodash.isstring@4.0.1: + resolution: {integrity: sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==} + lodash.merge@4.6.2: resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} + lodash.once@4.1.1: + resolution: {integrity: sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==} + lodash.startcase@4.4.0: resolution: {integrity: sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==} @@ -2398,6 +4081,9 @@ packages: lodash.templatesettings@4.2.0: resolution: {integrity: sha512-stgLz+i3Aa9mZgnjr/O+v9ruKZsPsndy7qPZOchbqk2cnTU1ZaldKK+v7m54WoKIyxiuMZTKT2H81F8BeAc3ZQ==} + lodash.throttle@4.1.1: + resolution: {integrity: sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ==} + lodash@4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} @@ -2405,8 +4091,15 @@ packages: resolution: {integrity: sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==} engines: {node: '>=10'} - loupe@3.2.0: - resolution: {integrity: sha512-2NCfZcT5VGVNX9mSZIxLRkEAegDGBpuQZBy13desuHeVORmBDyAET4TkJr4SjqQy3A8JDofMN6LpkK8Xcm/dlw==} + long@5.3.2: + resolution: {integrity: sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==} + + loose-envify@1.4.0: + resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} + hasBin: true + + loupe@3.2.1: + resolution: {integrity: sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==} lru-cache@10.4.3: resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==} @@ -2418,6 +4111,14 @@ packages: lru-cache@5.1.1: resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} + lru-cache@7.18.3: + resolution: {integrity: sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==} + engines: {node: '>=12'} + + lru.min@1.1.2: + resolution: {integrity: sha512-Nv9KddBcQSlQopmBHXSsZVY5xsdlZkdH/Iey0BlcBYggMd4two7cZnKOK9vmy3nY0O5RGH99z1PCeTpPqszUYg==} + engines: {bun: '>=1.0.0', deno: '>=1.30.0', node: '>=8.0.0'} + lz-string@1.5.0: resolution: {integrity: sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==} hasBin: true @@ -2432,8 +4133,8 @@ packages: typescript: optional: true - magic-string@0.30.17: - resolution: {integrity: sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==} + magic-string@0.30.18: + resolution: {integrity: sha512-yi8swmWbO17qHhwIBNeeZxTceJMeBvWJaId6dyvTSOwTipqeHhMhOrz6513r1sOKnpvQ7zkhlG8tPrpilwTxHQ==} magicast@0.3.5: resolution: {integrity: sha512-L0WhttDl+2BOsybvEOLK7fW3UA0OQ0IQ2d6Zl2x/a6vVRs3bAY0ECOSHHeL5jD+SbOpOCUEi0y1DgHEn9Qn1AQ==} @@ -2450,21 +4151,104 @@ packages: resolution: {integrity: sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==} engines: {node: '>=10'} + makeerror@1.0.12: + resolution: {integrity: sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==} + markdown-link@0.1.1: resolution: {integrity: sha512-TurLymbyLyo+kAUUAV9ggR9EPcDjP/ctlv9QAFiqUH7c+t6FlsbivPo9OKTU8xdOx9oNd2drW/Fi5RRElQbUqA==} engines: {node: '>=0.10.0'} + marky@1.3.0: + resolution: {integrity: sha512-ocnPZQLNpvbedwTy9kNrQEsknEfgvcLMvOtz3sFeWApDq1MXH1TqkCIx58xlpESsfwQOnuBO9beyQuNGzVvuhQ==} + math-random@1.0.4: resolution: {integrity: sha512-rUxjysqif/BZQH2yhd5Aaq7vXMSx9NdEsQcyA07uEzIvxgI7zIr33gGsh+RU0/XjmQpCW7RsVof1vlkvQVCK5A==} + memoize-one@5.2.1: + resolution: {integrity: sha512-zYiwtZUcYyXKo/np96AGZAckk+FWWsUdJ3cHGGmld7+AhvcWmQyGCYUh1hc4Q/pkOhb65dQR/pqCyK0cOaHz4Q==} + + merge-stream@2.0.0: + resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} + merge2@1.4.1: resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} engines: {node: '>= 8'} + metro-babel-transformer@0.83.1: + resolution: {integrity: sha512-r3xAD3964E8dwDBaZNSO2aIIvWXjIK80uO2xo0/pi3WI8XWT9h5SCjtGWtMtE5PRWw+t20TN0q1WMRsjvhC1rQ==} + engines: {node: '>=20.19.4'} + + metro-cache-key@0.83.1: + resolution: {integrity: sha512-ZUs+GD5CNeDLxx5UUWmfg26IL+Dnbryd+TLqTlZnDEgehkIa11kUSvgF92OFfJhONeXzV4rZDRGNXoo6JT+8Gg==} + engines: {node: '>=20.19.4'} + + metro-cache@0.83.1: + resolution: {integrity: sha512-7N/Ad1PHa1YMWDNiyynTPq34Op2qIE68NWryGEQ4TSE3Zy6a8GpsYnEEZE4Qi6aHgsE+yZHKkRczeBgxhnFIxQ==} + engines: {node: '>=20.19.4'} + + metro-config@0.83.1: + resolution: {integrity: sha512-HJhpZx3wyOkux/jeF1o7akFJzZFdbn6Zf7UQqWrvp7gqFqNulQ8Mju09raBgPmmSxKDl4LbbNeigkX0/nKY1QA==} + engines: {node: '>=20.19.4'} + + metro-core@0.83.1: + resolution: {integrity: sha512-uVL1eAJcMFd2o2Q7dsbpg8COaxjZBBGaXqO2OHnivpCdfanraVL8dPmY6It9ZeqWLOihUKZ2yHW4b6soVCzH/Q==} + engines: {node: '>=20.19.4'} + + metro-file-map@0.83.1: + resolution: {integrity: sha512-Yu429lnexKl44PttKw3nhqgmpBR+6UQ/tRaYcxPeEShtcza9DWakCn7cjqDTQZtWR2A8xSNv139izJMyQ4CG+w==} + engines: {node: '>=20.19.4'} + + metro-minify-terser@0.83.1: + resolution: {integrity: sha512-kmooOxXLvKVxkh80IVSYO4weBdJDhCpg5NSPkjzzAnPJP43u6+usGXobkTWxxrAlq900bhzqKek4pBsUchlX6A==} + engines: {node: '>=20.19.4'} + + metro-resolver@0.83.1: + resolution: {integrity: sha512-t8j46kiILAqqFS5RNa+xpQyVjULxRxlvMidqUswPEk5nQVNdlJslqizDm/Et3v/JKwOtQGkYAQCHxP1zGStR/g==} + engines: {node: '>=20.19.4'} + + metro-runtime@0.83.1: + resolution: {integrity: sha512-3Ag8ZS4IwafL/JUKlaeM6/CbkooY+WcVeqdNlBG0m4S0Qz0om3rdFdy1y6fYBpl6AwXJwWeMuXrvZdMuByTcRA==} + engines: {node: '>=20.19.4'} + + metro-source-map@0.83.1: + resolution: {integrity: sha512-De7Vbeo96fFZ2cqmI0fWwVJbtHIwPZv++LYlWSwzTiCzxBDJORncN0LcT48Vi2UlQLzXJg+/CuTAcy7NBVh69A==} + engines: {node: '>=20.19.4'} + + metro-symbolicate@0.83.1: + resolution: {integrity: sha512-wPxYkONlq/Sv8Ji7vHEx5OzFouXAMQJjpcPW41ySKMLP/Ir18SsiJK2h4YkdKpYrTS1+0xf8oqF6nxCsT3uWtg==} + engines: {node: '>=20.19.4'} + hasBin: true + + metro-transform-plugins@0.83.1: + resolution: {integrity: sha512-1Y+I8oozXwhuS0qwC+ezaHXBf0jXW4oeYn4X39XWbZt9X2HfjodqY9bH9r6RUTsoiK7S4j8Ni2C91bUC+sktJQ==} + engines: {node: '>=20.19.4'} + + metro-transform-worker@0.83.1: + resolution: {integrity: sha512-owCrhPyUxdLgXEEEAL2b14GWTPZ2zYuab1VQXcfEy0sJE71iciD7fuMcrngoufh7e7UHDZ56q4ktXg8wgiYA1Q==} + engines: {node: '>=20.19.4'} + + metro@0.83.1: + resolution: {integrity: sha512-UGKepmTxoGD4HkQV8YWvpvwef7fUujNtTgG4Ygf7m/M0qjvb9VuDmAsEU+UdriRX7F61pnVK/opz89hjKlYTXA==} + engines: {node: '>=20.19.4'} + hasBin: true + micromatch@4.0.8: resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} engines: {node: '>=8.6'} + mime-db@1.52.0: + resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} + engines: {node: '>= 0.6'} + + mime-types@2.1.35: + resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} + engines: {node: '>= 0.6'} + + mime@1.6.0: + resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==} + engines: {node: '>=4'} + hasBin: true + mime@4.0.7: resolution: {integrity: sha512-2OfDPL+e03E0LrXaGYOtTFIYhiuzep94NSsuhrNULq+stylcJedcHdzHtz0atMUuGwJfFYs0YL5xeC/Ca2x0eQ==} engines: {node: '>=16'} @@ -2474,6 +4258,15 @@ packages: resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} engines: {node: '>=6'} + mimic-response@3.1.0: + resolution: {integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==} + engines: {node: '>=10'} + + miniflare@4.20250823.0: + resolution: {integrity: sha512-ofQRQ6rb/5P4nsz/J+xptdrN4zvYUm0wuezbKfaxbAGiIVTsM1vd+Pta5MtZwdQ6BKLM9tKMtU0rnbTzy3wntQ==} + engines: {node: '>=18.0.0'} + hasBin: true + minimatch@10.0.3: resolution: {integrity: sha512-IPZ167aShDZZUMdRk66cyQAW3qr0WzbHkPdMYa8bzZhlHhO3jALbKdxcaak7W9FfT2rZNpQuUu4Od7ILEpXSaw==} engines: {node: 20 || >=22} @@ -2481,6 +4274,10 @@ packages: minimatch@3.1.2: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} + minimatch@5.1.6: + resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==} + engines: {node: '>=10'} + minimatch@9.0.5: resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==} engines: {node: '>=16 || 14 >=14.17'} @@ -2500,6 +4297,14 @@ packages: resolution: {integrity: sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==} engines: {node: '>=0.10.0'} + mkdirp-classic@0.5.3: + resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==} + + mkdirp@1.0.4: + resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==} + engines: {node: '>=10'} + hasBin: true + mkdirp@3.0.1: resolution: {integrity: sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==} engines: {node: '>=10'} @@ -2527,6 +4332,9 @@ packages: resolution: {integrity: sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==} engines: {node: '>=10'} + ms@2.0.0: + resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==} + ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} @@ -2540,25 +4348,55 @@ packages: multipasta@0.2.7: resolution: {integrity: sha512-KPA58d68KgGil15oDqXjkUBEBYc00XvbPj5/X+dyzeo/lWm9Nc25pQRlf1D+gv4OpK7NM0J1odrbu9JNNGvynA==} + mysql2@3.14.3: + resolution: {integrity: sha512-fD6MLV8XJ1KiNFIF0bS7Msl8eZyhlTDCDl75ajU5SJtpdx9ZPEACulJcqJWr1Y8OYyxsFc4j3+nflpmhxCU5aQ==} + engines: {node: '>= 8.0'} + + named-placeholders@1.1.3: + resolution: {integrity: sha512-eLoBxg6wE/rZkJPhU/xRX1WTpkFEwDJEN96oxFrTsqBdbT5ec295Q+CoHrL9IT0DipqKhmGcaZmwOt8OON5x1w==} + engines: {node: '>=12.0.0'} + + nan@2.23.0: + resolution: {integrity: sha512-1UxuyYGdoQHcGg87Lkqm3FzefucTa0NAiOcuRsDmysep3c1LVCRK2krrUDafMWtjSG04htvAmvg96+SDknOmgQ==} + nanoid@3.3.11: resolution: {integrity: sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true - napi-postinstall@0.3.2: - resolution: {integrity: sha512-tWVJxJHmBWLy69PvO96TZMZDrzmw5KeiZBz3RHmiM2XZ9grBJ2WgMAFVVg25nqp3ZjTFUs2Ftw1JhscL3Teliw==} + napi-build-utils@2.0.0: + resolution: {integrity: sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==} + + napi-postinstall@0.3.3: + resolution: {integrity: sha512-uTp172LLXSxuSYHv/kou+f6KW3SMppU9ivthaVTXian9sOt3XM/zHYHpRZiLgQoxeWfYUnslNWQHF1+G71xcow==} engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} hasBin: true + native-duplexpair@1.0.0: + resolution: {integrity: sha512-E7QQoM+3jvNtlmyfqRZ0/U75VFgCls+fSkbml2MpgWkWyz3ox8Y58gNhfuziuQYGNNQAbFZJQck55LHCnCK6CA==} + natural-compare-lite@1.4.0: resolution: {integrity: sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==} natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} + negotiator@0.6.3: + resolution: {integrity: sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==} + engines: {node: '>= 0.6'} + neo-async@2.6.2: resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} + node-abi@3.75.0: + resolution: {integrity: sha512-OhYaY5sDsIka7H7AtijtI9jwGYLyl29eQn/W623DiN/MIv5sUqc4g7BIDThX+gb7di9f6xK02nkp8sdfFWZLTg==} + engines: {node: '>=10'} + + node-domexception@1.0.0: + resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} + engines: {node: '>=10.5.0'} + deprecated: Use your platform's native DOMException instead + node-fetch@2.7.0: resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==} engines: {node: 4.x || >=6.0.0} @@ -2568,10 +4406,17 @@ packages: encoding: optional: true + node-fetch@3.3.2: + resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + node-gyp-build-optional-packages@5.2.2: resolution: {integrity: sha512-s+w+rBWnpTMwSFbaE0UXsRlg7hU4FjekKU4eyAih5T8nJuNZT1nNsskXpxmeqSK9UzkBl6UgRlnKc8hz8IEqOw==} hasBin: true + node-int64@0.4.0: + resolution: {integrity: sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==} + node-releases@2.0.19: resolution: {integrity: sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw==} @@ -2583,10 +4428,25 @@ packages: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} engines: {node: '>=0.10.0'} + nullthrows@1.1.1: + resolution: {integrity: sha512-2vPPEi+Z7WqML2jZYddDIfy5Dqb0r2fze2zTxNNknZaFpVHU3mFB3R+DWeJWGVx0ecvttSGlJTI+WG+8Z4cDWw==} + + ob1@0.83.1: + resolution: {integrity: sha512-ngwqewtdUzFyycomdbdIhFLjePPSOt1awKMUXQ0L7iLHgWEPF3DsCerblzjzfAUHaXuvE9ccJymWQ/4PNNqvnQ==} + engines: {node: '>=20.19.4'} + object.pick@1.3.0: resolution: {integrity: sha512-tqa/UMy/CCoYmj+H5qc07qvSL9dqcs/WZENZ1JbtWBlATP+iVOe778gE6MSijnyCnORzDuX6hU+LA4SZ09YjFQ==} engines: {node: '>=0.10.0'} + on-finished@2.3.0: + resolution: {integrity: sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==} + engines: {node: '>= 0.8'} + + on-finished@2.4.1: + resolution: {integrity: sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==} + engines: {node: '>= 0.8'} + once@1.4.0: resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} @@ -2594,6 +4454,14 @@ packages: resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==} engines: {node: '>=6'} + open@10.2.0: + resolution: {integrity: sha512-YgBpdJHPyQ2UE5x+hlSXcnejzAvD0b22U2OuAP+8OnlJT+PjWPxtgmGqKKc+RgTM63U9gN0YzrYc71R2WT/hTA==} + engines: {node: '>=18'} + + open@7.4.2: + resolution: {integrity: sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==} + engines: {node: '>=8'} + open@8.4.2: resolution: {integrity: sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==} engines: {node: '>=12'} @@ -2606,10 +4474,6 @@ packages: resolution: {integrity: sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==} engines: {node: '>=10'} - os-tmpdir@1.0.2: - resolution: {integrity: sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==} - engines: {node: '>=0.10.0'} - outdent@0.5.0: resolution: {integrity: sha512-/jHxFIzoMXdqPzTaCpFzAAWhpkSjZPF4Vsn6jAfNpmbH/ymsmd7Qc6VE9BGn0L6YMj6uwpQLxCECpus4ukKS9Q==} @@ -2655,10 +4519,18 @@ packages: resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} engines: {node: '>=6'} + parse-json@4.0.0: + resolution: {integrity: sha512-aOIos8bujGN93/8Ox/jPLh7RwVnPEysynVFE+fQZyg6jKELEHwzgKdLRFHUgXJL6kylijVSBC4BvN9OmsB48Rw==} + engines: {node: '>=4'} + parse-ms@2.1.0: resolution: {integrity: sha512-kHt7kzLoS9VBZfUsiKjv43mr91ea+U05EyKkEtqp7vNbHxmaVuEqN7XxeEVnGrMtYOAxGrDElSi96K7EgO1zCA==} engines: {node: '>=6'} + parseurl@1.3.3: + resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==} + engines: {node: '>= 0.8'} + path-exists@3.0.0: resolution: {integrity: sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==} engines: {node: '>=4'} @@ -2697,6 +4569,45 @@ packages: resolution: {integrity: sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==} engines: {node: '>= 14.16'} + pg-cloudflare@1.2.7: + resolution: {integrity: sha512-YgCtzMH0ptvZJslLM1ffsY4EuGaU0cx4XSdXLRFae8bPP4dS5xL1tNB3k2o/N64cHJpwU7dxKli/nZ2lUa5fLg==} + + pg-connection-string@2.9.1: + resolution: {integrity: sha512-nkc6NpDcvPVpZXxrreI/FOtX3XemeLl8E0qFr6F2Lrm/I8WOnaWNhIPK2Z7OHpw7gh5XJThi6j6ppgNoaT1w4w==} + + pg-cursor@2.15.3: + resolution: {integrity: sha512-eHw63TsiGtFEfAd7tOTZ+TLy+i/2ePKS20H84qCQ+aQ60pve05Okon9tKMC+YN3j6XyeFoHnaim7Lt9WVafQsA==} + peerDependencies: + pg: ^8 + + pg-int8@1.0.1: + resolution: {integrity: sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==} + engines: {node: '>=4.0.0'} + + pg-pool@3.10.1: + resolution: {integrity: sha512-Tu8jMlcX+9d8+QVzKIvM/uJtp07PKr82IUOYEphaWcoBhIYkoHpLXN3qO59nAI11ripznDsEzEv8nUxBVWajGg==} + peerDependencies: + pg: '>=8.0' + + pg-protocol@1.10.3: + resolution: {integrity: sha512-6DIBgBQaTKDJyxnXaLiLR8wBpQQcGWuAESkRBX/t6OwA8YsqP+iVSiond2EDy6Y/dsGk8rh/jtax3js5NeV7JQ==} + + pg-types@2.2.0: + resolution: {integrity: sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==} + engines: {node: '>=4'} + + pg@8.16.3: + resolution: {integrity: sha512-enxc1h0jA/aq5oSDMvqyW3q89ra6XIIDZgCX9vkMrnz5DFTw/Ny3Li2lFQ+pt3L6MCgm/5o2o8HW9hiJji+xvw==} + engines: {node: '>= 16.0.0'} + peerDependencies: + pg-native: '>=3.0.1' + peerDependenciesMeta: + pg-native: + optional: true + + pgpass@1.0.5: + resolution: {integrity: sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==} + picocolors@1.1.1: resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} @@ -2727,13 +4638,13 @@ packages: pkg-entry-points@1.1.1: resolution: {integrity: sha512-BhZa7iaPmB4b3vKIACoppyUoYn8/sFs17VJJtzrzPZvEnN2nqrgg911tdL65lA2m1ml6UI3iPeYbZQ4VXpn1mA==} - playwright-core@1.54.1: - resolution: {integrity: sha512-Nbjs2zjj0htNhzgiy5wu+3w09YetDx5pkrpI/kZotDlDUaYk0HVA5xrBVPdow4SAUIlhgKcJeJg4GRKW6xHusA==} + playwright-core@1.55.0: + resolution: {integrity: sha512-GvZs4vU3U5ro2nZpeiwyb0zuFaqb9sUiAJuyrWpcGouD8y9/HLgGbNRjIph7zU9D3hnPaisMl9zG9CgFi/biIg==} engines: {node: '>=18'} hasBin: true - playwright@1.54.1: - resolution: {integrity: sha512-peWpSwIBmSLi6aW2auvrUtf2DqY16YYcCMO8rTVx486jKmDTJg7UAhyrraP98GB8BoPURZP8+nxO7TSd4cPr5g==} + playwright@1.55.0: + resolution: {integrity: sha512-sdCWStblvV1YU909Xqx0DhOjPZE4/5lJsIS84IfN9dAZfcl/CIZ5O8l3o0j7hPMjDvqoTF8ZUcc+i/GL5erstA==} engines: {node: '>=18'} hasBin: true @@ -2751,6 +4662,27 @@ packages: resolution: {integrity: sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==} engines: {node: ^10 || ^12 || >=14} + postgres-array@2.0.0: + resolution: {integrity: sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==} + engines: {node: '>=4'} + + postgres-bytea@1.0.0: + resolution: {integrity: sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==} + engines: {node: '>=0.10.0'} + + postgres-date@1.0.7: + resolution: {integrity: sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==} + engines: {node: '>=0.10.0'} + + postgres-interval@1.2.0: + resolution: {integrity: sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==} + engines: {node: '>=0.10.0'} + + prebuild-install@7.1.3: + resolution: {integrity: sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==} + engines: {node: '>=10'} + hasBin: true + precinct@11.0.5: resolution: {integrity: sha512-oHSWLC8cL/0znFhvln26D14KfCQFFn4KOLSw6hmLhd+LQ2SKt9Ljm89but76Pc7flM9Ty1TnXyrA2u16MfRV3w==} engines: {node: ^14.14.0 || >=16.0.0} @@ -2778,6 +4710,10 @@ packages: resolution: {integrity: sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==} engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} + pretty-format@29.7.0: + resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + pretty-ms@7.0.1: resolution: {integrity: sha512-973driJZvxiGOQ5ONsFhOF/DtzPMOMtgC11kCpUrPGMTgqp2q/1gwzCquocrN33is0VZ5GFHXZYMM9l6h67v2Q==} engines: {node: '>=10'} @@ -2785,6 +4721,30 @@ packages: process-nextick-args@2.0.1: resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} + process@0.11.10: + resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==} + engines: {node: '>= 0.6.0'} + + promise-limit@2.7.0: + resolution: {integrity: sha512-7nJ6v5lnJsXwGprnGXga4wx6d1POjvi5Qmf1ivTRxTjH4Z/9Czja/UCMLVmB9N93GeWOU93XaFaEt6jbuoagNw==} + + promise@8.3.0: + resolution: {integrity: sha512-rZPNPKTOYVNEEKFaq1HqTgOwZD+4/YHS5ukLzQCypkj+OkYx7iv0mA91lJlpPPZ8vMau3IIGj5Qlwrx+8iiSmg==} + + proper-lockfile@4.1.2: + resolution: {integrity: sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA==} + + properties-reader@2.3.0: + resolution: {integrity: sha512-z597WicA7nDZxK12kZqHr2TcvwNU1GCfA5UwfDY/HDp3hXPoPlb5rlEx9bwGTiJnc0OqbBTkU975jDToth8Gxw==} + engines: {node: '>=14'} + + protobufjs@7.5.4: + resolution: {integrity: sha512-CvexbZtbov6jW2eXAvLukXjXUW1TzFaivC46BpWc/3BpcCysb5Vffu+B3XHMm8lVEuy2Mm4XGex8hBSg1yapPg==} + engines: {node: '>=12.0.0'} + + pump@3.0.3: + resolution: {integrity: sha512-todwxLMY7/heScKmntwQG8CXVkWUOdYxIvY2s0VWAAMh/nd8SoYiRaKjlr7+iCs984f2P8zvrfWcDDYVb73NfA==} + punycode@2.3.1: resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} engines: {node: '>=6'} @@ -2792,12 +4752,15 @@ packages: pure-rand@7.0.1: resolution: {integrity: sha512-oTUZM/NAZS8p7ANR3SHh30kXB+zK2r2BPcEn/awJIbOvq82WoMN4p62AWWp3Hhw50G0xMsw1mhIBLqHw64EcNQ==} - quansync@0.2.10: - resolution: {integrity: sha512-t41VRkMYbkHyCYmOvx/6URnN80H7k4X0lLdBMGsz+maAwrJQYB1djpV6vHrQIBE0WBSGqhtEHrK9U3DWWH8v7A==} + quansync@0.2.11: + resolution: {integrity: sha512-AifT7QEbW9Nri4tAwR5M/uzpBuqfZf+zwaEM/QkzEjj7NBuFD2rBuy0K3dE+8wltbezDV7JMA0WfnCPYRSYbXA==} queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} + queue@6.0.2: + resolution: {integrity: sha512-iHZWu+q3IdFZFX36ro/lKBkSvfkztY5Y7HMiPlOUjhupPcG2JMfst2KKEpu5XndviX/3UhFbRngUPNKtgvtZiA==} + quote-unquote@1.0.0: resolution: {integrity: sha512-twwRO/ilhlG/FIgYeKGFqyHhoEhqgnKVkcmqMKi2r524gz3ZbDTcyFt38E9xjJI2vT+KbRNHVbnJ/e0I25Azwg==} @@ -2808,13 +4771,42 @@ packages: randombytes@2.1.0: resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==} + range-parser@1.2.1: + resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==} + engines: {node: '>= 0.6'} + rc@1.2.8: resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==} hasBin: true + react-devtools-core@6.1.5: + resolution: {integrity: sha512-ePrwPfxAnB+7hgnEr8vpKxL9cmnp7F322t8oqcPshbIQQhDKgFDW4tjhF2wjVbdXF9O/nyuy3sQWd9JGpiLPvA==} + react-is@17.0.2: resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==} + react-is@18.3.1: + resolution: {integrity: sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==} + + react-native@0.81.0: + resolution: {integrity: sha512-RDWhewHGsAa5uZpwIxnJNiv5tW2y6/DrQUjEBdAHPzGMwuMTshern2s4gZaWYeRU3SQguExVddCjiss9IBhxqA==} + engines: {node: '>= 20.19.4'} + hasBin: true + peerDependencies: + '@types/react': ^19.1.0 + react: ^19.1.0 + peerDependenciesMeta: + '@types/react': + optional: true + + react-refresh@0.14.2: + resolution: {integrity: sha512-jCvmsr+1IUSMUyzOkRcvnVbX3ZYC6g9TDrDbFuFmRDq7PD4yaGbLKNQL6k2jnArV8hjYxh7hVhAZB6s9HDGpZA==} + engines: {node: '>=0.10.0'} + + react@19.1.1: + resolution: {integrity: sha512-w8nqGImo45dmMIfljjMwOGtbmC/mk4CMYhWIicdSflH91J9TyCyczcPFXJzrZ/ZXcgGRFeP6BU0BEJTw6tZdfQ==} + engines: {node: '>=0.10.0'} + read-yaml-file@1.1.0: resolution: {integrity: sha512-VIMnQi/Z4HT2Fxuwg5KrY174U1VdUIASQVWXXyqtNRtxSr9IYkn1rsI6Tb6HsrHCmB7gVpNwX6JxPTHcH6IoTA==} engines: {node: '>=6'} @@ -2826,6 +4818,13 @@ packages: resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} engines: {node: '>= 6'} + readable-stream@4.7.0: + resolution: {integrity: sha512-oIGGmcpTLwPga8Bn6/Z75SVaH1z5dUut2ibSyAMVhmUggWpmDn2dapB0n7f8nwaSiRtepAsfJyfXIO5DCVAODg==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + + readdir-glob@1.1.3: + resolution: {integrity: sha512-v05I2k7xN8zXvPD9N+z/uhXPaj0sUFCe2rcWZIpBsqxfP7xXFQ0tipAd/wjj1YxWyWtUS5IDJpOG82JKt2EAVA==} + readdirp@3.6.0: resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} engines: {node: '>=8.10.0'} @@ -2834,6 +4833,27 @@ packages: resolution: {integrity: sha512-YTUo+Flmw4ZXiWfQKGcwwc11KnoRAYgzAE2E7mXKCjSviTKShtxBsN6YUUBB2gtaBzKzeKunxhUwNHQuRryhWA==} engines: {node: '>= 4'} + regenerate-unicode-properties@10.2.0: + resolution: {integrity: sha512-DqHn3DwbmmPVzeKj9woBadqmXxLvQoQIwu7nopMc72ztvxVmVk2SBhSnx67zuye5TP+lJsb/TBQsjLKhnDf3MA==} + engines: {node: '>=4'} + + regenerate@1.4.2: + resolution: {integrity: sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==} + + regenerator-runtime@0.13.11: + resolution: {integrity: sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==} + + regexpu-core@6.2.0: + resolution: {integrity: sha512-H66BPQMrv+V16t8xtmq+UC0CBpiTBA60V8ibS1QVReIp8T1z8hwFxqcGzm9K6lgsN7sB5edVH8a+ze6Fqm4weA==} + engines: {node: '>=4'} + + regjsgen@0.8.0: + resolution: {integrity: sha512-RvwtGe3d7LvWiDQXeQw8p5asZUmfU1G/l6WbUXeHta7Y2PEIvBTwH6E2EfmYUK8pxcxEdEmaomqyp0vZZ7C+3Q==} + + regjsparser@0.12.0: + resolution: {integrity: sha512-cnE+y8bz4NhMjISKbgeVJtqNbtf5QpjZP+Bslo+UqkIt9QPnX9q095eiRRASJG1/tz6dlNr6Z5NsBiWYokp6EQ==} + hasBin: true + remarkable@1.7.4: resolution: {integrity: sha512-e6NKUXgX95whv7IgddywbeN/ItCkWbISmc2DiqHJb0wTrqZIexqdco5b8Z3XZoo/48IdNVKM9ZCvTPJ4F5uvhg==} engines: {node: '>= 0.10.0'} @@ -2868,6 +4888,10 @@ packages: resolution: {integrity: sha512-Tz7zfjhLfsvR39ADOSk9us4421J/1ztVBo4rWUkF38hgHK5m0OCZ3NxFVpqHRkjctnwVa15igEUHFJp8MCS7vA==} engines: {node: '>=14'} + resolve-from@3.0.0: + resolution: {integrity: sha512-GnlH6vxLymXJNMBo7XP1fJIzBFbdYt49CuTwmB/6N53t+kMPRMFKz783LlQ4tv28XoQfMWinAJX6WCGf2IlaIw==} + engines: {node: '>=4'} + resolve-from@4.0.0: resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} engines: {node: '>=4'} @@ -2888,22 +4912,38 @@ packages: resolution: {integrity: sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==} engines: {node: '>=8'} + retry@0.12.0: + resolution: {integrity: sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==} + engines: {node: '>= 4'} + reusify@1.1.0: resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} + rimraf@3.0.2: + resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} + deprecated: Rimraf versions prior to v4 are no longer supported + hasBin: true + rimraf@6.0.1: resolution: {integrity: sha512-9dkvaxAsk/xNXSJzMgFqqMCuFgt2+KsOFek3TMLfo8NCPfWpBmqwyNn5Y+NX56QUYfCtsyhF3ayiboEoUmJk/A==} engines: {node: 20 || >=22} hasBin: true - rollup-plugin-bundle-stats@4.21.0: - resolution: {integrity: sha512-cbT9uJf5FqBbDvFT3FmiiMuIfSshfFRBkiz6zXELb0wrUFPYAiL7rt4UJMUjJpovSVZeUbvYBaKyvgv9fInZow==} + rolldown@1.0.0-beta.34: + resolution: {integrity: sha512-Wwh7EwalMzzX3Yy3VN58VEajeR2Si8+HDNMf706jPLIqU7CxneRW+dQVfznf5O0TWTnJyu4npelwg2bzTXB1Nw==} + hasBin: true + + rollup-plugin-bundle-stats@4.21.3: + resolution: {integrity: sha512-JqdsZz3byWH8zhqPsosR8/mCMLszpLHhMtu3NYlXsN/LoXm342/urE5dOVaL+qWP/4mLqI1lNkbxG9QoLX1M6w==} engines: {node: '>= 16.0'} peerDependencies: + rolldown: ^1.0.0-beta.0 rollup: ^3.0.0 || ^4.0.0 vite: ^5.0.0 || ^6.0.0 || ^7.0.0 peerDependenciesMeta: + rolldown: + optional: true rollup: optional: true vite: @@ -2916,13 +4956,16 @@ packages: esbuild: '>=0.18.0' rollup: ^1.20.0 || ^2.0.0 || ^3.0.0 || ^4.0.0 - rollup-plugin-stats@1.4.0: - resolution: {integrity: sha512-qbwuMysGHqNrW0XBO3dU8qM7SdVYmMuaABp6SG1wFDClFVdUo8Umtk/LIDFCocNxDf6Tvtu7tXF/FsMy8NZCew==} + rollup-plugin-stats@1.5.0: + resolution: {integrity: sha512-TsWaV7ulwPA9JhqGJemrDJkvXNeNQb60lB13gIcT2kVDXlBM/PQD3GqVyhCJpvn43Y4YT5+VmWDRsbIAbuilBA==} engines: {node: '>=18'} peerDependencies: + rolldown: ^1.0.0-beta.0 rollup: ^3.0.0 || ^4.0.0 vite: ^5.0.0 || ^6.0.0 || ^7.0.0 peerDependenciesMeta: + rolldown: + optional: true rollup: optional: true vite: @@ -2941,10 +4984,11 @@ packages: rollup: optional: true - rollup-plugin-webpack-stats@2.1.0: - resolution: {integrity: sha512-7cxCelMRPkqZvjQa4NuHSkdJ6nshLDuDYyPAky8YOjcaz+qEocg0DRcJoSd4r2mKSupz0uZpoav5vqpDm7bSxg==} + rollup-plugin-webpack-stats@2.1.4: + resolution: {integrity: sha512-kv9W0rK9Qy1Q8/vkxEPGOwJvq7zVERnHD13At5Jv15FPPOXwxm1LblXtpuASeoM1ALhOPD0sJSDz64qgtSgh7g==} engines: {node: '>=18'} peerDependencies: + rolldown: ^1.0.0-beta.0 rollup: ^3.0.0 || ^4.0.0 vite: ^5.0.0 || ^6.0.0 || ^7.0.0 peerDependenciesMeta: @@ -2953,11 +4997,15 @@ packages: vite: optional: true - rollup@4.45.1: - resolution: {integrity: sha512-4iya7Jb76fVpQyLoiVpzUrsjQ12r3dM7fIVz+4NwoYvZOShknRmiv+iu9CClZml5ZLGb0XMcYLutK6w9tgxHDw==} + rollup@4.48.1: + resolution: {integrity: sha512-jVG20NvbhTYDkGAty2/Yh7HK6/q3DGSRH4o8ALKGArmMuaauM9kLfoMZ+WliPwA5+JHr2lTn3g557FxBV87ifg==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true + run-applescript@7.0.0: + resolution: {integrity: sha512-9by4Ij99JUr/MCFBUkDKLWK3G9HVXmabKz9U5MlIAIuvuzkiOicRYs8XJLxX+xahD+mLiiCYDqF9dKAgtzKP1A==} + engines: {node: '>=18'} + run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} @@ -2975,6 +5023,9 @@ packages: engines: {node: '>=14'} hasBin: true + scheduler@0.26.0: + resolution: {integrity: sha512-NlHwttCI/l5gCPR3D1nNXtWABUmBwvZpEQiD4IXSbIDq8BzLIK/7Ir5gTFSGZDUu37K5cMNp0hFtzO38sC7gWA==} + semver@5.7.2: resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} hasBin: true @@ -2988,20 +5039,42 @@ packages: engines: {node: '>=10'} hasBin: true + send@0.19.0: + resolution: {integrity: sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==} + engines: {node: '>= 0.8.0'} + + seq-queue@0.0.5: + resolution: {integrity: sha512-hr3Wtp/GZIc/6DAGPDcV4/9WoZhjrkXsi5B/07QgX8tsdc6ilr7BFM6PM6rbdAX1kFSDYeZGLipIZZKyQP0O5Q==} + + serialize-error@2.1.0: + resolution: {integrity: sha512-ghgmKt5o4Tly5yEG/UJp8qTd0AN7Xalw4XBtDEKP655B699qMEtra1WlXeE6WIvdEG481JvRxULKsInq/iNysw==} + engines: {node: '>=0.10.0'} + serialize-javascript@6.0.2: resolution: {integrity: sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==} serialize-query-params@2.0.2: resolution: {integrity: sha512-1chMo1dST4pFA9RDXAtF0Rbjaut4is7bzFbI1Z26IuMub68pNCILku85aYmeFhvnY//BXUPUhoRMjYcsT93J/Q==} + serve-static@1.16.2: + resolution: {integrity: sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==} + engines: {node: '>= 0.8.0'} + set-getter@0.1.1: resolution: {integrity: sha512-9sVWOy+gthr+0G9DzqqLaYNA7+5OKkSmcqjL9cBpDEaZrr3ShQlyX2cZ/O/ozE41oxn/Tt0LGEM/w4Rub3A3gw==} engines: {node: '>=0.10.0'} + setprototypeof@1.2.0: + resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==} + shallow-clone@3.0.1: resolution: {integrity: sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==} engines: {node: '>=8'} + sharp@0.33.5: + resolution: {integrity: sha512-haPVm1EkS9pgvHrQ/F3Xy+hgcuMV0Wm9vfIBSiwZ05k+xgb0PkBQpGsAA/oWdDobNaZTH5ppvHtzCFbnSEwHVw==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + shebang-command@2.0.0: resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} engines: {node: '>=8'} @@ -3010,6 +5083,10 @@ packages: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} + shell-quote@1.8.3: + resolution: {integrity: sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==} + engines: {node: '>= 0.4'} + siginfo@2.0.0: resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==} @@ -3020,6 +5097,15 @@ packages: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} engines: {node: '>=14'} + simple-concat@1.0.1: + resolution: {integrity: sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==} + + simple-get@4.0.1: + resolution: {integrity: sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==} + + simple-swizzle@0.2.2: + resolution: {integrity: sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==} + sirv@3.0.1: resolution: {integrity: sha512-FoqMu0NCGBLCcAkS1qA+XJIQTR6/JHfQXl+uGteNCQ76T91DMUjPa9xfmeqMY3z80nLSg9yQmNjK0Px6RWsH/A==} engines: {node: '>=18'} @@ -3042,30 +5128,78 @@ packages: source-map-support@0.5.21: resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} + source-map@0.5.7: + resolution: {integrity: sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==} + engines: {node: '>=0.10.0'} + source-map@0.6.1: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} - source-map@0.7.4: - resolution: {integrity: sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==} - engines: {node: '>= 8'} + source-map@0.7.6: + resolution: {integrity: sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ==} + engines: {node: '>= 12'} spawndamnit@3.0.1: resolution: {integrity: sha512-MmnduQUuHCoFckZoWnXsTg7JaiLBJrKFj9UI2MbRPGaJeVpsLcVBu6P/IGZovziM/YBsellCmsprgNA+w0CzVg==} + split-ca@1.0.1: + resolution: {integrity: sha512-Q5thBSxp5t8WPTTJQS59LrGqOZqOsrhDGDVm8azCqIBjSBd7nd9o2PM+mDulQQkh8h//4U6hFZnc/mul8t5pWQ==} + + split2@4.2.0: + resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==} + engines: {node: '>= 10.x'} + sprintf-js@1.0.3: resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} + sprintf-js@1.1.3: + resolution: {integrity: sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==} + + sqlstring@2.3.3: + resolution: {integrity: sha512-qC9iz2FlN7DQl3+wjwn3802RTyjCx7sDvfQEXchwa6CWOx07/WVfh91gBmQ9fahw8snwGEWU3xGzOt4tFyHLxg==} + engines: {node: '>= 0.6'} + + ssh-remote-port-forward@1.0.4: + resolution: {integrity: sha512-x0LV1eVDwjf1gmG7TTnfqIzf+3VPRz7vrNIjX6oYLbeCrf/PeVY6hkT68Mg+q02qXxQhrLjB0jfgvhevoCRmLQ==} + + ssh2@1.17.0: + resolution: {integrity: sha512-wPldCk3asibAjQ/kziWQQt1Wh3PgDFpC0XpwclzKcdT1vql6KeYxf5LIt4nlFkUeR8WuphYMKqUA56X4rjbfgQ==} + engines: {node: '>=10.16.0'} + stable-hash-x@0.2.0: resolution: {integrity: sha512-o3yWv49B/o4QZk5ZcsALc6t0+eCelPc44zZsLtCQnZPDwFpDYSWcDnrv2TtMmMbQ7uKo3J0HTURCqckw23czNQ==} engines: {node: '>=12.0.0'} + stack-utils@2.0.6: + resolution: {integrity: sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==} + engines: {node: '>=10'} + stackback@0.0.2: resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} + stackframe@1.3.4: + resolution: {integrity: sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==} + + stacktrace-parser@0.1.11: + resolution: {integrity: sha512-WjlahMgHmCJpqzU8bIBy4qtsZdU9lRlcZE3Lvyej6t4tuOuv1vk57OW3MBrj6hXBFx/nNoC9MPMTcr5YA7NQbg==} + engines: {node: '>=6'} + + statuses@1.5.0: + resolution: {integrity: sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==} + engines: {node: '>= 0.6'} + + statuses@2.0.1: + resolution: {integrity: sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==} + engines: {node: '>= 0.8'} + std-env@3.9.0: resolution: {integrity: sha512-UGvjygr6F6tpH7o2qyqR6QYpwraIjKSdtzyBdyytFOHmPZY917kwdwLG0RbOjWOnKmnm3PeHjaoLLMie7kPLQw==} + stoppable@1.1.0: + resolution: {integrity: sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==} + engines: {node: '>=4', npm: '>=6'} + stream-chain@2.2.5: resolution: {integrity: sha512-1TJmBx6aSWqZ4tx7aTpBDXK0/e2hhcNSTV8+CbFJtDjbb+I1mZ8lHit0Grw9GRT+6JbIrrDd8esncgBi8aBXGA==} @@ -3078,6 +5212,9 @@ packages: stream-to-array@2.3.0: resolution: {integrity: sha512-UsZtOYEn4tWU2RGLOXr/o/xjRBftZRlG3dEWoaHr8j4GuypJ3isitGbVyjQKAuMu+xbiop8q224TjiZWc4XTZA==} + streamx@2.22.1: + resolution: {integrity: sha512-znKXEBxfatz2GBNK02kRnCXjV+AA4kjZIUxeWSr3UGirZMJfTE9uiwKHobnbgxWyL/JWro8tTq+vOqAK1/qbSA==} + string-width@4.2.3: resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} engines: {node: '>=8'} @@ -3136,22 +5273,47 @@ packages: resolution: {integrity: sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A==} engines: {node: '>=14.0.0'} + supports-color@10.2.0: + resolution: {integrity: sha512-5eG9FQjEjDbAlI5+kdpdyPIBMRH4GfTVDGREVupaZHmVoppknhM29b/S9BkQz7cathp85BVgRi/As3Siln7e0Q==} + engines: {node: '>=18'} + supports-color@7.2.0: resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} engines: {node: '>=8'} + supports-color@8.1.1: + resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==} + engines: {node: '>=10'} + supports-preserve-symlinks-flag@1.0.0: resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} engines: {node: '>= 0.4'} - tapable@2.2.2: - resolution: {integrity: sha512-Re10+NauLTMCudc7T5WLFLAwDhQ0JWdrMK+9B2M8zR5hRExKmsRDCBA7/aV/pNJFltmBFO5BAMlQFi/vq3nKOg==} + tapable@2.2.3: + resolution: {integrity: sha512-ZL6DDuAlRlLGghwcfmSn9sK3Hr6ArtyudlSAiCqQ6IfE+b+HHbydbYDIG15IfS5do+7XQQBdBiubF/cV2dnDzg==} engines: {node: '>=6'} + tar-fs@2.1.3: + resolution: {integrity: sha512-090nwYJDmlhwFwEW3QQl+vaNnxsO2yVsd45eTKRBzSzu+hlb1w2K9inVq5b0ngXuLVqQ4ApvsUHHnu/zQNkWAg==} + + tar-fs@3.1.0: + resolution: {integrity: sha512-5Mty5y/sOF1YWj1J6GiBodjlDc05CUR8PKXrsnFAiSG0xA+GHeWLovaZPYUDXkH/1iKRf2+M5+OrRgzC7O9b7w==} + + tar-stream@2.2.0: + resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==} + engines: {node: '>=6'} + + tar-stream@3.1.7: + resolution: {integrity: sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==} + tar@7.4.3: resolution: {integrity: sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==} engines: {node: '>=18'} + tedious@18.6.1: + resolution: {integrity: sha512-9AvErXXQTd6l7TDd5EmM+nxbOGyhnmdbp/8c3pw+tjaiSXW9usME90ET/CRG1LN1Y9tPMtz/p83z4Q97B4DDpw==} + engines: {node: '>=18'} + term-size@2.2.1: resolution: {integrity: sha512-wK0Ri4fOGjv/XPy8SBHZChl8CM7uMc5VML7SqiQ0zG7+J5Vr+RMQDoHa2CNT6KHUnTGIXH34UDMkPzAUyapBZg==} engines: {node: '>=8'} @@ -3161,10 +5323,23 @@ packages: engines: {node: '>=10'} hasBin: true + test-exclude@6.0.0: + resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==} + engines: {node: '>=8'} + test-exclude@7.0.1: resolution: {integrity: sha512-pFYqmTw68LXVjeWJMST4+borgQP2AyMNbg1BpZh9LbyhUeNkeaPF9gzfPGUAnSMV3qPYdWUwDIjjCLiSDOl7vg==} engines: {node: '>=18'} + testcontainers@11.5.1: + resolution: {integrity: sha512-YSSP4lSJB8498zTeu4HYTZYgSky54ozBmIDdC8PFU5inj+vBo5hPpilhcYTgmsqsYjrXOJGV7jl0MWByS7GwuA==} + + text-decoder@1.2.3: + resolution: {integrity: sha512-3/o9z3X0X0fTupwsYvR03pJ/DjWuqqrfwBgTQzdWDiQSm9KitAyz/9WqsT2JQW7KV2m+bC2ol/zqpW37NHxLaA==} + + throat@5.0.0: + resolution: {integrity: sha512-fcwX4mndzpLQKBS1DVYhGAcYaYt7vsHNIvQV+WXMvnow5cgjPphq5CaayLaGsjRdSCKZFNGt7/GYAuXaNOiYCA==} + through2@2.0.5: resolution: {integrity: sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==} @@ -3174,9 +5349,9 @@ packages: tinybench@2.9.0: resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==} - tinybench@4.0.1: - resolution: {integrity: sha512-Nb1srn7dvzkVx0J5h1vq8f48e3TIcbrS7e/UfAI/cDSef/n8yLh4zsAEsFkfpw6auTY+ZaspEvam/xs8nMnotQ==} - engines: {node: '>=18.0.0'} + tinybench@5.0.1: + resolution: {integrity: sha512-aNVgWQZY4veCZLQJRftDA1X9OoLUIjDWNfC90nledkX7Lx205IpSEFYnsu4slyofoPGpJ+NIQj+BNSt4U5edMg==} + engines: {node: '>=20.0.0'} tinyexec@0.3.2: resolution: {integrity: sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==} @@ -3197,14 +5372,13 @@ packages: resolution: {integrity: sha512-t2T/WLB2WRgZ9EpE4jgPJ9w+i66UZfDc8wHh0xrwiRNN+UwH98GIJkTeZqX9rg0i0ptwzqW+uYeIF0T4F8LR7A==} engines: {node: '>=14.0.0'} - tmp@0.0.33: - resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==} - engines: {node: '>=0.6.0'} - - tmp@0.2.3: - resolution: {integrity: sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w==} + tmp@0.2.5: + resolution: {integrity: sha512-voyz6MApa1rQGUxT3E+BK7/ROe8itEx7vD8/HEvt4xwXucvQ5G5oeEiHkmHZJuBO21RpOf+YYm9MOivj709jow==} engines: {node: '>=14.14'} + tmpl@1.0.5: + resolution: {integrity: sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==} + to-object-path@0.3.0: resolution: {integrity: sha512-9mWHdnGRuh3onocaHzukyvCZhzvr6tiflAy/JRFXcJX0TjgfWA9pk9t8CMbzmBE4Jfw58pXbkngtBtqYxzNEyg==} engines: {node: '>=0.10.0'} @@ -3213,6 +5387,10 @@ packages: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} + toidentifier@1.0.1: + resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==} + engines: {node: '>=0.6'} + totalist@3.0.1: resolution: {integrity: sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==} engines: {node: '>=6'} @@ -3234,6 +5412,16 @@ packages: resolution: {integrity: sha512-zAOzDnd5qsfEnjd9IGy1IRuvA7ygyyxxdxesbhMdutt8AHFjD8Vw8hU2rMF89HX1BKRWFYqKHrO8Q6lw0NeUZg==} hasBin: true + tsconfck@3.1.6: + resolution: {integrity: sha512-ks6Vjr/jEw0P1gmOVwutM3B7fWxoWBL2KRDb1JfqGVawBmO5UsvmWOQFGHBPl5yxYz4eERr19E6L7NMv+Fej4w==} + engines: {node: ^18 || >=20} + hasBin: true + peerDependencies: + typescript: ^5.0.0 + peerDependenciesMeta: + typescript: + optional: true + tsconfig-paths@4.2.0: resolution: {integrity: sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==} engines: {node: '>=6'} @@ -3260,43 +5448,80 @@ packages: peerDependencies: typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' - tsx@4.20.3: - resolution: {integrity: sha512-qjbnuR9Tr+FJOMBqJCW5ehvIo/buZq7vH7qD7JziU98h6l3qGy0a/yPFjwO+y0/T7GFpNgNAvEcPPVfyT8rrPQ==} + tsx@4.20.5: + resolution: {integrity: sha512-+wKjMNU9w/EaQayHXb7WA7ZaHY6hN8WgfvHNQ3t1PnU91/7O8TcTnIhCDYTZwnt8JsO9IBqZ30Ln1r7pPF52Aw==} engines: {node: '>=18.0.0'} hasBin: true + tunnel-agent@0.6.0: + resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==} + + tweetnacl@0.14.5: + resolution: {integrity: sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==} + type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} + type-detect@4.0.8: + resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==} + engines: {node: '>=4'} + + type-fest@0.7.1: + resolution: {integrity: sha512-Ne2YiiGN8bmrmJJEuTWTLJR32nh/JdL1+PSicowtNb0WFpn59GK8/lfD61bVtzguz7b3PBt74nxpv/Pw5po5Rg==} + engines: {node: '>=8'} + typedarray@0.0.6: resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==} - typescript-eslint@8.38.0: - resolution: {integrity: sha512-FsZlrYK6bPDGoLeZRuvx2v6qrM03I0U0SnfCLPs/XCCPCFD80xU9Pg09H/K+XFa68uJuZo7l/Xhs+eDRg2l3hg==} + typescript-eslint@8.41.0: + resolution: {integrity: sha512-n66rzs5OBXW3SFSnZHr2T685q1i4ODm2nulFJhMZBotaTavsS8TrI3d7bDlRSs9yWo7HmyWrN9qDu14Qv7Y0Dw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 - typescript: '>=4.8.4 <5.9.0' + typescript: '>=4.8.4 <6.0.0' - typescript@5.8.3: - resolution: {integrity: sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==} + typescript@5.9.2: + resolution: {integrity: sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==} engines: {node: '>=14.17'} hasBin: true - undici-types@7.8.0: - resolution: {integrity: sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw==} + undici-types@5.26.5: + resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} - undici@7.12.0: - resolution: {integrity: sha512-GrKEsc3ughskmGA9jevVlIOPMiiAHJ4OFUtaAH+NhfTUSiZ1wMPIQqQvAJUrJspFXJt3EBWgpAeoHEDVT1IBug==} + undici-types@7.10.0: + resolution: {integrity: sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag==} + + undici@7.15.0: + resolution: {integrity: sha512-7oZJCPvvMvTd0OlqWsIxTuItTpJBpU1tcbVl24FMn3xt3+VSunwUasmfPJRE57oNO1KsZ4PgA1xTdAX4hq8NyQ==} engines: {node: '>=20.18.1'} + unicode-canonical-property-names-ecmascript@2.0.1: + resolution: {integrity: sha512-dA8WbNeb2a6oQzAQ55YlT5vQAWGV9WXOsi3SskE3bcCdM0P4SDd+24zS/OCacdRq5BkdsRj9q3Pg6YyQoxIGqg==} + engines: {node: '>=4'} + + unicode-match-property-ecmascript@2.0.0: + resolution: {integrity: sha512-5kaZCrbp5mmbz5ulBkDkbY0SsPOjKqVS35VpL9ulMPfSl0J0Xsm+9Evphv9CoIZFwre7aJoa94AY6seMKGVN5Q==} + engines: {node: '>=4'} + + unicode-match-property-value-ecmascript@2.2.0: + resolution: {integrity: sha512-4IehN3V/+kkr5YeSSDDQG8QLqO26XpL2XP3GQtqwlT/QYSECAwFztxVHjlbh0+gjJ3XmNLS0zDsbgs9jWKExLg==} + engines: {node: '>=4'} + + unicode-property-aliases-ecmascript@2.1.0: + resolution: {integrity: sha512-6t3foTQI9qne+OZoVQB/8x8rk2k1eVy1gRXhV3oFQ5T6R1dqQ1xtin3XqSlx3+ATBkliTaR/hHyJBm+LVPNM8w==} + engines: {node: '>=4'} + universalify@0.1.2: resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} engines: {node: '>= 4.0.0'} - unplugin-utils@0.2.4: - resolution: {integrity: sha512-8U/MtpkPkkk3Atewj1+RcKIjb5WBimZ/WSLhhR3w6SsIj8XJuKTacSP8g+2JhfSGw0Cb125Y+2zA/IzJZDVbhA==} + unpipe@1.0.0: + resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==} + engines: {node: '>= 0.8'} + + unplugin-utils@0.2.5: + resolution: {integrity: sha512-gwXJnPRewT4rT7sBi/IvxKTjsms7jX7QIDLOClApuZwR49SXbrB1z2NLUZ+vDHyqCj/n58OzRRqaW+B8OZi8vg==} engines: {node: '>=18.12.0'} unrs-resolver@1.11.1: @@ -3314,6 +5539,22 @@ packages: util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} + utils-merge@1.0.1: + resolution: {integrity: sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==} + engines: {node: '>= 0.4.0'} + + uuid@10.0.0: + resolution: {integrity: sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==} + hasBin: true + + uuid@11.1.0: + resolution: {integrity: sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==} + hasBin: true + + uuid@8.3.2: + resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==} + hasBin: true + valibot@1.1.0: resolution: {integrity: sha512-Nk8lX30Qhu+9txPYTwM0cFlWLdPFsFr6LblzqIySfbZph9+BFsAHsNvHOymEviUepeIW6KFHzpX8TKhbptBXXw==} peerDependencies: @@ -3327,8 +5568,16 @@ packages: engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} hasBin: true - vite@7.0.5: - resolution: {integrity: sha512-1mncVwJxy2C9ThLwz0+2GKZyEXuC3MyWtAAlNftlZZXZDP3AJt5FmwcMit/IGGaNZ8ZOB2BNO/HFUB+CpN0NQw==} + vite-tsconfig-paths@5.1.4: + resolution: {integrity: sha512-cYj0LRuLV2c2sMqhqhGpaO3LretdtMn/BVX4cPLanIZuwwrkVl+lK84E/miEXkCHWXuq65rhNN4rXsBcOB3S4w==} + peerDependencies: + vite: '*' + peerDependenciesMeta: + vite: + optional: true + + vite@7.1.3: + resolution: {integrity: sha512-OOUi5zjkDxYrKhTV3V7iKsoS37VUM7v40+HuwEmcrsf11Cdx9y3DIr2Px6liIcZFwt3XSRpQvFpL3WVy7ApkGw==} engines: {node: ^20.19.0 || >=22.12.0} hasBin: true peerDependencies: @@ -3400,16 +5649,29 @@ packages: jsdom: optional: true + vlq@1.0.1: + resolution: {integrity: sha512-gQpnTgkubC6hQgdIcRdYGDSDc+SaujOdyesZQMv6JlfQee/9Mp0Qhnys6WxDWvQnL5WZdT7o2Ul187aSt0Rq+w==} + walkdir@0.4.1: resolution: {integrity: sha512-3eBwRyEln6E1MSzcxcVpQIhRG8Q1jLvEqRmCZqS3dsfXEDR/AhOF4d+jHg1qvDCpYaVRZjENPQyrVxAkQqxPgQ==} engines: {node: '>=6.0.0'} + walker@1.0.8: + resolution: {integrity: sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==} + wcwidth@1.0.1: resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==} + web-streams-polyfill@3.3.3: + resolution: {integrity: sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==} + engines: {node: '>= 8'} + webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} + whatwg-fetch@3.6.20: + resolution: {integrity: sha512-EqhiFU6daOA8kpjOWTL0olhVOF3i7OrFzSYiGsEMB8GcXS+RrzauAERX65xMeNWVqxA6HXH2m69Z9LaKKdisfg==} + whatwg-url@5.0.0: resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} @@ -3432,6 +5694,11 @@ packages: resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==} engines: {node: '>=0.10.0'} + workerd@1.20250823.0: + resolution: {integrity: sha512-95lToK9zeaC7bX5ZmlP/wz6zqoUPBk3hhec1JjEMGZrxsXY9cPRkjWNCcjDctQ17U97vjMcY/ymchgx7w8Cfmg==} + engines: {node: '>=16'} + hasBin: true + wrap-ansi@7.0.0: resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} engines: {node: '>=10'} @@ -3443,10 +5710,49 @@ packages: wrappy@1.0.2: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} + write-file-atomic@4.0.2: + resolution: {integrity: sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==} + engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} + write-file-atomic@5.0.1: resolution: {integrity: sha512-+QU2zd6OTD8XWIJCbffaiQeH9U73qIqafo1x6V1snCWYGJf6cVE0cDR4D8xRzcEnfI21IFrUPzPGtcPf8AC+Rw==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + ws@6.2.3: + resolution: {integrity: sha512-jmTjYU0j60B+vHey6TfR3Z7RD61z/hmxBS3VMSGIrroOWXQEneK1zNuotOUrGyBHQj0yrpsLHPWtigEFd13ndA==} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + + ws@7.5.10: + resolution: {integrity: sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==} + engines: {node: '>=8.3.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + + ws@8.18.0: + resolution: {integrity: sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==} + engines: {node: '>=10.0.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: '>=5.0.2' + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + ws@8.18.3: resolution: {integrity: sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==} engines: {node: '>=10.0.0'} @@ -3459,6 +5765,10 @@ packages: utf-8-validate: optional: true + wsl-utils@0.1.0: + resolution: {integrity: sha512-h3Fbisa2nKGPxCpm89Hk33lBLsnaGBvctQopaBSOW/uIs6FTe1ATyAnKFJrzVs9vpGdsTe73WF3V4lIsk4Gacw==} + engines: {node: '>=18'} + xtend@4.0.2: resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} engines: {node: '>=0.4'} @@ -3474,6 +5784,11 @@ packages: resolution: {integrity: sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==} engines: {node: '>=18'} + yaml@2.8.1: + resolution: {integrity: sha512-lcYcMxX2PO9XMGvAJkJ3OsNMw+/7FKes7/hgerGUYWIoWu5j/+YQqcZr5JnPZWzOsEBgMbSbiSTn/dv/69Mkpw==} + engines: {node: '>= 14.6'} + hasBin: true + yargs-parser@21.1.1: resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} engines: {node: '>=12'} @@ -3486,15 +5801,28 @@ packages: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} - zod@4.0.7: - resolution: {integrity: sha512-AKvYUuvqmyRf21eNxjuO++WPrQHhWg8i/4POzBLL//qVhcxA6gOptSDxXKM2S+uh8FtPV3MU/QZKOxqwsRV5kg==} + youch-core@0.3.3: + resolution: {integrity: sha512-ho7XuGjLaJ2hWHoK8yFnsUGy2Y5uDpqSTq1FkHLK4/oqKtyUU1AFbOOxY4IpC9f0fTLjwYbslUz0Po5BpD1wrA==} + + youch@4.1.0-beta.10: + resolution: {integrity: sha512-rLfVLB4FgQneDr0dv1oddCVZmKjcJ6yX6mS4pU82Mq/Dt9a3cLZQ62pDBL4AUO+uVrCvtWz3ZFUL2HFAFJ/BXQ==} + + zip-stream@6.0.1: + resolution: {integrity: sha512-zK7YHHz4ZXpW89AHXUPbQVGKI7uvkd3hzusTdotCg1UxyaVtg0zFJSTfW/Dq5f7OBBVnq6cZIaC8Ti4hb6dtCA==} + engines: {node: '>= 14'} + + zod@3.22.3: + resolution: {integrity: sha512-EjIevzuJRiRPbVH4mGc8nApb/lVLKVpmUhAaR5R5doKGfAnGJ6Gr3CViAVjP+4FWSxCsybeWQdcgCtbX+7oZug==} + + zod@4.1.3: + resolution: {integrity: sha512-1neef4bMce1hNTrxvHVKxWjKfGDn0oAli3Wy1Uwb7TRO1+wEwoZUZNP1NXIEESybOBiFnBOhI6a4m6tCLE8dog==} snapshots: '@ampproject/remapping@2.3.0': dependencies: - '@jridgewell/gen-mapping': 0.3.12 - '@jridgewell/trace-mapping': 0.3.29 + '@jridgewell/gen-mapping': 0.3.13 + '@jridgewell/trace-mapping': 0.3.30 '@ark/schema@0.46.0': dependencies: @@ -3502,10 +5830,155 @@ snapshots: '@ark/util@0.46.0': {} - '@babel/cli@7.28.0(@babel/core@7.28.0)': + '@azure-rest/core-client@2.5.0': dependencies: - '@babel/core': 7.28.0 - '@jridgewell/trace-mapping': 0.3.29 + '@azure/abort-controller': 2.1.2 + '@azure/core-auth': 1.10.0 + '@azure/core-rest-pipeline': 1.22.0 + '@azure/core-tracing': 1.3.0 + '@typespec/ts-http-runtime': 0.3.0 + tslib: 2.8.1 + transitivePeerDependencies: + - supports-color + + '@azure/abort-controller@2.1.2': + dependencies: + tslib: 2.8.1 + + '@azure/core-auth@1.10.0': + dependencies: + '@azure/abort-controller': 2.1.2 + '@azure/core-util': 1.13.0 + tslib: 2.8.1 + transitivePeerDependencies: + - supports-color + + '@azure/core-client@1.10.0': + dependencies: + '@azure/abort-controller': 2.1.2 + '@azure/core-auth': 1.10.0 + '@azure/core-rest-pipeline': 1.22.0 + '@azure/core-tracing': 1.3.0 + '@azure/core-util': 1.13.0 + '@azure/logger': 1.3.0 + tslib: 2.8.1 + transitivePeerDependencies: + - supports-color + + '@azure/core-http-compat@2.3.0': + dependencies: + '@azure/abort-controller': 2.1.2 + '@azure/core-client': 1.10.0 + '@azure/core-rest-pipeline': 1.22.0 + transitivePeerDependencies: + - supports-color + + '@azure/core-lro@2.7.2': + dependencies: + '@azure/abort-controller': 2.1.2 + '@azure/core-util': 1.13.0 + '@azure/logger': 1.3.0 + tslib: 2.8.1 + transitivePeerDependencies: + - supports-color + + '@azure/core-paging@1.6.2': + dependencies: + tslib: 2.8.1 + + '@azure/core-rest-pipeline@1.22.0': + dependencies: + '@azure/abort-controller': 2.1.2 + '@azure/core-auth': 1.10.0 + '@azure/core-tracing': 1.3.0 + '@azure/core-util': 1.13.0 + '@azure/logger': 1.3.0 + '@typespec/ts-http-runtime': 0.3.0 + tslib: 2.8.1 + transitivePeerDependencies: + - supports-color + + '@azure/core-tracing@1.3.0': + dependencies: + tslib: 2.8.1 + + '@azure/core-util@1.13.0': + dependencies: + '@azure/abort-controller': 2.1.2 + '@typespec/ts-http-runtime': 0.3.0 + tslib: 2.8.1 + transitivePeerDependencies: + - supports-color + + '@azure/identity@4.11.1': + dependencies: + '@azure/abort-controller': 2.1.2 + '@azure/core-auth': 1.10.0 + '@azure/core-client': 1.10.0 + '@azure/core-rest-pipeline': 1.22.0 + '@azure/core-tracing': 1.3.0 + '@azure/core-util': 1.13.0 + '@azure/logger': 1.3.0 + '@azure/msal-browser': 4.21.1 + '@azure/msal-node': 3.7.3 + open: 10.2.0 + tslib: 2.8.1 + transitivePeerDependencies: + - supports-color + + '@azure/keyvault-common@2.0.0': + dependencies: + '@azure/abort-controller': 2.1.2 + '@azure/core-auth': 1.10.0 + '@azure/core-client': 1.10.0 + '@azure/core-rest-pipeline': 1.22.0 + '@azure/core-tracing': 1.3.0 + '@azure/core-util': 1.13.0 + '@azure/logger': 1.3.0 + tslib: 2.8.1 + transitivePeerDependencies: + - supports-color + + '@azure/keyvault-keys@4.10.0': + dependencies: + '@azure-rest/core-client': 2.5.0 + '@azure/abort-controller': 2.1.2 + '@azure/core-auth': 1.10.0 + '@azure/core-http-compat': 2.3.0 + '@azure/core-lro': 2.7.2 + '@azure/core-paging': 1.6.2 + '@azure/core-rest-pipeline': 1.22.0 + '@azure/core-tracing': 1.3.0 + '@azure/core-util': 1.13.0 + '@azure/keyvault-common': 2.0.0 + '@azure/logger': 1.3.0 + tslib: 2.8.1 + transitivePeerDependencies: + - supports-color + + '@azure/logger@1.3.0': + dependencies: + '@typespec/ts-http-runtime': 0.3.0 + tslib: 2.8.1 + transitivePeerDependencies: + - supports-color + + '@azure/msal-browser@4.21.1': + dependencies: + '@azure/msal-common': 15.12.0 + + '@azure/msal-common@15.12.0': {} + + '@azure/msal-node@3.7.3': + dependencies: + '@azure/msal-common': 15.12.0 + jsonwebtoken: 9.0.2 + uuid: 8.3.2 + + '@babel/cli@7.28.3(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@jridgewell/trace-mapping': 0.3.30 commander: 6.2.1 convert-source-map: 2.0.0 fs-readdir-recursive: 1.1.0 @@ -3524,18 +5997,18 @@ snapshots: '@babel/compat-data@7.28.0': {} - '@babel/core@7.28.0': + '@babel/core@7.28.3': dependencies: '@ampproject/remapping': 2.3.0 '@babel/code-frame': 7.27.1 - '@babel/generator': 7.28.0 + '@babel/generator': 7.28.3 '@babel/helper-compilation-targets': 7.27.2 - '@babel/helper-module-transforms': 7.27.3(@babel/core@7.28.0) - '@babel/helpers': 7.27.6 - '@babel/parser': 7.28.0 + '@babel/helper-module-transforms': 7.28.3(@babel/core@7.28.3) + '@babel/helpers': 7.28.3 + '@babel/parser': 7.28.3 '@babel/template': 7.27.2 - '@babel/traverse': 7.28.0 - '@babel/types': 7.28.1 + '@babel/traverse': 7.28.3 + '@babel/types': 7.28.2 convert-source-map: 2.0.0 debug: 4.4.1 gensync: 1.0.0-beta.2 @@ -3544,83 +6017,110 @@ snapshots: transitivePeerDependencies: - supports-color - '@babel/generator@7.28.0': + '@babel/generator@7.28.3': dependencies: - '@babel/parser': 7.28.0 - '@babel/types': 7.28.1 - '@jridgewell/gen-mapping': 0.3.12 - '@jridgewell/trace-mapping': 0.3.29 + '@babel/parser': 7.28.3 + '@babel/types': 7.28.2 + '@jridgewell/gen-mapping': 0.3.13 + '@jridgewell/trace-mapping': 0.3.30 jsesc: 3.1.0 '@babel/helper-annotate-as-pure@7.27.3': dependencies: - '@babel/types': 7.28.1 + '@babel/types': 7.28.2 '@babel/helper-compilation-targets@7.27.2': dependencies: '@babel/compat-data': 7.28.0 '@babel/helper-validator-option': 7.27.1 - browserslist: 4.25.1 + browserslist: 4.25.3 lru-cache: 5.1.1 semver: 6.3.1 - '@babel/helper-create-class-features-plugin@7.27.1(@babel/core@7.28.0)': + '@babel/helper-create-class-features-plugin@7.28.3(@babel/core@7.28.3)': dependencies: - '@babel/core': 7.28.0 + '@babel/core': 7.28.3 '@babel/helper-annotate-as-pure': 7.27.3 '@babel/helper-member-expression-to-functions': 7.27.1 '@babel/helper-optimise-call-expression': 7.27.1 - '@babel/helper-replace-supers': 7.27.1(@babel/core@7.28.0) + '@babel/helper-replace-supers': 7.27.1(@babel/core@7.28.3) '@babel/helper-skip-transparent-expression-wrappers': 7.27.1 - '@babel/traverse': 7.28.0 + '@babel/traverse': 7.28.3 semver: 6.3.1 transitivePeerDependencies: - supports-color + '@babel/helper-create-regexp-features-plugin@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-annotate-as-pure': 7.27.3 + regexpu-core: 6.2.0 + semver: 6.3.1 + + '@babel/helper-define-polyfill-provider@0.6.5(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-compilation-targets': 7.27.2 + '@babel/helper-plugin-utils': 7.27.1 + debug: 4.4.1 + lodash.debounce: 4.0.8 + resolve: 1.22.10 + transitivePeerDependencies: + - supports-color + '@babel/helper-globals@7.28.0': {} '@babel/helper-member-expression-to-functions@7.27.1': dependencies: - '@babel/traverse': 7.28.0 - '@babel/types': 7.28.1 + '@babel/traverse': 7.28.3 + '@babel/types': 7.28.2 transitivePeerDependencies: - supports-color '@babel/helper-module-imports@7.27.1': dependencies: - '@babel/traverse': 7.28.0 - '@babel/types': 7.28.1 + '@babel/traverse': 7.28.3 + '@babel/types': 7.28.2 transitivePeerDependencies: - supports-color - '@babel/helper-module-transforms@7.27.3(@babel/core@7.28.0)': + '@babel/helper-module-transforms@7.28.3(@babel/core@7.28.3)': dependencies: - '@babel/core': 7.28.0 + '@babel/core': 7.28.3 '@babel/helper-module-imports': 7.27.1 '@babel/helper-validator-identifier': 7.27.1 - '@babel/traverse': 7.28.0 + '@babel/traverse': 7.28.3 transitivePeerDependencies: - supports-color '@babel/helper-optimise-call-expression@7.27.1': dependencies: - '@babel/types': 7.28.1 + '@babel/types': 7.28.2 '@babel/helper-plugin-utils@7.27.1': {} - '@babel/helper-replace-supers@7.27.1(@babel/core@7.28.0)': + '@babel/helper-remap-async-to-generator@7.27.1(@babel/core@7.28.3)': dependencies: - '@babel/core': 7.28.0 + '@babel/core': 7.28.3 + '@babel/helper-annotate-as-pure': 7.27.3 + '@babel/helper-wrap-function': 7.28.3 + '@babel/traverse': 7.28.3 + transitivePeerDependencies: + - supports-color + + '@babel/helper-replace-supers@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 '@babel/helper-member-expression-to-functions': 7.27.1 '@babel/helper-optimise-call-expression': 7.27.1 - '@babel/traverse': 7.28.0 + '@babel/traverse': 7.28.3 transitivePeerDependencies: - supports-color '@babel/helper-skip-transparent-expression-wrappers@7.27.1': dependencies: - '@babel/traverse': 7.28.0 - '@babel/types': 7.28.1 + '@babel/traverse': 7.28.3 + '@babel/types': 7.28.2 transitivePeerDependencies: - supports-color @@ -3630,148 +6130,437 @@ snapshots: '@babel/helper-validator-option@7.27.1': {} - '@babel/helpers@7.27.6': + '@babel/helper-wrap-function@7.28.3': dependencies: '@babel/template': 7.27.2 - '@babel/types': 7.28.1 + '@babel/traverse': 7.28.3 + '@babel/types': 7.28.2 + transitivePeerDependencies: + - supports-color - '@babel/parser@7.28.0': + '@babel/helpers@7.28.3': dependencies: - '@babel/types': 7.28.1 + '@babel/template': 7.27.2 + '@babel/types': 7.28.2 - '@babel/plugin-syntax-flow@7.27.1(@babel/core@7.28.0)': + '@babel/parser@7.28.3': dependencies: - '@babel/core': 7.28.0 + '@babel/types': 7.28.2 + + '@babel/plugin-proposal-export-default-from@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 '@babel/helper-plugin-utils': 7.27.1 - '@babel/plugin-syntax-jsx@7.27.1(@babel/core@7.28.0)': + '@babel/plugin-syntax-async-generators@7.8.4(@babel/core@7.28.3)': dependencies: - '@babel/core': 7.28.0 + '@babel/core': 7.28.3 '@babel/helper-plugin-utils': 7.27.1 - '@babel/plugin-syntax-typescript@7.27.1(@babel/core@7.28.0)': + '@babel/plugin-syntax-bigint@7.8.3(@babel/core@7.28.3)': dependencies: - '@babel/core': 7.28.0 + '@babel/core': 7.28.3 '@babel/helper-plugin-utils': 7.27.1 - '@babel/plugin-transform-class-properties@7.27.1(@babel/core@7.28.0)': + '@babel/plugin-syntax-class-properties@7.12.13(@babel/core@7.28.3)': dependencies: - '@babel/core': 7.28.0 - '@babel/helper-create-class-features-plugin': 7.27.1(@babel/core@7.28.0) + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-syntax-class-static-block@7.14.5(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-syntax-dynamic-import@7.8.3(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-syntax-export-default-from@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-syntax-flow@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-syntax-import-attributes@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-syntax-import-meta@7.10.4(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-syntax-json-strings@7.8.3(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-syntax-jsx@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-syntax-logical-assignment-operators@7.10.4(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-syntax-nullish-coalescing-operator@7.8.3(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-syntax-numeric-separator@7.10.4(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-syntax-object-rest-spread@7.8.3(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-syntax-optional-catch-binding@7.8.3(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-syntax-optional-chaining@7.8.3(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-syntax-private-property-in-object@7.14.5(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-syntax-top-level-await@7.14.5(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-syntax-typescript@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-transform-arrow-functions@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-transform-async-generator-functions@7.28.0(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + '@babel/helper-remap-async-to-generator': 7.27.1(@babel/core@7.28.3) + '@babel/traverse': 7.28.3 + transitivePeerDependencies: + - supports-color + + '@babel/plugin-transform-async-to-generator@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-module-imports': 7.27.1 + '@babel/helper-plugin-utils': 7.27.1 + '@babel/helper-remap-async-to-generator': 7.27.1(@babel/core@7.28.3) + transitivePeerDependencies: + - supports-color + + '@babel/plugin-transform-block-scoping@7.28.0(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-transform-class-properties@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-create-class-features-plugin': 7.28.3(@babel/core@7.28.3) '@babel/helper-plugin-utils': 7.27.1 transitivePeerDependencies: - supports-color - '@babel/plugin-transform-export-namespace-from@7.27.1(@babel/core@7.28.0)': + '@babel/plugin-transform-classes@7.28.3(@babel/core@7.28.3)': dependencies: - '@babel/core': 7.28.0 - '@babel/helper-plugin-utils': 7.27.1 - - '@babel/plugin-transform-flow-strip-types@7.27.1(@babel/core@7.28.0)': - dependencies: - '@babel/core': 7.28.0 - '@babel/helper-plugin-utils': 7.27.1 - '@babel/plugin-syntax-flow': 7.27.1(@babel/core@7.28.0) - - '@babel/plugin-transform-modules-commonjs@7.27.1(@babel/core@7.28.0)': - dependencies: - '@babel/core': 7.28.0 - '@babel/helper-module-transforms': 7.27.3(@babel/core@7.28.0) - '@babel/helper-plugin-utils': 7.27.1 - transitivePeerDependencies: - - supports-color - - '@babel/plugin-transform-nullish-coalescing-operator@7.27.1(@babel/core@7.28.0)': - dependencies: - '@babel/core': 7.28.0 - '@babel/helper-plugin-utils': 7.27.1 - - '@babel/plugin-transform-optional-chaining@7.27.1(@babel/core@7.28.0)': - dependencies: - '@babel/core': 7.28.0 - '@babel/helper-plugin-utils': 7.27.1 - '@babel/helper-skip-transparent-expression-wrappers': 7.27.1 - transitivePeerDependencies: - - supports-color - - '@babel/plugin-transform-private-methods@7.27.1(@babel/core@7.28.0)': - dependencies: - '@babel/core': 7.28.0 - '@babel/helper-create-class-features-plugin': 7.27.1(@babel/core@7.28.0) - '@babel/helper-plugin-utils': 7.27.1 - transitivePeerDependencies: - - supports-color - - '@babel/plugin-transform-typescript@7.28.0(@babel/core@7.28.0)': - dependencies: - '@babel/core': 7.28.0 + '@babel/core': 7.28.3 '@babel/helper-annotate-as-pure': 7.27.3 - '@babel/helper-create-class-features-plugin': 7.27.1(@babel/core@7.28.0) + '@babel/helper-compilation-targets': 7.27.2 + '@babel/helper-globals': 7.28.0 + '@babel/helper-plugin-utils': 7.27.1 + '@babel/helper-replace-supers': 7.27.1(@babel/core@7.28.3) + '@babel/traverse': 7.28.3 + transitivePeerDependencies: + - supports-color + + '@babel/plugin-transform-computed-properties@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + '@babel/template': 7.27.2 + + '@babel/plugin-transform-destructuring@7.28.0(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + '@babel/traverse': 7.28.3 + transitivePeerDependencies: + - supports-color + + '@babel/plugin-transform-export-namespace-from@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-transform-flow-strip-types@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + '@babel/plugin-syntax-flow': 7.27.1(@babel/core@7.28.3) + + '@babel/plugin-transform-for-of@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 '@babel/helper-plugin-utils': 7.27.1 '@babel/helper-skip-transparent-expression-wrappers': 7.27.1 - '@babel/plugin-syntax-typescript': 7.27.1(@babel/core@7.28.0) transitivePeerDependencies: - supports-color - '@babel/preset-flow@7.27.1(@babel/core@7.28.0)': + '@babel/plugin-transform-function-name@7.27.1(@babel/core@7.28.3)': dependencies: - '@babel/core': 7.28.0 + '@babel/core': 7.28.3 + '@babel/helper-compilation-targets': 7.27.2 '@babel/helper-plugin-utils': 7.27.1 - '@babel/helper-validator-option': 7.27.1 - '@babel/plugin-transform-flow-strip-types': 7.27.1(@babel/core@7.28.0) - - '@babel/preset-typescript@7.27.1(@babel/core@7.28.0)': - dependencies: - '@babel/core': 7.28.0 - '@babel/helper-plugin-utils': 7.27.1 - '@babel/helper-validator-option': 7.27.1 - '@babel/plugin-syntax-jsx': 7.27.1(@babel/core@7.28.0) - '@babel/plugin-transform-modules-commonjs': 7.27.1(@babel/core@7.28.0) - '@babel/plugin-transform-typescript': 7.28.0(@babel/core@7.28.0) + '@babel/traverse': 7.28.3 transitivePeerDependencies: - supports-color - '@babel/register@7.27.1(@babel/core@7.28.0)': + '@babel/plugin-transform-literals@7.27.1(@babel/core@7.28.3)': dependencies: - '@babel/core': 7.28.0 + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-transform-logical-assignment-operators@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-transform-modules-commonjs@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-module-transforms': 7.28.3(@babel/core@7.28.3) + '@babel/helper-plugin-utils': 7.27.1 + transitivePeerDependencies: + - supports-color + + '@babel/plugin-transform-named-capturing-groups-regex@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-create-regexp-features-plugin': 7.27.1(@babel/core@7.28.3) + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-transform-nullish-coalescing-operator@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-transform-numeric-separator@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-transform-object-rest-spread@7.28.0(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-compilation-targets': 7.27.2 + '@babel/helper-plugin-utils': 7.27.1 + '@babel/plugin-transform-destructuring': 7.28.0(@babel/core@7.28.3) + '@babel/plugin-transform-parameters': 7.27.7(@babel/core@7.28.3) + '@babel/traverse': 7.28.3 + transitivePeerDependencies: + - supports-color + + '@babel/plugin-transform-optional-catch-binding@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-transform-optional-chaining@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + '@babel/helper-skip-transparent-expression-wrappers': 7.27.1 + transitivePeerDependencies: + - supports-color + + '@babel/plugin-transform-parameters@7.27.7(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-transform-private-methods@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-create-class-features-plugin': 7.28.3(@babel/core@7.28.3) + '@babel/helper-plugin-utils': 7.27.1 + transitivePeerDependencies: + - supports-color + + '@babel/plugin-transform-private-property-in-object@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-annotate-as-pure': 7.27.3 + '@babel/helper-create-class-features-plugin': 7.28.3(@babel/core@7.28.3) + '@babel/helper-plugin-utils': 7.27.1 + transitivePeerDependencies: + - supports-color + + '@babel/plugin-transform-react-display-name@7.28.0(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-transform-react-jsx-self@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-transform-react-jsx-source@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-transform-react-jsx@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-annotate-as-pure': 7.27.3 + '@babel/helper-module-imports': 7.27.1 + '@babel/helper-plugin-utils': 7.27.1 + '@babel/plugin-syntax-jsx': 7.27.1(@babel/core@7.28.3) + '@babel/types': 7.28.2 + transitivePeerDependencies: + - supports-color + + '@babel/plugin-transform-regenerator@7.28.3(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-transform-runtime@7.28.3(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-module-imports': 7.27.1 + '@babel/helper-plugin-utils': 7.27.1 + babel-plugin-polyfill-corejs2: 0.4.14(@babel/core@7.28.3) + babel-plugin-polyfill-corejs3: 0.13.0(@babel/core@7.28.3) + babel-plugin-polyfill-regenerator: 0.6.5(@babel/core@7.28.3) + semver: 6.3.1 + transitivePeerDependencies: + - supports-color + + '@babel/plugin-transform-shorthand-properties@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-transform-spread@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + '@babel/helper-skip-transparent-expression-wrappers': 7.27.1 + transitivePeerDependencies: + - supports-color + + '@babel/plugin-transform-sticky-regex@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-transform-typescript@7.28.0(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-annotate-as-pure': 7.27.3 + '@babel/helper-create-class-features-plugin': 7.28.3(@babel/core@7.28.3) + '@babel/helper-plugin-utils': 7.27.1 + '@babel/helper-skip-transparent-expression-wrappers': 7.27.1 + '@babel/plugin-syntax-typescript': 7.27.1(@babel/core@7.28.3) + transitivePeerDependencies: + - supports-color + + '@babel/plugin-transform-unicode-regex@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-create-regexp-features-plugin': 7.27.1(@babel/core@7.28.3) + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/preset-flow@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + '@babel/helper-validator-option': 7.27.1 + '@babel/plugin-transform-flow-strip-types': 7.27.1(@babel/core@7.28.3) + + '@babel/preset-typescript@7.27.1(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-plugin-utils': 7.27.1 + '@babel/helper-validator-option': 7.27.1 + '@babel/plugin-syntax-jsx': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-modules-commonjs': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-typescript': 7.28.0(@babel/core@7.28.3) + transitivePeerDependencies: + - supports-color + + '@babel/register@7.28.3(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 clone-deep: 4.0.1 find-cache-dir: 2.1.0 make-dir: 2.1.0 pirates: 4.0.7 source-map-support: 0.5.21 - '@babel/runtime@7.27.6': {} + '@babel/runtime@7.28.3': {} '@babel/template@7.27.2': dependencies: '@babel/code-frame': 7.27.1 - '@babel/parser': 7.28.0 - '@babel/types': 7.28.1 + '@babel/parser': 7.28.3 + '@babel/types': 7.28.2 - '@babel/traverse@7.28.0': + '@babel/traverse@7.28.3': dependencies: '@babel/code-frame': 7.27.1 - '@babel/generator': 7.28.0 + '@babel/generator': 7.28.3 '@babel/helper-globals': 7.28.0 - '@babel/parser': 7.28.0 + '@babel/parser': 7.28.3 '@babel/template': 7.27.2 - '@babel/types': 7.28.1 + '@babel/types': 7.28.2 debug: 4.4.1 transitivePeerDependencies: - supports-color - '@babel/types@7.28.1': + '@babel/types@7.28.2': dependencies: '@babel/helper-string-parser': 7.27.1 '@babel/helper-validator-identifier': 7.27.1 + '@balena/dockerignore@1.0.2': {} + '@bcoe/v8-coverage@1.0.2': {} - '@bundle-stats/cli-utils@4.21.0(core-js@3.44.0)': + '@bundle-stats/cli-utils@4.21.3(core-js@3.45.1)': dependencies: - '@bundle-stats/html-templates': 4.21.0 - '@bundle-stats/plugin-webpack-filter': 4.21.0(core-js@3.44.0) - '@bundle-stats/utils': 4.21.0(core-js@3.44.0)(lodash@4.17.21) + '@bundle-stats/html-templates': 4.21.3 + '@bundle-stats/plugin-webpack-filter': 4.21.3(core-js@3.45.1) + '@bundle-stats/utils': 4.21.3(core-js@3.45.1)(lodash@4.17.21) find-cache-dir: 3.3.2 lodash: 4.17.21 stream-chain: 3.4.0 @@ -3779,24 +6568,24 @@ snapshots: transitivePeerDependencies: - core-js - '@bundle-stats/html-templates@4.21.0': {} + '@bundle-stats/html-templates@4.21.3': {} - '@bundle-stats/plugin-webpack-filter@4.21.0(core-js@3.44.0)': + '@bundle-stats/plugin-webpack-filter@4.21.3(core-js@3.45.1)': dependencies: - core-js: 3.44.0 + core-js: 3.45.1 tslib: 2.8.1 - '@bundle-stats/plugin-webpack-validate@4.21.0': + '@bundle-stats/plugin-webpack-validate@4.21.3': dependencies: lodash: 4.17.21 superstruct: 2.0.2 tslib: 2.8.1 - '@bundle-stats/utils@4.21.0(core-js@3.44.0)(lodash@4.17.21)': + '@bundle-stats/utils@4.21.3(core-js@3.45.1)(lodash@4.17.21)': dependencies: - '@bundle-stats/plugin-webpack-filter': 4.21.0(core-js@3.44.0) - '@bundle-stats/plugin-webpack-validate': 4.21.0 - core-js: 3.44.0 + '@bundle-stats/plugin-webpack-filter': 4.21.3(core-js@3.45.1) + '@bundle-stats/plugin-webpack-validate': 4.21.3 + core-js: 3.45.1 lodash: 4.17.21 serialize-query-params: 2.0.2 @@ -3837,7 +6626,7 @@ snapshots: transitivePeerDependencies: - encoding - '@changesets/cli@2.29.5': + '@changesets/cli@2.29.6(@types/node@24.3.0)': dependencies: '@changesets/apply-release-plan': 7.0.12 '@changesets/assemble-release-plan': 6.0.9(patch_hash=29cf7a343aefd3c59ad238a4cb067f0a1a0adbeed07b6d57d6f31d6c80a5e25e) @@ -3853,11 +6642,11 @@ snapshots: '@changesets/should-skip-package': 0.1.2 '@changesets/types': 6.1.0 '@changesets/write': 0.4.0 + '@inquirer/external-editor': 1.0.1(@types/node@24.3.0) '@manypkg/get-packages': 1.1.3 ansi-colors: 4.1.3 ci-info: 3.9.0 enquirer: 2.4.1 - external-editor: 3.1.0 fs-extra: 7.0.1 mri: 1.2.0 p-limit: 2.3.0 @@ -3867,6 +6656,8 @@ snapshots: semver: 7.7.2 spawndamnit: 3.0.1 term-size: 2.2.1 + transitivePeerDependencies: + - '@types/node' '@changesets/config@3.1.1': dependencies: @@ -3957,6 +6748,33 @@ snapshots: human-id: 4.1.1 prettier: 2.8.8 + '@clickhouse/client-common@1.12.1': {} + + '@clickhouse/client@1.12.1': + dependencies: + '@clickhouse/client-common': 1.12.1 + + '@cloudflare/workerd-darwin-64@1.20250823.0': + optional: true + + '@cloudflare/workerd-darwin-arm64@1.20250823.0': + optional: true + + '@cloudflare/workerd-linux-64@1.20250823.0': + optional: true + + '@cloudflare/workerd-linux-arm64@1.20250823.0': + optional: true + + '@cloudflare/workerd-windows-64@1.20250823.0': + optional: true + + '@cloudflare/workers-types@4.20250826.0': {} + + '@cspotcode/source-map-support@0.8.1': + dependencies: + '@jridgewell/trace-mapping': 0.3.9 + '@dependents/detective-less@4.1.0': dependencies: gonzales-pe: 4.3.0 @@ -3977,15 +6795,15 @@ snapshots: micromatch: 4.0.8 pkg-entry-points: 1.1.1 - '@effect/docgen@https://pkg.pr.new/Effect-TS/docgen/@effect/docgen@49e99a2(tsx@4.20.3)(typescript@5.8.3)': + '@effect/docgen@https://pkg.pr.new/Effect-TS/docgen/@effect/docgen@49e99a2(tsx@4.20.5)(typescript@5.9.2)': dependencies: '@babel/code-frame': 7.27.1 '@effect/markdown-toc': 0.1.0 doctrine: 3.0.0 glob: 11.0.3 prettier: 3.6.2 - tsx: 4.20.3 - typescript: 5.8.3 + tsx: 4.20.5 + typescript: 5.9.2 '@effect/eslint-plugin@0.3.2': dependencies: @@ -3993,7 +6811,7 @@ snapshots: '@dprint/typescript': 0.91.8 prettier-linter-helpers: 1.0.0 - '@effect/language-service@0.28.3': {} + '@effect/language-service@0.36.0': {} '@effect/markdown-toc@0.1.0': dependencies: @@ -4010,6 +6828,8 @@ snapshots: repeat-string: 1.6.1 strip-color: 0.1.0 + '@effect/wa-sqlite@0.2.1': {} + '@emnapi/core@1.4.5': dependencies: '@emnapi/wasi-threads': 1.0.4 @@ -4026,87 +6846,87 @@ snapshots: tslib: 2.8.1 optional: true - '@esbuild/aix-ppc64@0.25.8': + '@esbuild/aix-ppc64@0.25.9': optional: true - '@esbuild/android-arm64@0.25.8': + '@esbuild/android-arm64@0.25.9': optional: true - '@esbuild/android-arm@0.25.8': + '@esbuild/android-arm@0.25.9': optional: true - '@esbuild/android-x64@0.25.8': + '@esbuild/android-x64@0.25.9': optional: true - '@esbuild/darwin-arm64@0.25.8': + '@esbuild/darwin-arm64@0.25.9': optional: true - '@esbuild/darwin-x64@0.25.8': + '@esbuild/darwin-x64@0.25.9': optional: true - '@esbuild/freebsd-arm64@0.25.8': + '@esbuild/freebsd-arm64@0.25.9': optional: true - '@esbuild/freebsd-x64@0.25.8': + '@esbuild/freebsd-x64@0.25.9': optional: true - '@esbuild/linux-arm64@0.25.8': + '@esbuild/linux-arm64@0.25.9': optional: true - '@esbuild/linux-arm@0.25.8': + '@esbuild/linux-arm@0.25.9': optional: true - '@esbuild/linux-ia32@0.25.8': + '@esbuild/linux-ia32@0.25.9': optional: true - '@esbuild/linux-loong64@0.25.8': + '@esbuild/linux-loong64@0.25.9': optional: true - '@esbuild/linux-mips64el@0.25.8': + '@esbuild/linux-mips64el@0.25.9': optional: true - '@esbuild/linux-ppc64@0.25.8': + '@esbuild/linux-ppc64@0.25.9': optional: true - '@esbuild/linux-riscv64@0.25.8': + '@esbuild/linux-riscv64@0.25.9': optional: true - '@esbuild/linux-s390x@0.25.8': + '@esbuild/linux-s390x@0.25.9': optional: true - '@esbuild/linux-x64@0.25.8': + '@esbuild/linux-x64@0.25.9': optional: true - '@esbuild/netbsd-arm64@0.25.8': + '@esbuild/netbsd-arm64@0.25.9': optional: true - '@esbuild/netbsd-x64@0.25.8': + '@esbuild/netbsd-x64@0.25.9': optional: true - '@esbuild/openbsd-arm64@0.25.8': + '@esbuild/openbsd-arm64@0.25.9': optional: true - '@esbuild/openbsd-x64@0.25.8': + '@esbuild/openbsd-x64@0.25.9': optional: true - '@esbuild/openharmony-arm64@0.25.8': + '@esbuild/openharmony-arm64@0.25.9': optional: true - '@esbuild/sunos-x64@0.25.8': + '@esbuild/sunos-x64@0.25.9': optional: true - '@esbuild/win32-arm64@0.25.8': + '@esbuild/win32-arm64@0.25.9': optional: true - '@esbuild/win32-ia32@0.25.8': + '@esbuild/win32-ia32@0.25.9': optional: true - '@esbuild/win32-x64@0.25.8': + '@esbuild/win32-x64@0.25.9': optional: true - '@eslint-community/eslint-utils@4.7.0(eslint@9.31.0)': + '@eslint-community/eslint-utils@4.7.0(eslint@9.34.0)': dependencies: - eslint: 9.31.0 + eslint: 9.34.0 eslint-visitor-keys: 3.4.3 '@eslint-community/regexpp@4.12.1': {} @@ -4119,9 +6939,9 @@ snapshots: transitivePeerDependencies: - supports-color - '@eslint/config-helpers@0.3.0': {} + '@eslint/config-helpers@0.3.1': {} - '@eslint/core@0.15.1': + '@eslint/core@0.15.2': dependencies: '@types/json-schema': 7.0.15 @@ -4139,15 +6959,27 @@ snapshots: transitivePeerDependencies: - supports-color - '@eslint/js@9.31.0': {} + '@eslint/js@9.34.0': {} '@eslint/object-schema@2.1.6': {} - '@eslint/plugin-kit@0.3.4': + '@eslint/plugin-kit@0.3.5': dependencies: - '@eslint/core': 0.15.1 + '@eslint/core': 0.15.2 levn: 0.4.1 + '@grpc/grpc-js@1.13.4': + dependencies: + '@grpc/proto-loader': 0.7.15 + '@js-sdsl/ordered-map': 4.4.2 + + '@grpc/proto-loader@0.7.15': + dependencies: + lodash.camelcase: 4.3.0 + long: 5.3.2 + protobufjs: 7.5.4 + yargs: 17.7.2 + '@humanfs/core@0.19.1': {} '@humanfs/node@0.16.6': @@ -4161,6 +6993,88 @@ snapshots: '@humanwhocodes/retry@0.4.3': {} + '@img/sharp-darwin-arm64@0.33.5': + optionalDependencies: + '@img/sharp-libvips-darwin-arm64': 1.0.4 + optional: true + + '@img/sharp-darwin-x64@0.33.5': + optionalDependencies: + '@img/sharp-libvips-darwin-x64': 1.0.4 + optional: true + + '@img/sharp-libvips-darwin-arm64@1.0.4': + optional: true + + '@img/sharp-libvips-darwin-x64@1.0.4': + optional: true + + '@img/sharp-libvips-linux-arm64@1.0.4': + optional: true + + '@img/sharp-libvips-linux-arm@1.0.5': + optional: true + + '@img/sharp-libvips-linux-s390x@1.0.4': + optional: true + + '@img/sharp-libvips-linux-x64@1.0.4': + optional: true + + '@img/sharp-libvips-linuxmusl-arm64@1.0.4': + optional: true + + '@img/sharp-libvips-linuxmusl-x64@1.0.4': + optional: true + + '@img/sharp-linux-arm64@0.33.5': + optionalDependencies: + '@img/sharp-libvips-linux-arm64': 1.0.4 + optional: true + + '@img/sharp-linux-arm@0.33.5': + optionalDependencies: + '@img/sharp-libvips-linux-arm': 1.0.5 + optional: true + + '@img/sharp-linux-s390x@0.33.5': + optionalDependencies: + '@img/sharp-libvips-linux-s390x': 1.0.4 + optional: true + + '@img/sharp-linux-x64@0.33.5': + optionalDependencies: + '@img/sharp-libvips-linux-x64': 1.0.4 + optional: true + + '@img/sharp-linuxmusl-arm64@0.33.5': + optionalDependencies: + '@img/sharp-libvips-linuxmusl-arm64': 1.0.4 + optional: true + + '@img/sharp-linuxmusl-x64@0.33.5': + optionalDependencies: + '@img/sharp-libvips-linuxmusl-x64': 1.0.4 + optional: true + + '@img/sharp-wasm32@0.33.5': + dependencies: + '@emnapi/runtime': 1.4.5 + optional: true + + '@img/sharp-win32-ia32@0.33.5': + optional: true + + '@img/sharp-win32-x64@0.33.5': + optional: true + + '@inquirer/external-editor@1.0.1(@types/node@24.3.0)': + dependencies: + chardet: 2.1.0 + iconv-lite: 0.6.3 + optionalDependencies: + '@types/node': 24.3.0 + '@isaacs/balanced-match@4.0.1': {} '@isaacs/brace-expansion@5.0.0': @@ -4180,37 +7094,171 @@ snapshots: dependencies: minipass: 7.1.2 + '@isaacs/ttlcache@1.4.1': {} + + '@istanbuljs/load-nyc-config@1.1.0': + dependencies: + camelcase: 5.3.1 + find-up: 4.1.0 + get-package-type: 0.1.0 + js-yaml: 3.14.1 + resolve-from: 5.0.0 + '@istanbuljs/schema@0.1.3': {} - '@jridgewell/gen-mapping@0.3.12': + '@jest/create-cache-key-function@29.7.0': dependencies: - '@jridgewell/sourcemap-codec': 1.5.4 - '@jridgewell/trace-mapping': 0.3.29 + '@jest/types': 29.6.3 + + '@jest/environment@29.7.0': + dependencies: + '@jest/fake-timers': 29.7.0 + '@jest/types': 29.6.3 + '@types/node': 24.3.0 + jest-mock: 29.7.0 + + '@jest/fake-timers@29.7.0': + dependencies: + '@jest/types': 29.6.3 + '@sinonjs/fake-timers': 10.3.0 + '@types/node': 24.3.0 + jest-message-util: 29.7.0 + jest-mock: 29.7.0 + jest-util: 29.7.0 + + '@jest/schemas@29.6.3': + dependencies: + '@sinclair/typebox': 0.27.8 + + '@jest/transform@29.7.0': + dependencies: + '@babel/core': 7.28.3 + '@jest/types': 29.6.3 + '@jridgewell/trace-mapping': 0.3.30 + babel-plugin-istanbul: 6.1.1 + chalk: 4.1.2 + convert-source-map: 2.0.0 + fast-json-stable-stringify: 2.1.0 + graceful-fs: 4.2.11 + jest-haste-map: 29.7.0 + jest-regex-util: 29.6.3 + jest-util: 29.7.0 + micromatch: 4.0.8 + pirates: 4.0.7 + slash: 3.0.0 + write-file-atomic: 4.0.2 + transitivePeerDependencies: + - supports-color + + '@jest/types@29.6.3': + dependencies: + '@jest/schemas': 29.6.3 + '@types/istanbul-lib-coverage': 2.0.6 + '@types/istanbul-reports': 3.0.4 + '@types/node': 24.3.0 + '@types/yargs': 17.0.33 + chalk: 4.1.2 + + '@jridgewell/gen-mapping@0.3.13': + dependencies: + '@jridgewell/sourcemap-codec': 1.5.5 + '@jridgewell/trace-mapping': 0.3.30 '@jridgewell/resolve-uri@3.1.2': {} - '@jridgewell/source-map@0.3.10': + '@jridgewell/source-map@0.3.11': dependencies: - '@jridgewell/gen-mapping': 0.3.12 - '@jridgewell/trace-mapping': 0.3.29 + '@jridgewell/gen-mapping': 0.3.13 + '@jridgewell/trace-mapping': 0.3.30 - '@jridgewell/sourcemap-codec@1.5.4': {} + '@jridgewell/sourcemap-codec@1.5.5': {} - '@jridgewell/trace-mapping@0.3.29': + '@jridgewell/trace-mapping@0.3.30': dependencies: '@jridgewell/resolve-uri': 3.1.2 - '@jridgewell/sourcemap-codec': 1.5.4 + '@jridgewell/sourcemap-codec': 1.5.5 + + '@jridgewell/trace-mapping@0.3.9': + dependencies: + '@jridgewell/resolve-uri': 3.1.2 + '@jridgewell/sourcemap-codec': 1.5.5 + + '@js-joda/core@5.6.5': {} + + '@js-sdsl/ordered-map@4.4.2': {} + + '@libsql/client@0.15.14': + dependencies: + '@libsql/core': 0.15.14 + '@libsql/hrana-client': 0.7.0 + js-base64: 3.7.8 + libsql: 0.5.20 + promise-limit: 2.7.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + '@libsql/core@0.15.14': + dependencies: + js-base64: 3.7.8 + + '@libsql/darwin-arm64@0.5.20': + optional: true + + '@libsql/darwin-x64@0.5.20': + optional: true + + '@libsql/hrana-client@0.7.0': + dependencies: + '@libsql/isomorphic-fetch': 0.3.1 + '@libsql/isomorphic-ws': 0.1.5 + js-base64: 3.7.8 + node-fetch: 3.3.2 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + '@libsql/isomorphic-fetch@0.3.1': {} + + '@libsql/isomorphic-ws@0.1.5': + dependencies: + '@types/ws': 8.18.1 + ws: 8.18.3 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + '@libsql/linux-arm-gnueabihf@0.5.20': + optional: true + + '@libsql/linux-arm-musleabihf@0.5.20': + optional: true + + '@libsql/linux-arm64-gnu@0.5.20': + optional: true + + '@libsql/linux-arm64-musl@0.5.20': + optional: true + + '@libsql/linux-x64-gnu@0.5.20': + optional: true + + '@libsql/linux-x64-musl@0.5.20': + optional: true + + '@libsql/win32-x64-msvc@0.5.20': + optional: true '@manypkg/find-root@1.1.0': dependencies: - '@babel/runtime': 7.27.6 + '@babel/runtime': 7.28.3 '@types/node': 12.20.55 find-up: 4.1.0 fs-extra: 8.1.0 '@manypkg/get-packages@1.1.3': dependencies: - '@babel/runtime': 7.27.6 + '@babel/runtime': 7.28.3 '@changesets/types': 4.1.0 '@manypkg/find-root': 1.1.0 fs-extra: 8.1.0 @@ -4242,6 +7290,15 @@ snapshots: '@tybys/wasm-util': 0.10.0 optional: true + '@napi-rs/wasm-runtime@1.0.3': + dependencies: + '@emnapi/core': 1.4.5 + '@emnapi/runtime': 1.4.5 + '@tybys/wasm-util': 0.10.0 + optional: true + + '@neon-rs/load@0.0.4': {} + '@nicolo-ribaudo/chokidar-2@2.1.8-no-fsevents.3': optional: true @@ -4257,120 +7314,378 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.19.1 + '@op-engineering/op-sqlite@15.0.1(patch_hash=633e2e7df06e7cfe942bfed907d736ce3b18b45b33a40e3170d3d8be7c605c32)(react-native@0.81.0(@babel/core@7.28.3)(@react-native/metro-config@0.81.0(@babel/core@7.28.3))(@types/react@19.1.11)(react@19.1.1))(react@19.1.1)': + dependencies: + react: 19.1.1 + react-native: 0.81.0(@babel/core@7.28.3)(@react-native/metro-config@0.81.0(@babel/core@7.28.3))(@types/react@19.1.11)(react@19.1.1) + + '@oxc-project/runtime@0.82.3': {} + + '@oxc-project/types@0.82.3': {} + '@pkgjs/parseargs@0.11.0': optional: true '@polka/url@1.0.0-next.29': {} - '@rollup/plugin-node-resolve@16.0.1(rollup@4.45.1)': + '@poppinss/colors@4.1.5': dependencies: - '@rollup/pluginutils': 5.2.0(rollup@4.45.1) + kleur: 4.1.5 + + '@poppinss/dumper@0.6.4': + dependencies: + '@poppinss/colors': 4.1.5 + '@sindresorhus/is': 7.0.2 + supports-color: 10.2.0 + + '@poppinss/exception@1.2.2': {} + + '@protobufjs/aspromise@1.1.2': {} + + '@protobufjs/base64@1.1.2': {} + + '@protobufjs/codegen@2.0.4': {} + + '@protobufjs/eventemitter@1.1.0': {} + + '@protobufjs/fetch@1.1.0': + dependencies: + '@protobufjs/aspromise': 1.1.2 + '@protobufjs/inquire': 1.1.0 + + '@protobufjs/float@1.0.2': {} + + '@protobufjs/inquire@1.1.0': {} + + '@protobufjs/path@1.1.2': {} + + '@protobufjs/pool@1.1.0': {} + + '@protobufjs/utf8@1.1.0': {} + + '@react-native/assets-registry@0.81.0': {} + + '@react-native/babel-plugin-codegen@0.81.0(@babel/core@7.28.3)': + dependencies: + '@babel/traverse': 7.28.3 + '@react-native/codegen': 0.81.0(@babel/core@7.28.3) + transitivePeerDependencies: + - '@babel/core' + - supports-color + + '@react-native/babel-preset@0.81.0(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@babel/plugin-proposal-export-default-from': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-syntax-dynamic-import': 7.8.3(@babel/core@7.28.3) + '@babel/plugin-syntax-export-default-from': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-syntax-nullish-coalescing-operator': 7.8.3(@babel/core@7.28.3) + '@babel/plugin-syntax-optional-chaining': 7.8.3(@babel/core@7.28.3) + '@babel/plugin-transform-arrow-functions': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-async-generator-functions': 7.28.0(@babel/core@7.28.3) + '@babel/plugin-transform-async-to-generator': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-block-scoping': 7.28.0(@babel/core@7.28.3) + '@babel/plugin-transform-class-properties': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-classes': 7.28.3(@babel/core@7.28.3) + '@babel/plugin-transform-computed-properties': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-destructuring': 7.28.0(@babel/core@7.28.3) + '@babel/plugin-transform-flow-strip-types': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-for-of': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-function-name': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-literals': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-logical-assignment-operators': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-modules-commonjs': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-named-capturing-groups-regex': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-nullish-coalescing-operator': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-numeric-separator': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-object-rest-spread': 7.28.0(@babel/core@7.28.3) + '@babel/plugin-transform-optional-catch-binding': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-optional-chaining': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-parameters': 7.27.7(@babel/core@7.28.3) + '@babel/plugin-transform-private-methods': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-private-property-in-object': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-react-display-name': 7.28.0(@babel/core@7.28.3) + '@babel/plugin-transform-react-jsx': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-react-jsx-self': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-react-jsx-source': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-regenerator': 7.28.3(@babel/core@7.28.3) + '@babel/plugin-transform-runtime': 7.28.3(@babel/core@7.28.3) + '@babel/plugin-transform-shorthand-properties': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-spread': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-sticky-regex': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-typescript': 7.28.0(@babel/core@7.28.3) + '@babel/plugin-transform-unicode-regex': 7.27.1(@babel/core@7.28.3) + '@babel/template': 7.27.2 + '@react-native/babel-plugin-codegen': 0.81.0(@babel/core@7.28.3) + babel-plugin-syntax-hermes-parser: 0.29.1 + babel-plugin-transform-flow-enums: 0.0.2(@babel/core@7.28.3) + react-refresh: 0.14.2 + transitivePeerDependencies: + - supports-color + + '@react-native/codegen@0.81.0(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + glob: 7.2.3 + hermes-parser: 0.29.1 + invariant: 2.2.4 + nullthrows: 1.1.1 + yargs: 17.7.2 + + '@react-native/community-cli-plugin@0.81.0(@react-native/metro-config@0.81.0(@babel/core@7.28.3))': + dependencies: + '@react-native/dev-middleware': 0.81.0 + '@react-native/metro-config': 0.81.0(@babel/core@7.28.3) + debug: 4.4.1 + invariant: 2.2.4 + metro: 0.83.1 + metro-config: 0.83.1 + metro-core: 0.83.1 + semver: 7.7.2 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + + '@react-native/debugger-frontend@0.81.0': {} + + '@react-native/dev-middleware@0.81.0': + dependencies: + '@isaacs/ttlcache': 1.4.1 + '@react-native/debugger-frontend': 0.81.0 + chrome-launcher: 0.15.2 + chromium-edge-launcher: 0.2.0 + connect: 3.7.0 + debug: 4.4.1 + invariant: 2.2.4 + nullthrows: 1.1.1 + open: 7.4.2 + serve-static: 1.16.2 + ws: 6.2.3 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + + '@react-native/gradle-plugin@0.81.0': {} + + '@react-native/js-polyfills@0.81.0': {} + + '@react-native/metro-babel-transformer@0.81.0(@babel/core@7.28.3)': + dependencies: + '@babel/core': 7.28.3 + '@react-native/babel-preset': 0.81.0(@babel/core@7.28.3) + hermes-parser: 0.29.1 + nullthrows: 1.1.1 + transitivePeerDependencies: + - supports-color + + '@react-native/metro-config@0.81.0(@babel/core@7.28.3)': + dependencies: + '@react-native/js-polyfills': 0.81.0 + '@react-native/metro-babel-transformer': 0.81.0(@babel/core@7.28.3) + metro-config: 0.83.1 + metro-runtime: 0.83.1 + transitivePeerDependencies: + - '@babel/core' + - bufferutil + - supports-color + - utf-8-validate + + '@react-native/normalize-colors@0.81.0': {} + + '@react-native/virtualized-lists@0.81.0(@types/react@19.1.11)(react-native@0.81.0(@babel/core@7.28.3)(@react-native/metro-config@0.81.0(@babel/core@7.28.3))(@types/react@19.1.11)(react@19.1.1))(react@19.1.1)': + dependencies: + invariant: 2.2.4 + nullthrows: 1.1.1 + react: 19.1.1 + react-native: 0.81.0(@babel/core@7.28.3)(@react-native/metro-config@0.81.0(@babel/core@7.28.3))(@types/react@19.1.11)(react@19.1.1) + optionalDependencies: + '@types/react': 19.1.11 + + '@rolldown/binding-android-arm64@1.0.0-beta.34': + optional: true + + '@rolldown/binding-darwin-arm64@1.0.0-beta.34': + optional: true + + '@rolldown/binding-darwin-x64@1.0.0-beta.34': + optional: true + + '@rolldown/binding-freebsd-x64@1.0.0-beta.34': + optional: true + + '@rolldown/binding-linux-arm-gnueabihf@1.0.0-beta.34': + optional: true + + '@rolldown/binding-linux-arm64-gnu@1.0.0-beta.34': + optional: true + + '@rolldown/binding-linux-arm64-musl@1.0.0-beta.34': + optional: true + + '@rolldown/binding-linux-x64-gnu@1.0.0-beta.34': + optional: true + + '@rolldown/binding-linux-x64-musl@1.0.0-beta.34': + optional: true + + '@rolldown/binding-openharmony-arm64@1.0.0-beta.34': + optional: true + + '@rolldown/binding-wasm32-wasi@1.0.0-beta.34': + dependencies: + '@napi-rs/wasm-runtime': 1.0.3 + optional: true + + '@rolldown/binding-win32-arm64-msvc@1.0.0-beta.34': + optional: true + + '@rolldown/binding-win32-ia32-msvc@1.0.0-beta.34': + optional: true + + '@rolldown/binding-win32-x64-msvc@1.0.0-beta.34': + optional: true + + '@rolldown/pluginutils@1.0.0-beta.34': {} + + '@rollup/plugin-node-resolve@16.0.1(rollup@4.48.1)': + dependencies: + '@rollup/pluginutils': 5.2.0(rollup@4.48.1) '@types/resolve': 1.20.2 deepmerge: 4.3.1 is-module: 1.0.0 resolve: 1.22.10 optionalDependencies: - rollup: 4.45.1 + rollup: 4.48.1 - '@rollup/plugin-replace@6.0.2(rollup@4.45.1)': + '@rollup/plugin-replace@6.0.2(rollup@4.48.1)': dependencies: - '@rollup/pluginutils': 5.2.0(rollup@4.45.1) - magic-string: 0.30.17 + '@rollup/pluginutils': 5.2.0(rollup@4.48.1) + magic-string: 0.30.18 optionalDependencies: - rollup: 4.45.1 + rollup: 4.48.1 - '@rollup/plugin-terser@0.4.4(rollup@4.45.1)': + '@rollup/plugin-terser@0.4.4(rollup@4.48.1)': dependencies: serialize-javascript: 6.0.2 smob: 1.5.0 terser: 5.43.1 optionalDependencies: - rollup: 4.45.1 + rollup: 4.48.1 - '@rollup/pluginutils@5.2.0(rollup@4.45.1)': + '@rollup/pluginutils@5.2.0(rollup@4.48.1)': dependencies: '@types/estree': 1.0.8 estree-walker: 2.0.2 picomatch: 4.0.3 optionalDependencies: - rollup: 4.45.1 + rollup: 4.48.1 - '@rollup/rollup-android-arm-eabi@4.45.1': + '@rollup/rollup-android-arm-eabi@4.48.1': optional: true - '@rollup/rollup-android-arm64@4.45.1': + '@rollup/rollup-android-arm64@4.48.1': optional: true - '@rollup/rollup-darwin-arm64@4.45.1': + '@rollup/rollup-darwin-arm64@4.48.1': optional: true - '@rollup/rollup-darwin-x64@4.45.1': + '@rollup/rollup-darwin-x64@4.48.1': optional: true - '@rollup/rollup-freebsd-arm64@4.45.1': + '@rollup/rollup-freebsd-arm64@4.48.1': optional: true - '@rollup/rollup-freebsd-x64@4.45.1': + '@rollup/rollup-freebsd-x64@4.48.1': optional: true - '@rollup/rollup-linux-arm-gnueabihf@4.45.1': + '@rollup/rollup-linux-arm-gnueabihf@4.48.1': optional: true - '@rollup/rollup-linux-arm-musleabihf@4.45.1': + '@rollup/rollup-linux-arm-musleabihf@4.48.1': optional: true - '@rollup/rollup-linux-arm64-gnu@4.45.1': + '@rollup/rollup-linux-arm64-gnu@4.48.1': optional: true - '@rollup/rollup-linux-arm64-musl@4.45.1': + '@rollup/rollup-linux-arm64-musl@4.48.1': optional: true - '@rollup/rollup-linux-loongarch64-gnu@4.45.1': + '@rollup/rollup-linux-loongarch64-gnu@4.48.1': optional: true - '@rollup/rollup-linux-powerpc64le-gnu@4.45.1': + '@rollup/rollup-linux-ppc64-gnu@4.48.1': optional: true - '@rollup/rollup-linux-riscv64-gnu@4.45.1': + '@rollup/rollup-linux-riscv64-gnu@4.48.1': optional: true - '@rollup/rollup-linux-riscv64-musl@4.45.1': + '@rollup/rollup-linux-riscv64-musl@4.48.1': optional: true - '@rollup/rollup-linux-s390x-gnu@4.45.1': + '@rollup/rollup-linux-s390x-gnu@4.48.1': optional: true - '@rollup/rollup-linux-x64-gnu@4.45.1': + '@rollup/rollup-linux-x64-gnu@4.48.1': optional: true - '@rollup/rollup-linux-x64-musl@4.45.1': + '@rollup/rollup-linux-x64-musl@4.48.1': optional: true - '@rollup/rollup-win32-arm64-msvc@4.45.1': + '@rollup/rollup-win32-arm64-msvc@4.48.1': optional: true - '@rollup/rollup-win32-ia32-msvc@4.45.1': + '@rollup/rollup-win32-ia32-msvc@4.48.1': optional: true - '@rollup/rollup-win32-x64-msvc@4.45.1': + '@rollup/rollup-win32-x64-msvc@4.48.1': optional: true + '@sinclair/typebox@0.27.8': {} + + '@sindresorhus/is@7.0.2': {} + + '@sinonjs/commons@3.0.1': + dependencies: + type-detect: 4.0.8 + + '@sinonjs/fake-timers@10.3.0': + dependencies: + '@sinonjs/commons': 3.0.1 + + '@speed-highlight/core@1.2.7': {} + '@standard-schema/spec@1.0.0': {} - '@testing-library/dom@10.4.0': + '@testcontainers/mysql@11.5.1': + dependencies: + testcontainers: 11.5.1 + transitivePeerDependencies: + - bare-buffer + - supports-color + + '@testcontainers/postgresql@11.5.1': + dependencies: + testcontainers: 11.5.1 + transitivePeerDependencies: + - bare-buffer + - supports-color + + '@testing-library/dom@10.4.1': dependencies: '@babel/code-frame': 7.27.1 - '@babel/runtime': 7.27.6 + '@babel/runtime': 7.28.3 '@types/aria-query': 5.0.4 aria-query: 5.3.0 - chalk: 4.1.2 dom-accessibility-api: 0.5.16 lz-string: 1.5.0 + picocolors: 1.1.1 pretty-format: 27.5.1 - '@testing-library/user-event@14.6.1(@testing-library/dom@10.4.0)': + '@testing-library/user-event@14.6.1(@testing-library/dom@10.4.1)': dependencies: - '@testing-library/dom': 10.4.0 + '@testing-library/dom': 10.4.1 '@ts-graphviz/adapter@2.0.6': dependencies: @@ -4394,9 +7709,34 @@ snapshots: '@types/aria-query@5.0.4': {} - '@types/bun@1.2.19(@types/react@19.1.8)': + '@types/babel__core@7.20.5': dependencies: - bun-types: 1.2.19(@types/react@19.1.8) + '@babel/parser': 7.28.3 + '@babel/types': 7.28.2 + '@types/babel__generator': 7.27.0 + '@types/babel__template': 7.4.4 + '@types/babel__traverse': 7.28.0 + + '@types/babel__generator@7.27.0': + dependencies: + '@babel/types': 7.28.2 + + '@types/babel__template@7.4.4': + dependencies: + '@babel/parser': 7.28.3 + '@babel/types': 7.28.2 + + '@types/babel__traverse@7.28.0': + dependencies: + '@babel/types': 7.28.2 + + '@types/better-sqlite3@7.6.13': + dependencies: + '@types/node': 24.3.0 + + '@types/bun@1.2.21(@types/react@19.1.11)': + dependencies: + bun-types: 1.2.21(@types/react@19.1.11) transitivePeerDependencies: - '@types/react' @@ -4406,8 +7746,33 @@ snapshots: '@types/deep-eql@4.0.2': {} + '@types/docker-modem@3.0.6': + dependencies: + '@types/node': 24.3.0 + '@types/ssh2': 1.15.5 + + '@types/dockerode@3.3.43': + dependencies: + '@types/docker-modem': 3.0.6 + '@types/node': 24.3.0 + '@types/ssh2': 1.15.5 + '@types/estree@1.0.8': {} + '@types/graceful-fs@4.1.9': + dependencies: + '@types/node': 24.3.0 + + '@types/istanbul-lib-coverage@2.0.6': {} + + '@types/istanbul-lib-report@3.0.3': + dependencies: + '@types/istanbul-lib-coverage': 2.0.6 + + '@types/istanbul-reports@3.0.4': + dependencies: + '@types/istanbul-lib-report': 3.0.3 + '@types/jscodeshift@17.3.0': dependencies: ast-types: 0.16.1 @@ -4417,84 +7782,124 @@ snapshots: '@types/node@12.20.55': {} - '@types/node@24.1.0': + '@types/node@18.19.123': dependencies: - undici-types: 7.8.0 + undici-types: 5.26.5 - '@types/react@19.1.8': + '@types/node@24.3.0': + dependencies: + undici-types: 7.10.0 + + '@types/pg-cursor@2.7.2': + dependencies: + '@types/node': 24.3.0 + '@types/pg': 8.15.5 + + '@types/pg@8.15.5': + dependencies: + '@types/node': 24.3.0 + pg-protocol: 1.10.3 + pg-types: 2.2.0 + + '@types/react@19.1.11': dependencies: csstype: 3.1.3 + '@types/readable-stream@4.0.21': + dependencies: + '@types/node': 24.3.0 + '@types/resolve@1.20.2': {} + '@types/ssh2-streams@0.1.12': + dependencies: + '@types/node': 24.3.0 + + '@types/ssh2@0.5.52': + dependencies: + '@types/node': 24.3.0 + '@types/ssh2-streams': 0.1.12 + + '@types/ssh2@1.15.5': + dependencies: + '@types/node': 18.19.123 + + '@types/stack-utils@2.0.3': {} + '@types/ws@8.18.1': dependencies: - '@types/node': 24.1.0 + '@types/node': 24.3.0 - '@typescript-eslint/eslint-plugin@8.38.0(@typescript-eslint/parser@8.38.0(eslint@9.31.0)(typescript@5.8.3))(eslint@9.31.0)(typescript@5.8.3)': + '@types/yargs-parser@21.0.3': {} + + '@types/yargs@17.0.33': + dependencies: + '@types/yargs-parser': 21.0.3 + + '@typescript-eslint/eslint-plugin@8.41.0(@typescript-eslint/parser@8.41.0(eslint@9.34.0)(typescript@5.9.2))(eslint@9.34.0)(typescript@5.9.2)': dependencies: '@eslint-community/regexpp': 4.12.1 - '@typescript-eslint/parser': 8.38.0(eslint@9.31.0)(typescript@5.8.3) - '@typescript-eslint/scope-manager': 8.38.0 - '@typescript-eslint/type-utils': 8.38.0(eslint@9.31.0)(typescript@5.8.3) - '@typescript-eslint/utils': 8.38.0(eslint@9.31.0)(typescript@5.8.3) - '@typescript-eslint/visitor-keys': 8.38.0 - eslint: 9.31.0 + '@typescript-eslint/parser': 8.41.0(eslint@9.34.0)(typescript@5.9.2) + '@typescript-eslint/scope-manager': 8.41.0 + '@typescript-eslint/type-utils': 8.41.0(eslint@9.34.0)(typescript@5.9.2) + '@typescript-eslint/utils': 8.41.0(eslint@9.34.0)(typescript@5.9.2) + '@typescript-eslint/visitor-keys': 8.41.0 + eslint: 9.34.0 graphemer: 1.4.0 ignore: 7.0.5 natural-compare: 1.4.0 - ts-api-utils: 2.1.0(typescript@5.8.3) - typescript: 5.8.3 + ts-api-utils: 2.1.0(typescript@5.9.2) + typescript: 5.9.2 transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.38.0(eslint@9.31.0)(typescript@5.8.3)': + '@typescript-eslint/parser@8.41.0(eslint@9.34.0)(typescript@5.9.2)': dependencies: - '@typescript-eslint/scope-manager': 8.38.0 - '@typescript-eslint/types': 8.38.0 - '@typescript-eslint/typescript-estree': 8.38.0(typescript@5.8.3) - '@typescript-eslint/visitor-keys': 8.38.0 + '@typescript-eslint/scope-manager': 8.41.0 + '@typescript-eslint/types': 8.41.0 + '@typescript-eslint/typescript-estree': 8.41.0(typescript@5.9.2) + '@typescript-eslint/visitor-keys': 8.41.0 debug: 4.4.1 - eslint: 9.31.0 - typescript: 5.8.3 + eslint: 9.34.0 + typescript: 5.9.2 transitivePeerDependencies: - supports-color - '@typescript-eslint/project-service@8.38.0(typescript@5.8.3)': + '@typescript-eslint/project-service@8.41.0(typescript@5.9.2)': dependencies: - '@typescript-eslint/tsconfig-utils': 8.38.0(typescript@5.8.3) - '@typescript-eslint/types': 8.38.0 + '@typescript-eslint/tsconfig-utils': 8.41.0(typescript@5.9.2) + '@typescript-eslint/types': 8.41.0 debug: 4.4.1 - typescript: 5.8.3 + typescript: 5.9.2 transitivePeerDependencies: - supports-color - '@typescript-eslint/scope-manager@8.38.0': + '@typescript-eslint/scope-manager@8.41.0': dependencies: - '@typescript-eslint/types': 8.38.0 - '@typescript-eslint/visitor-keys': 8.38.0 + '@typescript-eslint/types': 8.41.0 + '@typescript-eslint/visitor-keys': 8.41.0 - '@typescript-eslint/tsconfig-utils@8.38.0(typescript@5.8.3)': + '@typescript-eslint/tsconfig-utils@8.41.0(typescript@5.9.2)': dependencies: - typescript: 5.8.3 + typescript: 5.9.2 - '@typescript-eslint/type-utils@8.38.0(eslint@9.31.0)(typescript@5.8.3)': + '@typescript-eslint/type-utils@8.41.0(eslint@9.34.0)(typescript@5.9.2)': dependencies: - '@typescript-eslint/types': 8.38.0 - '@typescript-eslint/typescript-estree': 8.38.0(typescript@5.8.3) - '@typescript-eslint/utils': 8.38.0(eslint@9.31.0)(typescript@5.8.3) + '@typescript-eslint/types': 8.41.0 + '@typescript-eslint/typescript-estree': 8.41.0(typescript@5.9.2) + '@typescript-eslint/utils': 8.41.0(eslint@9.34.0)(typescript@5.9.2) debug: 4.4.1 - eslint: 9.31.0 - ts-api-utils: 2.1.0(typescript@5.8.3) - typescript: 5.8.3 + eslint: 9.34.0 + ts-api-utils: 2.1.0(typescript@5.9.2) + typescript: 5.9.2 transitivePeerDependencies: - supports-color '@typescript-eslint/types@5.62.0': {} - '@typescript-eslint/types@8.38.0': {} + '@typescript-eslint/types@8.41.0': {} - '@typescript-eslint/typescript-estree@5.62.0(typescript@5.8.3)': + '@typescript-eslint/typescript-estree@5.62.0(typescript@5.9.2)': dependencies: '@typescript-eslint/types': 5.62.0 '@typescript-eslint/visitor-keys': 5.62.0 @@ -4502,36 +7907,36 @@ snapshots: globby: 11.1.0 is-glob: 4.0.3 semver: 7.7.2 - tsutils: 3.21.0(typescript@5.8.3) + tsutils: 3.21.0(typescript@5.9.2) optionalDependencies: - typescript: 5.8.3 + typescript: 5.9.2 transitivePeerDependencies: - supports-color - '@typescript-eslint/typescript-estree@8.38.0(typescript@5.8.3)': + '@typescript-eslint/typescript-estree@8.41.0(typescript@5.9.2)': dependencies: - '@typescript-eslint/project-service': 8.38.0(typescript@5.8.3) - '@typescript-eslint/tsconfig-utils': 8.38.0(typescript@5.8.3) - '@typescript-eslint/types': 8.38.0 - '@typescript-eslint/visitor-keys': 8.38.0 + '@typescript-eslint/project-service': 8.41.0(typescript@5.9.2) + '@typescript-eslint/tsconfig-utils': 8.41.0(typescript@5.9.2) + '@typescript-eslint/types': 8.41.0 + '@typescript-eslint/visitor-keys': 8.41.0 debug: 4.4.1 fast-glob: 3.3.3 is-glob: 4.0.3 minimatch: 9.0.5 semver: 7.7.2 - ts-api-utils: 2.1.0(typescript@5.8.3) - typescript: 5.8.3 + ts-api-utils: 2.1.0(typescript@5.9.2) + typescript: 5.9.2 transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.38.0(eslint@9.31.0)(typescript@5.8.3)': + '@typescript-eslint/utils@8.41.0(eslint@9.34.0)(typescript@5.9.2)': dependencies: - '@eslint-community/eslint-utils': 4.7.0(eslint@9.31.0) - '@typescript-eslint/scope-manager': 8.38.0 - '@typescript-eslint/types': 8.38.0 - '@typescript-eslint/typescript-estree': 8.38.0(typescript@5.8.3) - eslint: 9.31.0 - typescript: 5.8.3 + '@eslint-community/eslint-utils': 4.7.0(eslint@9.34.0) + '@typescript-eslint/scope-manager': 8.41.0 + '@typescript-eslint/types': 8.41.0 + '@typescript-eslint/typescript-estree': 8.41.0(typescript@5.9.2) + eslint: 9.34.0 + typescript: 5.9.2 transitivePeerDependencies: - supports-color @@ -4540,11 +7945,19 @@ snapshots: '@typescript-eslint/types': 5.62.0 eslint-visitor-keys: 3.4.3 - '@typescript-eslint/visitor-keys@8.38.0': + '@typescript-eslint/visitor-keys@8.41.0': dependencies: - '@typescript-eslint/types': 8.38.0 + '@typescript-eslint/types': 8.41.0 eslint-visitor-keys: 4.2.1 + '@typespec/ts-http-runtime@0.3.0': + dependencies: + http-proxy-agent: 7.0.2 + https-proxy-agent: 7.0.6 + tslib: 2.8.1 + transitivePeerDependencies: + - supports-color + '@unrs/resolver-binding-android-arm-eabi@1.11.1': optional: true @@ -4604,19 +8017,19 @@ snapshots: '@unrs/resolver-binding-win32-x64-msvc@1.11.1': optional: true - '@vitest/browser@3.2.4(playwright@1.54.1)(vite@7.0.5(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3))(vitest@3.2.4)': + '@vitest/browser@3.2.4(playwright@1.55.0)(vite@7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1))(vitest@3.2.4)': dependencies: - '@testing-library/dom': 10.4.0 - '@testing-library/user-event': 14.6.1(@testing-library/dom@10.4.0) - '@vitest/mocker': 3.2.4(vite@7.0.5(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3)) + '@testing-library/dom': 10.4.1 + '@testing-library/user-event': 14.6.1(@testing-library/dom@10.4.1) + '@vitest/mocker': 3.2.4(vite@7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1)) '@vitest/utils': 3.2.4 - magic-string: 0.30.17 + magic-string: 0.30.18 sirv: 3.0.1 tinyrainbow: 2.0.0 - vitest: 3.2.4(@edge-runtime/vm@5.0.0)(@types/node@24.1.0)(@vitest/browser@3.2.4)(terser@5.43.1)(tsx@4.20.3) + vitest: 3.2.4(@edge-runtime/vm@5.0.0)(@types/node@24.3.0)(@vitest/browser@3.2.4)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1) ws: 8.18.3 optionalDependencies: - playwright: 1.54.1 + playwright: 1.55.0 transitivePeerDependencies: - bufferutil - msw @@ -4627,20 +8040,20 @@ snapshots: dependencies: '@ampproject/remapping': 2.3.0 '@bcoe/v8-coverage': 1.0.2 - ast-v8-to-istanbul: 0.3.3 + ast-v8-to-istanbul: 0.3.4 debug: 4.4.1 istanbul-lib-coverage: 3.2.2 istanbul-lib-report: 3.0.1 istanbul-lib-source-maps: 5.0.6 - istanbul-reports: 3.1.7 - magic-string: 0.30.17 + istanbul-reports: 3.2.0 + magic-string: 0.30.18 magicast: 0.3.5 std-env: 3.9.0 test-exclude: 7.0.1 tinyrainbow: 2.0.0 - vitest: 3.2.4(@edge-runtime/vm@5.0.0)(@types/node@24.1.0)(@vitest/browser@3.2.4)(terser@5.43.1)(tsx@4.20.3) + vitest: 3.2.4(@edge-runtime/vm@5.0.0)(@types/node@24.3.0)(@vitest/browser@3.2.4)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1) optionalDependencies: - '@vitest/browser': 3.2.4(playwright@1.54.1)(vite@7.0.5(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3))(vitest@3.2.4) + '@vitest/browser': 3.2.4(playwright@1.55.0)(vite@7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1))(vitest@3.2.4) transitivePeerDependencies: - supports-color @@ -4649,16 +8062,16 @@ snapshots: '@types/chai': 5.2.2 '@vitest/spy': 3.2.4 '@vitest/utils': 3.2.4 - chai: 5.2.1 + chai: 5.3.3 tinyrainbow: 2.0.0 - '@vitest/mocker@3.2.4(vite@7.0.5(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3))': + '@vitest/mocker@3.2.4(vite@7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1))': dependencies: '@vitest/spy': 3.2.4 estree-walker: 3.0.3 - magic-string: 0.30.17 + magic-string: 0.30.18 optionalDependencies: - vite: 7.0.5(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3) + vite: 7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1) '@vitest/pretty-format@3.2.4': dependencies: @@ -4673,7 +8086,7 @@ snapshots: '@vitest/snapshot@3.2.4': dependencies: '@vitest/pretty-format': 3.2.4 - magic-string: 0.30.17 + magic-string: 0.30.18 pathe: 2.0.3 '@vitest/spy@3.2.4': @@ -4683,22 +8096,37 @@ snapshots: '@vitest/utils@3.2.4': dependencies: '@vitest/pretty-format': 3.2.4 - loupe: 3.2.0 + loupe: 3.2.1 tinyrainbow: 2.0.0 '@vitest/web-worker@3.2.4(vitest@3.2.4)': dependencies: debug: 4.4.1 - vitest: 3.2.4(@edge-runtime/vm@5.0.0)(@types/node@24.1.0)(@vitest/browser@3.2.4)(terser@5.43.1)(tsx@4.20.3) + vitest: 3.2.4(@edge-runtime/vm@5.0.0)(@types/node@24.3.0)(@vitest/browser@3.2.4)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1) transitivePeerDependencies: - supports-color + abort-controller@3.0.0: + dependencies: + event-target-shim: 5.0.1 + + accepts@1.3.8: + dependencies: + mime-types: 2.1.35 + negotiator: 0.6.3 + acorn-jsx@5.3.2(acorn@8.15.0): dependencies: acorn: 8.15.0 + acorn-walk@8.3.2: {} + + acorn@8.14.0: {} + acorn@8.15.0: {} + agent-base@7.1.4: {} + ajv@6.12.6: dependencies: fast-deep-equal: 3.1.3 @@ -4709,15 +8137,17 @@ snapshots: ajv@8.17.1: dependencies: fast-deep-equal: 3.1.3 - fast-uri: 3.0.6 + fast-uri: 3.1.0 json-schema-traverse: 1.0.0 require-from-string: 2.0.2 + anser@1.4.10: {} + ansi-colors@4.1.3: {} ansi-regex@5.0.1: {} - ansi-regex@6.1.0: {} + ansi-regex@6.2.0: {} ansi-styles@4.3.0: dependencies: @@ -4727,16 +8157,37 @@ snapshots: ansi-styles@6.2.1: {} + ansis@4.1.0: {} + any-promise@1.3.0: {} anymatch@3.1.3: dependencies: normalize-path: 3.0.0 picomatch: 2.3.1 - optional: true app-module-path@2.2.0: {} + archiver-utils@5.0.2: + dependencies: + glob: 10.4.5 + graceful-fs: 4.2.11 + is-stream: 2.0.1 + lazystream: 1.0.1 + lodash: 4.17.21 + normalize-path: 3.0.0 + readable-stream: 4.7.0 + + archiver@7.0.1: + dependencies: + archiver-utils: 5.0.2 + async: 3.2.6 + buffer-crc32: 1.0.0 + readable-stream: 4.7.0 + readdir-glob: 1.1.3 + tar-stream: 3.1.7 + zip-stream: 6.0.1 + argparse@1.0.10: dependencies: sprintf-js: 1.0.3 @@ -4754,6 +8205,12 @@ snapshots: array-union@2.1.0: {} + asap@2.0.6: {} + + asn1@0.2.6: + dependencies: + safer-buffer: 2.1.2 + assertion-error@2.0.1: {} ast-module-types@5.0.0: {} @@ -4766,37 +8223,181 @@ snapshots: dependencies: tslib: 2.8.1 - ast-v8-to-istanbul@0.3.3: + ast-v8-to-istanbul@0.3.4: dependencies: - '@jridgewell/trace-mapping': 0.3.29 + '@jridgewell/trace-mapping': 0.3.30 estree-walker: 3.0.3 js-tokens: 9.0.1 + async-limiter@1.0.1: {} + + async-lock@1.4.1: {} + + async@3.2.6: {} + autolinker@0.28.1: dependencies: gulp-header: 1.8.12 - babel-plugin-annotate-pure-calls@0.5.0(@babel/core@7.28.0): + aws-ssl-profiles@1.1.2: {} + + b4a@1.6.7: {} + + babel-jest@29.7.0(@babel/core@7.28.3): dependencies: - '@babel/core': 7.28.0 + '@babel/core': 7.28.3 + '@jest/transform': 29.7.0 + '@types/babel__core': 7.20.5 + babel-plugin-istanbul: 6.1.1 + babel-preset-jest: 29.6.3(@babel/core@7.28.3) + chalk: 4.1.2 + graceful-fs: 4.2.11 + slash: 3.0.0 + transitivePeerDependencies: + - supports-color + + babel-plugin-annotate-pure-calls@0.5.0(@babel/core@7.28.3): + dependencies: + '@babel/core': 7.28.3 + + babel-plugin-istanbul@6.1.1: + dependencies: + '@babel/helper-plugin-utils': 7.27.1 + '@istanbuljs/load-nyc-config': 1.1.0 + '@istanbuljs/schema': 0.1.3 + istanbul-lib-instrument: 5.2.1 + test-exclude: 6.0.0 + transitivePeerDependencies: + - supports-color + + babel-plugin-jest-hoist@29.6.3: + dependencies: + '@babel/template': 7.27.2 + '@babel/types': 7.28.2 + '@types/babel__core': 7.20.5 + '@types/babel__traverse': 7.28.0 + + babel-plugin-polyfill-corejs2@0.4.14(@babel/core@7.28.3): + dependencies: + '@babel/compat-data': 7.28.0 + '@babel/core': 7.28.3 + '@babel/helper-define-polyfill-provider': 0.6.5(@babel/core@7.28.3) + semver: 6.3.1 + transitivePeerDependencies: + - supports-color + + babel-plugin-polyfill-corejs3@0.13.0(@babel/core@7.28.3): + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-define-polyfill-provider': 0.6.5(@babel/core@7.28.3) + core-js-compat: 3.45.1 + transitivePeerDependencies: + - supports-color + + babel-plugin-polyfill-regenerator@0.6.5(@babel/core@7.28.3): + dependencies: + '@babel/core': 7.28.3 + '@babel/helper-define-polyfill-provider': 0.6.5(@babel/core@7.28.3) + transitivePeerDependencies: + - supports-color + + babel-plugin-syntax-hermes-parser@0.29.1: + dependencies: + hermes-parser: 0.29.1 + + babel-plugin-transform-flow-enums@0.0.2(@babel/core@7.28.3): + dependencies: + '@babel/plugin-syntax-flow': 7.27.1(@babel/core@7.28.3) + transitivePeerDependencies: + - '@babel/core' + + babel-preset-current-node-syntax@1.2.0(@babel/core@7.28.3): + dependencies: + '@babel/core': 7.28.3 + '@babel/plugin-syntax-async-generators': 7.8.4(@babel/core@7.28.3) + '@babel/plugin-syntax-bigint': 7.8.3(@babel/core@7.28.3) + '@babel/plugin-syntax-class-properties': 7.12.13(@babel/core@7.28.3) + '@babel/plugin-syntax-class-static-block': 7.14.5(@babel/core@7.28.3) + '@babel/plugin-syntax-import-attributes': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-syntax-import-meta': 7.10.4(@babel/core@7.28.3) + '@babel/plugin-syntax-json-strings': 7.8.3(@babel/core@7.28.3) + '@babel/plugin-syntax-logical-assignment-operators': 7.10.4(@babel/core@7.28.3) + '@babel/plugin-syntax-nullish-coalescing-operator': 7.8.3(@babel/core@7.28.3) + '@babel/plugin-syntax-numeric-separator': 7.10.4(@babel/core@7.28.3) + '@babel/plugin-syntax-object-rest-spread': 7.8.3(@babel/core@7.28.3) + '@babel/plugin-syntax-optional-catch-binding': 7.8.3(@babel/core@7.28.3) + '@babel/plugin-syntax-optional-chaining': 7.8.3(@babel/core@7.28.3) + '@babel/plugin-syntax-private-property-in-object': 7.14.5(@babel/core@7.28.3) + '@babel/plugin-syntax-top-level-await': 7.14.5(@babel/core@7.28.3) + + babel-preset-jest@29.6.3(@babel/core@7.28.3): + dependencies: + '@babel/core': 7.28.3 + babel-plugin-jest-hoist: 29.6.3 + babel-preset-current-node-syntax: 1.2.0(@babel/core@7.28.3) balanced-match@1.0.2: {} + bare-events@2.6.1: + optional: true + + bare-fs@4.2.1: + dependencies: + bare-events: 2.6.1 + bare-path: 3.0.0 + bare-stream: 2.7.0(bare-events@2.6.1) + optional: true + + bare-os@3.6.2: + optional: true + + bare-path@3.0.0: + dependencies: + bare-os: 3.6.2 + optional: true + + bare-stream@2.7.0(bare-events@2.6.1): + dependencies: + streamx: 2.22.1 + optionalDependencies: + bare-events: 2.6.1 + optional: true + base64-js@1.5.1: {} + bcrypt-pbkdf@1.0.2: + dependencies: + tweetnacl: 0.14.5 + better-path-resolve@1.0.0: dependencies: is-windows: 1.0.2 + better-sqlite3@12.2.0: + dependencies: + bindings: 1.5.0 + prebuild-install: 7.1.3 + binary-extensions@2.3.0: optional: true + bindings@1.5.0: + dependencies: + file-uri-to-path: 1.0.0 + bl@4.1.0: dependencies: buffer: 5.7.1 inherits: 2.0.4 readable-stream: 3.6.2 + bl@6.1.2: + dependencies: + '@types/readable-stream': 4.0.21 + buffer: 6.0.3 + inherits: 2.0.4 + readable-stream: 4.7.0 + brace-expansion@1.1.12: dependencies: balanced-match: 1.0.2 @@ -4810,12 +8411,20 @@ snapshots: dependencies: fill-range: 7.1.1 - browserslist@4.25.1: + browserslist@4.25.3: dependencies: - caniuse-lite: 1.0.30001727 - electron-to-chromium: 1.5.190 + caniuse-lite: 1.0.30001737 + electron-to-chromium: 1.5.209 node-releases: 2.0.19 - update-browserslist-db: 1.1.3(browserslist@4.25.1) + update-browserslist-db: 1.1.3(browserslist@4.25.3) + + bser@2.1.1: + dependencies: + node-int64: 0.4.0 + + buffer-crc32@1.0.0: {} + + buffer-equal-constant-time@1.0.1: {} buffer-from@1.1.2: {} @@ -4824,23 +8433,51 @@ snapshots: base64-js: 1.5.1 ieee754: 1.2.1 - bun-types@1.2.19(@types/react@19.1.8): + buffer@6.0.3: dependencies: - '@types/node': 24.1.0 - '@types/react': 19.1.8 + base64-js: 1.5.1 + ieee754: 1.2.1 + + buildcheck@0.0.6: + optional: true + + bun-types@1.2.21(@types/react@19.1.11): + dependencies: + '@types/node': 24.3.0 + '@types/react': 19.1.11 + + bundle-name@4.1.0: + dependencies: + run-applescript: 7.0.0 + + byline@5.0.0: {} cac@6.7.14: {} + caller-callsite@2.0.0: + dependencies: + callsites: 2.0.0 + + caller-path@2.0.0: + dependencies: + caller-callsite: 2.0.0 + + callsites@2.0.0: {} + callsites@3.1.0: {} - caniuse-lite@1.0.30001727: {} + camelcase@5.3.1: {} - chai@5.2.1: + camelcase@6.3.0: {} + + caniuse-lite@1.0.30001737: {} + + chai@5.3.3: dependencies: assertion-error: 2.0.1 check-error: 2.1.1 deep-eql: 5.0.2 - loupe: 3.2.0 + loupe: 3.2.1 pathval: 2.0.1 chalk@4.1.2: @@ -4848,7 +8485,7 @@ snapshots: ansi-styles: 4.3.0 supports-color: 7.2.0 - chardet@0.7.0: {} + chardet@2.1.0: {} check-error@2.1.1: {} @@ -4865,8 +8502,32 @@ snapshots: fsevents: 2.3.3 optional: true + chownr@1.1.4: {} + chownr@3.0.0: {} + chrome-launcher@0.15.2: + dependencies: + '@types/node': 24.3.0 + escape-string-regexp: 4.0.0 + is-wsl: 2.2.0 + lighthouse-logger: 1.4.2 + transitivePeerDependencies: + - supports-color + + chromium-edge-launcher@0.2.0: + dependencies: + '@types/node': 24.3.0 + escape-string-regexp: 4.0.0 + is-wsl: 2.2.0 + lighthouse-logger: 1.4.2 + mkdirp: 1.0.4 + rimraf: 3.0.2 + transitivePeerDependencies: + - supports-color + + ci-info@2.0.0: {} + ci-info@3.9.0: {} cli-cursor@3.1.0: @@ -4895,8 +8556,20 @@ snapshots: color-name@1.1.4: {} + color-string@1.9.1: + dependencies: + color-name: 1.1.4 + simple-swizzle: 0.2.2 + + color@4.2.3: + dependencies: + color-convert: 2.0.1 + color-string: 1.9.1 + commander@10.0.1: {} + commander@12.1.0: {} + commander@2.20.3: {} commander@6.2.1: {} @@ -4907,6 +8580,14 @@ snapshots: commondir@1.0.1: {} + compress-commons@6.0.2: + dependencies: + crc-32: 1.2.2 + crc32-stream: 6.0.0 + is-stream: 2.0.1 + normalize-path: 3.0.0 + readable-stream: 4.7.0 + concat-map@0.0.1: {} concat-stream@1.6.2: @@ -4920,12 +8601,47 @@ snapshots: dependencies: source-map: 0.6.1 + connect@3.7.0: + dependencies: + debug: 2.6.9 + finalhandler: 1.1.2 + parseurl: 1.3.3 + utils-merge: 1.0.1 + transitivePeerDependencies: + - supports-color + convert-source-map@2.0.0: {} - core-js@3.44.0: {} + cookie@1.0.2: {} + + core-js-compat@3.45.1: + dependencies: + browserslist: 4.25.3 + + core-js@3.45.1: {} core-util-is@1.0.3: {} + cosmiconfig@5.2.1: + dependencies: + import-fresh: 2.0.0 + is-directory: 0.3.1 + js-yaml: 3.14.1 + parse-json: 4.0.0 + + cpu-features@0.0.10: + dependencies: + buildcheck: 0.0.6 + nan: 2.23.0 + optional: true + + crc-32@1.2.2: {} + + crc32-stream@6.0.0: + dependencies: + crc-32: 1.2.2 + readable-stream: 4.7.0 + cross-spawn@7.0.6: dependencies: path-key: 3.1.1 @@ -4934,12 +8650,22 @@ snapshots: csstype@3.1.3: {} + data-uri-to-buffer@4.0.1: {} + dataloader@1.4.0: {} + debug@2.6.9: + dependencies: + ms: 2.0.0 + debug@4.4.1: dependencies: ms: 2.1.3 + decompress-response@6.0.0: + dependencies: + mimic-response: 3.1.0 + deep-eql@5.0.2: {} deep-extend@0.6.0: {} @@ -4948,27 +8674,43 @@ snapshots: deepmerge@4.3.1: {} + default-browser-id@5.0.0: {} + + default-browser@5.2.1: + dependencies: + bundle-name: 4.1.0 + default-browser-id: 5.0.0 + defaults@1.0.4: dependencies: clone: 1.0.4 define-lazy-prop@2.0.0: {} + define-lazy-prop@3.0.0: {} + + denque@2.1.0: {} + + depd@2.0.0: {} + dependency-tree@10.0.9: dependencies: commander: 10.0.1 filing-cabinet: 4.2.0 precinct: 11.0.5 - typescript: 5.8.3 + typescript: 5.9.2 transitivePeerDependencies: - supports-color dequal@2.0.3: {} + destroy@1.2.0: {} + detect-indent@6.1.0: {} - detect-libc@2.0.4: - optional: true + detect-libc@2.0.2: {} + + detect-libc@2.0.4: {} detective-amd@5.0.2: dependencies: @@ -5006,10 +8748,10 @@ snapshots: detective-typescript@11.2.0: dependencies: - '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.8.3) + '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.9.2) ast-module-types: 5.0.0 node-source-walk: 6.0.2 - typescript: 5.8.3 + typescript: 5.9.2 transitivePeerDependencies: - supports-color @@ -5019,6 +8761,31 @@ snapshots: dependencies: path-type: 4.0.0 + docker-compose@1.2.0: + dependencies: + yaml: 2.8.1 + + docker-modem@5.0.6: + dependencies: + debug: 4.4.1 + readable-stream: 3.6.2 + split-ca: 1.0.1 + ssh2: 1.17.0 + transitivePeerDependencies: + - supports-color + + dockerode@4.0.7: + dependencies: + '@balena/dockerignore': 1.0.2 + '@grpc/grpc-js': 1.13.4 + '@grpc/proto-loader': 0.7.15 + docker-modem: 5.0.6 + protobufjs: 7.5.4 + tar-fs: 2.1.3 + uuid: 10.0.0 + transitivePeerDependencies: + - supports-color + doctrine@3.0.0: dependencies: esutils: 2.0.3 @@ -5029,55 +8796,83 @@ snapshots: eastasianwidth@0.2.0: {} - electron-to-chromium@1.5.190: {} + ecdsa-sig-formatter@1.0.11: + dependencies: + safe-buffer: 5.2.1 + + ee-first@1.1.1: {} + + electron-to-chromium@1.5.209: {} emoji-regex@8.0.0: {} emoji-regex@9.2.2: {} - enhanced-resolve@5.18.2: + encodeurl@1.0.2: {} + + encodeurl@2.0.0: {} + + end-of-stream@1.4.5: + dependencies: + once: 1.4.0 + + enhanced-resolve@5.18.3: dependencies: graceful-fs: 4.2.11 - tapable: 2.2.2 + tapable: 2.2.3 enquirer@2.4.1: dependencies: ansi-colors: 4.1.3 strip-ansi: 6.0.1 + error-ex@1.3.2: + dependencies: + is-arrayish: 0.2.1 + + error-stack-parser-es@1.0.5: {} + + error-stack-parser@2.1.4: + dependencies: + stackframe: 1.3.4 + es-module-lexer@1.7.0: {} - esbuild@0.25.8: + esbuild@0.25.9: optionalDependencies: - '@esbuild/aix-ppc64': 0.25.8 - '@esbuild/android-arm': 0.25.8 - '@esbuild/android-arm64': 0.25.8 - '@esbuild/android-x64': 0.25.8 - '@esbuild/darwin-arm64': 0.25.8 - '@esbuild/darwin-x64': 0.25.8 - '@esbuild/freebsd-arm64': 0.25.8 - '@esbuild/freebsd-x64': 0.25.8 - '@esbuild/linux-arm': 0.25.8 - '@esbuild/linux-arm64': 0.25.8 - '@esbuild/linux-ia32': 0.25.8 - '@esbuild/linux-loong64': 0.25.8 - '@esbuild/linux-mips64el': 0.25.8 - '@esbuild/linux-ppc64': 0.25.8 - '@esbuild/linux-riscv64': 0.25.8 - '@esbuild/linux-s390x': 0.25.8 - '@esbuild/linux-x64': 0.25.8 - '@esbuild/netbsd-arm64': 0.25.8 - '@esbuild/netbsd-x64': 0.25.8 - '@esbuild/openbsd-arm64': 0.25.8 - '@esbuild/openbsd-x64': 0.25.8 - '@esbuild/openharmony-arm64': 0.25.8 - '@esbuild/sunos-x64': 0.25.8 - '@esbuild/win32-arm64': 0.25.8 - '@esbuild/win32-ia32': 0.25.8 - '@esbuild/win32-x64': 0.25.8 + '@esbuild/aix-ppc64': 0.25.9 + '@esbuild/android-arm': 0.25.9 + '@esbuild/android-arm64': 0.25.9 + '@esbuild/android-x64': 0.25.9 + '@esbuild/darwin-arm64': 0.25.9 + '@esbuild/darwin-x64': 0.25.9 + '@esbuild/freebsd-arm64': 0.25.9 + '@esbuild/freebsd-x64': 0.25.9 + '@esbuild/linux-arm': 0.25.9 + '@esbuild/linux-arm64': 0.25.9 + '@esbuild/linux-ia32': 0.25.9 + '@esbuild/linux-loong64': 0.25.9 + '@esbuild/linux-mips64el': 0.25.9 + '@esbuild/linux-ppc64': 0.25.9 + '@esbuild/linux-riscv64': 0.25.9 + '@esbuild/linux-s390x': 0.25.9 + '@esbuild/linux-x64': 0.25.9 + '@esbuild/netbsd-arm64': 0.25.9 + '@esbuild/netbsd-x64': 0.25.9 + '@esbuild/openbsd-arm64': 0.25.9 + '@esbuild/openbsd-x64': 0.25.9 + '@esbuild/openharmony-arm64': 0.25.9 + '@esbuild/sunos-x64': 0.25.9 + '@esbuild/win32-arm64': 0.25.9 + '@esbuild/win32-ia32': 0.25.9 + '@esbuild/win32-x64': 0.25.9 escalade@3.2.0: {} + escape-html@1.0.3: {} + + escape-string-regexp@2.0.0: {} + escape-string-regexp@4.0.0: {} escodegen@2.1.0: @@ -5095,10 +8890,10 @@ snapshots: optionalDependencies: unrs-resolver: 1.11.1 - eslint-import-resolver-typescript@4.4.4(eslint-plugin-import-x@4.16.1(@typescript-eslint/utils@8.38.0(eslint@9.31.0)(typescript@5.8.3))(eslint@9.31.0))(eslint@9.31.0): + eslint-import-resolver-typescript@4.4.4(eslint-plugin-import-x@4.16.1(@typescript-eslint/utils@8.41.0(eslint@9.34.0)(typescript@5.9.2))(eslint@9.34.0))(eslint@9.34.0): dependencies: debug: 4.4.1 - eslint: 9.31.0 + eslint: 9.34.0 eslint-import-context: 0.1.9(unrs-resolver@1.11.1) get-tsconfig: 4.10.1 is-bun-module: 2.0.0 @@ -5106,16 +8901,16 @@ snapshots: tinyglobby: 0.2.14 unrs-resolver: 1.11.1 optionalDependencies: - eslint-plugin-import-x: 4.16.1(@typescript-eslint/utils@8.38.0(eslint@9.31.0)(typescript@5.8.3))(eslint@9.31.0) + eslint-plugin-import-x: 4.16.1(@typescript-eslint/utils@8.41.0(eslint@9.34.0)(typescript@5.9.2))(eslint@9.34.0) transitivePeerDependencies: - supports-color - eslint-plugin-import-x@4.16.1(@typescript-eslint/utils@8.38.0(eslint@9.31.0)(typescript@5.8.3))(eslint@9.31.0): + eslint-plugin-import-x@4.16.1(@typescript-eslint/utils@8.41.0(eslint@9.34.0)(typescript@5.9.2))(eslint@9.34.0): dependencies: - '@typescript-eslint/types': 8.38.0 + '@typescript-eslint/types': 8.41.0 comment-parser: 1.4.1 debug: 4.4.1 - eslint: 9.31.0 + eslint: 9.34.0 eslint-import-context: 0.1.9(unrs-resolver@1.11.1) is-glob: 4.0.3 minimatch: 10.0.3 @@ -5123,19 +8918,19 @@ snapshots: stable-hash-x: 0.2.0 unrs-resolver: 1.11.1 optionalDependencies: - '@typescript-eslint/utils': 8.38.0(eslint@9.31.0)(typescript@5.8.3) + '@typescript-eslint/utils': 8.41.0(eslint@9.34.0)(typescript@5.9.2) transitivePeerDependencies: - supports-color eslint-plugin-local-rules@3.0.2: {} - eslint-plugin-simple-import-sort@12.1.1(eslint@9.31.0): + eslint-plugin-simple-import-sort@12.1.1(eslint@9.34.0): dependencies: - eslint: 9.31.0 + eslint: 9.34.0 - eslint-plugin-sort-destructure-keys@2.0.0(eslint@9.31.0): + eslint-plugin-sort-destructure-keys@2.0.0(eslint@9.34.0): dependencies: - eslint: 9.31.0 + eslint: 9.34.0 natural-compare-lite: 1.4.0 eslint-scope@8.4.0: @@ -5147,16 +8942,16 @@ snapshots: eslint-visitor-keys@4.2.1: {} - eslint@9.31.0: + eslint@9.34.0: dependencies: - '@eslint-community/eslint-utils': 4.7.0(eslint@9.31.0) + '@eslint-community/eslint-utils': 4.7.0(eslint@9.34.0) '@eslint-community/regexpp': 4.12.1 '@eslint/config-array': 0.21.0 - '@eslint/config-helpers': 0.3.0 - '@eslint/core': 0.15.1 + '@eslint/config-helpers': 0.3.1 + '@eslint/core': 0.15.2 '@eslint/eslintrc': 3.3.1 - '@eslint/js': 9.31.0 - '@eslint/plugin-kit': 0.3.4 + '@eslint/js': 9.34.0 + '@eslint/plugin-kit': 0.3.5 '@humanfs/node': 0.16.6 '@humanwhocodes/module-importer': 1.0.1 '@humanwhocodes/retry': 0.4.3 @@ -5213,24 +9008,30 @@ snapshots: esutils@2.0.3: {} + etag@1.8.1: {} + + event-target-shim@5.0.1: {} + + events@3.3.0: {} + + exit-hook@2.2.1: {} + expand-range@1.8.2: dependencies: fill-range: 2.2.4 + expand-template@2.0.3: {} + expect-type@1.2.2: {} + exponential-backoff@3.1.2: {} + extend-shallow@2.0.1: dependencies: is-extendable: 0.1.1 extendable-error@0.1.7: {} - external-editor@3.1.0: - dependencies: - chardet: 0.7.0 - iconv-lite: 0.4.24 - tmp: 0.0.33 - fast-check@4.2.0: dependencies: pure-rand: 7.0.1 @@ -5239,6 +9040,8 @@ snapshots: fast-diff@1.3.0: {} + fast-fifo@1.3.2: {} + fast-glob@3.3.3: dependencies: '@nodelib/fs.stat': 2.0.5 @@ -5251,25 +9054,36 @@ snapshots: fast-levenshtein@2.0.6: {} - fast-uri@3.0.6: {} + fast-uri@3.1.0: {} fastq@1.19.1: dependencies: reusify: 1.1.0 - fdir@6.4.6(picomatch@4.0.3): + fb-watchman@2.0.2: + dependencies: + bser: 2.1.1 + + fdir@6.5.0(picomatch@4.0.3): optionalDependencies: picomatch: 4.0.3 + fetch-blob@3.2.0: + dependencies: + node-domexception: 1.0.0 + web-streams-polyfill: 3.3.3 + file-entry-cache@8.0.0: dependencies: flat-cache: 4.0.1 + file-uri-to-path@1.0.0: {} + filing-cabinet@4.2.0: dependencies: app-module-path: 2.2.0 commander: 10.0.1 - enhanced-resolve: 5.18.2 + enhanced-resolve: 5.18.3 is-relative-path: 1.0.2 module-definition: 5.0.1 module-lookup-amd: 8.0.5 @@ -5278,7 +9092,7 @@ snapshots: sass-lookup: 5.0.1 stylus-lookup: 5.0.1 tsconfig-paths: 4.2.0 - typescript: 5.8.3 + typescript: 5.9.2 fill-range@2.2.4: dependencies: @@ -5292,6 +9106,18 @@ snapshots: dependencies: to-regex-range: 5.0.1 + finalhandler@1.1.2: + dependencies: + debug: 2.6.9 + encodeurl: 1.0.2 + escape-html: 1.0.3 + on-finished: 2.3.0 + parseurl: 1.3.3 + statuses: 1.5.0 + unpipe: 1.0.0 + transitivePeerDependencies: + - supports-color + find-cache-dir@2.1.0: dependencies: commondir: 1.0.1 @@ -5327,7 +9153,9 @@ snapshots: flatted@3.3.3: {} - flow-parser@0.277.0: {} + flow-enums-runtime@0.0.6: {} + + flow-parser@0.279.0: {} for-in@1.0.2: {} @@ -5336,6 +9164,14 @@ snapshots: cross-spawn: 7.0.6 signal-exit: 4.1.0 + formdata-polyfill@4.0.10: + dependencies: + fetch-blob: 3.2.0 + + fresh@0.5.2: {} + + fs-constants@1.0.0: {} + fs-extra@7.0.1: dependencies: graceful-fs: 4.2.11 @@ -5360,6 +9196,10 @@ snapshots: function-bind@1.1.2: {} + generate-function@2.3.1: + dependencies: + is-property: 1.0.2 + gensync@1.0.0-beta.2: {} get-amd-module-type@5.0.1: @@ -5371,10 +9211,16 @@ snapshots: get-own-enumerable-property-symbols@3.0.2: {} + get-package-type@0.1.0: {} + + get-port@7.1.0: {} + get-tsconfig@4.10.1: dependencies: resolve-pkg-maps: 1.0.0 + github-from-package@0.0.0: {} + glob-parent@5.1.2: dependencies: is-glob: 4.0.3 @@ -5383,6 +9229,8 @@ snapshots: dependencies: is-glob: 4.0.3 + glob-to-regexp@0.4.1: {} + glob@10.4.5: dependencies: foreground-child: 3.3.1 @@ -5427,6 +9275,8 @@ snapshots: merge2: 1.4.1 slash: 3.0.0 + globrex@0.1.2: {} + gonzales-pe@4.3.0: dependencies: minimist: 1.2.8 @@ -5454,17 +9304,45 @@ snapshots: dependencies: function-bind: 1.1.2 + hermes-estree@0.29.1: {} + + hermes-parser@0.29.1: + dependencies: + hermes-estree: 0.29.1 + html-escaper@2.0.2: {} + http-errors@2.0.0: + dependencies: + depd: 2.0.0 + inherits: 2.0.4 + setprototypeof: 1.2.0 + statuses: 2.0.1 + toidentifier: 1.0.1 + + http-proxy-agent@7.0.2: + dependencies: + agent-base: 7.1.4 + debug: 4.4.1 + transitivePeerDependencies: + - supports-color + + https-proxy-agent@7.0.6: + dependencies: + agent-base: 7.1.4 + debug: 4.4.1 + transitivePeerDependencies: + - supports-color + human-id@4.1.1: {} - i18next@25.3.2(typescript@5.8.3): + i18next@25.4.2(typescript@5.9.2): dependencies: - '@babel/runtime': 7.27.6 + '@babel/runtime': 7.28.3 optionalDependencies: - typescript: 5.8.3 + typescript: 5.9.2 - iconv-lite@0.4.24: + iconv-lite@0.6.3: dependencies: safer-buffer: 2.1.2 @@ -5474,8 +9352,17 @@ snapshots: ignore@7.0.5: {} + image-size@1.2.1: + dependencies: + queue: 6.0.2 + immer@10.1.1: {} + import-fresh@2.0.0: + dependencies: + caller-path: 2.0.0 + resolve-from: 3.0.0 + import-fresh@3.3.1: dependencies: parent-module: 1.0.1 @@ -5494,6 +9381,14 @@ snapshots: ini@4.1.3: {} + invariant@2.2.4: + dependencies: + loose-envify: 1.4.0 + + is-arrayish@0.2.1: {} + + is-arrayish@0.3.2: {} + is-binary-path@2.1.0: dependencies: binary-extensions: 2.3.0 @@ -5509,8 +9404,12 @@ snapshots: dependencies: hasown: 2.0.2 + is-directory@0.3.1: {} + is-docker@2.2.1: {} + is-docker@3.0.0: {} + is-extendable@0.1.1: {} is-extendable@1.0.1: @@ -5525,6 +9424,10 @@ snapshots: dependencies: is-extglob: 2.1.1 + is-inside-container@1.0.0: + dependencies: + is-docker: 3.0.0 + is-interactive@1.0.0: {} is-module@1.0.0: {} @@ -5543,10 +9446,14 @@ snapshots: dependencies: isobject: 3.0.1 + is-property@1.0.2: {} + is-regexp@1.0.0: {} is-relative-path@1.0.2: {} + is-stream@2.0.1: {} + is-subdir@1.2.0: dependencies: better-path-resolve: 1.0.0 @@ -5563,6 +9470,10 @@ snapshots: dependencies: is-docker: 2.2.1 + is-wsl@3.1.0: + dependencies: + is-inside-container: 1.0.0 + isarray@1.0.0: {} isexe@2.0.0: {} @@ -5577,6 +9488,16 @@ snapshots: istanbul-lib-coverage@3.2.2: {} + istanbul-lib-instrument@5.2.1: + dependencies: + '@babel/core': 7.28.3 + '@babel/parser': 7.28.3 + '@istanbuljs/schema': 0.1.3 + istanbul-lib-coverage: 3.2.2 + semver: 6.3.1 + transitivePeerDependencies: + - supports-color + istanbul-lib-report@3.0.1: dependencies: istanbul-lib-coverage: 3.2.2 @@ -5585,13 +9506,13 @@ snapshots: istanbul-lib-source-maps@5.0.6: dependencies: - '@jridgewell/trace-mapping': 0.3.29 + '@jridgewell/trace-mapping': 0.3.30 debug: 4.4.1 istanbul-lib-coverage: 3.2.2 transitivePeerDependencies: - supports-color - istanbul-reports@3.1.7: + istanbul-reports@3.2.0: dependencies: html-escaper: 2.0.2 istanbul-lib-report: 3.0.1 @@ -5606,6 +9527,82 @@ snapshots: dependencies: '@isaacs/cliui': 8.0.2 + jest-environment-node@29.7.0: + dependencies: + '@jest/environment': 29.7.0 + '@jest/fake-timers': 29.7.0 + '@jest/types': 29.6.3 + '@types/node': 24.3.0 + jest-mock: 29.7.0 + jest-util: 29.7.0 + + jest-get-type@29.6.3: {} + + jest-haste-map@29.7.0: + dependencies: + '@jest/types': 29.6.3 + '@types/graceful-fs': 4.1.9 + '@types/node': 24.3.0 + anymatch: 3.1.3 + fb-watchman: 2.0.2 + graceful-fs: 4.2.11 + jest-regex-util: 29.6.3 + jest-util: 29.7.0 + jest-worker: 29.7.0 + micromatch: 4.0.8 + walker: 1.0.8 + optionalDependencies: + fsevents: 2.3.3 + + jest-message-util@29.7.0: + dependencies: + '@babel/code-frame': 7.27.1 + '@jest/types': 29.6.3 + '@types/stack-utils': 2.0.3 + chalk: 4.1.2 + graceful-fs: 4.2.11 + micromatch: 4.0.8 + pretty-format: 29.7.0 + slash: 3.0.0 + stack-utils: 2.0.6 + + jest-mock@29.7.0: + dependencies: + '@jest/types': 29.6.3 + '@types/node': 24.3.0 + jest-util: 29.7.0 + + jest-regex-util@29.6.3: {} + + jest-util@29.7.0: + dependencies: + '@jest/types': 29.6.3 + '@types/node': 24.3.0 + chalk: 4.1.2 + ci-info: 3.9.0 + graceful-fs: 4.2.11 + picomatch: 2.3.1 + + jest-validate@29.7.0: + dependencies: + '@jest/types': 29.6.3 + camelcase: 6.3.0 + chalk: 4.1.2 + jest-get-type: 29.6.3 + leven: 3.1.0 + pretty-format: 29.7.0 + + jest-worker@29.7.0: + dependencies: + '@types/node': 24.3.0 + jest-util: 29.7.0 + merge-stream: 2.0.0 + supports-color: 8.1.1 + + js-base64@3.7.8: {} + + js-md4@0.3.2: {} + js-tokens@4.0.0: {} js-tokens@9.0.1: {} @@ -5619,33 +9616,39 @@ snapshots: dependencies: argparse: 2.0.1 + jsc-safe-url@0.2.4: {} + jscodeshift@17.3.0: dependencies: - '@babel/core': 7.28.0 - '@babel/parser': 7.28.0 - '@babel/plugin-transform-class-properties': 7.27.1(@babel/core@7.28.0) - '@babel/plugin-transform-modules-commonjs': 7.27.1(@babel/core@7.28.0) - '@babel/plugin-transform-nullish-coalescing-operator': 7.27.1(@babel/core@7.28.0) - '@babel/plugin-transform-optional-chaining': 7.27.1(@babel/core@7.28.0) - '@babel/plugin-transform-private-methods': 7.27.1(@babel/core@7.28.0) - '@babel/preset-flow': 7.27.1(@babel/core@7.28.0) - '@babel/preset-typescript': 7.27.1(@babel/core@7.28.0) - '@babel/register': 7.27.1(@babel/core@7.28.0) - flow-parser: 0.277.0 + '@babel/core': 7.28.3 + '@babel/parser': 7.28.3 + '@babel/plugin-transform-class-properties': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-modules-commonjs': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-nullish-coalescing-operator': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-optional-chaining': 7.27.1(@babel/core@7.28.3) + '@babel/plugin-transform-private-methods': 7.27.1(@babel/core@7.28.3) + '@babel/preset-flow': 7.27.1(@babel/core@7.28.3) + '@babel/preset-typescript': 7.27.1(@babel/core@7.28.3) + '@babel/register': 7.28.3(@babel/core@7.28.3) + flow-parser: 0.279.0 graceful-fs: 4.2.11 micromatch: 4.0.8 neo-async: 2.6.2 picocolors: 1.1.1 recast: 0.23.11 - tmp: 0.2.3 + tmp: 0.2.5 write-file-atomic: 5.0.1 transitivePeerDependencies: - supports-color + jsesc@3.0.2: {} + jsesc@3.1.0: {} json-buffer@3.0.1: {} + json-parse-better-errors@1.0.2: {} + json-schema-traverse@0.4.1: {} json-schema-traverse@1.0.0: {} @@ -5658,6 +9661,30 @@ snapshots: optionalDependencies: graceful-fs: 4.2.11 + jsonwebtoken@9.0.2: + dependencies: + jws: 3.2.2 + lodash.includes: 4.3.0 + lodash.isboolean: 3.0.3 + lodash.isinteger: 4.0.4 + lodash.isnumber: 3.0.3 + lodash.isplainobject: 4.0.6 + lodash.isstring: 4.0.1 + lodash.once: 4.1.1 + ms: 2.1.3 + semver: 7.7.2 + + jwa@1.4.2: + dependencies: + buffer-equal-constant-time: 1.0.1 + ecdsa-sig-formatter: 1.0.11 + safe-buffer: 5.2.1 + + jws@3.2.2: + dependencies: + jwa: 1.4.2 + safe-buffer: 5.2.1 + keyv@4.5.4: dependencies: json-buffer: 3.0.1 @@ -5670,15 +9697,45 @@ snapshots: kind-of@6.0.3: {} + kleur@4.1.5: {} + lazy-cache@2.0.2: dependencies: set-getter: 0.1.1 + lazystream@1.0.1: + dependencies: + readable-stream: 2.3.8 + + leven@3.1.0: {} + levn@0.4.1: dependencies: prelude-ls: 1.2.1 type-check: 0.4.0 + libsql@0.5.20: + dependencies: + '@neon-rs/load': 0.0.4 + detect-libc: 2.0.2 + optionalDependencies: + '@libsql/darwin-arm64': 0.5.20 + '@libsql/darwin-x64': 0.5.20 + '@libsql/linux-arm-gnueabihf': 0.5.20 + '@libsql/linux-arm-musleabihf': 0.5.20 + '@libsql/linux-arm64-gnu': 0.5.20 + '@libsql/linux-arm64-musl': 0.5.20 + '@libsql/linux-x64-gnu': 0.5.20 + '@libsql/linux-x64-musl': 0.5.20 + '@libsql/win32-x64-msvc': 0.5.20 + + lighthouse-logger@1.4.2: + dependencies: + debug: 2.6.9 + marky: 1.3.0 + transitivePeerDependencies: + - supports-color + list-item@1.1.1: dependencies: expand-range: 1.8.2 @@ -5701,8 +9758,26 @@ snapshots: lodash._reinterpolate@3.0.0: {} + lodash.camelcase@4.3.0: {} + + lodash.debounce@4.0.8: {} + + lodash.includes@4.3.0: {} + + lodash.isboolean@3.0.3: {} + + lodash.isinteger@4.0.4: {} + + lodash.isnumber@3.0.3: {} + + lodash.isplainobject@4.0.6: {} + + lodash.isstring@4.0.1: {} + lodash.merge@4.6.2: {} + lodash.once@4.1.1: {} + lodash.startcase@4.4.0: {} lodash.template@4.5.0: @@ -5714,6 +9789,8 @@ snapshots: dependencies: lodash._reinterpolate: 3.0.0 + lodash.throttle@4.1.1: {} + lodash@4.17.21: {} log-symbols@4.1.0: @@ -5721,7 +9798,13 @@ snapshots: chalk: 4.1.2 is-unicode-supported: 0.1.0 - loupe@3.2.0: {} + long@5.3.2: {} + + loose-envify@1.4.0: + dependencies: + js-tokens: 4.0.0 + + loupe@3.2.1: {} lru-cache@10.4.3: {} @@ -5731,9 +9814,13 @@ snapshots: dependencies: yallist: 3.1.1 + lru-cache@7.18.3: {} + + lru.min@1.1.2: {} + lz-string@1.5.0: {} - madge@8.0.0(typescript@5.8.3): + madge@8.0.0(typescript@5.9.2): dependencies: chalk: 4.1.2 commander: 7.2.0 @@ -5748,18 +9835,18 @@ snapshots: ts-graphviz: 2.1.6 walkdir: 0.4.1 optionalDependencies: - typescript: 5.8.3 + typescript: 5.9.2 transitivePeerDependencies: - supports-color - magic-string@0.30.17: + magic-string@0.30.18: dependencies: - '@jridgewell/sourcemap-codec': 1.5.4 + '@jridgewell/sourcemap-codec': 1.5.5 magicast@0.3.5: dependencies: - '@babel/parser': 7.28.0 - '@babel/types': 7.28.1 + '@babel/parser': 7.28.3 + '@babel/types': 7.28.2 source-map-js: 1.2.1 make-dir@2.1.0: @@ -5775,21 +9862,234 @@ snapshots: dependencies: semver: 7.7.2 + makeerror@1.0.12: + dependencies: + tmpl: 1.0.5 + markdown-link@0.1.1: {} + marky@1.3.0: {} + math-random@1.0.4: {} + memoize-one@5.2.1: {} + + merge-stream@2.0.0: {} + merge2@1.4.1: {} + metro-babel-transformer@0.83.1: + dependencies: + '@babel/core': 7.28.3 + flow-enums-runtime: 0.0.6 + hermes-parser: 0.29.1 + nullthrows: 1.1.1 + transitivePeerDependencies: + - supports-color + + metro-cache-key@0.83.1: + dependencies: + flow-enums-runtime: 0.0.6 + + metro-cache@0.83.1: + dependencies: + exponential-backoff: 3.1.2 + flow-enums-runtime: 0.0.6 + https-proxy-agent: 7.0.6 + metro-core: 0.83.1 + transitivePeerDependencies: + - supports-color + + metro-config@0.83.1: + dependencies: + connect: 3.7.0 + cosmiconfig: 5.2.1 + flow-enums-runtime: 0.0.6 + jest-validate: 29.7.0 + metro: 0.83.1 + metro-cache: 0.83.1 + metro-core: 0.83.1 + metro-runtime: 0.83.1 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + + metro-core@0.83.1: + dependencies: + flow-enums-runtime: 0.0.6 + lodash.throttle: 4.1.1 + metro-resolver: 0.83.1 + + metro-file-map@0.83.1: + dependencies: + debug: 4.4.1 + fb-watchman: 2.0.2 + flow-enums-runtime: 0.0.6 + graceful-fs: 4.2.11 + invariant: 2.2.4 + jest-worker: 29.7.0 + micromatch: 4.0.8 + nullthrows: 1.1.1 + walker: 1.0.8 + transitivePeerDependencies: + - supports-color + + metro-minify-terser@0.83.1: + dependencies: + flow-enums-runtime: 0.0.6 + terser: 5.43.1 + + metro-resolver@0.83.1: + dependencies: + flow-enums-runtime: 0.0.6 + + metro-runtime@0.83.1: + dependencies: + '@babel/runtime': 7.28.3 + flow-enums-runtime: 0.0.6 + + metro-source-map@0.83.1: + dependencies: + '@babel/traverse': 7.28.3 + '@babel/traverse--for-generate-function-map': '@babel/traverse@7.28.3' + '@babel/types': 7.28.2 + flow-enums-runtime: 0.0.6 + invariant: 2.2.4 + metro-symbolicate: 0.83.1 + nullthrows: 1.1.1 + ob1: 0.83.1 + source-map: 0.5.7 + vlq: 1.0.1 + transitivePeerDependencies: + - supports-color + + metro-symbolicate@0.83.1: + dependencies: + flow-enums-runtime: 0.0.6 + invariant: 2.2.4 + metro-source-map: 0.83.1 + nullthrows: 1.1.1 + source-map: 0.5.7 + vlq: 1.0.1 + transitivePeerDependencies: + - supports-color + + metro-transform-plugins@0.83.1: + dependencies: + '@babel/core': 7.28.3 + '@babel/generator': 7.28.3 + '@babel/template': 7.27.2 + '@babel/traverse': 7.28.3 + flow-enums-runtime: 0.0.6 + nullthrows: 1.1.1 + transitivePeerDependencies: + - supports-color + + metro-transform-worker@0.83.1: + dependencies: + '@babel/core': 7.28.3 + '@babel/generator': 7.28.3 + '@babel/parser': 7.28.3 + '@babel/types': 7.28.2 + flow-enums-runtime: 0.0.6 + metro: 0.83.1 + metro-babel-transformer: 0.83.1 + metro-cache: 0.83.1 + metro-cache-key: 0.83.1 + metro-minify-terser: 0.83.1 + metro-source-map: 0.83.1 + metro-transform-plugins: 0.83.1 + nullthrows: 1.1.1 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + + metro@0.83.1: + dependencies: + '@babel/code-frame': 7.27.1 + '@babel/core': 7.28.3 + '@babel/generator': 7.28.3 + '@babel/parser': 7.28.3 + '@babel/template': 7.27.2 + '@babel/traverse': 7.28.3 + '@babel/types': 7.28.2 + accepts: 1.3.8 + chalk: 4.1.2 + ci-info: 2.0.0 + connect: 3.7.0 + debug: 4.4.1 + error-stack-parser: 2.1.4 + flow-enums-runtime: 0.0.6 + graceful-fs: 4.2.11 + hermes-parser: 0.29.1 + image-size: 1.2.1 + invariant: 2.2.4 + jest-worker: 29.7.0 + jsc-safe-url: 0.2.4 + lodash.throttle: 4.1.1 + metro-babel-transformer: 0.83.1 + metro-cache: 0.83.1 + metro-cache-key: 0.83.1 + metro-config: 0.83.1 + metro-core: 0.83.1 + metro-file-map: 0.83.1 + metro-resolver: 0.83.1 + metro-runtime: 0.83.1 + metro-source-map: 0.83.1 + metro-symbolicate: 0.83.1 + metro-transform-plugins: 0.83.1 + metro-transform-worker: 0.83.1 + mime-types: 2.1.35 + nullthrows: 1.1.1 + serialize-error: 2.1.0 + source-map: 0.5.7 + throat: 5.0.0 + ws: 7.5.10 + yargs: 17.7.2 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + micromatch@4.0.8: dependencies: braces: 3.0.3 picomatch: 2.3.1 + mime-db@1.52.0: {} + + mime-types@2.1.35: + dependencies: + mime-db: 1.52.0 + + mime@1.6.0: {} + mime@4.0.7: {} mimic-fn@2.1.0: {} + mimic-response@3.1.0: {} + + miniflare@4.20250823.0: + dependencies: + '@cspotcode/source-map-support': 0.8.1 + acorn: 8.14.0 + acorn-walk: 8.3.2 + exit-hook: 2.2.1 + glob-to-regexp: 0.4.1 + sharp: 0.33.5 + stoppable: 1.1.0 + undici: 7.15.0 + workerd: 1.20250823.0 + ws: 8.18.0 + youch: 4.1.0-beta.10 + zod: 3.22.3 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + minimatch@10.0.3: dependencies: '@isaacs/brace-expansion': 5.0.0 @@ -5798,6 +10098,10 @@ snapshots: dependencies: brace-expansion: 1.1.12 + minimatch@5.1.6: + dependencies: + brace-expansion: 2.0.2 + minimatch@9.0.5: dependencies: brace-expansion: 2.0.2 @@ -5815,6 +10119,10 @@ snapshots: for-in: 1.0.2 is-extendable: 1.0.1 + mkdirp-classic@0.5.3: {} + + mkdirp@1.0.4: {} + mkdirp@3.0.1: {} mock-socket@9.3.1: {} @@ -5835,6 +10143,8 @@ snapshots: mrmime@2.0.1: {} + ms@2.0.0: {} + ms@2.1.3: {} msgpackr-extract@3.0.3: @@ -5855,38 +10165,90 @@ snapshots: multipasta@0.2.7: {} + mysql2@3.14.3: + dependencies: + aws-ssl-profiles: 1.1.2 + denque: 2.1.0 + generate-function: 2.3.1 + iconv-lite: 0.6.3 + long: 5.3.2 + lru.min: 1.1.2 + named-placeholders: 1.1.3 + seq-queue: 0.0.5 + sqlstring: 2.3.3 + + named-placeholders@1.1.3: + dependencies: + lru-cache: 7.18.3 + + nan@2.23.0: + optional: true + nanoid@3.3.11: {} - napi-postinstall@0.3.2: {} + napi-build-utils@2.0.0: {} + + napi-postinstall@0.3.3: {} + + native-duplexpair@1.0.0: {} natural-compare-lite@1.4.0: {} natural-compare@1.4.0: {} + negotiator@0.6.3: {} + neo-async@2.6.2: {} + node-abi@3.75.0: + dependencies: + semver: 7.7.2 + + node-domexception@1.0.0: {} + node-fetch@2.7.0: dependencies: whatwg-url: 5.0.0 + node-fetch@3.3.2: + dependencies: + data-uri-to-buffer: 4.0.1 + fetch-blob: 3.2.0 + formdata-polyfill: 4.0.10 + node-gyp-build-optional-packages@5.2.2: dependencies: detect-libc: 2.0.4 optional: true + node-int64@0.4.0: {} + node-releases@2.0.19: {} node-source-walk@6.0.2: dependencies: - '@babel/parser': 7.28.0 + '@babel/parser': 7.28.3 - normalize-path@3.0.0: - optional: true + normalize-path@3.0.0: {} + + nullthrows@1.1.1: {} + + ob1@0.83.1: + dependencies: + flow-enums-runtime: 0.0.6 object.pick@1.3.0: dependencies: isobject: 3.0.1 + on-finished@2.3.0: + dependencies: + ee-first: 1.1.1 + + on-finished@2.4.1: + dependencies: + ee-first: 1.1.1 + once@1.4.0: dependencies: wrappy: 1.0.2 @@ -5895,6 +10257,18 @@ snapshots: dependencies: mimic-fn: 2.1.0 + open@10.2.0: + dependencies: + default-browser: 5.2.1 + define-lazy-prop: 3.0.0 + is-inside-container: 1.0.0 + wsl-utils: 0.1.0 + + open@7.4.2: + dependencies: + is-docker: 2.2.1 + is-wsl: 2.2.0 + open@8.4.2: dependencies: define-lazy-prop: 2.0.0 @@ -5922,8 +10296,6 @@ snapshots: strip-ansi: 6.0.1 wcwidth: 1.0.1 - os-tmpdir@1.0.2: {} - outdent@0.5.0: {} p-filter@2.1.0: @@ -5958,14 +10330,21 @@ snapshots: package-manager-detector@0.2.11: dependencies: - quansync: 0.2.10 + quansync: 0.2.11 parent-module@1.0.1: dependencies: callsites: 3.1.0 + parse-json@4.0.0: + dependencies: + error-ex: 1.3.2 + json-parse-better-errors: 1.0.2 + parse-ms@2.1.0: {} + parseurl@1.3.3: {} + path-exists@3.0.0: {} path-exists@4.0.0: {} @@ -5992,6 +10371,45 @@ snapshots: pathval@2.0.1: {} + pg-cloudflare@1.2.7: + optional: true + + pg-connection-string@2.9.1: {} + + pg-cursor@2.15.3(pg@8.16.3): + dependencies: + pg: 8.16.3 + + pg-int8@1.0.1: {} + + pg-pool@3.10.1(pg@8.16.3): + dependencies: + pg: 8.16.3 + + pg-protocol@1.10.3: {} + + pg-types@2.2.0: + dependencies: + pg-int8: 1.0.1 + postgres-array: 2.0.0 + postgres-bytea: 1.0.0 + postgres-date: 1.0.7 + postgres-interval: 1.2.0 + + pg@8.16.3: + dependencies: + pg-connection-string: 2.9.1 + pg-pool: 3.10.1(pg@8.16.3) + pg-protocol: 1.10.3 + pg-types: 2.2.0 + pgpass: 1.0.5 + optionalDependencies: + pg-cloudflare: 1.2.7 + + pgpass@1.0.5: + dependencies: + split2: 4.2.0 + picocolors@1.1.1: {} picomatch@2.3.1: {} @@ -6012,11 +10430,11 @@ snapshots: pkg-entry-points@1.1.1: {} - playwright-core@1.54.1: {} + playwright-core@1.55.0: {} - playwright@1.54.1: + playwright@1.55.0: dependencies: - playwright-core: 1.54.1 + playwright-core: 1.55.0 optionalDependencies: fsevents: 2.3.2 @@ -6035,6 +10453,31 @@ snapshots: picocolors: 1.1.1 source-map-js: 1.2.1 + postgres-array@2.0.0: {} + + postgres-bytea@1.0.0: {} + + postgres-date@1.0.7: {} + + postgres-interval@1.2.0: + dependencies: + xtend: 4.0.2 + + prebuild-install@7.1.3: + dependencies: + detect-libc: 2.0.4 + expand-template: 2.0.3 + github-from-package: 0.0.0 + minimist: 1.2.8 + mkdirp-classic: 0.5.3 + napi-build-utils: 2.0.0 + node-abi: 3.75.0 + pump: 3.0.3 + rc: 1.2.8 + simple-get: 4.0.1 + tar-fs: 2.1.3 + tunnel-agent: 0.6.0 + precinct@11.0.5: dependencies: '@dependents/detective-less': 4.1.0 @@ -6068,20 +10511,68 @@ snapshots: ansi-styles: 5.2.0 react-is: 17.0.2 + pretty-format@29.7.0: + dependencies: + '@jest/schemas': 29.6.3 + ansi-styles: 5.2.0 + react-is: 18.3.1 + pretty-ms@7.0.1: dependencies: parse-ms: 2.1.0 process-nextick-args@2.0.1: {} + process@0.11.10: {} + + promise-limit@2.7.0: {} + + promise@8.3.0: + dependencies: + asap: 2.0.6 + + proper-lockfile@4.1.2: + dependencies: + graceful-fs: 4.2.11 + retry: 0.12.0 + signal-exit: 3.0.7 + + properties-reader@2.3.0: + dependencies: + mkdirp: 1.0.4 + + protobufjs@7.5.4: + dependencies: + '@protobufjs/aspromise': 1.1.2 + '@protobufjs/base64': 1.1.2 + '@protobufjs/codegen': 2.0.4 + '@protobufjs/eventemitter': 1.1.0 + '@protobufjs/fetch': 1.1.0 + '@protobufjs/float': 1.0.2 + '@protobufjs/inquire': 1.1.0 + '@protobufjs/path': 1.1.2 + '@protobufjs/pool': 1.1.0 + '@protobufjs/utf8': 1.1.0 + '@types/node': 24.3.0 + long: 5.3.2 + + pump@3.0.3: + dependencies: + end-of-stream: 1.4.5 + once: 1.4.0 + punycode@2.3.1: {} pure-rand@7.0.1: {} - quansync@0.2.10: {} + quansync@0.2.11: {} queue-microtask@1.2.3: {} + queue@6.0.2: + dependencies: + inherits: 2.0.4 + quote-unquote@1.0.0: {} randomatic@3.1.1: @@ -6094,6 +10585,8 @@ snapshots: dependencies: safe-buffer: 5.2.1 + range-parser@1.2.1: {} + rc@1.2.8: dependencies: deep-extend: 0.6.0 @@ -6101,8 +10594,69 @@ snapshots: minimist: 1.2.8 strip-json-comments: 2.0.1 + react-devtools-core@6.1.5: + dependencies: + shell-quote: 1.8.3 + ws: 7.5.10 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + react-is@17.0.2: {} + react-is@18.3.1: {} + + react-native@0.81.0(@babel/core@7.28.3)(@react-native/metro-config@0.81.0(@babel/core@7.28.3))(@types/react@19.1.11)(react@19.1.1): + dependencies: + '@jest/create-cache-key-function': 29.7.0 + '@react-native/assets-registry': 0.81.0 + '@react-native/codegen': 0.81.0(@babel/core@7.28.3) + '@react-native/community-cli-plugin': 0.81.0(@react-native/metro-config@0.81.0(@babel/core@7.28.3)) + '@react-native/gradle-plugin': 0.81.0 + '@react-native/js-polyfills': 0.81.0 + '@react-native/normalize-colors': 0.81.0 + '@react-native/virtualized-lists': 0.81.0(@types/react@19.1.11)(react-native@0.81.0(@babel/core@7.28.3)(@react-native/metro-config@0.81.0(@babel/core@7.28.3))(@types/react@19.1.11)(react@19.1.1))(react@19.1.1) + abort-controller: 3.0.0 + anser: 1.4.10 + ansi-regex: 5.0.1 + babel-jest: 29.7.0(@babel/core@7.28.3) + babel-plugin-syntax-hermes-parser: 0.29.1 + base64-js: 1.5.1 + commander: 12.1.0 + flow-enums-runtime: 0.0.6 + glob: 7.2.3 + invariant: 2.2.4 + jest-environment-node: 29.7.0 + memoize-one: 5.2.1 + metro-runtime: 0.83.1 + metro-source-map: 0.83.1 + nullthrows: 1.1.1 + pretty-format: 29.7.0 + promise: 8.3.0 + react: 19.1.1 + react-devtools-core: 6.1.5 + react-refresh: 0.14.2 + regenerator-runtime: 0.13.11 + scheduler: 0.26.0 + semver: 7.7.2 + stacktrace-parser: 0.1.11 + whatwg-fetch: 3.6.20 + ws: 6.2.3 + yargs: 17.7.2 + optionalDependencies: + '@types/react': 19.1.11 + transitivePeerDependencies: + - '@babel/core' + - '@react-native-community/cli' + - '@react-native/metro-config' + - bufferutil + - supports-color + - utf-8-validate + + react-refresh@0.14.2: {} + + react@19.1.1: {} + read-yaml-file@1.1.0: dependencies: graceful-fs: 4.2.11 @@ -6126,6 +10680,18 @@ snapshots: string_decoder: 1.3.0 util-deprecate: 1.0.2 + readable-stream@4.7.0: + dependencies: + abort-controller: 3.0.0 + buffer: 6.0.3 + events: 3.3.0 + process: 0.11.10 + string_decoder: 1.3.0 + + readdir-glob@1.1.3: + dependencies: + minimatch: 5.1.6 + readdirp@3.6.0: dependencies: picomatch: 2.3.1 @@ -6139,6 +10705,29 @@ snapshots: tiny-invariant: 1.3.3 tslib: 2.8.1 + regenerate-unicode-properties@10.2.0: + dependencies: + regenerate: 1.4.2 + + regenerate@1.4.2: {} + + regenerator-runtime@0.13.11: {} + + regexpu-core@6.2.0: + dependencies: + regenerate: 1.4.2 + regenerate-unicode-properties: 10.2.0 + regjsgen: 0.8.0 + regjsparser: 0.12.0 + unicode-match-property-ecmascript: 2.0.0 + unicode-match-property-value-ecmascript: 2.2.0 + + regjsgen@0.8.0: {} + + regjsparser@0.12.0: + dependencies: + jsesc: 3.0.2 + remarkable@1.7.4: dependencies: argparse: 1.0.10 @@ -6161,6 +10750,8 @@ snapshots: resolve-dependency-path@3.0.2: {} + resolve-from@3.0.0: {} + resolve-from@4.0.0: {} resolve-from@5.0.0: {} @@ -6178,82 +10769,116 @@ snapshots: onetime: 5.1.2 signal-exit: 3.0.7 + retry@0.12.0: {} + reusify@1.1.0: {} + rimraf@3.0.2: + dependencies: + glob: 7.2.3 + rimraf@6.0.1: dependencies: glob: 11.0.3 package-json-from-dist: 1.0.1 - rollup-plugin-bundle-stats@4.21.0(core-js@3.44.0)(rollup@4.45.1)(vite@7.0.5(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3)): + rolldown@1.0.0-beta.34: dependencies: - '@bundle-stats/cli-utils': 4.21.0(core-js@3.44.0) - rollup-plugin-webpack-stats: 2.1.0(rollup@4.45.1)(vite@7.0.5(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3)) + '@oxc-project/runtime': 0.82.3 + '@oxc-project/types': 0.82.3 + '@rolldown/pluginutils': 1.0.0-beta.34 + ansis: 4.1.0 + optionalDependencies: + '@rolldown/binding-android-arm64': 1.0.0-beta.34 + '@rolldown/binding-darwin-arm64': 1.0.0-beta.34 + '@rolldown/binding-darwin-x64': 1.0.0-beta.34 + '@rolldown/binding-freebsd-x64': 1.0.0-beta.34 + '@rolldown/binding-linux-arm-gnueabihf': 1.0.0-beta.34 + '@rolldown/binding-linux-arm64-gnu': 1.0.0-beta.34 + '@rolldown/binding-linux-arm64-musl': 1.0.0-beta.34 + '@rolldown/binding-linux-x64-gnu': 1.0.0-beta.34 + '@rolldown/binding-linux-x64-musl': 1.0.0-beta.34 + '@rolldown/binding-openharmony-arm64': 1.0.0-beta.34 + '@rolldown/binding-wasm32-wasi': 1.0.0-beta.34 + '@rolldown/binding-win32-arm64-msvc': 1.0.0-beta.34 + '@rolldown/binding-win32-ia32-msvc': 1.0.0-beta.34 + '@rolldown/binding-win32-x64-msvc': 1.0.0-beta.34 + + rollup-plugin-bundle-stats@4.21.3(core-js@3.45.1)(rolldown@1.0.0-beta.34)(rollup@4.48.1)(vite@7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1)): + dependencies: + '@bundle-stats/cli-utils': 4.21.3(core-js@3.45.1) + rollup-plugin-webpack-stats: 2.1.4(rolldown@1.0.0-beta.34)(rollup@4.48.1)(vite@7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1)) tslib: 2.8.1 optionalDependencies: - rollup: 4.45.1 - vite: 7.0.5(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3) + rolldown: 1.0.0-beta.34 + rollup: 4.48.1 + vite: 7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1) transitivePeerDependencies: - core-js - rollup-plugin-esbuild@6.2.1(esbuild@0.25.8)(rollup@4.45.1): + rollup-plugin-esbuild@6.2.1(esbuild@0.25.9)(rollup@4.48.1): dependencies: debug: 4.4.1 es-module-lexer: 1.7.0 - esbuild: 0.25.8 + esbuild: 0.25.9 get-tsconfig: 4.10.1 - rollup: 4.45.1 - unplugin-utils: 0.2.4 + rollup: 4.48.1 + unplugin-utils: 0.2.5 transitivePeerDependencies: - supports-color - rollup-plugin-stats@1.4.0(rollup@4.45.1)(vite@7.0.5(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3)): + rollup-plugin-stats@1.5.0(rolldown@1.0.0-beta.34)(rollup@4.48.1)(vite@7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1)): optionalDependencies: - rollup: 4.45.1 - vite: 7.0.5(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3) + rolldown: 1.0.0-beta.34 + rollup: 4.48.1 + vite: 7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1) - rollup-plugin-visualizer@6.0.3(rollup@4.45.1): + rollup-plugin-visualizer@6.0.3(rolldown@1.0.0-beta.34)(rollup@4.48.1): dependencies: open: 8.4.2 picomatch: 4.0.3 - source-map: 0.7.4 + source-map: 0.7.6 yargs: 17.7.2 optionalDependencies: - rollup: 4.45.1 + rolldown: 1.0.0-beta.34 + rollup: 4.48.1 - rollup-plugin-webpack-stats@2.1.0(rollup@4.45.1)(vite@7.0.5(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3)): + rollup-plugin-webpack-stats@2.1.4(rolldown@1.0.0-beta.34)(rollup@4.48.1)(vite@7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1)): dependencies: - rollup-plugin-stats: 1.4.0(rollup@4.45.1)(vite@7.0.5(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3)) + rolldown: 1.0.0-beta.34 + rollup-plugin-stats: 1.5.0(rolldown@1.0.0-beta.34)(rollup@4.48.1)(vite@7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1)) optionalDependencies: - rollup: 4.45.1 - vite: 7.0.5(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3) + rollup: 4.48.1 + vite: 7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1) - rollup@4.45.1: + rollup@4.48.1: dependencies: '@types/estree': 1.0.8 optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.45.1 - '@rollup/rollup-android-arm64': 4.45.1 - '@rollup/rollup-darwin-arm64': 4.45.1 - '@rollup/rollup-darwin-x64': 4.45.1 - '@rollup/rollup-freebsd-arm64': 4.45.1 - '@rollup/rollup-freebsd-x64': 4.45.1 - '@rollup/rollup-linux-arm-gnueabihf': 4.45.1 - '@rollup/rollup-linux-arm-musleabihf': 4.45.1 - '@rollup/rollup-linux-arm64-gnu': 4.45.1 - '@rollup/rollup-linux-arm64-musl': 4.45.1 - '@rollup/rollup-linux-loongarch64-gnu': 4.45.1 - '@rollup/rollup-linux-powerpc64le-gnu': 4.45.1 - '@rollup/rollup-linux-riscv64-gnu': 4.45.1 - '@rollup/rollup-linux-riscv64-musl': 4.45.1 - '@rollup/rollup-linux-s390x-gnu': 4.45.1 - '@rollup/rollup-linux-x64-gnu': 4.45.1 - '@rollup/rollup-linux-x64-musl': 4.45.1 - '@rollup/rollup-win32-arm64-msvc': 4.45.1 - '@rollup/rollup-win32-ia32-msvc': 4.45.1 - '@rollup/rollup-win32-x64-msvc': 4.45.1 + '@rollup/rollup-android-arm-eabi': 4.48.1 + '@rollup/rollup-android-arm64': 4.48.1 + '@rollup/rollup-darwin-arm64': 4.48.1 + '@rollup/rollup-darwin-x64': 4.48.1 + '@rollup/rollup-freebsd-arm64': 4.48.1 + '@rollup/rollup-freebsd-x64': 4.48.1 + '@rollup/rollup-linux-arm-gnueabihf': 4.48.1 + '@rollup/rollup-linux-arm-musleabihf': 4.48.1 + '@rollup/rollup-linux-arm64-gnu': 4.48.1 + '@rollup/rollup-linux-arm64-musl': 4.48.1 + '@rollup/rollup-linux-loongarch64-gnu': 4.48.1 + '@rollup/rollup-linux-ppc64-gnu': 4.48.1 + '@rollup/rollup-linux-riscv64-gnu': 4.48.1 + '@rollup/rollup-linux-riscv64-musl': 4.48.1 + '@rollup/rollup-linux-s390x-gnu': 4.48.1 + '@rollup/rollup-linux-x64-gnu': 4.48.1 + '@rollup/rollup-linux-x64-musl': 4.48.1 + '@rollup/rollup-win32-arm64-msvc': 4.48.1 + '@rollup/rollup-win32-ia32-msvc': 4.48.1 + '@rollup/rollup-win32-x64-msvc': 4.48.1 fsevents: 2.3.3 + run-applescript@7.0.0: {} + run-parallel@1.2.0: dependencies: queue-microtask: 1.2.3 @@ -6268,38 +10893,113 @@ snapshots: dependencies: commander: 10.0.1 + scheduler@0.26.0: {} + semver@5.7.2: {} semver@6.3.1: {} semver@7.7.2: {} + send@0.19.0: + dependencies: + debug: 2.6.9 + depd: 2.0.0 + destroy: 1.2.0 + encodeurl: 1.0.2 + escape-html: 1.0.3 + etag: 1.8.1 + fresh: 0.5.2 + http-errors: 2.0.0 + mime: 1.6.0 + ms: 2.1.3 + on-finished: 2.4.1 + range-parser: 1.2.1 + statuses: 2.0.1 + transitivePeerDependencies: + - supports-color + + seq-queue@0.0.5: {} + + serialize-error@2.1.0: {} + serialize-javascript@6.0.2: dependencies: randombytes: 2.1.0 serialize-query-params@2.0.2: {} + serve-static@1.16.2: + dependencies: + encodeurl: 2.0.0 + escape-html: 1.0.3 + parseurl: 1.3.3 + send: 0.19.0 + transitivePeerDependencies: + - supports-color + set-getter@0.1.1: dependencies: to-object-path: 0.3.0 + setprototypeof@1.2.0: {} + shallow-clone@3.0.1: dependencies: kind-of: 6.0.3 + sharp@0.33.5: + dependencies: + color: 4.2.3 + detect-libc: 2.0.4 + semver: 7.7.2 + optionalDependencies: + '@img/sharp-darwin-arm64': 0.33.5 + '@img/sharp-darwin-x64': 0.33.5 + '@img/sharp-libvips-darwin-arm64': 1.0.4 + '@img/sharp-libvips-darwin-x64': 1.0.4 + '@img/sharp-libvips-linux-arm': 1.0.5 + '@img/sharp-libvips-linux-arm64': 1.0.4 + '@img/sharp-libvips-linux-s390x': 1.0.4 + '@img/sharp-libvips-linux-x64': 1.0.4 + '@img/sharp-libvips-linuxmusl-arm64': 1.0.4 + '@img/sharp-libvips-linuxmusl-x64': 1.0.4 + '@img/sharp-linux-arm': 0.33.5 + '@img/sharp-linux-arm64': 0.33.5 + '@img/sharp-linux-s390x': 0.33.5 + '@img/sharp-linux-x64': 0.33.5 + '@img/sharp-linuxmusl-arm64': 0.33.5 + '@img/sharp-linuxmusl-x64': 0.33.5 + '@img/sharp-wasm32': 0.33.5 + '@img/sharp-win32-ia32': 0.33.5 + '@img/sharp-win32-x64': 0.33.5 + shebang-command@2.0.0: dependencies: shebang-regex: 3.0.0 shebang-regex@3.0.0: {} + shell-quote@1.8.3: {} + siginfo@2.0.0: {} signal-exit@3.0.7: {} signal-exit@4.1.0: {} + simple-concat@1.0.1: {} + + simple-get@4.0.1: + dependencies: + decompress-response: 6.0.0 + once: 1.4.0 + simple-concat: 1.0.1 + + simple-swizzle@0.2.2: + dependencies: + is-arrayish: 0.3.2 + sirv@3.0.1: dependencies: '@polka/url': 1.0.0-next.29 @@ -6319,23 +11019,62 @@ snapshots: buffer-from: 1.1.2 source-map: 0.6.1 + source-map@0.5.7: {} + source-map@0.6.1: {} - source-map@0.7.4: {} + source-map@0.7.6: {} spawndamnit@3.0.1: dependencies: cross-spawn: 7.0.6 signal-exit: 4.1.0 + split-ca@1.0.1: {} + + split2@4.2.0: {} + sprintf-js@1.0.3: {} + sprintf-js@1.1.3: {} + + sqlstring@2.3.3: {} + + ssh-remote-port-forward@1.0.4: + dependencies: + '@types/ssh2': 0.5.52 + ssh2: 1.17.0 + + ssh2@1.17.0: + dependencies: + asn1: 0.2.6 + bcrypt-pbkdf: 1.0.2 + optionalDependencies: + cpu-features: 0.0.10 + nan: 2.23.0 + stable-hash-x@0.2.0: {} + stack-utils@2.0.6: + dependencies: + escape-string-regexp: 2.0.0 + stackback@0.0.2: {} + stackframe@1.3.4: {} + + stacktrace-parser@0.1.11: + dependencies: + type-fest: 0.7.1 + + statuses@1.5.0: {} + + statuses@2.0.1: {} + std-env@3.9.0: {} + stoppable@1.1.0: {} + stream-chain@2.2.5: {} stream-chain@3.4.0: {} @@ -6348,6 +11087,13 @@ snapshots: dependencies: any-promise: 1.3.0 + streamx@2.22.1: + dependencies: + fast-fifo: 1.3.2 + text-decoder: 1.2.3 + optionalDependencies: + bare-events: 2.6.1 + string-width@4.2.3: dependencies: emoji-regex: 8.0.0 @@ -6380,7 +11126,7 @@ snapshots: strip-ansi@7.1.0: dependencies: - ansi-regex: 6.1.0 + ansi-regex: 6.2.0 strip-bom-string@1.0.0: {} @@ -6402,13 +11148,50 @@ snapshots: superstruct@2.0.2: {} + supports-color@10.2.0: {} + supports-color@7.2.0: dependencies: has-flag: 4.0.0 + supports-color@8.1.1: + dependencies: + has-flag: 4.0.0 + supports-preserve-symlinks-flag@1.0.0: {} - tapable@2.2.2: {} + tapable@2.2.3: {} + + tar-fs@2.1.3: + dependencies: + chownr: 1.1.4 + mkdirp-classic: 0.5.3 + pump: 3.0.3 + tar-stream: 2.2.0 + + tar-fs@3.1.0: + dependencies: + pump: 3.0.3 + tar-stream: 3.1.7 + optionalDependencies: + bare-fs: 4.2.1 + bare-path: 3.0.0 + transitivePeerDependencies: + - bare-buffer + + tar-stream@2.2.0: + dependencies: + bl: 4.1.0 + end-of-stream: 1.4.5 + fs-constants: 1.0.0 + inherits: 2.0.4 + readable-stream: 3.6.2 + + tar-stream@3.1.7: + dependencies: + b4a: 1.6.7 + fast-fifo: 1.3.2 + streamx: 2.22.1 tar@7.4.3: dependencies: @@ -6419,21 +11202,69 @@ snapshots: mkdirp: 3.0.1 yallist: 5.0.0 + tedious@18.6.1: + dependencies: + '@azure/core-auth': 1.10.0 + '@azure/identity': 4.11.1 + '@azure/keyvault-keys': 4.10.0 + '@js-joda/core': 5.6.5 + '@types/node': 24.3.0 + bl: 6.1.2 + iconv-lite: 0.6.3 + js-md4: 0.3.2 + native-duplexpair: 1.0.0 + sprintf-js: 1.1.3 + transitivePeerDependencies: + - supports-color + term-size@2.2.1: {} terser@5.43.1: dependencies: - '@jridgewell/source-map': 0.3.10 + '@jridgewell/source-map': 0.3.11 acorn: 8.15.0 commander: 2.20.3 source-map-support: 0.5.21 + test-exclude@6.0.0: + dependencies: + '@istanbuljs/schema': 0.1.3 + glob: 7.2.3 + minimatch: 3.1.2 + test-exclude@7.0.1: dependencies: '@istanbuljs/schema': 0.1.3 glob: 10.4.5 minimatch: 9.0.5 + testcontainers@11.5.1: + dependencies: + '@balena/dockerignore': 1.0.2 + '@types/dockerode': 3.3.43 + archiver: 7.0.1 + async-lock: 1.4.1 + byline: 5.0.0 + debug: 4.4.1 + docker-compose: 1.2.0 + dockerode: 4.0.7 + get-port: 7.1.0 + proper-lockfile: 4.1.2 + properties-reader: 2.3.0 + ssh-remote-port-forward: 1.0.4 + tar-fs: 3.1.0 + tmp: 0.2.5 + undici: 7.15.0 + transitivePeerDependencies: + - bare-buffer + - supports-color + + text-decoder@1.2.3: + dependencies: + b4a: 1.6.7 + + throat@5.0.0: {} + through2@2.0.5: dependencies: readable-stream: 2.3.8 @@ -6443,13 +11274,13 @@ snapshots: tinybench@2.9.0: {} - tinybench@4.0.1: {} + tinybench@5.0.1: {} tinyexec@0.3.2: {} tinyglobby@0.2.14: dependencies: - fdir: 6.4.6(picomatch@4.0.3) + fdir: 6.5.0(picomatch@4.0.3) picomatch: 4.0.3 tinypool@1.1.1: {} @@ -6458,11 +11289,9 @@ snapshots: tinyspy@4.0.3: {} - tmp@0.0.33: - dependencies: - os-tmpdir: 1.0.2 + tmp@0.2.5: {} - tmp@0.2.3: {} + tmpl@1.0.5: {} to-object-path@0.3.0: dependencies: @@ -6472,13 +11301,15 @@ snapshots: dependencies: is-number: 7.0.0 + toidentifier@1.0.1: {} + totalist@3.0.1: {} tr46@0.0.3: {} - ts-api-utils@2.1.0(typescript@5.8.3): + ts-api-utils@2.1.0(typescript@5.9.2): dependencies: - typescript: 5.8.3 + typescript: 5.9.2 ts-graphviz@2.1.6: dependencies: @@ -6496,6 +11327,10 @@ snapshots: semver: 7.7.2 strip-ansi: 6.0.1 + tsconfck@3.1.6(typescript@5.9.2): + optionalDependencies: + typescript: 5.9.2 + tsconfig-paths@4.2.0: dependencies: json5: 2.2.3 @@ -6506,55 +11341,80 @@ snapshots: tslib@2.8.1: {} - tstyche@4.3.0(typescript@5.8.3): + tstyche@4.3.0(typescript@5.9.2): optionalDependencies: - typescript: 5.8.3 + typescript: 5.9.2 - tsutils@3.21.0(typescript@5.8.3): + tsutils@3.21.0(typescript@5.9.2): dependencies: tslib: 1.14.1 - typescript: 5.8.3 + typescript: 5.9.2 - tsx@4.20.3: + tsx@4.20.5: dependencies: - esbuild: 0.25.8 + esbuild: 0.25.9 get-tsconfig: 4.10.1 optionalDependencies: fsevents: 2.3.3 + tunnel-agent@0.6.0: + dependencies: + safe-buffer: 5.2.1 + + tweetnacl@0.14.5: {} + type-check@0.4.0: dependencies: prelude-ls: 1.2.1 + type-detect@4.0.8: {} + + type-fest@0.7.1: {} + typedarray@0.0.6: {} - typescript-eslint@8.38.0(eslint@9.31.0)(typescript@5.8.3): + typescript-eslint@8.41.0(eslint@9.34.0)(typescript@5.9.2): dependencies: - '@typescript-eslint/eslint-plugin': 8.38.0(@typescript-eslint/parser@8.38.0(eslint@9.31.0)(typescript@5.8.3))(eslint@9.31.0)(typescript@5.8.3) - '@typescript-eslint/parser': 8.38.0(eslint@9.31.0)(typescript@5.8.3) - '@typescript-eslint/typescript-estree': 8.38.0(typescript@5.8.3) - '@typescript-eslint/utils': 8.38.0(eslint@9.31.0)(typescript@5.8.3) - eslint: 9.31.0 - typescript: 5.8.3 + '@typescript-eslint/eslint-plugin': 8.41.0(@typescript-eslint/parser@8.41.0(eslint@9.34.0)(typescript@5.9.2))(eslint@9.34.0)(typescript@5.9.2) + '@typescript-eslint/parser': 8.41.0(eslint@9.34.0)(typescript@5.9.2) + '@typescript-eslint/typescript-estree': 8.41.0(typescript@5.9.2) + '@typescript-eslint/utils': 8.41.0(eslint@9.34.0)(typescript@5.9.2) + eslint: 9.34.0 + typescript: 5.9.2 transitivePeerDependencies: - supports-color - typescript@5.8.3: {} + typescript@5.9.2: {} - undici-types@7.8.0: {} + undici-types@5.26.5: {} - undici@7.12.0: {} + undici-types@7.10.0: {} + + undici@7.15.0: {} + + unicode-canonical-property-names-ecmascript@2.0.1: {} + + unicode-match-property-ecmascript@2.0.0: + dependencies: + unicode-canonical-property-names-ecmascript: 2.0.1 + unicode-property-aliases-ecmascript: 2.1.0 + + unicode-match-property-value-ecmascript@2.2.0: {} + + unicode-property-aliases-ecmascript@2.1.0: {} universalify@0.1.2: {} - unplugin-utils@0.2.4: + unpipe@1.0.0: {} + + unplugin-utils@0.2.5: dependencies: pathe: 2.0.3 picomatch: 4.0.3 unrs-resolver@1.11.1: dependencies: - napi-postinstall: 0.3.2 + napi-postinstall: 0.3.3 optionalDependencies: '@unrs/resolver-binding-android-arm-eabi': 1.11.1 '@unrs/resolver-binding-android-arm64': 1.11.1 @@ -6576,9 +11436,9 @@ snapshots: '@unrs/resolver-binding-win32-ia32-msvc': 1.11.1 '@unrs/resolver-binding-win32-x64-msvc': 1.11.1 - update-browserslist-db@1.1.3(browserslist@4.25.1): + update-browserslist-db@1.1.3(browserslist@4.25.3): dependencies: - browserslist: 4.25.1 + browserslist: 4.25.3 escalade: 3.2.0 picocolors: 1.1.1 @@ -6588,17 +11448,25 @@ snapshots: util-deprecate@1.0.2: {} - valibot@1.1.0(typescript@5.8.3): - optionalDependencies: - typescript: 5.8.3 + utils-merge@1.0.1: {} - vite-node@3.2.4(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3): + uuid@10.0.0: {} + + uuid@11.1.0: {} + + uuid@8.3.2: {} + + valibot@1.1.0(typescript@5.9.2): + optionalDependencies: + typescript: 5.9.2 + + vite-node@3.2.4(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1): dependencies: cac: 6.7.14 debug: 4.4.1 es-module-lexer: 1.7.0 pathe: 2.0.3 - vite: 7.0.5(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3) + vite: 7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1) transitivePeerDependencies: - '@types/node' - jiti @@ -6613,40 +11481,52 @@ snapshots: - tsx - yaml - vite@7.0.5(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3): + vite-tsconfig-paths@5.1.4(typescript@5.9.2)(vite@7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1)): dependencies: - esbuild: 0.25.8 - fdir: 6.4.6(picomatch@4.0.3) + debug: 4.4.1 + globrex: 0.1.2 + tsconfck: 3.1.6(typescript@5.9.2) + optionalDependencies: + vite: 7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1) + transitivePeerDependencies: + - supports-color + - typescript + + vite@7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1): + dependencies: + esbuild: 0.25.9 + fdir: 6.5.0(picomatch@4.0.3) picomatch: 4.0.3 postcss: 8.5.6 - rollup: 4.45.1 + rollup: 4.48.1 tinyglobby: 0.2.14 optionalDependencies: - '@types/node': 24.1.0 + '@types/node': 24.3.0 fsevents: 2.3.3 terser: 5.43.1 - tsx: 4.20.3 + tsx: 4.20.5 + yaml: 2.8.1 vitest-websocket-mock@0.5.0(vitest@3.2.4): dependencies: '@vitest/utils': 3.2.4 mock-socket: 9.3.1 - vitest: 3.2.4(@edge-runtime/vm@5.0.0)(@types/node@24.1.0)(@vitest/browser@3.2.4)(terser@5.43.1)(tsx@4.20.3) + vitest: 3.2.4(@edge-runtime/vm@5.0.0)(@types/node@24.3.0)(@vitest/browser@3.2.4)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1) - vitest@3.2.4(@edge-runtime/vm@5.0.0)(@types/node@24.1.0)(@vitest/browser@3.2.4)(terser@5.43.1)(tsx@4.20.3): + vitest@3.2.4(@edge-runtime/vm@5.0.0)(@types/node@24.3.0)(@vitest/browser@3.2.4)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1): dependencies: '@types/chai': 5.2.2 '@vitest/expect': 3.2.4 - '@vitest/mocker': 3.2.4(vite@7.0.5(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3)) + '@vitest/mocker': 3.2.4(vite@7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1)) '@vitest/pretty-format': 3.2.4 '@vitest/runner': 3.2.4 '@vitest/snapshot': 3.2.4 '@vitest/spy': 3.2.4 '@vitest/utils': 3.2.4 - chai: 5.2.1 + chai: 5.3.3 debug: 4.4.1 expect-type: 1.2.2 - magic-string: 0.30.17 + magic-string: 0.30.18 pathe: 2.0.3 picomatch: 4.0.3 std-env: 3.9.0 @@ -6655,13 +11535,13 @@ snapshots: tinyglobby: 0.2.14 tinypool: 1.1.1 tinyrainbow: 2.0.0 - vite: 7.0.5(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3) - vite-node: 3.2.4(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3) + vite: 7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1) + vite-node: 3.2.4(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1) why-is-node-running: 2.3.0 optionalDependencies: '@edge-runtime/vm': 5.0.0 - '@types/node': 24.1.0 - '@vitest/browser': 3.2.4(playwright@1.54.1)(vite@7.0.5(@types/node@24.1.0)(terser@5.43.1)(tsx@4.20.3))(vitest@3.2.4) + '@types/node': 24.3.0 + '@vitest/browser': 3.2.4(playwright@1.55.0)(vite@7.1.3(@types/node@24.3.0)(terser@5.43.1)(tsx@4.20.5)(yaml@2.8.1))(vitest@3.2.4) transitivePeerDependencies: - jiti - less @@ -6676,14 +11556,24 @@ snapshots: - tsx - yaml + vlq@1.0.1: {} + walkdir@0.4.1: {} + walker@1.0.8: + dependencies: + makeerror: 1.0.12 + wcwidth@1.0.1: dependencies: defaults: 1.0.4 + web-streams-polyfill@3.3.3: {} + webidl-conversions@3.0.1: {} + whatwg-fetch@3.6.20: {} + whatwg-url@5.0.0: dependencies: tr46: 0.0.3 @@ -6704,6 +11594,14 @@ snapshots: word-wrap@1.2.5: {} + workerd@1.20250823.0: + optionalDependencies: + '@cloudflare/workerd-darwin-64': 1.20250823.0 + '@cloudflare/workerd-darwin-arm64': 1.20250823.0 + '@cloudflare/workerd-linux-64': 1.20250823.0 + '@cloudflare/workerd-linux-arm64': 1.20250823.0 + '@cloudflare/workerd-windows-64': 1.20250823.0 + wrap-ansi@7.0.0: dependencies: ansi-styles: 4.3.0 @@ -6718,13 +11616,30 @@ snapshots: wrappy@1.0.2: {} + write-file-atomic@4.0.2: + dependencies: + imurmurhash: 0.1.4 + signal-exit: 3.0.7 + write-file-atomic@5.0.1: dependencies: imurmurhash: 0.1.4 signal-exit: 4.1.0 + ws@6.2.3: + dependencies: + async-limiter: 1.0.1 + + ws@7.5.10: {} + + ws@8.18.0: {} + ws@8.18.3: {} + wsl-utils@0.1.0: + dependencies: + is-wsl: 3.1.0 + xtend@4.0.2: {} y18n@5.0.8: {} @@ -6733,6 +11648,8 @@ snapshots: yallist@5.0.0: {} + yaml@2.8.1: {} + yargs-parser@21.1.1: {} yargs@17.7.2: @@ -6747,4 +11664,25 @@ snapshots: yocto-queue@0.1.0: {} - zod@4.0.7: {} + youch-core@0.3.3: + dependencies: + '@poppinss/exception': 1.2.2 + error-stack-parser-es: 1.0.5 + + youch@4.1.0-beta.10: + dependencies: + '@poppinss/colors': 4.1.5 + '@poppinss/dumper': 0.6.4 + '@speed-highlight/core': 1.2.7 + cookie: 1.0.2 + youch-core: 0.3.3 + + zip-stream@6.0.1: + dependencies: + archiver-utils: 5.0.2 + compress-commons: 6.0.2 + readable-stream: 4.7.0 + + zod@3.22.3: {} + + zod@4.1.3: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 2e86197954..1feea3c9d8 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,3 +1,4 @@ packages: - scratchpad - packages/* + - packages/sql/* diff --git a/scratchpad/package.json b/scratchpad/package.json index 98145851c6..e17da38574 100644 --- a/scratchpad/package.json +++ b/scratchpad/package.json @@ -6,6 +6,17 @@ "dependencies": { "effect": "workspace:*", "@effect/platform-bun": "workspace:*", - "@effect/platform-node": "workspace:*" + "@effect/platform-node": "workspace:*", + "@effect/sql-clickhouse": "workspace:*", + "@effect/sql-d1": "workspace:*", + "@effect/sql-libsql": "workspace:*", + "@effect/sql-mysql2": "workspace:*", + "@effect/sql-mssql": "workspace:*", + "@effect/sql-pg": "workspace:*", + "@effect/sql-sqlite-bun": "workspace:*", + "@effect/sql-sqlite-do": "workspace:*", + "@effect/sql-sqlite-node": "workspace:*", + "@effect/sql-sqlite-react-native": "workspace:*", + "@effect/sql-sqlite-wasm": "workspace:*" } } diff --git a/tsconfig.build.json b/tsconfig.build.json index 09a4cafbf9..15dd68ce58 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -7,6 +7,17 @@ { "path": "packages/platform-bun/tsconfig.build.json" }, { "path": "packages/platform-node/tsconfig.build.json" }, { "path": "packages/platform-node-shared/tsconfig.build.json" }, + { "path": "packages/sql/clickhouse/tsconfig.build.json" }, + { "path": "packages/sql/d1/tsconfig.build.json" }, + { "path": "packages/sql/libsql/tsconfig.build.json" }, + { "path": "packages/sql/mysql2/tsconfig.build.json" }, + { "path": "packages/sql/mssql/tsconfig.build.json" }, + { "path": "packages/sql/pg/tsconfig.build.json" }, + { "path": "packages/sql/sqlite-bun/tsconfig.build.json" }, + { "path": "packages/sql/sqlite-do/tsconfig.build.json" }, + { "path": "packages/sql/sqlite-node/tsconfig.build.json" }, + { "path": "packages/sql/sqlite-react-native/tsconfig.build.json" }, + { "path": "packages/sql/sqlite-wasm/tsconfig.build.json" }, { "path": "packages/vitest/tsconfig.build.json" } ] } diff --git a/tsconfig.json b/tsconfig.json index bc707ca522..49beadfc92 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,6 +7,17 @@ { "path": "packages/platform-bun" }, { "path": "packages/platform-node" }, { "path": "packages/platform-node-shared" }, + { "path": "packages/sql/clickhouse" }, + { "path": "packages/sql/d1" }, + { "path": "packages/sql/libsql" }, + { "path": "packages/sql/mysql2" }, + { "path": "packages/sql/mssql" }, + { "path": "packages/sql/pg" }, + { "path": "packages/sql/sqlite-bun" }, + { "path": "packages/sql/sqlite-do" }, + { "path": "packages/sql/sqlite-node" }, + { "path": "packages/sql/sqlite-react-native" }, + { "path": "packages/sql/sqlite-wasm" }, { "path": "packages/vitest" } ] } diff --git a/vitest.config.ts b/vitest.config.ts index 7677399f99..e4d7c18753 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -7,11 +7,14 @@ export default defineConfig({ test: { projects: [ "packages/*/vitest.config.ts", + "packages/sql/*/vitest.config.ts", ...(isDeno ? [ "!packages/platform-bun", "!packages/platform-node", - "!packages/platform-node-shared" + "!packages/platform-node-shared", + "!packages/sql/d1", + "!packages/sql/sqlite-node" ] : []), ...(isBun ? diff --git a/vitest.shared.ts b/vitest.shared.ts index fdab5c7a36..9e993d1c5d 100644 --- a/vitest.shared.ts +++ b/vitest.shared.ts @@ -1,7 +1,9 @@ import * as path from "node:path" +import viteTsconfigPaths from "vite-tsconfig-paths" import type { ViteUserConfig } from "vitest/config" const config: ViteUserConfig = { + plugins: [viteTsconfigPaths()], esbuild: { target: "es2020" },