@freedome/client 1.1.0 → 1.2.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/dist/testing.cjs CHANGED
@@ -1077,6 +1077,11 @@ var FakeDomeServer = class {
1077
1077
  ]);
1078
1078
  /** Accepted API keys → role. */
1079
1079
  apiKeys = /* @__PURE__ */ new Map();
1080
+ /** Pending physical actions (`listAssistantConfirmations`). */
1081
+ confirmations = [];
1082
+ linkSessions = [];
1083
+ /** The code `approveAssistantLink` accepts. */
1084
+ linkCode = "7KQM-2XVB";
1080
1085
  networkDown = false;
1081
1086
  realtimeAvailable = true;
1082
1087
  accessTtlSec = 900;
@@ -1114,7 +1119,7 @@ var FakeDomeServer = class {
1114
1119
  * Contract version the fake reports in `getInfo` and behaves as: below 1.1.0 the operations of 1.1.0 answer 404 and
1115
1120
  * its members 422, as a 1.0 server does.
1116
1121
  */
1117
- contractVersion = "1.1.0";
1122
+ contractVersion = "1.2.0";
1118
1123
  /** Calibration jobs by id. */
1119
1124
  calibrationJobs = /* @__PURE__ */ new Map();
1120
1125
  /** Audio model + hooks (`emitLevels`, `advanceSession`). */
@@ -1311,6 +1316,38 @@ var FakeDomeServer = class {
1311
1316
  capabilities: { realtime: ["ws"], audio: true },
1312
1317
  transports: { ws: true, graphql: false, socketIo: false }
1313
1318
  });
1319
+ case "listAssistantConfirmations":
1320
+ return json(200, { items: this.confirmations, nextCursor: null });
1321
+ case "refuseAssistantConfirmation": {
1322
+ const c = this.confirmations.find((x) => x.id === p.confirmationId);
1323
+ if (!c) return problem(404, "not-found", "no such confirmation");
1324
+ c.status = "refused";
1325
+ delete c.code;
1326
+ return json(200, c);
1327
+ }
1328
+ case "getAssistantLink":
1329
+ return json(200, { enabled: true, state: "online", sessions: this.linkSessions });
1330
+ case "approveAssistantLink": {
1331
+ if (body?.code !== this.linkCode) return problem(422, "validation-failed", "wrong code");
1332
+ const session = {
1333
+ id: uuidV7(),
1334
+ approver: "user:admin",
1335
+ role: "operator",
1336
+ scopes: ["playback:control"],
1337
+ createdAt: (/* @__PURE__ */ new Date(0)).toISOString(),
1338
+ expiresAt: new Date(8 * 36e5).toISOString(),
1339
+ status: "active",
1340
+ calls: 0
1341
+ };
1342
+ this.linkSessions.push(session);
1343
+ return json(201, session);
1344
+ }
1345
+ case "endAssistantLink": {
1346
+ const x = this.linkSessions.find((v) => v.id === p.sessionId);
1347
+ if (!x) return problem(404, "not-found", "no such approval");
1348
+ x.status = "ended";
1349
+ return new FreedomeResponse(204);
1350
+ }
1314
1351
  case "createSession": {
1315
1352
  if (this.users.get(body?.username) !== body?.password)
1316
1353
  return problem(401, "unauthenticated", "wrong username or password");
@@ -1639,8 +1676,19 @@ var FakeDomeServer = class {
1639
1676
  const a = this.assets.get(p.assetId);
1640
1677
  return a ? json(200, a, this.etag(a.revision)) : problem(404, "not-found", "asset");
1641
1678
  }
1642
- case "listAssets":
1643
- return json(200, { items: [...this.assets.values()], nextCursor: null });
1679
+ case "listAssets": {
1680
+ const f2 = r.query ?? {};
1681
+ const q = f2.q?.toLowerCase();
1682
+ const all = [...this.assets.values()].filter(
1683
+ (a) => (f2.type === void 0 || a.type === f2.type) && (f2.tag === void 0 || (a.tags ?? []).includes(f2.tag)) && (f2.status === void 0 || a.status === f2.status) && (q === void 0 || String(a.name).toLowerCase().includes(q))
1684
+ );
1685
+ const start = Number(f2.cursor ?? 0) || 0;
1686
+ const end = f2.limit === void 0 ? all.length : Math.min(all.length, start + Number(f2.limit));
1687
+ return json(200, {
1688
+ items: all.slice(start, end),
1689
+ nextCursor: end < all.length ? String(end) : null
1690
+ });
1691
+ }
1644
1692
  case "getJob": {
1645
1693
  const j = this.jobs.get(p.jobId);
1646
1694
  return j ? json(200, j) : problem(404, "not-found", "job");
@@ -110,6 +110,11 @@ declare class FakeDomeServer {
110
110
  readonly users: Map<string, string>;
111
111
  /** Accepted API keys → role. */
112
112
  readonly apiKeys: Map<string, string>;
113
+ /** Pending physical actions (`listAssistantConfirmations`). */
114
+ confirmations: Json[];
115
+ readonly linkSessions: Json[];
116
+ /** The code `approveAssistantLink` accepts. */
117
+ linkCode: string;
113
118
  networkDown: boolean;
114
119
  realtimeAvailable: boolean;
115
120
  accessTtlSec: number;
package/dist/testing.d.ts CHANGED
@@ -110,6 +110,11 @@ declare class FakeDomeServer {
110
110
  readonly users: Map<string, string>;
111
111
  /** Accepted API keys → role. */
112
112
  readonly apiKeys: Map<string, string>;
113
+ /** Pending physical actions (`listAssistantConfirmations`). */
114
+ confirmations: Json[];
115
+ readonly linkSessions: Json[];
116
+ /** The code `approveAssistantLink` accepts. */
117
+ linkCode: string;
113
118
  networkDown: boolean;
114
119
  realtimeAvailable: boolean;
115
120
  accessTtlSec: number;
package/dist/testing.js CHANGED
@@ -713,6 +713,11 @@ var FakeDomeServer = class {
713
713
  ]);
714
714
  /** Accepted API keys → role. */
715
715
  apiKeys = /* @__PURE__ */ new Map();
716
+ /** Pending physical actions (`listAssistantConfirmations`). */
717
+ confirmations = [];
718
+ linkSessions = [];
719
+ /** The code `approveAssistantLink` accepts. */
720
+ linkCode = "7KQM-2XVB";
716
721
  networkDown = false;
717
722
  realtimeAvailable = true;
718
723
  accessTtlSec = 900;
@@ -750,7 +755,7 @@ var FakeDomeServer = class {
750
755
  * Contract version the fake reports in `getInfo` and behaves as: below 1.1.0 the operations of 1.1.0 answer 404 and
751
756
  * its members 422, as a 1.0 server does.
752
757
  */
753
- contractVersion = "1.1.0";
758
+ contractVersion = "1.2.0";
754
759
  /** Calibration jobs by id. */
755
760
  calibrationJobs = /* @__PURE__ */ new Map();
756
761
  /** Audio model + hooks (`emitLevels`, `advanceSession`). */
@@ -947,6 +952,38 @@ var FakeDomeServer = class {
947
952
  capabilities: { realtime: ["ws"], audio: true },
948
953
  transports: { ws: true, graphql: false, socketIo: false }
949
954
  });
955
+ case "listAssistantConfirmations":
956
+ return json(200, { items: this.confirmations, nextCursor: null });
957
+ case "refuseAssistantConfirmation": {
958
+ const c = this.confirmations.find((x) => x.id === p.confirmationId);
959
+ if (!c) return problem(404, "not-found", "no such confirmation");
960
+ c.status = "refused";
961
+ delete c.code;
962
+ return json(200, c);
963
+ }
964
+ case "getAssistantLink":
965
+ return json(200, { enabled: true, state: "online", sessions: this.linkSessions });
966
+ case "approveAssistantLink": {
967
+ if (body?.code !== this.linkCode) return problem(422, "validation-failed", "wrong code");
968
+ const session = {
969
+ id: uuidV7(),
970
+ approver: "user:admin",
971
+ role: "operator",
972
+ scopes: ["playback:control"],
973
+ createdAt: (/* @__PURE__ */ new Date(0)).toISOString(),
974
+ expiresAt: new Date(8 * 36e5).toISOString(),
975
+ status: "active",
976
+ calls: 0
977
+ };
978
+ this.linkSessions.push(session);
979
+ return json(201, session);
980
+ }
981
+ case "endAssistantLink": {
982
+ const x = this.linkSessions.find((v) => v.id === p.sessionId);
983
+ if (!x) return problem(404, "not-found", "no such approval");
984
+ x.status = "ended";
985
+ return new FreedomeResponse(204);
986
+ }
950
987
  case "createSession": {
951
988
  if (this.users.get(body?.username) !== body?.password)
952
989
  return problem(401, "unauthenticated", "wrong username or password");
@@ -1275,8 +1312,19 @@ var FakeDomeServer = class {
1275
1312
  const a = this.assets.get(p.assetId);
1276
1313
  return a ? json(200, a, this.etag(a.revision)) : problem(404, "not-found", "asset");
1277
1314
  }
1278
- case "listAssets":
1279
- return json(200, { items: [...this.assets.values()], nextCursor: null });
1315
+ case "listAssets": {
1316
+ const f2 = r.query ?? {};
1317
+ const q = f2.q?.toLowerCase();
1318
+ const all = [...this.assets.values()].filter(
1319
+ (a) => (f2.type === void 0 || a.type === f2.type) && (f2.tag === void 0 || (a.tags ?? []).includes(f2.tag)) && (f2.status === void 0 || a.status === f2.status) && (q === void 0 || String(a.name).toLowerCase().includes(q))
1320
+ );
1321
+ const start = Number(f2.cursor ?? 0) || 0;
1322
+ const end = f2.limit === void 0 ? all.length : Math.min(all.length, start + Number(f2.limit));
1323
+ return json(200, {
1324
+ items: all.slice(start, end),
1325
+ nextCursor: end < all.length ? String(end) : null
1326
+ });
1327
+ }
1280
1328
  case "getJob": {
1281
1329
  const j = this.jobs.get(p.jobId);
1282
1330
  return j ? json(200, j) : problem(404, "not-found", "job");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@freedome/client",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Isomorphic Freedome client: REST, WebSocket freedome.v1, graphql-ws, socket.io; connection state machine; repositories; offline cache / outbox; codecs (/codecs), Node helpers (/node), in-memory fake (/testing).",
5
5
  "license": "NativeMindNONC",
6
6
  "homepage": "https://freedome.nativemind.us",
@@ -47,7 +47,7 @@
47
47
  "dependencies": {
48
48
  "fflate": "^0.8.3",
49
49
  "socket.io-client": "^4.8.4",
50
- "@freedome/protocol": "1.1.0"
50
+ "@freedome/protocol": "1.2.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/node": "^22.20.5",