@effect/sql-sqlite-do 4.0.0-beta.8 → 4.0.0-beta.81

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.
@@ -1,27 +1,41 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Connects Effect SQL to SQLite storage inside Cloudflare Durable Objects.
3
+ *
4
+ * This module wraps a Durable Object `SqlStorage` handle and exposes it as both
5
+ * `SqliteClient` and the generic Effect SQL client. It serializes access,
6
+ * supports normal and streaming queries, converts returned `ArrayBuffer` values
7
+ * to `Uint8Array`, and provides layers for wiring the client into an Effect
8
+ * application. `updateValues` is not supported by this driver.
9
+ *
10
+ * @since 4.0.0
3
11
  */
4
12
  import type { SqlStorage } from "@cloudflare/workers-types";
5
13
  import * as Config from "effect/Config";
14
+ import * as Context from "effect/Context";
6
15
  import * as Effect from "effect/Effect";
7
16
  import * as Layer from "effect/Layer";
8
17
  import * as Scope from "effect/Scope";
9
- import * as ServiceMap from "effect/ServiceMap";
10
18
  import * as Reactivity from "effect/unstable/reactivity/Reactivity";
11
19
  import * as Client from "effect/unstable/sql/SqlClient";
12
20
  /**
13
- * @category type ids
14
- * @since 1.0.0
21
+ * Runtime type identifier used to mark Cloudflare Durable Object `SqliteClient` values.
22
+ *
23
+ * @category type IDs
24
+ * @since 4.0.0
15
25
  */
16
26
  export declare const TypeId: TypeId;
17
27
  /**
18
- * @category type ids
19
- * @since 1.0.0
28
+ * Type-level identifier used to mark Cloudflare Durable Object `SqliteClient` values.
29
+ *
30
+ * @category type IDs
31
+ * @since 4.0.0
20
32
  */
21
33
  export type TypeId = "~@effect/sql-sqlite-do/SqliteClient";
22
34
  /**
35
+ * Cloudflare Durable Object SQLite client service, extending `SqlClient` with its configuration. `updateValues` is not supported.
36
+ *
23
37
  * @category models
24
- * @since 1.0.0
38
+ * @since 4.0.0
25
39
  */
26
40
  export interface SqliteClient extends Client.SqlClient {
27
41
  readonly [TypeId]: TypeId;
@@ -30,13 +44,22 @@ export interface SqliteClient extends Client.SqlClient {
30
44
  readonly updateValues: never;
31
45
  }
32
46
  /**
33
- * @category tags
34
- * @since 1.0.0
47
+ * Service tag for the Cloudflare Durable Object SQLite client service.
48
+ *
49
+ * **When to use**
50
+ *
51
+ * Use to access or provide a Durable Object SQLite client through the Effect
52
+ * context.
53
+ *
54
+ * @category services
55
+ * @since 4.0.0
35
56
  */
36
- export declare const SqliteClient: ServiceMap.Service<SqliteClient, SqliteClient>;
57
+ export declare const SqliteClient: Context.Service<SqliteClient, SqliteClient>;
37
58
  /**
59
+ * Configuration for a Cloudflare Durable Object SQLite client, including the `SqlStorage` handle, span attributes, and query/result name transforms.
60
+ *
38
61
  * @category models
39
- * @since 1.0.0
62
+ * @since 4.0.0
40
63
  */
41
64
  export interface SqliteClientConfig {
42
65
  readonly db: SqlStorage;
@@ -45,18 +68,24 @@ export interface SqliteClientConfig {
45
68
  readonly transformQueryNames?: ((str: string) => string) | undefined;
46
69
  }
47
70
  /**
48
- * @category constructor
49
- * @since 1.0.0
71
+ * Creates a scoped Cloudflare Durable Object SQLite client around `SqlStorage`, serializing access and converting returned `ArrayBuffer` values to `Uint8Array`.
72
+ *
73
+ * @category constructors
74
+ * @since 4.0.0
50
75
  */
51
76
  export declare const make: (options: SqliteClientConfig) => Effect.Effect<SqliteClient, never, Scope.Scope | Reactivity.Reactivity>;
52
77
  /**
78
+ * Creates a layer from a `Config`-wrapped Durable Object SQLite client configuration, providing both `SqliteClient` and `SqlClient`.
79
+ *
53
80
  * @category layers
54
- * @since 1.0.0
81
+ * @since 4.0.0
55
82
  */
56
83
  export declare const layerConfig: (config: Config.Wrap<SqliteClientConfig>) => Layer.Layer<SqliteClient | Client.SqlClient, Config.ConfigError>;
57
84
  /**
85
+ * Creates a layer from a concrete Durable Object SQLite client configuration, providing both `SqliteClient` and `SqlClient`.
86
+ *
58
87
  * @category layers
59
- * @since 1.0.0
88
+ * @since 4.0.0
60
89
  */
61
90
  export declare const layer: (config: SqliteClientConfig) => Layer.Layer<SqliteClient | Client.SqlClient>;
62
91
  //# sourceMappingURL=SqliteClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SqliteClient.d.ts","sourceRoot":"","sources":["../src/SqliteClient.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAE/C,OAAO,KAAK,UAAU,MAAM,uCAAuC,CAAA;AACnE,OAAO,KAAK,MAAM,MAAM,+BAA+B,CAAA;AAOvD;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,MAA8C,CAAA;AAEnE;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,qCAAqC,CAAA;AAE1D;;;GAGG;AACH,MAAM,WAAW,YAAa,SAAQ,MAAM,CAAC,SAAS;IACpD,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAA;IAEnC,8BAA8B;IAC9B,QAAQ,CAAC,YAAY,EAAE,KAAK,CAAA;CAC7B;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,gDAAyE,CAAA;AAElG;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAA;IACvB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;IAE7D,QAAQ,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,SAAS,CAAA;IACrE,QAAQ,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AS;IACpD,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAA;IAEnC,8BAA8B;IAC9B,QAAQ,CAAC,YAAY,EAAE,KAAK,CAAA;CAC7B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,6CAAsE,CAAA;AAE/F;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAA;IACvB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;IAE7D,QAAQ,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,SAAS,CAAA;IACrE,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,SAAS,CAAA;CACrE;AAED;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GACf,SAAS,kBAAkB,KAC1B,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,UAAU,CAmHrE,CAAA;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GACtB,QAAQ,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,KACtC,KAAK,CAAC,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,CAUzB,CAAA;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAChB,QAAQ,kBAAkB,KACzB,KAAK,CAAC,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,SAAS,CAML,CAAA"}
@@ -1,30 +1,45 @@
1
1
  import * as Config from "effect/Config";
2
+ import * as Context from "effect/Context";
2
3
  import * as Effect from "effect/Effect";
3
4
  import * as Fiber from "effect/Fiber";
4
5
  import { identity } from "effect/Function";
5
6
  import * as Layer from "effect/Layer";
6
7
  import * as Scope from "effect/Scope";
7
8
  import * as Semaphore from "effect/Semaphore";
8
- import * as ServiceMap from "effect/ServiceMap";
9
9
  import * as Stream from "effect/Stream";
10
10
  import * as Reactivity from "effect/unstable/reactivity/Reactivity";
11
11
  import * as Client from "effect/unstable/sql/SqlClient";
12
- import { SqlError } from "effect/unstable/sql/SqlError";
12
+ import { classifySqliteError, SqlError } from "effect/unstable/sql/SqlError";
13
13
  import * as Statement from "effect/unstable/sql/Statement";
14
14
  const ATTR_DB_SYSTEM_NAME = "db.system.name";
15
+ const classifyError = (cause, message, operation) => classifySqliteError(cause, {
16
+ message,
17
+ operation
18
+ });
15
19
  /**
16
- * @category type ids
17
- * @since 1.0.0
20
+ * Runtime type identifier used to mark Cloudflare Durable Object `SqliteClient` values.
21
+ *
22
+ * @category type IDs
23
+ * @since 4.0.0
18
24
  */
19
25
  export const TypeId = "~@effect/sql-sqlite-do/SqliteClient";
20
26
  /**
21
- * @category tags
22
- * @since 1.0.0
27
+ * Service tag for the Cloudflare Durable Object SQLite client service.
28
+ *
29
+ * **When to use**
30
+ *
31
+ * Use to access or provide a Durable Object SQLite client through the Effect
32
+ * context.
33
+ *
34
+ * @category services
35
+ * @since 4.0.0
23
36
  */
24
- export const SqliteClient = /*#__PURE__*/ServiceMap.Service("@effect/sql-sqlite-do/SqliteClient");
37
+ export const SqliteClient = /*#__PURE__*/Context.Service("@effect/sql-sqlite-do/SqliteClient");
25
38
  /**
26
- * @category constructor
27
- * @since 1.0.0
39
+ * Creates a scoped Cloudflare Durable Object SQLite client around `SqlStorage`, serializing access and converting returned `ArrayBuffer` values to `Uint8Array`.
40
+ *
41
+ * @category constructors
42
+ * @since 4.0.0
28
43
  */
29
44
  export const make = options => Effect.gen(function* () {
30
45
  const compiler = Statement.makeCompilerSqlite(options.transformQueryNames);
@@ -46,8 +61,7 @@ export const make = options => Effect.gen(function* () {
46
61
  const runStatement = (sql, params = []) => Effect.try({
47
62
  try: () => Array.from(runIterator(sql, params)),
48
63
  catch: cause => new SqlError({
49
- cause,
50
- message: `Failed to execute statement`
64
+ reason: classifyError(cause, "Failed to execute statement", "execute")
51
65
  })
52
66
  });
53
67
  const runValues = (sql, params = []) => Effect.try({
@@ -61,8 +75,7 @@ export const make = options => Effect.gen(function* () {
61
75
  return row;
62
76
  }),
63
77
  catch: cause => new SqlError({
64
- cause,
65
- message: `Failed to execute statement`
78
+ reason: classifyError(cause, "Failed to execute statement", "execute")
66
79
  })
67
80
  });
68
81
  return identity({
@@ -91,7 +104,7 @@ export const make = options => Effect.gen(function* () {
91
104
  const acquirer = semaphore.withPermits(1)(Effect.succeed(connection));
92
105
  const transactionAcquirer = Effect.uninterruptibleMask(restore => {
93
106
  const fiber = Fiber.getCurrent();
94
- const scope = ServiceMap.getUnsafe(fiber.services, Scope.Scope);
107
+ const scope = Context.getUnsafe(fiber.context, Scope.Scope);
95
108
  return Effect.as(Effect.tap(restore(semaphore.take(1)), () => Scope.addFinalizer(scope, semaphore.release(1))), connection);
96
109
  });
97
110
  return Object.assign(yield* Client.make({
@@ -106,13 +119,17 @@ export const make = options => Effect.gen(function* () {
106
119
  });
107
120
  });
108
121
  /**
122
+ * Creates a layer from a `Config`-wrapped Durable Object SQLite client configuration, providing both `SqliteClient` and `SqlClient`.
123
+ *
109
124
  * @category layers
110
- * @since 1.0.0
125
+ * @since 4.0.0
111
126
  */
112
- export const layerConfig = config => 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));
127
+ export const layerConfig = config => Layer.effectContext(Config.unwrap(config).pipe(Effect.flatMap(make), Effect.map(client => Context.make(SqliteClient, client).pipe(Context.add(Client.SqlClient, client))))).pipe(Layer.provide(Reactivity.layer));
113
128
  /**
129
+ * Creates a layer from a concrete Durable Object SQLite client configuration, providing both `SqliteClient` and `SqlClient`.
130
+ *
114
131
  * @category layers
115
- * @since 1.0.0
132
+ * @since 4.0.0
116
133
  */
117
- export const layer = config => Layer.effectServices(Effect.map(make(config), client => ServiceMap.make(SqliteClient, client).pipe(ServiceMap.add(Client.SqlClient, client)))).pipe(Layer.provide(Reactivity.layer));
134
+ export const layer = config => Layer.effectContext(Effect.map(make(config), client => Context.make(SqliteClient, client).pipe(Context.add(Client.SqlClient, client)))).pipe(Layer.provide(Reactivity.layer));
118
135
  //# sourceMappingURL=SqliteClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SqliteClient.js","names":["Config","Effect","Fiber","identity","Layer","Scope","Semaphore","ServiceMap","Stream","Reactivity","Client","SqlError","Statement","ATTR_DB_SYSTEM_NAME","TypeId","SqliteClient","Service","make","options","gen","compiler","makeCompilerSqlite","transformQueryNames","transformRows","transformResultNames","defaultTransforms","array","undefined","makeConnection","db","runIterator","sql","params","cursor","exec","columns","columnNames","result","raw","obj","i","length","value","ArrayBuffer","Uint8Array","runStatement","try","Array","from","catch","cause","message","runValues","row","execute","map","executeRaw","executeValues","executeUnprepared","executeStream","suspend","iterator","fromIteratorSucceed","pipe","mapArray","chunk","semaphore","connection","acquirer","withPermits","succeed","transactionAcquirer","uninterruptibleMask","restore","fiber","getCurrent","scope","getUnsafe","services","as","tap","take","addFinalizer","release","Object","assign","spanAttributes","entries","config","layerConfig","effectServices","unwrap","asEffect","flatMap","client","add","SqlClient","provide","layer"],"sources":["../src/SqliteClient.ts"],"sourcesContent":[null],"mappings":"AAIA,OAAO,KAAKA,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,SAAS,MAAM,kBAAkB;AAC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B,IAAI,CACxCxD,UAAU,CAACwF,GAAG,CAACrF,MAAM,CAACsF,SAAS,EAAEF,MAAM,CAAC,CACzC,CACF,CACF,CACF,CAAC/B,IAAI,CAAC3D,KAAK,CAAC6F,OAAO,CAACxF,UAAU,CAACyF,KAAK,CAAC,CAAC;AAEzC;;;;AAIA,OAAO,MAAMA,KAAK,GAChBV,MAA0B,IAE1BpF,KAAK,CAACsF,cAAc,CAClBzF,MAAM,CAACsD,GAAG,CAACtC,IAAI,CAACuE,MAAM,CAAC,EAAGM,MAAM,IAC9BvF,UAAU,CAACU,IAAI,CAACF,YAAY,EAAE+E,MAAM,CAAC,CAAC/B,IAAI,CACxCxD,UAAU,CAACwF,GAAG,CAACrF,MAAM,CAACsF,SAAS,EAAEF,MAAM,CAAC,CACzC,CAAC,CACL,CAAC/B,IAAI,CAAC3D,KAAK,CAAC6F,OAAO,CAACxF,UAAU,CAACyF,KAAK,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"SqliteClient.js","names":["Config","Context","Effect","Fiber","identity","Layer","Scope","Semaphore","Stream","Reactivity","Client","classifySqliteError","SqlError","Statement","ATTR_DB_SYSTEM_NAME","classifyError","cause","message","operation","TypeId","SqliteClient","Service","make","options","gen","compiler","makeCompilerSqlite","transformQueryNames","transformRows","transformResultNames","defaultTransforms","array","undefined","makeConnection","db","runIterator","sql","params","cursor","exec","columns","columnNames","result","raw","obj","i","length","value","ArrayBuffer","Uint8Array","runStatement","try","Array","from","catch","reason","runValues","row","execute","map","executeRaw","executeValues","executeUnprepared","executeStream","suspend","iterator","fromIteratorSucceed","pipe","mapArray","chunk","semaphore","connection","acquirer","withPermits","succeed","transactionAcquirer","uninterruptibleMask","restore","fiber","getCurrent","scope","getUnsafe","context","as","tap","take","addFinalizer","release","Object","assign","spanAttributes","entries","config","layerConfig","effectContext","unwrap","flatMap","client","add","SqlClient","provide","layer"],"sources":["../src/SqliteClient.ts"],"sourcesContent":[null],"mappings":"AAYA,OAAO,KAAKA,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C,GAAG,EAAE,CAAC,EACzE,CAAC5E,mBAAmB,EAAE,QAAQ,CAAC,CAChC;IACDc;GACD,CAAC,EACF;IACE,CAACT,MAAM,GAAGA,MAAgB;IAC1ByE,MAAM,EAAErE;GACT,CACF;AACH,CAAC,CAAC;AAEJ;;;;;;AAMA,OAAO,MAAMsE,WAAW,GACtBD,MAAuC,IAEvCvF,KAAK,CAACyF,aAAa,CACjB9F,MAAM,CAAC+F,MAAM,CAACH,MAAM,CAAC,CAACzB,IAAI,CACxBjE,MAAM,CAAC8F,OAAO,CAAC1E,IAAI,CAAC,EACpBpB,MAAM,CAACyD,GAAG,CAAEsC,MAAM,IAChBhG,OAAO,CAACqB,IAAI,CAACF,YAAY,EAAE6E,MAAM,CAAC,CAAC9B,IAAI,CACrClE,OAAO,CAACiG,GAAG,CAACxF,MAAM,CAACyF,SAAS,EAAEF,MAAM,CAAC,CACtC,CACF,CACF,CACF,CAAC9B,IAAI,CAAC9D,KAAK,CAAC+F,OAAO,CAAC3F,UAAU,CAAC4F,KAAK,CAAC,CAAC;AAEzC;;;;;;AAMA,OAAO,MAAMA,KAAK,GAChBT,MAA0B,IAE1BvF,KAAK,CAACyF,aAAa,CACjB5F,MAAM,CAACyD,GAAG,CAACrC,IAAI,CAACsE,MAAM,CAAC,EAAGK,MAAM,IAC9BhG,OAAO,CAACqB,IAAI,CAACF,YAAY,EAAE6E,MAAM,CAAC,CAAC9B,IAAI,CACrClE,OAAO,CAACiG,GAAG,CAACxF,MAAM,CAACyF,SAAS,EAAEF,MAAM,CAAC,CACtC,CAAC,CACL,CAAC9B,IAAI,CAAC9D,KAAK,CAAC+F,OAAO,CAAC3F,UAAU,CAAC4F,KAAK,CAAC,CAAC","ignoreList":[]}
@@ -1,5 +1,13 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Runs database migrations for Durable Object SQLite storage that uses Effect
3
+ * SQL.
4
+ *
5
+ * This module re-exports the shared migration loaders and errors, then provides
6
+ * `run` and `layer` helpers that apply pending migration files with the current
7
+ * `SqlClient`. The SQL client supplies the Durable Object storage connection;
8
+ * this module only handles migration execution.
9
+ *
10
+ * @since 4.0.0
3
11
  */
4
12
  import type * as Effect from "effect/Effect";
5
13
  import * as Layer from "effect/Layer";
@@ -7,17 +15,21 @@ import * as Migrator from "effect/unstable/sql/Migrator";
7
15
  import type * as Client from "effect/unstable/sql/SqlClient";
8
16
  import type { SqlError } from "effect/unstable/sql/SqlError";
9
17
  /**
10
- * @since 1.0.0
18
+ * @since 4.0.0
11
19
  */
12
20
  export * from "effect/unstable/sql/Migrator";
13
21
  /**
14
- * @category constructor
15
- * @since 1.0.0
22
+ * Runs SQL migrations using the configured `SqlClient`, returning the migrations that were applied.
23
+ *
24
+ * @category constructors
25
+ * @since 4.0.0
16
26
  */
17
27
  export declare const run: <R2 = never>({ loader, schemaDirectory, table }: Migrator.MigratorOptions<R2>) => Effect.Effect<ReadonlyArray<readonly [id: number, name: string]>, Migrator.MigrationError | SqlError, Client.SqlClient | R2>;
18
28
  /**
19
- * @category constructor
20
- * @since 1.0.0
29
+ * Creates a layer that runs the configured SQL migrations during layer construction.
30
+ *
31
+ * @category constructors
32
+ * @since 4.0.0
21
33
  */
22
34
  export declare const layer: <R>(options: Migrator.MigratorOptions<R>) => Layer.Layer<never, Migrator.MigrationError | SqlError, Client.SqlClient | R>;
23
35
  //# sourceMappingURL=SqliteMigrator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SqliteMigrator.d.ts","sourceRoot":"","sources":["../src/SqliteMigrator.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,8BAA8B,CAAA;AACxD,OAAO,KAAK,KAAK,MAAM,MAAM,+BAA+B,CAAA;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAE5D;;GAE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AM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,EAClD,QAAQ,CAAC,cAAc,GAAG,QAAQ,EAClC,MAAM,CAAC,SAAS,GAAG,EAAE,CACF,CAAA;AAErB;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,EACrB,SAAS,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,KACnC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,cAAc,GAAG,QAAQ,EAAE,MAAM,CAAC,SAAS,GAAG,CAAC,CAAsC,CAAA"}
@@ -1,17 +1,21 @@
1
1
  import * as Layer from "effect/Layer";
2
2
  import * as Migrator from "effect/unstable/sql/Migrator";
3
3
  /**
4
- * @since 1.0.0
4
+ * @since 4.0.0
5
5
  */
6
6
  export * from "effect/unstable/sql/Migrator";
7
7
  /**
8
- * @category constructor
9
- * @since 1.0.0
8
+ * Runs SQL migrations using the configured `SqlClient`, returning the migrations that were applied.
9
+ *
10
+ * @category constructors
11
+ * @since 4.0.0
10
12
  */
11
13
  export const run = /*#__PURE__*/Migrator.make({});
12
14
  /**
13
- * @category constructor
14
- * @since 1.0.0
15
+ * Creates a layer that runs the configured SQL migrations during layer construction.
16
+ *
17
+ * @category constructors
18
+ * @since 4.0.0
15
19
  */
16
20
  export const layer = options => Layer.effectDiscard(run(options));
17
21
  //# sourceMappingURL=SqliteMigrator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SqliteMigrator.js","names":["Layer","Migrator","run","make","layer","options","effectDiscard"],"sources":["../src/SqliteMigrator.ts"],"sourcesContent":[null],"mappings":"AAIA,OAAO,KAAKA,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,QAAQ,MAAM,8BAA8B;AAIxD;;;AAGA,cAAc,8BAA8B;AAE5C;;;;AAIA,OAAO,MAAMC,GAAG,gBAMZD,QAAQ,CAACE,IAAI,CAAC,EAAE,CAAC;AAErB;;;;AAIA,OAAO,MAAMC,KAAK,GAChBC,OAAoC,IAC6CL,KAAK,CAACM,aAAa,CAACJ,GAAG,CAACG,OAAO,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"SqliteMigrator.js","names":["Layer","Migrator","run","make","layer","options","effectDiscard"],"sources":["../src/SqliteMigrator.ts"],"sourcesContent":[null],"mappings":"AAYA,OAAO,KAAKA,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,QAAQ,MAAM,8BAA8B;AAIxD;;;AAGA,cAAc,8BAA8B;AAE5C;;;;;;AAMA,OAAO,MAAMC,GAAG,gBAMZD,QAAQ,CAACE,IAAI,CAAC,EAAE,CAAC;AAErB;;;;;;AAMA,OAAO,MAAMC,KAAK,GAChBC,OAAoC,IAC6CL,KAAK,CAACM,aAAa,CAACJ,GAAG,CAACG,OAAO,CAAC,CAAC","ignoreList":[]}
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * @since 4.0.0
3
3
  */
4
4
  /**
5
- * @since 1.0.0
5
+ * @since 4.0.0
6
6
  */
7
7
  export * as SqliteClient from "./SqliteClient.ts";
8
8
  /**
9
- * @since 1.0.0
9
+ * @since 4.0.0
10
10
  */
11
11
  export * as SqliteMigrator from "./SqliteMigrator.ts";
12
12
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * @since 4.0.0
3
3
  */
4
4
  // @barrel: Auto-generated exports. Do not edit manually.
5
5
  /**
6
- * @since 1.0.0
6
+ * @since 4.0.0
7
7
  */
8
8
  export * as SqliteClient from "./SqliteClient.js";
9
9
  /**
10
- * @since 1.0.0
10
+ * @since 4.0.0
11
11
  */
12
12
  export * as SqliteMigrator from "./SqliteMigrator.js";
13
13
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect/sql-sqlite-do",
3
- "version": "4.0.0-beta.8",
3
+ "version": "4.0.0-beta.81",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "A SQLite toolkit for Effect",
@@ -43,11 +43,11 @@
43
43
  "provenance": true
44
44
  },
45
45
  "devDependencies": {
46
- "@cloudflare/workers-types": "^4.20260131.0",
47
- "effect": "^4.0.0-beta.8"
46
+ "@cloudflare/workers-types": "^4.20260511.1",
47
+ "effect": "^4.0.0-beta.81"
48
48
  },
49
49
  "peerDependencies": {
50
- "effect": "^4.0.0-beta.8"
50
+ "effect": "^4.0.0-beta.81"
51
51
  },
52
52
  "scripts": {
53
53
  "codegen": "effect-utils codegen",
@@ -1,39 +1,56 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Connects Effect SQL to SQLite storage inside Cloudflare Durable Objects.
3
+ *
4
+ * This module wraps a Durable Object `SqlStorage` handle and exposes it as both
5
+ * `SqliteClient` and the generic Effect SQL client. It serializes access,
6
+ * supports normal and streaming queries, converts returned `ArrayBuffer` values
7
+ * to `Uint8Array`, and provides layers for wiring the client into an Effect
8
+ * application. `updateValues` is not supported by this driver.
9
+ *
10
+ * @since 4.0.0
3
11
  */
4
12
  import type { SqlStorage } from "@cloudflare/workers-types"
5
13
  import * as Config from "effect/Config"
14
+ import * as Context from "effect/Context"
6
15
  import * as Effect from "effect/Effect"
7
16
  import * as Fiber from "effect/Fiber"
8
17
  import { identity } from "effect/Function"
9
18
  import * as Layer from "effect/Layer"
10
19
  import * as Scope from "effect/Scope"
11
20
  import * as Semaphore from "effect/Semaphore"
12
- import * as ServiceMap from "effect/ServiceMap"
13
21
  import * as Stream from "effect/Stream"
14
22
  import * as Reactivity from "effect/unstable/reactivity/Reactivity"
15
23
  import * as Client from "effect/unstable/sql/SqlClient"
16
24
  import type { Connection } from "effect/unstable/sql/SqlConnection"
17
- import { SqlError } from "effect/unstable/sql/SqlError"
25
+ import { classifySqliteError, SqlError } from "effect/unstable/sql/SqlError"
18
26
  import * as Statement from "effect/unstable/sql/Statement"
19
27
 
20
28
  const ATTR_DB_SYSTEM_NAME = "db.system.name"
21
29
 
30
+ const classifyError = (cause: unknown, message: string, operation: string) =>
31
+ classifySqliteError(cause, { message, operation })
32
+
22
33
  /**
23
- * @category type ids
24
- * @since 1.0.0
34
+ * Runtime type identifier used to mark Cloudflare Durable Object `SqliteClient` values.
35
+ *
36
+ * @category type IDs
37
+ * @since 4.0.0
25
38
  */
26
39
  export const TypeId: TypeId = "~@effect/sql-sqlite-do/SqliteClient"
27
40
 
28
41
  /**
29
- * @category type ids
30
- * @since 1.0.0
42
+ * Type-level identifier used to mark Cloudflare Durable Object `SqliteClient` values.
43
+ *
44
+ * @category type IDs
45
+ * @since 4.0.0
31
46
  */
32
47
  export type TypeId = "~@effect/sql-sqlite-do/SqliteClient"
33
48
 
34
49
  /**
50
+ * Cloudflare Durable Object SQLite client service, extending `SqlClient` with its configuration. `updateValues` is not supported.
51
+ *
35
52
  * @category models
36
- * @since 1.0.0
53
+ * @since 4.0.0
37
54
  */
38
55
  export interface SqliteClient extends Client.SqlClient {
39
56
  readonly [TypeId]: TypeId
@@ -44,14 +61,23 @@ export interface SqliteClient extends Client.SqlClient {
44
61
  }
45
62
 
46
63
  /**
47
- * @category tags
48
- * @since 1.0.0
64
+ * Service tag for the Cloudflare Durable Object SQLite client service.
65
+ *
66
+ * **When to use**
67
+ *
68
+ * Use to access or provide a Durable Object SQLite client through the Effect
69
+ * context.
70
+ *
71
+ * @category services
72
+ * @since 4.0.0
49
73
  */
50
- export const SqliteClient = ServiceMap.Service<SqliteClient>("@effect/sql-sqlite-do/SqliteClient")
74
+ export const SqliteClient = Context.Service<SqliteClient>("@effect/sql-sqlite-do/SqliteClient")
51
75
 
52
76
  /**
77
+ * Configuration for a Cloudflare Durable Object SQLite client, including the `SqlStorage` handle, span attributes, and query/result name transforms.
78
+ *
53
79
  * @category models
54
- * @since 1.0.0
80
+ * @since 4.0.0
55
81
  */
56
82
  export interface SqliteClientConfig {
57
83
  readonly db: SqlStorage
@@ -62,8 +88,10 @@ export interface SqliteClientConfig {
62
88
  }
63
89
 
64
90
  /**
65
- * @category constructor
66
- * @since 1.0.0
91
+ * Creates a scoped Cloudflare Durable Object SQLite client around `SqlStorage`, serializing access and converting returned `ArrayBuffer` values to `Uint8Array`.
92
+ *
93
+ * @category constructors
94
+ * @since 4.0.0
67
95
  */
68
96
  export const make = (
69
97
  options: SqliteClientConfig
@@ -99,7 +127,7 @@ export const make = (
99
127
  ): Effect.Effect<ReadonlyArray<any>, SqlError, never> =>
100
128
  Effect.try({
101
129
  try: () => Array.from(runIterator(sql, params)),
102
- catch: (cause) => new SqlError({ cause, message: `Failed to execute statement` })
130
+ catch: (cause) => new SqlError({ reason: classifyError(cause, "Failed to execute statement", "execute") })
103
131
  })
104
132
 
105
133
  const runValues = (
@@ -117,7 +145,7 @@ export const make = (
117
145
  }
118
146
  return row
119
147
  }),
120
- catch: (cause) => new SqlError({ cause, message: `Failed to execute statement` })
148
+ catch: (cause) => new SqlError({ reason: classifyError(cause, "Failed to execute statement", "execute") })
121
149
  })
122
150
 
123
151
  return identity<Connection>({
@@ -156,7 +184,7 @@ export const make = (
156
184
  const acquirer = semaphore.withPermits(1)(Effect.succeed(connection))
157
185
  const transactionAcquirer = Effect.uninterruptibleMask((restore) => {
158
186
  const fiber = Fiber.getCurrent()!
159
- const scope = ServiceMap.getUnsafe(fiber.services, Scope.Scope)
187
+ const scope = Context.getUnsafe(fiber.context, Scope.Scope)
160
188
  return Effect.as(
161
189
  Effect.tap(
162
190
  restore(semaphore.take(1)),
@@ -185,33 +213,37 @@ export const make = (
185
213
  })
186
214
 
187
215
  /**
216
+ * Creates a layer from a `Config`-wrapped Durable Object SQLite client configuration, providing both `SqliteClient` and `SqlClient`.
217
+ *
188
218
  * @category layers
189
- * @since 1.0.0
219
+ * @since 4.0.0
190
220
  */
191
221
  export const layerConfig = (
192
222
  config: Config.Wrap<SqliteClientConfig>
193
223
  ): Layer.Layer<SqliteClient | Client.SqlClient, Config.ConfigError> =>
194
- Layer.effectServices(
195
- Config.unwrap(config).asEffect().pipe(
224
+ Layer.effectContext(
225
+ Config.unwrap(config).pipe(
196
226
  Effect.flatMap(make),
197
227
  Effect.map((client) =>
198
- ServiceMap.make(SqliteClient, client).pipe(
199
- ServiceMap.add(Client.SqlClient, client)
228
+ Context.make(SqliteClient, client).pipe(
229
+ Context.add(Client.SqlClient, client)
200
230
  )
201
231
  )
202
232
  )
203
233
  ).pipe(Layer.provide(Reactivity.layer))
204
234
 
205
235
  /**
236
+ * Creates a layer from a concrete Durable Object SQLite client configuration, providing both `SqliteClient` and `SqlClient`.
237
+ *
206
238
  * @category layers
207
- * @since 1.0.0
239
+ * @since 4.0.0
208
240
  */
209
241
  export const layer = (
210
242
  config: SqliteClientConfig
211
243
  ): Layer.Layer<SqliteClient | Client.SqlClient> =>
212
- Layer.effectServices(
244
+ Layer.effectContext(
213
245
  Effect.map(make(config), (client) =>
214
- ServiceMap.make(SqliteClient, client).pipe(
215
- ServiceMap.add(Client.SqlClient, client)
246
+ Context.make(SqliteClient, client).pipe(
247
+ Context.add(Client.SqlClient, client)
216
248
  ))
217
249
  ).pipe(Layer.provide(Reactivity.layer))
@@ -1,5 +1,13 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Runs database migrations for Durable Object SQLite storage that uses Effect
3
+ * SQL.
4
+ *
5
+ * This module re-exports the shared migration loaders and errors, then provides
6
+ * `run` and `layer` helpers that apply pending migration files with the current
7
+ * `SqlClient`. The SQL client supplies the Durable Object storage connection;
8
+ * this module only handles migration execution.
9
+ *
10
+ * @since 4.0.0
3
11
  */
4
12
  import type * as Effect from "effect/Effect"
5
13
  import * as Layer from "effect/Layer"
@@ -8,13 +16,15 @@ import type * as Client from "effect/unstable/sql/SqlClient"
8
16
  import type { SqlError } from "effect/unstable/sql/SqlError"
9
17
 
10
18
  /**
11
- * @since 1.0.0
19
+ * @since 4.0.0
12
20
  */
13
21
  export * from "effect/unstable/sql/Migrator"
14
22
 
15
23
  /**
16
- * @category constructor
17
- * @since 1.0.0
24
+ * Runs SQL migrations using the configured `SqlClient`, returning the migrations that were applied.
25
+ *
26
+ * @category constructors
27
+ * @since 4.0.0
18
28
  */
19
29
  export const run: <R2 = never>(
20
30
  { loader, schemaDirectory, table }: Migrator.MigratorOptions<R2>
@@ -25,8 +35,10 @@ export const run: <R2 = never>(
25
35
  > = Migrator.make({})
26
36
 
27
37
  /**
28
- * @category constructor
29
- * @since 1.0.0
38
+ * Creates a layer that runs the configured SQL migrations during layer construction.
39
+ *
40
+ * @category constructors
41
+ * @since 4.0.0
30
42
  */
31
43
  export const layer = <R>(
32
44
  options: Migrator.MigratorOptions<R>
package/src/index.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * @since 4.0.0
3
3
  */
4
4
 
5
5
  // @barrel: Auto-generated exports. Do not edit manually.
6
6
 
7
7
  /**
8
- * @since 1.0.0
8
+ * @since 4.0.0
9
9
  */
10
10
  export * as SqliteClient from "./SqliteClient.ts"
11
11
 
12
12
  /**
13
- * @since 1.0.0
13
+ * @since 4.0.0
14
14
  */
15
15
  export * as SqliteMigrator from "./SqliteMigrator.ts"