@fedify/sqlite 2.0.0-pr.412.1559 → 2.0.0-pr.412.1794
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/deno.json +1 -3
- package/dist/_virtual/{rolldown_runtime.js → rolldown_runtime.cjs} +9 -6
- package/dist/adapter.d.cts +45 -0
- package/dist/dist/sqlite.node.d.cts +2 -0
- package/dist/kv.cjs +188 -0
- package/dist/kv.d.cts +76 -0
- package/dist/kv.js +11 -12
- package/dist/mod.cjs +6 -0
- package/dist/mod.d.cts +2 -0
- package/dist/mod.js +2 -2
- package/dist/sqlite.bun.cjs +42 -0
- package/dist/sqlite.bun.d.cts +23 -0
- package/dist/sqlite.bun.js +2 -2
- package/dist/sqlite.node.cjs +44 -0
- package/dist/sqlite.node.d.cts +23 -0
- package/dist/sqlite.node.js +2 -2
- package/package.json +17 -7
- package/src/kv.test.ts +3 -3
- package/src/kv.ts +5 -6
- package/tsdown.config.ts +12 -4
- package/dist/node_modules/.pnpm/@js-temporal_polyfill@0.5.1/node_modules/@js-temporal/polyfill/dist/index.esm.js +0 -5795
- package/dist/node_modules/.pnpm/jsbi@4.3.2/node_modules/jsbi/dist/jsbi-cjs.js +0 -1139
package/src/kv.test.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as temporal from "@js-temporal/polyfill";
|
|
|
3
3
|
import { delay } from "@std/async/delay";
|
|
4
4
|
import assert from "node:assert/strict";
|
|
5
5
|
import { test } from "node:test";
|
|
6
|
-
import { SqliteKvStore } from "
|
|
6
|
+
import { SqliteKvStore } from "@fedify/sqlite/kv";
|
|
7
7
|
|
|
8
8
|
let Temporal: typeof temporal.Temporal;
|
|
9
9
|
if ("Temporal" in globalThis) {
|
|
@@ -31,7 +31,7 @@ test("SqliteKvStore.initialize()", async () => {
|
|
|
31
31
|
try {
|
|
32
32
|
await store.initialize();
|
|
33
33
|
const result = await db.prepare(`
|
|
34
|
-
SELECT name FROM sqlite_master
|
|
34
|
+
SELECT name FROM sqlite_master
|
|
35
35
|
WHERE type='table' AND name=?
|
|
36
36
|
`).get(tableName);
|
|
37
37
|
assert(result !== undefined);
|
|
@@ -180,7 +180,7 @@ test("SqliteKvStore.drop()", async () => {
|
|
|
180
180
|
try {
|
|
181
181
|
await store.drop();
|
|
182
182
|
const result = await db.prepare(`
|
|
183
|
-
SELECT name FROM sqlite_master
|
|
183
|
+
SELECT name FROM sqlite_master
|
|
184
184
|
WHERE type='table' AND name=?
|
|
185
185
|
`).get(tableName);
|
|
186
186
|
// Bun returns null, Node returns undefined
|
package/src/kv.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type PlatformDatabase, SqliteDatabase } from "#sqlite";
|
|
2
2
|
import type { KvKey, KvStore, KvStoreSetOptions } from "@fedify/fedify";
|
|
3
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
4
3
|
import { getLogger } from "@logtape/logtape";
|
|
5
4
|
import { isEqual } from "es-toolkit";
|
|
6
5
|
import type { SqliteDatabaseAdapter } from "./adapter.ts";
|
|
@@ -81,8 +80,8 @@ export class SqliteKvStore implements KvStore {
|
|
|
81
80
|
|
|
82
81
|
const result = this.#db
|
|
83
82
|
.prepare(`
|
|
84
|
-
SELECT value
|
|
85
|
-
FROM "${this.#tableName}"
|
|
83
|
+
SELECT value
|
|
84
|
+
FROM "${this.#tableName}"
|
|
86
85
|
WHERE key = ? AND (expires IS NULL OR expires > ?)
|
|
87
86
|
`)
|
|
88
87
|
.get(encodedKey, now);
|
|
@@ -170,8 +169,8 @@ export class SqliteKvStore implements KvStore {
|
|
|
170
169
|
|
|
171
170
|
const currentResult = this.#db
|
|
172
171
|
.prepare(`
|
|
173
|
-
SELECT value
|
|
174
|
-
FROM "${this.#tableName}"
|
|
172
|
+
SELECT value
|
|
173
|
+
FROM "${this.#tableName}"
|
|
175
174
|
WHERE key = ? AND (expires IS NULL OR expires > ?)
|
|
176
175
|
`)
|
|
177
176
|
.get(encodedKey, now) as { value: string } | undefined;
|
|
@@ -236,7 +235,7 @@ export class SqliteKvStore implements KvStore {
|
|
|
236
235
|
`);
|
|
237
236
|
|
|
238
237
|
this.#db.exec(`
|
|
239
|
-
CREATE INDEX IF NOT EXISTS "idx_${this.#tableName}_expires"
|
|
238
|
+
CREATE INDEX IF NOT EXISTS "idx_${this.#tableName}_expires"
|
|
240
239
|
ON "${this.#tableName}" (expires)
|
|
241
240
|
`);
|
|
242
241
|
|
package/tsdown.config.ts
CHANGED
|
@@ -4,6 +4,7 @@ export default defineConfig({
|
|
|
4
4
|
entry: ["src/mod.ts", "src/kv.ts", "src/sqlite.node.ts", "src/sqlite.bun.ts"],
|
|
5
5
|
dts: true,
|
|
6
6
|
unbundle: true,
|
|
7
|
+
format: ["esm", "cjs"],
|
|
7
8
|
platform: "node",
|
|
8
9
|
inputOptions: {
|
|
9
10
|
onwarn(warning, defaultHandler) {
|
|
@@ -16,9 +17,16 @@ export default defineConfig({
|
|
|
16
17
|
defaultHandler(warning);
|
|
17
18
|
},
|
|
18
19
|
},
|
|
19
|
-
outputOptions
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
outputOptions(outputOptions, format) {
|
|
21
|
+
if (format === "cjs") {
|
|
22
|
+
outputOptions.intro = `
|
|
23
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
|
24
|
+
`;
|
|
25
|
+
} else {
|
|
26
|
+
outputOptions.intro = `
|
|
27
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
28
|
+
`;
|
|
29
|
+
}
|
|
30
|
+
return outputOptions;
|
|
23
31
|
},
|
|
24
32
|
});
|