@fedify/sqlite 1.8.15-dev.1889 → 1.8.15

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 CHANGED
@@ -1,14 +1,12 @@
1
1
  {
2
2
  "name": "@fedify/sqlite",
3
- "version": "1.8.15-dev.1889+8a40b0d9",
3
+ "version": "1.8.15",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./src/mod.ts",
7
7
  "./kv": "./src/kv.ts"
8
8
  },
9
9
  "imports": {
10
- "@fedify/sqlite": "./src/mod.ts",
11
- "@fedify/sqlite/": "./src/",
12
10
  "#sqlite": "./src/sqlite.node.ts"
13
11
  },
14
12
  "exclude": [
package/dist/kv.js CHANGED
@@ -2,7 +2,6 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
 
4
4
  import { SqliteDatabase } from "#sqlite";
5
- import { Temporal } from "@js-temporal/polyfill";
6
5
  import { getLogger } from "@logtape/logtape";
7
6
  import { isEqual } from "es-toolkit";
8
7
 
@@ -55,8 +54,8 @@ var SqliteKvStore = class SqliteKvStore {
55
54
  const encodedKey = this.#encodeKey(key);
56
55
  const now = Temporal.Now.instant().epochMilliseconds;
57
56
  const result = this.#db.prepare(`
58
- SELECT value
59
- FROM "${this.#tableName}"
57
+ SELECT value
58
+ FROM "${this.#tableName}"
60
59
  WHERE key = ? AND (expires IS NULL OR expires > ?)
61
60
  `).get(encodedKey, now);
62
61
  if (!result) return void 0;
@@ -103,8 +102,8 @@ var SqliteKvStore = class SqliteKvStore {
103
102
  try {
104
103
  this.#db.exec("BEGIN IMMEDIATE");
105
104
  const currentResult = this.#db.prepare(`
106
- SELECT value
107
- FROM "${this.#tableName}"
105
+ SELECT value
106
+ FROM "${this.#tableName}"
108
107
  WHERE key = ? AND (expires IS NULL OR expires > ?)
109
108
  `).get(encodedKey, now);
110
109
  const currentValue = currentResult === void 0 ? void 0 : this.#decodeValue(currentResult.value);
@@ -149,7 +148,7 @@ var SqliteKvStore = class SqliteKvStore {
149
148
  )
150
149
  `);
151
150
  this.#db.exec(`
152
- CREATE INDEX IF NOT EXISTS "idx_${this.#tableName}_expires"
151
+ CREATE INDEX IF NOT EXISTS "idx_${this.#tableName}_expires"
153
152
  ON "${this.#tableName}" (expires)
154
153
  `);
155
154
  this.#initialized = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/sqlite",
3
- "version": "1.8.15-dev.1889+8a40b0d9",
3
+ "version": "1.8.15",
4
4
  "description": "SQLite drivers for Fedify",
5
5
  "keywords": [
6
6
  "fedify",
@@ -52,7 +52,7 @@
52
52
  "es-toolkit": "^1.31.0"
53
53
  },
54
54
  "peerDependencies": {
55
- "@fedify/fedify": "^1.8.15-dev.1889+8a40b0d9"
55
+ "@fedify/fedify": "^1.8.15"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@std/async": "npm:@jsr/std__async@^1.0.13",
package/src/kv.test.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { PlatformDatabase } from "#sqlite";
2
+ import { SqliteKvStore } from "@fedify/sqlite/kv";
2
3
  import * as temporal from "@js-temporal/polyfill";
3
4
  import { delay } from "@std/async/delay";
4
5
  import assert from "node:assert/strict";
5
6
  import { test } from "node:test";
6
- import { SqliteKvStore } from "./kv.ts";
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