@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,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
- };