@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,340 +0,0 @@
1
- import { randomUUID } from "node:crypto";
2
- import {
3
- DeleteObjectCommand,
4
- GetBucketLifecycleConfigurationCommand,
5
- GetBucketPolicyStatusCommand,
6
- GetBucketVersioningCommand,
7
- GetObjectCommand,
8
- HeadBucketCommand,
9
- HeadObjectCommand,
10
- PutObjectCommand
11
- } from "@aws-sdk/client-s3";
12
- import { ReportingRowStoreError } from "../ledger/row-storage-errors.mjs";
13
- import {
14
- assertReportingRowLocationKeys,
15
- assertReportingRowReadBounds,
16
- readReportingRowStream,
17
- reportingRowClientMap,
18
- reportingRowPrefixFilterOverlaps,
19
- runReportingRowProviderOperation,
20
- selectReportingRowClient
21
- } from "../ledger/row-storage-provider-io.mjs";
22
- const BUCKET = /^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$/;
23
- const REGION = /^[a-z0-9][a-z0-9-]{0,30}[a-z0-9]$/;
24
- const VERSION_ID = /^[\x21\x23-\x7e]{1,1024}$/;
25
- function statusOf(error) {
26
- const status = Number(error?.$metadata?.httpStatusCode);
27
- return Number.isInteger(status) ? status : void 0;
28
- }
29
- function nameOf(error) {
30
- const value = error?.name ?? error?.Code;
31
- return typeof value === "string" ? value : "";
32
- }
33
- const isPreconditionFailed = (error) => statusOf(error) === 412 || nameOf(error) === "PreconditionFailed";
34
- const isConditionalConflict = (error) => statusOf(error) === 409 || nameOf(error) === "ConditionalRequestConflict";
35
- const isNotFound = (error) => statusOf(error) === 404 || ["NoSuchKey", "NotFound", "NoSuchVersion", "NoSuchBucket"].includes(nameOf(error));
36
- const isNotImplemented = (error) => statusOf(error) === 501 || nameOf(error) === "NotImplemented";
37
- const isForbidden = (error) => statusOf(error) === 401 || statusOf(error) === 403;
38
- const isRangeError = (error) => statusOf(error) === 416 || nameOf(error) === "InvalidRange";
39
- function versionOf(output) {
40
- const id = output.VersionId;
41
- if (typeof id !== "string" || id === "null" || !VERSION_ID.test(id)) {
42
- throw new ReportingRowStoreError(
43
- "UNSAFE_BINDING",
44
- "store returned no object VersionId; S3 bucket versioning must be enabled so deletes are fenced to one write"
45
- );
46
- }
47
- return id;
48
- }
49
- function selectorOf(nativeVersionRef) {
50
- if (typeof nativeVersionRef !== "string" || nativeVersionRef === "null") return null;
51
- return VERSION_ID.test(nativeVersionRef) ? { VersionId: nativeVersionRef } : null;
52
- }
53
- function servedVersion(output, selector) {
54
- return output.VersionId === selector.VersionId;
55
- }
56
- function liveExpirationCovers(rule, prefix) {
57
- if (rule.Status !== "Enabled") return false;
58
- if (rule.Expiration?.Days === void 0 && rule.Expiration?.Date === void 0) return false;
59
- if (rule.Filter?.Tag !== void 0 || (rule.Filter?.And?.Tags?.length ?? 0) > 0) return false;
60
- const filter = rule.Filter?.Prefix ?? rule.Filter?.And?.Prefix ?? rule.Prefix;
61
- return reportingRowPrefixFilterOverlaps(filter, prefix);
62
- }
63
- function createS3ReportingRowObjectProviderV1(options) {
64
- if (!options || typeof options !== "object") {
65
- throw new ReportingRowStoreError("INVALID_INPUT", "S3 row provider options are required");
66
- }
67
- const clients = reportingRowClientMap(options.clients);
68
- const isClient = (value) => !!value && typeof value === "object" && typeof value.send === "function";
69
- if (options.client !== void 0 && !isClient(options.client) || [...clients.values()].some((client) => !isClient(client)) || options.client === void 0 && clients.size === 0) {
70
- throw new ReportingRowStoreError("INVALID_INPUT", "inject an official S3Client as client or clients");
71
- }
72
- const validateLocation = (location) => {
73
- assertReportingRowLocationKeys(location, ["bucket"], ["region"]);
74
- const bucket = location.bucket;
75
- if (!BUCKET.test(bucket) || bucket.includes("..") || /^\d+\.\d+\.\d+\.\d+$/.test(bucket)) {
76
- throw new ReportingRowStoreError("INVALID_INPUT", "S3 bucket name is invalid");
77
- }
78
- if (location.region !== void 0 && !REGION.test(location.region)) {
79
- throw new ReportingRowStoreError("INVALID_INPUT", "S3 region is invalid");
80
- }
81
- };
82
- const target = (input) => {
83
- validateLocation(input.location);
84
- return {
85
- client: selectReportingRowClient(options.client, clients, input.credentialRef),
86
- Bucket: input.location.bucket
87
- };
88
- };
89
- const assertKey = (key) => {
90
- if (typeof key !== "string" || key.length === 0 || Buffer.byteLength(key) > 1024) {
91
- throw new ReportingRowStoreError("INVALID_INPUT", "object key is invalid");
92
- }
93
- };
94
- async function putCreateOnly(client, params, signal) {
95
- for (let attempt = 0; ; attempt++) {
96
- try {
97
- return await client.send(new PutObjectCommand({ ...params, IfNoneMatch: "*" }), { abortSignal: signal });
98
- } catch (error) {
99
- if (attempt === 0 && isConditionalConflict(error) && !signal.aborted) continue;
100
- throw error;
101
- }
102
- }
103
- }
104
- async function assertVersioningEnabled(client, Bucket, signal) {
105
- let status;
106
- try {
107
- status = (await client.send(new GetBucketVersioningCommand({ Bucket }), { abortSignal: signal })).Status;
108
- } catch (error) {
109
- if (isForbidden(error) || isNotImplemented(error)) {
110
- throw new ReportingRowStoreError("UNSAFE_BINDING", "bucket versioning status cannot be verified");
111
- }
112
- throw error;
113
- }
114
- if (status !== "Enabled") {
115
- throw new ReportingRowStoreError(
116
- "UNSAFE_BINDING",
117
- "S3 bucket versioning must be enabled so row object deletes are fenced to one write"
118
- );
119
- }
120
- }
121
- async function assertCreateOnlyEnforced(client, Bucket, prefix, signal) {
122
- const Key = `${prefix}/.adcp-probe/${randomUUID()}`;
123
- const written = [];
124
- const put = async (body) => {
125
- const output = await putCreateOnly(
126
- client,
127
- { Bucket, Key, Body: Buffer.from(body), ContentType: "application/x-ndjson", CacheControl: "no-store" },
128
- signal
129
- );
130
- written.push(output);
131
- versionOf(output);
132
- };
133
- try {
134
- try {
135
- await put('{"probe":1}\n');
136
- } catch (error) {
137
- if (isNotImplemented(error) || isPreconditionFailed(error)) {
138
- throw new ReportingRowStoreError("UNSAFE_BINDING", "store does not support create-only writes");
139
- }
140
- throw error;
141
- }
142
- try {
143
- await put('{"probe":2}\n');
144
- } catch (error) {
145
- if (isPreconditionFailed(error)) return;
146
- if (isNotImplemented(error)) {
147
- throw new ReportingRowStoreError("UNSAFE_BINDING", "store does not support create-only writes");
148
- }
149
- throw error;
150
- }
151
- throw new ReportingRowStoreError("UNSAFE_BINDING", "store ignores If-None-Match and replaces objects");
152
- } finally {
153
- const versionIds = written.map((output) => output.VersionId).filter((id) => !!id);
154
- const deletes = versionIds.length > 0 ? versionIds.map((VersionId) => ({ VersionId })) : written.length ? [{}] : [];
155
- for (const selector of deletes) {
156
- if (signal.aborted) break;
157
- await client.send(new DeleteObjectCommand({ Bucket, Key, ...selector }), { abortSignal: signal }).catch(() => void 0);
158
- }
159
- }
160
- }
161
- return {
162
- name: "s3",
163
- rangedReads: true,
164
- validateLocation,
165
- probe(input, context) {
166
- return runReportingRowProviderOperation(context.signal, async () => {
167
- const { client, Bucket } = target(input);
168
- const signal = context.signal;
169
- try {
170
- await client.send(new HeadBucketCommand({ Bucket }), { abortSignal: signal });
171
- } catch (error) {
172
- if (isNotFound(error)) throw new ReportingRowStoreError("UNSAFE_BINDING", "bucket does not exist");
173
- if (isForbidden(error)) throw new ReportingRowStoreError("UNSAFE_BINDING", "bucket is not accessible");
174
- if (statusOf(error) === 301) {
175
- throw new ReportingRowStoreError("UNSAFE_BINDING", "bucket is in a different region");
176
- }
177
- throw error;
178
- }
179
- if (input.location.region !== void 0) {
180
- const configured = client.config?.region;
181
- const region = typeof configured === "function" ? await configured() : configured;
182
- if (region !== input.location.region) {
183
- throw new ReportingRowStoreError("UNSAFE_BINDING", "client region does not match the binding");
184
- }
185
- }
186
- const policy = await client.send(new GetBucketPolicyStatusCommand({ Bucket }), { abortSignal: signal }).catch(() => void 0);
187
- if (policy?.PolicyStatus?.IsPublic === true) {
188
- throw new ReportingRowStoreError("UNSAFE_BINDING", "bucket policy makes objects public");
189
- }
190
- let rules = [];
191
- try {
192
- const lifecycle = await client.send(new GetBucketLifecycleConfigurationCommand({ Bucket }), {
193
- abortSignal: signal
194
- });
195
- rules = lifecycle.Rules ?? [];
196
- } catch (error) {
197
- if (isForbidden(error)) {
198
- throw new ReportingRowStoreError("UNSAFE_BINDING", "bucket lifecycle cannot be read with this client");
199
- }
200
- if (!isNotFound(error) && !isNotImplemented(error) && nameOf(error) !== "NoSuchLifecycleConfiguration") {
201
- throw error;
202
- }
203
- }
204
- if (rules.some((rule) => liveExpirationCovers(rule, input.prefix))) {
205
- throw new ReportingRowStoreError("UNSAFE_BINDING", "a bucket lifecycle rule can expire live row objects");
206
- }
207
- await assertVersioningEnabled(client, Bucket, signal);
208
- await assertCreateOnlyEnforced(client, Bucket, input.prefix, signal);
209
- });
210
- },
211
- putIfAbsent(input, context) {
212
- return runReportingRowProviderOperation(context.signal, async () => {
213
- const { client, Bucket } = target(input);
214
- assertKey(input.objectRef);
215
- const bytes = Buffer.from(input.bytes);
216
- try {
217
- const output = await putCreateOnly(
218
- client,
219
- {
220
- Bucket,
221
- Key: input.objectRef,
222
- Body: bytes,
223
- ContentLength: bytes.byteLength,
224
- ContentType: input.contentType,
225
- CacheControl: "no-store",
226
- Metadata: { ...input.metadata }
227
- },
228
- context.signal
229
- );
230
- return { created: true, nativeVersionRef: versionOf(output) };
231
- } catch (error) {
232
- if (!isPreconditionFailed(error)) throw error;
233
- }
234
- const head = await client.send(new HeadObjectCommand({ Bucket, Key: input.objectRef }), {
235
- abortSignal: context.signal
236
- });
237
- return { created: false, nativeVersionRef: versionOf(head) };
238
- });
239
- },
240
- get(input, context) {
241
- return runReportingRowProviderOperation(context.signal, async () => {
242
- const { client, Bucket } = target(input);
243
- assertKey(input.objectRef);
244
- assertReportingRowReadBounds(input);
245
- const selector = selectorOf(input.nativeVersionRef);
246
- if (selector === null) return null;
247
- const Key = input.objectRef;
248
- try {
249
- if (input.range?.length === 0) {
250
- const head = await client.send(new HeadObjectCommand({ Bucket, Key, ...selector }), {
251
- abortSignal: context.signal
252
- });
253
- if (!servedVersion(head, selector)) return null;
254
- if (input.range.offset > Number(head.ContentLength ?? 0)) {
255
- throw new ReportingRowStoreError("ROWS_INTEGRITY_FAILED", "requested range exceeds the stored object");
256
- }
257
- return Buffer.alloc(0);
258
- }
259
- const output = await client.send(
260
- new GetObjectCommand({
261
- Bucket,
262
- Key,
263
- ...selector,
264
- ...input.range ? { Range: `bytes=${input.range.offset}-${input.range.offset + input.range.length - 1}` } : {}
265
- }),
266
- { abortSignal: context.signal }
267
- );
268
- const body = output.Body;
269
- if (!body || typeof body[Symbol.asyncIterator] !== "function") {
270
- throw new ReportingRowStoreError("PROVIDER_UNAVAILABLE", "object body is not a stream");
271
- }
272
- if (!servedVersion(output, selector)) {
273
- body.destroy?.();
274
- return null;
275
- }
276
- if (typeof output.ContentLength === "number" && output.ContentLength > input.maxBytes) {
277
- body.destroy?.();
278
- throw new ReportingRowStoreError("ROWS_INTEGRITY_FAILED", "stored object exceeds its recorded size");
279
- }
280
- return await readReportingRowStream(body, input.maxBytes, context.signal);
281
- } catch (error) {
282
- if (isNotFound(error) || isPreconditionFailed(error)) return null;
283
- if (statusOf(error) === 400 && nameOf(error) !== "InvalidRange") return null;
284
- if (isRangeError(error)) {
285
- throw new ReportingRowStoreError("ROWS_INTEGRITY_FAILED", "requested range exceeds the stored object");
286
- }
287
- throw error;
288
- }
289
- });
290
- },
291
- stat(input, context) {
292
- return runReportingRowProviderOperation(context.signal, async () => {
293
- const { client, Bucket } = target(input);
294
- assertKey(input.objectRef);
295
- const selector = selectorOf(input.nativeVersionRef);
296
- if (selector === null) return null;
297
- try {
298
- const head = await client.send(new HeadObjectCommand({ Bucket, Key: input.objectRef, ...selector }), {
299
- abortSignal: context.signal
300
- });
301
- if (!servedVersion(head, selector)) return null;
302
- const size = head.ContentLength;
303
- if (typeof size !== "number" || !Number.isSafeInteger(size) || size < 0) {
304
- throw new ReportingRowStoreError("PROVIDER_UNAVAILABLE", "object metadata is malformed");
305
- }
306
- return { nativeVersionRef: selector.VersionId, sizeBytes: size };
307
- } catch (error) {
308
- if (isNotFound(error) || isPreconditionFailed(error)) return null;
309
- if (statusOf(error) === 400 || statusOf(error) === 405) return null;
310
- throw error;
311
- }
312
- });
313
- },
314
- delete(input, context) {
315
- return runReportingRowProviderOperation(context.signal, async () => {
316
- const { client, Bucket } = target(input);
317
- assertKey(input.objectRef);
318
- const selector = selectorOf(input.nativeVersionRef);
319
- if (selector === null) return "absent";
320
- const Key = input.objectRef;
321
- const signal = context.signal;
322
- try {
323
- const head = await client.send(new HeadObjectCommand({ Bucket, Key, ...selector }), { abortSignal: signal });
324
- if (!servedVersion(head, selector)) return "absent";
325
- } catch (error) {
326
- if (isNotFound(error) || isPreconditionFailed(error)) return "absent";
327
- if (statusOf(error) === 400 || statusOf(error) === 405) return "absent";
328
- throw error;
329
- }
330
- await client.send(new DeleteObjectCommand({ Bucket, Key, VersionId: selector.VersionId }), {
331
- abortSignal: signal
332
- });
333
- return "deleted";
334
- });
335
- }
336
- };
337
- }
338
- export {
339
- createS3ReportingRowObjectProviderV1
340
- };
@@ -1,148 +0,0 @@
1
- import type { PostgresReportingLedgerStore } from '../ledger/index.mjs';
2
- /**
3
- * Period-aligned retention. Whole periods are retired once
4
- * `max(statusRetentionDays, recordRetentionDays)` has elapsed since both the
5
- * period end and its latest publication. `statusRetentionDays` always comes
6
- * from the service, so retention can never disagree with the commitment the
7
- * service advertises to buyers.
8
- *
9
- * @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
10
- */
11
- export interface ReportingRetentionOptionsV1 {
12
- enabled: true;
13
- recordRetentionDays?: number;
14
- limit?: number;
15
- }
16
- /**
17
- * Opt-in compaction of superseded snapshot revisions to metadata only, as
18
- * adcontextprotocol/adcp#8100 permits. Off unless `enabled: true`. Uses the
19
- * service's `statusRetentionDays` and `automatedRecoveryWindowSeconds`, so it
20
- * can never drop content earlier than the commitments advertised to buyers.
21
- *
22
- * Compaction takes effect in the AdCP release after November 20, 2026; do not
23
- * enable it in production before then. See `docs/guides/REPORTING-OPERATIONS.md`.
24
- *
25
- * @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
26
- */
27
- export interface ReportingCompactionOptionsV1 {
28
- enabled: true;
29
- /** Revisions compacted per pass. Defaults to 100. */
30
- limit?: number;
31
- }
32
- /**
33
- * Change-feed pruning window and the consumer hold shared with retention.
34
- *
35
- * @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
36
- */
37
- export type ReportingChangeFeedMaintenanceOptionsV1 = boolean | {
38
- changeRetentionDays?: number;
39
- maxFeedHoldDays?: number;
40
- };
41
- /**
42
- * The ledger-store surface a maintenance pass drives.
43
- *
44
- * @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
45
- */
46
- export type ReportingLedgerMaintenanceStoreV1 = Pick<PostgresReportingLedgerStore, 'sweepRowWriteIntents' | 'pruneChanges' | 'retireExpiredPeriods'> & Partial<Pick<PostgresReportingLedgerStore, 'compactSupersededSnapshots'>>;
47
- interface ReportingLedgerMaintenanceTaskOutcomesV1 {
48
- 'snapshot sweep': Awaited<ReturnType<PostgresReportingLedgerStore['sweepExpiredState']>>;
49
- 'row upload sweep': Awaited<ReturnType<PostgresReportingLedgerStore['sweepRowWriteIntents']>>;
50
- 'change-feed pruning': Awaited<ReturnType<PostgresReportingLedgerStore['pruneChanges']>>;
51
- retention: Awaited<ReturnType<PostgresReportingLedgerStore['retireExpiredPeriods']>>;
52
- 'snapshot compaction': Awaited<ReturnType<PostgresReportingLedgerStore['compactSupersededSnapshots']>>;
53
- }
54
- /**
55
- * @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
56
- */
57
- export type ReportingLedgerMaintenanceTaskNameV1 = keyof ReportingLedgerMaintenanceTaskOutcomesV1;
58
- /**
59
- * A scheduled maintenance pass completed but could not process some items
60
- * (for example, a retention period whose objects could not be deleted). The
61
- * pass resumes them next time; repeated reports need operator attention.
62
- *
63
- * @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
64
- */
65
- export declare class ReportingMaintenancePartialFailureError extends Error {
66
- readonly task: string;
67
- readonly failedCount: number;
68
- readonly failedIds: readonly string[];
69
- /**
70
- * Backlog the task is not reaching: items backing off, items this host cannot
71
- * handle, items that have failed persistently. Appended to the message so
72
- * `onError` and the logs carry them.
73
- */
74
- readonly warnings: readonly string[];
75
- constructor(task: string, failedCount: number, failedIds: readonly string[],
76
- /**
77
- * Backlog the task is not reaching: items backing off, items this host cannot
78
- * handle, items that have failed persistently. Appended to the message so
79
- * `onError` and the logs carry them.
80
- */
81
- warnings?: readonly string[]);
82
- }
83
- /**
84
- * Outcome of one maintenance task. A task that resolved but could not process
85
- * some items (a retention period whose objects would not delete, an upload that
86
- * would not sweep) is `completed` with `partialFailure` set; the pass resumes
87
- * those items next time.
88
- *
89
- * @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
90
- */
91
- export type ReportingLedgerMaintenanceTaskResultV1 = {
92
- [Task in ReportingLedgerMaintenanceTaskNameV1]: {
93
- readonly task: Task;
94
- readonly status: 'completed';
95
- readonly result: ReportingLedgerMaintenanceTaskOutcomesV1[Task];
96
- readonly partialFailure?: ReportingMaintenancePartialFailureError;
97
- } | {
98
- readonly task: Task;
99
- readonly status: 'failed';
100
- readonly error: unknown;
101
- };
102
- }[ReportingLedgerMaintenanceTaskNameV1];
103
- /**
104
- * @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
105
- */
106
- export interface RunReportingLedgerMaintenanceInputV1 {
107
- store: ReportingLedgerMaintenanceStoreV1;
108
- /**
109
- * Expired cursor snapshot and checkpoint sweep. Omitted when the caller has
110
- * no way to reach the database, in which case that task is not run.
111
- */
112
- sweepSnapshots?: (limit: number) => Promise<ReportingLedgerMaintenanceTaskOutcomesV1['snapshot sweep']>;
113
- statusRetentionDays: number;
114
- /** The service's advertised `automated_recovery_window_seconds`; required when `compaction` is enabled. */
115
- automatedRecoveryWindowSeconds?: number | undefined;
116
- retention?: ReportingRetentionOptionsV1 | undefined;
117
- compaction?: ReportingCompactionOptionsV1 | undefined;
118
- changeFeed?: ReportingChangeFeedMaintenanceOptionsV1 | undefined;
119
- signal?: AbortSignal | undefined;
120
- /**
121
- * Called, in task order and awaited, for every task that rejected or
122
- * partially failed, unless `signal` has aborted (an abort is shutdown, not a
123
- * fault).
124
- */
125
- report?: (error: unknown) => Promise<void>;
126
- }
127
- /**
128
- * The single ledger-maintenance pass shared by the Core service and the
129
- * production service, so partial-failure surfacing, the `maxFeedHoldDays` that
130
- * retention honours, per-task limits and abort handling cannot drift between
131
- * them. Tasks start together, in a fixed order, and are isolated: one task's
132
- * failure never prevents another from running.
133
- *
134
- * @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
135
- */
136
- export declare function runReportingLedgerMaintenance(input: RunReportingLedgerMaintenanceInputV1): Promise<ReportingLedgerMaintenanceTaskResultV1[]>;
137
- /**
138
- * Fail fast on maintenance options the store would otherwise reject on every
139
- * pass. Mirrors the checks `retireExpiredPeriods` and `pruneChanges` apply.
140
- *
141
- * @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
142
- */
143
- export declare function assertReportingLedgerMaintenanceOptions(input: {
144
- retention?: ReportingRetentionOptionsV1 | undefined;
145
- compaction?: ReportingCompactionOptionsV1 | undefined;
146
- changeFeed?: ReportingChangeFeedMaintenanceOptionsV1 | undefined;
147
- }, statusRetentionDays: number): void;
148
- export {};
@@ -1,148 +0,0 @@
1
- import type { PostgresReportingLedgerStore } from '../ledger';
2
- /**
3
- * Period-aligned retention. Whole periods are retired once
4
- * `max(statusRetentionDays, recordRetentionDays)` has elapsed since both the
5
- * period end and its latest publication. `statusRetentionDays` always comes
6
- * from the service, so retention can never disagree with the commitment the
7
- * service advertises to buyers.
8
- *
9
- * @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
10
- */
11
- export interface ReportingRetentionOptionsV1 {
12
- enabled: true;
13
- recordRetentionDays?: number;
14
- limit?: number;
15
- }
16
- /**
17
- * Opt-in compaction of superseded snapshot revisions to metadata only, as
18
- * adcontextprotocol/adcp#8100 permits. Off unless `enabled: true`. Uses the
19
- * service's `statusRetentionDays` and `automatedRecoveryWindowSeconds`, so it
20
- * can never drop content earlier than the commitments advertised to buyers.
21
- *
22
- * Compaction takes effect in the AdCP release after November 20, 2026; do not
23
- * enable it in production before then. See `docs/guides/REPORTING-OPERATIONS.md`.
24
- *
25
- * @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
26
- */
27
- export interface ReportingCompactionOptionsV1 {
28
- enabled: true;
29
- /** Revisions compacted per pass. Defaults to 100. */
30
- limit?: number;
31
- }
32
- /**
33
- * Change-feed pruning window and the consumer hold shared with retention.
34
- *
35
- * @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
36
- */
37
- export type ReportingChangeFeedMaintenanceOptionsV1 = boolean | {
38
- changeRetentionDays?: number;
39
- maxFeedHoldDays?: number;
40
- };
41
- /**
42
- * The ledger-store surface a maintenance pass drives.
43
- *
44
- * @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
45
- */
46
- export type ReportingLedgerMaintenanceStoreV1 = Pick<PostgresReportingLedgerStore, 'sweepRowWriteIntents' | 'pruneChanges' | 'retireExpiredPeriods'> & Partial<Pick<PostgresReportingLedgerStore, 'compactSupersededSnapshots'>>;
47
- interface ReportingLedgerMaintenanceTaskOutcomesV1 {
48
- 'snapshot sweep': Awaited<ReturnType<PostgresReportingLedgerStore['sweepExpiredState']>>;
49
- 'row upload sweep': Awaited<ReturnType<PostgresReportingLedgerStore['sweepRowWriteIntents']>>;
50
- 'change-feed pruning': Awaited<ReturnType<PostgresReportingLedgerStore['pruneChanges']>>;
51
- retention: Awaited<ReturnType<PostgresReportingLedgerStore['retireExpiredPeriods']>>;
52
- 'snapshot compaction': Awaited<ReturnType<PostgresReportingLedgerStore['compactSupersededSnapshots']>>;
53
- }
54
- /**
55
- * @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
56
- */
57
- export type ReportingLedgerMaintenanceTaskNameV1 = keyof ReportingLedgerMaintenanceTaskOutcomesV1;
58
- /**
59
- * A scheduled maintenance pass completed but could not process some items
60
- * (for example, a retention period whose objects could not be deleted). The
61
- * pass resumes them next time; repeated reports need operator attention.
62
- *
63
- * @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
64
- */
65
- export declare class ReportingMaintenancePartialFailureError extends Error {
66
- readonly task: string;
67
- readonly failedCount: number;
68
- readonly failedIds: readonly string[];
69
- /**
70
- * Backlog the task is not reaching: items backing off, items this host cannot
71
- * handle, items that have failed persistently. Appended to the message so
72
- * `onError` and the logs carry them.
73
- */
74
- readonly warnings: readonly string[];
75
- constructor(task: string, failedCount: number, failedIds: readonly string[],
76
- /**
77
- * Backlog the task is not reaching: items backing off, items this host cannot
78
- * handle, items that have failed persistently. Appended to the message so
79
- * `onError` and the logs carry them.
80
- */
81
- warnings?: readonly string[]);
82
- }
83
- /**
84
- * Outcome of one maintenance task. A task that resolved but could not process
85
- * some items (a retention period whose objects would not delete, an upload that
86
- * would not sweep) is `completed` with `partialFailure` set; the pass resumes
87
- * those items next time.
88
- *
89
- * @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
90
- */
91
- export type ReportingLedgerMaintenanceTaskResultV1 = {
92
- [Task in ReportingLedgerMaintenanceTaskNameV1]: {
93
- readonly task: Task;
94
- readonly status: 'completed';
95
- readonly result: ReportingLedgerMaintenanceTaskOutcomesV1[Task];
96
- readonly partialFailure?: ReportingMaintenancePartialFailureError;
97
- } | {
98
- readonly task: Task;
99
- readonly status: 'failed';
100
- readonly error: unknown;
101
- };
102
- }[ReportingLedgerMaintenanceTaskNameV1];
103
- /**
104
- * @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
105
- */
106
- export interface RunReportingLedgerMaintenanceInputV1 {
107
- store: ReportingLedgerMaintenanceStoreV1;
108
- /**
109
- * Expired cursor snapshot and checkpoint sweep. Omitted when the caller has
110
- * no way to reach the database, in which case that task is not run.
111
- */
112
- sweepSnapshots?: (limit: number) => Promise<ReportingLedgerMaintenanceTaskOutcomesV1['snapshot sweep']>;
113
- statusRetentionDays: number;
114
- /** The service's advertised `automated_recovery_window_seconds`; required when `compaction` is enabled. */
115
- automatedRecoveryWindowSeconds?: number | undefined;
116
- retention?: ReportingRetentionOptionsV1 | undefined;
117
- compaction?: ReportingCompactionOptionsV1 | undefined;
118
- changeFeed?: ReportingChangeFeedMaintenanceOptionsV1 | undefined;
119
- signal?: AbortSignal | undefined;
120
- /**
121
- * Called, in task order and awaited, for every task that rejected or
122
- * partially failed, unless `signal` has aborted (an abort is shutdown, not a
123
- * fault).
124
- */
125
- report?: (error: unknown) => Promise<void>;
126
- }
127
- /**
128
- * The single ledger-maintenance pass shared by the Core service and the
129
- * production service, so partial-failure surfacing, the `maxFeedHoldDays` that
130
- * retention honours, per-task limits and abort handling cannot drift between
131
- * them. Tasks start together, in a fixed order, and are isolated: one task's
132
- * failure never prevents another from running.
133
- *
134
- * @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
135
- */
136
- export declare function runReportingLedgerMaintenance(input: RunReportingLedgerMaintenanceInputV1): Promise<ReportingLedgerMaintenanceTaskResultV1[]>;
137
- /**
138
- * Fail fast on maintenance options the store would otherwise reject on every
139
- * pass. Mirrors the checks `retireExpiredPeriods` and `pruneChanges` apply.
140
- *
141
- * @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
142
- */
143
- export declare function assertReportingLedgerMaintenanceOptions(input: {
144
- retention?: ReportingRetentionOptionsV1 | undefined;
145
- compaction?: ReportingCompactionOptionsV1 | undefined;
146
- changeFeed?: ReportingChangeFeedMaintenanceOptionsV1 | undefined;
147
- }, statusRetentionDays: number): void;
148
- export {};