@effect/platform-browser 4.0.0-beta.8 → 4.0.0-beta.80
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/BrowserCrypto.d.ts +49 -0
- package/dist/BrowserCrypto.d.ts.map +1 -0
- package/dist/BrowserCrypto.js +87 -0
- package/dist/BrowserCrypto.js.map +1 -0
- package/dist/BrowserHttpClient.d.ts +48 -19
- package/dist/BrowserHttpClient.d.ts.map +1 -1
- package/dist/BrowserHttpClient.js +62 -21
- package/dist/BrowserHttpClient.js.map +1 -1
- package/dist/BrowserKeyValueStore.d.ts +37 -14
- package/dist/BrowserKeyValueStore.d.ts.map +1 -1
- package/dist/BrowserKeyValueStore.js +144 -10
- package/dist/BrowserKeyValueStore.js.map +1 -1
- package/dist/BrowserPersistence.d.ts +40 -0
- package/dist/BrowserPersistence.d.ts.map +1 -0
- package/dist/BrowserPersistence.js +207 -0
- package/dist/BrowserPersistence.js.map +1 -0
- package/dist/BrowserRuntime.d.ts +64 -4
- package/dist/BrowserRuntime.d.ts.map +1 -1
- package/dist/BrowserRuntime.js +19 -1
- package/dist/BrowserRuntime.js.map +1 -1
- package/dist/BrowserSocket.d.ts +33 -6
- package/dist/BrowserSocket.d.ts.map +1 -1
- package/dist/BrowserSocket.js +33 -6
- package/dist/BrowserSocket.js.map +1 -1
- package/dist/BrowserStream.d.ts +19 -7
- package/dist/BrowserStream.d.ts.map +1 -1
- package/dist/BrowserStream.js +19 -7
- package/dist/BrowserStream.js.map +1 -1
- package/dist/BrowserWorker.d.ts +25 -4
- package/dist/BrowserWorker.d.ts.map +1 -1
- package/dist/BrowserWorker.js +34 -6
- package/dist/BrowserWorker.js.map +1 -1
- package/dist/BrowserWorkerRunner.d.ts +31 -6
- package/dist/BrowserWorkerRunner.d.ts.map +1 -1
- package/dist/BrowserWorkerRunner.js +43 -10
- package/dist/BrowserWorkerRunner.js.map +1 -1
- package/dist/Clipboard.d.ts +59 -14
- package/dist/Clipboard.d.ts.map +1 -1
- package/dist/Clipboard.js +34 -12
- package/dist/Clipboard.js.map +1 -1
- package/dist/Geolocation.d.ts +80 -25
- package/dist/Geolocation.d.ts.map +1 -1
- package/dist/Geolocation.js +48 -17
- package/dist/Geolocation.js.map +1 -1
- package/dist/IndexedDb.d.ts +75 -0
- package/dist/IndexedDb.d.ts.map +1 -0
- package/dist/IndexedDb.js +85 -0
- package/dist/IndexedDb.js.map +1 -0
- package/dist/IndexedDbDatabase.d.ts +153 -0
- package/dist/IndexedDbDatabase.d.ts.map +1 -0
- package/dist/IndexedDbDatabase.js +327 -0
- package/dist/IndexedDbDatabase.js.map +1 -0
- package/dist/IndexedDbQueryBuilder.d.ts +422 -0
- package/dist/IndexedDbQueryBuilder.d.ts.map +1 -0
- package/dist/IndexedDbQueryBuilder.js +935 -0
- package/dist/IndexedDbQueryBuilder.js.map +1 -0
- package/dist/IndexedDbTable.d.ts +166 -0
- package/dist/IndexedDbTable.d.ts.map +1 -0
- package/dist/IndexedDbTable.js +71 -0
- package/dist/IndexedDbTable.js.map +1 -0
- package/dist/IndexedDbVersion.d.ts +99 -0
- package/dist/IndexedDbVersion.d.ts.map +1 -0
- package/dist/IndexedDbVersion.js +44 -0
- package/dist/IndexedDbVersion.js.map +1 -0
- package/dist/Permissions.d.ts +52 -16
- package/dist/Permissions.d.ts.map +1 -1
- package/dist/Permissions.js +42 -11
- package/dist/Permissions.js.map +1 -1
- package/dist/index.d.ts +38 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -10
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/src/BrowserCrypto.ts +97 -0
- package/src/BrowserHttpClient.ts +72 -27
- package/src/BrowserKeyValueStore.ts +160 -12
- package/src/BrowserPersistence.ts +334 -0
- package/src/BrowserRuntime.ts +64 -4
- package/src/BrowserSocket.ts +33 -6
- package/src/BrowserStream.ts +19 -7
- package/src/BrowserWorker.ts +34 -6
- package/src/BrowserWorkerRunner.ts +43 -10
- package/src/Clipboard.ts +56 -14
- package/src/Geolocation.ts +76 -21
- package/src/IndexedDb.ts +113 -0
- package/src/IndexedDbDatabase.ts +648 -0
- package/src/IndexedDbQueryBuilder.ts +2032 -0
- package/src/IndexedDbTable.ts +260 -0
- package/src/IndexedDbVersion.ts +138 -0
- package/src/Permissions.ts +47 -14
- package/src/index.ts +45 -10
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds and opens typed IndexedDB databases from versioned schema migrations.
|
|
3
|
+
*
|
|
4
|
+
* This module turns an `IndexedDbVersion` migration chain into an
|
|
5
|
+
* `IndexedDbDatabase` layer. The layer opens the browser database, runs any
|
|
6
|
+
* pending upgrade migrations, provides a query builder for the current schema,
|
|
7
|
+
* and exposes a `rebuild` effect that deletes and reopens the database.
|
|
8
|
+
* Migration transactions can create or delete object stores and indexes, and
|
|
9
|
+
* database failures are represented as `IndexedDbDatabaseError` values.
|
|
10
|
+
*
|
|
11
|
+
* @since 4.0.0
|
|
12
|
+
*/
|
|
13
|
+
import * as Context from "effect/Context";
|
|
14
|
+
import * as Effect from "effect/Effect";
|
|
15
|
+
import * as Layer from "effect/Layer";
|
|
16
|
+
import * as MutableRef from "effect/MutableRef";
|
|
17
|
+
import * as Reactivity from "effect/unstable/reactivity/Reactivity";
|
|
18
|
+
import * as IndexedDb from "./IndexedDb.ts";
|
|
19
|
+
import * as IndexedDbQueryBuilder from "./IndexedDbQueryBuilder.ts";
|
|
20
|
+
import type * as IndexedDbTable from "./IndexedDbTable.ts";
|
|
21
|
+
import type * as IndexedDbVersion from "./IndexedDbVersion.ts";
|
|
22
|
+
declare const ErrorTypeId = "~@effect/platform-browser/IndexedDbDatabase/IndexedDbDatabaseError";
|
|
23
|
+
/**
|
|
24
|
+
* String union describing the failure categories for IndexedDB database opening, migration, and schema operations.
|
|
25
|
+
*
|
|
26
|
+
* @category errors
|
|
27
|
+
* @since 4.0.0
|
|
28
|
+
*/
|
|
29
|
+
export type ErrorReason = "TransactionError" | "MissingTable" | "OpenError" | "UpgradeError" | "Aborted" | "Blocked" | "MissingIndex";
|
|
30
|
+
declare const IndexedDbDatabaseError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
31
|
+
readonly _tag: "IndexedDbDatabaseError";
|
|
32
|
+
} & Readonly<A>;
|
|
33
|
+
/**
|
|
34
|
+
* Tagged error for IndexedDB database operations, carrying a database error reason and the original cause.
|
|
35
|
+
*
|
|
36
|
+
* @category errors
|
|
37
|
+
* @since 4.0.0
|
|
38
|
+
*/
|
|
39
|
+
export declare class IndexedDbDatabaseError extends IndexedDbDatabaseError_base<{
|
|
40
|
+
reason: ErrorReason;
|
|
41
|
+
cause: unknown;
|
|
42
|
+
}> {
|
|
43
|
+
/**
|
|
44
|
+
* Marks this value as an IndexedDB database error for runtime guards.
|
|
45
|
+
*
|
|
46
|
+
* @since 4.0.0
|
|
47
|
+
*/
|
|
48
|
+
readonly [ErrorTypeId]: typeof ErrorTypeId;
|
|
49
|
+
readonly message: ErrorReason;
|
|
50
|
+
}
|
|
51
|
+
declare const IndexedDbDatabase_base: Context.ServiceClass<IndexedDbDatabase, "~@effect/platform-browser/IndexedDbDatabase", {
|
|
52
|
+
readonly database: MutableRef.MutableRef<globalThis.IDBDatabase>;
|
|
53
|
+
readonly IDBKeyRange: typeof globalThis.IDBKeyRange;
|
|
54
|
+
readonly reactivity: Reactivity.Reactivity["Service"];
|
|
55
|
+
readonly rebuild: Effect.Effect<void, IndexedDbDatabaseError>;
|
|
56
|
+
}>;
|
|
57
|
+
/**
|
|
58
|
+
* Service tag for an open IndexedDB database, its `IDBKeyRange` constructor, reactivity service, and rebuild effect.
|
|
59
|
+
*
|
|
60
|
+
* **When to use**
|
|
61
|
+
*
|
|
62
|
+
* Use when you need access to the live database service after an
|
|
63
|
+
* `IndexedDbSchema` layer has been provided, especially for `rebuild` or
|
|
64
|
+
* lower-level database primitives.
|
|
65
|
+
*
|
|
66
|
+
* **Details**
|
|
67
|
+
*
|
|
68
|
+
* `database` is a mutable reference to the current `IDBDatabase`. `IDBKeyRange`
|
|
69
|
+
* and `reactivity` are shared with query builders created from the schema.
|
|
70
|
+
*
|
|
71
|
+
* **Gotchas**
|
|
72
|
+
*
|
|
73
|
+
* `rebuild` closes and deletes the browser database, then reopens it and reruns
|
|
74
|
+
* migrations. Records not recreated by migrations are removed.
|
|
75
|
+
*
|
|
76
|
+
* @see {@link IndexedDb.IndexedDb} for the lower-level browser IndexedDB primitives
|
|
77
|
+
* @see {@link make} for creating a schema that provides this service as a layer
|
|
78
|
+
*
|
|
79
|
+
* @category models
|
|
80
|
+
* @since 4.0.0
|
|
81
|
+
*/
|
|
82
|
+
export declare class IndexedDbDatabase extends IndexedDbDatabase_base {
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Describes an IndexedDB schema version and its migrations, and acts as an effect that yields a query builder for the target version.
|
|
86
|
+
*
|
|
87
|
+
* @category models
|
|
88
|
+
* @since 4.0.0
|
|
89
|
+
*/
|
|
90
|
+
export interface IndexedDbSchema<in out FromVersion extends IndexedDbVersion.AnyWithProps, in out ToVersion extends IndexedDbVersion.AnyWithProps, out Error = never> extends Effect.Effect<IndexedDbQueryBuilder.IndexedDbQueryBuilder<ToVersion>, never, IndexedDbDatabase> {
|
|
91
|
+
new (_: never): {};
|
|
92
|
+
readonly previous: [FromVersion] extends [never] ? undefined : IndexedDbSchema<never, FromVersion, Error>;
|
|
93
|
+
readonly fromVersion: FromVersion;
|
|
94
|
+
readonly version: ToVersion;
|
|
95
|
+
readonly migrate: [FromVersion] extends [never] ? (query: Transaction<ToVersion>) => Effect.Effect<void, Error> : (fromQuery: Transaction<FromVersion>, toQuery: Transaction<ToVersion>) => Effect.Effect<void, Error>;
|
|
96
|
+
readonly add: <Version extends IndexedDbVersion.AnyWithProps, MigrationError>(version: Version, migrate: (fromQuery: Transaction<ToVersion>, toQuery: Transaction<Version>) => Effect.Effect<void, MigrationError>) => IndexedDbSchema<ToVersion, Version, MigrationError | Error>;
|
|
97
|
+
readonly getQueryBuilder: Effect.Effect<IndexedDbQueryBuilder.IndexedDbQueryBuilder<ToVersion>, never, IndexedDbDatabase>;
|
|
98
|
+
readonly layer: (databaseName: string) => Layer.Layer<IndexedDbDatabase, IndexedDbDatabaseError, IndexedDb.IndexedDb>;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Query builder available during a database migration, extended with object-store and index management helpers for the active `IDBTransaction`.
|
|
102
|
+
*
|
|
103
|
+
* @category models
|
|
104
|
+
* @since 4.0.0
|
|
105
|
+
*/
|
|
106
|
+
export interface Transaction<Source extends IndexedDbVersion.AnyWithProps = never> extends Omit<IndexedDbQueryBuilder.IndexedDbQueryBuilder<Source>, "transaction"> {
|
|
107
|
+
readonly transaction: globalThis.IDBTransaction;
|
|
108
|
+
readonly createObjectStore: <A extends IndexedDbTable.TableName<IndexedDbVersion.Tables<Source>>>(table: A) => Effect.Effect<globalThis.IDBObjectStore, IndexedDbDatabaseError>;
|
|
109
|
+
readonly deleteObjectStore: <A extends IndexedDbTable.TableName<IndexedDbVersion.Tables<Source>>>(table: A) => Effect.Effect<void, IndexedDbDatabaseError>;
|
|
110
|
+
readonly createIndex: <Name extends IndexedDbTable.TableName<IndexedDbVersion.Tables<Source>>>(table: Name, indexName: IndexFromTableName<Source, Name>, options?: IDBIndexParameters) => Effect.Effect<globalThis.IDBIndex, IndexedDbDatabaseError>;
|
|
111
|
+
readonly deleteIndex: <Name extends IndexedDbTable.TableName<IndexedDbVersion.Tables<Source>>>(table: Name, indexName: IndexFromTableName<Source, Name>) => Effect.Effect<void, IndexedDbDatabaseError>;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Extracts the string-literal index names defined by an `IndexedDbTable`.
|
|
115
|
+
*
|
|
116
|
+
* @category models
|
|
117
|
+
* @since 4.0.0
|
|
118
|
+
*/
|
|
119
|
+
export type IndexFromTable<Table extends IndexedDbTable.AnyWithProps> = IsStringLiteral<Extract<keyof IndexedDbTable.Indexes<Table>, string>> extends true ? Extract<keyof IndexedDbTable.Indexes<Table>, string> : never;
|
|
120
|
+
/**
|
|
121
|
+
* Extracts the valid index names for a table name within an IndexedDB version.
|
|
122
|
+
*
|
|
123
|
+
* @category models
|
|
124
|
+
* @since 4.0.0
|
|
125
|
+
*/
|
|
126
|
+
export type IndexFromTableName<Version extends IndexedDbVersion.AnyWithProps, Table extends string> = IndexFromTable<IndexedDbTable.WithName<IndexedDbVersion.Tables<Version>, Table>>;
|
|
127
|
+
/**
|
|
128
|
+
* Type-erased IndexedDB schema shape used when traversing schema migration chains.
|
|
129
|
+
*
|
|
130
|
+
* @category models
|
|
131
|
+
* @since 4.0.0
|
|
132
|
+
*/
|
|
133
|
+
export interface Any {
|
|
134
|
+
readonly previous?: Any | undefined;
|
|
135
|
+
readonly layer: (databaseName: string) => Layer.Layer<IndexedDbDatabase, IndexedDbDatabaseError, IndexedDb.IndexedDb>;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Type-erased `IndexedDbSchema` covering any source version, target version, and migration error type.
|
|
139
|
+
*
|
|
140
|
+
* @category models
|
|
141
|
+
* @since 4.0.0
|
|
142
|
+
*/
|
|
143
|
+
export type AnySchema = IndexedDbSchema<IndexedDbVersion.AnyWithProps, IndexedDbVersion.AnyWithProps, any>;
|
|
144
|
+
/**
|
|
145
|
+
* Creates the initial `IndexedDbSchema` from a version and an initialization migration run during database upgrade.
|
|
146
|
+
*
|
|
147
|
+
* @category constructors
|
|
148
|
+
* @since 4.0.0
|
|
149
|
+
*/
|
|
150
|
+
export declare const make: <InitialVersion extends IndexedDbVersion.AnyWithProps, Error>(initialVersion: InitialVersion, init: (toQuery: Transaction<InitialVersion>) => Effect.Effect<void, Error>) => IndexedDbSchema<never, InitialVersion, Error>;
|
|
151
|
+
type IsStringLiteral<T> = T extends string ? string extends T ? false : true : false;
|
|
152
|
+
export {};
|
|
153
|
+
//# sourceMappingURL=IndexedDbDatabase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IndexedDbDatabase.d.ts","sourceRoot":"","sources":["../src/IndexedDbDatabase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAE/C,OAAO,KAAK,UAAU,MAAM,uCAAuC,CAAA;AACnE,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,qBAAqB,MAAM,4BAA4B,CAAA;AACnE,OAAO,KAAK,KAAK,cAAc,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,KAAK,gBAAgB,MAAM,uBAAuB,CAAA;AAG9D,QAAA,MAAM,WAAW,uEAAuE,CAAA;AA2CxF;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GACnB,kBAAkB,GAClB,cAAc,GACd,WAAW,GACX,cAAc,GACd,SAAS,GACT,SAAS,GACT,cAAc,CAAA;;;;AAElB;;;;;GAKG;AACH,qBAAa,sBAAuB,SAAQ,4BAE1C;IACA,MAAM,EAAE,WAAW,CAAA;IACnB,KAAK,EAAE,OAAO,CAAA;CACf,CAAC;IACA;;;;OAIG;IACH,QAAQ,CAAC,CAAC,WAAW,CAAC,EAAE,OAAO,WAAW,CAAc;IACxD,SAAkB,OAAO,cAAc;CACxC;;uBA8BsB,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC;0BAC1C,OAAO,UAAU,CAAC,WAAW;yBAC9B,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC;sBACnC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,sBAAsB,CAAC;;AA/BjE;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AAY,EAC7B,GAAG,CACJ,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GACf,cAAc,SAAS,gBAAgB,CAAC,YAAY,EACpD,KAAK,EAEL,gBAAgB,cAAc,EAC9B,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,cAAc,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,KACzE,eAAe,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,CAO9C,CAAA;AAqOD,KAAK,eAAe,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,MAAM,SAAS,CAAC,GAAG,KAAK,GACjE,IAAI,GACJ,KAAK,CAAA"}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds and opens typed IndexedDB databases from versioned schema migrations.
|
|
3
|
+
*
|
|
4
|
+
* This module turns an `IndexedDbVersion` migration chain into an
|
|
5
|
+
* `IndexedDbDatabase` layer. The layer opens the browser database, runs any
|
|
6
|
+
* pending upgrade migrations, provides a query builder for the current schema,
|
|
7
|
+
* and exposes a `rebuild` effect that deletes and reopens the database.
|
|
8
|
+
* Migration transactions can create or delete object stores and indexes, and
|
|
9
|
+
* database failures are represented as `IndexedDbDatabaseError` values.
|
|
10
|
+
*
|
|
11
|
+
* @since 4.0.0
|
|
12
|
+
*/
|
|
13
|
+
import * as Context from "effect/Context";
|
|
14
|
+
import * as Data from "effect/Data";
|
|
15
|
+
import * as Effect from "effect/Effect";
|
|
16
|
+
import * as Effectable from "effect/Effectable";
|
|
17
|
+
import * as Fiber from "effect/Fiber";
|
|
18
|
+
import * as Layer from "effect/Layer";
|
|
19
|
+
import * as MutableRef from "effect/MutableRef";
|
|
20
|
+
import * as Semaphore from "effect/Semaphore";
|
|
21
|
+
import * as Reactivity from "effect/unstable/reactivity/Reactivity";
|
|
22
|
+
import * as IndexedDb from "./IndexedDb.js";
|
|
23
|
+
import * as IndexedDbQueryBuilder from "./IndexedDbQueryBuilder.js";
|
|
24
|
+
const TypeId = "~@effect/platform-browser/IndexedDbDatabase";
|
|
25
|
+
const ErrorTypeId = "~@effect/platform-browser/IndexedDbDatabase/IndexedDbDatabaseError";
|
|
26
|
+
const SchemaProto = {
|
|
27
|
+
[TypeId]: {
|
|
28
|
+
_A: _ => _
|
|
29
|
+
},
|
|
30
|
+
... /*#__PURE__*/Effectable.Prototype({
|
|
31
|
+
label: "IndexedDbSchema",
|
|
32
|
+
evaluate() {
|
|
33
|
+
return this.getQueryBuilder;
|
|
34
|
+
}
|
|
35
|
+
}),
|
|
36
|
+
get getQueryBuilder() {
|
|
37
|
+
const self = this;
|
|
38
|
+
return IndexedDbDatabase.useSync(({
|
|
39
|
+
database,
|
|
40
|
+
IDBKeyRange,
|
|
41
|
+
reactivity
|
|
42
|
+
}) => IndexedDbQueryBuilder.make({
|
|
43
|
+
database,
|
|
44
|
+
IDBKeyRange,
|
|
45
|
+
tables: self.version.tables,
|
|
46
|
+
reactivity
|
|
47
|
+
}));
|
|
48
|
+
},
|
|
49
|
+
add(version, migrate) {
|
|
50
|
+
return makeMigration({
|
|
51
|
+
fromVersion: this.version,
|
|
52
|
+
version,
|
|
53
|
+
migrate,
|
|
54
|
+
previous: this
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
layer(databaseName) {
|
|
58
|
+
return layer(databaseName, this);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Tagged error for IndexedDB database operations, carrying a database error reason and the original cause.
|
|
63
|
+
*
|
|
64
|
+
* @category errors
|
|
65
|
+
* @since 4.0.0
|
|
66
|
+
*/
|
|
67
|
+
export class IndexedDbDatabaseError extends /*#__PURE__*/Data.TaggedError("IndexedDbDatabaseError") {
|
|
68
|
+
/**
|
|
69
|
+
* Marks this value as an IndexedDB database error for runtime guards.
|
|
70
|
+
*
|
|
71
|
+
* @since 4.0.0
|
|
72
|
+
*/
|
|
73
|
+
[ErrorTypeId] = ErrorTypeId;
|
|
74
|
+
message = this.reason;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Service tag for an open IndexedDB database, its `IDBKeyRange` constructor, reactivity service, and rebuild effect.
|
|
78
|
+
*
|
|
79
|
+
* **When to use**
|
|
80
|
+
*
|
|
81
|
+
* Use when you need access to the live database service after an
|
|
82
|
+
* `IndexedDbSchema` layer has been provided, especially for `rebuild` or
|
|
83
|
+
* lower-level database primitives.
|
|
84
|
+
*
|
|
85
|
+
* **Details**
|
|
86
|
+
*
|
|
87
|
+
* `database` is a mutable reference to the current `IDBDatabase`. `IDBKeyRange`
|
|
88
|
+
* and `reactivity` are shared with query builders created from the schema.
|
|
89
|
+
*
|
|
90
|
+
* **Gotchas**
|
|
91
|
+
*
|
|
92
|
+
* `rebuild` closes and deletes the browser database, then reopens it and reruns
|
|
93
|
+
* migrations. Records not recreated by migrations are removed.
|
|
94
|
+
*
|
|
95
|
+
* @see {@link IndexedDb.IndexedDb} for the lower-level browser IndexedDB primitives
|
|
96
|
+
* @see {@link make} for creating a schema that provides this service as a layer
|
|
97
|
+
*
|
|
98
|
+
* @category models
|
|
99
|
+
* @since 4.0.0
|
|
100
|
+
*/
|
|
101
|
+
export class IndexedDbDatabase extends /*#__PURE__*/Context.Service()(TypeId) {}
|
|
102
|
+
/**
|
|
103
|
+
* Creates the initial `IndexedDbSchema` from a version and an initialization migration run during database upgrade.
|
|
104
|
+
*
|
|
105
|
+
* @category constructors
|
|
106
|
+
* @since 4.0.0
|
|
107
|
+
*/
|
|
108
|
+
export const make = (initialVersion, init) => {
|
|
109
|
+
// oxlint-disable-next-line typescript/no-extraneous-class
|
|
110
|
+
function Initial() {}
|
|
111
|
+
Object.setPrototypeOf(Initial, SchemaProto);
|
|
112
|
+
Initial.version = initialVersion;
|
|
113
|
+
Initial.migrate = init;
|
|
114
|
+
return Initial;
|
|
115
|
+
};
|
|
116
|
+
const makeMigration = options => {
|
|
117
|
+
// oxlint-disable-next-line typescript/no-extraneous-class
|
|
118
|
+
function Migration() {}
|
|
119
|
+
Object.setPrototypeOf(Migration, SchemaProto);
|
|
120
|
+
Migration.previous = options.previous;
|
|
121
|
+
Migration.fromVersion = options.fromVersion;
|
|
122
|
+
Migration.version = options.version;
|
|
123
|
+
Migration.migrate = options.migrate;
|
|
124
|
+
return Migration;
|
|
125
|
+
};
|
|
126
|
+
const layer = (databaseName, migration) => Layer.effect(IndexedDbDatabase, Effect.gen(function* () {
|
|
127
|
+
const {
|
|
128
|
+
IDBKeyRange,
|
|
129
|
+
indexedDB
|
|
130
|
+
} = yield* IndexedDb.IndexedDb;
|
|
131
|
+
const reactivity = yield* Reactivity.Reactivity;
|
|
132
|
+
const context = yield* Effect.context();
|
|
133
|
+
const runForkWith = Effect.runForkWith(context);
|
|
134
|
+
let oldVersion = 0;
|
|
135
|
+
const migrations = [];
|
|
136
|
+
let current = migration;
|
|
137
|
+
while (current) {
|
|
138
|
+
migrations.unshift(current);
|
|
139
|
+
current = current.previous;
|
|
140
|
+
}
|
|
141
|
+
const version = migrations.length;
|
|
142
|
+
const database = MutableRef.make(null);
|
|
143
|
+
const open = Effect.callback(resume => {
|
|
144
|
+
const request = indexedDB.open(databaseName, version);
|
|
145
|
+
request.onblocked = event => {
|
|
146
|
+
resume(Effect.fail(new IndexedDbDatabaseError({
|
|
147
|
+
reason: "Blocked",
|
|
148
|
+
cause: event
|
|
149
|
+
})));
|
|
150
|
+
};
|
|
151
|
+
request.onerror = event => {
|
|
152
|
+
const idbRequest = event.target;
|
|
153
|
+
resume(Effect.fail(new IndexedDbDatabaseError({
|
|
154
|
+
reason: "OpenError",
|
|
155
|
+
cause: idbRequest.error
|
|
156
|
+
})));
|
|
157
|
+
};
|
|
158
|
+
let fiber;
|
|
159
|
+
request.onupgradeneeded = event => {
|
|
160
|
+
const idbRequest = event.target;
|
|
161
|
+
const db = idbRequest.result;
|
|
162
|
+
const transaction = idbRequest.transaction;
|
|
163
|
+
oldVersion = event.oldVersion;
|
|
164
|
+
MutableRef.set(database, db);
|
|
165
|
+
if (transaction === null) {
|
|
166
|
+
return resume(Effect.fail(new IndexedDbDatabaseError({
|
|
167
|
+
reason: "TransactionError",
|
|
168
|
+
cause: null
|
|
169
|
+
})));
|
|
170
|
+
}
|
|
171
|
+
transaction.onabort = event => {
|
|
172
|
+
resume(Effect.fail(new IndexedDbDatabaseError({
|
|
173
|
+
reason: "Aborted",
|
|
174
|
+
cause: event
|
|
175
|
+
})));
|
|
176
|
+
};
|
|
177
|
+
transaction.onerror = event => {
|
|
178
|
+
resume(Effect.fail(new IndexedDbDatabaseError({
|
|
179
|
+
reason: "TransactionError",
|
|
180
|
+
cause: event
|
|
181
|
+
})));
|
|
182
|
+
};
|
|
183
|
+
const effect = Effect.forEach(migrations.slice(oldVersion), untypedMigration => {
|
|
184
|
+
if (untypedMigration.previous === undefined) {
|
|
185
|
+
const migration = untypedMigration;
|
|
186
|
+
const api = makeTransactionProto({
|
|
187
|
+
database,
|
|
188
|
+
IDBKeyRange,
|
|
189
|
+
tables: migration.version.tables,
|
|
190
|
+
transaction,
|
|
191
|
+
reactivity
|
|
192
|
+
});
|
|
193
|
+
return migration.migrate(api);
|
|
194
|
+
} else if (untypedMigration.previous) {
|
|
195
|
+
const migration = untypedMigration;
|
|
196
|
+
const fromApi = makeTransactionProto({
|
|
197
|
+
database,
|
|
198
|
+
IDBKeyRange,
|
|
199
|
+
tables: migration.fromVersion.tables,
|
|
200
|
+
transaction,
|
|
201
|
+
reactivity
|
|
202
|
+
});
|
|
203
|
+
const toApi = makeTransactionProto({
|
|
204
|
+
database,
|
|
205
|
+
IDBKeyRange,
|
|
206
|
+
tables: migration.version.tables,
|
|
207
|
+
transaction,
|
|
208
|
+
reactivity
|
|
209
|
+
});
|
|
210
|
+
return migration.migrate(fromApi, toApi);
|
|
211
|
+
}
|
|
212
|
+
return Effect.die(new Error("Invalid migration"));
|
|
213
|
+
}, {
|
|
214
|
+
discard: true
|
|
215
|
+
}).pipe(Effect.mapError(cause => new IndexedDbDatabaseError({
|
|
216
|
+
reason: "UpgradeError",
|
|
217
|
+
cause
|
|
218
|
+
})), Effect.provideService(IndexedDbQueryBuilder.IndexedDbTransaction, transaction));
|
|
219
|
+
fiber = runForkWith(effect);
|
|
220
|
+
fiber.currentDispatcher.flush();
|
|
221
|
+
};
|
|
222
|
+
request.onsuccess = event => {
|
|
223
|
+
const idbRequest = event.target;
|
|
224
|
+
const db = idbRequest.result;
|
|
225
|
+
MutableRef.set(database, db);
|
|
226
|
+
if (fiber) {
|
|
227
|
+
// ensure migration errors are propagated
|
|
228
|
+
resume(Effect.asVoid(Fiber.join(fiber)));
|
|
229
|
+
} else {
|
|
230
|
+
resume(Effect.void);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
});
|
|
234
|
+
yield* Effect.addFinalizer(() => {
|
|
235
|
+
database.current?.close();
|
|
236
|
+
return Effect.void;
|
|
237
|
+
});
|
|
238
|
+
yield* open;
|
|
239
|
+
const rebuildLock = Semaphore.makeUnsafe(1).withPermit;
|
|
240
|
+
const rebuild = Effect.callback(resume => {
|
|
241
|
+
database.current?.close();
|
|
242
|
+
const request = indexedDB.deleteDatabase(databaseName);
|
|
243
|
+
request.onerror = _ => {
|
|
244
|
+
resume(Effect.fail(new IndexedDbDatabaseError({
|
|
245
|
+
reason: "OpenError",
|
|
246
|
+
cause: request.error
|
|
247
|
+
})));
|
|
248
|
+
};
|
|
249
|
+
request.onsuccess = () => {
|
|
250
|
+
resume(Effect.void);
|
|
251
|
+
};
|
|
252
|
+
}).pipe(Effect.flatMap(() => open), rebuildLock);
|
|
253
|
+
return IndexedDbDatabase.of({
|
|
254
|
+
database,
|
|
255
|
+
IDBKeyRange,
|
|
256
|
+
rebuild,
|
|
257
|
+
reactivity
|
|
258
|
+
});
|
|
259
|
+
})).pipe(Layer.provide(Reactivity.layer));
|
|
260
|
+
const makeTransactionProto = ({
|
|
261
|
+
IDBKeyRange,
|
|
262
|
+
database,
|
|
263
|
+
tables,
|
|
264
|
+
transaction,
|
|
265
|
+
reactivity
|
|
266
|
+
}) => {
|
|
267
|
+
const migration = IndexedDbQueryBuilder.make({
|
|
268
|
+
database,
|
|
269
|
+
IDBKeyRange,
|
|
270
|
+
tables,
|
|
271
|
+
reactivity
|
|
272
|
+
});
|
|
273
|
+
migration.transaction = transaction;
|
|
274
|
+
migration.createObjectStore = Effect.fnUntraced(function* (table) {
|
|
275
|
+
const createTable = yield* Effect.fromNullishOr(tables.get(table)).pipe(Effect.mapError(cause => new IndexedDbDatabaseError({
|
|
276
|
+
reason: "MissingTable",
|
|
277
|
+
cause
|
|
278
|
+
})));
|
|
279
|
+
return yield* Effect.try({
|
|
280
|
+
try: () => database.current.createObjectStore(createTable.tableName, {
|
|
281
|
+
keyPath: createTable.keyPath,
|
|
282
|
+
autoIncrement: createTable.autoIncrement
|
|
283
|
+
}),
|
|
284
|
+
catch: cause => new IndexedDbDatabaseError({
|
|
285
|
+
reason: "TransactionError",
|
|
286
|
+
cause
|
|
287
|
+
})
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
migration.deleteObjectStore = Effect.fnUntraced(function* (table) {
|
|
291
|
+
const createTable = yield* Effect.fromNullishOr(tables.get(table)).pipe(Effect.mapError(cause => new IndexedDbDatabaseError({
|
|
292
|
+
reason: "MissingTable",
|
|
293
|
+
cause
|
|
294
|
+
})));
|
|
295
|
+
return yield* Effect.try({
|
|
296
|
+
try: () => database.current.deleteObjectStore(createTable.tableName),
|
|
297
|
+
catch: cause => new IndexedDbDatabaseError({
|
|
298
|
+
reason: "TransactionError",
|
|
299
|
+
cause
|
|
300
|
+
})
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
migration.createIndex = Effect.fnUntraced(function* (table, indexName, options) {
|
|
304
|
+
const store = transaction.objectStore(table);
|
|
305
|
+
const sourceTable = tables.get(table);
|
|
306
|
+
const keyPath = yield* Effect.fromNullishOr(sourceTable.indexes[indexName]).pipe(Effect.mapError(cause => new IndexedDbDatabaseError({
|
|
307
|
+
reason: "MissingIndex",
|
|
308
|
+
cause
|
|
309
|
+
})));
|
|
310
|
+
return yield* Effect.try({
|
|
311
|
+
try: () => store.createIndex(indexName, keyPath, options),
|
|
312
|
+
catch: cause => new IndexedDbDatabaseError({
|
|
313
|
+
reason: "TransactionError",
|
|
314
|
+
cause
|
|
315
|
+
})
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
migration.deleteIndex = (table, indexName) => Effect.try({
|
|
319
|
+
try: () => transaction.objectStore(table).deleteIndex(indexName),
|
|
320
|
+
catch: cause => new IndexedDbDatabaseError({
|
|
321
|
+
reason: "TransactionError",
|
|
322
|
+
cause
|
|
323
|
+
})
|
|
324
|
+
});
|
|
325
|
+
return migration;
|
|
326
|
+
};
|
|
327
|
+
//# sourceMappingURL=IndexedDbDatabase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IndexedDbDatabase.js","names":["Context","Data","Effect","Effectable","Fiber","Layer","MutableRef","Semaphore","Reactivity","IndexedDb","IndexedDbQueryBuilder","TypeId","ErrorTypeId","SchemaProto","_A","_","Prototype","label","evaluate","getQueryBuilder","self","IndexedDbDatabase","useSync","database","IDBKeyRange","reactivity","make","tables","version","add","migrate","makeMigration","fromVersion","previous","layer","databaseName","IndexedDbDatabaseError","TaggedError","message","reason","Service","initialVersion","init","Initial","Object","setPrototypeOf","options","Migration","migration","effect","gen","indexedDB","context","runForkWith","oldVersion","migrations","current","unshift","length","open","callback","resume","request","onblocked","event","fail","cause","onerror","idbRequest","target","error","fiber","onupgradeneeded","db","result","transaction","set","onabort","forEach","slice","untypedMigration","undefined","api","makeTransactionProto","fromApi","toApi","die","Error","discard","pipe","mapError","provideService","IndexedDbTransaction","currentDispatcher","flush","onsuccess","asVoid","join","void","addFinalizer","close","rebuildLock","makeUnsafe","withPermit","rebuild","deleteDatabase","flatMap","of","provide","createObjectStore","fnUntraced","table","createTable","fromNullishOr","get","try","tableName","keyPath","autoIncrement","catch","deleteObjectStore","createIndex","indexName","store","objectStore","sourceTable","indexes","deleteIndex"],"sources":["../src/IndexedDbDatabase.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;AAYA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,IAAI,MAAM,aAAa;AACnC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,UAAU,MAAM,mBAAmB;AAC/C,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,UAAU,MAAM,mBAAmB;AAC/C,OAAO,KAAKC,SAAS,MAAM,kBAAkB;AAC7C,OAAO,KAAKC,UAAU,MAAM,uCAAuC;AACnE,OAAO,KAAKC,SAAS,MAAM,gBAAgB;AAC3C,OAAO,KAAKC,qBAAqB,MAAM,4BAA4B;AAInE,MAAMC,MAAM,GAAG,6CAA6C;AAC5D,MAAMC,WAAW,GAAG,oEAAoE;AAExF,MAAMC,WAAW,GAAG;EAClB,CAACF,MAAM,GAAG;IACRG,EAAE,EAAGC,CAAQ,IAAKA;GACnB;EACD,iBAAGZ,UAAU,CAACa,SAAS,CAAiC;IACtDC,KAAK,EAAE,iBAAiB;IACxBC,QAAQA,CAAA;MACN,OAAO,IAAI,CAACC,eAAe;IAC7B;GACD,CAAC;EACF,IAAIA,eAAeA,CAAA;IACjB,MAAMC,IAAI,GAAG,IAAiD;IAC9D,OAAOC,iBAAiB,CAACC,OAAO,CAAC,CAAC;MAAEC,QAAQ;MAAEC,WAAW;MAAEC;IAAU,CAAE,KACrEf,qBAAqB,CAACgB,IAAI,CAAC;MACzBH,QAAQ;MACRC,WAAW;MACXG,MAAM,EAAEP,IAAI,CAACQ,OAAO,CAACD,MAAM;MAC3BF;KACD,CAAC,CACH;EACH,CAAC;EACDI,GAAGA,CAEDD,OAAgB,EAChBE,OAG+B;IAE/B,OAAOC,aAAa,CAAC;MACnBC,WAAW,EAAE,IAAI,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