@adcp/sdk 15.5.0 → 15.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +15 -0
  2. package/dist/lib/auth/oauth/index.d.mts +1 -0
  3. package/dist/lib/auth/oauth/index.d.ts +1 -0
  4. package/dist/lib/auth/oauth/index.js +5 -0
  5. package/dist/lib/auth/oauth/index.mjs +3 -0
  6. package/dist/lib/auth/oauth/pending-web-flow.d.mts +16 -0
  7. package/dist/lib/auth/oauth/pending-web-flow.d.ts +16 -0
  8. package/dist/lib/auth/oauth/pending-web-flow.js +66 -0
  9. package/dist/lib/auth/oauth/pending-web-flow.mjs +41 -0
  10. package/dist/lib/auth/oauth/web-flow.js +3 -3
  11. package/dist/lib/auth/oauth/web-flow.mjs +3 -3
  12. package/dist/lib/registry/types.generated.d.mts +63 -1
  13. package/dist/lib/registry/types.generated.d.ts +63 -1
  14. package/dist/lib/reporting/azure/index.d.mts +26 -0
  15. package/dist/lib/reporting/azure/index.d.ts +26 -0
  16. package/dist/lib/reporting/azure/index.js +247 -0
  17. package/dist/lib/reporting/azure/index.mjs +230 -0
  18. package/dist/lib/reporting/bigquery/index.d.mts +127 -0
  19. package/dist/lib/reporting/bigquery/index.d.ts +127 -0
  20. package/dist/lib/reporting/bigquery/index.js +379 -0
  21. package/dist/lib/reporting/bigquery/index.mjs +341 -0
  22. package/dist/lib/reporting/ledger/handler.js +20 -8
  23. package/dist/lib/reporting/ledger/handler.mjs +20 -8
  24. package/dist/lib/reporting/ledger/postgres.d.mts +21 -0
  25. package/dist/lib/reporting/ledger/postgres.d.ts +21 -0
  26. package/dist/lib/reporting/ledger/postgres.js +35 -2
  27. package/dist/lib/reporting/ledger/postgres.mjs +35 -2
  28. package/dist/lib/reporting/ledger/row-storage-object.js +31 -8
  29. package/dist/lib/reporting/ledger/row-storage-object.mjs +32 -9
  30. package/dist/lib/reporting/ledger/row-storage-provider-io.d.mts +0 -7
  31. package/dist/lib/reporting/ledger/row-storage-provider-io.d.ts +0 -7
  32. package/dist/lib/reporting/ledger/row-storage-provider-io.js +0 -10
  33. package/dist/lib/reporting/ledger/row-storage-provider-io.mjs +0 -8
  34. package/dist/lib/reporting/s3/index.d.mts +29 -0
  35. package/dist/lib/reporting/s3/index.d.ts +29 -0
  36. package/dist/lib/reporting/s3/index.js +324 -0
  37. package/dist/lib/reporting/s3/index.mjs +317 -0
  38. package/dist/lib/reporting/service/index.d.mts +39 -22
  39. package/dist/lib/reporting/service/index.d.ts +39 -22
  40. package/dist/lib/reporting/service/index.js +75 -64
  41. package/dist/lib/reporting/service/index.mjs +79 -63
  42. package/dist/lib/reporting/service/maintenance.d.mts +91 -0
  43. package/dist/lib/reporting/service/maintenance.d.ts +91 -0
  44. package/dist/lib/reporting/service/maintenance.js +140 -0
  45. package/dist/lib/reporting/service/maintenance.mjs +114 -0
  46. package/dist/lib/schemas/browser.d.mts +14 -0
  47. package/dist/lib/schemas/browser.d.ts +14 -0
  48. package/dist/lib/schemas/browser.js +48 -0
  49. package/dist/lib/schemas/browser.mjs +20 -0
  50. package/dist/lib/schemas/index.d.mts +2 -120
  51. package/dist/lib/schemas/index.d.ts +2 -120
  52. package/dist/lib/schemas/index.js +3 -11
  53. package/dist/lib/schemas/index.mjs +1 -9
  54. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  55. package/dist/lib/testing/index.d.mts +1 -0
  56. package/dist/lib/testing/index.d.ts +1 -0
  57. package/dist/lib/testing/index.js +3 -0
  58. package/dist/lib/testing/index.mjs +2 -0
  59. package/dist/lib/testing/pending-web-flow-store.d.mts +20 -0
  60. package/dist/lib/testing/pending-web-flow-store.d.ts +20 -0
  61. package/dist/lib/testing/pending-web-flow-store.js +132 -0
  62. package/dist/lib/testing/pending-web-flow-store.mjs +98 -0
  63. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  64. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  65. package/dist/lib/validation/get-products-request.d.mts +122 -0
  66. package/dist/lib/validation/get-products-request.d.ts +122 -0
  67. package/dist/lib/validation/get-products-request.js +39 -0
  68. package/dist/lib/validation/get-products-request.mjs +14 -0
  69. package/dist/lib/version.d.mts +3 -3
  70. package/dist/lib/version.d.ts +3 -3
  71. package/dist/lib/version.js +3 -3
  72. package/dist/lib/version.mjs +3 -3
  73. package/docs/TYPE-SUMMARY.md +1 -1
  74. package/docs/ZOD-SCHEMAS.md +13 -1
  75. package/docs/guides/OAUTH-ISSUER-BINDING.md +6 -0
  76. package/docs/guides/REPORTING-LEDGER.md +254 -0
  77. package/docs/guides/REPORTING-OPERATIONS.md +82 -1
  78. package/docs/guides/WEB-OAUTH.md +48 -1
  79. package/docs/llms.txt +1 -1
  80. package/docs/migration-14.x-rc-worksheet.md +6 -4
  81. package/package.json +64 -1
@@ -0,0 +1,91 @@
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
+ export interface ReportingRetentionOptionsV1 {
10
+ enabled: true;
11
+ recordRetentionDays?: number;
12
+ limit?: number;
13
+ }
14
+ /** Change-feed pruning window and the consumer hold shared with retention. */
15
+ export type ReportingChangeFeedMaintenanceOptionsV1 = boolean | {
16
+ changeRetentionDays?: number;
17
+ maxFeedHoldDays?: number;
18
+ };
19
+ /** The ledger-store surface a maintenance pass drives. */
20
+ export type ReportingLedgerMaintenanceStoreV1 = Pick<PostgresReportingLedgerStore, 'sweepRowWriteIntents' | 'pruneChanges' | 'retireExpiredPeriods'>;
21
+ interface ReportingLedgerMaintenanceTaskOutcomesV1 {
22
+ 'snapshot sweep': Awaited<ReturnType<PostgresReportingLedgerStore['sweepExpiredState']>>;
23
+ 'row upload sweep': Awaited<ReturnType<PostgresReportingLedgerStore['sweepRowWriteIntents']>>;
24
+ 'change-feed pruning': Awaited<ReturnType<PostgresReportingLedgerStore['pruneChanges']>>;
25
+ retention: Awaited<ReturnType<PostgresReportingLedgerStore['retireExpiredPeriods']>>;
26
+ }
27
+ export type ReportingLedgerMaintenanceTaskNameV1 = keyof ReportingLedgerMaintenanceTaskOutcomesV1;
28
+ /**
29
+ * A scheduled maintenance pass completed but could not process some items
30
+ * (for example, a retention period whose objects could not be deleted). The
31
+ * pass resumes them next time; repeated reports need operator attention.
32
+ */
33
+ export declare class ReportingMaintenancePartialFailureError extends Error {
34
+ readonly task: string;
35
+ readonly failedCount: number;
36
+ readonly failedIds: readonly string[];
37
+ constructor(task: string, failedCount: number, failedIds: readonly string[]);
38
+ }
39
+ /**
40
+ * Outcome of one maintenance task. A task that resolved but could not process
41
+ * some items (a retention period whose objects would not delete, an upload that
42
+ * would not sweep) is `completed` with `partialFailure` set; the pass resumes
43
+ * those items next time.
44
+ */
45
+ export type ReportingLedgerMaintenanceTaskResultV1 = {
46
+ [Task in ReportingLedgerMaintenanceTaskNameV1]: {
47
+ readonly task: Task;
48
+ readonly status: 'completed';
49
+ readonly result: ReportingLedgerMaintenanceTaskOutcomesV1[Task];
50
+ readonly partialFailure?: ReportingMaintenancePartialFailureError;
51
+ } | {
52
+ readonly task: Task;
53
+ readonly status: 'failed';
54
+ readonly error: unknown;
55
+ };
56
+ }[ReportingLedgerMaintenanceTaskNameV1];
57
+ export interface RunReportingLedgerMaintenanceInputV1 {
58
+ store: ReportingLedgerMaintenanceStoreV1;
59
+ /**
60
+ * Expired cursor snapshot and checkpoint sweep. Omitted when the caller has
61
+ * no way to reach the database, in which case that task is not run.
62
+ */
63
+ sweepSnapshots?: (limit: number) => Promise<ReportingLedgerMaintenanceTaskOutcomesV1['snapshot sweep']>;
64
+ statusRetentionDays: number;
65
+ retention?: ReportingRetentionOptionsV1 | undefined;
66
+ changeFeed?: ReportingChangeFeedMaintenanceOptionsV1 | undefined;
67
+ signal?: AbortSignal | undefined;
68
+ /**
69
+ * Called, in task order and awaited, for every task that rejected or
70
+ * partially failed, unless `signal` has aborted (an abort is shutdown, not a
71
+ * fault).
72
+ */
73
+ report?: (error: unknown) => Promise<void>;
74
+ }
75
+ /**
76
+ * The single ledger-maintenance pass shared by the Core service and the
77
+ * production service, so partial-failure surfacing, the `maxFeedHoldDays` that
78
+ * retention honours, per-task limits and abort handling cannot drift between
79
+ * them. Tasks start together, in a fixed order, and are isolated: one task's
80
+ * failure never prevents another from running.
81
+ */
82
+ export declare function runReportingLedgerMaintenance(input: RunReportingLedgerMaintenanceInputV1): Promise<ReportingLedgerMaintenanceTaskResultV1[]>;
83
+ /**
84
+ * Fail fast on maintenance options the store would otherwise reject on every
85
+ * pass. Mirrors the checks `retireExpiredPeriods` and `pruneChanges` apply.
86
+ */
87
+ export declare function assertReportingLedgerMaintenanceOptions(input: {
88
+ retention?: ReportingRetentionOptionsV1 | undefined;
89
+ changeFeed?: ReportingChangeFeedMaintenanceOptionsV1 | undefined;
90
+ }, statusRetentionDays: number): void;
91
+ export {};
@@ -0,0 +1,91 @@
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
+ export interface ReportingRetentionOptionsV1 {
10
+ enabled: true;
11
+ recordRetentionDays?: number;
12
+ limit?: number;
13
+ }
14
+ /** Change-feed pruning window and the consumer hold shared with retention. */
15
+ export type ReportingChangeFeedMaintenanceOptionsV1 = boolean | {
16
+ changeRetentionDays?: number;
17
+ maxFeedHoldDays?: number;
18
+ };
19
+ /** The ledger-store surface a maintenance pass drives. */
20
+ export type ReportingLedgerMaintenanceStoreV1 = Pick<PostgresReportingLedgerStore, 'sweepRowWriteIntents' | 'pruneChanges' | 'retireExpiredPeriods'>;
21
+ interface ReportingLedgerMaintenanceTaskOutcomesV1 {
22
+ 'snapshot sweep': Awaited<ReturnType<PostgresReportingLedgerStore['sweepExpiredState']>>;
23
+ 'row upload sweep': Awaited<ReturnType<PostgresReportingLedgerStore['sweepRowWriteIntents']>>;
24
+ 'change-feed pruning': Awaited<ReturnType<PostgresReportingLedgerStore['pruneChanges']>>;
25
+ retention: Awaited<ReturnType<PostgresReportingLedgerStore['retireExpiredPeriods']>>;
26
+ }
27
+ export type ReportingLedgerMaintenanceTaskNameV1 = keyof ReportingLedgerMaintenanceTaskOutcomesV1;
28
+ /**
29
+ * A scheduled maintenance pass completed but could not process some items
30
+ * (for example, a retention period whose objects could not be deleted). The
31
+ * pass resumes them next time; repeated reports need operator attention.
32
+ */
33
+ export declare class ReportingMaintenancePartialFailureError extends Error {
34
+ readonly task: string;
35
+ readonly failedCount: number;
36
+ readonly failedIds: readonly string[];
37
+ constructor(task: string, failedCount: number, failedIds: readonly string[]);
38
+ }
39
+ /**
40
+ * Outcome of one maintenance task. A task that resolved but could not process
41
+ * some items (a retention period whose objects would not delete, an upload that
42
+ * would not sweep) is `completed` with `partialFailure` set; the pass resumes
43
+ * those items next time.
44
+ */
45
+ export type ReportingLedgerMaintenanceTaskResultV1 = {
46
+ [Task in ReportingLedgerMaintenanceTaskNameV1]: {
47
+ readonly task: Task;
48
+ readonly status: 'completed';
49
+ readonly result: ReportingLedgerMaintenanceTaskOutcomesV1[Task];
50
+ readonly partialFailure?: ReportingMaintenancePartialFailureError;
51
+ } | {
52
+ readonly task: Task;
53
+ readonly status: 'failed';
54
+ readonly error: unknown;
55
+ };
56
+ }[ReportingLedgerMaintenanceTaskNameV1];
57
+ export interface RunReportingLedgerMaintenanceInputV1 {
58
+ store: ReportingLedgerMaintenanceStoreV1;
59
+ /**
60
+ * Expired cursor snapshot and checkpoint sweep. Omitted when the caller has
61
+ * no way to reach the database, in which case that task is not run.
62
+ */
63
+ sweepSnapshots?: (limit: number) => Promise<ReportingLedgerMaintenanceTaskOutcomesV1['snapshot sweep']>;
64
+ statusRetentionDays: number;
65
+ retention?: ReportingRetentionOptionsV1 | undefined;
66
+ changeFeed?: ReportingChangeFeedMaintenanceOptionsV1 | undefined;
67
+ signal?: AbortSignal | undefined;
68
+ /**
69
+ * Called, in task order and awaited, for every task that rejected or
70
+ * partially failed, unless `signal` has aborted (an abort is shutdown, not a
71
+ * fault).
72
+ */
73
+ report?: (error: unknown) => Promise<void>;
74
+ }
75
+ /**
76
+ * The single ledger-maintenance pass shared by the Core service and the
77
+ * production service, so partial-failure surfacing, the `maxFeedHoldDays` that
78
+ * retention honours, per-task limits and abort handling cannot drift between
79
+ * them. Tasks start together, in a fixed order, and are isolated: one task's
80
+ * failure never prevents another from running.
81
+ */
82
+ export declare function runReportingLedgerMaintenance(input: RunReportingLedgerMaintenanceInputV1): Promise<ReportingLedgerMaintenanceTaskResultV1[]>;
83
+ /**
84
+ * Fail fast on maintenance options the store would otherwise reject on every
85
+ * pass. Mirrors the checks `retireExpiredPeriods` and `pruneChanges` apply.
86
+ */
87
+ export declare function assertReportingLedgerMaintenanceOptions(input: {
88
+ retention?: ReportingRetentionOptionsV1 | undefined;
89
+ changeFeed?: ReportingChangeFeedMaintenanceOptionsV1 | undefined;
90
+ }, statusRetentionDays: number): void;
91
+ export {};
@@ -0,0 +1,140 @@
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 maintenance_exports = {};
20
+ __export(maintenance_exports, {
21
+ ReportingMaintenancePartialFailureError: () => ReportingMaintenancePartialFailureError,
22
+ assertReportingLedgerMaintenanceOptions: () => assertReportingLedgerMaintenanceOptions,
23
+ runReportingLedgerMaintenance: () => runReportingLedgerMaintenance
24
+ });
25
+ module.exports = __toCommonJS(maintenance_exports);
26
+ class ReportingMaintenancePartialFailureError extends Error {
27
+ constructor(task, failedCount, failedIds) {
28
+ super(
29
+ `Reporting ${task} could not process ${failedCount} item(s)${failedIds.length ? `: ${failedIds.slice(0, 20).join(", ")}` : ""}`
30
+ );
31
+ this.task = task;
32
+ this.failedCount = failedCount;
33
+ this.failedIds = failedIds;
34
+ this.name = "ReportingMaintenancePartialFailureError";
35
+ }
36
+ task;
37
+ failedCount;
38
+ failedIds;
39
+ }
40
+ async function runReportingLedgerMaintenance(input) {
41
+ const { store, signal, changeFeed, retention } = input;
42
+ const start = (name, run) => {
43
+ try {
44
+ return [name, run()];
45
+ } catch (error) {
46
+ return [name, Promise.reject(error)];
47
+ }
48
+ };
49
+ const tasks = [
50
+ ...input.sweepSnapshots ? [start("snapshot sweep", () => input.sweepSnapshots(1e3))] : [],
51
+ start("row upload sweep", () => store.sweepRowWriteIntents({ limit: 100, ...signal ? { signal } : {} })),
52
+ ...changeFeed ? [
53
+ start(
54
+ "change-feed pruning",
55
+ () => store.pruneChanges(
56
+ typeof changeFeed === "object" ? {
57
+ ...changeFeed.changeRetentionDays !== void 0 ? { changeRetentionDays: changeFeed.changeRetentionDays } : {},
58
+ ...changeFeed.maxFeedHoldDays !== void 0 ? { maxFeedHoldDays: changeFeed.maxFeedHoldDays } : {}
59
+ } : {}
60
+ )
61
+ )
62
+ ] : [],
63
+ ...retention?.enabled ? [
64
+ start(
65
+ "retention",
66
+ () => store.retireExpiredPeriods({
67
+ statusRetentionDays: input.statusRetentionDays,
68
+ ...retention.recordRetentionDays !== void 0 ? { recordRetentionDays: retention.recordRetentionDays } : {},
69
+ ...typeof changeFeed === "object" && changeFeed.maxFeedHoldDays !== void 0 ? { maxFeedHoldDays: changeFeed.maxFeedHoldDays } : {},
70
+ limit: retention.limit ?? 100,
71
+ ...signal ? { signal } : {}
72
+ })
73
+ )
74
+ ] : []
75
+ ];
76
+ const settled = await Promise.allSettled(tasks.map(([, task]) => task));
77
+ const results = [];
78
+ for (const [index, outcome] of settled.entries()) {
79
+ const name = tasks[index][0];
80
+ if (outcome.status === "rejected") {
81
+ if (!signal?.aborted) await input.report?.(outcome.reason);
82
+ results.push({ task: name, status: "failed", error: outcome.reason });
83
+ continue;
84
+ }
85
+ const value = outcome.value;
86
+ const failed = Array.isArray(value?.failed) ? value.failed.length : typeof value?.failed === "number" ? value.failed : 0;
87
+ let partialFailure;
88
+ if (failed > 0) {
89
+ partialFailure = new ReportingMaintenancePartialFailureError(
90
+ name,
91
+ failed,
92
+ value?.failures?.length ? value.failures.map((entry) => `${entry.reporting_obligation_id} (${entry.cause})`) : Array.isArray(value?.failed) ? value.failed : []
93
+ );
94
+ if (!signal?.aborted) await input.report?.(partialFailure);
95
+ }
96
+ results.push({
97
+ task: name,
98
+ status: "completed",
99
+ result: outcome.value,
100
+ ...partialFailure ? { partialFailure } : {}
101
+ });
102
+ }
103
+ return results;
104
+ }
105
+ function assertReportingLedgerMaintenanceOptions(input, statusRetentionDays) {
106
+ const positive = (value, field) => {
107
+ if (!Number.isSafeInteger(value) || value <= 0) {
108
+ throw new TypeError(`${field} must be a positive safe integer`);
109
+ }
110
+ };
111
+ const { retention, changeFeed } = input;
112
+ if (retention !== void 0) {
113
+ if (retention === null || typeof retention !== "object" || retention.enabled !== true) {
114
+ throw new TypeError("maintenance.retention must be { enabled: true, ... }");
115
+ }
116
+ if (retention.recordRetentionDays !== void 0) {
117
+ positive(retention.recordRetentionDays, "maintenance.retention.recordRetentionDays");
118
+ if (retention.recordRetentionDays < statusRetentionDays) {
119
+ throw new RangeError(
120
+ "maintenance.retention.recordRetentionDays must be no shorter than statusRetentionDays, the retention advertised to buyers"
121
+ );
122
+ }
123
+ }
124
+ if (retention.limit !== void 0) positive(retention.limit, "maintenance.retention.limit");
125
+ }
126
+ if (typeof changeFeed === "object" && changeFeed !== null) {
127
+ if (changeFeed.changeRetentionDays !== void 0) {
128
+ positive(changeFeed.changeRetentionDays, "maintenance.changeFeed.changeRetentionDays");
129
+ }
130
+ if (changeFeed.maxFeedHoldDays !== void 0) {
131
+ positive(changeFeed.maxFeedHoldDays, "maintenance.changeFeed.maxFeedHoldDays");
132
+ }
133
+ }
134
+ }
135
+ // Annotate the CommonJS export names for ESM import in node:
136
+ 0 && (module.exports = {
137
+ ReportingMaintenancePartialFailureError,
138
+ assertReportingLedgerMaintenanceOptions,
139
+ runReportingLedgerMaintenance
140
+ });
@@ -0,0 +1,114 @@
1
+ class ReportingMaintenancePartialFailureError extends Error {
2
+ constructor(task, failedCount, failedIds) {
3
+ super(
4
+ `Reporting ${task} could not process ${failedCount} item(s)${failedIds.length ? `: ${failedIds.slice(0, 20).join(", ")}` : ""}`
5
+ );
6
+ this.task = task;
7
+ this.failedCount = failedCount;
8
+ this.failedIds = failedIds;
9
+ this.name = "ReportingMaintenancePartialFailureError";
10
+ }
11
+ task;
12
+ failedCount;
13
+ failedIds;
14
+ }
15
+ async function runReportingLedgerMaintenance(input) {
16
+ const { store, signal, changeFeed, retention } = input;
17
+ const start = (name, run) => {
18
+ try {
19
+ return [name, run()];
20
+ } catch (error) {
21
+ return [name, Promise.reject(error)];
22
+ }
23
+ };
24
+ const tasks = [
25
+ ...input.sweepSnapshots ? [start("snapshot sweep", () => input.sweepSnapshots(1e3))] : [],
26
+ start("row upload sweep", () => store.sweepRowWriteIntents({ limit: 100, ...signal ? { signal } : {} })),
27
+ ...changeFeed ? [
28
+ start(
29
+ "change-feed pruning",
30
+ () => store.pruneChanges(
31
+ typeof changeFeed === "object" ? {
32
+ ...changeFeed.changeRetentionDays !== void 0 ? { changeRetentionDays: changeFeed.changeRetentionDays } : {},
33
+ ...changeFeed.maxFeedHoldDays !== void 0 ? { maxFeedHoldDays: changeFeed.maxFeedHoldDays } : {}
34
+ } : {}
35
+ )
36
+ )
37
+ ] : [],
38
+ ...retention?.enabled ? [
39
+ start(
40
+ "retention",
41
+ () => store.retireExpiredPeriods({
42
+ statusRetentionDays: input.statusRetentionDays,
43
+ ...retention.recordRetentionDays !== void 0 ? { recordRetentionDays: retention.recordRetentionDays } : {},
44
+ ...typeof changeFeed === "object" && changeFeed.maxFeedHoldDays !== void 0 ? { maxFeedHoldDays: changeFeed.maxFeedHoldDays } : {},
45
+ limit: retention.limit ?? 100,
46
+ ...signal ? { signal } : {}
47
+ })
48
+ )
49
+ ] : []
50
+ ];
51
+ const settled = await Promise.allSettled(tasks.map(([, task]) => task));
52
+ const results = [];
53
+ for (const [index, outcome] of settled.entries()) {
54
+ const name = tasks[index][0];
55
+ if (outcome.status === "rejected") {
56
+ if (!signal?.aborted) await input.report?.(outcome.reason);
57
+ results.push({ task: name, status: "failed", error: outcome.reason });
58
+ continue;
59
+ }
60
+ const value = outcome.value;
61
+ const failed = Array.isArray(value?.failed) ? value.failed.length : typeof value?.failed === "number" ? value.failed : 0;
62
+ let partialFailure;
63
+ if (failed > 0) {
64
+ partialFailure = new ReportingMaintenancePartialFailureError(
65
+ name,
66
+ failed,
67
+ value?.failures?.length ? value.failures.map((entry) => `${entry.reporting_obligation_id} (${entry.cause})`) : Array.isArray(value?.failed) ? value.failed : []
68
+ );
69
+ if (!signal?.aborted) await input.report?.(partialFailure);
70
+ }
71
+ results.push({
72
+ task: name,
73
+ status: "completed",
74
+ result: outcome.value,
75
+ ...partialFailure ? { partialFailure } : {}
76
+ });
77
+ }
78
+ return results;
79
+ }
80
+ function assertReportingLedgerMaintenanceOptions(input, statusRetentionDays) {
81
+ const positive = (value, field) => {
82
+ if (!Number.isSafeInteger(value) || value <= 0) {
83
+ throw new TypeError(`${field} must be a positive safe integer`);
84
+ }
85
+ };
86
+ const { retention, changeFeed } = input;
87
+ if (retention !== void 0) {
88
+ if (retention === null || typeof retention !== "object" || retention.enabled !== true) {
89
+ throw new TypeError("maintenance.retention must be { enabled: true, ... }");
90
+ }
91
+ if (retention.recordRetentionDays !== void 0) {
92
+ positive(retention.recordRetentionDays, "maintenance.retention.recordRetentionDays");
93
+ if (retention.recordRetentionDays < statusRetentionDays) {
94
+ throw new RangeError(
95
+ "maintenance.retention.recordRetentionDays must be no shorter than statusRetentionDays, the retention advertised to buyers"
96
+ );
97
+ }
98
+ }
99
+ if (retention.limit !== void 0) positive(retention.limit, "maintenance.retention.limit");
100
+ }
101
+ if (typeof changeFeed === "object" && changeFeed !== null) {
102
+ if (changeFeed.changeRetentionDays !== void 0) {
103
+ positive(changeFeed.changeRetentionDays, "maintenance.changeFeed.changeRetentionDays");
104
+ }
105
+ if (changeFeed.maxFeedHoldDays !== void 0) {
106
+ positive(changeFeed.maxFeedHoldDays, "maintenance.changeFeed.maxFeedHoldDays");
107
+ }
108
+ }
109
+ }
110
+ export {
111
+ ReportingMaintenancePartialFailureError,
112
+ assertReportingLedgerMaintenanceOptions,
113
+ runReportingLedgerMaintenance
114
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Browser-safe Zod schemas for validating AdCP objects in widgets and UIs.
3
+ *
4
+ * Import from `@adcp/sdk/schemas/browser`. This entry exposes the generated
5
+ * schemas and portable cross-field validators without loading the Node-only
6
+ * JSON Schema loader or bundled schema store.
7
+ */
8
+ export * from '../types/schemas.generated.mjs';
9
+ export { GetProductsRequestSchema, LegacyGetProductsRequestSchema } from '../validation/get-products-request.mjs';
10
+ export type { LooseObjectSchemaFor } from '../validation/get-products-request.mjs';
11
+ export { BiddingPolicySchema } from '../validation/bidding-policy.mjs';
12
+ export { CanonicalBudgetAllocationSchema } from '../validation/budget-allocation.mjs';
13
+ export { SyncCreativesItemSchema, SyncCreativesSuccessStrictSchema, SyncCreativesResponseStrictSchema, SyncCreativesActionSchema, } from '../validation/sync-creatives.mjs';
14
+ export type { SyncCreativesItem, SyncCreativesSuccessStrict } from '../validation/sync-creatives.mjs';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Browser-safe Zod schemas for validating AdCP objects in widgets and UIs.
3
+ *
4
+ * Import from `@adcp/sdk/schemas/browser`. This entry exposes the generated
5
+ * schemas and portable cross-field validators without loading the Node-only
6
+ * JSON Schema loader or bundled schema store.
7
+ */
8
+ export * from '../types/schemas.generated';
9
+ export { GetProductsRequestSchema, LegacyGetProductsRequestSchema } from '../validation/get-products-request';
10
+ export type { LooseObjectSchemaFor } from '../validation/get-products-request';
11
+ export { BiddingPolicySchema } from '../validation/bidding-policy';
12
+ export { CanonicalBudgetAllocationSchema } from '../validation/budget-allocation';
13
+ export { SyncCreativesItemSchema, SyncCreativesSuccessStrictSchema, SyncCreativesResponseStrictSchema, SyncCreativesActionSchema, } from '../validation/sync-creatives';
14
+ export type { SyncCreativesItem, SyncCreativesSuccessStrict } from '../validation/sync-creatives';
@@ -0,0 +1,48 @@
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var browser_exports = {};
21
+ __export(browser_exports, {
22
+ BiddingPolicySchema: () => import_bidding_policy.BiddingPolicySchema,
23
+ CanonicalBudgetAllocationSchema: () => import_budget_allocation.CanonicalBudgetAllocationSchema,
24
+ GetProductsRequestSchema: () => import_get_products_request.GetProductsRequestSchema,
25
+ LegacyGetProductsRequestSchema: () => import_get_products_request.LegacyGetProductsRequestSchema,
26
+ SyncCreativesActionSchema: () => import_sync_creatives.SyncCreativesActionSchema,
27
+ SyncCreativesItemSchema: () => import_sync_creatives.SyncCreativesItemSchema,
28
+ SyncCreativesResponseStrictSchema: () => import_sync_creatives.SyncCreativesResponseStrictSchema,
29
+ SyncCreativesSuccessStrictSchema: () => import_sync_creatives.SyncCreativesSuccessStrictSchema
30
+ });
31
+ module.exports = __toCommonJS(browser_exports);
32
+ __reExport(browser_exports, require('../types/schemas.generated.js'), module.exports);
33
+ var import_get_products_request = require('../validation/get-products-request.js');
34
+ var import_bidding_policy = require('../validation/bidding-policy.js');
35
+ var import_budget_allocation = require('../validation/budget-allocation.js');
36
+ var import_sync_creatives = require('../validation/sync-creatives.js');
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ BiddingPolicySchema,
40
+ CanonicalBudgetAllocationSchema,
41
+ GetProductsRequestSchema,
42
+ LegacyGetProductsRequestSchema,
43
+ SyncCreativesActionSchema,
44
+ SyncCreativesItemSchema,
45
+ SyncCreativesResponseStrictSchema,
46
+ SyncCreativesSuccessStrictSchema,
47
+ ...require('../types/schemas.generated.js')
48
+ });
@@ -0,0 +1,20 @@
1
+ export * from "../types/schemas.generated.mjs";
2
+ import { GetProductsRequestSchema, LegacyGetProductsRequestSchema } from "../validation/get-products-request.mjs";
3
+ import { BiddingPolicySchema } from "../validation/bidding-policy.mjs";
4
+ import { CanonicalBudgetAllocationSchema } from "../validation/budget-allocation.mjs";
5
+ import {
6
+ SyncCreativesItemSchema,
7
+ SyncCreativesSuccessStrictSchema,
8
+ SyncCreativesResponseStrictSchema,
9
+ SyncCreativesActionSchema
10
+ } from "../validation/sync-creatives.mjs";
11
+ export {
12
+ BiddingPolicySchema,
13
+ CanonicalBudgetAllocationSchema,
14
+ GetProductsRequestSchema,
15
+ LegacyGetProductsRequestSchema,
16
+ SyncCreativesActionSchema,
17
+ SyncCreativesItemSchema,
18
+ SyncCreativesResponseStrictSchema,
19
+ SyncCreativesSuccessStrictSchema
20
+ };