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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/README.md +54 -0
  2. package/dist/lib/auth/oauth/diagnose.js +3 -11
  3. package/dist/lib/auth/oauth/diagnose.mjs +4 -12
  4. package/dist/lib/auth/oauth/diagnostics.d.mts +2 -1
  5. package/dist/lib/auth/oauth/diagnostics.d.ts +2 -1
  6. package/dist/lib/auth/oauth/diagnostics.js +8 -10
  7. package/dist/lib/auth/oauth/diagnostics.mjs +7 -10
  8. package/dist/lib/core/ConversationTypes.d.mts +8 -3
  9. package/dist/lib/core/ConversationTypes.d.ts +8 -3
  10. package/dist/lib/core/SingleAgentClient.d.mts +5 -3
  11. package/dist/lib/core/SingleAgentClient.d.ts +5 -3
  12. package/dist/lib/core/TaskExecutor.js +5 -1
  13. package/dist/lib/core/TaskExecutor.mjs +5 -1
  14. package/dist/lib/errors/index.d.mts +9 -4
  15. package/dist/lib/errors/index.d.ts +9 -4
  16. package/dist/lib/index.d.mts +3 -3
  17. package/dist/lib/index.d.ts +3 -3
  18. package/dist/lib/index.js +8 -0
  19. package/dist/lib/index.mjs +14 -2
  20. package/dist/lib/negotiation/types.d.mts +20 -39
  21. package/dist/lib/negotiation/types.d.ts +20 -39
  22. package/dist/lib/protocols/index.d.mts +60 -24
  23. package/dist/lib/protocols/index.d.ts +60 -24
  24. package/dist/lib/protocols/index.js +9 -4
  25. package/dist/lib/protocols/index.mjs +3 -0
  26. package/dist/lib/protocols/mcp-modern.js +1 -0
  27. package/dist/lib/protocols/mcp-modern.mjs +2 -1
  28. package/dist/lib/protocols/mcp.js +1 -0
  29. package/dist/lib/protocols/mcp.mjs +2 -1
  30. package/dist/lib/protocols/responseSizeLimit.d.mts +91 -5
  31. package/dist/lib/protocols/responseSizeLimit.d.ts +91 -5
  32. package/dist/lib/protocols/responseSizeLimit.js +195 -31
  33. package/dist/lib/protocols/responseSizeLimit.mjs +192 -31
  34. package/dist/lib/reporting/consumer-runtime.js +2 -1
  35. package/dist/lib/reporting/consumer-runtime.mjs +2 -1
  36. package/dist/lib/reporting/ledger/handler.js +50 -11
  37. package/dist/lib/reporting/ledger/handler.mjs +50 -12
  38. package/dist/lib/reporting/ledger/index.d.mts +17 -14
  39. package/dist/lib/reporting/ledger/index.d.ts +17 -14
  40. package/dist/lib/reporting/ledger/index.js +32 -20
  41. package/dist/lib/reporting/ledger/index.mjs +21 -10
  42. package/dist/lib/reporting/ledger/offering-validation.d.mts +9 -0
  43. package/dist/lib/reporting/ledger/offering-validation.d.ts +9 -0
  44. package/dist/lib/reporting/{gcs/bucket-policy.js → ledger/offering-validation.js} +9 -8
  45. package/dist/lib/reporting/ledger/offering-validation.mjs +8 -0
  46. package/dist/lib/reporting/ledger/receipts.d.mts +48 -0
  47. package/dist/lib/reporting/ledger/receipts.d.ts +48 -0
  48. package/dist/lib/reporting/ledger/receipts.js +186 -0
  49. package/dist/lib/reporting/ledger/receipts.mjs +161 -0
  50. package/dist/lib/reporting/ledger/status-ingest.js +3 -3
  51. package/dist/lib/reporting/ledger/status-ingest.mjs +4 -5
  52. package/dist/lib/reporting/ledger/types.d.mts +43 -0
  53. package/dist/lib/reporting/ledger/types.d.ts +43 -0
  54. package/dist/lib/reporting/ledger/types.js +31 -2
  55. package/dist/lib/reporting/ledger/types.mjs +26 -1
  56. package/dist/lib/reporting/pagination.d.mts +6 -0
  57. package/dist/lib/reporting/pagination.d.ts +6 -0
  58. package/dist/lib/reporting/{gcs/errors.js → pagination.js} +12 -17
  59. package/dist/lib/reporting/pagination.mjs +12 -0
  60. package/dist/lib/reporting/reconciliation.d.mts +1 -0
  61. package/dist/lib/reporting/reconciliation.d.ts +1 -0
  62. package/dist/lib/reporting/reconciliation.js +3 -2
  63. package/dist/lib/reporting/reconciliation.mjs +3 -2
  64. package/dist/lib/reporting/service/index.d.mts +79 -153
  65. package/dist/lib/reporting/service/index.d.ts +79 -153
  66. package/dist/lib/reporting/service/index.js +34 -491
  67. package/dist/lib/reporting/service/index.mjs +36 -510
  68. package/dist/lib/reporting/service/scheduler-support.d.mts +43 -0
  69. package/dist/lib/reporting/service/scheduler-support.d.ts +43 -0
  70. package/dist/lib/reporting/service/scheduler-support.js +125 -0
  71. package/dist/lib/reporting/service/scheduler-support.mjs +96 -0
  72. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  73. package/dist/lib/signing/canonicalize.d.mts +4 -0
  74. package/dist/lib/signing/canonicalize.d.ts +4 -0
  75. package/dist/lib/signing/canonicalize.js +14 -8
  76. package/dist/lib/signing/canonicalize.mjs +14 -8
  77. package/dist/lib/signing/content-digest.d.mts +8 -0
  78. package/dist/lib/signing/content-digest.d.ts +8 -0
  79. package/dist/lib/signing/content-digest.js +11 -5
  80. package/dist/lib/signing/content-digest.mjs +10 -5
  81. package/dist/lib/signing/crypto.d.mts +15 -0
  82. package/dist/lib/signing/crypto.d.ts +15 -0
  83. package/dist/lib/signing/crypto.js +75 -3
  84. package/dist/lib/signing/crypto.mjs +78 -3
  85. package/dist/lib/signing/server.d.mts +1 -1
  86. package/dist/lib/signing/server.d.ts +1 -1
  87. package/dist/lib/signing/server.js +2 -0
  88. package/dist/lib/signing/server.mjs +2 -1
  89. package/dist/lib/signing/signer.js +11 -14
  90. package/dist/lib/signing/signer.mjs +13 -16
  91. package/dist/lib/signing/testing.js +2 -6
  92. package/dist/lib/signing/testing.mjs +3 -7
  93. package/dist/lib/signing/verifier.js +2 -2
  94. package/dist/lib/signing/verifier.mjs +3 -3
  95. package/dist/lib/signing/web-bot-auth.js +122 -43
  96. package/dist/lib/signing/web-bot-auth.mjs +128 -44
  97. package/dist/lib/signing/webhook-verifier.js +2 -2
  98. package/dist/lib/signing/webhook-verifier.mjs +3 -3
  99. package/dist/lib/substitution/compile.js +2 -1
  100. package/dist/lib/substitution/compile.mjs +2 -1
  101. package/dist/lib/substitution/consent-macros.d.mts +4 -0
  102. package/dist/lib/substitution/consent-macros.d.ts +4 -0
  103. package/dist/lib/substitution/consent-macros.js +45 -0
  104. package/dist/lib/substitution/consent-macros.mjs +20 -0
  105. package/dist/lib/substitution/index.d.mts +1 -1
  106. package/dist/lib/substitution/index.d.ts +1 -1
  107. package/dist/lib/substitution/index.js +2 -0
  108. package/dist/lib/substitution/index.mjs +2 -1
  109. package/dist/lib/substitution/translate.d.mts +15 -2
  110. package/dist/lib/substitution/translate.d.ts +15 -2
  111. package/dist/lib/substitution/translate.js +148 -26
  112. package/dist/lib/substitution/translate.mjs +147 -26
  113. package/dist/lib/testing/client.js +2 -1
  114. package/dist/lib/testing/client.mjs +2 -1
  115. package/dist/lib/testing/scenarios/capabilities.js +1 -1
  116. package/dist/lib/testing/scenarios/capabilities.mjs +1 -1
  117. package/dist/lib/testing/storyboard/junit.js +16 -3
  118. package/dist/lib/testing/storyboard/junit.mjs +16 -3
  119. package/dist/lib/testing/storyboard/request-signing/builder.js +12 -14
  120. package/dist/lib/testing/storyboard/request-signing/builder.mjs +13 -15
  121. package/dist/lib/testing/storyboard/runner.js +94 -25
  122. package/dist/lib/testing/storyboard/runner.mjs +94 -25
  123. package/dist/lib/testing/storyboard/signer-grader/grader.js +2 -7
  124. package/dist/lib/testing/storyboard/signer-grader/grader.mjs +2 -7
  125. package/dist/lib/testing/storyboard/types.d.mts +6 -0
  126. package/dist/lib/testing/storyboard/types.d.ts +6 -0
  127. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  128. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  129. package/dist/lib/types/enums.generated.d.mts +3 -0
  130. package/dist/lib/types/enums.generated.d.ts +3 -0
  131. package/dist/lib/types/enums.generated.js +9 -0
  132. package/dist/lib/types/enums.generated.mjs +6 -0
  133. package/dist/lib/validation/schema-loader.js +25 -0
  134. package/dist/lib/validation/schema-loader.mjs +24 -0
  135. package/dist/lib/version.d.mts +3 -3
  136. package/dist/lib/version.d.ts +3 -3
  137. package/dist/lib/version.js +3 -3
  138. package/dist/lib/version.mjs +3 -3
  139. package/docs/TYPE-SUMMARY.md +28 -5
  140. package/docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md +3 -2
  141. package/docs/guides/REPORTING-GCS-FENCE.md +3 -3
  142. package/docs/guides/REPORTING-GCS-MANAGED.md +4 -4
  143. package/docs/guides/REPORTING-LEDGER-CUTOVER.md +7 -7
  144. package/docs/guides/REPORTING-LEDGER.md +107 -51
  145. package/docs/guides/REPORTING-OPERATIONS.md +66 -5
  146. package/docs/guides/REPORTING-STABILITY.md +36 -32
  147. package/docs/guides/UNIVERSAL-MACRO-COMPILATION.md +38 -0
  148. package/docs/guides/VALIDATE-YOUR-AGENT.md +12 -0
  149. package/docs/llms.txt +4 -3
  150. package/docs/migration-14.x-rc-worksheet.md +4 -7
  151. package/docs/migration-reporting-storage-package.md +186 -0
  152. package/examples/README.md +1 -1
  153. package/package.json +14 -78
  154. package/dist/lib/reporting/azure/index.d.mts +0 -31
  155. package/dist/lib/reporting/azure/index.d.ts +0 -31
  156. package/dist/lib/reporting/azure/index.js +0 -266
  157. package/dist/lib/reporting/azure/index.mjs +0 -249
  158. package/dist/lib/reporting/bigquery/index.d.mts +0 -246
  159. package/dist/lib/reporting/bigquery/index.d.ts +0 -246
  160. package/dist/lib/reporting/bigquery/index.js +0 -633
  161. package/dist/lib/reporting/bigquery/index.mjs +0 -594
  162. package/dist/lib/reporting/gcs/adapter.d.mts +0 -38
  163. package/dist/lib/reporting/gcs/adapter.d.ts +0 -38
  164. package/dist/lib/reporting/gcs/adapter.js +0 -342
  165. package/dist/lib/reporting/gcs/adapter.mjs +0 -325
  166. package/dist/lib/reporting/gcs/bucket-policy.d.mts +0 -3
  167. package/dist/lib/reporting/gcs/bucket-policy.d.ts +0 -3
  168. package/dist/lib/reporting/gcs/bucket-policy.mjs +0 -7
  169. package/dist/lib/reporting/gcs/errors.d.mts +0 -11
  170. package/dist/lib/reporting/gcs/errors.d.ts +0 -11
  171. package/dist/lib/reporting/gcs/errors.mjs +0 -16
  172. package/dist/lib/reporting/gcs/fence.d.mts +0 -41
  173. package/dist/lib/reporting/gcs/fence.d.ts +0 -41
  174. package/dist/lib/reporting/gcs/fence.js +0 -250
  175. package/dist/lib/reporting/gcs/fence.mjs +0 -230
  176. package/dist/lib/reporting/gcs/index.d.mts +0 -18
  177. package/dist/lib/reporting/gcs/index.d.ts +0 -18
  178. package/dist/lib/reporting/gcs/index.js +0 -44
  179. package/dist/lib/reporting/gcs/index.mjs +0 -14
  180. package/dist/lib/reporting/gcs/io.d.mts +0 -7
  181. package/dist/lib/reporting/gcs/io.d.ts +0 -7
  182. package/dist/lib/reporting/gcs/io.js +0 -95
  183. package/dist/lib/reporting/gcs/io.mjs +0 -69
  184. package/dist/lib/reporting/gcs/reader.d.mts +0 -67
  185. package/dist/lib/reporting/gcs/reader.d.ts +0 -67
  186. package/dist/lib/reporting/gcs/reader.js +0 -193
  187. package/dist/lib/reporting/gcs/reader.mjs +0 -169
  188. package/dist/lib/reporting/gcs/row-provider.d.mts +0 -39
  189. package/dist/lib/reporting/gcs/row-provider.d.ts +0 -39
  190. package/dist/lib/reporting/gcs/row-provider.js +0 -225
  191. package/dist/lib/reporting/gcs/row-provider.mjs +0 -208
  192. package/dist/lib/reporting/gcs/validation.d.mts +0 -5
  193. package/dist/lib/reporting/gcs/validation.d.ts +0 -5
  194. package/dist/lib/reporting/gcs/validation.js +0 -49
  195. package/dist/lib/reporting/gcs/validation.mjs +0 -25
  196. package/dist/lib/reporting/ledger/change-feed.d.mts +0 -69
  197. package/dist/lib/reporting/ledger/change-feed.d.ts +0 -69
  198. package/dist/lib/reporting/ledger/change-feed.js +0 -107
  199. package/dist/lib/reporting/ledger/change-feed.mjs +0 -80
  200. package/dist/lib/reporting/ledger/managed-postgres.d.mts +0 -293
  201. package/dist/lib/reporting/ledger/managed-postgres.d.ts +0 -293
  202. package/dist/lib/reporting/ledger/managed-postgres.js +0 -2346
  203. package/dist/lib/reporting/ledger/managed-postgres.mjs +0 -2332
  204. package/dist/lib/reporting/ledger/managed-router.d.mts +0 -148
  205. package/dist/lib/reporting/ledger/managed-router.d.ts +0 -148
  206. package/dist/lib/reporting/ledger/managed-router.js +0 -280
  207. package/dist/lib/reporting/ledger/managed-router.mjs +0 -258
  208. package/dist/lib/reporting/ledger/managed.d.mts +0 -535
  209. package/dist/lib/reporting/ledger/managed.d.ts +0 -535
  210. package/dist/lib/reporting/ledger/managed.js +0 -761
  211. package/dist/lib/reporting/ledger/managed.mjs +0 -729
  212. package/dist/lib/reporting/ledger/notification-activity.d.mts +0 -332
  213. package/dist/lib/reporting/ledger/notification-activity.d.ts +0 -332
  214. package/dist/lib/reporting/ledger/notification-activity.js +0 -1366
  215. package/dist/lib/reporting/ledger/notification-activity.mjs +0 -1337
  216. package/dist/lib/reporting/ledger/object-writes.d.mts +0 -128
  217. package/dist/lib/reporting/ledger/object-writes.d.ts +0 -128
  218. package/dist/lib/reporting/ledger/object-writes.js +0 -147
  219. package/dist/lib/reporting/ledger/object-writes.mjs +0 -114
  220. package/dist/lib/reporting/ledger/postgres.d.mts +0 -689
  221. package/dist/lib/reporting/ledger/postgres.d.ts +0 -689
  222. package/dist/lib/reporting/ledger/postgres.js +0 -4462
  223. package/dist/lib/reporting/ledger/postgres.mjs +0 -4462
  224. package/dist/lib/reporting/ledger/row-storage-migration.d.mts +0 -59
  225. package/dist/lib/reporting/ledger/row-storage-migration.d.ts +0 -59
  226. package/dist/lib/reporting/ledger/row-storage-migration.js +0 -365
  227. package/dist/lib/reporting/ledger/row-storage-migration.mjs +0 -339
  228. package/dist/lib/reporting/ledger/row-storage-object.d.mts +0 -203
  229. package/dist/lib/reporting/ledger/row-storage-object.d.ts +0 -203
  230. package/dist/lib/reporting/ledger/row-storage-object.js +0 -379
  231. package/dist/lib/reporting/ledger/row-storage-object.mjs +0 -335
  232. package/dist/lib/reporting/ledger/row-storage-provider-io.d.mts +0 -44
  233. package/dist/lib/reporting/ledger/row-storage-provider-io.d.ts +0 -44
  234. package/dist/lib/reporting/ledger/row-storage-provider-io.js +0 -142
  235. package/dist/lib/reporting/ledger/row-storage-provider-io.mjs +0 -111
  236. package/dist/lib/reporting/ledger/row-storage.d.mts +0 -316
  237. package/dist/lib/reporting/ledger/row-storage.d.ts +0 -316
  238. package/dist/lib/reporting/ledger/row-storage.js +0 -812
  239. package/dist/lib/reporting/ledger/row-storage.mjs +0 -802
  240. package/dist/lib/reporting/s3/index.d.mts +0 -34
  241. package/dist/lib/reporting/s3/index.d.ts +0 -34
  242. package/dist/lib/reporting/s3/index.js +0 -347
  243. package/dist/lib/reporting/s3/index.mjs +0 -340
  244. package/dist/lib/reporting/service/maintenance.d.mts +0 -148
  245. package/dist/lib/reporting/service/maintenance.d.ts +0 -148
  246. package/dist/lib/reporting/service/maintenance.js +0 -185
  247. package/dist/lib/reporting/service/maintenance.mjs +0 -159
  248. package/examples/reliable-reporting-service/README.md +0 -169
@@ -1,128 +0,0 @@
1
- /**
2
- * @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
3
- */
4
- export declare class ReportingObjectWriteConflictError extends Error {
5
- constructor();
6
- }
7
- /**
8
- * Symbol branding preserves errors when CJS stores are paired with ESM fences.
9
- *
10
- * @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
11
- */
12
- export declare function isReportingObjectWriteConflictError(error: unknown): boolean;
13
- /**
14
- * @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
15
- */
16
- export declare class ReportingObjectWriteNotRevokedError extends Error {
17
- constructor();
18
- }
19
- /**
20
- * @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
21
- */
22
- export declare function isReportingObjectWriteNotRevokedError(error: unknown): boolean;
23
- /**
24
- * Non-secret destination identity, scoped to the store's isolated tenant database.
25
- *
26
- * @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
27
- */
28
- export interface ReportingObjectWriteScopeV1 {
29
- account_id: string;
30
- destination_ref: string;
31
- generation: number;
32
- }
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 interface ReportingObjectWriteV1 {
37
- bucket: string;
38
- object_name: string;
39
- sha256: string;
40
- size_bytes: number;
41
- }
42
- /**
43
- * @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
44
- */
45
- export interface ReportingObjectWriteBindingV1 {
46
- bucket: string;
47
- /** SHA-256 of a host-owned deployment namespace; immutable per authorization generation. */
48
- namespace_key: string;
49
- }
50
- /**
51
- * @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
52
- */
53
- export interface ReportingObjectWriteContextV1 {
54
- signal?: AbortSignal;
55
- }
56
- /**
57
- * @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
58
- */
59
- export declare function reportingObjectWriteScopeKey(scope: ReportingObjectWriteScopeV1): string;
60
- /**
61
- * @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
62
- */
63
- export declare function reportingObjectWriteName(scope: ReportingObjectWriteScopeV1, binding: ReportingObjectWriteBindingV1, planId: string, index: number): string;
64
- /**
65
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
66
- */
67
- export interface ReportingObjectWritePlanV1 extends ReportingObjectWriteScopeV1 {
68
- provider: ReportingObjectWriteBindingV1;
69
- /** Stable opaque identity for the same logical delivery across retries. */
70
- plan_id: string;
71
- objects: readonly ReportingObjectWriteV1[];
72
- }
73
- /**
74
- * @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
75
- */
76
- export interface ReportingObjectWriteCursorV1 {
77
- plan_id: string;
78
- object_index: number;
79
- }
80
- /**
81
- * @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
82
- */
83
- export interface ReportingObjectWriteStoreV1 {
84
- /** Registration and destination revocation MUST share one authority/lock boundary. */
85
- registerObjectWritePlan(plan: ReportingObjectWritePlanV1, context?: ReportingObjectWriteContextV1): Promise<'registered' | 'unchanged' | 'revoked'>;
86
- /** Authoritative cleanup routing, available only for a closed generation. */
87
- getObjectWriteBinding(scope: ReportingObjectWriteScopeV1, context?: ReportingObjectWriteContextV1): Promise<ReportingObjectWriteBindingV1 | null>;
88
- /** Only reads closed (revoked) generations; inventory never prunes automatically. */
89
- listRevokedObjectWrites(scope: ReportingObjectWriteScopeV1, options?: {
90
- after?: ReportingObjectWriteCursorV1;
91
- limit?: number;
92
- }, context?: ReportingObjectWriteContextV1): Promise<Array<ReportingObjectWriteV1 & ReportingObjectWriteCursorV1>>;
93
- /** Trusted provider code calls this only after verifying a persistent tombstone. */
94
- markObjectWriteFenced(input: ReportingObjectWriteScopeV1 & ReportingObjectWriteCursorV1 & {
95
- tombstone_generation: string;
96
- }, context?: ReportingObjectWriteContextV1): Promise<void>;
97
- }
98
- /**
99
- * Apply after REPORTING_MANAGED_DELIVERY_MIGRATION. Additive and independently opt-in.
100
- *
101
- * @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
102
- */
103
- export declare const REPORTING_OBJECT_WRITE_MIGRATION = "\nCREATE TABLE IF NOT EXISTS adcp_reporting_object_write_bindings (\n account_id TEXT NOT NULL,\n destination_ref TEXT NOT NULL,\n generation BIGINT NOT NULL,\n bucket TEXT NOT NULL,\n namespace_key TEXT NOT NULL CHECK (namespace_key ~ '^[a-f0-9]{64}$'),\n PRIMARY KEY (account_id, destination_ref, generation),\n FOREIGN KEY (account_id, destination_ref, generation)\n REFERENCES adcp_reporting_destination_authorizations(account_id, destination_ref, generation)\n);\nCREATE TABLE IF NOT EXISTS adcp_reporting_object_write_plans (\n account_id TEXT NOT NULL,\n destination_ref TEXT NOT NULL,\n generation BIGINT NOT NULL,\n plan_id TEXT NOT NULL CHECK (plan_id ~ '^[a-f0-9]{64}$'),\n fingerprint TEXT NOT NULL,\n PRIMARY KEY (account_id, destination_ref, generation, plan_id),\n FOREIGN KEY (account_id, destination_ref, generation)\n REFERENCES adcp_reporting_destination_authorizations(account_id, destination_ref, generation)\n);\nCREATE TABLE IF NOT EXISTS adcp_reporting_object_writes (\n account_id TEXT NOT NULL,\n destination_ref TEXT NOT NULL,\n generation BIGINT NOT NULL,\n plan_id TEXT NOT NULL,\n object_index INTEGER NOT NULL CHECK (object_index >= 0 AND object_index < 128),\n bucket TEXT NOT NULL,\n object_name TEXT NOT NULL,\n sha256 TEXT NOT NULL CHECK (sha256 ~ '^[a-f0-9]{64}$'),\n size_bytes BIGINT NOT NULL CHECK (size_bytes >= 0 AND size_bytes <= 67108864),\n fenced_at TIMESTAMPTZ,\n tombstone_generation TEXT,\n PRIMARY KEY (account_id, destination_ref, generation, plan_id, object_index),\n UNIQUE (bucket, object_name),\n FOREIGN KEY (account_id, destination_ref, generation, plan_id)\n REFERENCES adcp_reporting_object_write_plans(account_id, destination_ref, generation, plan_id)\n);\n";
104
- /**
105
- * @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
106
- */
107
- export declare function assertReportingObjectWriteScope(scope: ReportingObjectWriteScopeV1): void;
108
- /**
109
- * @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
110
- */
111
- export declare function reportingObjectWritePlanFingerprint(plan: ReportingObjectWritePlanV1): string;
112
- /**
113
- * Opt-in authority for complete provider adapters; the original primitive store port is unchanged.
114
- *
115
- * @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
116
- */
117
- export interface ReportingObjectWriteAuthorityStoreV1 extends ReportingObjectWriteStoreV1 {
118
- probeObjectWriteAuthority(context?: ReportingObjectWriteContextV1): Promise<boolean>;
119
- getObjectWriteAuthorityId(context?: ReportingObjectWriteContextV1): Promise<string>;
120
- getAuthorizedObjectWriteBinding(scope: ReportingObjectWriteScopeV1, context?: ReportingObjectWriteContextV1): Promise<ReportingObjectWriteBindingV1 | null>;
121
- getObjectWritePlan(scope: ReportingObjectWriteScopeV1, planId: string, context?: ReportingObjectWriteContextV1): Promise<ReportingObjectWritePlanV1 | null>;
122
- }
123
- /**
124
- * PostgreSQL 13+; apply after REPORTING_OBJECT_WRITE_MIGRATION. Identity survives replica/worker restart.
125
- *
126
- * @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
127
- */
128
- export declare const REPORTING_OBJECT_WRITE_AUTHORITY_MIGRATION = "\nCREATE TABLE IF NOT EXISTS adcp_reporting_object_write_authority (\n singleton BOOLEAN PRIMARY KEY DEFAULT TRUE CHECK (singleton),\n installation_id UUID NOT NULL DEFAULT gen_random_uuid(),\n schema_version INTEGER NOT NULL DEFAULT 1 CHECK (schema_version = 1)\n);\nINSERT INTO adcp_reporting_object_write_authority (singleton) VALUES (TRUE) ON CONFLICT DO NOTHING;\n";
@@ -1,128 +0,0 @@
1
- /**
2
- * @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
3
- */
4
- export declare class ReportingObjectWriteConflictError extends Error {
5
- constructor();
6
- }
7
- /**
8
- * Symbol branding preserves errors when CJS stores are paired with ESM fences.
9
- *
10
- * @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
11
- */
12
- export declare function isReportingObjectWriteConflictError(error: unknown): boolean;
13
- /**
14
- * @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
15
- */
16
- export declare class ReportingObjectWriteNotRevokedError extends Error {
17
- constructor();
18
- }
19
- /**
20
- * @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
21
- */
22
- export declare function isReportingObjectWriteNotRevokedError(error: unknown): boolean;
23
- /**
24
- * Non-secret destination identity, scoped to the store's isolated tenant database.
25
- *
26
- * @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
27
- */
28
- export interface ReportingObjectWriteScopeV1 {
29
- account_id: string;
30
- destination_ref: string;
31
- generation: number;
32
- }
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 interface ReportingObjectWriteV1 {
37
- bucket: string;
38
- object_name: string;
39
- sha256: string;
40
- size_bytes: number;
41
- }
42
- /**
43
- * @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
44
- */
45
- export interface ReportingObjectWriteBindingV1 {
46
- bucket: string;
47
- /** SHA-256 of a host-owned deployment namespace; immutable per authorization generation. */
48
- namespace_key: string;
49
- }
50
- /**
51
- * @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
52
- */
53
- export interface ReportingObjectWriteContextV1 {
54
- signal?: AbortSignal;
55
- }
56
- /**
57
- * @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
58
- */
59
- export declare function reportingObjectWriteScopeKey(scope: ReportingObjectWriteScopeV1): string;
60
- /**
61
- * @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
62
- */
63
- export declare function reportingObjectWriteName(scope: ReportingObjectWriteScopeV1, binding: ReportingObjectWriteBindingV1, planId: string, index: number): string;
64
- /**
65
- * @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
66
- */
67
- export interface ReportingObjectWritePlanV1 extends ReportingObjectWriteScopeV1 {
68
- provider: ReportingObjectWriteBindingV1;
69
- /** Stable opaque identity for the same logical delivery across retries. */
70
- plan_id: string;
71
- objects: readonly ReportingObjectWriteV1[];
72
- }
73
- /**
74
- * @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
75
- */
76
- export interface ReportingObjectWriteCursorV1 {
77
- plan_id: string;
78
- object_index: number;
79
- }
80
- /**
81
- * @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
82
- */
83
- export interface ReportingObjectWriteStoreV1 {
84
- /** Registration and destination revocation MUST share one authority/lock boundary. */
85
- registerObjectWritePlan(plan: ReportingObjectWritePlanV1, context?: ReportingObjectWriteContextV1): Promise<'registered' | 'unchanged' | 'revoked'>;
86
- /** Authoritative cleanup routing, available only for a closed generation. */
87
- getObjectWriteBinding(scope: ReportingObjectWriteScopeV1, context?: ReportingObjectWriteContextV1): Promise<ReportingObjectWriteBindingV1 | null>;
88
- /** Only reads closed (revoked) generations; inventory never prunes automatically. */
89
- listRevokedObjectWrites(scope: ReportingObjectWriteScopeV1, options?: {
90
- after?: ReportingObjectWriteCursorV1;
91
- limit?: number;
92
- }, context?: ReportingObjectWriteContextV1): Promise<Array<ReportingObjectWriteV1 & ReportingObjectWriteCursorV1>>;
93
- /** Trusted provider code calls this only after verifying a persistent tombstone. */
94
- markObjectWriteFenced(input: ReportingObjectWriteScopeV1 & ReportingObjectWriteCursorV1 & {
95
- tombstone_generation: string;
96
- }, context?: ReportingObjectWriteContextV1): Promise<void>;
97
- }
98
- /**
99
- * Apply after REPORTING_MANAGED_DELIVERY_MIGRATION. Additive and independently opt-in.
100
- *
101
- * @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
102
- */
103
- export declare const REPORTING_OBJECT_WRITE_MIGRATION = "\nCREATE TABLE IF NOT EXISTS adcp_reporting_object_write_bindings (\n account_id TEXT NOT NULL,\n destination_ref TEXT NOT NULL,\n generation BIGINT NOT NULL,\n bucket TEXT NOT NULL,\n namespace_key TEXT NOT NULL CHECK (namespace_key ~ '^[a-f0-9]{64}$'),\n PRIMARY KEY (account_id, destination_ref, generation),\n FOREIGN KEY (account_id, destination_ref, generation)\n REFERENCES adcp_reporting_destination_authorizations(account_id, destination_ref, generation)\n);\nCREATE TABLE IF NOT EXISTS adcp_reporting_object_write_plans (\n account_id TEXT NOT NULL,\n destination_ref TEXT NOT NULL,\n generation BIGINT NOT NULL,\n plan_id TEXT NOT NULL CHECK (plan_id ~ '^[a-f0-9]{64}$'),\n fingerprint TEXT NOT NULL,\n PRIMARY KEY (account_id, destination_ref, generation, plan_id),\n FOREIGN KEY (account_id, destination_ref, generation)\n REFERENCES adcp_reporting_destination_authorizations(account_id, destination_ref, generation)\n);\nCREATE TABLE IF NOT EXISTS adcp_reporting_object_writes (\n account_id TEXT NOT NULL,\n destination_ref TEXT NOT NULL,\n generation BIGINT NOT NULL,\n plan_id TEXT NOT NULL,\n object_index INTEGER NOT NULL CHECK (object_index >= 0 AND object_index < 128),\n bucket TEXT NOT NULL,\n object_name TEXT NOT NULL,\n sha256 TEXT NOT NULL CHECK (sha256 ~ '^[a-f0-9]{64}$'),\n size_bytes BIGINT NOT NULL CHECK (size_bytes >= 0 AND size_bytes <= 67108864),\n fenced_at TIMESTAMPTZ,\n tombstone_generation TEXT,\n PRIMARY KEY (account_id, destination_ref, generation, plan_id, object_index),\n UNIQUE (bucket, object_name),\n FOREIGN KEY (account_id, destination_ref, generation, plan_id)\n REFERENCES adcp_reporting_object_write_plans(account_id, destination_ref, generation, plan_id)\n);\n";
104
- /**
105
- * @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
106
- */
107
- export declare function assertReportingObjectWriteScope(scope: ReportingObjectWriteScopeV1): void;
108
- /**
109
- * @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
110
- */
111
- export declare function reportingObjectWritePlanFingerprint(plan: ReportingObjectWritePlanV1): string;
112
- /**
113
- * Opt-in authority for complete provider adapters; the original primitive store port is unchanged.
114
- *
115
- * @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
116
- */
117
- export interface ReportingObjectWriteAuthorityStoreV1 extends ReportingObjectWriteStoreV1 {
118
- probeObjectWriteAuthority(context?: ReportingObjectWriteContextV1): Promise<boolean>;
119
- getObjectWriteAuthorityId(context?: ReportingObjectWriteContextV1): Promise<string>;
120
- getAuthorizedObjectWriteBinding(scope: ReportingObjectWriteScopeV1, context?: ReportingObjectWriteContextV1): Promise<ReportingObjectWriteBindingV1 | null>;
121
- getObjectWritePlan(scope: ReportingObjectWriteScopeV1, planId: string, context?: ReportingObjectWriteContextV1): Promise<ReportingObjectWritePlanV1 | null>;
122
- }
123
- /**
124
- * PostgreSQL 13+; apply after REPORTING_OBJECT_WRITE_MIGRATION. Identity survives replica/worker restart.
125
- *
126
- * @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
127
- */
128
- export declare const REPORTING_OBJECT_WRITE_AUTHORITY_MIGRATION = "\nCREATE TABLE IF NOT EXISTS adcp_reporting_object_write_authority (\n singleton BOOLEAN PRIMARY KEY DEFAULT TRUE CHECK (singleton),\n installation_id UUID NOT NULL DEFAULT gen_random_uuid(),\n schema_version INTEGER NOT NULL DEFAULT 1 CHECK (schema_version = 1)\n);\nINSERT INTO adcp_reporting_object_write_authority (singleton) VALUES (TRUE) ON CONFLICT DO NOTHING;\n";
@@ -1,147 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var object_writes_exports = {};
20
- __export(object_writes_exports, {
21
- REPORTING_OBJECT_WRITE_AUTHORITY_MIGRATION: () => REPORTING_OBJECT_WRITE_AUTHORITY_MIGRATION,
22
- REPORTING_OBJECT_WRITE_MIGRATION: () => REPORTING_OBJECT_WRITE_MIGRATION,
23
- ReportingObjectWriteConflictError: () => ReportingObjectWriteConflictError,
24
- ReportingObjectWriteNotRevokedError: () => ReportingObjectWriteNotRevokedError,
25
- assertReportingObjectWriteScope: () => assertReportingObjectWriteScope,
26
- isReportingObjectWriteConflictError: () => isReportingObjectWriteConflictError,
27
- isReportingObjectWriteNotRevokedError: () => isReportingObjectWriteNotRevokedError,
28
- reportingObjectWriteName: () => reportingObjectWriteName,
29
- reportingObjectWritePlanFingerprint: () => reportingObjectWritePlanFingerprint,
30
- reportingObjectWriteScopeKey: () => reportingObjectWriteScopeKey
31
- });
32
- module.exports = __toCommonJS(object_writes_exports);
33
- var import_node_crypto = require("node:crypto");
34
- var import_jcs = require('../../utils/jcs.js');
35
- class ReportingObjectWriteConflictError extends Error {
36
- constructor() {
37
- super("Reporting object-write plan conflict");
38
- this.name = "ReportingObjectWriteConflictError";
39
- Object.defineProperty(this, /* @__PURE__ */ Symbol.for("adcp.reporting.objectWriteConflict"), { value: true });
40
- }
41
- }
42
- function isReportingObjectWriteConflictError(error) {
43
- return !!error && typeof error === "object" && error[/* @__PURE__ */ Symbol.for("adcp.reporting.objectWriteConflict")] === true;
44
- }
45
- class ReportingObjectWriteNotRevokedError extends Error {
46
- constructor() {
47
- super("Reporting object-write generation is not revoked");
48
- this.name = "ReportingObjectWriteNotRevokedError";
49
- Object.defineProperty(this, /* @__PURE__ */ Symbol.for("adcp.reporting.objectWriteNotRevoked"), { value: true });
50
- }
51
- }
52
- function isReportingObjectWriteNotRevokedError(error) {
53
- return !!error && typeof error === "object" && error[/* @__PURE__ */ Symbol.for("adcp.reporting.objectWriteNotRevoked")] === true;
54
- }
55
- function reportingObjectWriteScopeKey(scope) {
56
- assertReportingObjectWriteScope(scope);
57
- return (0, import_node_crypto.createHash)("sha256").update(JSON.stringify([scope.account_id, scope.destination_ref, scope.generation])).digest("hex");
58
- }
59
- function reportingObjectWriteName(scope, binding, planId, index) {
60
- return `adcp-reporting/${binding.namespace_key}/${reportingObjectWriteScopeKey(scope)}/${planId}/${index}`;
61
- }
62
- const REPORTING_OBJECT_WRITE_MIGRATION = `
63
- CREATE TABLE IF NOT EXISTS adcp_reporting_object_write_bindings (
64
- account_id TEXT NOT NULL,
65
- destination_ref TEXT NOT NULL,
66
- generation BIGINT NOT NULL,
67
- bucket TEXT NOT NULL,
68
- namespace_key TEXT NOT NULL CHECK (namespace_key ~ '^[a-f0-9]{64}$'),
69
- PRIMARY KEY (account_id, destination_ref, generation),
70
- FOREIGN KEY (account_id, destination_ref, generation)
71
- REFERENCES adcp_reporting_destination_authorizations(account_id, destination_ref, generation)
72
- );
73
- CREATE TABLE IF NOT EXISTS adcp_reporting_object_write_plans (
74
- account_id TEXT NOT NULL,
75
- destination_ref TEXT NOT NULL,
76
- generation BIGINT NOT NULL,
77
- plan_id TEXT NOT NULL CHECK (plan_id ~ '^[a-f0-9]{64}$'),
78
- fingerprint TEXT NOT NULL,
79
- PRIMARY KEY (account_id, destination_ref, generation, plan_id),
80
- FOREIGN KEY (account_id, destination_ref, generation)
81
- REFERENCES adcp_reporting_destination_authorizations(account_id, destination_ref, generation)
82
- );
83
- CREATE TABLE IF NOT EXISTS adcp_reporting_object_writes (
84
- account_id TEXT NOT NULL,
85
- destination_ref TEXT NOT NULL,
86
- generation BIGINT NOT NULL,
87
- plan_id TEXT NOT NULL,
88
- object_index INTEGER NOT NULL CHECK (object_index >= 0 AND object_index < 128),
89
- bucket TEXT NOT NULL,
90
- object_name TEXT NOT NULL,
91
- sha256 TEXT NOT NULL CHECK (sha256 ~ '^[a-f0-9]{64}$'),
92
- size_bytes BIGINT NOT NULL CHECK (size_bytes >= 0 AND size_bytes <= 67108864),
93
- fenced_at TIMESTAMPTZ,
94
- tombstone_generation TEXT,
95
- PRIMARY KEY (account_id, destination_ref, generation, plan_id, object_index),
96
- UNIQUE (bucket, object_name),
97
- FOREIGN KEY (account_id, destination_ref, generation, plan_id)
98
- REFERENCES adcp_reporting_object_write_plans(account_id, destination_ref, generation, plan_id)
99
- );
100
- `;
101
- function assertReportingObjectWriteScope(scope) {
102
- if (!scope || ![scope.account_id, scope.destination_ref].every((v) => typeof v === "string" && v.length > 0 && v.length <= 255) || !Number.isSafeInteger(scope.generation) || scope.generation < 1)
103
- throw new Error("Invalid reporting object-write scope");
104
- }
105
- function reportingObjectWritePlanFingerprint(plan) {
106
- assertReportingObjectWriteScope(plan);
107
- if (!plan.provider || typeof plan.provider.bucket !== "string" || !/^[a-z0-9][a-z0-9.-]{1,220}[a-z0-9]$/.test(plan.provider.bucket) || typeof plan.provider.namespace_key !== "string" || !/^[a-f0-9]{64}$/.test(plan.provider.namespace_key) || typeof plan.plan_id !== "string" || !/^[a-f0-9]{64}$/.test(plan.plan_id) || !Array.isArray(plan.objects) || plan.objects.length < 1 || plan.objects.length > 128 || plan.objects.some(
108
- (o, i) => !o || typeof o.bucket !== "string" || !/^[a-z0-9][a-z0-9.-]{1,220}[a-z0-9]$/.test(o.bucket) || o.bucket !== plan.provider.bucket || o.object_name !== reportingObjectWriteName(plan, plan.provider, plan.plan_id, i) || typeof o.object_name !== "string" || !/^[A-Za-z0-9/_-]{1,1024}$/.test(o.object_name) || typeof o.sha256 !== "string" || !/^[a-f0-9]{64}$/.test(o.sha256) || !Number.isSafeInteger(o.size_bytes) || o.size_bytes < 0 || o.size_bytes > 64 * 1024 * 1024
109
- ) || plan.objects.reduce((total, o) => total + o.size_bytes, 0) > 64 * 1024 * 1024 || new Set(plan.objects.map((o) => JSON.stringify([o.bucket, o.object_name]))).size !== plan.objects.length)
110
- throw new Error("Invalid reporting object-write plan");
111
- return (0, import_node_crypto.createHash)("sha256").update(
112
- (0, import_jcs.canonicalize)({
113
- account_id: plan.account_id,
114
- destination_ref: plan.destination_ref,
115
- generation: plan.generation,
116
- plan_id: plan.plan_id,
117
- provider: { bucket: plan.provider.bucket, namespace_key: plan.provider.namespace_key },
118
- objects: plan.objects.map(({ bucket, object_name, sha256, size_bytes }) => ({
119
- bucket,
120
- object_name,
121
- sha256,
122
- size_bytes
123
- }))
124
- })
125
- ).digest("hex");
126
- }
127
- const REPORTING_OBJECT_WRITE_AUTHORITY_MIGRATION = `
128
- CREATE TABLE IF NOT EXISTS adcp_reporting_object_write_authority (
129
- singleton BOOLEAN PRIMARY KEY DEFAULT TRUE CHECK (singleton),
130
- installation_id UUID NOT NULL DEFAULT gen_random_uuid(),
131
- schema_version INTEGER NOT NULL DEFAULT 1 CHECK (schema_version = 1)
132
- );
133
- INSERT INTO adcp_reporting_object_write_authority (singleton) VALUES (TRUE) ON CONFLICT DO NOTHING;
134
- `;
135
- // Annotate the CommonJS export names for ESM import in node:
136
- 0 && (module.exports = {
137
- REPORTING_OBJECT_WRITE_AUTHORITY_MIGRATION,
138
- REPORTING_OBJECT_WRITE_MIGRATION,
139
- ReportingObjectWriteConflictError,
140
- ReportingObjectWriteNotRevokedError,
141
- assertReportingObjectWriteScope,
142
- isReportingObjectWriteConflictError,
143
- isReportingObjectWriteNotRevokedError,
144
- reportingObjectWriteName,
145
- reportingObjectWritePlanFingerprint,
146
- reportingObjectWriteScopeKey
147
- });
@@ -1,114 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { canonicalize } from "../../utils/jcs.mjs";
3
- class ReportingObjectWriteConflictError extends Error {
4
- constructor() {
5
- super("Reporting object-write plan conflict");
6
- this.name = "ReportingObjectWriteConflictError";
7
- Object.defineProperty(this, /* @__PURE__ */ Symbol.for("adcp.reporting.objectWriteConflict"), { value: true });
8
- }
9
- }
10
- function isReportingObjectWriteConflictError(error) {
11
- return !!error && typeof error === "object" && error[/* @__PURE__ */ Symbol.for("adcp.reporting.objectWriteConflict")] === true;
12
- }
13
- class ReportingObjectWriteNotRevokedError extends Error {
14
- constructor() {
15
- super("Reporting object-write generation is not revoked");
16
- this.name = "ReportingObjectWriteNotRevokedError";
17
- Object.defineProperty(this, /* @__PURE__ */ Symbol.for("adcp.reporting.objectWriteNotRevoked"), { value: true });
18
- }
19
- }
20
- function isReportingObjectWriteNotRevokedError(error) {
21
- return !!error && typeof error === "object" && error[/* @__PURE__ */ Symbol.for("adcp.reporting.objectWriteNotRevoked")] === true;
22
- }
23
- function reportingObjectWriteScopeKey(scope) {
24
- assertReportingObjectWriteScope(scope);
25
- return createHash("sha256").update(JSON.stringify([scope.account_id, scope.destination_ref, scope.generation])).digest("hex");
26
- }
27
- function reportingObjectWriteName(scope, binding, planId, index) {
28
- return `adcp-reporting/${binding.namespace_key}/${reportingObjectWriteScopeKey(scope)}/${planId}/${index}`;
29
- }
30
- const REPORTING_OBJECT_WRITE_MIGRATION = `
31
- CREATE TABLE IF NOT EXISTS adcp_reporting_object_write_bindings (
32
- account_id TEXT NOT NULL,
33
- destination_ref TEXT NOT NULL,
34
- generation BIGINT NOT NULL,
35
- bucket TEXT NOT NULL,
36
- namespace_key TEXT NOT NULL CHECK (namespace_key ~ '^[a-f0-9]{64}$'),
37
- PRIMARY KEY (account_id, destination_ref, generation),
38
- FOREIGN KEY (account_id, destination_ref, generation)
39
- REFERENCES adcp_reporting_destination_authorizations(account_id, destination_ref, generation)
40
- );
41
- CREATE TABLE IF NOT EXISTS adcp_reporting_object_write_plans (
42
- account_id TEXT NOT NULL,
43
- destination_ref TEXT NOT NULL,
44
- generation BIGINT NOT NULL,
45
- plan_id TEXT NOT NULL CHECK (plan_id ~ '^[a-f0-9]{64}$'),
46
- fingerprint TEXT NOT NULL,
47
- PRIMARY KEY (account_id, destination_ref, generation, plan_id),
48
- FOREIGN KEY (account_id, destination_ref, generation)
49
- REFERENCES adcp_reporting_destination_authorizations(account_id, destination_ref, generation)
50
- );
51
- CREATE TABLE IF NOT EXISTS adcp_reporting_object_writes (
52
- account_id TEXT NOT NULL,
53
- destination_ref TEXT NOT NULL,
54
- generation BIGINT NOT NULL,
55
- plan_id TEXT NOT NULL,
56
- object_index INTEGER NOT NULL CHECK (object_index >= 0 AND object_index < 128),
57
- bucket TEXT NOT NULL,
58
- object_name TEXT NOT NULL,
59
- sha256 TEXT NOT NULL CHECK (sha256 ~ '^[a-f0-9]{64}$'),
60
- size_bytes BIGINT NOT NULL CHECK (size_bytes >= 0 AND size_bytes <= 67108864),
61
- fenced_at TIMESTAMPTZ,
62
- tombstone_generation TEXT,
63
- PRIMARY KEY (account_id, destination_ref, generation, plan_id, object_index),
64
- UNIQUE (bucket, object_name),
65
- FOREIGN KEY (account_id, destination_ref, generation, plan_id)
66
- REFERENCES adcp_reporting_object_write_plans(account_id, destination_ref, generation, plan_id)
67
- );
68
- `;
69
- function assertReportingObjectWriteScope(scope) {
70
- if (!scope || ![scope.account_id, scope.destination_ref].every((v) => typeof v === "string" && v.length > 0 && v.length <= 255) || !Number.isSafeInteger(scope.generation) || scope.generation < 1)
71
- throw new Error("Invalid reporting object-write scope");
72
- }
73
- function reportingObjectWritePlanFingerprint(plan) {
74
- assertReportingObjectWriteScope(plan);
75
- if (!plan.provider || typeof plan.provider.bucket !== "string" || !/^[a-z0-9][a-z0-9.-]{1,220}[a-z0-9]$/.test(plan.provider.bucket) || typeof plan.provider.namespace_key !== "string" || !/^[a-f0-9]{64}$/.test(plan.provider.namespace_key) || typeof plan.plan_id !== "string" || !/^[a-f0-9]{64}$/.test(plan.plan_id) || !Array.isArray(plan.objects) || plan.objects.length < 1 || plan.objects.length > 128 || plan.objects.some(
76
- (o, i) => !o || typeof o.bucket !== "string" || !/^[a-z0-9][a-z0-9.-]{1,220}[a-z0-9]$/.test(o.bucket) || o.bucket !== plan.provider.bucket || o.object_name !== reportingObjectWriteName(plan, plan.provider, plan.plan_id, i) || typeof o.object_name !== "string" || !/^[A-Za-z0-9/_-]{1,1024}$/.test(o.object_name) || typeof o.sha256 !== "string" || !/^[a-f0-9]{64}$/.test(o.sha256) || !Number.isSafeInteger(o.size_bytes) || o.size_bytes < 0 || o.size_bytes > 64 * 1024 * 1024
77
- ) || plan.objects.reduce((total, o) => total + o.size_bytes, 0) > 64 * 1024 * 1024 || new Set(plan.objects.map((o) => JSON.stringify([o.bucket, o.object_name]))).size !== plan.objects.length)
78
- throw new Error("Invalid reporting object-write plan");
79
- return createHash("sha256").update(
80
- canonicalize({
81
- account_id: plan.account_id,
82
- destination_ref: plan.destination_ref,
83
- generation: plan.generation,
84
- plan_id: plan.plan_id,
85
- provider: { bucket: plan.provider.bucket, namespace_key: plan.provider.namespace_key },
86
- objects: plan.objects.map(({ bucket, object_name, sha256, size_bytes }) => ({
87
- bucket,
88
- object_name,
89
- sha256,
90
- size_bytes
91
- }))
92
- })
93
- ).digest("hex");
94
- }
95
- const REPORTING_OBJECT_WRITE_AUTHORITY_MIGRATION = `
96
- CREATE TABLE IF NOT EXISTS adcp_reporting_object_write_authority (
97
- singleton BOOLEAN PRIMARY KEY DEFAULT TRUE CHECK (singleton),
98
- installation_id UUID NOT NULL DEFAULT gen_random_uuid(),
99
- schema_version INTEGER NOT NULL DEFAULT 1 CHECK (schema_version = 1)
100
- );
101
- INSERT INTO adcp_reporting_object_write_authority (singleton) VALUES (TRUE) ON CONFLICT DO NOTHING;
102
- `;
103
- export {
104
- REPORTING_OBJECT_WRITE_AUTHORITY_MIGRATION,
105
- REPORTING_OBJECT_WRITE_MIGRATION,
106
- ReportingObjectWriteConflictError,
107
- ReportingObjectWriteNotRevokedError,
108
- assertReportingObjectWriteScope,
109
- isReportingObjectWriteConflictError,
110
- isReportingObjectWriteNotRevokedError,
111
- reportingObjectWriteName,
112
- reportingObjectWritePlanFingerprint,
113
- reportingObjectWriteScopeKey
114
- };