@adcp/sdk 16.0.0-beta.3 → 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.
- package/dist/lib/auth/oauth/diagnose.js +3 -11
- package/dist/lib/auth/oauth/diagnose.mjs +4 -12
- package/dist/lib/auth/oauth/diagnostics.d.mts +2 -1
- package/dist/lib/auth/oauth/diagnostics.d.ts +2 -1
- package/dist/lib/auth/oauth/diagnostics.js +8 -10
- package/dist/lib/auth/oauth/diagnostics.mjs +7 -10
- package/dist/lib/index.d.mts +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +2 -0
- package/dist/lib/index.mjs +7 -1
- package/dist/lib/reporting/consumer-runtime.js +2 -1
- package/dist/lib/reporting/consumer-runtime.mjs +2 -1
- package/dist/lib/reporting/ledger/handler.js +50 -11
- package/dist/lib/reporting/ledger/handler.mjs +50 -12
- package/dist/lib/reporting/ledger/index.d.mts +17 -14
- package/dist/lib/reporting/ledger/index.d.ts +17 -14
- package/dist/lib/reporting/ledger/index.js +32 -20
- package/dist/lib/reporting/ledger/index.mjs +21 -10
- package/dist/lib/reporting/ledger/offering-validation.d.mts +9 -0
- package/dist/lib/reporting/ledger/offering-validation.d.ts +9 -0
- package/dist/lib/reporting/{gcs/bucket-policy.js → ledger/offering-validation.js} +9 -8
- package/dist/lib/reporting/ledger/offering-validation.mjs +8 -0
- package/dist/lib/reporting/ledger/receipts.d.mts +48 -0
- package/dist/lib/reporting/ledger/receipts.d.ts +48 -0
- package/dist/lib/reporting/ledger/receipts.js +186 -0
- package/dist/lib/reporting/ledger/receipts.mjs +161 -0
- package/dist/lib/reporting/ledger/status-ingest.js +3 -3
- package/dist/lib/reporting/ledger/status-ingest.mjs +4 -5
- package/dist/lib/reporting/ledger/types.d.mts +43 -0
- package/dist/lib/reporting/ledger/types.d.ts +43 -0
- package/dist/lib/reporting/ledger/types.js +31 -2
- package/dist/lib/reporting/ledger/types.mjs +26 -1
- package/dist/lib/reporting/pagination.d.mts +6 -0
- package/dist/lib/reporting/pagination.d.ts +6 -0
- package/dist/lib/reporting/{gcs/errors.js → pagination.js} +12 -17
- package/dist/lib/reporting/pagination.mjs +12 -0
- package/dist/lib/reporting/reconciliation.d.mts +1 -0
- package/dist/lib/reporting/reconciliation.d.ts +1 -0
- package/dist/lib/reporting/reconciliation.js +3 -2
- package/dist/lib/reporting/reconciliation.mjs +3 -2
- package/dist/lib/reporting/service/index.d.mts +79 -153
- package/dist/lib/reporting/service/index.d.ts +79 -153
- package/dist/lib/reporting/service/index.js +34 -491
- package/dist/lib/reporting/service/index.mjs +36 -510
- package/dist/lib/reporting/service/scheduler-support.d.mts +43 -0
- package/dist/lib/reporting/service/scheduler-support.d.ts +43 -0
- package/dist/lib/reporting/service/scheduler-support.js +125 -0
- package/dist/lib/reporting/service/scheduler-support.mjs +96 -0
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/signing/canonicalize.d.mts +4 -0
- package/dist/lib/signing/canonicalize.d.ts +4 -0
- package/dist/lib/signing/canonicalize.js +14 -8
- package/dist/lib/signing/canonicalize.mjs +14 -8
- package/dist/lib/signing/content-digest.d.mts +8 -0
- package/dist/lib/signing/content-digest.d.ts +8 -0
- package/dist/lib/signing/content-digest.js +11 -5
- package/dist/lib/signing/content-digest.mjs +10 -5
- package/dist/lib/signing/signer.js +9 -6
- package/dist/lib/signing/signer.mjs +10 -7
- package/dist/lib/signing/web-bot-auth.js +103 -37
- package/dist/lib/signing/web-bot-auth.mjs +108 -37
- package/dist/lib/testing/storyboard/junit.js +16 -3
- package/dist/lib/testing/storyboard/junit.mjs +16 -3
- package/dist/lib/testing/storyboard/request-signing/builder.js +10 -9
- package/dist/lib/testing/storyboard/request-signing/builder.mjs +10 -9
- package/dist/lib/testing/storyboard/runner.js +94 -25
- package/dist/lib/testing/storyboard/runner.mjs +94 -25
- package/dist/lib/testing/storyboard/types.d.mts +6 -0
- package/dist/lib/testing/storyboard/types.d.ts +6 -0
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/version.d.mts +3 -3
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.js +3 -3
- package/dist/lib/version.mjs +3 -3
- package/docs/TYPE-SUMMARY.md +23 -5
- package/docs/guides/REPORTING-GCS-FENCE.md +3 -3
- package/docs/guides/REPORTING-GCS-MANAGED.md +4 -4
- package/docs/guides/REPORTING-LEDGER-CUTOVER.md +7 -7
- package/docs/guides/REPORTING-LEDGER.md +107 -51
- package/docs/guides/REPORTING-OPERATIONS.md +66 -5
- package/docs/guides/REPORTING-STABILITY.md +36 -32
- package/docs/llms.txt +4 -3
- package/docs/migration-14.x-rc-worksheet.md +4 -7
- package/docs/migration-reporting-storage-package.md +186 -0
- package/examples/README.md +1 -1
- package/package.json +13 -78
- package/dist/lib/reporting/azure/index.d.mts +0 -31
- package/dist/lib/reporting/azure/index.d.ts +0 -31
- package/dist/lib/reporting/azure/index.js +0 -266
- package/dist/lib/reporting/azure/index.mjs +0 -249
- package/dist/lib/reporting/bigquery/index.d.mts +0 -246
- package/dist/lib/reporting/bigquery/index.d.ts +0 -246
- package/dist/lib/reporting/bigquery/index.js +0 -633
- package/dist/lib/reporting/bigquery/index.mjs +0 -594
- package/dist/lib/reporting/gcs/adapter.d.mts +0 -38
- package/dist/lib/reporting/gcs/adapter.d.ts +0 -38
- package/dist/lib/reporting/gcs/adapter.js +0 -342
- package/dist/lib/reporting/gcs/adapter.mjs +0 -325
- package/dist/lib/reporting/gcs/bucket-policy.d.mts +0 -3
- package/dist/lib/reporting/gcs/bucket-policy.d.ts +0 -3
- package/dist/lib/reporting/gcs/bucket-policy.mjs +0 -7
- package/dist/lib/reporting/gcs/errors.d.mts +0 -11
- package/dist/lib/reporting/gcs/errors.d.ts +0 -11
- package/dist/lib/reporting/gcs/errors.mjs +0 -16
- package/dist/lib/reporting/gcs/fence.d.mts +0 -41
- package/dist/lib/reporting/gcs/fence.d.ts +0 -41
- package/dist/lib/reporting/gcs/fence.js +0 -250
- package/dist/lib/reporting/gcs/fence.mjs +0 -230
- package/dist/lib/reporting/gcs/index.d.mts +0 -18
- package/dist/lib/reporting/gcs/index.d.ts +0 -18
- package/dist/lib/reporting/gcs/index.js +0 -44
- package/dist/lib/reporting/gcs/index.mjs +0 -14
- package/dist/lib/reporting/gcs/io.d.mts +0 -7
- package/dist/lib/reporting/gcs/io.d.ts +0 -7
- package/dist/lib/reporting/gcs/io.js +0 -95
- package/dist/lib/reporting/gcs/io.mjs +0 -69
- package/dist/lib/reporting/gcs/reader.d.mts +0 -67
- package/dist/lib/reporting/gcs/reader.d.ts +0 -67
- package/dist/lib/reporting/gcs/reader.js +0 -193
- package/dist/lib/reporting/gcs/reader.mjs +0 -169
- package/dist/lib/reporting/gcs/row-provider.d.mts +0 -39
- package/dist/lib/reporting/gcs/row-provider.d.ts +0 -39
- package/dist/lib/reporting/gcs/row-provider.js +0 -225
- package/dist/lib/reporting/gcs/row-provider.mjs +0 -208
- package/dist/lib/reporting/gcs/validation.d.mts +0 -5
- package/dist/lib/reporting/gcs/validation.d.ts +0 -5
- package/dist/lib/reporting/gcs/validation.js +0 -49
- package/dist/lib/reporting/gcs/validation.mjs +0 -25
- package/dist/lib/reporting/ledger/change-feed.d.mts +0 -69
- package/dist/lib/reporting/ledger/change-feed.d.ts +0 -69
- package/dist/lib/reporting/ledger/change-feed.js +0 -107
- package/dist/lib/reporting/ledger/change-feed.mjs +0 -80
- package/dist/lib/reporting/ledger/managed-postgres.d.mts +0 -293
- package/dist/lib/reporting/ledger/managed-postgres.d.ts +0 -293
- package/dist/lib/reporting/ledger/managed-postgres.js +0 -2346
- package/dist/lib/reporting/ledger/managed-postgres.mjs +0 -2332
- package/dist/lib/reporting/ledger/managed-router.d.mts +0 -148
- package/dist/lib/reporting/ledger/managed-router.d.ts +0 -148
- package/dist/lib/reporting/ledger/managed-router.js +0 -280
- package/dist/lib/reporting/ledger/managed-router.mjs +0 -258
- package/dist/lib/reporting/ledger/managed.d.mts +0 -535
- package/dist/lib/reporting/ledger/managed.d.ts +0 -535
- package/dist/lib/reporting/ledger/managed.js +0 -761
- package/dist/lib/reporting/ledger/managed.mjs +0 -729
- package/dist/lib/reporting/ledger/notification-activity.d.mts +0 -332
- package/dist/lib/reporting/ledger/notification-activity.d.ts +0 -332
- package/dist/lib/reporting/ledger/notification-activity.js +0 -1366
- package/dist/lib/reporting/ledger/notification-activity.mjs +0 -1337
- package/dist/lib/reporting/ledger/object-writes.d.mts +0 -128
- package/dist/lib/reporting/ledger/object-writes.d.ts +0 -128
- package/dist/lib/reporting/ledger/object-writes.js +0 -147
- package/dist/lib/reporting/ledger/object-writes.mjs +0 -114
- package/dist/lib/reporting/ledger/postgres.d.mts +0 -689
- package/dist/lib/reporting/ledger/postgres.d.ts +0 -689
- package/dist/lib/reporting/ledger/postgres.js +0 -4462
- package/dist/lib/reporting/ledger/postgres.mjs +0 -4462
- package/dist/lib/reporting/ledger/row-storage-migration.d.mts +0 -59
- package/dist/lib/reporting/ledger/row-storage-migration.d.ts +0 -59
- package/dist/lib/reporting/ledger/row-storage-migration.js +0 -365
- package/dist/lib/reporting/ledger/row-storage-migration.mjs +0 -339
- package/dist/lib/reporting/ledger/row-storage-object.d.mts +0 -203
- package/dist/lib/reporting/ledger/row-storage-object.d.ts +0 -203
- package/dist/lib/reporting/ledger/row-storage-object.js +0 -379
- package/dist/lib/reporting/ledger/row-storage-object.mjs +0 -335
- package/dist/lib/reporting/ledger/row-storage-provider-io.d.mts +0 -44
- package/dist/lib/reporting/ledger/row-storage-provider-io.d.ts +0 -44
- package/dist/lib/reporting/ledger/row-storage-provider-io.js +0 -142
- package/dist/lib/reporting/ledger/row-storage-provider-io.mjs +0 -111
- package/dist/lib/reporting/ledger/row-storage.d.mts +0 -316
- package/dist/lib/reporting/ledger/row-storage.d.ts +0 -316
- package/dist/lib/reporting/ledger/row-storage.js +0 -812
- package/dist/lib/reporting/ledger/row-storage.mjs +0 -802
- package/dist/lib/reporting/s3/index.d.mts +0 -34
- package/dist/lib/reporting/s3/index.d.ts +0 -34
- package/dist/lib/reporting/s3/index.js +0 -347
- package/dist/lib/reporting/s3/index.mjs +0 -340
- package/dist/lib/reporting/service/maintenance.d.mts +0 -148
- package/dist/lib/reporting/service/maintenance.d.ts +0 -148
- package/dist/lib/reporting/service/maintenance.js +0 -185
- package/dist/lib/reporting/service/maintenance.mjs +0 -159
- package/examples/reliable-reporting-service/README.md +0 -169
|
@@ -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
|
-
};
|