@streamsy/storage 0.0.0-stage → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,43 @@
1
+ import { Context, Effect, Layer, Queue, Scope, Stream } from "effect";
2
+ import * as Reactivity from "effect/reactivity/Reactivity";
3
+ import * as SqlClient from "effect/sql/SqlClient";
4
+ import "effect/sql/SqlError";
5
+ import { OwnerRecords } from "@streamsy/core/internal";
6
+ import { CommitBoundary, Storage, StorageFault, Streamsy } from "@streamsy/core";
7
+ import { Protocol } from "@streamsy/core/protocol";
8
+ //#region src/transaction-retry.d.ts
9
+ declare const DEFAULT_TRANSACTION_RETRY_ATTEMPTS = 16;
10
+ declare const DEFAULT_TRANSACTION_RETRY_DELAY_MS = 25;
11
+ //#endregion
12
+ //#region src/boundary.d.ts
13
+ /**
14
+ * Build a `SqlClient` and provide it with the `Reactivity` it captured, so the
15
+ * client and the storage boundary share one change graph.
16
+ *
17
+ * ```ts
18
+ * const storage = Storage.layer(streams).pipe(
19
+ * Layer.provide(Storage.clientLayer(PgClient.make({ url: Redacted.make(url) }))),
20
+ * );
21
+ * ```
22
+ */
23
+ declare const clientLayer: <A extends SqlClient.SqlClient, E>(makeClient: Effect.Effect<A, E, Scope.Scope | Reactivity.Reactivity>) => Layer.Layer<SqlClient.SqlClient | Reactivity.Reactivity, E>;
24
+ //#endregion
25
+ //#region src/storage.d.ts
26
+ declare const DEFAULT_REPAIR_INTERVAL_MS = 1000;
27
+ interface SqlStorageOptions {
28
+ /** Cross-process and post-commit-interruption staleness bound. */
29
+ readonly repairIntervalMs?: number;
30
+ /** Total attempts for a standalone storage-owned transaction. */
31
+ readonly transactionRetryAttempts?: number;
32
+ /** Yield between retryable, known-rolled-back transaction attempts. */
33
+ readonly transactionRetryDelayMs?: number;
34
+ }
35
+ /** Generic SQLite-stream SQL layer. Hosts supply one matching SqlClient/Reactivity graph. */
36
+ declare const storageLayer: (options?: SqlStorageOptions) => Layer.Layer<Storage | CommitBoundary | OwnerRecords, StorageFault, SqlClient.SqlClient | Reactivity.Reactivity>;
37
+ /** Options for `layer` and `layerProtocol`. */
38
+ interface Options extends SqlStorageOptions, Protocol.ProtocolOptions {}
39
+ /** Protocol over SQL storage. */
40
+ declare const layerProtocol: (options?: Options) => Layer.Layer<CommitBoundary | OwnerRecords | Storage | import("@streamsy/core/protocol").StreamsReader | import("@streamsy/core/protocol").StreamsWriter, StorageFault, Reactivity.Reactivity | SqlClient.SqlClient>;
41
+ declare function layer<const Keys extends ReadonlyArray<Streamsy.Any>>(group: Streamsy.Group<Keys>, options?: Options): Layer.Layer<Layer.Success<ReturnType<typeof storageLayer>> | Streamsy.Host<Streamsy.Group<Keys>>, Layer.Error<ReturnType<typeof storageLayer>>, Layer.Services<ReturnType<typeof storageLayer>>>;
42
+ //#endregion
43
+ export { layerProtocol as a, DEFAULT_TRANSACTION_RETRY_DELAY_MS as c, layer as i, Options as n, clientLayer as o, SqlStorageOptions as r, DEFAULT_TRANSACTION_RETRY_ATTEMPTS as s, DEFAULT_REPAIR_INTERVAL_MS as t };
package/package.json CHANGED
@@ -1,6 +1,83 @@
1
1
  {
2
2
  "name": "@streamsy/storage",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.4.0",
4
+ "description": "Effect SQL storage for Streamsy on SQLite, Postgres and MySQL, with Bun and Durable Object SQLite host layers.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/gingerhendrix/streamsy.git",
9
+ "directory": "packages/storage"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "type": "module",
17
+ "sideEffects": false,
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js",
22
+ "default": "./dist/index.js"
23
+ },
24
+ "./bun": {
25
+ "types": "./dist/bun.d.ts",
26
+ "import": "./dist/bun.js",
27
+ "default": "./dist/bun.js"
28
+ },
29
+ "./durable-object": {
30
+ "types": "./dist/durable-object.d.ts",
31
+ "import": "./dist/durable-object.js",
32
+ "default": "./dist/durable-object.js"
33
+ }
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "scripts": {
39
+ "build": "tsdown src/index.ts src/bun.ts src/durable-object.ts --format esm --dts --out-dir dist --clean --deps.never-bundle effect --deps.never-bundle bun:sqlite --deps.never-bundle @streamsy/core --deps.never-bundle @effect/platform-bun --deps.never-bundle @effect/sql-sqlite-bun --deps.never-bundle @effect/sql-sqlite-do",
40
+ "typecheck": "tsc --noEmit",
41
+ "test:unit": "bun --bun vitest run --dir test",
42
+ "test:dialects": "bun --bun vitest run test/dialects"
43
+ },
44
+ "dependencies": {
45
+ "@streamsy/core": "^0.4.0"
46
+ },
47
+ "devDependencies": {
48
+ "@cloudflare/workers-types": "4.20251228.0",
49
+ "@effect/platform-bun": "4.0.5",
50
+ "@effect/sql-mysql2": "4.0.5",
51
+ "@effect/sql-pg": "4.0.5",
52
+ "@effect/sql-sqlite-bun": "4.0.5",
53
+ "@effect/sql-sqlite-do": "4.0.5",
54
+ "@effect/vitest": "4.0.5",
55
+ "@streamsy/serve": "0.4.0",
56
+ "@types/bun": "^1.4.3",
57
+ "effect": "4.0.5",
58
+ "miniflare": "4.20260730.0",
59
+ "typescript": "^7.0.2",
60
+ "vitest": "5.0.5"
61
+ },
62
+ "peerDependencies": {
63
+ "@effect/platform-bun": "^4.0.5",
64
+ "@effect/sql-sqlite-bun": "^4.0.5",
65
+ "@effect/sql-sqlite-do": "^4.0.5",
66
+ "effect": "^4.0.5"
67
+ },
68
+ "peerDependenciesMeta": {
69
+ "@effect/platform-bun": {
70
+ "optional": true
71
+ },
72
+ "@effect/sql-sqlite-bun": {
73
+ "optional": true
74
+ },
75
+ "@effect/sql-sqlite-do": {
76
+ "optional": true
77
+ }
78
+ },
79
+ "tsdown": {
80
+ "fixedExtension": false,
81
+ "tsconfig": "tsconfig.build.json"
82
+ }
83
+ }