@noldova/context.data.sql.sqlite 0.0.0-stage → 0.0.7
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/LICENSE +21 -0
- package/README.md +29 -2
- package/api/index.d.ts +87 -0
- package/api/index.js +12 -0
- package/api/index.js.map +1 -0
- package/extensions/db-context-options-builder.extensions.js +18 -0
- package/extensions/db-context-options-builder.extensions.js.map +1 -0
- package/models/sqlite-connection.js +38 -0
- package/models/sqlite-connection.js.map +1 -0
- package/models/sqlite-session.js +44 -0
- package/models/sqlite-session.js.map +1 -0
- package/package.json +26 -4
- package/resources.js +19 -0
- package/resources.js.map +1 -0
- package/services/sqlite-dialect.js +24 -0
- package/services/sqlite-dialect.js.map +1 -0
- package/services/sqlite-provider.js +15 -0
- package/services/sqlite-provider.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Noldova
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
-
#
|
|
1
|
+
# noldova.context.data.sql.sqlite
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The SQLite provider of `noldova.context.data.sql`, on the host's
|
|
4
|
+
`node:sqlite`: a connection opens a database file with write-ahead logging
|
|
5
|
+
and foreign keys on, creating its folder and the file when absent, and runs
|
|
6
|
+
its statements and transactions one at a time. Inside a transaction's
|
|
7
|
+
action, every statement goes through the transaction the action receives.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @noldova/context.data.sql.sqlite
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Use
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { DbContextOptionsBuilder } from "@noldova/context.data";
|
|
19
|
+
import "@noldova/context.data.sql.sqlite";
|
|
20
|
+
|
|
21
|
+
await using context = new NotesContext(new DbContextOptionsBuilder().useSQLite("data/notes.db"));
|
|
22
|
+
await context.database.migrateAsync();
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The declaration file `api/index.d.ts` documents every member with its
|
|
26
|
+
contract.
|
|
27
|
+
|
|
28
|
+
## License
|
|
29
|
+
|
|
30
|
+
MIT; see `LICENSE`.
|
package/api/index.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { DataSource, DbContextOptions } from "@noldova/context.data";
|
|
10
|
+
import { ColumnType, SqlConnection, SqlDialect, type SqlMigration, SqlProvider } from "@noldova/context.data.sql";
|
|
11
|
+
|
|
12
|
+
declare module "@noldova/context.data" {
|
|
13
|
+
interface DbContextOptionsBuilder {
|
|
14
|
+
/**
|
|
15
|
+
* Returns options that open the SQLite database file at the location
|
|
16
|
+
* through `SQLiteProvider`; the data source is named after the file
|
|
17
|
+
* without its extension. A blank location throws `ArgumentException`.
|
|
18
|
+
*/
|
|
19
|
+
useSQLite(location: string): DbContextOptions<SqlConnection, SqlMigration>;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* How SQLite spells transactions, column types, generated keys, and locks.
|
|
25
|
+
*/
|
|
26
|
+
export declare class SQLiteDialect extends SqlDialect {
|
|
27
|
+
/**
|
|
28
|
+
* `BEGIN IMMEDIATE`, which takes the file's write lock when the
|
|
29
|
+
* transaction begins, so a second writer waits for it there instead of
|
|
30
|
+
* failing at its first write with a stale read.
|
|
31
|
+
*/
|
|
32
|
+
public override formatBeginTransaction(): string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* `TEXT` or `INTEGER`.
|
|
36
|
+
*/
|
|
37
|
+
public override formatColumnType(type: ColumnType): string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* `INTEGER PRIMARY KEY AUTOINCREMENT`, so a key is never reused after its
|
|
41
|
+
* row is deleted.
|
|
42
|
+
*/
|
|
43
|
+
public override formatIdentityColumnType(): string;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* No statements: every transaction takes the file's write lock when it
|
|
47
|
+
* begins, so one transaction at a time runs.
|
|
48
|
+
*/
|
|
49
|
+
public override formatLock(): readonly string[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A connection to a SQLite database file through the host's `node:sqlite`,
|
|
54
|
+
* opened with write-ahead logging, foreign keys on, and a busy timeout of
|
|
55
|
+
* five seconds, within which a transaction waits for another connection's
|
|
56
|
+
* write lock. The data source's
|
|
57
|
+
* location is the file path. Rows hold text, numbers, and `NULL`; a row
|
|
58
|
+
* holding another value, such as a blob, rejects with `DataException` when
|
|
59
|
+
* read. `node:sqlite` runs each statement synchronously, so a statement holds
|
|
60
|
+
* the host's thread while it runs.
|
|
61
|
+
*/
|
|
62
|
+
export declare class SQLiteConnection extends SqlConnection {
|
|
63
|
+
/**
|
|
64
|
+
* Opens the data source's file, creating its directory and the file when
|
|
65
|
+
* absent.
|
|
66
|
+
*/
|
|
67
|
+
public static open(dataSource: DataSource): SQLiteConnection;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The SQLite dialect.
|
|
71
|
+
*/
|
|
72
|
+
public override get dialect(): SqlDialect;
|
|
73
|
+
|
|
74
|
+
private constructor(dataSource: DataSource, session: unknown);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The SQLite provider: opens `SQLiteConnection` on a data source's file and
|
|
79
|
+
* inherits the `SqlMigrator`. Reached through
|
|
80
|
+
* `DbContextOptionsBuilder.useSQLite`.
|
|
81
|
+
*/
|
|
82
|
+
export declare class SQLiteProvider extends SqlProvider {
|
|
83
|
+
/**
|
|
84
|
+
* Opens the data source's file.
|
|
85
|
+
*/
|
|
86
|
+
public override openConnection(dataSource: DataSource): SQLiteConnection;
|
|
87
|
+
}
|
package/api/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import "../extensions/db-context-options-builder.extensions.js";
|
|
9
|
+
export { SQLiteConnection } from "../models/sqlite-connection.js";
|
|
10
|
+
export { SQLiteDialect } from "../services/sqlite-dialect.js";
|
|
11
|
+
export { SQLiteProvider } from "../services/sqlite-provider.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
package/api/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/data/noldova.context.data.sql.sqlite/src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,wDAAwD,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
// This file uses Node APIs and will change when we replace Node.
|
|
9
|
+
import { basename, extname } from "node:path";
|
|
10
|
+
import { DataSource, DbContextOptionsBuilder } from "@noldova/context.data";
|
|
11
|
+
import { ArgumentException } from "@noldova/context.exceptions";
|
|
12
|
+
import { Resources } from "../resources.js";
|
|
13
|
+
import { SQLiteProvider } from "../services/sqlite-provider.js";
|
|
14
|
+
DbContextOptionsBuilder.prototype.useSQLite = function (location) {
|
|
15
|
+
ArgumentException.throwIfNullOrWhitespace(location, Resources.locationParameterName);
|
|
16
|
+
return this.use(new SQLiteProvider(), new DataSource(basename(location, extname(location)), location));
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=db-context-options-builder.extensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-context-options-builder.extensions.js","sourceRoot":"","sources":["../../../../src/data/noldova.context.data.sql.sqlite/src/extensions/db-context-options-builder.extensions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,iEAAiE;AAEjE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAyB,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAQhE,uBAAuB,CAAC,SAAS,CAAC,SAAS,GAAG,UAAyC,QAAgB;IACrG,iBAAiB,CAAC,uBAAuB,CAAC,QAAQ,EAAE,SAAS,CAAC,qBAAqB,CAAC,CAAC;IAErF,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,cAAc,EAAE,EAAE,IAAI,UAAU,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;AACzG,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
// This file uses Node APIs and will change when we replace Node.
|
|
9
|
+
import { mkdirSync } from "node:fs";
|
|
10
|
+
import { dirname } from "node:path";
|
|
11
|
+
import { DatabaseSync } from "node:sqlite";
|
|
12
|
+
import { SqlConnection } from "@noldova/context.data.sql";
|
|
13
|
+
import { Resources } from "../resources.js";
|
|
14
|
+
import { SQLiteDialect } from "../services/sqlite-dialect.js";
|
|
15
|
+
import { SQLiteSession } from "./sqlite-session.js";
|
|
16
|
+
export class SQLiteConnection extends SqlConnection {
|
|
17
|
+
sqliteDialect = new SQLiteDialect();
|
|
18
|
+
constructor(dataSource, session) {
|
|
19
|
+
super(dataSource, session);
|
|
20
|
+
}
|
|
21
|
+
static open(dataSource) {
|
|
22
|
+
mkdirSync(dirname(dataSource.location), { recursive: true });
|
|
23
|
+
const handle = new DatabaseSync(dataSource.location, { timeout: Resources.busyTimeout });
|
|
24
|
+
try {
|
|
25
|
+
handle.exec(Resources.journalModePragma);
|
|
26
|
+
handle.exec(Resources.foreignKeysPragma);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
handle.close();
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
return new SQLiteConnection(dataSource, new SQLiteSession(handle));
|
|
33
|
+
}
|
|
34
|
+
get dialect() {
|
|
35
|
+
return this.sqliteDialect;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=sqlite-connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-connection.js","sourceRoot":"","sources":["../../../../src/data/noldova.context.data.sql.sqlite/src/models/sqlite-connection.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,iEAAiE;AAEjE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,EAAE,aAAa,EAAmB,MAAM,2BAA2B,CAAC;AAE3E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,OAAO,gBAAiB,SAAQ,aAAa;IAChC,aAAa,GAAe,IAAI,aAAa,EAAE,CAAC;IAEjE,YAAoB,UAAsB,EAAE,OAAsB;QAChE,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC7B,CAAC;IAEM,MAAM,CAAC,IAAI,CAAC,UAAsB;QACvC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7D,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;QACzF,IAAI,CAAC;YACH,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;YACzC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,MAAM,KAAK,CAAC;QACd,CAAC;QAED,OAAO,IAAI,gBAAgB,CAAC,UAAU,EAAE,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,IAAoB,OAAO;QACzB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import "@noldova/context.core";
|
|
9
|
+
import { DataException, DataRecord } from "@noldova/context.data";
|
|
10
|
+
import { SqlSession } from "@noldova/context.data.sql";
|
|
11
|
+
import { Resources } from "../resources.js";
|
|
12
|
+
export class SQLiteSession extends SqlSession {
|
|
13
|
+
handle;
|
|
14
|
+
constructor(handle) {
|
|
15
|
+
super();
|
|
16
|
+
this.handle = handle;
|
|
17
|
+
}
|
|
18
|
+
get isOpen() {
|
|
19
|
+
return this.handle.isOpen;
|
|
20
|
+
}
|
|
21
|
+
async executeAsync(query) {
|
|
22
|
+
return Number(this.handle.prepare(query.text).run(...query.parameters).changes);
|
|
23
|
+
}
|
|
24
|
+
async insertAsync(query) {
|
|
25
|
+
return Number(this.handle.prepare(query.text).run(...query.parameters).lastInsertRowid);
|
|
26
|
+
}
|
|
27
|
+
async queryAsync(query) {
|
|
28
|
+
return this.handle.prepare(query.text).all(...query.parameters).map(t => SQLiteSession.toRecord(t));
|
|
29
|
+
}
|
|
30
|
+
async closeAsync() {
|
|
31
|
+
if (this.handle.isOpen)
|
|
32
|
+
this.handle.close();
|
|
33
|
+
}
|
|
34
|
+
static toRecord(row) {
|
|
35
|
+
const values = new Map();
|
|
36
|
+
for (const [name, value] of Object.entries(row)) {
|
|
37
|
+
if (!Object.isNull(value) && !Object.isString(value) && !Object.isNumber(value))
|
|
38
|
+
throw new DataException(Resources.unsupportedValue);
|
|
39
|
+
values.set(name, value);
|
|
40
|
+
}
|
|
41
|
+
return new DataRecord(values);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=sqlite-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-session.js","sourceRoot":"","sources":["../../../../src/data/noldova.context.data.sql.sqlite/src/models/sqlite-session.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAkB,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAiB,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEtE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,OAAO,aAAc,SAAQ,UAAU;IAC1B,MAAM,CAAe;IAEtC,YAAmB,MAAoB;QACrC,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,IAAoB,MAAM;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAEe,KAAK,CAAC,YAAY,CAAC,KAAe;QAChD,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC;IAClF,CAAC;IAEe,KAAK,CAAC,WAAW,CAAC,KAAe;QAC/C,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,eAAe,CAAC,CAAC;IAC1F,CAAC;IAEe,KAAK,CAAC,UAAU,CAAC,KAAe;QAC9C,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACtG,CAAC;IAEe,KAAK,CAAC,UAAU;QAC9B,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM;YACpB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAEO,MAAM,CAAC,QAAQ,CAAC,GAAmC;QACzD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAqB,CAAC;QAC5C,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAChD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;gBAC7E,MAAM,IAAI,aAAa,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;YAEtD,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC1B,CAAC;QAED,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noldova/context.data.sql.sqlite",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.7",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "api/index.js",
|
|
6
|
+
"types": "api/index.d.ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/noldova-com/context.git",
|
|
11
|
+
"directory": "src/data/noldova.context.data.sql.sqlite"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/noldova-com/context#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/noldova-com/context/issues"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public",
|
|
19
|
+
"registry": "https://registry.npmjs.org/"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@noldova/context.core": "0.0.7",
|
|
23
|
+
"@noldova/context.data": "0.0.7",
|
|
24
|
+
"@noldova/context.data.sql": "0.0.7",
|
|
25
|
+
"@noldova/context.exceptions": "0.0.7"
|
|
26
|
+
},
|
|
27
|
+
"gitHead": "e9d41328166262bf33aa8c896abc82092ebdfffc"
|
|
28
|
+
}
|
package/resources.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export class Resources {
|
|
9
|
+
static beginTransaction = "BEGIN IMMEDIATE";
|
|
10
|
+
static busyTimeout = 5000;
|
|
11
|
+
static foreignKeysPragma = "PRAGMA foreign_keys = ON";
|
|
12
|
+
static identityColumnType = "INTEGER PRIMARY KEY AUTOINCREMENT";
|
|
13
|
+
static integerType = "INTEGER";
|
|
14
|
+
static journalModePragma = "PRAGMA journal_mode = WAL";
|
|
15
|
+
static locationParameterName = "location";
|
|
16
|
+
static textType = "TEXT";
|
|
17
|
+
static unsupportedValue = "The row holds a value that is neither text, a number, nor null.";
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=resources.js.map
|
package/resources.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../../src/data/noldova.context.data.sql.sqlite/src/resources.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,OAAO,SAAS;IACb,MAAM,CAAU,gBAAgB,GAAW,iBAAiB,CAAC;IAC7D,MAAM,CAAU,WAAW,GAAW,IAAI,CAAC;IAC3C,MAAM,CAAU,iBAAiB,GAAW,0BAA0B,CAAC;IACvE,MAAM,CAAU,kBAAkB,GAAW,mCAAmC,CAAC;IACjF,MAAM,CAAU,WAAW,GAAW,SAAS,CAAC;IAChD,MAAM,CAAU,iBAAiB,GAAW,2BAA2B,CAAC;IACxE,MAAM,CAAU,qBAAqB,GAAW,UAAU,CAAC;IAC3D,MAAM,CAAU,QAAQ,GAAW,MAAM,CAAC;IAC1C,MAAM,CAAU,gBAAgB,GAAW,iEAAiE,CAAC;CACrH"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import { ColumnType, SqlDialect } from "@noldova/context.data.sql";
|
|
9
|
+
import { Resources } from "../resources.js";
|
|
10
|
+
export class SQLiteDialect extends SqlDialect {
|
|
11
|
+
formatBeginTransaction() {
|
|
12
|
+
return Resources.beginTransaction;
|
|
13
|
+
}
|
|
14
|
+
formatColumnType(type) {
|
|
15
|
+
return type === ColumnType.Integer ? Resources.integerType : Resources.textType;
|
|
16
|
+
}
|
|
17
|
+
formatIdentityColumnType() {
|
|
18
|
+
return Resources.identityColumnType;
|
|
19
|
+
}
|
|
20
|
+
formatLock() {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=sqlite-dialect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-dialect.js","sourceRoot":"","sources":["../../../../src/data/noldova.context.data.sql.sqlite/src/services/sqlite-dialect.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,OAAO,aAAc,SAAQ,UAAU;IAC3B,sBAAsB;QACpC,OAAO,SAAS,CAAC,gBAAgB,CAAC;IACpC,CAAC;IAEe,gBAAgB,CAAC,IAAgB;QAC/C,OAAO,IAAI,KAAK,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC;IAClF,CAAC;IAEe,wBAAwB;QACtC,OAAO,SAAS,CAAC,kBAAkB,CAAC;IACtC,CAAC;IAEe,UAAU;QACxB,OAAO,EAAE,CAAC;IACZ,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import { SqlProvider } from "@noldova/context.data.sql";
|
|
9
|
+
import { SQLiteConnection } from "../models/sqlite-connection.js";
|
|
10
|
+
export class SQLiteProvider extends SqlProvider {
|
|
11
|
+
openConnection(dataSource) {
|
|
12
|
+
return SQLiteConnection.open(dataSource);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=sqlite-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-provider.js","sourceRoot":"","sources":["../../../../src/data/noldova.context.data.sql.sqlite/src/services/sqlite-provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,MAAM,OAAO,cAAe,SAAQ,WAAW;IAC7B,cAAc,CAAC,UAAsB;QACnD,OAAO,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;CACF"}
|