@effect/sql-pglite 4.0.0-beta.66 → 4.0.0-beta.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PgliteClient.d.ts +77 -25
- package/dist/PgliteClient.d.ts.map +1 -1
- package/dist/PgliteClient.js +48 -13
- package/dist/PgliteClient.js.map +1 -1
- package/dist/PgliteMigrator.d.ts +30 -6
- package/dist/PgliteMigrator.d.ts.map +1 -1
- package/dist/PgliteMigrator.js +9 -5
- package/dist/PgliteMigrator.js.map +1 -1
- package/dist/index.d.ts +42 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/PgliteClient.ts +77 -25
- package/src/PgliteMigrator.ts +30 -6
- package/src/index.ts +42 -3
package/dist/PgliteClient.d.ts
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Embedded PostgreSQL client implementation for Effect SQL, backed by
|
|
3
|
+
* `@electric-sql/pglite`.
|
|
4
|
+
*
|
|
5
|
+
* This module exposes constructors and layers for providing a `PgliteClient`
|
|
6
|
+
* as both the PGlite-specific service and the generic `SqlClient`. It can
|
|
7
|
+
* create a scoped `PGlite` instance from constructor options or wrap a
|
|
8
|
+
* caller-owned `liveClient`, making it useful for local-first browser storage,
|
|
9
|
+
* web worker databases, tests, demos, migrations, and development tools that
|
|
10
|
+
* want PostgreSQL syntax without connecting to a separate PostgreSQL server.
|
|
11
|
+
*
|
|
12
|
+
* The client uses the PostgreSQL statement compiler and adds PGlite-specific
|
|
13
|
+
* access to the underlying instance, JSON fragments, LISTEN/NOTIFY streams,
|
|
14
|
+
* data directory dumps, and array type refresh. Because PGlite is embedded in
|
|
15
|
+
* the current JavaScript runtime, operations share the supplied instance and
|
|
16
|
+
* are serialized by this client; a `liveClient` remains caller-owned and is not
|
|
17
|
+
* closed by the layer. In browsers or workers, persistence, durability,
|
|
18
|
+
* extension availability, and lifecycle all follow the selected PGlite
|
|
19
|
+
* `dataDir`/runtime rather than a hosted PostgreSQL process.
|
|
20
|
+
*
|
|
21
|
+
* @since 4.0.0
|
|
3
22
|
*/
|
|
4
23
|
import { type PGliteInterface, type PGliteOptions } from "@electric-sql/pglite";
|
|
5
24
|
import * as Config from "effect/Config";
|
|
@@ -14,18 +33,24 @@ import { SqlError } from "effect/unstable/sql/SqlError";
|
|
|
14
33
|
import type { Custom, Fragment } from "effect/unstable/sql/Statement";
|
|
15
34
|
import * as Statement from "effect/unstable/sql/Statement";
|
|
16
35
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
36
|
+
* Runtime type identifier used to mark `PgliteClient` values.
|
|
37
|
+
*
|
|
38
|
+
* @category type IDs
|
|
39
|
+
* @since 4.0.0
|
|
19
40
|
*/
|
|
20
41
|
export declare const TypeId: TypeId;
|
|
21
42
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
43
|
+
* Type-level identifier used to mark `PgliteClient` values.
|
|
44
|
+
*
|
|
45
|
+
* @category type IDs
|
|
46
|
+
* @since 4.0.0
|
|
24
47
|
*/
|
|
25
48
|
export type TypeId = "~@effect/sql-pglite/PgliteClient";
|
|
26
49
|
/**
|
|
50
|
+
* PGlite-backed PostgreSQL client service, extending `SqlClient` with access to the PGlite instance, JSON fragments, LISTEN/NOTIFY, data directory dumps, and array type refresh.
|
|
51
|
+
*
|
|
27
52
|
* @category models
|
|
28
|
-
* @since
|
|
53
|
+
* @since 4.0.0
|
|
29
54
|
*/
|
|
30
55
|
export interface PgliteClient extends Client.SqlClient {
|
|
31
56
|
readonly [TypeId]: TypeId;
|
|
@@ -38,23 +63,30 @@ export interface PgliteClient extends Client.SqlClient {
|
|
|
38
63
|
readonly refreshArrayTypes: Effect.Effect<void, SqlError>;
|
|
39
64
|
}
|
|
40
65
|
/**
|
|
66
|
+
* Context tag used to access the `PgliteClient` service.
|
|
67
|
+
*
|
|
41
68
|
* @category tags
|
|
42
|
-
* @since
|
|
69
|
+
* @since 4.0.0
|
|
43
70
|
*/
|
|
44
71
|
export declare const PgliteClient: Context.Service<PgliteClient, PgliteClient>;
|
|
45
72
|
/**
|
|
73
|
+
* Configuration for a PGlite client, either by supplying PGlite creation options or an existing live PGlite client.
|
|
74
|
+
*
|
|
46
75
|
* @category models
|
|
47
|
-
* @since
|
|
76
|
+
* @since 4.0.0
|
|
48
77
|
*/
|
|
49
78
|
export type PgliteClientConfig = PgliteClientConfig.Create | PgliteClientConfig.Live;
|
|
50
79
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
80
|
+
* Namespace containing the configuration variants for `PgliteClient`.
|
|
81
|
+
*
|
|
82
|
+
* @since 4.0.0
|
|
53
83
|
*/
|
|
54
84
|
export declare namespace PgliteClientConfig {
|
|
55
85
|
/**
|
|
86
|
+
* Shared PGlite client options for span attributes, query/result name transformations, and JSON value transformation.
|
|
87
|
+
*
|
|
56
88
|
* @category models
|
|
57
|
-
* @since
|
|
89
|
+
* @since 4.0.0
|
|
58
90
|
*/
|
|
59
91
|
interface Base {
|
|
60
92
|
readonly spanAttributes?: Record<string, unknown> | undefined;
|
|
@@ -63,21 +95,27 @@ export declare namespace PgliteClientConfig {
|
|
|
63
95
|
readonly transformJson?: boolean | undefined;
|
|
64
96
|
}
|
|
65
97
|
/**
|
|
98
|
+
* Configuration used to create a managed PGlite instance from PGlite constructor options.
|
|
99
|
+
*
|
|
66
100
|
* @category models
|
|
67
|
-
* @since
|
|
101
|
+
* @since 4.0.0
|
|
68
102
|
*/
|
|
69
103
|
interface Create extends Base, PGliteOptions {
|
|
70
104
|
}
|
|
71
105
|
/**
|
|
106
|
+
* Configuration that uses an existing PGlite client. The supplied `liveClient` is caller-owned and is not closed by the Effect client.
|
|
107
|
+
*
|
|
72
108
|
* @category models
|
|
73
|
-
* @since
|
|
109
|
+
* @since 4.0.0
|
|
74
110
|
*/
|
|
75
111
|
interface Live extends Base {
|
|
76
112
|
readonly liveClient: PGliteInterface;
|
|
77
113
|
}
|
|
78
114
|
/**
|
|
115
|
+
* Config-friendly subset of PGlite creation options, including data directory, username, database, relaxed durability, and shared transform options.
|
|
116
|
+
*
|
|
79
117
|
* @category models
|
|
80
|
-
* @since
|
|
118
|
+
* @since 4.0.0
|
|
81
119
|
*/
|
|
82
120
|
interface ConfigBase extends Base {
|
|
83
121
|
readonly dataDir?: string | undefined;
|
|
@@ -87,45 +125,59 @@ export declare namespace PgliteClientConfig {
|
|
|
87
125
|
}
|
|
88
126
|
}
|
|
89
127
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
128
|
+
* Creates a scoped PGlite SQL client. When no live client is supplied it creates and closes a PGlite instance; when `liveClient` is supplied, the caller retains ownership.
|
|
129
|
+
*
|
|
130
|
+
* @category constructors
|
|
131
|
+
* @since 4.0.0
|
|
92
132
|
*/
|
|
93
133
|
export declare const make: (options?: PgliteClientConfig) => Effect.Effect<PgliteClient, SqlError, Scope.Scope | Reactivity.Reactivity>;
|
|
94
134
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
135
|
+
* Builds a `PgliteClient` around an existing PGlite instance, adding SQL client operations, LISTEN/NOTIFY, dump helpers, and serialized access.
|
|
136
|
+
*
|
|
137
|
+
* @category constructors
|
|
138
|
+
* @since 4.0.0
|
|
97
139
|
*/
|
|
98
140
|
export declare const fromClient: (options: PgliteClientConfig.Base & {
|
|
99
141
|
readonly liveClient: PGliteInterface;
|
|
100
142
|
}) => Effect.Effect<PgliteClient, SqlError, Scope.Scope | Reactivity.Reactivity>;
|
|
101
143
|
/**
|
|
144
|
+
* Creates a layer from an effect that acquires a `PgliteClient`, providing both `PgliteClient` and `SqlClient`.
|
|
145
|
+
*
|
|
102
146
|
* @category layers
|
|
103
|
-
* @since
|
|
147
|
+
* @since 4.0.0
|
|
104
148
|
*/
|
|
105
149
|
export declare const layerFrom: <E, R>(acquire: Effect.Effect<PgliteClient, E, R>) => Layer.Layer<PgliteClient | Client.SqlClient, E, Exclude<R, Scope.Scope | Reactivity.Reactivity>>;
|
|
106
150
|
/**
|
|
151
|
+
* Creates a layer from a `Config`-wrapped PGlite client configuration, providing both `PgliteClient` and `SqlClient`.
|
|
152
|
+
*
|
|
107
153
|
* @category layers
|
|
108
|
-
* @since
|
|
154
|
+
* @since 4.0.0
|
|
109
155
|
*/
|
|
110
156
|
export declare const layerConfig: (config: Config.Wrap<PgliteClientConfig.ConfigBase>) => Layer.Layer<PgliteClient | Client.SqlClient, Config.ConfigError | SqlError>;
|
|
111
157
|
/**
|
|
158
|
+
* Creates a layer from a concrete PGlite client configuration, providing both `PgliteClient` and `SqlClient`.
|
|
159
|
+
*
|
|
112
160
|
* @category layers
|
|
113
|
-
* @since
|
|
161
|
+
* @since 4.0.0
|
|
114
162
|
*/
|
|
115
163
|
export declare const layer: (config?: PgliteClientConfig | undefined) => Layer.Layer<PgliteClient | Client.SqlClient, SqlError>;
|
|
116
164
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
165
|
+
* Creates the PGlite statement compiler, using PostgreSQL `$1` placeholders, double-quoted identifiers, returning clauses, and optional JSON value transformation.
|
|
166
|
+
*
|
|
167
|
+
* @category constructors
|
|
168
|
+
* @since 4.0.0
|
|
119
169
|
*/
|
|
120
170
|
export declare const makeCompiler: (transform?: (_: string) => string, transformJson?: boolean) => Statement.Compiler;
|
|
121
171
|
/**
|
|
172
|
+
* PGlite-specific custom statement fragments supported by the compiler, currently JSON parameter fragments.
|
|
173
|
+
*
|
|
122
174
|
* @category custom types
|
|
123
|
-
* @since
|
|
175
|
+
* @since 4.0.0
|
|
124
176
|
*/
|
|
125
177
|
export type PgCustom = PgJson;
|
|
126
178
|
/**
|
|
127
179
|
* @category custom types
|
|
128
|
-
* @since
|
|
180
|
+
* @since 4.0.0
|
|
129
181
|
*/
|
|
130
182
|
interface PgJson extends Custom<"PgJson", unknown> {
|
|
131
183
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PgliteClient.d.ts","sourceRoot":"","sources":["../src/PgliteClient.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"PgliteClient.d.ts","sourceRoot":"","sources":["../src/PgliteClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAU,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACvF,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,UAAU,MAAM,uCAAuC,CAAA;AACnE,OAAO,KAAK,MAAM,MAAM,+BAA+B,CAAA;AAEvD,OAAO,EAQL,QAAQ,EAKT,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AACrE,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,MAAM,EAAE,MAA2C,CAAA;AAEhE;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG,kCAAkC,CAAA;AAEvD;;;;;GAKG;AACH,MAAM,WAAW,YAAa,SAAQ,MAAM,CAAC,SAAS;IACpD,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAA;IACnC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAA;IAChC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,QAAQ,CAAA;IACvC,QAAQ,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,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,GAAG,QAAQ,CAM3E,CAAA;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAChB,SAAS,kBAAkB,GAAG,SAAS,KACtC,KAAK,CAAC,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,SAAS,EAAE,QAAQ,CAA4B,CAAA;AAEpF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GACvB,YAAY,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,EACjC,uBAAoB,KACnB,SAAS,CAAC,QAsCZ,CAAA;AAKD;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAA;AAE7B;;;GAGG;AACH,UAAU,MAAO,SAAQ,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC;CAAG;AACrD,QAAA,MAAM,MAAM,yDAAqC,CAAA"}
|
package/dist/PgliteClient.js
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Embedded PostgreSQL client implementation for Effect SQL, backed by
|
|
3
|
+
* `@electric-sql/pglite`.
|
|
4
|
+
*
|
|
5
|
+
* This module exposes constructors and layers for providing a `PgliteClient`
|
|
6
|
+
* as both the PGlite-specific service and the generic `SqlClient`. It can
|
|
7
|
+
* create a scoped `PGlite` instance from constructor options or wrap a
|
|
8
|
+
* caller-owned `liveClient`, making it useful for local-first browser storage,
|
|
9
|
+
* web worker databases, tests, demos, migrations, and development tools that
|
|
10
|
+
* want PostgreSQL syntax without connecting to a separate PostgreSQL server.
|
|
11
|
+
*
|
|
12
|
+
* The client uses the PostgreSQL statement compiler and adds PGlite-specific
|
|
13
|
+
* access to the underlying instance, JSON fragments, LISTEN/NOTIFY streams,
|
|
14
|
+
* data directory dumps, and array type refresh. Because PGlite is embedded in
|
|
15
|
+
* the current JavaScript runtime, operations share the supplied instance and
|
|
16
|
+
* are serialized by this client; a `liveClient` remains caller-owned and is not
|
|
17
|
+
* closed by the layer. In browsers or workers, persistence, durability,
|
|
18
|
+
* extension availability, and lifecycle all follow the selected PGlite
|
|
19
|
+
* `dataDir`/runtime rather than a hosted PostgreSQL process.
|
|
20
|
+
*
|
|
21
|
+
* @since 4.0.0
|
|
3
22
|
*/
|
|
4
23
|
import { PGlite } from "@electric-sql/pglite";
|
|
5
24
|
import * as Config from "effect/Config";
|
|
@@ -16,18 +35,24 @@ import * as Client from "effect/unstable/sql/SqlClient";
|
|
|
16
35
|
import { AuthenticationError, AuthorizationError, ConnectionError, ConstraintError, DeadlockError, LockTimeoutError, SerializationError, SqlError, SqlSyntaxError, StatementTimeoutError, UniqueViolation, UnknownError } from "effect/unstable/sql/SqlError";
|
|
17
36
|
import * as Statement from "effect/unstable/sql/Statement";
|
|
18
37
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
38
|
+
* Runtime type identifier used to mark `PgliteClient` values.
|
|
39
|
+
*
|
|
40
|
+
* @category type IDs
|
|
41
|
+
* @since 4.0.0
|
|
21
42
|
*/
|
|
22
43
|
export const TypeId = "~@effect/sql-pglite/PgliteClient";
|
|
23
44
|
/**
|
|
45
|
+
* Context tag used to access the `PgliteClient` service.
|
|
46
|
+
*
|
|
24
47
|
* @category tags
|
|
25
|
-
* @since
|
|
48
|
+
* @since 4.0.0
|
|
26
49
|
*/
|
|
27
50
|
export const PgliteClient = /*#__PURE__*/Context.Service("@effect/sql-pglite/PgliteClient");
|
|
28
51
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
52
|
+
* Creates a scoped PGlite SQL client. When no live client is supplied it creates and closes a PGlite instance; when `liveClient` is supplied, the caller retains ownership.
|
|
53
|
+
*
|
|
54
|
+
* @category constructors
|
|
55
|
+
* @since 4.0.0
|
|
31
56
|
*/
|
|
32
57
|
export const make = (options = {}) => Effect.gen(function* () {
|
|
33
58
|
const pglite = "liveClient" in options ? options.liveClient : yield* Effect.acquireRelease(Effect.tryPromise({
|
|
@@ -48,8 +73,10 @@ export const make = (options = {}) => Effect.gen(function* () {
|
|
|
48
73
|
});
|
|
49
74
|
});
|
|
50
75
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
76
|
+
* Builds a `PgliteClient` around an existing PGlite instance, adding SQL client operations, LISTEN/NOTIFY, dump helpers, and serialized access.
|
|
77
|
+
*
|
|
78
|
+
* @category constructors
|
|
79
|
+
* @since 4.0.0
|
|
53
80
|
*/
|
|
54
81
|
export const fromClient = options => Effect.gen(function* () {
|
|
55
82
|
const pglite = options.liveClient;
|
|
@@ -150,23 +177,31 @@ class PgliteConnection {
|
|
|
150
177
|
}
|
|
151
178
|
}
|
|
152
179
|
/**
|
|
180
|
+
* Creates a layer from an effect that acquires a `PgliteClient`, providing both `PgliteClient` and `SqlClient`.
|
|
181
|
+
*
|
|
153
182
|
* @category layers
|
|
154
|
-
* @since
|
|
183
|
+
* @since 4.0.0
|
|
155
184
|
*/
|
|
156
185
|
export const layerFrom = acquire => Layer.effectContext(Effect.map(acquire, client => Context.make(PgliteClient, client).pipe(Context.add(Client.SqlClient, client)))).pipe(Layer.provide(Reactivity.layer));
|
|
157
186
|
/**
|
|
187
|
+
* Creates a layer from a `Config`-wrapped PGlite client configuration, providing both `PgliteClient` and `SqlClient`.
|
|
188
|
+
*
|
|
158
189
|
* @category layers
|
|
159
|
-
* @since
|
|
190
|
+
* @since 4.0.0
|
|
160
191
|
*/
|
|
161
192
|
export const layerConfig = config => layerFrom(Effect.flatMap(Config.unwrap(config), resolved => make(resolved)));
|
|
162
193
|
/**
|
|
194
|
+
* Creates a layer from a concrete PGlite client configuration, providing both `PgliteClient` and `SqlClient`.
|
|
195
|
+
*
|
|
163
196
|
* @category layers
|
|
164
|
-
* @since
|
|
197
|
+
* @since 4.0.0
|
|
165
198
|
*/
|
|
166
199
|
export const layer = config => layerFrom(make(config));
|
|
167
200
|
/**
|
|
168
|
-
*
|
|
169
|
-
*
|
|
201
|
+
* Creates the PGlite statement compiler, using PostgreSQL `$1` placeholders, double-quoted identifiers, returning clauses, and optional JSON value transformation.
|
|
202
|
+
*
|
|
203
|
+
* @category constructors
|
|
204
|
+
* @since 4.0.0
|
|
170
205
|
*/
|
|
171
206
|
export const makeCompiler = (transform, transformJson = true) => {
|
|
172
207
|
const transformValue = transformJson && transform ? Statement.defaultTransforms(transform).value : undefined;
|
package/dist/PgliteClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PgliteClient.js","names":["PGlite","Config","Context","Effect","Fiber","Layer","Queue","Scope","Semaphore","Stream","Reactivity","Client","AuthenticationError","AuthorizationError","ConnectionError","ConstraintError","DeadlockError","LockTimeoutError","SerializationError","SqlError","SqlSyntaxError","StatementTimeoutError","UniqueViolation","UnknownError","Statement","TypeId","PgliteClient","Service","make","options","gen","pglite","liveClient","acquireRelease","tryPromise","try","pg","waitReady","catch","cause","reason","classifyError","promise","close","pipe","timeoutOption","interruptible","fromClient","compiler","makeCompiler","transformQueryNames","transformJson","transformRows","transformResultNames","defaultTransforms","array","undefined","spanAttributes","Object","entries","ATTR_DB_SYSTEM_NAME","connection","PgliteConnection","semaphore","makeUnsafe","acquirer","withPermits","succeed","transactionAcquirer","uninterruptibleMask","restore","fiber","getCurrent","scope","getUnsafe","context","as","tap","take","addFinalizer","release","config","client","assign","json","_","fragment","PgJson","listen","channel","callback","queue","payload","offerUnsafe","unlisten","notify","exec","escape","escapeLiteral","withPermit","asVoid","dumpDataDir","compression","refreshArrayTypes","constructor","run","method","sql","params","map","query","result","rows","execute","executeRaw","executeValues","rowMode","executeUnprepared","executeStream","eff","fromArrayEffect","layerFrom","acquire","effectContext","add","SqlClient","provide","layer","layerConfig","flatMap","unwrap","resolved","transform","transformValue","value","dialect","placeholder","onIdentifier","withoutTransform","onRecordUpdate","placeholders","valueAlias","valueColumns","values","returning","flat","concat","onCustom","type","kind","paramA","defaultEscape","replace","custom","pgCodeFromCause","code","pgConstraintFromCause","constraint","normalized","trim","length","message","operation","props","startsWith"],"sources":["../src/PgliteClient.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAG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AI3I,aAAa,CAACmJ,KAAK,CAAC;IACjC;IACA,IAAIR,IAAI,KAAK,OAAO,EAAE;MACpB,OAAO,IAAIzI,kBAAkB,CAACiJ,KAAK,CAAC;IACtC;IACA,IAAIR,IAAI,KAAK,OAAO,EAAE;MACpB,OAAO,IAAI1I,gBAAgB,CAACkJ,KAAK,CAAC;IACpC;IACA,IAAIR,IAAI,KAAK,OAAO,EAAE;MACpB,OAAO,IAAItI,qBAAqB,CAAC8I,KAAK,CAAC;IACzC;EACF;EACA,OAAO,IAAI5I,YAAY,CAAC4I,KAAK,CAAC;AAChC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"PgliteClient.js","names":["PGlite","Config","Context","Effect","Fiber","Layer","Queue","Scope","Semaphore","Stream","Reactivity","Client","AuthenticationError","AuthorizationError","ConnectionError","ConstraintError","DeadlockError","LockTimeoutError","SerializationError","SqlError","SqlSyntaxError","StatementTimeoutError","UniqueViolation","UnknownError","Statement","TypeId","PgliteClient","Service","make","options","gen","pglite","liveClient","acquireRelease","tryPromise","try","pg","waitReady","catch","cause","reason","classifyError","promise","close","pipe","timeoutOption","interruptible","fromClient","compiler","makeCompiler","transformQueryNames","transformJson","transformRows","transformResultNames","defaultTransforms","array","undefined","spanAttributes","Object","entries","ATTR_DB_SYSTEM_NAME","connection","PgliteConnection","semaphore","makeUnsafe","acquirer","withPermits","succeed","transactionAcquirer","uninterruptibleMask","restore","fiber","getCurrent","scope","getUnsafe","context","as","tap","take","addFinalizer","release","config","client","assign","json","_","fragment","PgJson","listen","channel","callback","queue","payload","offerUnsafe","unlisten","notify","exec","escape","escapeLiteral","withPermit","asVoid","dumpDataDir","compression","refreshArrayTypes","constructor","run","method","sql","params","map","query","result","rows","execute","executeRaw","executeValues","rowMode","executeUnprepared","executeStream","eff","fromArrayEffect","layerFrom","acquire","effectContext","add","SqlClient","provide","layer","layerConfig","flatMap","unwrap","resolved","transform","transformValue","value","dialect","placeholder","onIdentifier","withoutTransform","onRecordUpdate","placeholders","valueAlias","valueColumns","values","returning","flat","concat","onCustom","type","kind","paramA","defaultEscape","replace","custom","pgCodeFromCause","code","pgConstraintFromCause","constraint","normalized","trim","length","message","operation","props","startsWith"],"sources":["../src/PgliteClient.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBA,SAASA,MAAM,QAAkD,sBAAsB;AACvF,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,SAAS,MAAM,kBAAkB;AAC7C,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,UAAU,MAAM,uCAAuC;AACnE,OAAO,KAAKC,MAAM,MAAM,+BAA+B;AAEvD,SACEC,mBAAmB,EACnBC,kBAAkB,EAClBC,eAAe,EACfC,eAAe,EACfC,aAAa,EACbC,gBAAgB,EAChBC,kBAAkB,EAClBC,QAAQ,EACRC,cAAc,EACdC,qBAAqB,EACrBC,eAAe,EACfC,YAAY,QACP,8BAA8B;AAErC,OAAO,KAAKC,SAAS,MAAM,+BAA+B;AAE1D;;;;;;AAMA,OAAO,MAAMC,MAAM,GAAW,kCAAkC;AA2BhE;;;;;;AAMA,OAAO,MAAMC,YAAY,gBAAGxB,OAAO,CAACyB,OAAO,CAAe,iCAAiC,CAAC;AA6D5F;;;;;;AAMA,OAAO,MAAMC,IAAI,GAAGA,CAClBC,OAAA,GAA8B,EAAE,KAEhC1B,MAAM,CAAC2B,GAAG,CAAC,aAAS;EAClB,MAAMC,MAAM,GAAG,YAAY,IAAIF,OAAO,GAClCA,OAAO,CAACG,UAAU,GAClB,OAAO7B,MAAM,CA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;QAAEN,UAAU,EAAED,qBAAqB,CAACrH,KAAK;MAAC,CAAE,CAAC;IACpF;IACA,IAAIoH,IAAI,CAACS,UAAU,CAAC,IAAI,CAAC,EAAE;MACzB,OAAO,IAAIrJ,eAAe,CAACoJ,KAAK,CAAC;IACnC;IACA,IAAIR,IAAI,KAAK,OAAO,EAAE;MACpB,OAAO,IAAI3I,aAAa,CAACmJ,KAAK,CAAC;IACjC;IACA,IAAIR,IAAI,KAAK,OAAO,EAAE;MACpB,OAAO,IAAIzI,kBAAkB,CAACiJ,KAAK,CAAC;IACtC;IACA,IAAIR,IAAI,KAAK,OAAO,EAAE;MACpB,OAAO,IAAI1I,gBAAgB,CAACkJ,KAAK,CAAC;IACpC;IACA,IAAIR,IAAI,KAAK,OAAO,EAAE;MACpB,OAAO,IAAItI,qBAAqB,CAAC8I,KAAK,CAAC;IACzC;EACF;EACA,OAAO,IAAI5I,YAAY,CAAC4I,KAAK,CAAC;AAChC,CAAC","ignoreList":[]}
|
package/dist/PgliteMigrator.d.ts
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Utilities for applying Effect SQL migrations to embedded PGlite databases.
|
|
3
|
+
*
|
|
4
|
+
* This module re-exports the shared `Migrator` loaders and error types, then
|
|
5
|
+
* provides `run` and `layer` helpers for applying ordered migrations through the
|
|
6
|
+
* current PGlite-backed `SqlClient`. It is typically used to bootstrap schemas
|
|
7
|
+
* for local-first applications, browser or Node.js integration tests, examples,
|
|
8
|
+
* and layer graphs that need an embedded PostgreSQL-compatible database to be
|
|
9
|
+
* ready before dependent services start.
|
|
10
|
+
*
|
|
11
|
+
* Migrations are recorded in `effect_sql_migrations` by default and are loaded
|
|
12
|
+
* using the shared `<id>_<name>` file or record-key convention. PGlite uses
|
|
13
|
+
* PostgreSQL semantics inside the embedded database, so migrations run in a
|
|
14
|
+
* transaction and the shared migrator uses PostgreSQL table locking to avoid
|
|
15
|
+
* concurrent runners. Coordinate every process or layer using the same
|
|
16
|
+
* `liveClient` or `dataDir`, and remember that in-memory PGlite clients start
|
|
17
|
+
* with no recorded migrations. This adapter does not currently write schema
|
|
18
|
+
* dumps for `schemaDirectory`; use PGlite data-directory persistence or
|
|
19
|
+
* `PgliteClient.dumpDataDir` when a portable embedded database snapshot is
|
|
20
|
+
* needed.
|
|
21
|
+
*
|
|
22
|
+
* @since 4.0.0
|
|
3
23
|
*/
|
|
4
24
|
import type * as Effect from "effect/Effect";
|
|
5
25
|
import * as Layer from "effect/Layer";
|
|
@@ -7,17 +27,21 @@ import * as Migrator from "effect/unstable/sql/Migrator";
|
|
|
7
27
|
import type * as Client from "effect/unstable/sql/SqlClient";
|
|
8
28
|
import type { SqlError } from "effect/unstable/sql/SqlError";
|
|
9
29
|
/**
|
|
10
|
-
* @since
|
|
30
|
+
* @since 4.0.0
|
|
11
31
|
*/
|
|
12
32
|
export * from "effect/unstable/sql/Migrator";
|
|
13
33
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
34
|
+
* Runs SQL migrations using the configured `SqlClient`, returning the migrations that were applied.
|
|
35
|
+
*
|
|
36
|
+
* @category constructors
|
|
37
|
+
* @since 4.0.0
|
|
16
38
|
*/
|
|
17
39
|
export declare const run: <R2 = never>(options: Migrator.MigratorOptions<R2>) => Effect.Effect<ReadonlyArray<readonly [id: number, name: string]>, Migrator.MigrationError | SqlError, Client.SqlClient | R2>;
|
|
18
40
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
41
|
+
* Creates a layer that runs the configured SQL migrations during layer construction.
|
|
42
|
+
*
|
|
43
|
+
* @category constructors
|
|
44
|
+
* @since 4.0.0
|
|
21
45
|
*/
|
|
22
46
|
export declare const layer: <R>(options: Migrator.MigratorOptions<R>) => Layer.Layer<never, Migrator.MigrationError | SqlError, Client.SqlClient | R>;
|
|
23
47
|
//# sourceMappingURL=PgliteMigrator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PgliteMigrator.d.ts","sourceRoot":"","sources":["../src/PgliteMigrator.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"PgliteMigrator.d.ts","sourceRoot":"","sources":["../src/PgliteMigrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;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;;GAEG;AACH,cAAc,8BAA8B,CAAA;AAE5C;;;;;GAKG;AACH,eAAO,MAAM,GAAG,EAAE,CAAC,EAAE,GAAG,KAAK,EAC3B,OAAO,EAAE,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,KAClC,MAAM,CAAC,MAAM,CAChB,aAAa,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,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"}
|
package/dist/PgliteMigrator.js
CHANGED
|
@@ -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
|
|
4
|
+
* @since 4.0.0
|
|
5
5
|
*/
|
|
6
6
|
export * from "effect/unstable/sql/Migrator";
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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
|
-
*
|
|
14
|
-
*
|
|
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=PgliteMigrator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PgliteMigrator.js","names":["Layer","Migrator","run","make","layer","options","effectDiscard"],"sources":["../src/PgliteMigrator.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"file":"PgliteMigrator.js","names":["Layer","Migrator","run","make","layer","options","effectDiscard"],"sources":["../src/PgliteMigrator.ts"],"sourcesContent":[null],"mappings":"AAwBA,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,51 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @since
|
|
2
|
+
* @since 4.0.0
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Embedded PostgreSQL client implementation for Effect SQL, backed by
|
|
6
|
+
* `@electric-sql/pglite`.
|
|
7
|
+
*
|
|
8
|
+
* This module exposes constructors and layers for providing a `PgliteClient`
|
|
9
|
+
* as both the PGlite-specific service and the generic `SqlClient`. It can
|
|
10
|
+
* create a scoped `PGlite` instance from constructor options or wrap a
|
|
11
|
+
* caller-owned `liveClient`, making it useful for local-first browser storage,
|
|
12
|
+
* web worker databases, tests, demos, migrations, and development tools that
|
|
13
|
+
* want PostgreSQL syntax without connecting to a separate PostgreSQL server.
|
|
14
|
+
*
|
|
15
|
+
* The client uses the PostgreSQL statement compiler and adds PGlite-specific
|
|
16
|
+
* access to the underlying instance, JSON fragments, LISTEN/NOTIFY streams,
|
|
17
|
+
* data directory dumps, and array type refresh. Because PGlite is embedded in
|
|
18
|
+
* the current JavaScript runtime, operations share the supplied instance and
|
|
19
|
+
* are serialized by this client; a `liveClient` remains caller-owned and is not
|
|
20
|
+
* closed by the layer. In browsers or workers, persistence, durability,
|
|
21
|
+
* extension availability, and lifecycle all follow the selected PGlite
|
|
22
|
+
* `dataDir`/runtime rather than a hosted PostgreSQL process.
|
|
23
|
+
*
|
|
24
|
+
* @since 4.0.0
|
|
6
25
|
*/
|
|
7
26
|
export * as PgliteClient from "./PgliteClient.ts";
|
|
8
27
|
/**
|
|
9
|
-
*
|
|
28
|
+
* Utilities for applying Effect SQL migrations to embedded PGlite databases.
|
|
29
|
+
*
|
|
30
|
+
* This module re-exports the shared `Migrator` loaders and error types, then
|
|
31
|
+
* provides `run` and `layer` helpers for applying ordered migrations through the
|
|
32
|
+
* current PGlite-backed `SqlClient`. It is typically used to bootstrap schemas
|
|
33
|
+
* for local-first applications, browser or Node.js integration tests, examples,
|
|
34
|
+
* and layer graphs that need an embedded PostgreSQL-compatible database to be
|
|
35
|
+
* ready before dependent services start.
|
|
36
|
+
*
|
|
37
|
+
* Migrations are recorded in `effect_sql_migrations` by default and are loaded
|
|
38
|
+
* using the shared `<id>_<name>` file or record-key convention. PGlite uses
|
|
39
|
+
* PostgreSQL semantics inside the embedded database, so migrations run in a
|
|
40
|
+
* transaction and the shared migrator uses PostgreSQL table locking to avoid
|
|
41
|
+
* concurrent runners. Coordinate every process or layer using the same
|
|
42
|
+
* `liveClient` or `dataDir`, and remember that in-memory PGlite clients start
|
|
43
|
+
* with no recorded migrations. This adapter does not currently write schema
|
|
44
|
+
* dumps for `schemaDirectory`; use PGlite data-directory persistence or
|
|
45
|
+
* `PgliteClient.dumpDataDir` when a portable embedded database snapshot is
|
|
46
|
+
* needed.
|
|
47
|
+
*
|
|
48
|
+
* @since 4.0.0
|
|
10
49
|
*/
|
|
11
50
|
export * as PgliteMigrator from "./PgliteMigrator.ts";
|
|
12
51
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAEjD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @since
|
|
2
|
+
* @since 4.0.0
|
|
3
3
|
*/
|
|
4
4
|
// @barrel: Auto-generated exports. Do not edit manually.
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Embedded PostgreSQL client implementation for Effect SQL, backed by
|
|
7
|
+
* `@electric-sql/pglite`.
|
|
8
|
+
*
|
|
9
|
+
* This module exposes constructors and layers for providing a `PgliteClient`
|
|
10
|
+
* as both the PGlite-specific service and the generic `SqlClient`. It can
|
|
11
|
+
* create a scoped `PGlite` instance from constructor options or wrap a
|
|
12
|
+
* caller-owned `liveClient`, making it useful for local-first browser storage,
|
|
13
|
+
* web worker databases, tests, demos, migrations, and development tools that
|
|
14
|
+
* want PostgreSQL syntax without connecting to a separate PostgreSQL server.
|
|
15
|
+
*
|
|
16
|
+
* The client uses the PostgreSQL statement compiler and adds PGlite-specific
|
|
17
|
+
* access to the underlying instance, JSON fragments, LISTEN/NOTIFY streams,
|
|
18
|
+
* data directory dumps, and array type refresh. Because PGlite is embedded in
|
|
19
|
+
* the current JavaScript runtime, operations share the supplied instance and
|
|
20
|
+
* are serialized by this client; a `liveClient` remains caller-owned and is not
|
|
21
|
+
* closed by the layer. In browsers or workers, persistence, durability,
|
|
22
|
+
* extension availability, and lifecycle all follow the selected PGlite
|
|
23
|
+
* `dataDir`/runtime rather than a hosted PostgreSQL process.
|
|
24
|
+
*
|
|
25
|
+
* @since 4.0.0
|
|
7
26
|
*/
|
|
8
27
|
export * as PgliteClient from "./PgliteClient.js";
|
|
9
28
|
/**
|
|
10
|
-
*
|
|
29
|
+
* Utilities for applying Effect SQL migrations to embedded PGlite databases.
|
|
30
|
+
*
|
|
31
|
+
* This module re-exports the shared `Migrator` loaders and error types, then
|
|
32
|
+
* provides `run` and `layer` helpers for applying ordered migrations through the
|
|
33
|
+
* current PGlite-backed `SqlClient`. It is typically used to bootstrap schemas
|
|
34
|
+
* for local-first applications, browser or Node.js integration tests, examples,
|
|
35
|
+
* and layer graphs that need an embedded PostgreSQL-compatible database to be
|
|
36
|
+
* ready before dependent services start.
|
|
37
|
+
*
|
|
38
|
+
* Migrations are recorded in `effect_sql_migrations` by default and are loaded
|
|
39
|
+
* using the shared `<id>_<name>` file or record-key convention. PGlite uses
|
|
40
|
+
* PostgreSQL semantics inside the embedded database, so migrations run in a
|
|
41
|
+
* transaction and the shared migrator uses PostgreSQL table locking to avoid
|
|
42
|
+
* concurrent runners. Coordinate every process or layer using the same
|
|
43
|
+
* `liveClient` or `dataDir`, and remember that in-memory PGlite clients start
|
|
44
|
+
* with no recorded migrations. This adapter does not currently write schema
|
|
45
|
+
* dumps for `schemaDirectory`; use PGlite data-directory persistence or
|
|
46
|
+
* `PgliteClient.dumpDataDir` when a portable embedded database snapshot is
|
|
47
|
+
* needed.
|
|
48
|
+
*
|
|
49
|
+
* @since 4.0.0
|
|
11
50
|
*/
|
|
12
51
|
export * as PgliteMigrator from "./PgliteMigrator.js";
|
|
13
52
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["PgliteClient","PgliteMigrator"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAIA;AAEA
|
|
1
|
+
{"version":3,"file":"index.js","names":["PgliteClient","PgliteMigrator"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAIA;AAEA;;;;;;;;;;;;;;;;;;;;;;AAsBA,OAAO,KAAKA,YAAY,MAAM,mBAAmB;AAEjD;;;;;;;;;;;;;;;;;;;;;;;AAuBA,OAAO,KAAKC,cAAc,MAAM,qBAAqB","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/sql-pglite",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.68",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A PGlite toolkit for Effect",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"provenance": true
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"effect": "^4.0.0-beta.
|
|
50
|
+
"effect": "^4.0.0-beta.68"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"effect": "^4.0.0-beta.
|
|
53
|
+
"effect": "^4.0.0-beta.68"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@electric-sql/pglite": "^0.4.
|
|
56
|
+
"@electric-sql/pglite": "^0.4.5"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"codegen": "effect-utils codegen",
|
package/src/PgliteClient.ts
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Embedded PostgreSQL client implementation for Effect SQL, backed by
|
|
3
|
+
* `@electric-sql/pglite`.
|
|
4
|
+
*
|
|
5
|
+
* This module exposes constructors and layers for providing a `PgliteClient`
|
|
6
|
+
* as both the PGlite-specific service and the generic `SqlClient`. It can
|
|
7
|
+
* create a scoped `PGlite` instance from constructor options or wrap a
|
|
8
|
+
* caller-owned `liveClient`, making it useful for local-first browser storage,
|
|
9
|
+
* web worker databases, tests, demos, migrations, and development tools that
|
|
10
|
+
* want PostgreSQL syntax without connecting to a separate PostgreSQL server.
|
|
11
|
+
*
|
|
12
|
+
* The client uses the PostgreSQL statement compiler and adds PGlite-specific
|
|
13
|
+
* access to the underlying instance, JSON fragments, LISTEN/NOTIFY streams,
|
|
14
|
+
* data directory dumps, and array type refresh. Because PGlite is embedded in
|
|
15
|
+
* the current JavaScript runtime, operations share the supplied instance and
|
|
16
|
+
* are serialized by this client; a `liveClient` remains caller-owned and is not
|
|
17
|
+
* closed by the layer. In browsers or workers, persistence, durability,
|
|
18
|
+
* extension availability, and lifecycle all follow the selected PGlite
|
|
19
|
+
* `dataDir`/runtime rather than a hosted PostgreSQL process.
|
|
20
|
+
*
|
|
21
|
+
* @since 4.0.0
|
|
3
22
|
*/
|
|
4
23
|
import { PGlite, type PGliteInterface, type PGliteOptions } from "@electric-sql/pglite"
|
|
5
24
|
import * as Config from "effect/Config"
|
|
@@ -32,20 +51,26 @@ import type { Custom, Fragment } from "effect/unstable/sql/Statement"
|
|
|
32
51
|
import * as Statement from "effect/unstable/sql/Statement"
|
|
33
52
|
|
|
34
53
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
54
|
+
* Runtime type identifier used to mark `PgliteClient` values.
|
|
55
|
+
*
|
|
56
|
+
* @category type IDs
|
|
57
|
+
* @since 4.0.0
|
|
37
58
|
*/
|
|
38
59
|
export const TypeId: TypeId = "~@effect/sql-pglite/PgliteClient"
|
|
39
60
|
|
|
40
61
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
62
|
+
* Type-level identifier used to mark `PgliteClient` values.
|
|
63
|
+
*
|
|
64
|
+
* @category type IDs
|
|
65
|
+
* @since 4.0.0
|
|
43
66
|
*/
|
|
44
67
|
export type TypeId = "~@effect/sql-pglite/PgliteClient"
|
|
45
68
|
|
|
46
69
|
/**
|
|
70
|
+
* PGlite-backed PostgreSQL client service, extending `SqlClient` with access to the PGlite instance, JSON fragments, LISTEN/NOTIFY, data directory dumps, and array type refresh.
|
|
71
|
+
*
|
|
47
72
|
* @category models
|
|
48
|
-
* @since
|
|
73
|
+
* @since 4.0.0
|
|
49
74
|
*/
|
|
50
75
|
export interface PgliteClient extends Client.SqlClient {
|
|
51
76
|
readonly [TypeId]: TypeId
|
|
@@ -59,25 +84,32 @@ export interface PgliteClient extends Client.SqlClient {
|
|
|
59
84
|
}
|
|
60
85
|
|
|
61
86
|
/**
|
|
87
|
+
* Context tag used to access the `PgliteClient` service.
|
|
88
|
+
*
|
|
62
89
|
* @category tags
|
|
63
|
-
* @since
|
|
90
|
+
* @since 4.0.0
|
|
64
91
|
*/
|
|
65
92
|
export const PgliteClient = Context.Service<PgliteClient>("@effect/sql-pglite/PgliteClient")
|
|
66
93
|
|
|
67
94
|
/**
|
|
95
|
+
* Configuration for a PGlite client, either by supplying PGlite creation options or an existing live PGlite client.
|
|
96
|
+
*
|
|
68
97
|
* @category models
|
|
69
|
-
* @since
|
|
98
|
+
* @since 4.0.0
|
|
70
99
|
*/
|
|
71
100
|
export type PgliteClientConfig = PgliteClientConfig.Create | PgliteClientConfig.Live
|
|
72
101
|
|
|
73
102
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
103
|
+
* Namespace containing the configuration variants for `PgliteClient`.
|
|
104
|
+
*
|
|
105
|
+
* @since 4.0.0
|
|
76
106
|
*/
|
|
77
107
|
export declare namespace PgliteClientConfig {
|
|
78
108
|
/**
|
|
109
|
+
* Shared PGlite client options for span attributes, query/result name transformations, and JSON value transformation.
|
|
110
|
+
*
|
|
79
111
|
* @category models
|
|
80
|
-
* @since
|
|
112
|
+
* @since 4.0.0
|
|
81
113
|
*/
|
|
82
114
|
export interface Base {
|
|
83
115
|
readonly spanAttributes?: Record<string, unknown> | undefined
|
|
@@ -87,22 +119,28 @@ export declare namespace PgliteClientConfig {
|
|
|
87
119
|
}
|
|
88
120
|
|
|
89
121
|
/**
|
|
122
|
+
* Configuration used to create a managed PGlite instance from PGlite constructor options.
|
|
123
|
+
*
|
|
90
124
|
* @category models
|
|
91
|
-
* @since
|
|
125
|
+
* @since 4.0.0
|
|
92
126
|
*/
|
|
93
127
|
export interface Create extends Base, PGliteOptions {}
|
|
94
128
|
|
|
95
129
|
/**
|
|
130
|
+
* Configuration that uses an existing PGlite client. The supplied `liveClient` is caller-owned and is not closed by the Effect client.
|
|
131
|
+
*
|
|
96
132
|
* @category models
|
|
97
|
-
* @since
|
|
133
|
+
* @since 4.0.0
|
|
98
134
|
*/
|
|
99
135
|
export interface Live extends Base {
|
|
100
136
|
readonly liveClient: PGliteInterface
|
|
101
137
|
}
|
|
102
138
|
|
|
103
139
|
/**
|
|
140
|
+
* Config-friendly subset of PGlite creation options, including data directory, username, database, relaxed durability, and shared transform options.
|
|
141
|
+
*
|
|
104
142
|
* @category models
|
|
105
|
-
* @since
|
|
143
|
+
* @since 4.0.0
|
|
106
144
|
*/
|
|
107
145
|
export interface ConfigBase extends Base {
|
|
108
146
|
readonly dataDir?: string | undefined
|
|
@@ -113,8 +151,10 @@ export declare namespace PgliteClientConfig {
|
|
|
113
151
|
}
|
|
114
152
|
|
|
115
153
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
154
|
+
* Creates a scoped PGlite SQL client. When no live client is supplied it creates and closes a PGlite instance; when `liveClient` is supplied, the caller retains ownership.
|
|
155
|
+
*
|
|
156
|
+
* @category constructors
|
|
157
|
+
* @since 4.0.0
|
|
118
158
|
*/
|
|
119
159
|
export const make = (
|
|
120
160
|
options: PgliteClientConfig = {}
|
|
@@ -139,8 +179,10 @@ export const make = (
|
|
|
139
179
|
})
|
|
140
180
|
|
|
141
181
|
/**
|
|
142
|
-
*
|
|
143
|
-
*
|
|
182
|
+
* Builds a `PgliteClient` around an existing PGlite instance, adding SQL client operations, LISTEN/NOTIFY, dump helpers, and serialized access.
|
|
183
|
+
*
|
|
184
|
+
* @category constructors
|
|
185
|
+
* @since 4.0.0
|
|
144
186
|
*/
|
|
145
187
|
export const fromClient = (
|
|
146
188
|
options:
|
|
@@ -293,8 +335,10 @@ class PgliteConnection implements Connection {
|
|
|
293
335
|
}
|
|
294
336
|
|
|
295
337
|
/**
|
|
338
|
+
* Creates a layer from an effect that acquires a `PgliteClient`, providing both `PgliteClient` and `SqlClient`.
|
|
339
|
+
*
|
|
296
340
|
* @category layers
|
|
297
|
-
* @since
|
|
341
|
+
* @since 4.0.0
|
|
298
342
|
*/
|
|
299
343
|
export const layerFrom = <E, R>(
|
|
300
344
|
acquire: Effect.Effect<PgliteClient, E, R>
|
|
@@ -307,8 +351,10 @@ export const layerFrom = <E, R>(
|
|
|
307
351
|
).pipe(Layer.provide(Reactivity.layer)) as any
|
|
308
352
|
|
|
309
353
|
/**
|
|
354
|
+
* Creates a layer from a `Config`-wrapped PGlite client configuration, providing both `PgliteClient` and `SqlClient`.
|
|
355
|
+
*
|
|
310
356
|
* @category layers
|
|
311
|
-
* @since
|
|
357
|
+
* @since 4.0.0
|
|
312
358
|
*/
|
|
313
359
|
export const layerConfig: (
|
|
314
360
|
config: Config.Wrap<PgliteClientConfig.ConfigBase>
|
|
@@ -321,16 +367,20 @@ export const layerConfig: (
|
|
|
321
367
|
))
|
|
322
368
|
|
|
323
369
|
/**
|
|
370
|
+
* Creates a layer from a concrete PGlite client configuration, providing both `PgliteClient` and `SqlClient`.
|
|
371
|
+
*
|
|
324
372
|
* @category layers
|
|
325
|
-
* @since
|
|
373
|
+
* @since 4.0.0
|
|
326
374
|
*/
|
|
327
375
|
export const layer = (
|
|
328
376
|
config?: PgliteClientConfig | undefined
|
|
329
377
|
): Layer.Layer<PgliteClient | Client.SqlClient, SqlError> => layerFrom(make(config))
|
|
330
378
|
|
|
331
379
|
/**
|
|
332
|
-
*
|
|
333
|
-
*
|
|
380
|
+
* Creates the PGlite statement compiler, using PostgreSQL `$1` placeholders, double-quoted identifiers, returning clauses, and optional JSON value transformation.
|
|
381
|
+
*
|
|
382
|
+
* @category constructors
|
|
383
|
+
* @since 4.0.0
|
|
334
384
|
*/
|
|
335
385
|
export const makeCompiler = (
|
|
336
386
|
transform?: (_: string) => string,
|
|
@@ -379,14 +429,16 @@ const escape = Statement.defaultEscape("\"")
|
|
|
379
429
|
const escapeLiteral = (value: string) => `'${value.replace(/'/g, "''")}'`
|
|
380
430
|
|
|
381
431
|
/**
|
|
432
|
+
* PGlite-specific custom statement fragments supported by the compiler, currently JSON parameter fragments.
|
|
433
|
+
*
|
|
382
434
|
* @category custom types
|
|
383
|
-
* @since
|
|
435
|
+
* @since 4.0.0
|
|
384
436
|
*/
|
|
385
437
|
export type PgCustom = PgJson
|
|
386
438
|
|
|
387
439
|
/**
|
|
388
440
|
* @category custom types
|
|
389
|
-
* @since
|
|
441
|
+
* @since 4.0.0
|
|
390
442
|
*/
|
|
391
443
|
interface PgJson extends Custom<"PgJson", unknown> {}
|
|
392
444
|
const PgJson = Statement.custom<PgJson>("PgJson")
|
package/src/PgliteMigrator.ts
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Utilities for applying Effect SQL migrations to embedded PGlite databases.
|
|
3
|
+
*
|
|
4
|
+
* This module re-exports the shared `Migrator` loaders and error types, then
|
|
5
|
+
* provides `run` and `layer` helpers for applying ordered migrations through the
|
|
6
|
+
* current PGlite-backed `SqlClient`. It is typically used to bootstrap schemas
|
|
7
|
+
* for local-first applications, browser or Node.js integration tests, examples,
|
|
8
|
+
* and layer graphs that need an embedded PostgreSQL-compatible database to be
|
|
9
|
+
* ready before dependent services start.
|
|
10
|
+
*
|
|
11
|
+
* Migrations are recorded in `effect_sql_migrations` by default and are loaded
|
|
12
|
+
* using the shared `<id>_<name>` file or record-key convention. PGlite uses
|
|
13
|
+
* PostgreSQL semantics inside the embedded database, so migrations run in a
|
|
14
|
+
* transaction and the shared migrator uses PostgreSQL table locking to avoid
|
|
15
|
+
* concurrent runners. Coordinate every process or layer using the same
|
|
16
|
+
* `liveClient` or `dataDir`, and remember that in-memory PGlite clients start
|
|
17
|
+
* with no recorded migrations. This adapter does not currently write schema
|
|
18
|
+
* dumps for `schemaDirectory`; use PGlite data-directory persistence or
|
|
19
|
+
* `PgliteClient.dumpDataDir` when a portable embedded database snapshot is
|
|
20
|
+
* needed.
|
|
21
|
+
*
|
|
22
|
+
* @since 4.0.0
|
|
3
23
|
*/
|
|
4
24
|
import type * as Effect from "effect/Effect"
|
|
5
25
|
import * as Layer from "effect/Layer"
|
|
@@ -8,13 +28,15 @@ import type * as Client from "effect/unstable/sql/SqlClient"
|
|
|
8
28
|
import type { SqlError } from "effect/unstable/sql/SqlError"
|
|
9
29
|
|
|
10
30
|
/**
|
|
11
|
-
* @since
|
|
31
|
+
* @since 4.0.0
|
|
12
32
|
*/
|
|
13
33
|
export * from "effect/unstable/sql/Migrator"
|
|
14
34
|
|
|
15
35
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
36
|
+
* Runs SQL migrations using the configured `SqlClient`, returning the migrations that were applied.
|
|
37
|
+
*
|
|
38
|
+
* @category constructors
|
|
39
|
+
* @since 4.0.0
|
|
18
40
|
*/
|
|
19
41
|
export const run: <R2 = never>(
|
|
20
42
|
options: Migrator.MigratorOptions<R2>
|
|
@@ -25,8 +47,10 @@ export const run: <R2 = never>(
|
|
|
25
47
|
> = Migrator.make({})
|
|
26
48
|
|
|
27
49
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
50
|
+
* Creates a layer that runs the configured SQL migrations during layer construction.
|
|
51
|
+
*
|
|
52
|
+
* @category constructors
|
|
53
|
+
* @since 4.0.0
|
|
30
54
|
*/
|
|
31
55
|
export const layer = <R>(
|
|
32
56
|
options: Migrator.MigratorOptions<R>
|
package/src/index.ts
CHANGED
|
@@ -1,15 +1,54 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @since
|
|
2
|
+
* @since 4.0.0
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
// @barrel: Auto-generated exports. Do not edit manually.
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Embedded PostgreSQL client implementation for Effect SQL, backed by
|
|
9
|
+
* `@electric-sql/pglite`.
|
|
10
|
+
*
|
|
11
|
+
* This module exposes constructors and layers for providing a `PgliteClient`
|
|
12
|
+
* as both the PGlite-specific service and the generic `SqlClient`. It can
|
|
13
|
+
* create a scoped `PGlite` instance from constructor options or wrap a
|
|
14
|
+
* caller-owned `liveClient`, making it useful for local-first browser storage,
|
|
15
|
+
* web worker databases, tests, demos, migrations, and development tools that
|
|
16
|
+
* want PostgreSQL syntax without connecting to a separate PostgreSQL server.
|
|
17
|
+
*
|
|
18
|
+
* The client uses the PostgreSQL statement compiler and adds PGlite-specific
|
|
19
|
+
* access to the underlying instance, JSON fragments, LISTEN/NOTIFY streams,
|
|
20
|
+
* data directory dumps, and array type refresh. Because PGlite is embedded in
|
|
21
|
+
* the current JavaScript runtime, operations share the supplied instance and
|
|
22
|
+
* are serialized by this client; a `liveClient` remains caller-owned and is not
|
|
23
|
+
* closed by the layer. In browsers or workers, persistence, durability,
|
|
24
|
+
* extension availability, and lifecycle all follow the selected PGlite
|
|
25
|
+
* `dataDir`/runtime rather than a hosted PostgreSQL process.
|
|
26
|
+
*
|
|
27
|
+
* @since 4.0.0
|
|
9
28
|
*/
|
|
10
29
|
export * as PgliteClient from "./PgliteClient.ts"
|
|
11
30
|
|
|
12
31
|
/**
|
|
13
|
-
*
|
|
32
|
+
* Utilities for applying Effect SQL migrations to embedded PGlite databases.
|
|
33
|
+
*
|
|
34
|
+
* This module re-exports the shared `Migrator` loaders and error types, then
|
|
35
|
+
* provides `run` and `layer` helpers for applying ordered migrations through the
|
|
36
|
+
* current PGlite-backed `SqlClient`. It is typically used to bootstrap schemas
|
|
37
|
+
* for local-first applications, browser or Node.js integration tests, examples,
|
|
38
|
+
* and layer graphs that need an embedded PostgreSQL-compatible database to be
|
|
39
|
+
* ready before dependent services start.
|
|
40
|
+
*
|
|
41
|
+
* Migrations are recorded in `effect_sql_migrations` by default and are loaded
|
|
42
|
+
* using the shared `<id>_<name>` file or record-key convention. PGlite uses
|
|
43
|
+
* PostgreSQL semantics inside the embedded database, so migrations run in a
|
|
44
|
+
* transaction and the shared migrator uses PostgreSQL table locking to avoid
|
|
45
|
+
* concurrent runners. Coordinate every process or layer using the same
|
|
46
|
+
* `liveClient` or `dataDir`, and remember that in-memory PGlite clients start
|
|
47
|
+
* with no recorded migrations. This adapter does not currently write schema
|
|
48
|
+
* dumps for `schemaDirectory`; use PGlite data-directory persistence or
|
|
49
|
+
* `PgliteClient.dumpDataDir` when a portable embedded database snapshot is
|
|
50
|
+
* needed.
|
|
51
|
+
*
|
|
52
|
+
* @since 4.0.0
|
|
14
53
|
*/
|
|
15
54
|
export * as PgliteMigrator from "./PgliteMigrator.ts"
|