@pluv/persistence-cloudflare-transactional-storage 5.1.0 → 5.1.1
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/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/PersistenceCloudflareTransactionalStorage.ts"],"mappings":";;;UAiBiB;EACb;;qBAES,kDAAkD;UACnD;UACA;UACA;EAER,YAAY,QAAQ;EASP,QACT,cACA,sBACA,MAAM,oBACP;EAkCU,mBAAmB,eAAe;EAoBlC,WAAW,cAAc,uBAAuB;EAuBhD,YAAY,eAAe;EAqC3B,gBAAgB,eAAe;EA6B/B,QAAQ,cAAc,uBAAuB,QAAQ;EAmCrD,SACT,eACD,QAAQ,KAAK,0BAA0B;EAwC7B,aAAa,eAAe;EAgClC,WAAW;IAAe,OAAO;;EAiC3B,gBAAgB,cAAc,gBAAgB;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/PersistenceCloudflareTransactionalStorage.ts"],"mappings":";;;UAiBiB;EACb;;qBAES,kDAAkD;UACnD;UACA;UACA;EAER,YAAY,QAAQ;EASP,QACT,cACA,sBACA,MAAM,oBACP;EAkCU,mBAAmB,eAAe;EAoBlC,WAAW,cAAc,uBAAuB;EAuBhD,YAAY,eAAe;EAqC3B,gBAAgB,eAAe;EA6B/B,QAAQ,cAAc,uBAAuB,QAAQ;EAmCrD,SACT,eACD,QAAQ,KAAK,0BAA0B;EAwC7B,aAAa,eAAe;EAgClC,WAAW;IAAe,OAAO;;EAiC3B,gBAAgB,cAAc,gBAAgB;UA6CnD;UAQA"}
|
package/dist/index.mjs
CHANGED
|
@@ -209,7 +209,7 @@ var PersistenceCloudflareTransactionalStorage = class PersistenceCloudflareTrans
|
|
|
209
209
|
if (!this._state) return;
|
|
210
210
|
await this._initialized;
|
|
211
211
|
if (this._mode === "kv") {
|
|
212
|
-
await this._state.storage.put(this._getStorageKey(room), state
|
|
212
|
+
await this._state.storage.put(this._getStorageKey(room), state);
|
|
213
213
|
return;
|
|
214
214
|
}
|
|
215
215
|
if (!!(this._state.storage.sql.exec(sql`
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/utils/castNumber.ts","../src/utils/partitionByLength.ts","../src/utils/sql.ts","../src/PersistenceCloudflareTransactionalStorage.ts"],"sourcesContent":["export const castNumber = (value: any): number => {\n return typeof value === \"number\"\n ? value\n : typeof value === \"string\"\n ? Number.parseInt(value, 10)\n : Number(value);\n};\n","export const partitionByLength = <T>(\n arr: readonly T[] | T[],\n length: number,\n): readonly (readonly T[])[] => {\n if (!arr.length) return [];\n\n const head = arr.slice(0, length);\n const tail = arr.slice(length);\n\n return [head, ...partitionByLength(tail, length)];\n};\n","export const sql = (strings: TemplateStringsArray, ...values: any[]): string => {\n return strings\n .reduce((result, str, i) => {\n // Compresses the string to a single line (not including the interpolated values)\n const cleaned = str.replace(/(\\n[ \\t]*)+/g, \" \");\n\n return result + cleaned + (i < values.length ? values[i] : \"\");\n }, \"\")\n .trim();\n};\n","import { AbstractPersistence } from \"@pluv/io\";\nimport type { JsonObject } from \"@pluv/types\";\nimport { castNumber, partitionByLength, sql } from \"./utils\";\n\n/**\n * !HACK\n * @description The max amount of keys a Cloudflare transactional storage may delete at once\n * @see https://developers.cloudflare.com/durable-objects/api/transactional-storage-api/#delete\n * @date July 8, 2024\n */\nconst KV_CLOUDFLARE_DELETE_BATCH_LIMIT = 128;\nconst KV_STORAGE_PREFIX = \"$PLUV_STORAGE;\";\nconst KV_USER_PREFIX = \"$PLUV_USER\";\n\nconst SQLITE_STORAGE_TABLE = \"__pluv_storage\";\nconst SQLITE_USER_TABLE = \"__pluv_user\";\n\nexport interface PersistenceCloudflareTransactionalStorageConfig {\n mode: \"kv\" | \"sqlite\";\n}\nexport class PersistenceCloudflareTransactionalStorage extends AbstractPersistence {\n private _mode: \"kv\" | \"sqlite\";\n private _state: DurableObjectState | null = null;\n private _initialized: Promise<true> | null = null;\n\n constructor(config: PersistenceCloudflareTransactionalStorageConfig) {\n super();\n\n const { mode } = config;\n\n this._initialized = (config as any)._initialized;\n this._mode = mode;\n }\n\n public async addUser(\n room: string,\n connectionId: string,\n user: JsonObject | null,\n ): Promise<void> {\n if (!this._initialized) return;\n if (!this._state) return;\n\n await this._initialized;\n\n if (this._mode === \"kv\") {\n await this._state.storage.put(this._getUserKey(room, connectionId), user);\n return;\n }\n\n const result = this._state.storage.sql.exec<{ count: 0 }>(\n sql`\n SELECT id\n FROM ${SQLITE_USER_TABLE}\n WHERE id = ?;\n `,\n connectionId,\n );\n\n const existing = !!(result.toArray()[0]?.count ?? 0);\n\n if (existing) return;\n\n this._state.storage.sql.exec(\n sql`\n INSERT INTO ${SQLITE_USER_TABLE} VALUES (?, ?, ?);\n `,\n connectionId,\n JSON.stringify(user),\n room,\n );\n }\n\n public async deleteStorageState(room: string): Promise<void> {\n if (!this._initialized) return;\n if (!this._state) return;\n\n await this._initialized;\n\n if (this._mode === \"kv\") {\n await this._state.storage.delete(this._getStorageKey(room));\n return;\n }\n\n this._state.storage.sql.exec(\n sql`\n DELETE FROM ${SQLITE_STORAGE_TABLE}\n WHERE room = ?;\n `,\n room,\n );\n }\n\n public async deleteUser(room: string, connectionId: string): Promise<void> {\n if (!this._initialized) return;\n if (!this._state) return;\n\n await this._initialized;\n\n if (this._mode === \"kv\") {\n await this._state.storage.delete(this._getUserKey(room, connectionId));\n\n return;\n }\n\n this._state.storage.sql.exec(\n sql`\n DELETE FROM ${SQLITE_USER_TABLE}\n WHERE room = ?\n AND id = ?;\n `,\n room,\n connectionId,\n );\n }\n\n public async deleteUsers(room: string): Promise<void> {\n if (!this._initialized) return;\n if (!this._state) return;\n\n await this._initialized;\n\n if (this._mode === \"kv\") {\n const map = await this._state.storage.list({\n allowConcurrency: true,\n noCache: true,\n prefix: `${KV_USER_PREFIX}::${room}`,\n });\n\n const partitions = partitionByLength(\n Array.from(map.keys()),\n KV_CLOUDFLARE_DELETE_BATCH_LIMIT,\n );\n\n await this._state.storage.transaction(async (tx) => {\n await partitions.reduce(async (promise, partition) => {\n await promise;\n await tx.delete(partition as string[]);\n }, Promise.resolve());\n });\n\n return;\n }\n\n this._state.storage.sql.exec(\n sql`\n DELETE FROM ${SQLITE_USER_TABLE}\n WHERE room = ?;\n `,\n room,\n );\n }\n\n public async getStorageState(room: string): Promise<string | null> {\n if (!this._initialized) return null;\n if (!this._state) return null;\n\n await this._initialized;\n\n if (this._mode === \"kv\") {\n const storage = await this._state.storage.get<string>(this._getStorageKey(room));\n return storage ?? null;\n }\n\n const cursor = this._state.storage.sql.exec<{ room: string; data: string }>(\n sql`\n SELECT room, data\n FROM ${SQLITE_STORAGE_TABLE}\n WHERE room = ?;\n `,\n room,\n );\n\n try {\n const result = cursor.one();\n\n return result.data;\n } catch {\n return null;\n }\n }\n\n public async getUser(room: string, connectionId: string): Promise<JsonObject | null> {\n if (!this._initialized) return null;\n if (!this._state) return null;\n\n await this._initialized;\n\n if (this._mode === \"kv\") {\n const user = await this._state.storage.get<JsonObject | null>(\n this._getUserKey(room, connectionId),\n );\n\n return user ?? null;\n }\n\n const cursor = this._state.storage.sql.exec<{ id: string; data: string; room: string }>(\n sql`\n SELECT id, data, room\n FROM ${SQLITE_USER_TABLE}\n WHERE room = ?\n AND id = ?;\n `,\n room,\n connectionId,\n );\n\n try {\n const result = cursor.one();\n const user = JSON.parse(result.data);\n\n return user;\n } catch {\n return null;\n }\n }\n\n public async getUsers(\n room: string,\n ): Promise<Map<[connectionId: string][0], JsonObject | null>> {\n if (!this._initialized) return new Map();\n if (!this._state) return new Map();\n\n await this._initialized;\n\n if (this._mode === \"kv\") {\n const entries = await this._state.storage\n .list<JsonObject | null>({\n prefix: `${KV_USER_PREFIX}::${room}`,\n })\n .then((map) => Array.from(map.entries()));\n\n return entries.reduce((map, [key, user]) => {\n const connectionId = key.split(\"::\").slice(-1)[0];\n\n return !!connectionId ? map.set(connectionId, user) : map;\n }, new Map<string, JsonObject | null>());\n }\n\n const cursor = this._state.storage.sql.exec<{ id: string; data: string; room: string }>(\n sql`\n SELECT id, room, data\n FROM ${SQLITE_USER_TABLE}\n WHERE room = ?;\n `,\n room,\n );\n\n return cursor.toArray().reduce((map, { id, data }) => {\n try {\n const user = JSON.parse(data) as JsonObject;\n\n return map.set(id, user);\n } catch {\n return map;\n }\n }, new Map<string, JsonObject | null>());\n }\n\n public async getUsersSize(room: string): Promise<number> {\n if (!this._initialized) return 0;\n if (!this._state) return 0;\n\n await this._initialized;\n\n if (this._mode) {\n const storage = await this._state.storage.list({\n prefix: `${KV_USER_PREFIX}::${room}`,\n });\n\n return storage.size;\n }\n\n const cursor = this._state.storage.sql.exec<{ count: number }>(\n sql`\n SELECT COUNT(*) count\n FROM ${SQLITE_USER_TABLE}\n WHERE room = ?;\n `,\n room,\n );\n\n try {\n const result = cursor.one();\n\n return castNumber(result.count);\n } catch {\n return 0;\n }\n }\n\n public initialize(roomContext: { state: DurableObjectState }): typeof this {\n const initialized = (async () => {\n const { state } = roomContext;\n\n this._state = state;\n\n if (this._mode === \"sqlite\") {\n this._state.storage.sql.exec(sql`\n CREATE TABLE IF NOT EXISTS ${SQLITE_STORAGE_TABLE}(\n room TEXT PRIMARY KEY,\n data TEXT NOT NULL\n );\n CREATE TABLE IF NOT EXISTS ${SQLITE_USER_TABLE}(\n id TEXT PRIMARY KEY,\n data TEXT NOT NULL,\n room TEXT NOT NULL\n );\n CREATE INDEX IF NOT EXISTS ${SQLITE_USER_TABLE}_room ON ${SQLITE_USER_TABLE}(room);\n `);\n }\n\n return true as const;\n })();\n\n return new PersistenceCloudflareTransactionalStorage({\n mode: this._mode,\n // Spreading avoids an excess property check, so `_initialized` can be handed to the\n // constructor without exposing it on the public config type.\n // oxlint-disable-next-line unicorn/no-useless-spread\n ...{ _initialized: initialized },\n }) as typeof this;\n }\n\n public async setStorageState(room: string, state: string): Promise<void> {\n if (!this._initialized) return;\n if (!this._state) return;\n\n await this._initialized;\n\n if (this._mode === \"kv\") {\n await this._state.storage.put(this._getStorageKey(room), state, {\n allowConcurrency: true,\n });\n return;\n }\n\n const result = this._state.storage.sql.exec<{ count: number }>(\n sql`\n SELECT COUNT(*) as count\n FROM ${SQLITE_STORAGE_TABLE}\n WHERE room = ?;\n `,\n room,\n );\n\n const existing = !!(result.toArray()[0]?.count ?? 0);\n\n if (existing) {\n this._state.storage.sql.exec(\n sql`\n UPDATE ${SQLITE_STORAGE_TABLE}\n SET data = ?\n WHERE room = ?;\n `,\n state,\n room,\n );\n\n return;\n }\n\n this._state.storage.sql.exec(\n sql`\n INSERT INTO ${SQLITE_STORAGE_TABLE} VALUES (?, ?);\n `,\n room,\n state,\n );\n }\n\n private _getStorageKey(room: string): string {\n if (this._mode === \"sqlite\") {\n throw new Error(\"Attempted to get kv key for sqlite storage\");\n }\n\n return `${KV_STORAGE_PREFIX}::${room}`;\n }\n\n private _getUserKey(room: string, connectionId: string): string {\n if (this._mode === \"sqlite\") {\n throw new Error(\"Attempted to get kv key for sqlite storage\");\n }\n\n return `${KV_USER_PREFIX}::${room}::${connectionId}`;\n }\n}\n"],"mappings":";;AAAA,MAAa,cAAc,UAAuB;CAC9C,OAAO,OAAO,UAAU,WAClB,QACA,OAAO,UAAU,WACf,OAAO,SAAS,OAAO,EAAE,IACzB,OAAO,KAAK;AACxB;;;ACNA,MAAa,qBACT,KACA,WAC4B;CAC5B,IAAI,CAAC,IAAI,QAAQ,OAAO,CAAC;CAEzB,MAAM,OAAO,IAAI,MAAM,GAAG,MAAM;CAChC,MAAM,OAAO,IAAI,MAAM,MAAM;CAE7B,OAAO,CAAC,MAAM,GAAG,kBAAkB,MAAM,MAAM,CAAC;AACpD;;;ACVA,MAAa,OAAO,SAA+B,GAAG,WAA0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AAC,CAAC,EAAE,EAAE,SAAS,IAEpC;GACV,KAAK,OAAO,QAAQ,IAAI,KACpB,GAAG;6BACU,qBAAqB;;;mBAIlC,OACA,IACJ;GAEA;EACJ;EAEA,KAAK,OAAO,QAAQ,IAAI,KACpB,GAAG;8BACe,qBAAqB;eAEvC,MACA,KACJ;CACJ;CAEA,eAAuB,MAAsB;EACzC,IAAI,KAAK,UAAU,UACf,MAAM,IAAI,MAAM,4CAA4C;EAGhE,OAAO,GAAG,kBAAkB,IAAI;CACpC;CAEA,YAAoB,MAAc,cAA8B;EAC5D,IAAI,KAAK,UAAU,UACf,MAAM,IAAI,MAAM,4CAA4C;EAGhE,OAAO,GAAG,eAAe,IAAI,KAAK,IAAI;CAC1C;AACJ"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/utils/castNumber.ts","../src/utils/partitionByLength.ts","../src/utils/sql.ts","../src/PersistenceCloudflareTransactionalStorage.ts"],"sourcesContent":["export const castNumber = (value: any): number => {\n return typeof value === \"number\"\n ? value\n : typeof value === \"string\"\n ? Number.parseInt(value, 10)\n : Number(value);\n};\n","export const partitionByLength = <T>(\n arr: readonly T[] | T[],\n length: number,\n): readonly (readonly T[])[] => {\n if (!arr.length) return [];\n\n const head = arr.slice(0, length);\n const tail = arr.slice(length);\n\n return [head, ...partitionByLength(tail, length)];\n};\n","export const sql = (strings: TemplateStringsArray, ...values: any[]): string => {\n return strings\n .reduce((result, str, i) => {\n // Compresses the string to a single line (not including the interpolated values)\n const cleaned = str.replace(/(\\n[ \\t]*)+/g, \" \");\n\n return result + cleaned + (i < values.length ? values[i] : \"\");\n }, \"\")\n .trim();\n};\n","import { AbstractPersistence } from \"@pluv/io\";\nimport type { JsonObject } from \"@pluv/types\";\nimport { castNumber, partitionByLength, sql } from \"./utils\";\n\n/**\n * !HACK\n * @description The max amount of keys a Cloudflare transactional storage may delete at once\n * @see https://developers.cloudflare.com/durable-objects/api/transactional-storage-api/#delete\n * @date July 8, 2024\n */\nconst KV_CLOUDFLARE_DELETE_BATCH_LIMIT = 128;\nconst KV_STORAGE_PREFIX = \"$PLUV_STORAGE;\";\nconst KV_USER_PREFIX = \"$PLUV_USER\";\n\nconst SQLITE_STORAGE_TABLE = \"__pluv_storage\";\nconst SQLITE_USER_TABLE = \"__pluv_user\";\n\nexport interface PersistenceCloudflareTransactionalStorageConfig {\n mode: \"kv\" | \"sqlite\";\n}\nexport class PersistenceCloudflareTransactionalStorage extends AbstractPersistence {\n private _mode: \"kv\" | \"sqlite\";\n private _state: DurableObjectState | null = null;\n private _initialized: Promise<true> | null = null;\n\n constructor(config: PersistenceCloudflareTransactionalStorageConfig) {\n super();\n\n const { mode } = config;\n\n this._initialized = (config as any)._initialized;\n this._mode = mode;\n }\n\n public async addUser(\n room: string,\n connectionId: string,\n user: JsonObject | null,\n ): Promise<void> {\n if (!this._initialized) return;\n if (!this._state) return;\n\n await this._initialized;\n\n if (this._mode === \"kv\") {\n await this._state.storage.put(this._getUserKey(room, connectionId), user);\n return;\n }\n\n const result = this._state.storage.sql.exec<{ count: 0 }>(\n sql`\n SELECT id\n FROM ${SQLITE_USER_TABLE}\n WHERE id = ?;\n `,\n connectionId,\n );\n\n const existing = !!(result.toArray()[0]?.count ?? 0);\n\n if (existing) return;\n\n this._state.storage.sql.exec(\n sql`\n INSERT INTO ${SQLITE_USER_TABLE} VALUES (?, ?, ?);\n `,\n connectionId,\n JSON.stringify(user),\n room,\n );\n }\n\n public async deleteStorageState(room: string): Promise<void> {\n if (!this._initialized) return;\n if (!this._state) return;\n\n await this._initialized;\n\n if (this._mode === \"kv\") {\n await this._state.storage.delete(this._getStorageKey(room));\n return;\n }\n\n this._state.storage.sql.exec(\n sql`\n DELETE FROM ${SQLITE_STORAGE_TABLE}\n WHERE room = ?;\n `,\n room,\n );\n }\n\n public async deleteUser(room: string, connectionId: string): Promise<void> {\n if (!this._initialized) return;\n if (!this._state) return;\n\n await this._initialized;\n\n if (this._mode === \"kv\") {\n await this._state.storage.delete(this._getUserKey(room, connectionId));\n\n return;\n }\n\n this._state.storage.sql.exec(\n sql`\n DELETE FROM ${SQLITE_USER_TABLE}\n WHERE room = ?\n AND id = ?;\n `,\n room,\n connectionId,\n );\n }\n\n public async deleteUsers(room: string): Promise<void> {\n if (!this._initialized) return;\n if (!this._state) return;\n\n await this._initialized;\n\n if (this._mode === \"kv\") {\n const map = await this._state.storage.list({\n allowConcurrency: true,\n noCache: true,\n prefix: `${KV_USER_PREFIX}::${room}`,\n });\n\n const partitions = partitionByLength(\n Array.from(map.keys()),\n KV_CLOUDFLARE_DELETE_BATCH_LIMIT,\n );\n\n await this._state.storage.transaction(async (tx) => {\n await partitions.reduce(async (promise, partition) => {\n await promise;\n await tx.delete(partition as string[]);\n }, Promise.resolve());\n });\n\n return;\n }\n\n this._state.storage.sql.exec(\n sql`\n DELETE FROM ${SQLITE_USER_TABLE}\n WHERE room = ?;\n `,\n room,\n );\n }\n\n public async getStorageState(room: string): Promise<string | null> {\n if (!this._initialized) return null;\n if (!this._state) return null;\n\n await this._initialized;\n\n if (this._mode === \"kv\") {\n const storage = await this._state.storage.get<string>(this._getStorageKey(room));\n return storage ?? null;\n }\n\n const cursor = this._state.storage.sql.exec<{ room: string; data: string }>(\n sql`\n SELECT room, data\n FROM ${SQLITE_STORAGE_TABLE}\n WHERE room = ?;\n `,\n room,\n );\n\n try {\n const result = cursor.one();\n\n return result.data;\n } catch {\n return null;\n }\n }\n\n public async getUser(room: string, connectionId: string): Promise<JsonObject | null> {\n if (!this._initialized) return null;\n if (!this._state) return null;\n\n await this._initialized;\n\n if (this._mode === \"kv\") {\n const user = await this._state.storage.get<JsonObject | null>(\n this._getUserKey(room, connectionId),\n );\n\n return user ?? null;\n }\n\n const cursor = this._state.storage.sql.exec<{ id: string; data: string; room: string }>(\n sql`\n SELECT id, data, room\n FROM ${SQLITE_USER_TABLE}\n WHERE room = ?\n AND id = ?;\n `,\n room,\n connectionId,\n );\n\n try {\n const result = cursor.one();\n const user = JSON.parse(result.data);\n\n return user;\n } catch {\n return null;\n }\n }\n\n public async getUsers(\n room: string,\n ): Promise<Map<[connectionId: string][0], JsonObject | null>> {\n if (!this._initialized) return new Map();\n if (!this._state) return new Map();\n\n await this._initialized;\n\n if (this._mode === \"kv\") {\n const entries = await this._state.storage\n .list<JsonObject | null>({\n prefix: `${KV_USER_PREFIX}::${room}`,\n })\n .then((map) => Array.from(map.entries()));\n\n return entries.reduce((map, [key, user]) => {\n const connectionId = key.split(\"::\").slice(-1)[0];\n\n return !!connectionId ? map.set(connectionId, user) : map;\n }, new Map<string, JsonObject | null>());\n }\n\n const cursor = this._state.storage.sql.exec<{ id: string; data: string; room: string }>(\n sql`\n SELECT id, room, data\n FROM ${SQLITE_USER_TABLE}\n WHERE room = ?;\n `,\n room,\n );\n\n return cursor.toArray().reduce((map, { id, data }) => {\n try {\n const user = JSON.parse(data) as JsonObject;\n\n return map.set(id, user);\n } catch {\n return map;\n }\n }, new Map<string, JsonObject | null>());\n }\n\n public async getUsersSize(room: string): Promise<number> {\n if (!this._initialized) return 0;\n if (!this._state) return 0;\n\n await this._initialized;\n\n if (this._mode) {\n const storage = await this._state.storage.list({\n prefix: `${KV_USER_PREFIX}::${room}`,\n });\n\n return storage.size;\n }\n\n const cursor = this._state.storage.sql.exec<{ count: number }>(\n sql`\n SELECT COUNT(*) count\n FROM ${SQLITE_USER_TABLE}\n WHERE room = ?;\n `,\n room,\n );\n\n try {\n const result = cursor.one();\n\n return castNumber(result.count);\n } catch {\n return 0;\n }\n }\n\n public initialize(roomContext: { state: DurableObjectState }): typeof this {\n const initialized = (async () => {\n const { state } = roomContext;\n\n this._state = state;\n\n if (this._mode === \"sqlite\") {\n this._state.storage.sql.exec(sql`\n CREATE TABLE IF NOT EXISTS ${SQLITE_STORAGE_TABLE}(\n room TEXT PRIMARY KEY,\n data TEXT NOT NULL\n );\n CREATE TABLE IF NOT EXISTS ${SQLITE_USER_TABLE}(\n id TEXT PRIMARY KEY,\n data TEXT NOT NULL,\n room TEXT NOT NULL\n );\n CREATE INDEX IF NOT EXISTS ${SQLITE_USER_TABLE}_room ON ${SQLITE_USER_TABLE}(room);\n `);\n }\n\n return true as const;\n })();\n\n return new PersistenceCloudflareTransactionalStorage({\n mode: this._mode,\n // Spreading avoids an excess property check, so `_initialized` can be handed to the\n // constructor without exposing it on the public config type.\n // oxlint-disable-next-line unicorn/no-useless-spread\n ...{ _initialized: initialized },\n }) as typeof this;\n }\n\n public async setStorageState(room: string, state: string): Promise<void> {\n if (!this._initialized) return;\n if (!this._state) return;\n\n await this._initialized;\n\n if (this._mode === \"kv\") {\n await this._state.storage.put(this._getStorageKey(room), state);\n return;\n }\n\n const result = this._state.storage.sql.exec<{ count: number }>(\n sql`\n SELECT COUNT(*) as count\n FROM ${SQLITE_STORAGE_TABLE}\n WHERE room = ?;\n `,\n room,\n );\n\n const existing = !!(result.toArray()[0]?.count ?? 0);\n\n if (existing) {\n this._state.storage.sql.exec(\n sql`\n UPDATE ${SQLITE_STORAGE_TABLE}\n SET data = ?\n WHERE room = ?;\n `,\n state,\n room,\n );\n\n return;\n }\n\n this._state.storage.sql.exec(\n sql`\n INSERT INTO ${SQLITE_STORAGE_TABLE} VALUES (?, ?);\n `,\n room,\n state,\n );\n }\n\n private _getStorageKey(room: string): string {\n if (this._mode === \"sqlite\") {\n throw new Error(\"Attempted to get kv key for sqlite storage\");\n }\n\n return `${KV_STORAGE_PREFIX}::${room}`;\n }\n\n private _getUserKey(room: string, connectionId: string): string {\n if (this._mode === \"sqlite\") {\n throw new Error(\"Attempted to get kv key for sqlite storage\");\n }\n\n return `${KV_USER_PREFIX}::${room}::${connectionId}`;\n }\n}\n"],"mappings":";;AAAA,MAAa,cAAc,UAAuB;CAC9C,OAAO,OAAO,UAAU,WAClB,QACA,OAAO,UAAU,WACf,OAAO,SAAS,OAAO,EAAE,IACzB,OAAO,KAAK;AACxB;;;ACNA,MAAa,qBACT,KACA,WAC4B;CAC5B,IAAI,CAAC,IAAI,QAAQ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QAAQ,IAAI,KAAK,eAAe,IAAI,GAAG,KAAK;GAC9D;EACJ;EAaA,IAAI,CAFc,EATH,KAAK,OAAO,QAAQ,IAAI,KACnC,GAAG;;uBAEQ,qBAAqB;;eAGhC,IAGqB,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,SAAS,IAEpC;GACV,KAAK,OAAO,QAAQ,IAAI,KACpB,GAAG;6BACU,qBAAqB;;;mBAIlC,OACA,IACJ;GAEA;EACJ;EAEA,KAAK,OAAO,QAAQ,IAAI,KACpB,GAAG;8BACe,qBAAqB;eAEvC,MACA,KACJ;CACJ;CAEA,eAAuB,MAAsB;EACzC,IAAI,KAAK,UAAU,UACf,MAAM,IAAI,MAAM,4CAA4C;EAGhE,OAAO,GAAG,kBAAkB,IAAI;CACpC;CAEA,YAAoB,MAAc,cAA8B;EAC5D,IAAI,KAAK,UAAU,UACf,MAAM,IAAI,MAAM,4CAA4C;EAGhE,OAAO,GAAG,eAAe,IAAI,KAAK,IAAI;CAC1C;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/persistence-cloudflare-transactional-storage",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.1",
|
|
4
4
|
"description": "@pluv/io crdt storage persistence for cloudflare via transactional storage",
|
|
5
5
|
"author": {
|
|
6
6
|
"email": "david@pluv.io",
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@pluv/io": "^5.1.
|
|
27
|
-
"@pluv/types": "^5.1.
|
|
26
|
+
"@pluv/io": "^5.1.1",
|
|
27
|
+
"@pluv/types": "^5.1.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@cloudflare/workers-types": "^5.20260906.1",
|
|
31
|
-
"@pluv/tsconfig": "^5.1.
|
|
31
|
+
"@pluv/tsconfig": "^5.1.1",
|
|
32
32
|
"tsdown": "^0.23.0",
|
|
33
33
|
"typescript": "^7.0.2"
|
|
34
34
|
},
|