@adcp/sdk 16.0.0-beta.3 → 16.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/auth/oauth/diagnose.js +3 -11
- package/dist/lib/auth/oauth/diagnose.mjs +4 -12
- package/dist/lib/auth/oauth/diagnostics.d.mts +2 -1
- package/dist/lib/auth/oauth/diagnostics.d.ts +2 -1
- package/dist/lib/auth/oauth/diagnostics.js +8 -10
- package/dist/lib/auth/oauth/diagnostics.mjs +7 -10
- package/dist/lib/index.d.mts +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +2 -0
- package/dist/lib/index.mjs +7 -1
- package/dist/lib/reporting/consumer-runtime.js +2 -1
- package/dist/lib/reporting/consumer-runtime.mjs +2 -1
- package/dist/lib/reporting/ledger/handler.js +50 -11
- package/dist/lib/reporting/ledger/handler.mjs +50 -12
- package/dist/lib/reporting/ledger/index.d.mts +17 -14
- package/dist/lib/reporting/ledger/index.d.ts +17 -14
- package/dist/lib/reporting/ledger/index.js +32 -20
- package/dist/lib/reporting/ledger/index.mjs +21 -10
- package/dist/lib/reporting/ledger/offering-validation.d.mts +9 -0
- package/dist/lib/reporting/ledger/offering-validation.d.ts +9 -0
- package/dist/lib/reporting/{gcs/bucket-policy.js → ledger/offering-validation.js} +9 -8
- package/dist/lib/reporting/ledger/offering-validation.mjs +8 -0
- package/dist/lib/reporting/ledger/receipts.d.mts +48 -0
- package/dist/lib/reporting/ledger/receipts.d.ts +48 -0
- package/dist/lib/reporting/ledger/receipts.js +186 -0
- package/dist/lib/reporting/ledger/receipts.mjs +161 -0
- package/dist/lib/reporting/ledger/status-ingest.js +3 -3
- package/dist/lib/reporting/ledger/status-ingest.mjs +4 -5
- package/dist/lib/reporting/ledger/types.d.mts +43 -0
- package/dist/lib/reporting/ledger/types.d.ts +43 -0
- package/dist/lib/reporting/ledger/types.js +31 -2
- package/dist/lib/reporting/ledger/types.mjs +26 -1
- package/dist/lib/reporting/pagination.d.mts +6 -0
- package/dist/lib/reporting/pagination.d.ts +6 -0
- package/dist/lib/reporting/{gcs/errors.js → pagination.js} +12 -17
- package/dist/lib/reporting/pagination.mjs +12 -0
- package/dist/lib/reporting/reconciliation.d.mts +1 -0
- package/dist/lib/reporting/reconciliation.d.ts +1 -0
- package/dist/lib/reporting/reconciliation.js +3 -2
- package/dist/lib/reporting/reconciliation.mjs +3 -2
- package/dist/lib/reporting/service/index.d.mts +79 -153
- package/dist/lib/reporting/service/index.d.ts +79 -153
- package/dist/lib/reporting/service/index.js +34 -491
- package/dist/lib/reporting/service/index.mjs +36 -510
- package/dist/lib/reporting/service/scheduler-support.d.mts +43 -0
- package/dist/lib/reporting/service/scheduler-support.d.ts +43 -0
- package/dist/lib/reporting/service/scheduler-support.js +125 -0
- package/dist/lib/reporting/service/scheduler-support.mjs +96 -0
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/signing/canonicalize.d.mts +4 -0
- package/dist/lib/signing/canonicalize.d.ts +4 -0
- package/dist/lib/signing/canonicalize.js +14 -8
- package/dist/lib/signing/canonicalize.mjs +14 -8
- package/dist/lib/signing/content-digest.d.mts +8 -0
- package/dist/lib/signing/content-digest.d.ts +8 -0
- package/dist/lib/signing/content-digest.js +11 -5
- package/dist/lib/signing/content-digest.mjs +10 -5
- package/dist/lib/signing/signer.js +9 -6
- package/dist/lib/signing/signer.mjs +10 -7
- package/dist/lib/signing/web-bot-auth.js +103 -37
- package/dist/lib/signing/web-bot-auth.mjs +108 -37
- package/dist/lib/testing/storyboard/junit.js +16 -3
- package/dist/lib/testing/storyboard/junit.mjs +16 -3
- package/dist/lib/testing/storyboard/request-signing/builder.js +10 -9
- package/dist/lib/testing/storyboard/request-signing/builder.mjs +10 -9
- package/dist/lib/testing/storyboard/runner.js +94 -25
- package/dist/lib/testing/storyboard/runner.mjs +94 -25
- package/dist/lib/testing/storyboard/types.d.mts +6 -0
- package/dist/lib/testing/storyboard/types.d.ts +6 -0
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/types/schemas.generated.d.ts +907 -60
- package/dist/lib/types/schemas.generated.js +7 -7
- package/dist/lib/types/schemas.generated.mjs +7 -7
- package/dist/lib/version.d.mts +3 -3
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.js +3 -3
- package/dist/lib/version.mjs +3 -3
- package/docs/TYPE-SUMMARY.md +23 -5
- package/docs/guides/REPORTING-GCS-FENCE.md +3 -3
- package/docs/guides/REPORTING-GCS-MANAGED.md +4 -4
- package/docs/guides/REPORTING-LEDGER-CUTOVER.md +7 -7
- package/docs/guides/REPORTING-LEDGER.md +107 -51
- package/docs/guides/REPORTING-OPERATIONS.md +66 -5
- package/docs/guides/REPORTING-STABILITY.md +36 -32
- package/docs/llms.txt +4 -3
- package/docs/migration-14.x-rc-worksheet.md +4 -7
- package/docs/migration-reporting-storage-package.md +186 -0
- package/examples/README.md +1 -1
- package/package.json +13 -78
- package/dist/lib/reporting/azure/index.d.mts +0 -31
- package/dist/lib/reporting/azure/index.d.ts +0 -31
- package/dist/lib/reporting/azure/index.js +0 -266
- package/dist/lib/reporting/azure/index.mjs +0 -249
- package/dist/lib/reporting/bigquery/index.d.mts +0 -246
- package/dist/lib/reporting/bigquery/index.d.ts +0 -246
- package/dist/lib/reporting/bigquery/index.js +0 -633
- package/dist/lib/reporting/bigquery/index.mjs +0 -594
- package/dist/lib/reporting/gcs/adapter.d.mts +0 -38
- package/dist/lib/reporting/gcs/adapter.d.ts +0 -38
- package/dist/lib/reporting/gcs/adapter.js +0 -342
- package/dist/lib/reporting/gcs/adapter.mjs +0 -325
- package/dist/lib/reporting/gcs/bucket-policy.d.mts +0 -3
- package/dist/lib/reporting/gcs/bucket-policy.d.ts +0 -3
- package/dist/lib/reporting/gcs/bucket-policy.mjs +0 -7
- package/dist/lib/reporting/gcs/errors.d.mts +0 -11
- package/dist/lib/reporting/gcs/errors.d.ts +0 -11
- package/dist/lib/reporting/gcs/errors.mjs +0 -16
- package/dist/lib/reporting/gcs/fence.d.mts +0 -41
- package/dist/lib/reporting/gcs/fence.d.ts +0 -41
- package/dist/lib/reporting/gcs/fence.js +0 -250
- package/dist/lib/reporting/gcs/fence.mjs +0 -230
- package/dist/lib/reporting/gcs/index.d.mts +0 -18
- package/dist/lib/reporting/gcs/index.d.ts +0 -18
- package/dist/lib/reporting/gcs/index.js +0 -44
- package/dist/lib/reporting/gcs/index.mjs +0 -14
- package/dist/lib/reporting/gcs/io.d.mts +0 -7
- package/dist/lib/reporting/gcs/io.d.ts +0 -7
- package/dist/lib/reporting/gcs/io.js +0 -95
- package/dist/lib/reporting/gcs/io.mjs +0 -69
- package/dist/lib/reporting/gcs/reader.d.mts +0 -67
- package/dist/lib/reporting/gcs/reader.d.ts +0 -67
- package/dist/lib/reporting/gcs/reader.js +0 -193
- package/dist/lib/reporting/gcs/reader.mjs +0 -169
- package/dist/lib/reporting/gcs/row-provider.d.mts +0 -39
- package/dist/lib/reporting/gcs/row-provider.d.ts +0 -39
- package/dist/lib/reporting/gcs/row-provider.js +0 -225
- package/dist/lib/reporting/gcs/row-provider.mjs +0 -208
- package/dist/lib/reporting/gcs/validation.d.mts +0 -5
- package/dist/lib/reporting/gcs/validation.d.ts +0 -5
- package/dist/lib/reporting/gcs/validation.js +0 -49
- package/dist/lib/reporting/gcs/validation.mjs +0 -25
- package/dist/lib/reporting/ledger/change-feed.d.mts +0 -69
- package/dist/lib/reporting/ledger/change-feed.d.ts +0 -69
- package/dist/lib/reporting/ledger/change-feed.js +0 -107
- package/dist/lib/reporting/ledger/change-feed.mjs +0 -80
- package/dist/lib/reporting/ledger/managed-postgres.d.mts +0 -293
- package/dist/lib/reporting/ledger/managed-postgres.d.ts +0 -293
- package/dist/lib/reporting/ledger/managed-postgres.js +0 -2346
- package/dist/lib/reporting/ledger/managed-postgres.mjs +0 -2332
- package/dist/lib/reporting/ledger/managed-router.d.mts +0 -148
- package/dist/lib/reporting/ledger/managed-router.d.ts +0 -148
- package/dist/lib/reporting/ledger/managed-router.js +0 -280
- package/dist/lib/reporting/ledger/managed-router.mjs +0 -258
- package/dist/lib/reporting/ledger/managed.d.mts +0 -535
- package/dist/lib/reporting/ledger/managed.d.ts +0 -535
- package/dist/lib/reporting/ledger/managed.js +0 -761
- package/dist/lib/reporting/ledger/managed.mjs +0 -729
- package/dist/lib/reporting/ledger/notification-activity.d.mts +0 -332
- package/dist/lib/reporting/ledger/notification-activity.d.ts +0 -332
- package/dist/lib/reporting/ledger/notification-activity.js +0 -1366
- package/dist/lib/reporting/ledger/notification-activity.mjs +0 -1337
- package/dist/lib/reporting/ledger/object-writes.d.mts +0 -128
- package/dist/lib/reporting/ledger/object-writes.d.ts +0 -128
- package/dist/lib/reporting/ledger/object-writes.js +0 -147
- package/dist/lib/reporting/ledger/object-writes.mjs +0 -114
- package/dist/lib/reporting/ledger/postgres.d.mts +0 -689
- package/dist/lib/reporting/ledger/postgres.d.ts +0 -689
- package/dist/lib/reporting/ledger/postgres.js +0 -4462
- package/dist/lib/reporting/ledger/postgres.mjs +0 -4462
- package/dist/lib/reporting/ledger/row-storage-migration.d.mts +0 -59
- package/dist/lib/reporting/ledger/row-storage-migration.d.ts +0 -59
- package/dist/lib/reporting/ledger/row-storage-migration.js +0 -365
- package/dist/lib/reporting/ledger/row-storage-migration.mjs +0 -339
- package/dist/lib/reporting/ledger/row-storage-object.d.mts +0 -203
- package/dist/lib/reporting/ledger/row-storage-object.d.ts +0 -203
- package/dist/lib/reporting/ledger/row-storage-object.js +0 -379
- package/dist/lib/reporting/ledger/row-storage-object.mjs +0 -335
- package/dist/lib/reporting/ledger/row-storage-provider-io.d.mts +0 -44
- package/dist/lib/reporting/ledger/row-storage-provider-io.d.ts +0 -44
- package/dist/lib/reporting/ledger/row-storage-provider-io.js +0 -142
- package/dist/lib/reporting/ledger/row-storage-provider-io.mjs +0 -111
- package/dist/lib/reporting/ledger/row-storage.d.mts +0 -316
- package/dist/lib/reporting/ledger/row-storage.d.ts +0 -316
- package/dist/lib/reporting/ledger/row-storage.js +0 -812
- package/dist/lib/reporting/ledger/row-storage.mjs +0 -802
- package/dist/lib/reporting/s3/index.d.mts +0 -34
- package/dist/lib/reporting/s3/index.d.ts +0 -34
- package/dist/lib/reporting/s3/index.js +0 -347
- package/dist/lib/reporting/s3/index.mjs +0 -340
- package/dist/lib/reporting/service/maintenance.d.mts +0 -148
- package/dist/lib/reporting/service/maintenance.d.ts +0 -148
- package/dist/lib/reporting/service/maintenance.js +0 -185
- package/dist/lib/reporting/service/maintenance.mjs +0 -159
- package/examples/reliable-reporting-service/README.md +0 -169
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { canonicalize } from "../../utils/jcs.mjs";
|
|
3
|
+
import { isReportingAdjustmentReceiptEvidence, isReportingReceiptEvidence } from "../evidence.mjs";
|
|
4
|
+
import { AdcpError } from "../../server/decisioning/async-outcome.mjs";
|
|
5
|
+
const MAX_RECEIPTS_PER_ARRAY = 100;
|
|
6
|
+
const MAX_RECEIPT_RESULTS = 100;
|
|
7
|
+
const MAX_RECEIPT_EVIDENCE_BYTES = 64 * 1024;
|
|
8
|
+
function createSyncReportingReceiptsHandler(store, resolveConsumerId, now = () => /* @__PURE__ */ new Date()) {
|
|
9
|
+
return async (request, context) => {
|
|
10
|
+
const account_id = resolvedAccountId(context.account);
|
|
11
|
+
const consumer_id = await resolveConsumerId(context);
|
|
12
|
+
if (!consumer_id || consumer_id.length > 255) {
|
|
13
|
+
throw new TypeError("resolveConsumerId must return a durable authenticated principal of at most 255 characters");
|
|
14
|
+
}
|
|
15
|
+
if (request.receipts !== void 0 && !Array.isArray(request.receipts)) {
|
|
16
|
+
throw new AdcpError("VALIDATION_ERROR", { message: "sync_reporting_receipts receipts must be an array" });
|
|
17
|
+
}
|
|
18
|
+
if (request.adjustment_receipts !== void 0 && !Array.isArray(request.adjustment_receipts)) {
|
|
19
|
+
throw new AdcpError("VALIDATION_ERROR", {
|
|
20
|
+
message: "sync_reporting_receipts adjustment_receipts must be an array"
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const revisionReceipts = request.receipts ?? [];
|
|
24
|
+
const adjustmentReceipts = request.adjustment_receipts ?? [];
|
|
25
|
+
if (!revisionReceipts.every(isRecord) || !adjustmentReceipts.every(isRecord)) {
|
|
26
|
+
throw new AdcpError("VALIDATION_ERROR", {
|
|
27
|
+
message: "sync_reporting_receipts entries must be objects"
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (revisionReceipts.length > MAX_RECEIPTS_PER_ARRAY || adjustmentReceipts.length > MAX_RECEIPTS_PER_ARRAY) {
|
|
31
|
+
throw new AdcpError("VALIDATION_ERROR", {
|
|
32
|
+
message: `sync_reporting_receipts accepts at most ${MAX_RECEIPTS_PER_ARRAY} receipts and ${MAX_RECEIPTS_PER_ARRAY} adjustment receipts per request`
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if ([...revisionReceipts, ...adjustmentReceipts].some((receipt) => "received_at" in receipt)) {
|
|
36
|
+
throw new AdcpError("VALIDATION_ERROR", {
|
|
37
|
+
message: "sync_reporting_receipts receipts must not carry received_at; it is assigned by the server"
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
const entries = [
|
|
41
|
+
...revisionReceipts.map((receipt) => ({ kind: "revision", receipt })),
|
|
42
|
+
...adjustmentReceipts.map((receipt) => ({
|
|
43
|
+
kind: "adjustment",
|
|
44
|
+
receipt
|
|
45
|
+
}))
|
|
46
|
+
];
|
|
47
|
+
if (entries.length > MAX_RECEIPT_RESULTS) {
|
|
48
|
+
throw new AdcpError("VALIDATION_ERROR", {
|
|
49
|
+
message: `sync_reporting_receipts can return at most ${MAX_RECEIPT_RESULTS} results, so a request may carry at most ${MAX_RECEIPT_RESULTS} receipts and adjustment receipts in total`
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (!entries.length) {
|
|
53
|
+
throw new AdcpError("VALIDATION_ERROR", {
|
|
54
|
+
message: "sync_reporting_receipts requires at least one receipt or adjustment receipt"
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (request.account && "account_id" in request.account && request.account.account_id !== account_id) {
|
|
58
|
+
return receiptBatchFailure(entries, "PERMISSION_DENIED", "Reporting receipt account is unavailable");
|
|
59
|
+
}
|
|
60
|
+
if (!/^[A-Za-z0-9_.:-]{16,255}$/.test(request.idempotency_key)) {
|
|
61
|
+
return receiptBatchFailure(entries, "VALIDATION_ERROR", "sync_reporting_receipts idempotency_key is invalid");
|
|
62
|
+
}
|
|
63
|
+
const submittedIds = entries.map(
|
|
64
|
+
(entry) => isRecord(entry.receipt) && typeof entry.receipt.reporting_receipt_id === "string" ? entry.receipt.reporting_receipt_id : ""
|
|
65
|
+
);
|
|
66
|
+
const duplicateSubmittedIds = new Set(
|
|
67
|
+
submittedIds.filter((value, index) => value !== "" && submittedIds.indexOf(value) !== index)
|
|
68
|
+
);
|
|
69
|
+
if (duplicateSubmittedIds.size) {
|
|
70
|
+
return receiptBatchFailure(
|
|
71
|
+
entries,
|
|
72
|
+
"VALIDATION_ERROR",
|
|
73
|
+
"sync_reporting_receipts receipt IDs must be unique across the batch"
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
const evidenceValid = entries.map(
|
|
77
|
+
(entry) => entry.kind === "revision" ? isReportingReceiptEvidence(entry.receipt) : isReportingAdjustmentReceiptEvidence(entry.receipt)
|
|
78
|
+
);
|
|
79
|
+
const oversized = entries.map(
|
|
80
|
+
(entry) => Buffer.byteLength(JSON.stringify(entry.receipt), "utf8") > MAX_RECEIPT_EVIDENCE_BYTES
|
|
81
|
+
);
|
|
82
|
+
const valid = entries.map((_, index) => evidenceValid[index] && !oversized[index]);
|
|
83
|
+
const validEntries = entries.filter((_, index) => valid[index]);
|
|
84
|
+
const request_fingerprint = sha256({ entries });
|
|
85
|
+
const stored = validEntries.length ? await store.syncReceiptBatch({
|
|
86
|
+
account_id,
|
|
87
|
+
consumer_id,
|
|
88
|
+
idempotency_key: request.idempotency_key,
|
|
89
|
+
request_fingerprint,
|
|
90
|
+
entries: validEntries,
|
|
91
|
+
received_at: now().toISOString()
|
|
92
|
+
}) : [];
|
|
93
|
+
let storedIndex = 0;
|
|
94
|
+
return {
|
|
95
|
+
status: "completed",
|
|
96
|
+
results: entries.map((entry, index) => {
|
|
97
|
+
if (valid[index]) return stored[storedIndex++];
|
|
98
|
+
const field = entry.kind === "revision" ? `receipts[${index}]` : `adjustment_receipts[${index - revisionReceipts.length}]`;
|
|
99
|
+
return oversized[index] ? receiptFailure(
|
|
100
|
+
reflectableReceiptId(entry.receipt.reporting_receipt_id, index),
|
|
101
|
+
"VALIDATION_ERROR",
|
|
102
|
+
"Reporting receipt evidence exceeds the 64 KiB limit",
|
|
103
|
+
{
|
|
104
|
+
field,
|
|
105
|
+
suggestion: `Reduce ${field} to 64 KiB or less and retry.`
|
|
106
|
+
}
|
|
107
|
+
) : receiptFailure(
|
|
108
|
+
reflectableReceiptId(entry.receipt.reporting_receipt_id, index),
|
|
109
|
+
"VALIDATION_ERROR",
|
|
110
|
+
"Reporting receipt evidence is malformed",
|
|
111
|
+
{
|
|
112
|
+
field,
|
|
113
|
+
suggestion: `Correct ${field} to satisfy the reporting receipt evidence schema and retry.`
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
})
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function receiptBatchFailure(entries, code, message) {
|
|
121
|
+
return {
|
|
122
|
+
status: "completed",
|
|
123
|
+
results: entries.map(
|
|
124
|
+
(entry, index) => receiptFailure(reflectableReceiptId(entry.receipt.reporting_receipt_id, index), code, message)
|
|
125
|
+
)
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
const RECEIPT_ID_PATTERN = /^[A-Za-z0-9_.:-]{16,255}$/;
|
|
129
|
+
function reflectableReceiptId(value, index) {
|
|
130
|
+
return typeof value === "string" && RECEIPT_ID_PATTERN.test(value) ? value : `unidentified-reporting-receipt-${String(index).padStart(3, "0")}`;
|
|
131
|
+
}
|
|
132
|
+
function receiptFailure(reporting_receipt_id, code, message, metadata = {}) {
|
|
133
|
+
return {
|
|
134
|
+
result: "failed",
|
|
135
|
+
reporting_receipt_id,
|
|
136
|
+
errors: [{ code, message, recovery: "correctable", ...metadata }]
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function resolvedAccountId(account) {
|
|
140
|
+
if (!account || typeof account !== "object") throw new Error("Reporting receipts require a resolved account");
|
|
141
|
+
const value = account;
|
|
142
|
+
const id = typeof value.id === "string" ? value.id : typeof value.account_id === "string" ? value.account_id : "";
|
|
143
|
+
if (!id) throw new Error("Reporting receipts require a resolved account");
|
|
144
|
+
return id;
|
|
145
|
+
}
|
|
146
|
+
function isRecord(value) {
|
|
147
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
148
|
+
}
|
|
149
|
+
function sha256(value) {
|
|
150
|
+
return createHash("sha256").update(canonicalize(value === void 0 ? null : value)).digest("hex");
|
|
151
|
+
}
|
|
152
|
+
function reportingManagedDeliveryBindingV1(input) {
|
|
153
|
+
const created_at = input.created_at ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
154
|
+
const { semantic_fingerprint: _predecessor, ...semantic } = input;
|
|
155
|
+
const semantic_fingerprint = sha256({ ...semantic, created_at: void 0 });
|
|
156
|
+
return { ...semantic, created_at, semantic_fingerprint };
|
|
157
|
+
}
|
|
158
|
+
export {
|
|
159
|
+
createSyncReportingReceiptsHandler,
|
|
160
|
+
reportingManagedDeliveryBindingV1
|
|
161
|
+
};
|
|
@@ -156,7 +156,7 @@ function createSyncReportingStatusHandler(store, options) {
|
|
|
156
156
|
});
|
|
157
157
|
if (replay) return completed(replay);
|
|
158
158
|
} catch (error) {
|
|
159
|
-
if (!(
|
|
159
|
+
if (!(0, import_types.isReportingLedgerErrorNamed)(error, "ReportingConsumerStatusConflictError")) throw error;
|
|
160
160
|
return failed(statusIds, "IDEMPOTENCY_CONFLICT", "Reporting status idempotency conflict");
|
|
161
161
|
}
|
|
162
162
|
const now = (options.now ?? (() => /* @__PURE__ */ new Date()))();
|
|
@@ -216,7 +216,7 @@ function createSyncReportingStatusHandler(store, options) {
|
|
|
216
216
|
});
|
|
217
217
|
return completed(results);
|
|
218
218
|
} catch (error) {
|
|
219
|
-
const conflict =
|
|
219
|
+
const conflict = (0, import_types.isReportingLedgerErrorNamed)(error, "ReportingConsumerStatusConflictError");
|
|
220
220
|
if (!conflict && !(error instanceof ReportingStatusValidationError)) throw error;
|
|
221
221
|
return failed(
|
|
222
222
|
statusIds,
|
|
@@ -277,7 +277,7 @@ async function validateStatus(store, configurations, accountId, consumerId, stat
|
|
|
277
277
|
try {
|
|
278
278
|
page = await store.readSnapshotPage(status.seller_ledger_snapshot_id, accountId, void 0, 1);
|
|
279
279
|
} catch (error) {
|
|
280
|
-
if (!(
|
|
280
|
+
if (!(0, import_types.isReportingLedgerErrorNamed)(error, "ReportingLedgerSnapshotUnavailableError")) throw error;
|
|
281
281
|
throw new ReportingStatusValidationError("snapshot provenance unavailable");
|
|
282
282
|
}
|
|
283
283
|
const scope = (0, import_coverage.reportingLedgerEffectivePeriod)(page.snapshot.query, page.snapshot.ledgerAsOf);
|
|
@@ -24,8 +24,7 @@ import {
|
|
|
24
24
|
import {
|
|
25
25
|
REPORTING_CONSUMER_STATUS_ERROR_FIELD_MAX_BYTES,
|
|
26
26
|
REPORTING_CONSUMER_STATUS_ERROR_MESSAGE_MAX_BYTES,
|
|
27
|
-
|
|
28
|
-
ReportingLedgerSnapshotUnavailableError
|
|
27
|
+
isReportingLedgerErrorNamed
|
|
29
28
|
} from "./types.mjs";
|
|
30
29
|
const statusId = z.string().min(16).max(255).regex(/^[A-Za-z0-9_.:-]+$/);
|
|
31
30
|
const INVALID_REPORTING_STATUS_ID = "invalid-reporting-status-id";
|
|
@@ -147,7 +146,7 @@ function createSyncReportingStatusHandler(store, options) {
|
|
|
147
146
|
});
|
|
148
147
|
if (replay) return completed(replay);
|
|
149
148
|
} catch (error) {
|
|
150
|
-
if (!(error
|
|
149
|
+
if (!isReportingLedgerErrorNamed(error, "ReportingConsumerStatusConflictError")) throw error;
|
|
151
150
|
return failed(statusIds, "IDEMPOTENCY_CONFLICT", "Reporting status idempotency conflict");
|
|
152
151
|
}
|
|
153
152
|
const now = (options.now ?? (() => /* @__PURE__ */ new Date()))();
|
|
@@ -207,7 +206,7 @@ function createSyncReportingStatusHandler(store, options) {
|
|
|
207
206
|
});
|
|
208
207
|
return completed(results);
|
|
209
208
|
} catch (error) {
|
|
210
|
-
const conflict = error
|
|
209
|
+
const conflict = isReportingLedgerErrorNamed(error, "ReportingConsumerStatusConflictError");
|
|
211
210
|
if (!conflict && !(error instanceof ReportingStatusValidationError)) throw error;
|
|
212
211
|
return failed(
|
|
213
212
|
statusIds,
|
|
@@ -268,7 +267,7 @@ async function validateStatus(store, configurations, accountId, consumerId, stat
|
|
|
268
267
|
try {
|
|
269
268
|
page = await store.readSnapshotPage(status.seller_ledger_snapshot_id, accountId, void 0, 1);
|
|
270
269
|
} catch (error) {
|
|
271
|
-
if (!(error
|
|
270
|
+
if (!isReportingLedgerErrorNamed(error, "ReportingLedgerSnapshotUnavailableError")) throw error;
|
|
272
271
|
throw new ReportingStatusValidationError("snapshot provenance unavailable");
|
|
273
272
|
}
|
|
274
273
|
const scope = reportingLedgerEffectivePeriod(page.snapshot.query, page.snapshot.ledgerAsOf);
|
|
@@ -722,6 +722,35 @@ export interface ReportingLedgerLeaseV1 {
|
|
|
722
722
|
generation: number;
|
|
723
723
|
expiresAt: string;
|
|
724
724
|
}
|
|
725
|
+
/**
|
|
726
|
+
* The writer's lease was lost before the commit completed.
|
|
727
|
+
*
|
|
728
|
+
* `ReportingLedgerLeaseLostError`, `ReportingLedgerPeriodRetiredError` and
|
|
729
|
+
* `ReportingLedgerContinuityError` are the errors every `ReportingLedgerStore` throws. The protocol
|
|
730
|
+
* layer recognizes them by `name`, so a store from another package (or another copy of the SDK) is
|
|
731
|
+
* understood as well as one built here. Store implementations should throw these classes.
|
|
732
|
+
*
|
|
733
|
+
* @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
|
|
734
|
+
*/
|
|
735
|
+
export declare class ReportingLedgerLeaseLostError extends Error {
|
|
736
|
+
constructor(message?: string);
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* A planner or writer named a period whose ledger records were retired by retention.
|
|
740
|
+
*
|
|
741
|
+
* @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
|
|
742
|
+
*/
|
|
743
|
+
export declare class ReportingLedgerPeriodRetiredError extends Error {
|
|
744
|
+
constructor(message?: string);
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* A revision continuity invariant failed (a gap or a fork in the revision chain).
|
|
748
|
+
*
|
|
749
|
+
* @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
|
|
750
|
+
*/
|
|
751
|
+
export declare class ReportingLedgerContinuityError extends Error {
|
|
752
|
+
constructor(message?: string);
|
|
753
|
+
}
|
|
725
754
|
export declare class ReportingLedgerSnapshotUnavailableError extends Error {
|
|
726
755
|
constructor();
|
|
727
756
|
}
|
|
@@ -732,10 +761,24 @@ export declare class ReportingConsumerStatusConflictError extends Error {
|
|
|
732
761
|
*/
|
|
733
762
|
constructor(message?: string);
|
|
734
763
|
}
|
|
764
|
+
/**
|
|
765
|
+
* Recognizes a store-contract error by its `name`, not its class. A host that loads the SDK once through
|
|
766
|
+
* `require` and once through `import` holds two copies of every class, and a store from another package can
|
|
767
|
+
* be built against either, so `instanceof` would miss an error the store legitimately threw.
|
|
768
|
+
*
|
|
769
|
+
* @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
|
|
770
|
+
*/
|
|
771
|
+
export declare function isReportingLedgerErrorNamed(error: unknown, name: 'ReportingLedgerSnapshotUnavailableError' | 'ReportingConsumerStatusConflictError' | 'ReportingLedgerIssueIntegrityError' | 'ReportingLedgerLeaseLostError' | 'ReportingLedgerPeriodRetiredError' | 'ReportingLedgerContinuityError'): boolean;
|
|
735
772
|
/**
|
|
736
773
|
* @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
|
|
737
774
|
*/
|
|
738
775
|
export interface ReportingLedgerStore {
|
|
776
|
+
/**
|
|
777
|
+
* Setup scripts the host applies before first use (SQL for a SQL store), in order and idempotent.
|
|
778
|
+
* `createReliableReportingService` surfaces them as `service.setup.migrations`. A store with nothing
|
|
779
|
+
* to install omits it.
|
|
780
|
+
*/
|
|
781
|
+
readonly migrations?: readonly string[];
|
|
739
782
|
/** Optional substrate identity for an add-on store that must prove shared authority. */
|
|
740
783
|
readonly [REPORTING_LEDGER_AUTHORITY]?: ReportingLedgerAuthorityV1;
|
|
741
784
|
/**
|
|
@@ -722,6 +722,35 @@ export interface ReportingLedgerLeaseV1 {
|
|
|
722
722
|
generation: number;
|
|
723
723
|
expiresAt: string;
|
|
724
724
|
}
|
|
725
|
+
/**
|
|
726
|
+
* The writer's lease was lost before the commit completed.
|
|
727
|
+
*
|
|
728
|
+
* `ReportingLedgerLeaseLostError`, `ReportingLedgerPeriodRetiredError` and
|
|
729
|
+
* `ReportingLedgerContinuityError` are the errors every `ReportingLedgerStore` throws. The protocol
|
|
730
|
+
* layer recognizes them by `name`, so a store from another package (or another copy of the SDK) is
|
|
731
|
+
* understood as well as one built here. Store implementations should throw these classes.
|
|
732
|
+
*
|
|
733
|
+
* @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
|
|
734
|
+
*/
|
|
735
|
+
export declare class ReportingLedgerLeaseLostError extends Error {
|
|
736
|
+
constructor(message?: string);
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* A planner or writer named a period whose ledger records were retired by retention.
|
|
740
|
+
*
|
|
741
|
+
* @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
|
|
742
|
+
*/
|
|
743
|
+
export declare class ReportingLedgerPeriodRetiredError extends Error {
|
|
744
|
+
constructor(message?: string);
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* A revision continuity invariant failed (a gap or a fork in the revision chain).
|
|
748
|
+
*
|
|
749
|
+
* @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
|
|
750
|
+
*/
|
|
751
|
+
export declare class ReportingLedgerContinuityError extends Error {
|
|
752
|
+
constructor(message?: string);
|
|
753
|
+
}
|
|
725
754
|
export declare class ReportingLedgerSnapshotUnavailableError extends Error {
|
|
726
755
|
constructor();
|
|
727
756
|
}
|
|
@@ -732,10 +761,24 @@ export declare class ReportingConsumerStatusConflictError extends Error {
|
|
|
732
761
|
*/
|
|
733
762
|
constructor(message?: string);
|
|
734
763
|
}
|
|
764
|
+
/**
|
|
765
|
+
* Recognizes a store-contract error by its `name`, not its class. A host that loads the SDK once through
|
|
766
|
+
* `require` and once through `import` holds two copies of every class, and a store from another package can
|
|
767
|
+
* be built against either, so `instanceof` would miss an error the store legitimately threw.
|
|
768
|
+
*
|
|
769
|
+
* @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
|
|
770
|
+
*/
|
|
771
|
+
export declare function isReportingLedgerErrorNamed(error: unknown, name: 'ReportingLedgerSnapshotUnavailableError' | 'ReportingConsumerStatusConflictError' | 'ReportingLedgerIssueIntegrityError' | 'ReportingLedgerLeaseLostError' | 'ReportingLedgerPeriodRetiredError' | 'ReportingLedgerContinuityError'): boolean;
|
|
735
772
|
/**
|
|
736
773
|
* @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
|
|
737
774
|
*/
|
|
738
775
|
export interface ReportingLedgerStore {
|
|
776
|
+
/**
|
|
777
|
+
* Setup scripts the host applies before first use (SQL for a SQL store), in order and idempotent.
|
|
778
|
+
* `createReliableReportingService` surfaces them as `service.setup.migrations`. A store with nothing
|
|
779
|
+
* to install omits it.
|
|
780
|
+
*/
|
|
781
|
+
readonly migrations?: readonly string[];
|
|
739
782
|
/** Optional substrate identity for an add-on store that must prove shared authority. */
|
|
740
783
|
readonly [REPORTING_LEDGER_AUTHORITY]?: ReportingLedgerAuthorityV1;
|
|
741
784
|
/**
|
|
@@ -25,7 +25,11 @@ __export(types_exports, {
|
|
|
25
25
|
REPORTING_CONSUMER_STATUS_MAX_BYTES: () => REPORTING_CONSUMER_STATUS_MAX_BYTES,
|
|
26
26
|
REPORTING_LEDGER_AUTHORITY: () => REPORTING_LEDGER_AUTHORITY,
|
|
27
27
|
ReportingConsumerStatusConflictError: () => ReportingConsumerStatusConflictError,
|
|
28
|
-
|
|
28
|
+
ReportingLedgerContinuityError: () => ReportingLedgerContinuityError,
|
|
29
|
+
ReportingLedgerLeaseLostError: () => ReportingLedgerLeaseLostError,
|
|
30
|
+
ReportingLedgerPeriodRetiredError: () => ReportingLedgerPeriodRetiredError,
|
|
31
|
+
ReportingLedgerSnapshotUnavailableError: () => ReportingLedgerSnapshotUnavailableError,
|
|
32
|
+
isReportingLedgerErrorNamed: () => isReportingLedgerErrorNamed
|
|
29
33
|
});
|
|
30
34
|
module.exports = __toCommonJS(types_exports);
|
|
31
35
|
const REPORTING_LEDGER_AUTHORITY = /* @__PURE__ */ Symbol.for("@adcp/sdk/reporting-ledger-authority");
|
|
@@ -34,6 +38,24 @@ const REPORTING_CONSUMER_STATUS_ERROR_MESSAGE_MAX_BYTES = 1024;
|
|
|
34
38
|
const REPORTING_CONSUMER_STATUS_MAX_BYTES = 64 * 1024;
|
|
35
39
|
const REPORTING_CONSUMER_STATUS_BATCH_MAX_BYTES = 8 * 1024 * 1024;
|
|
36
40
|
const REPORTING_CONSUMER_STATUS_BATCH_RESULT_MAX_BYTES = 64 * 1024;
|
|
41
|
+
class ReportingLedgerLeaseLostError extends Error {
|
|
42
|
+
constructor(message = "Reporting ledger lease was lost before commit") {
|
|
43
|
+
super(message);
|
|
44
|
+
this.name = "ReportingLedgerLeaseLostError";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
class ReportingLedgerPeriodRetiredError extends Error {
|
|
48
|
+
constructor(message = "Reporting obligation period was retired by retention") {
|
|
49
|
+
super(message);
|
|
50
|
+
this.name = "ReportingLedgerPeriodRetiredError";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
class ReportingLedgerContinuityError extends Error {
|
|
54
|
+
constructor(message = "Reporting ledger revision continuity invariant failed") {
|
|
55
|
+
super(message);
|
|
56
|
+
this.name = "ReportingLedgerContinuityError";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
37
59
|
class ReportingLedgerSnapshotUnavailableError extends Error {
|
|
38
60
|
constructor() {
|
|
39
61
|
super("Reporting ledger snapshot is unavailable");
|
|
@@ -50,6 +72,9 @@ class ReportingConsumerStatusConflictError extends Error {
|
|
|
50
72
|
this.name = "ReportingConsumerStatusConflictError";
|
|
51
73
|
}
|
|
52
74
|
}
|
|
75
|
+
function isReportingLedgerErrorNamed(error, name) {
|
|
76
|
+
return error instanceof Error && error.name === name;
|
|
77
|
+
}
|
|
53
78
|
// Annotate the CommonJS export names for ESM import in node:
|
|
54
79
|
0 && (module.exports = {
|
|
55
80
|
REPORTING_CONSUMER_STATUS_BATCH_MAX_BYTES,
|
|
@@ -59,5 +84,9 @@ class ReportingConsumerStatusConflictError extends Error {
|
|
|
59
84
|
REPORTING_CONSUMER_STATUS_MAX_BYTES,
|
|
60
85
|
REPORTING_LEDGER_AUTHORITY,
|
|
61
86
|
ReportingConsumerStatusConflictError,
|
|
62
|
-
|
|
87
|
+
ReportingLedgerContinuityError,
|
|
88
|
+
ReportingLedgerLeaseLostError,
|
|
89
|
+
ReportingLedgerPeriodRetiredError,
|
|
90
|
+
ReportingLedgerSnapshotUnavailableError,
|
|
91
|
+
isReportingLedgerErrorNamed
|
|
63
92
|
});
|
|
@@ -4,6 +4,24 @@ const REPORTING_CONSUMER_STATUS_ERROR_MESSAGE_MAX_BYTES = 1024;
|
|
|
4
4
|
const REPORTING_CONSUMER_STATUS_MAX_BYTES = 64 * 1024;
|
|
5
5
|
const REPORTING_CONSUMER_STATUS_BATCH_MAX_BYTES = 8 * 1024 * 1024;
|
|
6
6
|
const REPORTING_CONSUMER_STATUS_BATCH_RESULT_MAX_BYTES = 64 * 1024;
|
|
7
|
+
class ReportingLedgerLeaseLostError extends Error {
|
|
8
|
+
constructor(message = "Reporting ledger lease was lost before commit") {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = "ReportingLedgerLeaseLostError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
class ReportingLedgerPeriodRetiredError extends Error {
|
|
14
|
+
constructor(message = "Reporting obligation period was retired by retention") {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = "ReportingLedgerPeriodRetiredError";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
class ReportingLedgerContinuityError extends Error {
|
|
20
|
+
constructor(message = "Reporting ledger revision continuity invariant failed") {
|
|
21
|
+
super(message);
|
|
22
|
+
this.name = "ReportingLedgerContinuityError";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
7
25
|
class ReportingLedgerSnapshotUnavailableError extends Error {
|
|
8
26
|
constructor() {
|
|
9
27
|
super("Reporting ledger snapshot is unavailable");
|
|
@@ -20,6 +38,9 @@ class ReportingConsumerStatusConflictError extends Error {
|
|
|
20
38
|
this.name = "ReportingConsumerStatusConflictError";
|
|
21
39
|
}
|
|
22
40
|
}
|
|
41
|
+
function isReportingLedgerErrorNamed(error, name) {
|
|
42
|
+
return error instanceof Error && error.name === name;
|
|
43
|
+
}
|
|
23
44
|
export {
|
|
24
45
|
REPORTING_CONSUMER_STATUS_BATCH_MAX_BYTES,
|
|
25
46
|
REPORTING_CONSUMER_STATUS_BATCH_RESULT_MAX_BYTES,
|
|
@@ -28,5 +49,9 @@ export {
|
|
|
28
49
|
REPORTING_CONSUMER_STATUS_MAX_BYTES,
|
|
29
50
|
REPORTING_LEDGER_AUTHORITY,
|
|
30
51
|
ReportingConsumerStatusConflictError,
|
|
31
|
-
|
|
52
|
+
ReportingLedgerContinuityError,
|
|
53
|
+
ReportingLedgerLeaseLostError,
|
|
54
|
+
ReportingLedgerPeriodRetiredError,
|
|
55
|
+
ReportingLedgerSnapshotUnavailableError,
|
|
56
|
+
isReportingLedgerErrorNamed
|
|
32
57
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The largest `pagination.max_results` AdCP allows (`core/pagination-request.json`), read from the generated
|
|
3
|
+
* schema so a protocol change carries through. The reporting walkers ask for pages this large: a seller that
|
|
4
|
+
* validates the schema answers 50 rows when `max_results` is omitted.
|
|
5
|
+
*/
|
|
6
|
+
export declare function reportingMaxPageSize(): number;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The largest `pagination.max_results` AdCP allows (`core/pagination-request.json`), read from the generated
|
|
3
|
+
* schema so a protocol change carries through. The reporting walkers ask for pages this large: a seller that
|
|
4
|
+
* validates the schema answers 50 rows when `max_results` is omitted.
|
|
5
|
+
*/
|
|
6
|
+
export declare function reportingMaxPageSize(): number;
|
|
@@ -16,26 +16,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
22
|
-
isReportingGcsFenceError: () => isReportingGcsFenceError
|
|
19
|
+
var pagination_exports = {};
|
|
20
|
+
__export(pagination_exports, {
|
|
21
|
+
reportingMaxPageSize: () => reportingMaxPageSize
|
|
23
22
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
module.exports = __toCommonJS(pagination_exports);
|
|
24
|
+
var import_schemas = require('../types/schemas.generated.js');
|
|
25
|
+
function reportingMaxPageSize() {
|
|
26
|
+
const field = import_schemas.PaginationRequestSchema.shape.max_results;
|
|
27
|
+
const maximum = field.unwrap().maxValue;
|
|
28
|
+
if (maximum === null || !Number.isSafeInteger(maximum) || maximum < 1) {
|
|
29
|
+
throw new Error("The AdCP pagination-request schema does not define a maximum for max_results");
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
function isReportingGcsFenceError(error) {
|
|
35
|
-
return !!error && typeof error === "object" && error[/* @__PURE__ */ Symbol.for("adcp.reportingGcsFenceError")] === true;
|
|
31
|
+
return maximum;
|
|
36
32
|
}
|
|
37
33
|
// Annotate the CommonJS export names for ESM import in node:
|
|
38
34
|
0 && (module.exports = {
|
|
39
|
-
|
|
40
|
-
isReportingGcsFenceError
|
|
35
|
+
reportingMaxPageSize
|
|
41
36
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PaginationRequestSchema } from "../types/schemas.generated.mjs";
|
|
2
|
+
function reportingMaxPageSize() {
|
|
3
|
+
const field = PaginationRequestSchema.shape.max_results;
|
|
4
|
+
const maximum = field.unwrap().maxValue;
|
|
5
|
+
if (maximum === null || !Number.isSafeInteger(maximum) || maximum < 1) {
|
|
6
|
+
throw new Error("The AdCP pagination-request schema does not define a maximum for max_results");
|
|
7
|
+
}
|
|
8
|
+
return maximum;
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
reportingMaxPageSize
|
|
12
|
+
};
|
|
@@ -30,6 +30,7 @@ module.exports = __toCommonJS(reconciliation_exports);
|
|
|
30
30
|
var import_crypto = require("crypto");
|
|
31
31
|
var import_idempotency = require('../utils/idempotency.js');
|
|
32
32
|
var import_jcs = require('../utils/jcs.js');
|
|
33
|
+
var import_pagination = require('./pagination.js');
|
|
33
34
|
var import_content_mismatch = require('./content-mismatch.js');
|
|
34
35
|
var import_evidence = require('./evidence.js');
|
|
35
36
|
var import_inspection = require('./inspection.js');
|
|
@@ -319,7 +320,7 @@ async function loadReportingLedger(client, request, maxSnapshotRestarts = 2, lim
|
|
|
319
320
|
{
|
|
320
321
|
...request,
|
|
321
322
|
view: "periods",
|
|
322
|
-
...cursor ? {
|
|
323
|
+
pagination: { max_results: (0, import_pagination.reportingMaxPageSize)(), ...cursor ? { cursor } : {} }
|
|
323
324
|
},
|
|
324
325
|
{ signal }
|
|
325
326
|
),
|
|
@@ -2040,7 +2041,7 @@ async function consumeReportingRevision(options, reportingRevisionId, deadline,
|
|
|
2040
2041
|
{
|
|
2041
2042
|
...options.request.account ? { account: options.request.account } : {},
|
|
2042
2043
|
reporting_revision_id: reportingRevisionId,
|
|
2043
|
-
...cursor ? {
|
|
2044
|
+
pagination: { max_results: (0, import_pagination.reportingMaxPageSize)(), ...cursor ? { cursor } : {} }
|
|
2044
2045
|
},
|
|
2045
2046
|
{ signal }
|
|
2046
2047
|
),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash } from "crypto";
|
|
2
2
|
import { generateIdempotencyKey } from "../utils/idempotency.mjs";
|
|
3
3
|
import { canonicalize } from "../utils/jcs.mjs";
|
|
4
|
+
import { reportingMaxPageSize } from "./pagination.mjs";
|
|
4
5
|
import {
|
|
5
6
|
detectReportingContentMismatch
|
|
6
7
|
} from "./content-mismatch.mjs";
|
|
@@ -295,7 +296,7 @@ async function loadReportingLedger(client, request, maxSnapshotRestarts = 2, lim
|
|
|
295
296
|
{
|
|
296
297
|
...request,
|
|
297
298
|
view: "periods",
|
|
298
|
-
...cursor ? {
|
|
299
|
+
pagination: { max_results: reportingMaxPageSize(), ...cursor ? { cursor } : {} }
|
|
299
300
|
},
|
|
300
301
|
{ signal }
|
|
301
302
|
),
|
|
@@ -2016,7 +2017,7 @@ async function consumeReportingRevision(options, reportingRevisionId, deadline,
|
|
|
2016
2017
|
{
|
|
2017
2018
|
...options.request.account ? { account: options.request.account } : {},
|
|
2018
2019
|
reporting_revision_id: reportingRevisionId,
|
|
2019
|
-
...cursor ? {
|
|
2020
|
+
pagination: { max_results: reportingMaxPageSize(), ...cursor ? { cursor } : {} }
|
|
2020
2021
|
},
|
|
2021
2022
|
{ signal }
|
|
2022
2023
|
),
|