@cnstra/devtools-server-repository-redis 0.2.0 → 0.3.0
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/README.md +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **⚠️ Experimental**: API may change.
|
|
4
4
|
|
|
5
|
-
Redis persistence for the [CNStra](https://cnstra.org) DevTools server. A drop-in,
|
|
5
|
+
Redis persistence for the [CNStra](https://cnstra.org) DevTools server. A drop-in, resumable
|
|
6
6
|
replacement for `@cnstra/devtools-server-repository-in-memory`: same
|
|
7
7
|
`ICNSDevToolsServerRepository` contract, backed by Redis so apps, topology, stimulations and
|
|
8
8
|
per-hop history outlive a restart.
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AA2BA,IAAM,KAAA,GAAQ,CAAI,CAAA,KACd,CAAA,IAAK,OAAO,IAAA,GAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAa7B,IAAM,mCAAN,MAEP;AAAA,EAGI,WAAA,CACqB,KAAA,EACjB,OAAA,GAAmD,EAAC,EACtD;AAFmB,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AAGjB,IAAA,IAAA,CAAK,CAAA,GAAI,QAAQ,SAAA,IAAa,MAAA;AAAA,EAClC;AAAA;AAAA,EAIA,MAAM,UAAU,GAAA,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AA2BA,IAAM,KAAA,GAAQ,CAAI,CAAA,KACd,CAAA,IAAK,OAAO,IAAA,GAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAa7B,IAAM,mCAAN,MAEP;AAAA,EAGI,WAAA,CACqB,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AC;AAAA,IAC5B;AACA,IAAA,MAAM,GAAA,GAAM,MAAM,IAAA,CAAK,KAAA,CAAM,QAAQ,CAAA,EAAG,IAAA,CAAK,CAAC,CAAA,QAAA,CAAU,CAAA;AACxD,IAAA,OAAO,MAAA,CAAO,MAAA,CAAO,GAAA,IAAO,EAAE,CAAA,CAAE,GAAA;AAAA,MAC5B,CAAA,CAAA,KAAK,IAAA,CAAK,KAAA,CAAM,CAAC;AAAA,KACrB;AAAA,EACJ;AAAA;AAAA,EAIA,MAAM,WAAA,CAAY,KAAA,EAAe,KAAA,EAA8B;AAC3D,IAAA,MAAM,IAAA,CAAK,MAAM,IAAA,CAAK,CAAA,EAAG,KAAK,CAAC,CAAA,QAAA,CAAA,EAAY,OAAO,KAAK,CAAA;AACvD,IAAA,MAAM,IAAA,CAAK,MAAM,IAAA,CAAK,CAAA,EAAG,KAAK,CAAC,CAAA,SAAA,EAAY,KAAK,CAAA,CAAA,EAAI,KAAK,CAAA;AAAA,EAC7D;AAAA,EAEA,MAAM,YAAY,KAAA,EAAkC;AAChD,IAAA,OAAO,IAAA,CAAK,MAAM,QAAA,CAAS,CAAA,EAAG,KAAK,CAAC,CAAA,SAAA,EAAY,KAAK,CAAA,CAAE,CAAA;AAAA,EAC3D;AAAA,EAEA,MAAM,aAAa,KAAA,EAA4C;AAC3D,IAAA,MAAM,KAAA,GAAQ,MAAM,IAAA,CAAK,KAAA,CAAM,KAAK,CAAA,EAAG,IAAA,CAAK,CAAC,CAAA,QAAA,CAAA,EAAY,KAAK,CAAA;AAC9D,IAAA,OAAO,KAAA,IAAS,MAAA;AAAA,EACpB;AACJ","file":"index.cjs","sourcesContent":["import type {\n ICNSDevToolsServerRepository,\n TCNSTopologySnapshotDTO,\n} from '@cnstra/devtools-server';\nimport type { TCNSAppDTO } from '@cnstra/devtools-dto';\n\n/**\n * Minimal structural view of an `ioredis` client — only the commands this\n * repository uses. A real `Redis` instance from `ioredis` satisfies it, so we\n * avoid a hard dependency on `ioredis` and its types.\n *\n * Note: this targets ioredis-style lowercase command methods. `node-redis` v4\n * uses different names (hSet, hGetAll, …) and is not directly compatible.\n */\nexport interface IRedisLike {\n hset(key: string, field: string, value: string): Promise<unknown>;\n hget(key: string, field: string): Promise<string | null>;\n hgetall(key: string): Promise<Record<string, string>>;\n sadd(key: string, member: string): Promise<unknown>;\n smembers(key: string): Promise<string[]>;\n}\n\nexport interface CNSDevToolsServerRepositoryRedisOptions {\n /** Key namespace prefix (default \"cns:\"). */\n keyPrefix?: string;\n}\n\nconst parse = <T>(s: string | null): T | null =>\n s == null ? null : (JSON.parse(s) as T);\n\n/**\n * Redis-backed repository for the CNStra DevTools server. Resumable counterpart of\n * `@cnstra/devtools-server-repository-in-memory` with the same\n * `ICNSDevToolsServerRepository` contract.\n *\n * Data layout (with the default `cns:` prefix):\n * - `cns:apps` hash appId → app JSON\n * - `cns:topology` hash cnsId → snapshot JSON\n * - `cns:cnsToApp` hash cnsId → appId\n * - `cns:appToCns:{appId}` set cnsId\n */\nexport class CNSDevToolsServerRepositoryRedis\n implements ICNSDevToolsServerRepository\n{\n private readonly p: string;\n\n constructor(\n private readonly redis: IRedisLike,\n options: CNSDevToolsServerRepositoryRedisOptions = {}\n ) {\n this.p = options.keyPrefix ?? 'cns:';\n }\n\n // ─── Apps ───────────────────────────────────────────────────────────────\n\n async upsertApp(app: TCNSAppDTO): Promise<void> {\n await this.redis.hset(`${this.p}apps`, app.id, JSON.stringify(app));\n }\n\n async listApps(): Promise<TCNSAppDTO[]> {\n const all = await this.redis.hgetall(`${this.p}apps`);\n return Object.values(all ?? {}).map(v => JSON.parse(v) as TCNSAppDTO);\n }\n\n // ─── Topology ───────────────────────────────────────────────────────────\n\n async saveTopology(snapshot: TCNSTopologySnapshotDTO): Promise<void> {\n await this.redis.hset(\n `${this.p}topology`,\n snapshot.cnsId,\n JSON.stringify(snapshot)\n );\n }\n\n async getTopology(cnsId?: string): Promise<TCNSTopologySnapshotDTO[]> {\n if (cnsId) {\n const raw = await this.redis.hget(`${this.p}topology`, cnsId);\n const snap = parse<TCNSTopologySnapshotDTO>(raw);\n return snap ? [snap] : [];\n }\n const all = await this.redis.hgetall(`${this.p}topology`);\n return Object.values(all ?? {}).map(\n v => JSON.parse(v) as TCNSTopologySnapshotDTO\n );\n }\n\n // ─── CNS ↔ App mapping ──────────────────────────────────────────────────\n\n async addCnsToApp(appId: string, cnsId: string): Promise<void> {\n await this.redis.hset(`${this.p}cnsToApp`, cnsId, appId);\n await this.redis.sadd(`${this.p}appToCns:${appId}`, cnsId);\n }\n\n async getCnsByApp(appId: string): Promise<string[]> {\n return this.redis.smembers(`${this.p}appToCns:${appId}`);\n }\n\n async findAppByCns(cnsId: string): Promise<string | undefined> {\n const appId = await this.redis.hget(`${this.p}cnsToApp`, cnsId);\n return appId ?? undefined;\n }\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ICNSDevToolsServerRepository,
|
|
2
|
-
import type {
|
|
1
|
+
import type { ICNSDevToolsServerRepository, TCNSTopologySnapshotDTO } from '@cnstra/devtools-server';
|
|
2
|
+
import type { TCNSAppDTO } from '@cnstra/devtools-dto';
|
|
3
3
|
/**
|
|
4
4
|
* Minimal structural view of an `ioredis` client — only the commands this
|
|
5
5
|
* repository uses. A real `Redis` instance from `ioredis` satisfies it, so we
|
|
@@ -20,7 +20,7 @@ export interface CNSDevToolsServerRepositoryRedisOptions {
|
|
|
20
20
|
keyPrefix?: string;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
* Redis-backed repository for the CNStra DevTools server.
|
|
23
|
+
* Redis-backed repository for the CNStra DevTools server. Resumable counterpart of
|
|
24
24
|
* `@cnstra/devtools-server-repository-in-memory` with the same
|
|
25
25
|
* `ICNSDevToolsServerRepository` contract.
|
|
26
26
|
*
|
|
@@ -34,10 +34,10 @@ export declare class CNSDevToolsServerRepositoryRedis implements ICNSDevToolsSer
|
|
|
34
34
|
private readonly redis;
|
|
35
35
|
private readonly p;
|
|
36
36
|
constructor(redis: IRedisLike, options?: CNSDevToolsServerRepositoryRedisOptions);
|
|
37
|
-
upsertApp(app:
|
|
38
|
-
listApps(): Promise<
|
|
39
|
-
saveTopology(snapshot:
|
|
40
|
-
getTopology(cnsId?: string): Promise<
|
|
37
|
+
upsertApp(app: TCNSAppDTO): Promise<void>;
|
|
38
|
+
listApps(): Promise<TCNSAppDTO[]>;
|
|
39
|
+
saveTopology(snapshot: TCNSTopologySnapshotDTO): Promise<void>;
|
|
40
|
+
getTopology(cnsId?: string): Promise<TCNSTopologySnapshotDTO[]>;
|
|
41
41
|
addCnsToApp(appId: string, cnsId: string): Promise<void>;
|
|
42
42
|
getCnsByApp(appId: string): Promise<string[]>;
|
|
43
43
|
findAppByCns(cnsId: string): Promise<string | undefined>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,4BAA4B,EAC5B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,4BAA4B,EAC5B,uBAAuB,EAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IACvB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAClE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACzD,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,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IAAA,MAAM,KAAA,GAAQ,MAAM,IAAA,CAAK,KAAA,CAAM,KAAK,CAAA,EAAG,IAAA,CAAK,CAAC,CAAA,QAAA,CAAA,EAAY,KAAK,CAAA;AAC9D,IAAA,OAAO,KAAA,IAAS,MAAA;AAAA,EACpB;AACJ","file":"index.js","sourcesContent":["import type {\n ICNSDevToolsServerRepository,\n TCNSTopologySnapshotDTO,\n} from '@cnstra/devtools-server';\nimport type { TCNSAppDTO } from '@cnstra/devtools-dto';\n\n/**\n * Minimal structural view of an `ioredis` client — only the commands this\n * repository uses. A real `Redis` instance from `ioredis` satisfies it, so we\n * avoid a hard dependency on `ioredis` and its types.\n *\n * Note: this targets ioredis-style lowercase command methods. `node-redis` v4\n * uses different names (hSet, hGetAll, …) and is not directly compatible.\n */\nexport interface IRedisLike {\n hset(key: string, field: string, value: string): Promise<unknown>;\n hget(key: string, field: string): Promise<string | null>;\n hgetall(key: string): Promise<Record<string, string>>;\n sadd(key: string, member: string): Promise<unknown>;\n smembers(key: string): Promise<string[]>;\n}\n\nexport interface CNSDevToolsServerRepositoryRedisOptions {\n /** Key namespace prefix (default \"cns:\"). */\n keyPrefix?: string;\n}\n\nconst parse = <T>(s: string | null): T | null =>\n s == null ? null : (JSON.parse(s) as T);\n\n/**\n * Redis-backed repository for the CNStra DevTools server. Resumable counterpart of\n * `@cnstra/devtools-server-repository-in-memory` with the same\n * `ICNSDevToolsServerRepository` contract.\n *\n * Data layout (with the default `cns:` prefix):\n * - `cns:apps` hash appId → app JSON\n * - `cns:topology` hash cnsId → snapshot JSON\n * - `cns:cnsToApp` hash cnsId → appId\n * - `cns:appToCns:{appId}` set cnsId\n */\nexport class CNSDevToolsServerRepositoryRedis\n implements ICNSDevToolsServerRepository\n{\n private readonly p: string;\n\n constructor(\n private readonly redis: IRedisLike,\n options: CNSDevToolsServerRepositoryRedisOptions = {}\n ) {\n this.p = options.keyPrefix ?? 'cns:';\n }\n\n // ─── Apps ───────────────────────────────────────────────────────────────\n\n async upsertApp(app: TCNSAppDTO): Promise<void> {\n await this.redis.hset(`${this.p}apps`, app.id, JSON.stringify(app));\n }\n\n async listApps(): Promise<TCNSAppDTO[]> {\n const all = await this.redis.hgetall(`${this.p}apps`);\n return Object.values(all ?? {}).map(v => JSON.parse(v) as TCNSAppDTO);\n }\n\n // ─── Topology ───────────────────────────────────────────────────────────\n\n async saveTopology(snapshot: TCNSTopologySnapshotDTO): Promise<void> {\n await this.redis.hset(\n `${this.p}topology`,\n snapshot.cnsId,\n JSON.stringify(snapshot)\n );\n }\n\n async getTopology(cnsId?: string): Promise<TCNSTopologySnapshotDTO[]> {\n if (cnsId) {\n const raw = await this.redis.hget(`${this.p}topology`, cnsId);\n const snap = parse<TCNSTopologySnapshotDTO>(raw);\n return snap ? [snap] : [];\n }\n const all = await this.redis.hgetall(`${this.p}topology`);\n return Object.values(all ?? {}).map(\n v => JSON.parse(v) as TCNSTopologySnapshotDTO\n );\n }\n\n // ─── CNS ↔ App mapping ──────────────────────────────────────────────────\n\n async addCnsToApp(appId: string, cnsId: string): Promise<void> {\n await this.redis.hset(`${this.p}cnsToApp`, cnsId, appId);\n await this.redis.sadd(`${this.p}appToCns:${appId}`, cnsId);\n }\n\n async getCnsByApp(appId: string): Promise<string[]> {\n return this.redis.smembers(`${this.p}appToCns:${appId}`);\n }\n\n async findAppByCns(cnsId: string): Promise<string | undefined> {\n const appId = await this.redis.hget(`${this.p}cnsToApp`, cnsId);\n return appId ?? undefined;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cnstra/devtools-server-repository-redis",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Redis repository for CNStra DevTools server (
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Redis repository for CNStra DevTools server (resumable stimulations & hops)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cnstra",
|
|
7
7
|
"devtools",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
|
+
"prepublishOnly": "node ../../scripts/check-drift.mjs --gate",
|
|
25
26
|
"build": "tsup && tsc --emitDeclarationOnly",
|
|
26
27
|
"build:types": "tsc --emitDeclarationOnly",
|
|
27
28
|
"test": "jest",
|
|
@@ -31,14 +32,14 @@
|
|
|
31
32
|
"dist"
|
|
32
33
|
],
|
|
33
34
|
"dependencies": {
|
|
34
|
-
"@cnstra/devtools-dto": "^
|
|
35
|
+
"@cnstra/devtools-dto": "^3.0.0"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
|
-
"@cnstra/devtools-server": "^
|
|
38
|
+
"@cnstra/devtools-server": "^3.0.0",
|
|
38
39
|
"ioredis": ">=5"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
|
-
"@cnstra/devtools-server": "^
|
|
42
|
+
"@cnstra/devtools-server": "^3.0.0",
|
|
42
43
|
"@types/jest": "^29.5.5",
|
|
43
44
|
"ioredis-mock": "^8.9.0",
|
|
44
45
|
"jest": "^29.7.0",
|