@indigoai-us/hq-cloud 6.14.7 → 6.14.8

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.
Files changed (69) hide show
  1. package/dist/backup-prune.d.ts +68 -0
  2. package/dist/backup-prune.d.ts.map +1 -0
  3. package/dist/backup-prune.js +196 -0
  4. package/dist/backup-prune.js.map +1 -0
  5. package/dist/backup-prune.test.d.ts +2 -0
  6. package/dist/backup-prune.test.d.ts.map +1 -0
  7. package/dist/backup-prune.test.js +89 -0
  8. package/dist/backup-prune.test.js.map +1 -0
  9. package/dist/bin/backup-prune-runner.d.ts +3 -0
  10. package/dist/bin/backup-prune-runner.d.ts.map +1 -0
  11. package/dist/bin/backup-prune-runner.js +50 -0
  12. package/dist/bin/backup-prune-runner.js.map +1 -0
  13. package/dist/bin/sync-runner-watch-loop.d.ts.map +1 -1
  14. package/dist/bin/sync-runner-watch-loop.js +28 -0
  15. package/dist/bin/sync-runner-watch-loop.js.map +1 -1
  16. package/dist/bin/sync-runner.d.ts +2 -0
  17. package/dist/bin/sync-runner.d.ts.map +1 -1
  18. package/dist/bin/sync-runner.js.map +1 -1
  19. package/dist/cli/rescue-classify-ordering.test.js +105 -0
  20. package/dist/cli/rescue-classify-ordering.test.js.map +1 -1
  21. package/dist/cli/rescue-core.d.ts +1 -0
  22. package/dist/cli/rescue-core.d.ts.map +1 -1
  23. package/dist/cli/rescue-core.js +478 -300
  24. package/dist/cli/rescue-core.js.map +1 -1
  25. package/dist/cli/rescue-snapshot.d.ts +14 -0
  26. package/dist/cli/rescue-snapshot.d.ts.map +1 -0
  27. package/dist/cli/rescue-snapshot.js +39 -0
  28. package/dist/cli/rescue-snapshot.js.map +1 -0
  29. package/dist/cli/rescue-snapshot.test.d.ts +2 -0
  30. package/dist/cli/rescue-snapshot.test.d.ts.map +1 -0
  31. package/dist/cli/rescue-snapshot.test.js +46 -0
  32. package/dist/cli/rescue-snapshot.test.js.map +1 -0
  33. package/dist/cli/sync.d.ts.map +1 -1
  34. package/dist/cli/sync.js +13 -0
  35. package/dist/cli/sync.js.map +1 -1
  36. package/dist/cli/sync.test.js +51 -0
  37. package/dist/cli/sync.test.js.map +1 -1
  38. package/dist/object-io.d.ts +19 -2
  39. package/dist/object-io.d.ts.map +1 -1
  40. package/dist/object-io.js +168 -32
  41. package/dist/object-io.js.map +1 -1
  42. package/dist/object-io.test.js +157 -1
  43. package/dist/object-io.test.js.map +1 -1
  44. package/dist/signals/get.test.js +21 -1
  45. package/dist/signals/get.test.js.map +1 -1
  46. package/dist/signals/list.test.js +21 -1
  47. package/dist/signals/list.test.js.map +1 -1
  48. package/dist/sources/get.test.js +21 -1
  49. package/dist/sources/get.test.js.map +1 -1
  50. package/dist/sources/list.test.js +21 -1
  51. package/dist/sources/list.test.js.map +1 -1
  52. package/package.json +3 -2
  53. package/src/backup-prune.test.ts +98 -0
  54. package/src/backup-prune.ts +182 -0
  55. package/src/bin/backup-prune-runner.ts +33 -0
  56. package/src/bin/sync-runner-watch-loop.ts +18 -0
  57. package/src/bin/sync-runner.ts +2 -0
  58. package/src/cli/rescue-classify-ordering.test.ts +121 -0
  59. package/src/cli/rescue-core.ts +261 -86
  60. package/src/cli/rescue-snapshot.test.ts +57 -0
  61. package/src/cli/rescue-snapshot.ts +51 -0
  62. package/src/cli/sync.test.ts +62 -0
  63. package/src/cli/sync.ts +18 -0
  64. package/src/object-io.test.ts +175 -0
  65. package/src/object-io.ts +213 -32
  66. package/src/signals/get.test.ts +26 -2
  67. package/src/signals/list.test.ts +26 -2
  68. package/src/sources/get.test.ts +26 -2
  69. package/src/sources/list.test.ts +26 -2
@@ -7,6 +7,7 @@
7
7
  */
8
8
 
9
9
  import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
10
+ import { Readable } from "node:stream";
10
11
  import {
11
12
  GetObjectCommand,
12
13
  ListObjectsV2Command,
@@ -17,7 +18,11 @@ import {
17
18
  _setSignalsS3Factory,
18
19
  _resetSignalsS3Factory,
19
20
  } from "./internals.js";
20
- import type { PresignTransportClient } from "../object-io.js";
21
+ import {
22
+ setPresignedGetTransportForTesting,
23
+ type PresignedGetTransport,
24
+ type PresignTransportClient,
25
+ } from "../object-io.js";
21
26
  import type { VaultListedObject } from "../vault-client.js";
22
27
  import type { EntityContext } from "../types.js";
23
28
  import { InvalidSignalTypeError, SIGNAL_TYPES } from "../schemas/signal-types.js";
@@ -293,6 +298,21 @@ interface PresignVaultStub {
293
298
  listCalls: Array<{ prefix?: string; cursor?: string }>;
294
299
  }
295
300
 
301
+ function fetchBackedPresignedGetTransport(): PresignedGetTransport {
302
+ return {
303
+ async get(url, headers) {
304
+ const response = await fetch(url, { method: "GET", headers });
305
+ const body = response.body ? Readable.fromWeb(response.body) : undefined;
306
+ return {
307
+ status: response.status,
308
+ headers: response.headers,
309
+ body,
310
+ destroy: () => body?.destroy(),
311
+ };
312
+ },
313
+ };
314
+ }
315
+
296
316
  function makePresignVault(
297
317
  page: { objects: VaultListedObject[]; cursor: string | null },
298
318
  contents: Record<string, string> = {},
@@ -307,6 +327,7 @@ function makePresignVault(
307
327
  return new Response(Buffer.from(c, "utf-8"), { status: 200 });
308
328
  }),
309
329
  );
330
+ setPresignedGetTransportForTesting(fetchBackedPresignedGetTransport());
310
331
  const vault: PresignTransportClient = {
311
332
  presign: async (input) => ({
312
333
  results: input.keys.map((k) => ({
@@ -339,7 +360,10 @@ function listed(key: string): VaultListedObject {
339
360
  }
340
361
 
341
362
  describe("listSignals — presigned transport (vault + cmp_)", () => {
342
- afterEach(() => vi.unstubAllGlobals());
363
+ afterEach(() => {
364
+ setPresignedGetTransportForTesting(null);
365
+ vi.unstubAllGlobals();
366
+ });
343
367
 
344
368
  it("lists via the ACL-filtered vault endpoint and never touches S3", async () => {
345
369
  _setSignalsS3Factory(
@@ -3,13 +3,18 @@
3
3
  */
4
4
 
5
5
  import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
6
+ import { Readable } from "node:stream";
6
7
  import { GetObjectCommand, type S3Client } from "@aws-sdk/client-s3";
7
8
  import { getSource, SourceNotFoundError } from "./get.js";
8
9
  import {
9
10
  _setSourcesS3Factory,
10
11
  _resetSourcesS3Factory,
11
12
  } from "./internals.js";
12
- import type { PresignTransportClient } from "../object-io.js";
13
+ import {
14
+ setPresignedGetTransportForTesting,
15
+ type PresignedGetTransport,
16
+ type PresignTransportClient,
17
+ } from "../object-io.js";
13
18
  import type { EntityContext } from "../types.js";
14
19
  import { InvalidSourceChannelError } from "../schemas/source-channels.js";
15
20
 
@@ -170,6 +175,21 @@ describe("getSource", () => {
170
175
  // Presigned transport (vault client + company vault) — HQ-59
171
176
  // ---------------------------------------------------------------------------
172
177
 
178
+ function fetchBackedPresignedGetTransport(): PresignedGetTransport {
179
+ return {
180
+ async get(url, headers) {
181
+ const response = await fetch(url, { method: "GET", headers });
182
+ const body = response.body ? Readable.fromWeb(response.body) : undefined;
183
+ return {
184
+ status: response.status,
185
+ headers: response.headers,
186
+ body,
187
+ destroy: () => body?.destroy(),
188
+ };
189
+ },
190
+ };
191
+ }
192
+
173
193
  /**
174
194
  * A presign-capable vault stub + a `fetch` mock keyed by the presigned URL.
175
195
  * presign() mints a URL that encodes the key; fetch() returns the object's
@@ -186,6 +206,7 @@ function makePresignVault(objects: Record<string, string>): PresignTransportClie
186
206
  return new Response(Buffer.from(content, "utf-8"), { status: 200 });
187
207
  }),
188
208
  );
209
+ setPresignedGetTransportForTesting(fetchBackedPresignedGetTransport());
189
210
  return {
190
211
  presign: async (input) => ({
191
212
  results: input.keys.map((k) => ({
@@ -200,7 +221,10 @@ function makePresignVault(objects: Record<string, string>): PresignTransportClie
200
221
  }
201
222
 
202
223
  describe("getSource — presigned transport (vault + cmp_)", () => {
203
- afterEach(() => vi.unstubAllGlobals());
224
+ afterEach(() => {
225
+ setPresignedGetTransportForTesting(null);
226
+ vi.unstubAllGlobals();
227
+ });
204
228
 
205
229
  it("reads via presign and never touches S3", async () => {
206
230
  // S3 factory throws if used — proves the read went through presign.
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
9
+ import { Readable } from "node:stream";
9
10
  import {
10
11
  GetObjectCommand,
11
12
  ListObjectsV2Command,
@@ -16,7 +17,11 @@ import {
16
17
  _setSourcesS3Factory,
17
18
  _resetSourcesS3Factory,
18
19
  } from "./internals.js";
19
- import type { PresignTransportClient } from "../object-io.js";
20
+ import {
21
+ setPresignedGetTransportForTesting,
22
+ type PresignedGetTransport,
23
+ type PresignTransportClient,
24
+ } from "../object-io.js";
20
25
  import type { VaultListedObject } from "../vault-client.js";
21
26
  import type { EntityContext } from "../types.js";
22
27
  import { InvalidSourceChannelError } from "../schemas/source-channels.js";
@@ -257,6 +262,21 @@ interface PresignVaultStub {
257
262
  listCalls: Array<{ prefix?: string; cursor?: string }>;
258
263
  }
259
264
 
265
+ function fetchBackedPresignedGetTransport(): PresignedGetTransport {
266
+ return {
267
+ async get(url, headers) {
268
+ const response = await fetch(url, { method: "GET", headers });
269
+ const body = response.body ? Readable.fromWeb(response.body) : undefined;
270
+ return {
271
+ status: response.status,
272
+ headers: response.headers,
273
+ body,
274
+ destroy: () => body?.destroy(),
275
+ };
276
+ },
277
+ };
278
+ }
279
+
260
280
  /**
261
281
  * Vault stub for the list path: `listFiles` returns the configured ACL-filtered
262
282
  * page (the server is the ACL boundary — only readable keys come back) + an
@@ -276,6 +296,7 @@ function makePresignVault(
276
296
  return new Response(Buffer.from(c, "utf-8"), { status: 200 });
277
297
  }),
278
298
  );
299
+ setPresignedGetTransportForTesting(fetchBackedPresignedGetTransport());
279
300
  const vault: PresignTransportClient = {
280
301
  presign: async (input) => ({
281
302
  results: input.keys.map((k) => ({
@@ -308,7 +329,10 @@ function listed(key: string): VaultListedObject {
308
329
  }
309
330
 
310
331
  describe("listSources — presigned transport (vault + cmp_)", () => {
311
- afterEach(() => vi.unstubAllGlobals());
332
+ afterEach(() => {
333
+ setPresignedGetTransportForTesting(null);
334
+ vi.unstubAllGlobals();
335
+ });
312
336
 
313
337
  it("lists via the ACL-filtered vault endpoint and never touches S3", async () => {
314
338
  _setSourcesS3Factory(