alink-cli 0.7.2 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SqlClient-DcM69ZvI.mjs","names":["TypeId","effect.contextWith","effect.updateContext","Context.merge","MutableHashMap.make","Duration.fromInputUnsafe","effect.succeed","make","Duration.infinity","core.withFiber","MutableHashMap.get","Option.isSome","effect.exitHasInterrupts","Duration.isFinite","effect.ClockRef","Duration.toMillis","Duration.isZero","effect.forkUnsafe","effect.onExit","effect.fiberJoin","effect.void","effect.fiberInterrupt","MutableHashMap.size","effect.asSome","effect.succeedNone","Option.isNone","core.exitSucceed","effect.sync","Iterable.filterMap","Result.succeed","Result.failVoid","Context.Service","make","Effect.contextWith","Effect.void","Effect.tap","Effect.gen","Effect.context","Context.get","Scope.Scope","Queue.make","Effect.runForkWith","Fiber.runIn","Scope.addFinalizer","Effect.sync","Effect.map","Stream.fromQueue","Stream.unwrap","Effect.suspend","Effect.provideService","Effect.onExit","Hash.hash","make","Effect.useSpan","Effect.scoped","Effect.flatMap","Stream.unwrap","Effect.makeSpanScoped","Effect.map","internalEffect.makeSpanUnsafe","Effect.onExit","internalEffect.endSpan","Effect.withFiber","Effect.flatMap","Effect.serviceOption","Option.match","Effect.succeed","Scope.make","Effect.map","Scope.provide","Statement.make","Stream.fromQueue","Stream.unwrap","Effect.uninterruptibleMask","Effect.useSpan","Effect.withFiber","Context.getOption","Effect.provideContext","Context.add","Tracer.ParentSpan","Effect.exit","Exit.isSuccess","Effect.orDie","Effect.void","Effect.ensuring","Scope.close","Context.Service"],"sources":["../../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=a18f963109656ddbeb2a99ca45f942ecf54830986259eb01ce6a970421c9c6a9/node_modules/effect/dist/Cache.js","../../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=a18f963109656ddbeb2a99ca45f942ecf54830986259eb01ce6a970421c9c6a9/node_modules/effect/dist/unstable/reactivity/Reactivity.js","../../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=a18f963109656ddbeb2a99ca45f942ecf54830986259eb01ce6a970421c9c6a9/node_modules/effect/dist/unstable/sql/Statement.js","../../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=a18f963109656ddbeb2a99ca45f942ecf54830986259eb01ce6a970421c9c6a9/node_modules/effect/dist/unstable/sql/SqlClient.js"],"sourcesContent":["/**\n * Caches values loaded by an Effect lookup function.\n *\n * A cache stores successful and failed lookup results, shares an in-progress\n * lookup when multiple callers request the same missing key, and limits entries\n * by capacity and optional time-to-live rules. This module includes helpers for\n * reading, setting, refreshing, invalidating, and inspecting cache contents.\n *\n * @since 4.0.0\n */\nimport * as Context from \"./Context.js\";\nimport * as Duration from \"./Duration.js\";\nimport { dual } from \"./Function.js\";\nimport * as core from \"./internal/core.js\";\nimport { PipeInspectableProto } from \"./internal/core.js\";\nimport * as effect from \"./internal/effect.js\";\nimport * as Iterable from \"./Iterable.js\";\nimport * as MutableHashMap from \"./MutableHashMap.js\";\nimport * as Option from \"./Option.js\";\nimport * as Result from \"./Result.js\";\nconst TypeId = \"~effect/Cache\";\n/**\n * Creates a cache with dynamic time-to-live based on the result and key.\n *\n * **When to use**\n *\n * Use when you need different cache entry lifetimes based on the lookup result\n * or key characteristics.\n *\n * **Details**\n *\n * The timeToLive function receives both the exit result and the key, allowing\n * for flexible TTL policies based on success/failure state and key characteristics.\n *\n * **Example** (Configuring dynamic time to live)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect, Exit } from \"effect\"\n *\n * // Cache with TTL based on computed value\n * const program = Effect.gen(function*() {\n * const cache = yield* Cache.makeWith(\n * (id: number) => Effect.succeed({ id, active: id % 2 === 0 }),\n * {\n * capacity: 1000,\n * timeToLive(exit) {\n * if (Exit.isSuccess(exit)) {\n * const user = exit.value\n * return user.active ? \"1 hour\" : \"5 minutes\"\n * }\n * return \"30 seconds\"\n * }\n * }\n * )\n *\n * return cache.capacity\n * })\n *\n * const actual = await Effect.runPromise(program)\n * actual // => 1000\n * ```\n *\n * @see {@link make} for a simpler cache constructor with a fixed time-to-live for all entries\n * @category constructors\n * @since 2.0.0\n */\nexport const makeWith = (lookup, options) => effect.contextWith(context => {\n const self = Object.create(Proto);\n self.lookup = key => effect.updateContext(lookup(key), input => Context.merge(context, input));\n self.map = MutableHashMap.make();\n self.capacity = options.capacity;\n self.timeToLive = options.timeToLive ? (exit, key) => Duration.fromInputUnsafe(options.timeToLive(exit, key)) : defaultTimeToLive;\n return effect.succeed(self);\n});\n/**\n * Creates a cache with a fixed time-to-live for all entries.\n *\n * **Details**\n *\n * This is the basic cache constructor where all entries share the same TTL.\n * The lookup function will be called when a key is not found or has expired.\n *\n * **Example** (Creating a basic cache)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect } from \"effect\"\n *\n * // Basic cache with string keys\n * const program = Effect.gen(function*() {\n * const cache = yield* Cache.make<string, number>({\n * capacity: 100,\n * lookup: (key) => Effect.succeed(key.length)\n * })\n *\n * const result1 = yield* Cache.get(cache, \"hello\")\n * const result2 = yield* Cache.get(cache, \"world\")\n * return { result1, result2 }\n * })\n *\n * const actual = await Effect.runPromise(program)\n * actual // => { result1: 5, result2: 5 }\n * ```\n *\n * **Example** (Creating a cache with TTL)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const users = new Map([\n * [123, { name: \"Ada\", email: \"ada@example.com\" }],\n * [456, { name: \"Grace\", email: \"grace@example.com\" }]\n * ])\n *\n * const cache = yield* Cache.make<\n * number,\n * { name: string; email: string },\n * string\n * >({\n * capacity: 500,\n * lookup: (userId) =>\n * Effect.suspend(() => {\n * const user = users.get(userId)\n * return user === undefined\n * ? Effect.fail(`User ${userId} not found`)\n * : Effect.succeed(user)\n * }),\n * timeToLive: \"15 minutes\"\n * })\n *\n * const user1 = yield* Cache.get(cache, 123)\n * const user2 = yield* Cache.get(cache, 123)\n * return [user1, user2, user1 === user2] as const\n * })\n *\n * const actual = await Effect.runPromise(program)\n * actual // => [{ name: \"Ada\", email: \"ada@example.com\" }, { name: \"Ada\", email: \"ada@example.com\" }, true]\n * ```\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const make = options => makeWith(options.lookup, {\n ...options,\n timeToLive: options.timeToLive ? () => options.timeToLive : defaultTimeToLive\n});\nconst Proto = {\n ...PipeInspectableProto,\n [TypeId]: TypeId,\n toJSON() {\n return {\n _id: \"Cache\",\n capacity: this.capacity,\n map: this.map\n };\n }\n};\nconst defaultTimeToLive = (_, _key) => Duration.infinity;\n/**\n * Retrieves the value for a key, invoking the lookup function on a cache miss\n * or expired entry.\n *\n * **Details**\n *\n * Concurrent `get` calls for the same missing key share the same pending\n * lookup. The cache stores the lookup `Exit`, so failed lookups are cached and\n * will fail again until the entry expires, is invalidated, or is refreshed.\n *\n * **Example** (Getting cached values)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const cache = yield* Cache.make({\n * capacity: 10,\n * lookup: (key: string) => Effect.succeed(key.length)\n * })\n *\n * // Cache miss - triggers lookup function\n * const result1 = yield* Cache.get(cache, \"hello\")\n *\n * // Cache hit - returns cached value without lookup\n * const result2 = yield* Cache.get(cache, \"hello\")\n *\n * return { result1, result2 }\n * })\n *\n * const actual = await Effect.runPromise(program)\n * actual // => { result1: 5, result2: 5 }\n * ```\n *\n * **Example** (Handling lookup failures)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect, Exit } from \"effect\"\n *\n * // Error handling when lookup fails\n * const program = Effect.gen(function*() {\n * const cache = yield* Cache.make<string, number, string>({\n * capacity: 10,\n * lookup: (key: string) =>\n * key === \"error\"\n * ? Effect.fail(\"Lookup failed\")\n * : Effect.succeed(key.length)\n * })\n *\n * // Successful lookup\n * const success = yield* Cache.get(cache, \"hello\")\n *\n * // Failed lookup - returns error\n * const failure = yield* Effect.exit(Cache.get(cache, \"error\"))\n * return [success, failure] as const\n * })\n *\n * const actual = await Effect.runPromise(program)\n * actual // => [5, Exit.fail(\"Lookup failed\")]\n * ```\n *\n * **Example** (Sharing concurrent lookups)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect } from \"effect\"\n *\n * // Concurrent access - multiple gets of same key only invoke lookup once\n * const program = Effect.gen(function*() {\n * let lookupCount = 0\n * const cache = yield* Cache.make({\n * capacity: 10,\n * lookup: (key: string) =>\n * Effect.sync(() => {\n * lookupCount++\n * return key.length\n * })\n * })\n *\n * // Multiple concurrent gets\n * const results = yield* Effect.all([\n * Cache.get(cache, \"hello\"),\n * Cache.get(cache, \"hello\"),\n * Cache.get(cache, \"hello\")\n * ], { concurrency: \"unbounded\" })\n *\n * return { results, lookupCount }\n * })\n *\n * const actual = await Effect.runPromise(program)\n * actual // => { results: [5, 5, 5], lookupCount: 1 }\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const get = /*#__PURE__*/dual(2, (self, key) => core.withFiber(fiber => {\n const oentry = MutableHashMap.get(self.map, key);\n if (Option.isSome(oentry) && !hasExpired(oentry.value, fiber)) {\n // Move the entry to the end of the map to keep it fresh\n MutableHashMap.remove(self.map, key);\n MutableHashMap.set(self.map, key, oentry.value);\n return oentry.value.await();\n }\n const entry = new EntryImpl(fiber, self.lookup(key));\n entry.fiber.addObserver(exit => {\n if (effect.exitHasInterrupts(exit)) {\n const current = MutableHashMap.get(self.map, key);\n if (Option.isSome(current) && current.value === entry) {\n MutableHashMap.remove(self.map, key);\n }\n return;\n }\n const ttl = self.timeToLive(exit, key);\n if (Duration.isFinite(ttl)) {\n entry.expiresAt = fiber.getRef(effect.ClockRef).currentTimeMillisUnsafe() + Duration.toMillis(ttl);\n } else if (Duration.isZero(ttl)) {\n MutableHashMap.remove(self.map, key);\n }\n });\n MutableHashMap.set(self.map, key, entry);\n if (Number.isFinite(self.capacity)) {\n checkCapacity(self);\n }\n return entry.await();\n}));\nclass EntryImpl {\n expiresAt;\n awaiters;\n fiber;\n constructor(parent, valueEffect) {\n this.fiber = effect.forkUnsafe(parent, valueEffect, true, true);\n this.awaiters = 0;\n this.expiresAt = undefined;\n }\n await() {\n const exit = this.fiber.pollUnsafe();\n if (exit) return exit;\n this.awaiters++;\n return effect.onExit(effect.fiberJoin(this.fiber), () => {\n this.awaiters--;\n if (this.awaiters > 0 || this.fiber.pollUnsafe()) return effect.void;\n return effect.fiberInterrupt(this.fiber);\n });\n }\n}\nconst hasExpired = (entry, fiber) => {\n if (entry.expiresAt === undefined) {\n return false;\n }\n return fiber.getRef(effect.ClockRef).currentTimeMillisUnsafe() >= entry.expiresAt;\n};\nconst checkCapacity = self => {\n let diff = MutableHashMap.size(self.map) - self.capacity;\n if (diff <= 0) return;\n // MutableHashMap has insertion order, so we can remove the oldest entries\n for (const [key] of self.map) {\n MutableHashMap.remove(self.map, key);\n diff--;\n if (diff === 0) return;\n }\n};\n/**\n * Reads an existing cache entry without invoking the lookup function.\n *\n * **Details**\n *\n * Returns `Option.none()` when the key is missing or expired, and `Option.some`\n * when a cached lookup has succeeded. If the entry is still pending, waits for\n * it to complete. If the cached or pending lookup fails, this effect fails with\n * the same error.\n *\n * **Example** (Reading cached values without lookup)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect, Option } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const cache = yield* Cache.make({\n * capacity: 10,\n * lookup: (key: string) => Effect.succeed(key.length)\n * })\n *\n * // No value in cache yet - returns None without lookup\n * const empty = yield* Cache.getOption(cache, \"hello\")\n *\n * // Populate cache using get\n * yield* Cache.get(cache, \"hello\")\n *\n * // Now getOption returns the cached value\n * const cached = yield* Cache.getOption(cache, \"hello\")\n * return [empty, cached] as const\n * })\n *\n * const actual = await Effect.runPromise(program)\n * actual // => [Option.none(), Option.some(5)]\n * ```\n *\n * **Example** (Skipping expired entries)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect, Option } from \"effect\"\n * import { TestClock } from \"effect/testing\"\n *\n * // Expired entries return None\n * const program = Effect.gen(function*() {\n * const cache = yield* Cache.make({\n * capacity: 10,\n * lookup: (key: string) => Effect.succeed(key.length),\n * timeToLive: \"1 hour\"\n * })\n *\n * // Add value to cache\n * yield* Cache.get(cache, \"hello\")\n *\n * // Value exists before expiration\n * const beforeExpiry = yield* Cache.getOption(cache, \"hello\")\n *\n * // Simulate time passing\n * yield* TestClock.adjust(\"2 hours\")\n *\n * // Value expired - returns None\n * const afterExpiry = yield* Cache.getOption(cache, \"hello\")\n * return [beforeExpiry, afterExpiry] as const\n * })\n *\n * const actual = await Effect.runPromise(Effect.provide(program, TestClock.layer()))\n * actual // => [Option.some(5), Option.none()]\n * ```\n *\n * **Example** (Waiting for pending lookups)\n *\n * ```ts import.meta.vitest\n * import { Cache, Deferred, Effect, Fiber, Option } from \"effect\"\n *\n * // Waits for ongoing computation to complete\n * const program = Effect.gen(function*() {\n * const deferred = yield* Deferred.make<void>()\n * const cache = yield* Cache.make({\n * capacity: 10,\n * lookup: (_key: string) => Deferred.await(deferred).pipe(Effect.as(42))\n * })\n *\n * // Start lookup in background\n * const getFiber = yield* Effect.forkChild(Cache.get(cache, \"key\"))\n *\n * // getOption waits for ongoing computation\n * const optionFiber = yield* Effect.forkChild(Cache.getOption(cache, \"key\"))\n *\n * // Complete the computation\n * yield* Deferred.succeed(deferred, void 0)\n *\n * const result = yield* Fiber.join(optionFiber)\n * const value = yield* Fiber.join(getFiber)\n * return [result, value] as const\n * })\n *\n * const actual = await Effect.runPromise(program)\n * actual // => [Option.some(42), 42]\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const getOption = /*#__PURE__*/dual(2, (self, key) => core.withFiber(fiber => {\n const entry = getImpl(self, key, fiber);\n return entry ? effect.asSome(entry.await()) : effect.succeedNone;\n}));\nconst getImpl = (self, key, fiber, isRead = true) => {\n const oentry = MutableHashMap.get(self.map, key);\n if (Option.isNone(oentry)) {\n return undefined;\n } else if (hasExpired(oentry.value, fiber)) {\n MutableHashMap.remove(self.map, key);\n return undefined;\n } else if (isRead) {\n MutableHashMap.remove(self.map, key);\n MutableHashMap.set(self.map, key, oentry.value);\n }\n return oentry.value;\n};\n/**\n * Retrieves the value associated with the specified key from the cache, only if\n * it contains a resolved successful value.\n *\n * **Details**\n *\n * This checks only an existing non-expired entry. It returns `Option.some` when\n * the entry has already resolved successfully, and `Option.none` for missing,\n * expired, failed, or still-pending entries.\n *\n * @see {@link get} for triggering or awaiting the cache lookup\n * @see {@link getOption} for reading an existing entry as an optional effect\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const getSuccess = /*#__PURE__*/dual(2, (self, key) => core.withFiber(fiber => {\n const exit = getImpl(self, key, fiber)?.fiber.pollUnsafe();\n if (exit && effect.exitIsSuccess(exit)) {\n return effect.succeedSome(exit.value);\n }\n return effect.succeedNone;\n}));\n/**\n * Sets the value associated with the specified key in the cache. This will\n * overwrite any existing value for that key, skipping the lookup function.\n *\n * **Example** (Setting values directly)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const cache = yield* Cache.make({\n * capacity: 100,\n * lookup: (key: string) => Effect.succeed(key.length)\n * })\n *\n * // Set a value directly without invoking lookup\n * yield* Cache.set(cache, \"hello\", 42)\n * return yield* Cache.get(cache, \"hello\")\n * })\n *\n * const actual = await Effect.runPromise(program)\n * actual // => 42\n * ```\n *\n * **Example** (Overwriting cached values)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect } from \"effect\"\n *\n * // Overwriting existing cached values\n * const program = Effect.gen(function*() {\n * const cache = yield* Cache.make({\n * capacity: 100,\n * lookup: (key: string) => Effect.succeed(key.length)\n * })\n *\n * // First get populates via lookup\n * const original = yield* Cache.get(cache, \"test\") // 4\n *\n * // Set overwrites the cached value\n * yield* Cache.set(cache, \"test\", 999)\n * const updated = yield* Cache.get(cache, \"test\") // 999\n *\n * return { original, updated }\n * })\n *\n * const actual = await Effect.runPromise(program)\n * actual // => { original: 4, updated: 999 }\n * ```\n *\n * **Example** (Applying TTL to set values)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect } from \"effect\"\n * import { TestClock } from \"effect/testing\"\n *\n * // TTL behavior with set operations\n * const program = Effect.gen(function*() {\n * const cache = yield* Cache.make({\n * capacity: 100,\n * lookup: (key: string) => Effect.succeed(key.length),\n * timeToLive: \"1 hour\"\n * })\n *\n * // Set value with TTL applied\n * yield* Cache.set(cache, \"temporary\", 123)\n * const beforeExpiry = yield* Cache.has(cache, \"temporary\")\n *\n * // Advance time past TTL\n * yield* TestClock.adjust(\"2 hours\")\n * const afterExpiry = yield* Cache.has(cache, \"temporary\")\n * return [beforeExpiry, afterExpiry]\n * })\n *\n * const actual = await Effect.runPromise(Effect.provide(program, TestClock.layer()))\n * actual // => [true, false]\n * ```\n *\n * **Example** (Enforcing capacity when setting values)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect } from \"effect\"\n *\n * // Capacity enforcement with set operations\n * const program = Effect.gen(function*() {\n * const cache = yield* Cache.make({\n * capacity: 2,\n * lookup: (key: string) => Effect.succeed(key.length)\n * })\n *\n * // Fill cache to capacity\n * yield* Cache.set(cache, \"a\", 1)\n * yield* Cache.set(cache, \"b\", 2)\n * const sizeBeforeEviction = yield* Cache.size(cache)\n *\n * // Adding another entry evicts oldest\n * yield* Cache.set(cache, \"c\", 3)\n * const sizeAfterEviction = yield* Cache.size(cache)\n * const hasOldest = yield* Cache.has(cache, \"a\")\n * const hasNewest = yield* Cache.has(cache, \"c\")\n * return [sizeBeforeEviction, sizeAfterEviction, hasOldest, hasNewest]\n * })\n *\n * const actual = await Effect.runPromise(program)\n * actual // => [2, 2, false, true]\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const set = /*#__PURE__*/dual(3, (self, key, value) => core.withFiber(fiber => {\n const exit = core.exitSucceed(value);\n const entry = new EntryImpl(fiber, exit);\n const ttl = self.timeToLive(exit, key);\n if (Duration.isZero(ttl)) {\n MutableHashMap.remove(self.map, key);\n return effect.void;\n }\n entry.expiresAt = Duration.isFinite(ttl) ? fiber.getRef(effect.ClockRef).currentTimeMillisUnsafe() + Duration.toMillis(ttl) : undefined;\n MutableHashMap.set(self.map, key, entry);\n checkCapacity(self);\n return effect.void;\n}));\n/**\n * Checks whether the cache contains an entry for the specified key.\n *\n * **Details**\n *\n * This checks for an existing non-expired entry without invoking the cache\n * lookup function. Expired entries are treated as absent.\n *\n * **Example** (Checking for cached keys)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const cache = yield* Cache.make({\n * capacity: 100,\n * lookup: (key: string) => Effect.succeed(key.length)\n * })\n *\n * // Check non-existent key\n * const missing = yield* Cache.has(cache, \"missing\")\n *\n * // Add entry and check existence\n * yield* Cache.get(cache, \"hello\")\n * const present = yield* Cache.has(cache, \"hello\")\n * return [missing, present]\n * })\n *\n * const actual = await Effect.runPromise(program)\n * actual // => [false, true]\n * ```\n *\n * **Example** (Checking TTL expiration)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect } from \"effect\"\n * import { TestClock } from \"effect/testing\"\n *\n * // TTL expiration behavior\n * const program = Effect.gen(function*() {\n * const cache = yield* Cache.make({\n * capacity: 100,\n * lookup: (key: string) => Effect.succeed(key.length),\n * timeToLive: \"1 hour\"\n * })\n *\n * // Add entry with TTL\n * yield* Cache.get(cache, \"expires\")\n * const initial = yield* Cache.has(cache, \"expires\")\n *\n * // Still valid before expiration\n * yield* TestClock.adjust(\"30 minutes\")\n * const beforeExpiry = yield* Cache.has(cache, \"expires\")\n *\n * // Expired after TTL\n * yield* TestClock.adjust(\"31 minutes\")\n * const afterExpiry = yield* Cache.has(cache, \"expires\")\n * return [initial, beforeExpiry, afterExpiry]\n * })\n *\n * const actual = await Effect.runPromise(Effect.provide(program, TestClock.layer()))\n * actual // => [true, true, false]\n * ```\n *\n * **Example** (Checking multiple keys)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect } from \"effect\"\n *\n * // Checking multiple keys efficiently\n * const program = Effect.gen(function*() {\n * const cache = yield* Cache.make({\n * capacity: 100,\n * lookup: (key: string) => Effect.succeed(key.length)\n * })\n *\n * // Populate some entries\n * yield* Cache.set(cache, \"apple\", 5)\n * yield* Cache.set(cache, \"banana\", 6)\n *\n * // Check multiple keys\n * const keys = [\"apple\", \"banana\", \"cherry\", \"date\"]\n * const results: Array<string> = []\n * for (const key of keys) {\n * const exists = yield* Cache.has(cache, key)\n * results.push(`${key}: ${exists}`)\n * }\n * return results\n * })\n *\n * const actual = await Effect.runPromise(program)\n * actual // => [\"apple: true\", \"banana: true\", \"cherry: false\", \"date: false\"]\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const has = /*#__PURE__*/dual(2, (self, key) => core.withFiber(fiber => {\n const oentry = getImpl(self, key, fiber, false);\n return effect.succeed(oentry !== undefined);\n}));\n/**\n * Invalidates the entry associated with the specified key in the cache.\n *\n * **Example** (Invalidating cached entries)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const cache = yield* Cache.make({\n * capacity: 10,\n * lookup: (key: string) => Effect.succeed(key.length)\n * })\n *\n * // Add a value to the cache\n * yield* Cache.get(cache, \"hello\")\n * const beforeInvalidation = yield* Cache.has(cache, \"hello\")\n *\n * // Invalidate the entry\n * yield* Cache.invalidate(cache, \"hello\")\n * const afterInvalidation = yield* Cache.has(cache, \"hello\")\n *\n * // Invalidating non-existent keys doesn't error\n * yield* Cache.invalidate(cache, \"nonexistent\")\n *\n * // Get after invalidation will invoke lookup again\n * let lookupCount = 0\n * const cache2 = yield* Cache.make({\n * capacity: 10,\n * lookup: (key: string) =>\n * Effect.sync(() => {\n * lookupCount++\n * return key.length\n * })\n * })\n *\n * yield* Cache.get(cache2, \"test\") // lookupCount = 1\n * yield* Cache.invalidate(cache2, \"test\")\n * yield* Cache.get(cache2, \"test\") // lookupCount = 2 (lookup called again)\n * return { beforeInvalidation, afterInvalidation, lookupCount }\n * })\n *\n * const actual = await Effect.runPromise(program)\n * actual // => { beforeInvalidation: true, afterInvalidation: false, lookupCount: 2 }\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const invalidate = /*#__PURE__*/dual(2, (self, key) => effect.sync(() => {\n MutableHashMap.remove(self.map, key);\n}));\n/**\n * Invalidates the entry associated with the specified key in the cache when the\n * predicate returns true for the cached value.\n *\n * **Example** (Invalidating entries conditionally)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const cache = yield* Cache.make({\n * capacity: 10,\n * lookup: (key: string) => Effect.succeed(key.length)\n * })\n *\n * // Add values to the cache\n * yield* Cache.get(cache, \"hello\") // value = 5\n * yield* Cache.get(cache, \"hi\") // value = 2\n *\n * // Invalidate when value equals 5\n * const invalidated1 = yield* Cache.invalidateWhen(\n * cache,\n * \"hello\",\n * (value) => value === 5\n * )\n * const hasHello = yield* Cache.has(cache, \"hello\")\n *\n * // Don't invalidate when predicate doesn't match\n * const invalidated2 = yield* Cache.invalidateWhen(\n * cache,\n * \"hi\",\n * (value) => value === 5\n * )\n * const hasHi = yield* Cache.has(cache, \"hi\")\n *\n * // Returns false for non-existent keys\n * const invalidated3 = yield* Cache.invalidateWhen(\n * cache,\n * \"nonexistent\",\n * () => true\n * )\n *\n * // Returns false for failed cached values\n * const cacheWithErrors = yield* Cache.make<string, number, string>({\n * capacity: 10,\n * lookup: (key: string) =>\n * key === \"fail\" ? Effect.fail(\"error\") : Effect.succeed(key.length)\n * })\n *\n * yield* Effect.exit(Cache.get(cacheWithErrors, \"fail\"))\n * const invalidated4 = yield* Cache.invalidateWhen(\n * cacheWithErrors,\n * \"fail\",\n * () => true\n * )\n * return [invalidated1, hasHello, invalidated2, hasHi, invalidated3, invalidated4]\n * })\n *\n * const actual = await Effect.runPromise(program)\n * actual // => [true, false, false, true, false, false]\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const invalidateWhen = /*#__PURE__*/dual(3, (self, key, f) => core.withFiber(fiber => {\n const oentry = getImpl(self, key, fiber, false);\n if (oentry === undefined) {\n return effect.succeed(false);\n }\n return oentry.await().pipe(effect.map(value => {\n if (f(value)) {\n MutableHashMap.remove(self.map, key);\n return true;\n }\n return false;\n }), effect.catchCause(() => effect.succeed(false)));\n}));\n/**\n * Forces a refresh of the value associated with the specified key in the cache.\n *\n * **Details**\n *\n * It will always invoke the lookup function to construct a new value,\n * overwriting any existing value for that key.\n *\n * **Example** (Refreshing cached values)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect } from \"effect\"\n *\n * // Force refresh of existing cached values\n * const program = Effect.gen(function*() {\n * let counter = 0\n * const cache = yield* Cache.make({\n * capacity: 10,\n * lookup: (key: string) => Effect.sync(() => `${key}-${++counter}`)\n * })\n *\n * // Initial cache population\n * const value1 = yield* Cache.get(cache, \"user\")\n *\n * // Get from cache (no lookup)\n * const value2 = yield* Cache.get(cache, \"user\")\n *\n * // Force refresh - always calls lookup\n * const refreshed = yield* Cache.refresh(cache, \"user\")\n *\n * // Subsequent gets return refreshed value\n * const value3 = yield* Cache.get(cache, \"user\")\n * return [value1, value2, refreshed, value3, counter]\n * })\n *\n * const actual = await Effect.runPromise(program)\n * actual // => [\"user-1\", \"user-1\", \"user-2\", \"user-2\", 2]\n * ```\n *\n * **Example** (Resetting TTL on refresh)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect } from \"effect\"\n * import { TestClock } from \"effect/testing\"\n *\n * // Refresh resets TTL (Time To Live)\n * const program = Effect.gen(function*() {\n * const cache = yield* Cache.make({\n * capacity: 10,\n * lookup: (key: string) => Effect.succeed(key.length),\n * timeToLive: \"1 hour\"\n * })\n *\n * yield* Cache.get(cache, \"test\")\n * yield* TestClock.adjust(\"45 minutes\")\n *\n * // Entry would normally expire in 15 minutes\n * const beforeRefresh = yield* Cache.has(cache, \"test\")\n *\n * // Refresh resets the TTL to full 1 hour\n * yield* Cache.refresh(cache, \"test\")\n * yield* TestClock.adjust(\"30 minutes\")\n *\n * // Still valid because TTL was reset\n * const afterRefresh = yield* Cache.has(cache, \"test\")\n * return [beforeRefresh, afterRefresh]\n * })\n *\n * const actual = await Effect.runPromise(Effect.provide(program, TestClock.layer()))\n * actual // => [true, true]\n * ```\n *\n * **Example** (Refreshing missing keys)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect } from \"effect\"\n *\n * // Refresh non-existent keys\n * const program = Effect.gen(function*() {\n * const cache = yield* Cache.make({\n * capacity: 10,\n * lookup: (key: string) => Effect.succeed(`value-for-${key}`)\n * })\n *\n * // Refresh non-existent key creates new entry\n * const result = yield* Cache.refresh(cache, \"newKey\")\n *\n * // Verify it's now cached\n * const cached = yield* Cache.has(cache, \"newKey\")\n * return [result, cached]\n * })\n *\n * const actual = await Effect.runPromise(program)\n * actual // => [\"value-for-newKey\", true]\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const refresh = /*#__PURE__*/dual(2, (self, key) => core.withFiber(fiber => {\n const entry = new EntryImpl(fiber, self.lookup(key));\n const existing = getImpl(self, key, fiber, false) !== undefined;\n if (!existing) {\n MutableHashMap.set(self.map, key, entry);\n checkCapacity(self);\n }\n entry.fiber.addObserver(exit => {\n if (effect.exitHasInterrupts(exit)) {\n if (!existing) MutableHashMap.remove(self.map, key);\n return;\n }\n const ttl = self.timeToLive(exit, key);\n if (Duration.isZero(ttl)) {\n MutableHashMap.remove(self.map, key);\n return effect.void;\n }\n entry.expiresAt = Duration.isFinite(ttl) ? fiber.getRef(effect.ClockRef).currentTimeMillisUnsafe() + Duration.toMillis(ttl) : undefined;\n if (existing) {\n MutableHashMap.set(self.map, key, entry);\n }\n });\n return entry.await();\n}));\n/**\n * Invalidates all entries in the cache.\n *\n * **Example** (Invalidating all entries)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect } from \"effect\"\n *\n * // Clear all cached entries at once\n * const program = Effect.gen(function*() {\n * const cache = yield* Cache.make({\n * capacity: 10,\n * lookup: (key: string) => Effect.succeed(key.length)\n * })\n *\n * // Populate cache with multiple entries\n * yield* Cache.get(cache, \"apple\")\n * yield* Cache.get(cache, \"banana\")\n * yield* Cache.get(cache, \"cherry\")\n *\n * const sizeBeforeInvalidation = yield* Cache.size(cache)\n * const hasAppleBeforeInvalidation = yield* Cache.has(cache, \"apple\")\n *\n * // Clear all entries\n * yield* Cache.invalidateAll(cache)\n *\n * // Verify cache is empty\n * const sizeAfterInvalidation = yield* Cache.size(cache)\n * const hasAppleAfterInvalidation = yield* Cache.has(cache, \"apple\")\n * const hasBananaAfterInvalidation = yield* Cache.has(cache, \"banana\")\n * const hasCherryAfterInvalidation = yield* Cache.has(cache, \"cherry\")\n * return [\n * sizeBeforeInvalidation,\n * hasAppleBeforeInvalidation,\n * sizeAfterInvalidation,\n * hasAppleAfterInvalidation,\n * hasBananaAfterInvalidation,\n * hasCherryAfterInvalidation\n * ]\n * })\n *\n * const actual = await Effect.runPromise(program)\n * actual // => [3, true, 0, false, false, false]\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const invalidateAll = self => effect.sync(() => {\n MutableHashMap.clear(self.map);\n});\n/**\n * Retrieves the approximate number of entries in the cache.\n *\n * **Details**\n *\n * Note that expired entries are counted until they are accessed and removed.\n * The size reflects the current number of entries stored, not the number\n * of valid entries.\n *\n * **Example** (Reading cache size)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const cache = yield* Cache.make({\n * capacity: 10,\n * lookup: (key: string) => Effect.succeed(key.length)\n * })\n *\n * // Empty cache has size 0\n * const emptySize = yield* Cache.size(cache)\n *\n * // Add entries and check size\n * yield* Cache.get(cache, \"hello\")\n * yield* Cache.get(cache, \"world\")\n * const sizeAfterAdding = yield* Cache.size(cache)\n *\n * // Size decreases after invalidation\n * yield* Cache.invalidate(cache, \"hello\")\n * const sizeAfterInvalidation = yield* Cache.size(cache)\n * return [emptySize, sizeAfterAdding, sizeAfterInvalidation]\n * })\n *\n * const actual = await Effect.runPromise(program)\n * actual // => [0, 2, 1]\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const size = self => effect.sync(() => MutableHashMap.size(self.map));\n/**\n * Retrieves all active keys from the cache, automatically filtering out expired entries.\n *\n * **Example** (Reading active keys)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect } from \"effect\"\n *\n * // Basic key enumeration\n * const program = Effect.gen(function*() {\n * const cache = yield* Cache.make({\n * capacity: 10,\n * lookup: (key: string) => Effect.succeed(key.length)\n * })\n *\n * // Add some entries to the cache\n * yield* Cache.get(cache, \"hello\")\n * yield* Cache.get(cache, \"world\")\n * yield* Cache.get(cache, \"cache\")\n *\n * // Retrieve all active keys\n * const keys = yield* Cache.keys(cache)\n * return Array.from(keys).sort()\n * })\n *\n * const actual = await Effect.runPromise(program)\n * actual // => [\"cache\", \"hello\", \"world\"]\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const keys = self => core.withFiber(fiber => {\n const now = fiber.getRef(effect.ClockRef).currentTimeMillisUnsafe();\n return effect.succeed(Iterable.filterMap(self.map, ([key, entry]) => {\n if (entry.expiresAt === undefined || entry.expiresAt > now) {\n return Result.succeed(key);\n }\n MutableHashMap.remove(self.map, key);\n return Result.failVoid;\n }));\n});\n/**\n * Retrieves all successfully cached values from the cache, excluding failed\n * lookups and expired entries.\n *\n * **Example** (Reading all cached values)\n *\n * ```ts import.meta.vitest\n * import { Cache, Effect } from \"effect\"\n *\n * const program = Effect.gen(function*() {\n * const cache = yield* Cache.make({\n * capacity: 10,\n * lookup: (key: string) => Effect.succeed(key.length)\n * })\n *\n * // Add some values to the cache\n * yield* Cache.get(cache, \"a\")\n * yield* Cache.get(cache, \"ab\")\n * yield* Cache.get(cache, \"abc\")\n *\n * // Retrieve all cached values\n * const values = yield* Cache.values(cache)\n * return Array.from(values).sort()\n * })\n *\n * const actual = await Effect.runPromise(program)\n * actual // => [1, 2, 3]\n * ```\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const values = self => effect.map(entries(self), Iterable.map(([, value]) => value));\n/**\n * Retrieves all key-value pairs from the cache as an iterable. This function\n * only returns entries with successfully resolved values, filtering out any\n * failed lookups or expired entries.\n *\n * **Gotchas**\n *\n * Expired entries are removed from the cache while `entries` filters them out.\n *\n * @see {@link keys} for retrieving only cached keys\n * @see {@link values} for retrieving only cached values\n *\n * @category combinators\n * @since 4.0.0\n */\nexport const entries = self => core.withFiber(fiber => {\n const now = fiber.getRef(effect.ClockRef).currentTimeMillisUnsafe();\n return effect.succeed(Iterable.filterMap(self.map, ([key, entry]) => {\n if (entry.expiresAt === undefined || entry.expiresAt > now) {\n const exit = entry.fiber.pollUnsafe();\n return exit && exit._tag === \"Success\" ? Result.succeed([key, exit.value]) : Result.failVoid;\n }\n MutableHashMap.remove(self.map, key);\n return Result.failVoid;\n }));\n});\n//# sourceMappingURL=Cache.js.map","/**\n * Process-local invalidation for connecting writes to dependent reads.\n *\n * This module does not cache values itself. It lets callers register handlers\n * for keys, invalidate those keys, wrap successful mutations so they invalidate\n * keys, and expose effects as queues or streams that rerun when matching keys\n * change. The service can also batch invalidations so handlers run after the\n * batch completes.\n *\n * @since 4.0.0\n */\nimport * as Context from \"../../Context.js\";\nimport * as Effect from \"../../Effect.js\";\nimport * as Fiber from \"../../Fiber.js\";\nimport { dual, flow } from \"../../Function.js\";\nimport * as Hash from \"../../Hash.js\";\nimport * as Layer from \"../../Layer.js\";\nimport * as Queue from \"../../Queue.js\";\nimport * as Scope from \"../../Scope.js\";\nimport * as Stream from \"../../Stream.js\";\n/**\n * Service for key-based reactive invalidation.\n *\n * **When to use**\n *\n * Use to provide the invalidation service that refreshes queries, streams, and\n * atoms when application keys change.\n *\n * **Details**\n *\n * The service can register handlers for keys, invalidate those keys, wrap\n * mutations so successful effects invalidate keys, and turn query effects into\n * queues or streams that rerun when keys are invalidated.\n *\n * @category services\n * @since 4.0.0\n */\nexport class Reactivity extends /*#__PURE__*/Context.Service()(\"effect/reactivity/Reactivity\") {}\n/**\n * Creates an in-memory `Reactivity` service.\n *\n * **Details**\n *\n * The service tracks handlers by hashed keys and runs the registered handlers when\n * matching keys are invalidated.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const make = /*#__PURE__*/Effect.sync(() => {\n const handlers = new Map();\n const invalidateUnsafe = keys => {\n keysToHashes(keys, hash => {\n const set = handlers.get(hash);\n if (set === undefined) return;\n set.forEach(run => run());\n });\n };\n const invalidate = keys => Effect.contextWith(services => {\n const pending = services.mapUnsafe.get(PendingInvalidation.key);\n if (pending) {\n keysToHashes(keys, hash => {\n pending.add(hash);\n });\n } else {\n invalidateUnsafe(keys);\n }\n return Effect.void;\n });\n const mutation = (keys, effect) => Effect.tap(effect, invalidate(keys));\n const registerUnsafe = (keys, handler) => {\n const resolvedKeys = [];\n keysToHashes(keys, hash => {\n resolvedKeys.push(hash);\n let set = handlers.get(hash);\n if (set === undefined) {\n set = new Set();\n handlers.set(hash, set);\n }\n set.add(handler);\n });\n return () => {\n for (let i = 0; i < resolvedKeys.length; i++) {\n const set = handlers.get(resolvedKeys[i]);\n set.delete(handler);\n if (set.size === 0) {\n handlers.delete(resolvedKeys[i]);\n }\n }\n };\n };\n const query = (keys, effect) => Effect.gen(function* () {\n const services = yield* Effect.context();\n const scope = Context.get(services, Scope.Scope);\n const results = yield* Queue.make();\n const runFork = flow(Effect.runForkWith(services), Fiber.runIn(scope));\n let running = false;\n let pending = false;\n const handleExit = exit => {\n if (exit._tag === \"Failure\") {\n Queue.failCauseUnsafe(results, exit.cause);\n } else {\n Queue.offerUnsafe(results, exit.value);\n }\n if (pending) {\n pending = false;\n runFork(effect).addObserver(handleExit);\n } else {\n running = false;\n }\n };\n function run() {\n if (running) {\n pending = true;\n return;\n }\n running = true;\n runFork(effect).addObserver(handleExit);\n }\n const cancel = registerUnsafe(keys, run);\n yield* Scope.addFinalizer(scope, Effect.sync(cancel));\n run();\n return results;\n });\n const stream = (tables, effect) => query(tables, effect).pipe(Effect.map(Stream.fromQueue), Stream.unwrap);\n const withBatch = effect => Effect.suspend(() => {\n const pending = new Set();\n return effect.pipe(Effect.provideService(PendingInvalidation, pending), Effect.onExit(_ => Effect.sync(() => {\n pending.forEach(hash => {\n const set = handlers.get(hash);\n if (set === undefined) return;\n set.forEach(run => run());\n });\n })));\n });\n return Reactivity.of({\n mutation,\n query,\n stream,\n invalidateUnsafe,\n invalidate,\n registerUnsafe,\n withBatch\n });\n});\nclass PendingInvalidation extends /*#__PURE__*/Context.Service()(\"effect/reactivity/Reactivity/PendingInvalidation\") {}\n/**\n * Wraps an effect so the supplied keys are invalidated after the effect succeeds.\n *\n * **Gotchas**\n *\n * If the effect fails, the keys are not invalidated.\n *\n * @category accessors\n * @since 4.0.0\n */\nexport const mutation = /*#__PURE__*/dual(2, (effect, keys) => Reactivity.use(_ => _.mutation(keys, effect)));\n/**\n * Runs an effect as a query tied to the supplied invalidation keys.\n *\n * **Details**\n *\n * The returned queue receives the initial result and each later result after the\n * keys are invalidated. The registration is removed when the current scope closes.\n *\n * @category accessors\n * @since 4.0.0\n */\nexport const query = /*#__PURE__*/dual(2, (effect, keys) => Reactivity.use(r => r.query(keys, effect)));\n/**\n * Runs an effect as a stream of query results tied to the supplied invalidation\n * keys.\n *\n * **Details**\n *\n * The effect runs initially and reruns whenever the keys are invalidated.\n *\n * @category accessors\n * @since 4.0.0\n */\nexport const stream = /*#__PURE__*/dual(2, (effect, keys) => Reactivity.use(r => r.query(keys, effect)).pipe(Effect.map(Stream.fromQueue), Stream.unwrap));\n/**\n * Invalidates the supplied keys through the `Reactivity` service.\n *\n * **Details**\n *\n * Registered queries for matching keys are rerun immediately, or collected until\n * the enclosing reactivity batch completes.\n *\n * @category accessors\n * @since 4.0.0\n */\nexport const invalidate = keys => Reactivity.use(r => r.invalidate(keys));\n/**\n * The default layer that provides an in-memory `Reactivity` service.\n *\n * @category layers\n * @since 4.0.0\n */\nexport const layer = /*#__PURE__*/Layer.effect(Reactivity)(make);\nfunction stringOrHash(u) {\n switch (typeof u) {\n case \"string\":\n case \"number\":\n case \"bigint\":\n case \"boolean\":\n return String(u);\n default:\n return Hash.hash(u);\n }\n}\nconst keysToHashes = (keys, f) => {\n if (Array.isArray(keys)) {\n for (let i = 0; i < keys.length; i++) {\n f(stringOrHash(keys[i]));\n }\n return;\n }\n for (const key in keys) {\n f(key);\n const ids = keys[key];\n for (let i = 0; i < ids.length; i++) {\n f(`${key}:${stringOrHash(ids[i])}`);\n }\n }\n};\n//# sourceMappingURL=Reactivity.js.map","/**\n * Low-level SQL statement and fragment primitives.\n *\n * `SqlClient` uses this module to build executable, parameterized SQL from\n * reusable fragments. A statement can be executed, streamed, run without row\n * transformation, or compiled to SQL text and parameters for a specific\n * dialect. The module also contains helpers for identifiers, parameters,\n * inserts, updates, custom dialect fragments, statement compilation, and row\n * transformation.\n *\n * @since 4.0.0\n */\nimport { Clock } from \"../../Clock.js\";\nimport * as Context from \"../../Context.js\";\nimport * as Effect from \"../../Effect.js\";\nimport * as Effectable from \"../../Effectable.js\";\nimport { constUndefined } from \"../../Function.js\";\nimport * as internalEffect from \"../../internal/effect.js\";\nimport * as InternalRecord from \"../../internal/record.js\";\nimport { hasProperty } from \"../../Predicate.js\";\nimport { TracerTimingEnabled } from \"../../References.js\";\nimport * as Stream from \"../../Stream.js\";\nconst FragmentTypeId = \"~effect/sql/Fragment\";\n/**\n * Constructs a SQL `Fragment` from low-level statement segments.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const fragment = segments => ({\n [FragmentTypeId]: FragmentTypeId,\n segments\n});\n/**\n * Context reference for an optional current SQL statement transformer applied\n * before statement execution.\n *\n * @category services\n * @since 4.0.0\n */\nexport const CurrentTransformer = /*#__PURE__*/Context.Reference(\"effect/sql/CurrentTransformer\", {\n defaultValue: constUndefined\n});\n/**\n * Returns `true` when a value is a SQL `Fragment`.\n *\n * @category guards\n * @since 4.0.0\n */\nexport const isFragment = u => hasProperty(u, FragmentTypeId);\n/**\n * Creates a type guard for custom SQL segments with the specified custom kind.\n *\n * @category guards\n * @since 4.0.0\n */\nexport const isCustom = kind => u => hasProperty(u, \"_tag\") && u._tag === \"Custom\" && u.kind === kind;\n/**\n * Constructs a raw SQL literal segment. The literal text is not escaped, so use\n * bound parameters for untrusted values.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const literal = (value, params) => ({\n _tag: \"Literal\",\n value,\n params\n});\n/**\n * Constructs a SQL identifier segment that will be escaped by the active\n * compiler.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const identifier = value => ({\n _tag: \"Identifier\",\n value\n});\n/**\n * Constructs a bound parameter segment for a statement value.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const parameter = value => ({\n _tag: \"Parameter\",\n value\n});\n/**\n * Constructs an `ArrayHelper` segment for an array of values or fragments.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const arrayHelper = value => ({\n _tag: \"ArrayHelper\",\n value\n});\nconst RecordInsertHelperProto = {\n _tag: \"RecordInsertHelper\",\n returning(sql) {\n const self = Object.create(Object.getPrototypeOf(this));\n Object.assign(self, this, {\n returningIdentifier: sql\n });\n return self;\n }\n};\n/**\n * Constructs a `RecordInsertHelper` from one or more row objects.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const recordInsertHelper = value => Object.assign(Object.create(RecordInsertHelperProto), {\n value,\n returningIdentifier: undefined\n});\nconst RecordUpdateHelperProto = {\n ...RecordInsertHelperProto,\n _tag: \"RecordUpdateHelper\"\n};\n/**\n * Constructs a `RecordUpdateHelper` for multi-row update compilation using the\n * provided alias.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const recordUpdateHelper = (value, alias) => Object.assign(Object.create(RecordUpdateHelperProto), {\n value,\n alias,\n returningIdentifier: undefined\n});\nconst RecordUpdateHelperSingleProto = {\n ...RecordInsertHelperProto,\n _tag: \"RecordUpdateHelperSingle\"\n};\n/**\n * Constructs a `RecordUpdateHelperSingle` from a record and a list of columns\n * to omit from the update.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const recordUpdateHelperSingle = (value, omit) => Object.assign(Object.create(RecordUpdateHelperSingleProto), {\n value,\n omit,\n returningIdentifier: undefined\n});\n/**\n * Creates a constructor for custom SQL segments of a specific kind handled by\n * the active compiler.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const custom = kind => (paramA, paramB, paramC) => ({\n _tag: \"Custom\",\n kind,\n paramA,\n paramB,\n paramC\n});\n/**\n * Creates a cached SQL statement constructor from a connection acquirer,\n * compiler, tracing attributes, and optional row transformation function.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const make = (acquirer, compiler, spanAttributes, transformRows) => {\n const cache = transformRows === undefined ? constructorCache.noTransforms : constructorCache.transforms;\n if (cache.has(acquirer)) {\n return cache.get(acquirer);\n }\n const self = Object.assign(function sql(strings, ...args) {\n if (typeof strings === \"string\") {\n return identifier(strings);\n } else if (Array.isArray(strings) && \"raw\" in strings) {\n return statement(acquirer, compiler, strings, args, spanAttributes, transformRows);\n }\n throw \"absurd\";\n }, {\n unsafe(sql, params) {\n return makeUnsafe([literal(sql, params)], acquirer, compiler, spanAttributes, transformRows);\n },\n literal(sql) {\n return fragment([literal(sql)]);\n },\n in: in_,\n insert(value) {\n return recordInsertHelper(Array.isArray(value) ? value : [value]);\n },\n update(value, omit) {\n return recordUpdateHelperSingle(value, omit ?? []);\n },\n updateValues(value, alias) {\n return recordUpdateHelper(value, alias);\n },\n and,\n or,\n csv,\n join,\n onDialect(options) {\n return options[compiler.dialect]();\n },\n onDialectOrElse(options) {\n return options[compiler.dialect] !== undefined ? options[compiler.dialect]() : options.orElse();\n }\n });\n cache.set(acquirer, self);\n return self;\n};\nconst constructorCache = {\n transforms: /*#__PURE__*/new WeakMap(),\n noTransforms: /*#__PURE__*/new WeakMap()\n};\n/**\n * Builds a `Statement` from template strings and arguments, preserving\n * fragments and helper segments while converting ordinary interpolated values\n * into bound parameters.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const statement = (acquirer, compiler, strings, args, spanAttributes, transformRows) => {\n const segments = strings[0].length > 0 ? [literal(strings[0])] : [];\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n if (isFragment(arg)) {\n segments.push(...arg.segments);\n } else if (isSegment(arg)) {\n segments.push(arg);\n } else {\n segments.push(parameter(arg));\n }\n if (strings[i + 1].length > 0) {\n segments.push(literal(strings[i + 1]));\n }\n }\n return makeUnsafe(segments, acquirer, compiler, spanAttributes, transformRows);\n};\n/**\n * Creates a helper that joins SQL clauses with a literal separator, optionally\n * wrapping multiple clauses in parentheses and using a fallback for an empty\n * list.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport function join(lit, addParens = true, fallback = \"\") {\n const literalStatement = literal(lit);\n const fallbackFragment = fragment([literal(fallback)]);\n return clauses => {\n if (clauses.length === 0) {\n return fallbackFragment;\n } else if (clauses.length === 1) {\n return fragment(convertLiteralOrFragment(clauses[0]));\n }\n const segments = [];\n if (addParens) {\n segments.push(literal(\"(\"));\n }\n segments.push.apply(segments, convertLiteralOrFragment(clauses[0]));\n for (let i = 1; i < clauses.length; i++) {\n segments.push(literalStatement);\n segments.push.apply(segments, convertLiteralOrFragment(clauses[i]));\n }\n if (addParens) {\n segments.push(literal(\")\"));\n }\n return fragment(segments);\n };\n}\n/**\n * Combines clauses with `AND`, parenthesizing multiple clauses and returning\n * `1=1` when the list is empty.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const and = /*#__PURE__*/join(\" AND \", true, \"1=1\");\n/**\n * Combines clauses with `OR`, parenthesizing multiple clauses and returning\n * `1=1` when the list is empty.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const or = /*#__PURE__*/join(\" OR \", true, \"1=1\");\n/**\n * Creates a comma-separated SQL fragment from values, optionally adding a\n * prefix, and returns an empty fragment when no values are provided.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const csv = function (...args) {\n if (args[args.length - 1].length === 0) {\n return emptyFragment;\n }\n if (args.length === 1) {\n return csvRaw(args[0]);\n }\n return fragment([literal(`${args[0]} `), ...csvRaw(args[1]).segments]);\n};\nconst csvRaw = /*#__PURE__*/join(\",\", false);\nconst emptyFragment = /*#__PURE__*/fragment([/*#__PURE__*/literal(\"\")]);\n/**\n * Creates a dialect-specific SQL `Compiler` from rendering callbacks.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const makeCompiler = options => {\n const self = Object.create(CompilerProto);\n self.options = options;\n self.dialect = options.dialect;\n self.disableTransforms = false;\n return self;\n};\nconst statementCacheSymbol = /*#__PURE__*/Symbol.for(\"effect/unstable/sql/Statement/statementCache\");\nconst statementCacheNoTransformSymbol = /*#__PURE__*/Symbol.for(\"effect/unstable/sql/Statement/statementCacheNoTransform\");\nconst CompilerProto = {\n compile(statement, withoutTransform = false, placeholderOverride) {\n const opts = this.options;\n withoutTransform = withoutTransform || this.disableTransforms;\n const cacheSymbol = withoutTransform ? statementCacheNoTransformSymbol : statementCacheSymbol;\n if (cacheSymbol in statement) {\n return statement[cacheSymbol];\n }\n const segments = statement.segments;\n const len = segments.length;\n let sql = \"\";\n const binds = [];\n let placeholderCount = 0;\n const placeholder = placeholderOverride ?? (u => opts.placeholder(++placeholderCount, u));\n const placeholderNoIncrement = u => opts.placeholder(placeholderCount, u);\n const placeholders = makePlaceholdersArray(placeholder);\n for (let i = 0; i < len; i++) {\n const segment = segments[i];\n switch (segment._tag) {\n case \"Literal\":\n {\n sql += segment.value;\n if (segment.params) {\n binds.push.apply(binds, segment.params);\n }\n break;\n }\n case \"Identifier\":\n {\n sql += opts.onIdentifier(segment.value, withoutTransform);\n break;\n }\n case \"Parameter\":\n {\n sql += placeholder(segment.value);\n binds.push(segment.value);\n break;\n }\n case \"ArrayHelper\":\n {\n sql += `(${placeholders(segment.value)})`;\n binds.push.apply(binds, segment.value);\n break;\n }\n case \"RecordInsertHelper\":\n {\n const keys = Object.keys(segment.value[0]);\n if (opts.onInsert) {\n const values = new Array(segment.value.length);\n let placeholders = \"\";\n for (let i = 0; i < segment.value.length; i++) {\n const row = new Array(keys.length);\n values[i] = row;\n placeholders += i === 0 ? \"(\" : \",(\";\n for (let j = 0; j < keys.length; j++) {\n const key = keys[j];\n const value = segment.value[i][key];\n const primitive = extractPrimitive(value, opts.onCustom, placeholderNoIncrement, withoutTransform);\n row[j] = primitive;\n placeholders += j === 0 ? placeholder(value) : `,${placeholder(value)}`;\n }\n placeholders += \")\";\n }\n 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);\n sql += s;\n binds.push.apply(binds, b);\n } else {\n let placeholders = \"\";\n for (let i = 0; i < segment.value.length; i++) {\n placeholders += i === 0 ? \"(\" : \",(\";\n for (let j = 0; j < keys.length; j++) {\n const value = segment.value[i][keys[j]];\n const primitive = extractPrimitive(value, opts.onCustom, placeholderNoIncrement, withoutTransform);\n binds.push(primitive);\n placeholders += j === 0 ? placeholder(value) : `,${placeholder(value)}`;\n }\n placeholders += \")\";\n }\n sql += `${generateColumns(keys, opts.onIdentifier, withoutTransform)} VALUES ${placeholders}`;\n if (typeof segment.returningIdentifier === \"string\") {\n sql += ` RETURNING ${segment.returningIdentifier}`;\n } else if (segment.returningIdentifier) {\n sql += \" RETURNING \";\n const [s, b] = this.compile(segment.returningIdentifier, withoutTransform, placeholder);\n sql += s;\n binds.push.apply(binds, b);\n }\n }\n break;\n }\n case \"RecordUpdateHelperSingle\":\n {\n let keys = Object.keys(segment.value);\n if (segment.omit.length > 0) {\n keys = keys.filter(key => !segment.omit.includes(key));\n }\n if (opts.onRecordUpdateSingle) {\n 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);\n sql += s;\n binds.push.apply(binds, b);\n } else {\n for (let i = 0, len = keys.length; i < len; i++) {\n const column = opts.onIdentifier(keys[i], withoutTransform);\n if (i === 0) {\n sql += `${column} = ${placeholder(segment.value[keys[i]])}`;\n } else {\n sql += `, ${column} = ${placeholder(segment.value[keys[i]])}`;\n }\n binds.push(extractPrimitive(segment.value[keys[i]], opts.onCustom, placeholderNoIncrement, withoutTransform));\n }\n if (typeof segment.returningIdentifier === \"string\") {\n if (this.dialect === \"mssql\") {\n sql += ` OUTPUT ${segment.returningIdentifier === \"*\" ? \"INSERTED.*\" : segment.returningIdentifier}`;\n } else {\n sql += ` RETURNING ${segment.returningIdentifier}`;\n }\n } else if (segment.returningIdentifier) {\n sql += this.dialect === \"mssql\" ? \" OUTPUT \" : \" RETURNING \";\n const [s, b] = this.compile(segment.returningIdentifier, withoutTransform, placeholder);\n sql += s;\n binds.push.apply(binds, b);\n }\n }\n break;\n }\n case \"RecordUpdateHelper\":\n {\n const keys = Object.keys(segment.value[0]);\n const values = new Array(segment.value.length);\n let placeholders = \"\";\n for (let i = 0; i < segment.value.length; i++) {\n const row = new Array(keys.length);\n values[i] = row;\n placeholders += i === 0 ? \"(\" : \",(\";\n for (let j = 0; j < keys.length; j++) {\n const key = keys[j];\n const value = segment.value[i][key];\n row[j] = extractPrimitive(value, opts.onCustom, placeholderNoIncrement, withoutTransform);\n placeholders += j === 0 ? placeholder(value) : `,${placeholder(value)}`;\n }\n placeholders += \")\";\n }\n 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);\n sql += s;\n binds.push.apply(binds, b);\n break;\n }\n case \"Custom\":\n {\n const [s, b] = opts.onCustom(segment, placeholder, withoutTransform);\n sql += s;\n binds.push.apply(binds, b);\n break;\n }\n }\n }\n const result = [sql, binds];\n if (placeholderOverride !== undefined) {\n return result;\n }\n return statement[cacheSymbol] = result;\n },\n get withoutTransform() {\n const self = Object.create(CompilerProto);\n Object.assign(self, this, {\n disableTransforms: true\n });\n return self;\n }\n};\n/**\n * Creates a SQLite compiler that uses `?` placeholders and quoted identifiers,\n * optionally transforming identifier names before escaping.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const makeCompilerSqlite = transform => makeCompiler({\n dialect: \"sqlite\",\n placeholder(_) {\n return \"?\";\n },\n onIdentifier: transform ? function (value, withoutTransform) {\n return withoutTransform ? escapeSqlite(value) : escapeSqlite(transform(value));\n } : escapeSqlite,\n onRecordUpdate() {\n return [\"\", []];\n },\n onCustom() {\n return [\"\", []];\n }\n});\n/**\n * Creates an identifier escaping function that wraps names in the given\n * delimiter, doubles delimiter characters, and escapes dots between identifier\n * parts.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport function defaultEscape(c) {\n const re = new RegExp(c, \"g\");\n const double = c + c;\n const dot = c + \".\" + c;\n return function (str) {\n return c + str.replace(re, double).replace(/\\./g, dot) + c;\n };\n}\n/**\n * Classifies a JavaScript value as a SQL primitive kind, treating `undefined`\n * as `null` and defaulting unrecognized objects to `string`.\n *\n * @category converting\n * @since 4.0.0\n */\nexport const primitiveKind = value => {\n switch (typeof value) {\n case \"string\":\n return \"string\";\n case \"number\":\n return \"number\";\n case \"boolean\":\n return \"boolean\";\n case \"bigint\":\n return \"bigint\";\n case \"undefined\":\n return \"null\";\n }\n if (value === null) {\n return \"null\";\n } else if (value instanceof Date) {\n return \"Date\";\n } else if (value instanceof Uint8Array) {\n return \"Uint8Array\";\n } else if (value instanceof Int8Array) {\n return \"Int8Array\";\n }\n return \"string\";\n};\n/**\n * Builds value, object, and row-array transformers that rename object keys with\n * the supplied function and optionally recurse into nested object arrays.\n *\n * @category transforming\n * @since 4.0.0\n */\nexport const defaultTransforms = (transformer, nested = true) => {\n const transformValue = value => {\n if (Array.isArray(value)) {\n if (value.length === 0 || value[0].constructor !== Object) {\n return value;\n }\n return array(value);\n } else if (value?.constructor === Object) {\n return transformObject(value);\n }\n return value;\n };\n const transformObject = obj => {\n const newObj = {};\n for (const key of Object.keys(obj)) {\n InternalRecord.assignProperty(newObj, transformer(key), transformValue(obj[key]));\n }\n return newObj;\n };\n const transformArrayNested = rows => {\n const newRows = new Array(rows.length);\n for (let i = 0, len = rows.length; i < len; i++) {\n const row = rows[i];\n if (Array.isArray(row)) {\n newRows[i] = transformArrayNested(row);\n } else {\n const obj = {};\n for (const [key, value] of Object.entries(row)) {\n InternalRecord.assignProperty(obj, transformer(key), transformValue(value));\n }\n newRows[i] = obj;\n }\n }\n return newRows;\n };\n const transformArray = rows => {\n const newRows = new Array(rows.length);\n for (let i = 0, len = rows.length; i < len; i++) {\n const row = rows[i];\n if (Array.isArray(row)) {\n newRows[i] = transformArray(row);\n } else {\n const obj = {};\n for (const [key, value] of Object.entries(row)) {\n InternalRecord.assignProperty(obj, transformer(key), value);\n }\n newRows[i] = obj;\n }\n }\n return newRows;\n };\n const array = nested ? transformArrayNested : transformArray;\n return {\n value: transformValue,\n object: transformObject,\n array\n };\n};\n// internal\nconst ATTR_DB_OPERATION_NAME = \"db.operation.name\";\nconst ATTR_DB_QUERY_TEXT = \"db.query.text\";\nconst makeUnsafe = (segments, acquirer, compiler, spanAttributes, transformRows) => {\n const self = Object.create(StatementProto);\n self.segments = segments;\n self.acquirer = acquirer;\n self.compiler = compiler;\n self.spanAttributes = spanAttributes;\n self.transformRows = transformRows;\n return self;\n};\n// TODO: figure out why these diagnostics are emitted\nconst StatementProto = {\n [FragmentTypeId]: FragmentTypeId,\n withConnection(operation, f, withoutTransform = false) {\n return Effect.useSpan(\"sql.execute\", {\n kind: \"client\"\n }, span => this.withConnectionSpan(operation, f, withoutTransform, span));\n },\n withConnectionSpan(operation, f, withoutTransform, span) {\n return withStatement(this, span, statement => {\n const [sql, params] = statement.compile(withoutTransform);\n for (const [key, value] of this.spanAttributes) {\n span.attribute(key, value);\n }\n span.attribute(ATTR_DB_OPERATION_NAME, operation);\n span.attribute(ATTR_DB_QUERY_TEXT, sql);\n return Effect.scoped(Effect.flatMap(this.acquirer, _ => f(_, sql, params)));\n });\n },\n get withoutTransform() {\n return this.withConnection(\"executeWithoutTransform\", (connection, sql, params) => connection.execute(sql, params, undefined), true);\n },\n get raw() {\n return this.withConnection(\"executeRaw\", (connection, sql, params) => connection.executeRaw(sql, params), true);\n },\n get stream() {\n const self = this;\n return Stream.unwrap(Effect.flatMap(Effect.makeSpanScoped(\"sql.execute\", {\n kind: \"client\"\n }), span => withStatement(self, span, statement => {\n const [sql, params] = statement.compile();\n for (const [key, value] of self.spanAttributes) {\n span.attribute(key, value);\n }\n span.attribute(ATTR_DB_OPERATION_NAME, \"executeStream\");\n span.attribute(ATTR_DB_QUERY_TEXT, sql);\n return Effect.map(self.acquirer, _ => _.executeStream(sql, params, self.transformRows));\n })));\n },\n get values() {\n return this.withConnection(\"executeValues\", (connection, sql, params) => connection.executeValues(sql, params));\n },\n get valuesUnprepared() {\n return this.withConnection(\"executeValuesUnprepared\", (connection, sql, params) => connection.executeValuesUnprepared(sql, params));\n },\n get unprepared() {\n const self = this;\n return self.withConnection(\"executeUnprepared\", (connection, sql, params) => connection.executeUnprepared(sql, params, self.transformRows));\n },\n ... /*#__PURE__*/Effectable.Prototype({\n label: \"Statement\",\n evaluate(fiber) {\n const span = internalEffect.makeSpanUnsafe(fiber, \"sql.execute\", {\n kind: \"client\"\n });\n const clock = fiber.getRef(Clock);\n const timingEnabled = fiber.getRef(TracerTimingEnabled);\n return Effect.onExit(this.withConnectionSpan(\"execute\", (connection, sql, params) => connection.execute(sql, params, this.transformRows), false, span), exit => internalEffect.endSpan(span, exit, clock, timingEnabled));\n }\n }),\n compile(withoutTransform) {\n return this.compiler.compile(this, withoutTransform ?? false);\n },\n toJSON() {\n const [sql, params] = this.compile();\n return {\n _id: \"Statement\",\n segments: this.segments,\n sql,\n params\n };\n }\n};\nconst withStatement = (self, span, f) => Effect.withFiber(fiber => {\n const transform = fiber.getRef(CurrentTransformer);\n if (transform === undefined) {\n return f(self);\n }\n return Effect.flatMap(transform(self, make(self.acquirer, self.compiler, self.spanAttributes, self.transformRows), fiber, span), f);\n});\nconst isSegment = u => {\n if (!hasProperty(u, \"_tag\")) {\n return false;\n }\n switch (u._tag) {\n case \"Literal\":\n case \"Parameter\":\n case \"ArrayHelper\":\n case \"RecordInsertHelper\":\n case \"RecordUpdateHelper\":\n case \"RecordUpdateHelperSingle\":\n case \"Identifier\":\n case \"Custom\":\n return true;\n default:\n return false;\n }\n};\nfunction convertLiteralOrFragment(clause) {\n if (typeof clause === \"string\") {\n return [literal(clause)];\n }\n return clause.segments;\n}\nconst makePlaceholdersArray = evaluate => values => {\n if (values.length === 0) {\n return \"\";\n }\n let result = evaluate(values[0]);\n for (let i = 1; i < values.length; i++) {\n result += `,${evaluate(values[i])}`;\n }\n return result;\n};\nconst generateColumns = (keys, escape, withoutTransform) => {\n if (keys.length === 0) {\n return \"()\";\n }\n let str = `(${escape(keys[0], withoutTransform)}`;\n for (let i = 1; i < keys.length; i++) {\n str += `,${escape(keys[i], withoutTransform)}`;\n }\n return str + \")\";\n};\nconst extractPrimitive = (value, onCustom, placeholder, withoutTransform) => {\n if (value === undefined) {\n return null;\n } else if (isFragment(value)) {\n const head = value.segments[0];\n if (head._tag === \"Custom\") {\n const compiled = onCustom(head, placeholder, withoutTransform);\n return compiled[1][0] ?? null;\n } else if (head._tag === \"Parameter\") {\n return head.value;\n }\n return null;\n }\n return value;\n};\nconst escapeSqlite = /*#__PURE__*/defaultEscape(\"\\\"\");\nfunction in_() {\n if (arguments.length === 1) {\n return arrayHelper(arguments[0]);\n }\n const column = arguments[0];\n const values = arguments[1];\n return values.length === 0 ? neverFragment : fragment([identifier(column), literal(\" IN \"), arrayHelper(values)]);\n}\nconst neverFragment = /*#__PURE__*/fragment([/*#__PURE__*/literal(\"1=0\")]);\n//# sourceMappingURL=Statement.js.map","/**\n * Main SQL client service for tagged-template queries.\n *\n * `SqlClient` combines the tagged-template statement constructor with\n * connection acquisition, dialect compilation, transactions, row transforms,\n * tracing, and reactive query helpers. Driver integrations build this service\n * from their connection and compiler pieces.\n *\n * @since 4.0.0\n */\nimport { Clock } from \"../../Clock.js\";\nimport * as Context from \"../../Context.js\";\nimport * as Effect from \"../../Effect.js\";\nimport * as Exit from \"../../Exit.js\";\nimport * as Option from \"../../Option.js\";\nimport * as Scope from \"../../Scope.js\";\nimport * as Stream from \"../../Stream.js\";\nimport * as Tracer from \"../../Tracer.js\";\nimport { Reactivity } from \"../reactivity/Reactivity.js\";\nimport * as Statement from \"./Statement.js\";\nconst TypeId = \"~effect/sql/SqlClient\";\n/**\n * Service tag for the active SQL client service.\n *\n * **When to use**\n *\n * Use to access or provide the SQL client used to build statements, stream\n * rows, reserve connections, and run transactions.\n *\n * @category services\n * @since 4.0.0\n */\nexport const SqlClient = /*#__PURE__*/Context.Service(\"effect/sql/SqlClient\");\nlet clientIdCounter = 0;\n/**\n * Constructs a `SqlClient` from connection acquirers, a compiler, transaction\n * commands, tracing attributes, optional row transforms, and reactive query\n * integration.\n *\n * @category constructors\n * @since 4.0.0\n */\nexport const make = /*#__PURE__*/Effect.fnUntraced(function* (options) {\n const transactionService = options.transactionService ?? TransactionConnection(clientIdCounter++);\n const getConnection = Effect.flatMap(Effect.serviceOption(transactionService), Option.match({\n onNone: () => options.acquirer,\n onSome: ([conn]) => Effect.succeed(conn)\n }));\n const beginTransaction = options.beginTransaction ?? \"BEGIN\";\n const commit = options.commit ?? \"COMMIT\";\n const savepoint = options.savepoint ?? (name => `SAVEPOINT ${name}`);\n const rollback = options.rollback ?? \"ROLLBACK\";\n const rollbackSavepoint = options.rollbackSavepoint ?? (name => `ROLLBACK TO SAVEPOINT ${name}`);\n const transactionAcquirer = options.transactionAcquirer ?? options.acquirer;\n const withTransaction = makeWithTransaction({\n transactionService,\n spanAttributes: options.spanAttributes,\n acquireConnection: Effect.flatMap(Scope.make(), scope => Effect.map(Scope.provide(transactionAcquirer, scope), conn => [scope, conn])),\n begin: conn => conn.executeUnprepared(beginTransaction, [], undefined),\n savepoint: (conn, id) => conn.executeUnprepared(savepoint(`effect_sql_${id}`), [], undefined),\n commit: conn => conn.executeUnprepared(commit, [], undefined),\n rollback: conn => conn.executeUnprepared(rollback, [], undefined),\n rollbackSavepoint: (conn, id) => conn.executeUnprepared(rollbackSavepoint(`effect_sql_${id}`), [], undefined)\n });\n const reactivity = yield* Reactivity;\n const client = Object.assign(Statement.make(getConnection, options.compiler, options.spanAttributes, options.transformRows), {\n [TypeId]: TypeId,\n safe: undefined,\n withTransaction,\n transactionService,\n reserve: transactionAcquirer,\n withoutTransforms() {\n if (options.transformRows === undefined) {\n return this;\n }\n const statement = Statement.make(getConnection, options.compiler.withoutTransform, options.spanAttributes, undefined);\n const client = Object.assign(statement, {\n ...this,\n ...statement\n });\n client.safe = client;\n client.withoutTransforms = () => client;\n return client;\n },\n reactive: options.reactiveQueue ? (keys, effect) => options.reactiveQueue(keys, effect).pipe(Effect.map(Stream.fromQueue), Stream.unwrap) : reactivity.stream,\n reactiveMailbox: options.reactiveQueue ?? reactivity.query\n });\n client.safe = client;\n return client;\n});\n/**\n * Builds a transaction wrapper that begins top-level transactions, uses\n * savepoints for nested transactions, commits on success, and rolls back on\n * failure or interruption.\n *\n * @category transactions\n * @since 4.0.0\n */\nexport const makeWithTransaction = options => effect => {\n return Effect.uninterruptibleMask(restore => Effect.useSpan(\"sql.transaction\", {\n kind: \"client\"\n }, span => Effect.withFiber(fiber => {\n for (const [key, value] of options.spanAttributes) {\n span.attribute(key, value);\n }\n const services = fiber.context;\n const clock = fiber.getRef(Clock);\n const connOption = Context.getOption(services, options.transactionService);\n const conn = connOption._tag === \"Some\" ? Effect.succeed([undefined, connOption.value[0]]) : options.acquireConnection;\n const id = connOption._tag === \"Some\" ? connOption.value[1] + 1 : 0;\n return Effect.flatMap(conn, ([scope, conn]) => (id === 0 ? options.begin(conn) : options.savepoint(conn, id)).pipe(Effect.flatMap(() => Effect.provideContext(restore(effect), services.pipe(Context.add(options.transactionService, [conn, id]), Context.add(Tracer.ParentSpan, span)))), Effect.exit, Effect.flatMap(exit => {\n let effect;\n if (Exit.isSuccess(exit)) {\n if (id === 0) {\n span.event(\"db.transaction.commit\", clock.currentTimeNanosUnsafe());\n effect = Effect.orDie(options.commit(conn));\n } else {\n span.event(\"db.transaction.savepoint\", clock.currentTimeNanosUnsafe());\n effect = Effect.void;\n }\n } else {\n span.event(\"db.transaction.rollback\", clock.currentTimeNanosUnsafe());\n effect = Effect.orDie(id > 0 ? options.rollbackSavepoint(conn, id) : options.rollback(conn));\n }\n const withScope = scope !== undefined ? Effect.ensuring(effect, Scope.close(scope, exit)) : effect;\n return Effect.flatMap(withScope, () => exit);\n })));\n })));\n};\n/**\n * Creates a unique context service tag for the active transaction connection of\n * a specific SQL client.\n *\n * @category services\n * @since 4.0.0\n */\nexport const TransactionConnection = clientId => Context.Service(`effect/sql/SqlClient/TransactionConnection/${clientId}`);\n/**\n * Context reference used by SQL integrations to opt in to safe integer\n * handling; defaults to `false`.\n *\n * @category services\n * @since 4.0.0\n */\nexport const SafeIntegers = /*#__PURE__*/Context.Reference(\"effect/sql/SqlClient/SafeIntegers\", {\n defaultValue: () => false\n});\n//# sourceMappingURL=SqlClient.js.map"],"x_google_ignoreList":[0,1,2,3],"mappings":";;;;;;;;;;;;;;AAoBA,MAAMA,WAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8Cf,MAAa,YAAY,QAAQ,YAAYC,aAAmB,YAAW;CACzE,MAAM,OAAO,OAAO,OAAO,KAAK;CAChC,KAAK,UAAS,QAAOC,cAAqB,OAAO,GAAG,IAAG,UAASC,MAAc,SAAS,KAAK,CAAC;CAC7F,KAAK,MAAMC,OAAoB;CAC/B,KAAK,WAAW,QAAQ;CACxB,KAAK,aAAa,QAAQ,cAAc,MAA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