@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.
Files changed (185) 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/types/schemas.generated.d.ts +907 -60
  73. package/dist/lib/types/schemas.generated.js +7 -7
  74. package/dist/lib/types/schemas.generated.mjs +7 -7
  75. package/dist/lib/version.d.mts +3 -3
  76. package/dist/lib/version.d.ts +3 -3
  77. package/dist/lib/version.js +3 -3
  78. package/dist/lib/version.mjs +3 -3
  79. package/docs/TYPE-SUMMARY.md +23 -5
  80. package/docs/guides/REPORTING-GCS-FENCE.md +3 -3
  81. package/docs/guides/REPORTING-GCS-MANAGED.md +4 -4
  82. package/docs/guides/REPORTING-LEDGER-CUTOVER.md +7 -7
  83. package/docs/guides/REPORTING-LEDGER.md +107 -51
  84. package/docs/guides/REPORTING-OPERATIONS.md +66 -5
  85. package/docs/guides/REPORTING-STABILITY.md +36 -32
  86. package/docs/llms.txt +4 -3
  87. package/docs/migration-14.x-rc-worksheet.md +4 -7
  88. package/docs/migration-reporting-storage-package.md +186 -0
  89. package/examples/README.md +1 -1
  90. package/package.json +13 -78
  91. package/dist/lib/reporting/azure/index.d.mts +0 -31
  92. package/dist/lib/reporting/azure/index.d.ts +0 -31
  93. package/dist/lib/reporting/azure/index.js +0 -266
  94. package/dist/lib/reporting/azure/index.mjs +0 -249
  95. package/dist/lib/reporting/bigquery/index.d.mts +0 -246
  96. package/dist/lib/reporting/bigquery/index.d.ts +0 -246
  97. package/dist/lib/reporting/bigquery/index.js +0 -633
  98. package/dist/lib/reporting/bigquery/index.mjs +0 -594
  99. package/dist/lib/reporting/gcs/adapter.d.mts +0 -38
  100. package/dist/lib/reporting/gcs/adapter.d.ts +0 -38
  101. package/dist/lib/reporting/gcs/adapter.js +0 -342
  102. package/dist/lib/reporting/gcs/adapter.mjs +0 -325
  103. package/dist/lib/reporting/gcs/bucket-policy.d.mts +0 -3
  104. package/dist/lib/reporting/gcs/bucket-policy.d.ts +0 -3
  105. package/dist/lib/reporting/gcs/bucket-policy.mjs +0 -7
  106. package/dist/lib/reporting/gcs/errors.d.mts +0 -11
  107. package/dist/lib/reporting/gcs/errors.d.ts +0 -11
  108. package/dist/lib/reporting/gcs/errors.mjs +0 -16
  109. package/dist/lib/reporting/gcs/fence.d.mts +0 -41
  110. package/dist/lib/reporting/gcs/fence.d.ts +0 -41
  111. package/dist/lib/reporting/gcs/fence.js +0 -250
  112. package/dist/lib/reporting/gcs/fence.mjs +0 -230
  113. package/dist/lib/reporting/gcs/index.d.mts +0 -18
  114. package/dist/lib/reporting/gcs/index.d.ts +0 -18
  115. package/dist/lib/reporting/gcs/index.js +0 -44
  116. package/dist/lib/reporting/gcs/index.mjs +0 -14
  117. package/dist/lib/reporting/gcs/io.d.mts +0 -7
  118. package/dist/lib/reporting/gcs/io.d.ts +0 -7
  119. package/dist/lib/reporting/gcs/io.js +0 -95
  120. package/dist/lib/reporting/gcs/io.mjs +0 -69
  121. package/dist/lib/reporting/gcs/reader.d.mts +0 -67
  122. package/dist/lib/reporting/gcs/reader.d.ts +0 -67
  123. package/dist/lib/reporting/gcs/reader.js +0 -193
  124. package/dist/lib/reporting/gcs/reader.mjs +0 -169
  125. package/dist/lib/reporting/gcs/row-provider.d.mts +0 -39
  126. package/dist/lib/reporting/gcs/row-provider.d.ts +0 -39
  127. package/dist/lib/reporting/gcs/row-provider.js +0 -225
  128. package/dist/lib/reporting/gcs/row-provider.mjs +0 -208
  129. package/dist/lib/reporting/gcs/validation.d.mts +0 -5
  130. package/dist/lib/reporting/gcs/validation.d.ts +0 -5
  131. package/dist/lib/reporting/gcs/validation.js +0 -49
  132. package/dist/lib/reporting/gcs/validation.mjs +0 -25
  133. package/dist/lib/reporting/ledger/change-feed.d.mts +0 -69
  134. package/dist/lib/reporting/ledger/change-feed.d.ts +0 -69
  135. package/dist/lib/reporting/ledger/change-feed.js +0 -107
  136. package/dist/lib/reporting/ledger/change-feed.mjs +0 -80
  137. package/dist/lib/reporting/ledger/managed-postgres.d.mts +0 -293
  138. package/dist/lib/reporting/ledger/managed-postgres.d.ts +0 -293
  139. package/dist/lib/reporting/ledger/managed-postgres.js +0 -2346
  140. package/dist/lib/reporting/ledger/managed-postgres.mjs +0 -2332
  141. package/dist/lib/reporting/ledger/managed-router.d.mts +0 -148
  142. package/dist/lib/reporting/ledger/managed-router.d.ts +0 -148
  143. package/dist/lib/reporting/ledger/managed-router.js +0 -280
  144. package/dist/lib/reporting/ledger/managed-router.mjs +0 -258
  145. package/dist/lib/reporting/ledger/managed.d.mts +0 -535
  146. package/dist/lib/reporting/ledger/managed.d.ts +0 -535
  147. package/dist/lib/reporting/ledger/managed.js +0 -761
  148. package/dist/lib/reporting/ledger/managed.mjs +0 -729
  149. package/dist/lib/reporting/ledger/notification-activity.d.mts +0 -332
  150. package/dist/lib/reporting/ledger/notification-activity.d.ts +0 -332
  151. package/dist/lib/reporting/ledger/notification-activity.js +0 -1366
  152. package/dist/lib/reporting/ledger/notification-activity.mjs +0 -1337
  153. package/dist/lib/reporting/ledger/object-writes.d.mts +0 -128
  154. package/dist/lib/reporting/ledger/object-writes.d.ts +0 -128
  155. package/dist/lib/reporting/ledger/object-writes.js +0 -147
  156. package/dist/lib/reporting/ledger/object-writes.mjs +0 -114
  157. package/dist/lib/reporting/ledger/postgres.d.mts +0 -689
  158. package/dist/lib/reporting/ledger/postgres.d.ts +0 -689
  159. package/dist/lib/reporting/ledger/postgres.js +0 -4462
  160. package/dist/lib/reporting/ledger/postgres.mjs +0 -4462
  161. package/dist/lib/reporting/ledger/row-storage-migration.d.mts +0 -59
  162. package/dist/lib/reporting/ledger/row-storage-migration.d.ts +0 -59
  163. package/dist/lib/reporting/ledger/row-storage-migration.js +0 -365
  164. package/dist/lib/reporting/ledger/row-storage-migration.mjs +0 -339
  165. package/dist/lib/reporting/ledger/row-storage-object.d.mts +0 -203
  166. package/dist/lib/reporting/ledger/row-storage-object.d.ts +0 -203
  167. package/dist/lib/reporting/ledger/row-storage-object.js +0 -379
  168. package/dist/lib/reporting/ledger/row-storage-object.mjs +0 -335
  169. package/dist/lib/reporting/ledger/row-storage-provider-io.d.mts +0 -44
  170. package/dist/lib/reporting/ledger/row-storage-provider-io.d.ts +0 -44
  171. package/dist/lib/reporting/ledger/row-storage-provider-io.js +0 -142
  172. package/dist/lib/reporting/ledger/row-storage-provider-io.mjs +0 -111
  173. package/dist/lib/reporting/ledger/row-storage.d.mts +0 -316
  174. package/dist/lib/reporting/ledger/row-storage.d.ts +0 -316
  175. package/dist/lib/reporting/ledger/row-storage.js +0 -812
  176. package/dist/lib/reporting/ledger/row-storage.mjs +0 -802
  177. package/dist/lib/reporting/s3/index.d.mts +0 -34
  178. package/dist/lib/reporting/s3/index.d.ts +0 -34
  179. package/dist/lib/reporting/s3/index.js +0 -347
  180. package/dist/lib/reporting/s3/index.mjs +0 -340
  181. package/dist/lib/reporting/service/maintenance.d.mts +0 -148
  182. package/dist/lib/reporting/service/maintenance.d.ts +0 -148
  183. package/dist/lib/reporting/service/maintenance.js +0 -185
  184. package/dist/lib/reporting/service/maintenance.mjs +0 -159
  185. package/examples/reliable-reporting-service/README.md +0 -169
@@ -1,203 +0,0 @@
1
- /**
2
- * Object-storage providers for revision row chunks (shared SDK persistence
3
- * spec, adcontextprotocol/adcp#7996 §3.3–§3.4).
4
- *
5
- * A provider is a thin, credential-free port over one object store. It never
6
- * decides where bytes go: keys are rendered by the SDK from an allowlisted
7
- * binding, and every byte a provider returns is verified against digests
8
- * committed in PostgreSQL before rows are released.
9
- */
10
- /**
11
- * @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
12
- */
13
- export interface ReportingRowObjectContextV1 {
14
- signal: AbortSignal;
15
- }
16
- /**
17
- * @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
18
- */
19
- export interface ReportingRowObjectLocationV1 {
20
- /** Non-secret provider coordinates (bucket, container, filesystem root name, endpoint host). */
21
- readonly location: Readonly<Record<string, string>>;
22
- /** Host-mapped client reference; never a secret. */
23
- readonly credentialRef?: string;
24
- }
25
- /**
26
- * Bounds AdCP puts on `object_ref` and `native_version_ref`
27
- * (`reporting-file-object-ref.json`, `reporting-native-version-ref.json`):
28
- * 1 to 1024 characters. The row-storage `CHECK` constraints enforce the same.
29
- *
30
- * @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
31
- */
32
- export declare const REPORTING_ROW_OBJECT_REF_MAX_LENGTH = 1024;
33
- /**
34
- * @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
35
- */
36
- export declare const REPORTING_ROW_NATIVE_VERSION_REF_MAX_LENGTH = 1024;
37
- /**
38
- * @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
39
- */
40
- export interface ReportingRowObjectPutInputV1 extends ReportingRowObjectLocationV1 {
41
- /** AdCP `object_ref`: decoded, destination-relative object key. */
42
- objectRef: string;
43
- bytes: Uint8Array;
44
- contentType: 'application/x-ndjson' | 'application/gzip';
45
- /** Non-secret object metadata (installation and intent identifiers). */
46
- metadata: Readonly<Record<string, string>>;
47
- }
48
- /**
49
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
50
- */
51
- export interface ReportingRowObjectGetInputV1 extends ReportingRowObjectLocationV1 {
52
- objectRef: string;
53
- /** AdCP `native_version_ref`: the exact native version recorded at write time. */
54
- nativeVersionRef: string;
55
- /** Byte range within the stored object; omit for the whole object. */
56
- range?: {
57
- offset: number;
58
- length: number;
59
- };
60
- /** Hard cap on bytes read; providers abort beyond it. */
61
- maxBytes: number;
62
- }
63
- /**
64
- * @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
65
- */
66
- export interface ReportingRowObjectDeleteInputV1 extends ReportingRowObjectLocationV1 {
67
- objectRef: string;
68
- nativeVersionRef: string;
69
- }
70
- /**
71
- * @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
72
- */
73
- export interface ReportingRowObjectStatInputV1 extends ReportingRowObjectLocationV1 {
74
- objectRef: string;
75
- nativeVersionRef: string;
76
- }
77
- /**
78
- * @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
79
- */
80
- export interface ReportingRowObjectProviderV1 {
81
- /** Registry name, e.g. `filesystem`, `gcs`, `s3`, `azure_blob`. */
82
- readonly name: string;
83
- /** Whether `get` honours `range` without reading the whole object. */
84
- readonly rangedReads: boolean;
85
- /**
86
- * Validate binding coordinates against the provider's closed schema. Throw
87
- * `INVALID_INPUT` for unknown fields or values that could carry secrets.
88
- */
89
- validateLocation(location: Readonly<Record<string, string>>): void;
90
- /** Fail closed (`UNSAFE_BINDING`) when the destination is unsafe or create-only writes are not enforced. */
91
- probe(input: ReportingRowObjectLocationV1 & {
92
- prefix: string;
93
- }, context: ReportingRowObjectContextV1): Promise<void>;
94
- /**
95
- * Create-only write. Returns `created: true` with the new native version, or
96
- * `created: false` with the existing object's version when the key is taken.
97
- * Must never replace an existing object.
98
- */
99
- putIfAbsent(input: ReportingRowObjectPutInputV1, context: ReportingRowObjectContextV1): Promise<{
100
- created: boolean;
101
- nativeVersionRef: string;
102
- }>;
103
- /** Bytes at the exact native version, or `null` when that version is absent. */
104
- get(input: ReportingRowObjectGetInputV1, context: ReportingRowObjectContextV1): Promise<Uint8Array | null>;
105
- /**
106
- * Metadata of the exact native version without reading its bytes: the version it resolved (which must equal the
107
- * requested `nativeVersionRef`) and its stored size (`size_bytes`), or `null` when that version is absent. Optional. The commit transaction uses it to
108
- * prove an adopted object is unchanged (native versions are write-unique, so the same version at
109
- * the recorded size is the same bytes) without downloading it under the account lock. A provider
110
- * without `stat` falls back to a full read there. Never return a size for a different version.
111
- */
112
- stat?(input: ReportingRowObjectStatInputV1, context: ReportingRowObjectContextV1): Promise<{
113
- nativeVersionRef: string;
114
- sizeBytes: number;
115
- } | null>;
116
- /** Delete the exact native version. Idempotent: `absent` is success. */
117
- delete(input: ReportingRowObjectDeleteInputV1, context: ReportingRowObjectContextV1): Promise<'deleted' | 'absent'>;
118
- }
119
- /**
120
- * Placeholders allowed in object key templates. `{period_date}` renders AdCP's `YYYY-MM-DD`: the calendar
121
- * date of the period start in the period's `source_timezone` (never UTC, unless that is the source
122
- * timezone). It is one path segment, so the default layout is
123
- * `.../{account_key}/2026-10-02/{finality}/...`.
124
- *
125
- * @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
126
- */
127
- export declare const REPORTING_ROW_KEY_PLACEHOLDERS: readonly ["prefix", "namespace_key", "account_key", "period_date", "finality", "revision_key", "content_sha256", "chunk_index"];
128
- /**
129
- * @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
130
- */
131
- export declare const REPORTING_ROW_DEFAULT_KEY_TEMPLATE = "{prefix}/{namespace_key}/{account_key}/{period_date}/{finality}/{revision_key}/{content_sha256}/{chunk_index}";
132
- /**
133
- * Validate an object key template; throws `INVALID_INPUT`. Every template that writes must include
134
- * `{revision_key}`, so no two row sets can ever name the same object key; `requireRevisionKey: false`
135
- * is for a read-only binding that only reads rows written under an older template.
136
- *
137
- * @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
138
- */
139
- export declare function assertReportingRowKeyTemplateV1(template: string, options?: {
140
- requireRevisionKey?: boolean;
141
- }): void;
142
- /**
143
- * @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
144
- */
145
- export declare function assertReportingRowPrefixV1(prefix: string): void;
146
- /**
147
- * Pseudonymous account segment; never a raw account ID.
148
- *
149
- * @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
150
- */
151
- export declare function reportingRowAccountKeyV1(namespaceKey: string, accountId: string): string;
152
- /**
153
- * @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
154
- */
155
- export declare function reportingRowRevisionKeyV1(rowSetId: string): string;
156
- /**
157
- * Render one chunk's object key and confine it to the binding's owned prefix.
158
- *
159
- * @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
160
- */
161
- export declare function renderReportingRowObjectKeyV1(input: {
162
- template: string;
163
- prefix: string;
164
- namespaceKey: string;
165
- accountId: string;
166
- rowSetId: string;
167
- /** Period start instant; with `sourceTimezone`, renders `{period_date}`. Absent renders `undated`. */
168
- periodStart?: string;
169
- /** The period's `source_timezone`; required whenever `periodStart` is set. Invalid values fail closed. */
170
- sourceTimezone?: string;
171
- finality?: 'snapshot' | 'official';
172
- contentSha256: string;
173
- chunkIndex: number;
174
- compression: 'none' | 'gzip';
175
- }): string;
176
- /**
177
- * @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
178
- */
179
- export interface FilesystemReportingRowObjectProviderOptionsV1 {
180
- /**
181
- * Root name → absolute directory. Bindings name a root (`location.root`);
182
- * they never carry paths, so the database cannot point writes elsewhere.
183
- */
184
- roots: Readonly<Record<string, string>>;
185
- }
186
- /**
187
- * Local filesystem provider for tests and single-host deployments. Create-only
188
- * writes use a temporary file, `fsync`, and `link()` to the final name, which
189
- * fails rather than replacing an existing object.
190
- *
191
- * @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
192
- */
193
- export declare function createFilesystemReportingRowObjectProviderV1(options: FilesystemReportingRowObjectProviderOptionsV1): ReportingRowObjectProviderV1;
194
- /**
195
- * Behavioural conformance for a custom object provider. Writes and deletes
196
- * only under `prefix`; run it against a dedicated test bucket or prefix.
197
- * Resolves with the checks that passed; rejects on the first violation.
198
- *
199
- * @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
200
- */
201
- export declare function runReportingRowObjectProviderConformanceV1(provider: ReportingRowObjectProviderV1, input: ReportingRowObjectLocationV1 & {
202
- prefix: string;
203
- }): Promise<string[]>;
@@ -1,379 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var row_storage_object_exports = {};
30
- __export(row_storage_object_exports, {
31
- REPORTING_ROW_DEFAULT_KEY_TEMPLATE: () => REPORTING_ROW_DEFAULT_KEY_TEMPLATE,
32
- REPORTING_ROW_KEY_PLACEHOLDERS: () => REPORTING_ROW_KEY_PLACEHOLDERS,
33
- REPORTING_ROW_NATIVE_VERSION_REF_MAX_LENGTH: () => REPORTING_ROW_NATIVE_VERSION_REF_MAX_LENGTH,
34
- REPORTING_ROW_OBJECT_REF_MAX_LENGTH: () => REPORTING_ROW_OBJECT_REF_MAX_LENGTH,
35
- assertReportingRowKeyTemplateV1: () => assertReportingRowKeyTemplateV1,
36
- assertReportingRowPrefixV1: () => assertReportingRowPrefixV1,
37
- createFilesystemReportingRowObjectProviderV1: () => createFilesystemReportingRowObjectProviderV1,
38
- renderReportingRowObjectKeyV1: () => renderReportingRowObjectKeyV1,
39
- reportingRowAccountKeyV1: () => reportingRowAccountKeyV1,
40
- reportingRowRevisionKeyV1: () => reportingRowRevisionKeyV1,
41
- runReportingRowObjectProviderConformanceV1: () => runReportingRowObjectProviderConformanceV1
42
- });
43
- module.exports = __toCommonJS(row_storage_object_exports);
44
- var import_crypto = require("crypto");
45
- var import_fs = require("fs");
46
- var path = __toESM(require("path"));
47
- var import_jcs = require('../../utils/jcs.js');
48
- var import_row_storage_errors = require('./row-storage-errors.js');
49
- var import_schedule = require('./schedule.js');
50
- const REPORTING_ROW_OBJECT_REF_MAX_LENGTH = 1024;
51
- const REPORTING_ROW_NATIVE_VERSION_REF_MAX_LENGTH = 1024;
52
- const REPORTING_ROW_KEY_PLACEHOLDERS = Object.freeze([
53
- "prefix",
54
- "namespace_key",
55
- "account_key",
56
- "period_date",
57
- "finality",
58
- "revision_key",
59
- "content_sha256",
60
- "chunk_index"
61
- ]);
62
- const REPORTING_ROW_DEFAULT_KEY_TEMPLATE = "{prefix}/{namespace_key}/{account_key}/{period_date}/{finality}/{revision_key}/{content_sha256}/{chunk_index}";
63
- const PREFIX = /^[A-Za-z0-9_.=-]+(?:\/[A-Za-z0-9_.=-]+)*$/;
64
- const KEY = /^[A-Za-z0-9_.=-]+(?:\/[A-Za-z0-9_.=-]+)*$/;
65
- const PLACEHOLDER = /\{([a-z0-9_]+)\}/g;
66
- function assertReportingRowKeyTemplateV1(template, options = {}) {
67
- if (!template.startsWith("{prefix}/{namespace_key}/")) {
68
- throw new import_row_storage_errors.ReportingRowStoreError("INVALID_INPUT", "key templates must begin with {prefix}/{namespace_key}/");
69
- }
70
- const requiredPlaceholders = ["{content_sha256}", "{chunk_index}"];
71
- if (options.requireRevisionKey ?? true) requiredPlaceholders.push("{revision_key}");
72
- for (const required of requiredPlaceholders) {
73
- if (!template.includes(required)) {
74
- throw new import_row_storage_errors.ReportingRowStoreError(
75
- "INVALID_INPUT",
76
- required === "{revision_key}" ? "key templates must include {revision_key} so every row set has unique object keys. A binding identity includes its template, so add it under a NEW binding ID and keep the old definition configured with `readOnly: true` while rows reference it (rows already written stay readable at their recorded object_ref)" : `key templates must include ${required}`
77
- );
78
- }
79
- }
80
- const unknown = [...template.matchAll(PLACEHOLDER)].map((match) => match[1]).filter((name) => !REPORTING_ROW_KEY_PLACEHOLDERS.includes(name));
81
- if (unknown.length > 0) {
82
- throw new import_row_storage_errors.ReportingRowStoreError("INVALID_INPUT", `unknown key template placeholders: ${unknown.join(", ")}`);
83
- }
84
- const literal = template.replace(PLACEHOLDER, "x");
85
- if (!KEY.test(literal) || literal.split("/").some((segment) => segment === "." || segment === "..")) {
86
- throw new import_row_storage_errors.ReportingRowStoreError("INVALID_INPUT", "key template contains unsafe characters or segments");
87
- }
88
- }
89
- function assertReportingRowPrefixV1(prefix) {
90
- if (!PREFIX.test(prefix) || prefix.length > 512 || prefix.split("/").some((segment) => segment === "." || segment === "..")) {
91
- throw new import_row_storage_errors.ReportingRowStoreError("INVALID_INPUT", "row binding prefix is invalid");
92
- }
93
- }
94
- function reportingRowAccountKeyV1(namespaceKey, accountId) {
95
- return sha256Hex((0, import_jcs.canonicalize)(["adcp.account_key.v1", namespaceKey, accountId]));
96
- }
97
- function reportingRowRevisionKeyV1(rowSetId) {
98
- return sha256Hex((0, import_jcs.canonicalize)(["adcp.revision_key.v1", rowSetId]));
99
- }
100
- function renderReportingRowObjectKeyV1(input) {
101
- const values = {
102
- prefix: input.prefix,
103
- namespace_key: input.namespaceKey,
104
- account_key: reportingRowAccountKeyV1(input.namespaceKey, input.accountId),
105
- // Rendered only when the template uses it, so a template without {period_date} needs no timezone.
106
- period_date: input.template.includes("{period_date}") ? renderedPeriodDate(input.periodStart, input.sourceTimezone) : "",
107
- finality: input.finality ?? "adjustment",
108
- revision_key: reportingRowRevisionKeyV1(input.rowSetId),
109
- content_sha256: input.contentSha256,
110
- chunk_index: String(input.chunkIndex).padStart(6, "0")
111
- };
112
- const key = input.template.replace(PLACEHOLDER, (_, name) => values[name]) + (input.compression === "gzip" ? ".jsonl.gz" : ".jsonl");
113
- if (!KEY.test(key) || key.split("/").some((segment) => segment === "." || segment === "..") || !key.startsWith(`${input.prefix}/${input.namespaceKey}/`)) {
114
- throw new import_row_storage_errors.ReportingRowStoreError("INVALID_INPUT", "rendered object key escapes the binding prefix");
115
- }
116
- if (key.length > REPORTING_ROW_OBJECT_REF_MAX_LENGTH) {
117
- throw new import_row_storage_errors.ReportingRowStoreError(
118
- "INVALID_INPUT",
119
- `rendered object key exceeds ${REPORTING_ROW_OBJECT_REF_MAX_LENGTH} characters (AdCP object_ref bound)`
120
- );
121
- }
122
- return key;
123
- }
124
- function renderedPeriodDate(periodStart, sourceTimezone) {
125
- if (!periodStart) return "undated";
126
- if (!sourceTimezone) {
127
- throw new import_row_storage_errors.ReportingRowStoreError(
128
- "INVALID_INPUT",
129
- "a period start needs its source_timezone to render {period_date}"
130
- );
131
- }
132
- try {
133
- return (0, import_schedule.reportingPeriodDate)(periodStart, sourceTimezone);
134
- } catch {
135
- throw new import_row_storage_errors.ReportingRowStoreError(
136
- "INVALID_INPUT",
137
- "period start or source_timezone is invalid; cannot render {period_date}"
138
- );
139
- }
140
- }
141
- function createFilesystemReportingRowObjectProviderV1(options) {
142
- const roots = /* @__PURE__ */ new Map();
143
- for (const [name, directory] of Object.entries(options.roots)) {
144
- if (!/^[A-Za-z0-9_.-]{1,64}$/.test(name) || !path.isAbsolute(directory)) {
145
- throw new import_row_storage_errors.ReportingRowStoreError("INVALID_INPUT", "filesystem roots need a simple name and an absolute path");
146
- }
147
- roots.set(name, path.resolve(directory));
148
- }
149
- const resolve = (location, key) => {
150
- const root = roots.get(location.root ?? "");
151
- if (!root) throw new import_row_storage_errors.ReportingRowStoreError("UNSAFE_BINDING", "filesystem root is not configured");
152
- const target = path.resolve(root, key);
153
- if (!target.startsWith(root + path.sep)) {
154
- throw new import_row_storage_errors.ReportingRowStoreError("INVALID_INPUT", "object key escapes the filesystem root");
155
- }
156
- return target;
157
- };
158
- const versionOf = (stat) => `${stat.ino}:${stat.birthtimeNs}:${stat.mtimeNs}:${stat.size}`;
159
- const version = async (target) => versionOf(await import_fs.promises.stat(target, { bigint: true }));
160
- return {
161
- name: "filesystem",
162
- rangedReads: true,
163
- validateLocation(location) {
164
- const keys = Object.keys(location);
165
- if (keys.length !== 1 || keys[0] !== "root" || !roots.has(location.root)) {
166
- throw new import_row_storage_errors.ReportingRowStoreError("INVALID_INPUT", "filesystem locations name exactly one configured root");
167
- }
168
- },
169
- async probe(input) {
170
- const root = roots.get(input.location.root ?? "");
171
- if (!root) throw new import_row_storage_errors.ReportingRowStoreError("UNSAFE_BINDING", "filesystem root is not configured");
172
- await import_fs.promises.mkdir(root, { recursive: true });
173
- },
174
- async putIfAbsent(input, context) {
175
- context.signal.throwIfAborted();
176
- const target = resolve(input.location, input.objectRef);
177
- await import_fs.promises.mkdir(path.dirname(target), { recursive: true });
178
- const temporary = `${target}.${(0, import_crypto.randomUUID)()}.tmp`;
179
- const handle = await import_fs.promises.open(temporary, "wx");
180
- try {
181
- await handle.writeFile(input.bytes);
182
- const mtime = Date.now() / 1e3 + (0, import_crypto.randomInt)(0, 1e3) / 1e6;
183
- await handle.utimes(mtime, mtime);
184
- await handle.sync();
185
- } finally {
186
- await handle.close();
187
- }
188
- try {
189
- await import_fs.promises.link(temporary, target);
190
- return { created: true, nativeVersionRef: await version(target) };
191
- } catch (error) {
192
- if (error.code === "EEXIST") {
193
- return { created: false, nativeVersionRef: await version(target) };
194
- }
195
- throw new import_row_storage_errors.ReportingRowStoreError("PROVIDER_UNAVAILABLE", "filesystem write failed");
196
- } finally {
197
- await import_fs.promises.rm(temporary, { force: true });
198
- }
199
- },
200
- async get(input, context) {
201
- context.signal.throwIfAborted();
202
- const target = resolve(input.location, input.objectRef);
203
- let handle;
204
- try {
205
- handle = await import_fs.promises.open(target, "r");
206
- } catch (error) {
207
- if (error.code === "ENOENT") return null;
208
- throw new import_row_storage_errors.ReportingRowStoreError("PROVIDER_UNAVAILABLE", "filesystem read failed");
209
- }
210
- try {
211
- const stat = await handle.stat({ bigint: true });
212
- if (versionOf(stat) !== input.nativeVersionRef) return null;
213
- const size = Number(stat.size);
214
- const offset = input.range?.offset ?? 0;
215
- const length = input.range?.length ?? size - offset;
216
- if (offset < 0 || length < 0 || offset + length > size) {
217
- throw new import_row_storage_errors.ReportingRowStoreError("ROWS_INTEGRITY_FAILED", "requested range exceeds the stored object");
218
- }
219
- if (length > input.maxBytes) {
220
- throw new import_row_storage_errors.ReportingRowStoreError("ROWS_INTEGRITY_FAILED", "stored object exceeds its recorded size");
221
- }
222
- const buffer = Buffer.alloc(length);
223
- await handle.read(buffer, 0, length, offset);
224
- return buffer;
225
- } finally {
226
- await handle.close();
227
- }
228
- },
229
- async stat(input, context) {
230
- context.signal.throwIfAborted();
231
- const target = resolve(input.location, input.objectRef);
232
- try {
233
- const stat = await import_fs.promises.stat(target, { bigint: true });
234
- return versionOf(stat) === input.nativeVersionRef ? { nativeVersionRef: input.nativeVersionRef, sizeBytes: Number(stat.size) } : null;
235
- } catch (error) {
236
- if (error.code === "ENOENT") return null;
237
- throw new import_row_storage_errors.ReportingRowStoreError("PROVIDER_UNAVAILABLE", "filesystem stat failed");
238
- }
239
- },
240
- async delete(input, context) {
241
- context.signal.throwIfAborted();
242
- const target = resolve(input.location, input.objectRef);
243
- try {
244
- if (await version(target) !== input.nativeVersionRef) return "absent";
245
- await import_fs.promises.unlink(target);
246
- return "deleted";
247
- } catch (error) {
248
- if (error.code === "ENOENT") return "absent";
249
- throw new import_row_storage_errors.ReportingRowStoreError("PROVIDER_UNAVAILABLE", "filesystem delete failed");
250
- }
251
- }
252
- };
253
- }
254
- async function runReportingRowObjectProviderConformanceV1(provider, input) {
255
- assertReportingRowPrefixV1(input.prefix);
256
- provider.validateLocation(input.location);
257
- const context = { signal: AbortSignal.timeout(6e4) };
258
- const passed = [];
259
- const key = `${input.prefix}/conformance/${(0, import_crypto.randomUUID)()}.jsonl`;
260
- const first = Buffer.from('{"a":1}\n{"b":2}\n');
261
- const metadata = { "adcp-installation": "conformance", "adcp-intent": "conformance" };
262
- const base = { location: input.location, ...input.credentialRef ? { credentialRef: input.credentialRef } : {} };
263
- await provider.probe(input, context);
264
- passed.push("probe");
265
- const created = await provider.putIfAbsent(
266
- { ...base, objectRef: key, bytes: first, contentType: "application/x-ndjson", metadata },
267
- context
268
- );
269
- if (!created.created || !created.nativeVersionRef) throw new Error("putIfAbsent did not create a new object");
270
- passed.push("create");
271
- const conflict = await provider.putIfAbsent(
272
- { ...base, objectRef: key, bytes: Buffer.from('{"c":3}\n'), contentType: "application/x-ndjson", metadata },
273
- context
274
- );
275
- if (conflict.created || conflict.nativeVersionRef !== created.nativeVersionRef) {
276
- throw new Error("putIfAbsent replaced or re-versioned an existing object");
277
- }
278
- const stored = await provider.get(
279
- { ...base, objectRef: key, nativeVersionRef: created.nativeVersionRef, maxBytes: 1024 },
280
- context
281
- );
282
- if (!stored || !Buffer.from(stored).equals(first))
283
- throw new Error("create-only write did not preserve the first bytes");
284
- passed.push("create-only");
285
- if (provider.rangedReads) {
286
- const ranged = await provider.get(
287
- {
288
- ...base,
289
- objectRef: key,
290
- nativeVersionRef: created.nativeVersionRef,
291
- range: { offset: 8, length: 8 },
292
- maxBytes: 1024
293
- },
294
- context
295
- );
296
- if (!ranged || Buffer.from(ranged).toString("utf8") !== '{"b":2}\n')
297
- throw new Error("ranged read returned wrong bytes");
298
- passed.push("ranged-read");
299
- }
300
- if (await provider.get({ ...base, objectRef: key, nativeVersionRef: "not-a-version", maxBytes: 1024 }, context) !== null) {
301
- throw new Error("get returned bytes for a version that does not exist");
302
- }
303
- passed.push("version-pinned-read");
304
- if (provider.stat) {
305
- const stat = await provider.stat({ ...base, objectRef: key, nativeVersionRef: created.nativeVersionRef }, context);
306
- if (!stat || stat.sizeBytes !== first.byteLength) throw new Error("stat did not report the stored object size");
307
- if (stat.nativeVersionRef !== created.nativeVersionRef) throw new Error("stat did not echo the version it checked");
308
- if (await provider.stat({ ...base, objectRef: key, nativeVersionRef: "not-a-version" }, context) !== null) {
309
- throw new Error("stat returned metadata for a version that does not exist");
310
- }
311
- passed.push("version-pinned-stat");
312
- }
313
- if (await provider.delete({ ...base, objectRef: key, nativeVersionRef: "not-a-version" }, context) !== "absent") {
314
- throw new Error("delete removed an object at a different version");
315
- }
316
- if (await provider.delete({ ...base, objectRef: key, nativeVersionRef: created.nativeVersionRef }, context) !== "deleted") {
317
- throw new Error("delete did not remove the exact version");
318
- }
319
- if (await provider.delete({ ...base, objectRef: key, nativeVersionRef: created.nativeVersionRef }, context) !== "absent") {
320
- throw new Error("repeated delete was not idempotent");
321
- }
322
- passed.push("exact-version-delete");
323
- if (provider.stat && await provider.stat({ ...base, objectRef: key, nativeVersionRef: created.nativeVersionRef }, context) !== null) {
324
- throw new Error("stat returned metadata for a deleted version");
325
- }
326
- const recreated = await provider.putIfAbsent(
327
- { ...base, objectRef: key, bytes: first, contentType: "application/x-ndjson", metadata },
328
- context
329
- );
330
- if (!recreated.created || !recreated.nativeVersionRef)
331
- throw new Error("putIfAbsent did not re-create a deleted object");
332
- if (recreated.nativeVersionRef === created.nativeVersionRef) {
333
- throw new Error("re-creating identical bytes produced the same native version; versions must be write-unique");
334
- }
335
- if (await provider.delete({ ...base, objectRef: key, nativeVersionRef: created.nativeVersionRef }, context) !== "absent") {
336
- throw new Error("delete of a stale version removed or reported a later write");
337
- }
338
- if (provider.stat) {
339
- if (await provider.stat({ ...base, objectRef: key, nativeVersionRef: created.nativeVersionRef }, context) !== null) {
340
- throw new Error("stat of a stale version reported a later write at the same key");
341
- }
342
- const current = await provider.stat(
343
- { ...base, objectRef: key, nativeVersionRef: recreated.nativeVersionRef },
344
- context
345
- );
346
- if (!current || current.sizeBytes !== first.byteLength || current.nativeVersionRef !== recreated.nativeVersionRef) {
347
- throw new Error("stat did not report the re-created object");
348
- }
349
- }
350
- const survivor = await provider.get(
351
- { ...base, objectRef: key, nativeVersionRef: recreated.nativeVersionRef, maxBytes: 1024 },
352
- context
353
- );
354
- if (!survivor || !Buffer.from(survivor).equals(first)) {
355
- throw new Error("delete of a stale version removed a later write with identical bytes");
356
- }
357
- if (await provider.delete({ ...base, objectRef: key, nativeVersionRef: recreated.nativeVersionRef }, context) !== "deleted") {
358
- throw new Error("delete did not remove the re-created version");
359
- }
360
- passed.push("write-unique-version");
361
- return passed;
362
- }
363
- function sha256Hex(value) {
364
- return (0, import_crypto.createHash)("sha256").update(value).digest("hex");
365
- }
366
- // Annotate the CommonJS export names for ESM import in node:
367
- 0 && (module.exports = {
368
- REPORTING_ROW_DEFAULT_KEY_TEMPLATE,
369
- REPORTING_ROW_KEY_PLACEHOLDERS,
370
- REPORTING_ROW_NATIVE_VERSION_REF_MAX_LENGTH,
371
- REPORTING_ROW_OBJECT_REF_MAX_LENGTH,
372
- assertReportingRowKeyTemplateV1,
373
- assertReportingRowPrefixV1,
374
- createFilesystemReportingRowObjectProviderV1,
375
- renderReportingRowObjectKeyV1,
376
- reportingRowAccountKeyV1,
377
- reportingRowRevisionKeyV1,
378
- runReportingRowObjectProviderConformanceV1
379
- });