@adcp/sdk 16.0.0-beta.3 → 16.0.0-beta.4

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 (182) hide show
  1. package/dist/lib/auth/oauth/diagnose.js +3 -11
  2. package/dist/lib/auth/oauth/diagnose.mjs +4 -12
  3. package/dist/lib/auth/oauth/diagnostics.d.mts +2 -1
  4. package/dist/lib/auth/oauth/diagnostics.d.ts +2 -1
  5. package/dist/lib/auth/oauth/diagnostics.js +8 -10
  6. package/dist/lib/auth/oauth/diagnostics.mjs +7 -10
  7. package/dist/lib/index.d.mts +1 -1
  8. package/dist/lib/index.d.ts +1 -1
  9. package/dist/lib/index.js +2 -0
  10. package/dist/lib/index.mjs +7 -1
  11. package/dist/lib/reporting/consumer-runtime.js +2 -1
  12. package/dist/lib/reporting/consumer-runtime.mjs +2 -1
  13. package/dist/lib/reporting/ledger/handler.js +50 -11
  14. package/dist/lib/reporting/ledger/handler.mjs +50 -12
  15. package/dist/lib/reporting/ledger/index.d.mts +17 -14
  16. package/dist/lib/reporting/ledger/index.d.ts +17 -14
  17. package/dist/lib/reporting/ledger/index.js +32 -20
  18. package/dist/lib/reporting/ledger/index.mjs +21 -10
  19. package/dist/lib/reporting/ledger/offering-validation.d.mts +9 -0
  20. package/dist/lib/reporting/ledger/offering-validation.d.ts +9 -0
  21. package/dist/lib/reporting/{gcs/bucket-policy.js → ledger/offering-validation.js} +9 -8
  22. package/dist/lib/reporting/ledger/offering-validation.mjs +8 -0
  23. package/dist/lib/reporting/ledger/receipts.d.mts +48 -0
  24. package/dist/lib/reporting/ledger/receipts.d.ts +48 -0
  25. package/dist/lib/reporting/ledger/receipts.js +186 -0
  26. package/dist/lib/reporting/ledger/receipts.mjs +161 -0
  27. package/dist/lib/reporting/ledger/status-ingest.js +3 -3
  28. package/dist/lib/reporting/ledger/status-ingest.mjs +4 -5
  29. package/dist/lib/reporting/ledger/types.d.mts +43 -0
  30. package/dist/lib/reporting/ledger/types.d.ts +43 -0
  31. package/dist/lib/reporting/ledger/types.js +31 -2
  32. package/dist/lib/reporting/ledger/types.mjs +26 -1
  33. package/dist/lib/reporting/pagination.d.mts +6 -0
  34. package/dist/lib/reporting/pagination.d.ts +6 -0
  35. package/dist/lib/reporting/{gcs/errors.js → pagination.js} +12 -17
  36. package/dist/lib/reporting/pagination.mjs +12 -0
  37. package/dist/lib/reporting/reconciliation.d.mts +1 -0
  38. package/dist/lib/reporting/reconciliation.d.ts +1 -0
  39. package/dist/lib/reporting/reconciliation.js +3 -2
  40. package/dist/lib/reporting/reconciliation.mjs +3 -2
  41. package/dist/lib/reporting/service/index.d.mts +79 -153
  42. package/dist/lib/reporting/service/index.d.ts +79 -153
  43. package/dist/lib/reporting/service/index.js +34 -491
  44. package/dist/lib/reporting/service/index.mjs +36 -510
  45. package/dist/lib/reporting/service/scheduler-support.d.mts +43 -0
  46. package/dist/lib/reporting/service/scheduler-support.d.ts +43 -0
  47. package/dist/lib/reporting/service/scheduler-support.js +125 -0
  48. package/dist/lib/reporting/service/scheduler-support.mjs +96 -0
  49. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  50. package/dist/lib/signing/canonicalize.d.mts +4 -0
  51. package/dist/lib/signing/canonicalize.d.ts +4 -0
  52. package/dist/lib/signing/canonicalize.js +14 -8
  53. package/dist/lib/signing/canonicalize.mjs +14 -8
  54. package/dist/lib/signing/content-digest.d.mts +8 -0
  55. package/dist/lib/signing/content-digest.d.ts +8 -0
  56. package/dist/lib/signing/content-digest.js +11 -5
  57. package/dist/lib/signing/content-digest.mjs +10 -5
  58. package/dist/lib/signing/signer.js +9 -6
  59. package/dist/lib/signing/signer.mjs +10 -7
  60. package/dist/lib/signing/web-bot-auth.js +103 -37
  61. package/dist/lib/signing/web-bot-auth.mjs +108 -37
  62. package/dist/lib/testing/storyboard/junit.js +16 -3
  63. package/dist/lib/testing/storyboard/junit.mjs +16 -3
  64. package/dist/lib/testing/storyboard/request-signing/builder.js +10 -9
  65. package/dist/lib/testing/storyboard/request-signing/builder.mjs +10 -9
  66. package/dist/lib/testing/storyboard/runner.js +94 -25
  67. package/dist/lib/testing/storyboard/runner.mjs +94 -25
  68. package/dist/lib/testing/storyboard/types.d.mts +6 -0
  69. package/dist/lib/testing/storyboard/types.d.ts +6 -0
  70. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  71. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  72. package/dist/lib/version.d.mts +3 -3
  73. package/dist/lib/version.d.ts +3 -3
  74. package/dist/lib/version.js +3 -3
  75. package/dist/lib/version.mjs +3 -3
  76. package/docs/TYPE-SUMMARY.md +23 -5
  77. package/docs/guides/REPORTING-GCS-FENCE.md +3 -3
  78. package/docs/guides/REPORTING-GCS-MANAGED.md +4 -4
  79. package/docs/guides/REPORTING-LEDGER-CUTOVER.md +7 -7
  80. package/docs/guides/REPORTING-LEDGER.md +107 -51
  81. package/docs/guides/REPORTING-OPERATIONS.md +66 -5
  82. package/docs/guides/REPORTING-STABILITY.md +36 -32
  83. package/docs/llms.txt +4 -3
  84. package/docs/migration-14.x-rc-worksheet.md +4 -7
  85. package/docs/migration-reporting-storage-package.md +186 -0
  86. package/examples/README.md +1 -1
  87. package/package.json +13 -78
  88. package/dist/lib/reporting/azure/index.d.mts +0 -31
  89. package/dist/lib/reporting/azure/index.d.ts +0 -31
  90. package/dist/lib/reporting/azure/index.js +0 -266
  91. package/dist/lib/reporting/azure/index.mjs +0 -249
  92. package/dist/lib/reporting/bigquery/index.d.mts +0 -246
  93. package/dist/lib/reporting/bigquery/index.d.ts +0 -246
  94. package/dist/lib/reporting/bigquery/index.js +0 -633
  95. package/dist/lib/reporting/bigquery/index.mjs +0 -594
  96. package/dist/lib/reporting/gcs/adapter.d.mts +0 -38
  97. package/dist/lib/reporting/gcs/adapter.d.ts +0 -38
  98. package/dist/lib/reporting/gcs/adapter.js +0 -342
  99. package/dist/lib/reporting/gcs/adapter.mjs +0 -325
  100. package/dist/lib/reporting/gcs/bucket-policy.d.mts +0 -3
  101. package/dist/lib/reporting/gcs/bucket-policy.d.ts +0 -3
  102. package/dist/lib/reporting/gcs/bucket-policy.mjs +0 -7
  103. package/dist/lib/reporting/gcs/errors.d.mts +0 -11
  104. package/dist/lib/reporting/gcs/errors.d.ts +0 -11
  105. package/dist/lib/reporting/gcs/errors.mjs +0 -16
  106. package/dist/lib/reporting/gcs/fence.d.mts +0 -41
  107. package/dist/lib/reporting/gcs/fence.d.ts +0 -41
  108. package/dist/lib/reporting/gcs/fence.js +0 -250
  109. package/dist/lib/reporting/gcs/fence.mjs +0 -230
  110. package/dist/lib/reporting/gcs/index.d.mts +0 -18
  111. package/dist/lib/reporting/gcs/index.d.ts +0 -18
  112. package/dist/lib/reporting/gcs/index.js +0 -44
  113. package/dist/lib/reporting/gcs/index.mjs +0 -14
  114. package/dist/lib/reporting/gcs/io.d.mts +0 -7
  115. package/dist/lib/reporting/gcs/io.d.ts +0 -7
  116. package/dist/lib/reporting/gcs/io.js +0 -95
  117. package/dist/lib/reporting/gcs/io.mjs +0 -69
  118. package/dist/lib/reporting/gcs/reader.d.mts +0 -67
  119. package/dist/lib/reporting/gcs/reader.d.ts +0 -67
  120. package/dist/lib/reporting/gcs/reader.js +0 -193
  121. package/dist/lib/reporting/gcs/reader.mjs +0 -169
  122. package/dist/lib/reporting/gcs/row-provider.d.mts +0 -39
  123. package/dist/lib/reporting/gcs/row-provider.d.ts +0 -39
  124. package/dist/lib/reporting/gcs/row-provider.js +0 -225
  125. package/dist/lib/reporting/gcs/row-provider.mjs +0 -208
  126. package/dist/lib/reporting/gcs/validation.d.mts +0 -5
  127. package/dist/lib/reporting/gcs/validation.d.ts +0 -5
  128. package/dist/lib/reporting/gcs/validation.js +0 -49
  129. package/dist/lib/reporting/gcs/validation.mjs +0 -25
  130. package/dist/lib/reporting/ledger/change-feed.d.mts +0 -69
  131. package/dist/lib/reporting/ledger/change-feed.d.ts +0 -69
  132. package/dist/lib/reporting/ledger/change-feed.js +0 -107
  133. package/dist/lib/reporting/ledger/change-feed.mjs +0 -80
  134. package/dist/lib/reporting/ledger/managed-postgres.d.mts +0 -293
  135. package/dist/lib/reporting/ledger/managed-postgres.d.ts +0 -293
  136. package/dist/lib/reporting/ledger/managed-postgres.js +0 -2346
  137. package/dist/lib/reporting/ledger/managed-postgres.mjs +0 -2332
  138. package/dist/lib/reporting/ledger/managed-router.d.mts +0 -148
  139. package/dist/lib/reporting/ledger/managed-router.d.ts +0 -148
  140. package/dist/lib/reporting/ledger/managed-router.js +0 -280
  141. package/dist/lib/reporting/ledger/managed-router.mjs +0 -258
  142. package/dist/lib/reporting/ledger/managed.d.mts +0 -535
  143. package/dist/lib/reporting/ledger/managed.d.ts +0 -535
  144. package/dist/lib/reporting/ledger/managed.js +0 -761
  145. package/dist/lib/reporting/ledger/managed.mjs +0 -729
  146. package/dist/lib/reporting/ledger/notification-activity.d.mts +0 -332
  147. package/dist/lib/reporting/ledger/notification-activity.d.ts +0 -332
  148. package/dist/lib/reporting/ledger/notification-activity.js +0 -1366
  149. package/dist/lib/reporting/ledger/notification-activity.mjs +0 -1337
  150. package/dist/lib/reporting/ledger/object-writes.d.mts +0 -128
  151. package/dist/lib/reporting/ledger/object-writes.d.ts +0 -128
  152. package/dist/lib/reporting/ledger/object-writes.js +0 -147
  153. package/dist/lib/reporting/ledger/object-writes.mjs +0 -114
  154. package/dist/lib/reporting/ledger/postgres.d.mts +0 -689
  155. package/dist/lib/reporting/ledger/postgres.d.ts +0 -689
  156. package/dist/lib/reporting/ledger/postgres.js +0 -4462
  157. package/dist/lib/reporting/ledger/postgres.mjs +0 -4462
  158. package/dist/lib/reporting/ledger/row-storage-migration.d.mts +0 -59
  159. package/dist/lib/reporting/ledger/row-storage-migration.d.ts +0 -59
  160. package/dist/lib/reporting/ledger/row-storage-migration.js +0 -365
  161. package/dist/lib/reporting/ledger/row-storage-migration.mjs +0 -339
  162. package/dist/lib/reporting/ledger/row-storage-object.d.mts +0 -203
  163. package/dist/lib/reporting/ledger/row-storage-object.d.ts +0 -203
  164. package/dist/lib/reporting/ledger/row-storage-object.js +0 -379
  165. package/dist/lib/reporting/ledger/row-storage-object.mjs +0 -335
  166. package/dist/lib/reporting/ledger/row-storage-provider-io.d.mts +0 -44
  167. package/dist/lib/reporting/ledger/row-storage-provider-io.d.ts +0 -44
  168. package/dist/lib/reporting/ledger/row-storage-provider-io.js +0 -142
  169. package/dist/lib/reporting/ledger/row-storage-provider-io.mjs +0 -111
  170. package/dist/lib/reporting/ledger/row-storage.d.mts +0 -316
  171. package/dist/lib/reporting/ledger/row-storage.d.ts +0 -316
  172. package/dist/lib/reporting/ledger/row-storage.js +0 -812
  173. package/dist/lib/reporting/ledger/row-storage.mjs +0 -802
  174. package/dist/lib/reporting/s3/index.d.mts +0 -34
  175. package/dist/lib/reporting/s3/index.d.ts +0 -34
  176. package/dist/lib/reporting/s3/index.js +0 -347
  177. package/dist/lib/reporting/s3/index.mjs +0 -340
  178. package/dist/lib/reporting/service/maintenance.d.mts +0 -148
  179. package/dist/lib/reporting/service/maintenance.d.ts +0 -148
  180. package/dist/lib/reporting/service/maintenance.js +0 -185
  181. package/dist/lib/reporting/service/maintenance.mjs +0 -159
  182. package/examples/reliable-reporting-service/README.md +0 -169
@@ -1,44 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var gcs_exports = {};
20
- __export(gcs_exports, {
21
- ReportingGcsFenceError: () => import_errors.ReportingGcsFenceError,
22
- createGcsReportingManagedDeliveryAdapterV1: () => import_adapter.createGcsReportingManagedDeliveryAdapterV1,
23
- createGcsReportingObjectFenceV1: () => import_fence.createGcsReportingObjectFenceV1,
24
- createGcsReportingReferenceResolverV1: () => import_reader.createGcsReportingReferenceResolverV1,
25
- createGcsReportingResourceReaderV1: () => import_reader.createGcsReportingResourceReaderV1,
26
- createGcsReportingRowObjectProviderV1: () => import_row_provider.createGcsReportingRowObjectProviderV1,
27
- isReportingGcsFenceError: () => import_errors.isReportingGcsFenceError
28
- });
29
- module.exports = __toCommonJS(gcs_exports);
30
- var import_fence = require('./fence.js');
31
- var import_errors = require('./errors.js');
32
- var import_reader = require('./reader.js');
33
- var import_adapter = require('./adapter.js');
34
- var import_row_provider = require('./row-provider.js');
35
- // Annotate the CommonJS export names for ESM import in node:
36
- 0 && (module.exports = {
37
- ReportingGcsFenceError,
38
- createGcsReportingManagedDeliveryAdapterV1,
39
- createGcsReportingObjectFenceV1,
40
- createGcsReportingReferenceResolverV1,
41
- createGcsReportingResourceReaderV1,
42
- createGcsReportingRowObjectProviderV1,
43
- isReportingGcsFenceError
44
- });
@@ -1,14 +0,0 @@
1
- import { createGcsReportingObjectFenceV1 } from "./fence.mjs";
2
- import { ReportingGcsFenceError, isReportingGcsFenceError } from "./errors.mjs";
3
- import { createGcsReportingResourceReaderV1, createGcsReportingReferenceResolverV1 } from "./reader.mjs";
4
- import { createGcsReportingManagedDeliveryAdapterV1 } from "./adapter.mjs";
5
- import { createGcsReportingRowObjectProviderV1 } from "./row-provider.mjs";
6
- export {
7
- ReportingGcsFenceError,
8
- createGcsReportingManagedDeliveryAdapterV1,
9
- createGcsReportingObjectFenceV1,
10
- createGcsReportingReferenceResolverV1,
11
- createGcsReportingResourceReaderV1,
12
- createGcsReportingRowObjectProviderV1,
13
- isReportingGcsFenceError
14
- };
@@ -1,7 +0,0 @@
1
- import type { File } from '@google-cloud/storage';
2
- export declare function activeGcsSignal(signal: AbortSignal): void;
3
- export declare function withGcsDeadline<T>(work: (signal: AbortSignal) => Promise<T>, context?: {
4
- signal?: AbortSignal;
5
- milliseconds?: number;
6
- }): Promise<T>;
7
- export declare function readGcsBytes(file: File, maxBytes: number, signal: AbortSignal): Promise<Buffer>;
@@ -1,7 +0,0 @@
1
- import type { File } from '@google-cloud/storage';
2
- export declare function activeGcsSignal(signal: AbortSignal): void;
3
- export declare function withGcsDeadline<T>(work: (signal: AbortSignal) => Promise<T>, context?: {
4
- signal?: AbortSignal;
5
- milliseconds?: number;
6
- }): Promise<T>;
7
- export declare function readGcsBytes(file: File, maxBytes: number, signal: AbortSignal): Promise<Buffer>;
@@ -1,95 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var io_exports = {};
20
- __export(io_exports, {
21
- activeGcsSignal: () => activeGcsSignal,
22
- readGcsBytes: () => readGcsBytes,
23
- withGcsDeadline: () => withGcsDeadline
24
- });
25
- module.exports = __toCommonJS(io_exports);
26
- var import_object_writes = require('../ledger/object-writes.js');
27
- var import_errors = require('./errors.js');
28
- function activeGcsSignal(signal) {
29
- if (signal.aborted) throw signal.reason;
30
- }
31
- const active = activeGcsSignal;
32
- async function withGcsDeadline(work, context = {}) {
33
- const signal = context.signal;
34
- const deadline = context.milliseconds ?? 6e4;
35
- if (!Number.isSafeInteger(deadline) || deadline < 1 || deadline > 6e4)
36
- throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
37
- if (signal !== void 0 && !(signal instanceof AbortSignal)) throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
38
- const controller = new AbortController();
39
- const onAbort = () => controller.abort(new import_errors.ReportingGcsFenceError("ABORTED"));
40
- signal?.addEventListener("abort", onAbort, { once: true });
41
- if (signal?.aborted) onAbort();
42
- const timer = setTimeout(() => controller.abort(new import_errors.ReportingGcsFenceError("DEADLINE_EXCEEDED")), deadline);
43
- let rejectAbort;
44
- try {
45
- active(controller.signal);
46
- return await Promise.race([
47
- work(controller.signal),
48
- new Promise((_, reject) => {
49
- rejectAbort = () => reject(controller.signal.reason);
50
- controller.signal.addEventListener("abort", rejectAbort, { once: true });
51
- if (controller.signal.aborted) rejectAbort();
52
- })
53
- ]);
54
- } catch (error) {
55
- if (controller.signal.aborted) throw controller.signal.reason;
56
- if ((0, import_errors.isReportingGcsFenceError)(error)) throw error;
57
- if ((0, import_object_writes.isReportingObjectWriteConflictError)(error) || error instanceof Error && (0, import_object_writes.isReportingObjectWriteConflictError)(error.cause))
58
- throw new import_errors.ReportingGcsFenceError("CONTENT_CONFLICT");
59
- if ((0, import_object_writes.isReportingObjectWriteNotRevokedError)(error) || error instanceof Error && (0, import_object_writes.isReportingObjectWriteNotRevokedError)(error.cause))
60
- throw new import_errors.ReportingGcsFenceError("NOT_REVOKED");
61
- throw new import_errors.ReportingGcsFenceError("STATE_UNAVAILABLE");
62
- } finally {
63
- clearTimeout(timer);
64
- signal?.removeEventListener("abort", onAbort);
65
- if (rejectAbort) controller.signal.removeEventListener("abort", rejectAbort);
66
- }
67
- }
68
- async function readGcsBytes(file, maxBytes, signal) {
69
- active(signal);
70
- const stream = file.createReadStream();
71
- const abort = () => stream.destroy(new import_errors.ReportingGcsFenceError("ABORTED"));
72
- signal.addEventListener("abort", abort, { once: true });
73
- if (signal.aborted) abort();
74
- const chunks = [];
75
- let count = 0;
76
- try {
77
- for await (const chunk of stream) {
78
- active(signal);
79
- count += chunk.length;
80
- if (count > maxBytes) throw new import_errors.ReportingGcsFenceError("CONTENT_CONFLICT");
81
- chunks.push(Buffer.from(chunk));
82
- }
83
- active(signal);
84
- return Buffer.concat(chunks);
85
- } finally {
86
- signal.removeEventListener("abort", abort);
87
- stream.destroy();
88
- }
89
- }
90
- // Annotate the CommonJS export names for ESM import in node:
91
- 0 && (module.exports = {
92
- activeGcsSignal,
93
- readGcsBytes,
94
- withGcsDeadline
95
- });
@@ -1,69 +0,0 @@
1
- import { isReportingObjectWriteConflictError, isReportingObjectWriteNotRevokedError } from "../ledger/object-writes.mjs";
2
- import { ReportingGcsFenceError, isReportingGcsFenceError } from "./errors.mjs";
3
- function activeGcsSignal(signal) {
4
- if (signal.aborted) throw signal.reason;
5
- }
6
- const active = activeGcsSignal;
7
- async function withGcsDeadline(work, context = {}) {
8
- const signal = context.signal;
9
- const deadline = context.milliseconds ?? 6e4;
10
- if (!Number.isSafeInteger(deadline) || deadline < 1 || deadline > 6e4)
11
- throw new ReportingGcsFenceError("INVALID_INPUT");
12
- if (signal !== void 0 && !(signal instanceof AbortSignal)) throw new ReportingGcsFenceError("INVALID_INPUT");
13
- const controller = new AbortController();
14
- const onAbort = () => controller.abort(new ReportingGcsFenceError("ABORTED"));
15
- signal?.addEventListener("abort", onAbort, { once: true });
16
- if (signal?.aborted) onAbort();
17
- const timer = setTimeout(() => controller.abort(new ReportingGcsFenceError("DEADLINE_EXCEEDED")), deadline);
18
- let rejectAbort;
19
- try {
20
- active(controller.signal);
21
- return await Promise.race([
22
- work(controller.signal),
23
- new Promise((_, reject) => {
24
- rejectAbort = () => reject(controller.signal.reason);
25
- controller.signal.addEventListener("abort", rejectAbort, { once: true });
26
- if (controller.signal.aborted) rejectAbort();
27
- })
28
- ]);
29
- } catch (error) {
30
- if (controller.signal.aborted) throw controller.signal.reason;
31
- if (isReportingGcsFenceError(error)) throw error;
32
- if (isReportingObjectWriteConflictError(error) || error instanceof Error && isReportingObjectWriteConflictError(error.cause))
33
- throw new ReportingGcsFenceError("CONTENT_CONFLICT");
34
- if (isReportingObjectWriteNotRevokedError(error) || error instanceof Error && isReportingObjectWriteNotRevokedError(error.cause))
35
- throw new ReportingGcsFenceError("NOT_REVOKED");
36
- throw new ReportingGcsFenceError("STATE_UNAVAILABLE");
37
- } finally {
38
- clearTimeout(timer);
39
- signal?.removeEventListener("abort", onAbort);
40
- if (rejectAbort) controller.signal.removeEventListener("abort", rejectAbort);
41
- }
42
- }
43
- async function readGcsBytes(file, maxBytes, signal) {
44
- active(signal);
45
- const stream = file.createReadStream();
46
- const abort = () => stream.destroy(new ReportingGcsFenceError("ABORTED"));
47
- signal.addEventListener("abort", abort, { once: true });
48
- if (signal.aborted) abort();
49
- const chunks = [];
50
- let count = 0;
51
- try {
52
- for await (const chunk of stream) {
53
- active(signal);
54
- count += chunk.length;
55
- if (count > maxBytes) throw new ReportingGcsFenceError("CONTENT_CONFLICT");
56
- chunks.push(Buffer.from(chunk));
57
- }
58
- active(signal);
59
- return Buffer.concat(chunks);
60
- } finally {
61
- signal.removeEventListener("abort", abort);
62
- stream.destroy();
63
- }
64
- }
65
- export {
66
- activeGcsSignal,
67
- readGcsBytes,
68
- withGcsDeadline
69
- };
@@ -1,67 +0,0 @@
1
- import type { Storage } from '@google-cloud/storage';
2
- import { type CanonicalReferenceResolver } from '../../canonical-references/index.mjs';
3
- import type { ReportingResourceReader } from '../inspection.mjs';
4
- import { type ReportingObjectWriteScopeV1 } from '../ledger/object-writes.mjs';
5
- /**
6
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
7
- */
8
- export interface GcsReportingReadScopeV1 extends ReportingObjectWriteScopeV1 {
9
- /** Non-secret identity from the host's authenticated principal registry. Never a bearer. */
10
- principal_id: string;
11
- }
12
- /**
13
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
14
- */
15
- export interface GcsReportingReadAuthorizationV1 {
16
- scope: Readonly<GcsReportingReadScopeV1>;
17
- bucket: string;
18
- objectPrefix: string;
19
- objectName: string;
20
- }
21
- /**
22
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
23
- */
24
- export interface GcsReportingReaderOptionsV1 {
25
- scope: GcsReportingReadScopeV1;
26
- bucket: string;
27
- /** Exact saved destination prefix, including the trailing slash. */
28
- objectPrefix: string;
29
- /** Resolve an official client with keyless credentials for this operation. */
30
- getStorage(scope: Readonly<GcsReportingReadScopeV1>, context: {
31
- signal: AbortSignal;
32
- }): Promise<Storage>;
33
- /** Host verifies principal/account/destination ownership and the current grant generation. */
34
- authorize(request: Readonly<GcsReportingReadAuthorizationV1>, context: {
35
- signal: AbortSignal;
36
- }): Promise<boolean>;
37
- /** Optional operation lifetime, composed with each read deadline/caller signal. */
38
- signal?: AbortSignal;
39
- operationDeadlineMilliseconds?: number;
40
- maxBytes?: number;
41
- }
42
- /**
43
- * Restrictive provider-native URL grammar: no credentials, queries, encoding or traversal.
44
- *
45
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
46
- */
47
- export declare function gcsReportingObjectFromUriV1(uri: string, bucket: string, prefix: string): string;
48
- /**
49
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
50
- */
51
- export declare function createGcsScopedObjectReadV1(options: GcsReportingReaderOptionsV1): (uri: string, maxBytes: number, signal?: AbortSignal, nativeVersion?: string) => Promise<{
52
- body: Buffer<ArrayBufferLike>;
53
- contentType: string | undefined;
54
- generation: string;
55
- }>;
56
- /**
57
- * Destination-bound manifest/object reader. The caller never supplies bucket or credential scope.
58
- *
59
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
60
- */
61
- export declare function createGcsReportingResourceReaderV1(options: GcsReportingReaderOptionsV1): ReportingResourceReader;
62
- /**
63
- * Digest-pinned private contract resolver; all resolutions re-authorize and bypass caches.
64
- *
65
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
66
- */
67
- export declare function createGcsReportingReferenceResolverV1(options: GcsReportingReaderOptionsV1): CanonicalReferenceResolver;
@@ -1,67 +0,0 @@
1
- import type { Storage } from '@google-cloud/storage';
2
- import { type CanonicalReferenceResolver } from '../../canonical-references';
3
- import type { ReportingResourceReader } from '../inspection';
4
- import { type ReportingObjectWriteScopeV1 } from '../ledger/object-writes';
5
- /**
6
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
7
- */
8
- export interface GcsReportingReadScopeV1 extends ReportingObjectWriteScopeV1 {
9
- /** Non-secret identity from the host's authenticated principal registry. Never a bearer. */
10
- principal_id: string;
11
- }
12
- /**
13
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
14
- */
15
- export interface GcsReportingReadAuthorizationV1 {
16
- scope: Readonly<GcsReportingReadScopeV1>;
17
- bucket: string;
18
- objectPrefix: string;
19
- objectName: string;
20
- }
21
- /**
22
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
23
- */
24
- export interface GcsReportingReaderOptionsV1 {
25
- scope: GcsReportingReadScopeV1;
26
- bucket: string;
27
- /** Exact saved destination prefix, including the trailing slash. */
28
- objectPrefix: string;
29
- /** Resolve an official client with keyless credentials for this operation. */
30
- getStorage(scope: Readonly<GcsReportingReadScopeV1>, context: {
31
- signal: AbortSignal;
32
- }): Promise<Storage>;
33
- /** Host verifies principal/account/destination ownership and the current grant generation. */
34
- authorize(request: Readonly<GcsReportingReadAuthorizationV1>, context: {
35
- signal: AbortSignal;
36
- }): Promise<boolean>;
37
- /** Optional operation lifetime, composed with each read deadline/caller signal. */
38
- signal?: AbortSignal;
39
- operationDeadlineMilliseconds?: number;
40
- maxBytes?: number;
41
- }
42
- /**
43
- * Restrictive provider-native URL grammar: no credentials, queries, encoding or traversal.
44
- *
45
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
46
- */
47
- export declare function gcsReportingObjectFromUriV1(uri: string, bucket: string, prefix: string): string;
48
- /**
49
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
50
- */
51
- export declare function createGcsScopedObjectReadV1(options: GcsReportingReaderOptionsV1): (uri: string, maxBytes: number, signal?: AbortSignal, nativeVersion?: string) => Promise<{
52
- body: Buffer<ArrayBufferLike>;
53
- contentType: string | undefined;
54
- generation: string;
55
- }>;
56
- /**
57
- * Destination-bound manifest/object reader. The caller never supplies bucket or credential scope.
58
- *
59
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
60
- */
61
- export declare function createGcsReportingResourceReaderV1(options: GcsReportingReaderOptionsV1): ReportingResourceReader;
62
- /**
63
- * Digest-pinned private contract resolver; all resolutions re-authorize and bypass caches.
64
- *
65
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
66
- */
67
- export declare function createGcsReportingReferenceResolverV1(options: GcsReportingReaderOptionsV1): CanonicalReferenceResolver;
@@ -1,193 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var reader_exports = {};
20
- __export(reader_exports, {
21
- createGcsReportingReferenceResolverV1: () => createGcsReportingReferenceResolverV1,
22
- createGcsReportingResourceReaderV1: () => createGcsReportingResourceReaderV1,
23
- createGcsScopedObjectReadV1: () => createGcsScopedObjectReadV1,
24
- gcsReportingObjectFromUriV1: () => gcsReportingObjectFromUriV1
25
- });
26
- module.exports = __toCommonJS(reader_exports);
27
- var import_canonical_references = require('../../canonical-references/index.js');
28
- var import_object_writes = require('../ledger/object-writes.js');
29
- var import_errors = require('./errors.js');
30
- var import_io = require('./io.js');
31
- function gcsReportingObjectFromUriV1(uri, bucket, prefix) {
32
- if (typeof uri !== "string" || uri.length > 2048) throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
33
- const expectedBase = `https://storage.googleapis.com/${bucket}/`;
34
- let parsed;
35
- try {
36
- parsed = new URL(uri);
37
- } catch {
38
- throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
39
- }
40
- const name = uri.startsWith(expectedBase) ? uri.slice(expectedBase.length) : "";
41
- if (parsed.href !== uri || parsed.username || parsed.password || parsed.search || parsed.hash || !name.startsWith(prefix) || name.length <= prefix.length || name.length > 1024 || !/^[A-Za-z0-9/_.-]+$/.test(name) || name.split("/").some((part) => !part || part === "." || part === ".."))
42
- throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
43
- return name;
44
- }
45
- function createGcsScopedObjectReadV1(options) {
46
- let scope;
47
- try {
48
- scope = structuredClone(options.scope);
49
- (0, import_object_writes.assertReportingObjectWriteScope)(scope);
50
- } catch {
51
- throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
52
- }
53
- if (typeof scope.principal_id !== "string" || scope.principal_id.length < 1 || scope.principal_id.length > 255 || typeof options.bucket !== "string" || !/^[a-z0-9][a-z0-9.-]{1,220}[a-z0-9]$/.test(options.bucket) || typeof options.objectPrefix !== "string" || !/^[A-Za-z0-9/_.-]+\/$/.test(options.objectPrefix) || options.objectPrefix.length > 1e3 || options.objectPrefix.split("/").slice(0, -1).some((p) => !p || p === "." || p === "..") || typeof options.authorize !== "function" || typeof options.getStorage !== "function")
54
- throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
55
- Object.freeze(scope);
56
- const { bucket, objectPrefix, authorize, getStorage, signal: parentSignal } = options;
57
- if (parentSignal !== void 0 && !(parentSignal instanceof AbortSignal))
58
- throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
59
- const maximum = options.maxBytes ?? 64 * 1024 * 1024;
60
- const milliseconds = options.operationDeadlineMilliseconds ?? 6e4;
61
- if (!Number.isSafeInteger(maximum) || maximum < 1 || maximum > 64 * 1024 * 1024 || !Number.isSafeInteger(milliseconds) || milliseconds < 1 || milliseconds > 6e4)
62
- throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
63
- async function authorized(signal, objectName) {
64
- (0, import_io.activeGcsSignal)(signal);
65
- const allowed = await authorize({ scope, bucket, objectPrefix, objectName }, { signal });
66
- (0, import_io.activeGcsSignal)(signal);
67
- if (allowed !== true) throw new import_errors.ReportingGcsFenceError("REVOKED");
68
- }
69
- return async (uri, maxBytes, signal, nativeVersion) => (0, import_io.withGcsDeadline)(
70
- async (active) => {
71
- const name = gcsReportingObjectFromUriV1(uri, bucket, objectPrefix);
72
- if (!Number.isSafeInteger(maxBytes) || maxBytes < 1 || nativeVersion !== void 0 && !/^[1-9][0-9]{0,39}$/.test(nativeVersion))
73
- throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
74
- await authorized(active, name);
75
- const storage = await getStorage(scope, { signal: active });
76
- (0, import_io.activeGcsSignal)(active);
77
- try {
78
- const file = storage.bucket(bucket).file(name, nativeVersion ? { generation: nativeVersion } : void 0);
79
- const [metadata] = await file.getMetadata();
80
- (0, import_io.activeGcsSignal)(active);
81
- if (metadata.metadata?.adcp_reporting_tombstone !== void 0) throw new import_errors.ReportingGcsFenceError("REVOKED");
82
- const generation = String(metadata.generation);
83
- if (nativeVersion !== void 0 && generation !== nativeVersion)
84
- throw new import_errors.ReportingGcsFenceError("CONTENT_CONFLICT");
85
- if (!/^[1-9][0-9]{0,39}$/.test(generation) || !/^(?:0|[1-9][0-9]{0,19})$/.test(String(metadata.size)) || BigInt(String(metadata.size)) > BigInt(Math.min(maxBytes, maximum)))
86
- throw new import_errors.ReportingGcsFenceError("CONTENT_CONFLICT");
87
- const body = await (0, import_io.readGcsBytes)(
88
- storage.bucket(bucket).file(name, { generation }),
89
- Math.min(maxBytes, maximum),
90
- active
91
- );
92
- (0, import_io.activeGcsSignal)(active);
93
- await authorized(active, name);
94
- return { body, contentType: metadata.contentType, generation };
95
- } catch (error) {
96
- (0, import_io.activeGcsSignal)(active);
97
- if ((0, import_errors.isReportingGcsFenceError)(error)) throw error;
98
- await authorized(active, name);
99
- throw new import_errors.ReportingGcsFenceError("PROVIDER_UNAVAILABLE");
100
- }
101
- },
102
- {
103
- signal: parentSignal && signal ? AbortSignal.any([parentSignal, signal]) : parentSignal ?? signal,
104
- milliseconds
105
- }
106
- );
107
- }
108
- function createGcsReportingResourceReaderV1(options) {
109
- const read = createGcsScopedObjectReadV1(options);
110
- const scope = structuredClone(options.scope);
111
- const { bucket, objectPrefix } = options;
112
- return {
113
- async read(request) {
114
- if (!request?.context?.materialization?.resource || !["manifest", "object"].includes(request.role) || request.context.obligation?.account_id !== scope.account_id || request.location !== request.context.materialization.resource.location || request.context.materialization.destination_ref !== scope.destination_ref)
115
- throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
116
- let uri = request.location;
117
- if (request.role === "object") {
118
- if (typeof request.objectRef !== "string" || !/^[A-Za-z0-9_.-]+$/.test(request.objectRef) || request.objectRef === "." || request.objectRef === "..")
119
- throw new import_errors.ReportingGcsFenceError("INVALID_INPUT");
120
- const name = gcsReportingObjectFromUriV1(request.location, bucket, objectPrefix);
121
- uri = `https://storage.googleapis.com/${bucket}/${name.slice(0, name.lastIndexOf("/") + 1)}${request.objectRef}`;
122
- }
123
- return read(
124
- uri,
125
- request.maxBytes,
126
- request.signal,
127
- request.role === "manifest" ? request.context.materialization.resource?.native_version_ref : void 0
128
- );
129
- }
130
- };
131
- }
132
- function createGcsReportingReferenceResolverV1(options) {
133
- const read = createGcsScopedObjectReadV1(options);
134
- const documentReader = {
135
- async read(request) {
136
- try {
137
- return await read(request.uri, request.maxBytes, request.signal);
138
- } catch (error) {
139
- if ((0, import_errors.isReportingGcsFenceError)(error)) {
140
- if (error.code === "ABORTED") throw new import_canonical_references.CanonicalDocumentReadError("aborted");
141
- if (error.code === "INVALID_INPUT") throw new import_canonical_references.CanonicalDocumentReadError("unsafe_url");
142
- if (error.code === "REVOKED") throw new import_canonical_references.CanonicalDocumentReadError("access_denied");
143
- if (error.code === "CONTENT_CONFLICT") throw new import_canonical_references.CanonicalDocumentReadError("body_too_large");
144
- }
145
- throw new import_canonical_references.CanonicalDocumentReadError("network_error");
146
- }
147
- }
148
- };
149
- const parentSignal = options.signal;
150
- const resolver = (0, import_canonical_references.createCanonicalReferenceResolver)({ documentReader, signal: parentSignal });
151
- const routing = { bucket: options.bucket, objectPrefix: options.objectPrefix };
152
- const forced = (input) => ({
153
- ...input,
154
- documentReader,
155
- signal: parentSignal && input?.signal ? AbortSignal.any([parentSignal, input.signal]) : parentSignal ?? input?.signal
156
- });
157
- function blocked(ref, kind) {
158
- try {
159
- gcsReportingObjectFromUriV1(ref.uri, routing.bucket, routing.objectPrefix);
160
- return void 0;
161
- } catch {
162
- return {
163
- ok: false,
164
- status: "blocked_unsafe_url",
165
- kind,
166
- ref: {
167
- uri: "https://storage.googleapis.com/redacted-invalid-reference",
168
- digest: /^sha256:[a-f0-9]{64}$/.test(ref?.digest) ? ref.digest : "invalid"
169
- },
170
- cacheKey: "private-reference-refused",
171
- fromCache: false,
172
- error: {
173
- code: "unsafe_url",
174
- message: "Private reference is outside the saved destination scope",
175
- retryable: false
176
- }
177
- };
178
- }
179
- }
180
- return {
181
- cache: resolver.cache,
182
- resolve: async (ref, context) => blocked(ref, "generic") ?? resolver.resolve(ref, forced(context)),
183
- resolveFormatSchema: async (ref, context) => blocked(ref, "format_schema") ?? resolver.resolveFormatSchema(ref, forced(context)),
184
- resolvePlatformExtensions: async (ref, context) => blocked(ref, "platform_extensions") ?? resolver.resolvePlatformExtensions(ref, forced(context))
185
- };
186
- }
187
- // Annotate the CommonJS export names for ESM import in node:
188
- 0 && (module.exports = {
189
- createGcsReportingReferenceResolverV1,
190
- createGcsReportingResourceReaderV1,
191
- createGcsScopedObjectReadV1,
192
- gcsReportingObjectFromUriV1
193
- });