@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.
- 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/types/schemas.generated.d.ts +907 -60
- package/dist/lib/types/schemas.generated.js +7 -7
- package/dist/lib/types/schemas.generated.mjs +7 -7
- 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,339 +0,0 @@
|
|
|
1
|
-
const REPORTING_ROW_STORAGE_MIGRATION = `
|
|
2
|
-
-- Serialize concurrent appliers (several instances may run migrations at startup) so the guarded
|
|
3
|
-
-- renames below cannot race each other. Released at the end of this implicit transaction.
|
|
4
|
-
SELECT pg_advisory_xact_lock(hashtextextended('adcp-reporting-row-storage-migration', 0));
|
|
5
|
-
|
|
6
|
-
-- In-place upgrade from the pre-AdCP-alignment column names. Every step is guarded, so a fresh
|
|
7
|
-
-- install (no tables yet) and a reapplied migration are both no-ops here.
|
|
8
|
-
DO $align$
|
|
9
|
-
DECLARE
|
|
10
|
-
renames TEXT[][] := ARRAY[
|
|
11
|
-
ARRAY['adcp_reporting_row_chunks', 'object_key', 'object_ref'],
|
|
12
|
-
ARRAY['adcp_reporting_row_chunks', 'native_version', 'native_version_ref'],
|
|
13
|
-
ARRAY['adcp_reporting_row_chunks', 'byte_count', 'canonical_size_bytes'],
|
|
14
|
-
ARRAY['adcp_reporting_row_chunks', 'physical_byte_count', 'size_bytes'],
|
|
15
|
-
ARRAY['adcp_reporting_row_sets', 'canonical_byte_count', 'content_size_bytes']
|
|
16
|
-
];
|
|
17
|
-
item TEXT[];
|
|
18
|
-
BEGIN
|
|
19
|
-
FOREACH item SLICE 1 IN ARRAY renames LOOP
|
|
20
|
-
IF EXISTS (
|
|
21
|
-
SELECT 1 FROM information_schema.columns
|
|
22
|
-
WHERE table_schema = current_schema() AND table_name = item[1] AND column_name = item[2]
|
|
23
|
-
) AND NOT EXISTS (
|
|
24
|
-
SELECT 1 FROM information_schema.columns
|
|
25
|
-
WHERE table_schema = current_schema() AND table_name = item[1] AND column_name = item[3]
|
|
26
|
-
) THEN
|
|
27
|
-
EXECUTE format('ALTER TABLE %I RENAME COLUMN %I TO %I', item[1], item[2], item[3]);
|
|
28
|
-
END IF;
|
|
29
|
-
END LOOP;
|
|
30
|
-
-- encoding = 'adcp_canonical_jsonl_v1' becomes AdCP's format = 'jsonl' plus
|
|
31
|
-
-- algorithm = 'adcp_jcs_rows_v1'. The old CHECK admitted one value, so the defaults backfill
|
|
32
|
-
-- every row without an UPDATE (the immutability trigger forbids one).
|
|
33
|
-
IF EXISTS (
|
|
34
|
-
SELECT 1 FROM information_schema.columns
|
|
35
|
-
WHERE table_schema = current_schema() AND table_name = 'adcp_reporting_row_sets' AND column_name = 'encoding'
|
|
36
|
-
) AND NOT EXISTS (
|
|
37
|
-
SELECT 1 FROM information_schema.columns
|
|
38
|
-
WHERE table_schema = current_schema() AND table_name = 'adcp_reporting_row_sets' AND column_name = 'format'
|
|
39
|
-
) THEN
|
|
40
|
-
ALTER TABLE adcp_reporting_row_sets
|
|
41
|
-
ADD COLUMN format TEXT NOT NULL DEFAULT 'jsonl' CHECK (format = 'jsonl'),
|
|
42
|
-
ADD COLUMN algorithm TEXT NOT NULL DEFAULT 'adcp_jcs_rows_v1' CHECK (algorithm = 'adcp_jcs_rows_v1');
|
|
43
|
-
ALTER TABLE adcp_reporting_row_sets ALTER COLUMN format DROP DEFAULT, ALTER COLUMN algorithm DROP DEFAULT;
|
|
44
|
-
ALTER TABLE adcp_reporting_row_sets DROP COLUMN encoding;
|
|
45
|
-
END IF;
|
|
46
|
-
END
|
|
47
|
-
$align$;
|
|
48
|
-
|
|
49
|
-
CREATE TABLE IF NOT EXISTS adcp_persistence_installation (
|
|
50
|
-
singleton BOOLEAN PRIMARY KEY DEFAULT TRUE CHECK (singleton),
|
|
51
|
-
installation_id UUID NOT NULL DEFAULT gen_random_uuid(),
|
|
52
|
-
created_at TIMESTAMPTZ NOT NULL DEFAULT clock_timestamp()
|
|
53
|
-
);
|
|
54
|
-
INSERT INTO adcp_persistence_installation (singleton) VALUES (TRUE) ON CONFLICT DO NOTHING;
|
|
55
|
-
|
|
56
|
-
CREATE TABLE IF NOT EXISTS adcp_reporting_row_bindings (
|
|
57
|
-
row_binding_id TEXT COLLATE "C" PRIMARY KEY CHECK (row_binding_id ~ '^[A-Za-z0-9_.:-]{1,128}$'),
|
|
58
|
-
kind TEXT NOT NULL CHECK (kind IN ('postgres', 'object')),
|
|
59
|
-
provider TEXT NOT NULL CHECK (provider ~ '^[a-z][a-z0-9_]{0,63}$'),
|
|
60
|
-
identity_config JSONB NOT NULL CHECK (jsonb_typeof(identity_config) = 'object'),
|
|
61
|
-
identity_sha256 TEXT COLLATE "C" NOT NULL CHECK (identity_sha256 ~ '^[0-9a-f]{64}$'),
|
|
62
|
-
operational_config JSONB NOT NULL DEFAULT '{}'::jsonb CHECK (jsonb_typeof(operational_config) = 'object'),
|
|
63
|
-
namespace_key TEXT COLLATE "C" NOT NULL CHECK (namespace_key ~ '^[0-9a-f]{64}$'),
|
|
64
|
-
state TEXT NOT NULL DEFAULT 'active' CHECK (state IN ('active', 'read_only', 'retired')),
|
|
65
|
-
created_at TIMESTAMPTZ NOT NULL DEFAULT clock_timestamp(),
|
|
66
|
-
retired_at TIMESTAMPTZ,
|
|
67
|
-
CHECK ((state = 'retired') = (retired_at IS NOT NULL))
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
CREATE TABLE IF NOT EXISTS adcp_reporting_row_sets (
|
|
71
|
-
row_set_id TEXT COLLATE "C" PRIMARY KEY,
|
|
72
|
-
row_set_kind TEXT NOT NULL CHECK (row_set_kind IN ('revision', 'adjustment')),
|
|
73
|
-
account_id TEXT COLLATE "C" NOT NULL,
|
|
74
|
-
obligation_id TEXT COLLATE "C" NOT NULL REFERENCES adcp_reporting_obligations(obligation_id),
|
|
75
|
-
format TEXT NOT NULL CHECK (format = 'jsonl'),
|
|
76
|
-
algorithm TEXT NOT NULL CHECK (algorithm = 'adcp_jcs_rows_v1'),
|
|
77
|
-
digest_profile TEXT NOT NULL CHECK (digest_profile IN ('revision_envelope_v1', 'rows_v1')),
|
|
78
|
-
content_sha256 TEXT COLLATE "C" NOT NULL CHECK (content_sha256 ~ '^[0-9a-f]{64}$'),
|
|
79
|
-
content_size_bytes BIGINT NOT NULL CHECK (content_size_bytes > 0),
|
|
80
|
-
row_count BIGINT NOT NULL CHECK (row_count >= 0),
|
|
81
|
-
row_manifest_sha256 TEXT COLLATE "C" NOT NULL CHECK (row_manifest_sha256 ~ '^[0-9a-f]{64}$'),
|
|
82
|
-
chunk_count INTEGER NOT NULL CHECK (chunk_count >= 0),
|
|
83
|
-
rows_shared_from_row_set_id TEXT COLLATE "C",
|
|
84
|
-
row_binding_id TEXT COLLATE "C" NOT NULL REFERENCES adcp_reporting_row_bindings(row_binding_id),
|
|
85
|
-
row_location_version INTEGER NOT NULL DEFAULT 1 CHECK (row_location_version > 0),
|
|
86
|
-
rows_state TEXT NOT NULL DEFAULT 'live' CHECK (rows_state IN ('live', 'pruning', 'pruned', 'unavailable')),
|
|
87
|
-
rows_state_changed_at TIMESTAMPTZ,
|
|
88
|
-
recorded_at TIMESTAMPTZ NOT NULL DEFAULT clock_timestamp(),
|
|
89
|
-
CHECK ((row_count = 0) = (chunk_count = 0)),
|
|
90
|
-
CHECK (rows_shared_from_row_set_id IS NULL OR rows_shared_from_row_set_id <> row_set_id),
|
|
91
|
-
-- Tenant columns are the composite key children reference, so a chunk or a
|
|
92
|
-
-- shared row set can never name another account's or obligation's rows.
|
|
93
|
-
UNIQUE (row_set_id, account_id, obligation_id),
|
|
94
|
-
FOREIGN KEY (rows_shared_from_row_set_id, account_id, obligation_id)
|
|
95
|
-
REFERENCES adcp_reporting_row_sets (row_set_id, account_id, obligation_id)
|
|
96
|
-
);
|
|
97
|
-
CREATE INDEX IF NOT EXISTS adcp_reporting_row_sets_obligation
|
|
98
|
-
ON adcp_reporting_row_sets (obligation_id, recorded_at, row_set_id);
|
|
99
|
-
CREATE INDEX IF NOT EXISTS adcp_reporting_row_sets_state
|
|
100
|
-
ON adcp_reporting_row_sets (account_id, rows_state, recorded_at)
|
|
101
|
-
WHERE rows_state <> 'pruned';
|
|
102
|
-
CREATE INDEX IF NOT EXISTS adcp_reporting_row_sets_shared
|
|
103
|
-
ON adcp_reporting_row_sets (rows_shared_from_row_set_id)
|
|
104
|
-
WHERE rows_shared_from_row_set_id IS NOT NULL;
|
|
105
|
-
|
|
106
|
-
CREATE TABLE IF NOT EXISTS adcp_reporting_row_chunks (
|
|
107
|
-
row_set_id TEXT COLLATE "C" NOT NULL,
|
|
108
|
-
chunk_index INTEGER NOT NULL CHECK (chunk_index >= 0),
|
|
109
|
-
account_id TEXT COLLATE "C" NOT NULL,
|
|
110
|
-
obligation_id TEXT COLLATE "C" NOT NULL,
|
|
111
|
-
first_ordinal BIGINT NOT NULL CHECK (first_ordinal >= 0),
|
|
112
|
-
row_count INTEGER NOT NULL CHECK (row_count > 0),
|
|
113
|
-
canonical_size_bytes BIGINT NOT NULL CHECK (canonical_size_bytes > 0),
|
|
114
|
-
sha256 TEXT COLLATE "C" NOT NULL CHECK (sha256 ~ '^[0-9a-f]{64}$'),
|
|
115
|
-
segments JSONB NOT NULL CHECK (jsonb_typeof(segments) = 'array'),
|
|
116
|
-
object_ref TEXT COLLATE "C" CONSTRAINT adcp_reporting_row_chunks_object_ref_bounds
|
|
117
|
-
CHECK (object_ref IS NULL OR char_length(object_ref) BETWEEN 1 AND 1024),
|
|
118
|
-
native_version_ref TEXT CONSTRAINT adcp_reporting_row_chunks_native_version_ref_bounds
|
|
119
|
-
CHECK (native_version_ref IS NULL OR char_length(native_version_ref) BETWEEN 1 AND 1024),
|
|
120
|
-
compression TEXT NOT NULL DEFAULT 'none' CHECK (compression IN ('none', 'gzip')),
|
|
121
|
-
physical_sha256 TEXT COLLATE "C" CHECK (physical_sha256 IS NULL OR physical_sha256 ~ '^[0-9a-f]{64}$'),
|
|
122
|
-
size_bytes BIGINT CHECK (size_bytes IS NULL OR size_bytes > 0),
|
|
123
|
-
PRIMARY KEY (row_set_id, chunk_index),
|
|
124
|
-
FOREIGN KEY (row_set_id, account_id, obligation_id)
|
|
125
|
-
REFERENCES adcp_reporting_row_sets (row_set_id, account_id, obligation_id),
|
|
126
|
-
CHECK ((object_ref IS NULL) = (native_version_ref IS NULL)),
|
|
127
|
-
CHECK ((object_ref IS NULL) = (physical_sha256 IS NULL)),
|
|
128
|
-
CHECK ((object_ref IS NULL) = (size_bytes IS NULL))
|
|
129
|
-
);
|
|
130
|
-
CREATE INDEX IF NOT EXISTS adcp_reporting_row_chunks_object
|
|
131
|
-
ON adcp_reporting_row_chunks (object_ref, native_version_ref)
|
|
132
|
-
WHERE object_ref IS NOT NULL;
|
|
133
|
-
CREATE INDEX IF NOT EXISTS adcp_reporting_row_chunks_body
|
|
134
|
-
ON adcp_reporting_row_chunks (account_id, obligation_id, sha256)
|
|
135
|
-
WHERE object_ref IS NULL;
|
|
136
|
-
|
|
137
|
-
CREATE TABLE IF NOT EXISTS adcp_reporting_chunk_bodies (
|
|
138
|
-
account_id TEXT COLLATE "C" NOT NULL,
|
|
139
|
-
obligation_id TEXT COLLATE "C" NOT NULL,
|
|
140
|
-
sha256 TEXT COLLATE "C" NOT NULL,
|
|
141
|
-
body BYTEA NOT NULL,
|
|
142
|
-
recorded_at TIMESTAMPTZ NOT NULL DEFAULT clock_timestamp(),
|
|
143
|
-
PRIMARY KEY (account_id, obligation_id, sha256),
|
|
144
|
-
CHECK (sha256 = encode(sha256(body), 'hex'))
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
CREATE TABLE IF NOT EXISTS adcp_reporting_row_write_intents (
|
|
148
|
-
row_binding_id TEXT COLLATE "C" NOT NULL REFERENCES adcp_reporting_row_bindings(row_binding_id),
|
|
149
|
-
account_id TEXT COLLATE "C" NOT NULL,
|
|
150
|
-
row_set_id TEXT COLLATE "C" NOT NULL,
|
|
151
|
-
content_sha256 TEXT COLLATE "C" NOT NULL CHECK (content_sha256 ~ '^[0-9a-f]{64}$'),
|
|
152
|
-
state TEXT NOT NULL DEFAULT 'open' CHECK (state IN ('open', 'sweeping')),
|
|
153
|
-
owner_token TEXT COLLATE "C" NOT NULL,
|
|
154
|
-
created_objects JSONB NOT NULL DEFAULT '[]'::jsonb CHECK (jsonb_typeof(created_objects) = 'array'),
|
|
155
|
-
created_at TIMESTAMPTZ NOT NULL DEFAULT clock_timestamp(),
|
|
156
|
-
expires_at TIMESTAMPTZ NOT NULL,
|
|
157
|
-
PRIMARY KEY (row_binding_id, row_set_id, content_sha256)
|
|
158
|
-
);
|
|
159
|
-
CREATE INDEX IF NOT EXISTS adcp_reporting_row_write_intents_expiry
|
|
160
|
-
ON adcp_reporting_row_write_intents (expires_at, account_id)
|
|
161
|
-
WHERE state = 'open';
|
|
162
|
-
-- Sweep retry state. An intent whose sweep fails backs off instead of holding
|
|
163
|
-
-- the head of every pass. Guarded on the catalog because ADD COLUMN IF NOT EXISTS
|
|
164
|
-
-- takes ACCESS EXCLUSIVE even when the column exists, which would block a rerun
|
|
165
|
-
-- behind every upload.
|
|
166
|
-
DO $intent_retry$
|
|
167
|
-
DECLARE
|
|
168
|
-
intents regclass := to_regclass('adcp_reporting_row_write_intents');
|
|
169
|
-
BEGIN
|
|
170
|
-
IF NOT EXISTS (SELECT 1 FROM pg_attribute WHERE attrelid = intents AND attname = 'sweep_attempts' AND NOT attisdropped) THEN
|
|
171
|
-
ALTER TABLE adcp_reporting_row_write_intents ADD COLUMN sweep_attempts INTEGER NOT NULL DEFAULT 0;
|
|
172
|
-
END IF;
|
|
173
|
-
IF NOT EXISTS (SELECT 1 FROM pg_attribute WHERE attrelid = intents AND attname = 'next_sweep_at' AND NOT attisdropped) THEN
|
|
174
|
-
ALTER TABLE adcp_reporting_row_write_intents ADD COLUMN next_sweep_at TIMESTAMPTZ;
|
|
175
|
-
END IF;
|
|
176
|
-
END
|
|
177
|
-
$intent_retry$;
|
|
178
|
-
|
|
179
|
-
CREATE OR REPLACE FUNCTION adcp_reporting_row_storage_immutable() RETURNS trigger
|
|
180
|
-
LANGUAGE plpgsql AS $immutable$
|
|
181
|
-
BEGIN
|
|
182
|
-
IF TG_TABLE_NAME = 'adcp_reporting_row_bindings' THEN
|
|
183
|
-
IF (NEW.row_binding_id, NEW.kind, NEW.provider, NEW.identity_config, NEW.identity_sha256, NEW.namespace_key)
|
|
184
|
-
IS DISTINCT FROM
|
|
185
|
-
(OLD.row_binding_id, OLD.kind, OLD.provider, OLD.identity_config, OLD.identity_sha256, OLD.namespace_key) THEN
|
|
186
|
-
RAISE EXCEPTION 'reporting row binding identity is immutable' USING ERRCODE = '23514';
|
|
187
|
-
END IF;
|
|
188
|
-
ELSIF TG_TABLE_NAME = 'adcp_reporting_row_sets' THEN
|
|
189
|
-
IF (NEW.row_set_id, NEW.row_set_kind, NEW.account_id, NEW.obligation_id, NEW.format, NEW.algorithm,
|
|
190
|
-
NEW.digest_profile, NEW.content_sha256, NEW.content_size_bytes, NEW.row_count, NEW.row_manifest_sha256, NEW.chunk_count,
|
|
191
|
-
NEW.rows_shared_from_row_set_id, NEW.recorded_at)
|
|
192
|
-
IS DISTINCT FROM
|
|
193
|
-
(OLD.row_set_id, OLD.row_set_kind, OLD.account_id, OLD.obligation_id, OLD.format, OLD.algorithm,
|
|
194
|
-
OLD.digest_profile, OLD.content_sha256, OLD.content_size_bytes, OLD.row_count, OLD.row_manifest_sha256, OLD.chunk_count,
|
|
195
|
-
OLD.rows_shared_from_row_set_id, OLD.recorded_at) THEN
|
|
196
|
-
RAISE EXCEPTION 'reporting row set content is immutable' USING ERRCODE = '23514';
|
|
197
|
-
END IF;
|
|
198
|
-
IF NEW.row_binding_id IS DISTINCT FROM OLD.row_binding_id
|
|
199
|
-
AND NEW.row_location_version <> OLD.row_location_version + 1 THEN
|
|
200
|
-
RAISE EXCEPTION 'reporting row set moves must advance row_location_version' USING ERRCODE = '23514';
|
|
201
|
-
END IF;
|
|
202
|
-
ELSIF TG_TABLE_NAME = 'adcp_reporting_row_chunks' THEN
|
|
203
|
-
IF (NEW.row_set_id, NEW.chunk_index, NEW.account_id, NEW.obligation_id, NEW.first_ordinal, NEW.row_count,
|
|
204
|
-
NEW.canonical_size_bytes, NEW.sha256, NEW.segments)
|
|
205
|
-
IS DISTINCT FROM
|
|
206
|
-
(OLD.row_set_id, OLD.chunk_index, OLD.account_id, OLD.obligation_id, OLD.first_ordinal, OLD.row_count,
|
|
207
|
-
OLD.canonical_size_bytes, OLD.sha256, OLD.segments) THEN
|
|
208
|
-
RAISE EXCEPTION 'reporting row chunk content is immutable' USING ERRCODE = '23514';
|
|
209
|
-
END IF;
|
|
210
|
-
ELSIF TG_TABLE_NAME = 'adcp_reporting_chunk_bodies' THEN
|
|
211
|
-
RAISE EXCEPTION 'reporting chunk bodies are immutable' USING ERRCODE = '23514';
|
|
212
|
-
END IF;
|
|
213
|
-
RETURN NEW;
|
|
214
|
-
END
|
|
215
|
-
$immutable$;
|
|
216
|
-
|
|
217
|
-
DO $triggers$
|
|
218
|
-
DECLARE
|
|
219
|
-
target TEXT;
|
|
220
|
-
BEGIN
|
|
221
|
-
FOREACH target IN ARRAY ARRAY[
|
|
222
|
-
'adcp_reporting_row_bindings',
|
|
223
|
-
'adcp_reporting_row_sets',
|
|
224
|
-
'adcp_reporting_row_chunks',
|
|
225
|
-
'adcp_reporting_chunk_bodies'
|
|
226
|
-
] LOOP
|
|
227
|
-
IF NOT EXISTS (
|
|
228
|
-
SELECT 1 FROM pg_trigger
|
|
229
|
-
WHERE tgname = target || '_immutable'
|
|
230
|
-
AND tgrelid = to_regclass(quote_ident(current_schema()) || '.' || quote_ident(target))
|
|
231
|
-
) THEN
|
|
232
|
-
EXECUTE format(
|
|
233
|
-
'CREATE TRIGGER %I BEFORE UPDATE ON %I FOR EACH ROW EXECUTE FUNCTION adcp_reporting_row_storage_immutable()',
|
|
234
|
-
target || '_immutable',
|
|
235
|
-
target
|
|
236
|
-
);
|
|
237
|
-
END IF;
|
|
238
|
-
END LOOP;
|
|
239
|
-
END
|
|
240
|
-
$triggers$;
|
|
241
|
-
|
|
242
|
-
-- AdCP bounds on installs created before they existed (a fresh install has them inline).
|
|
243
|
-
DO $bounds$
|
|
244
|
-
DECLARE
|
|
245
|
-
offending BIGINT;
|
|
246
|
-
BEGIN
|
|
247
|
-
SELECT count(*) INTO offending FROM adcp_reporting_row_chunks
|
|
248
|
-
WHERE object_ref IS NOT NULL
|
|
249
|
-
AND (char_length(object_ref) NOT BETWEEN 1 AND 1024 OR char_length(native_version_ref) NOT BETWEEN 1 AND 1024);
|
|
250
|
-
IF offending > 0 THEN
|
|
251
|
-
RAISE EXCEPTION 'reporting row storage: % chunk(s) hold an object_ref or native_version_ref outside AdCP 1 to 1024 characters; re-sync them before applying this migration', offending
|
|
252
|
-
USING ERRCODE = '23514';
|
|
253
|
-
END IF;
|
|
254
|
-
IF NOT EXISTS (
|
|
255
|
-
SELECT 1 FROM pg_constraint
|
|
256
|
-
WHERE conname = 'adcp_reporting_row_chunks_object_ref_bounds'
|
|
257
|
-
AND conrelid = to_regclass(quote_ident(current_schema()) || '.adcp_reporting_row_chunks')
|
|
258
|
-
) THEN
|
|
259
|
-
ALTER TABLE adcp_reporting_row_chunks ADD CONSTRAINT adcp_reporting_row_chunks_object_ref_bounds
|
|
260
|
-
CHECK (object_ref IS NULL OR char_length(object_ref) BETWEEN 1 AND 1024);
|
|
261
|
-
END IF;
|
|
262
|
-
IF NOT EXISTS (
|
|
263
|
-
SELECT 1 FROM pg_constraint
|
|
264
|
-
WHERE conname = 'adcp_reporting_row_chunks_native_version_ref_bounds'
|
|
265
|
-
AND conrelid = to_regclass(quote_ident(current_schema()) || '.adcp_reporting_row_chunks')
|
|
266
|
-
) THEN
|
|
267
|
-
ALTER TABLE adcp_reporting_row_chunks ADD CONSTRAINT adcp_reporting_row_chunks_native_version_ref_bounds
|
|
268
|
-
CHECK (native_version_ref IS NULL OR char_length(native_version_ref) BETWEEN 1 AND 1024);
|
|
269
|
-
END IF;
|
|
270
|
-
END
|
|
271
|
-
$bounds$;
|
|
272
|
-
|
|
273
|
-
-- Open write intents written before the rename name objects objectKey / nativeVersion.
|
|
274
|
-
UPDATE adcp_reporting_row_write_intents
|
|
275
|
-
SET created_objects = (
|
|
276
|
-
SELECT COALESCE(jsonb_agg(
|
|
277
|
-
CASE WHEN jsonb_typeof(created) = 'object' AND created ? 'objectKey'
|
|
278
|
-
THEN jsonb_build_object('object_ref', created -> 'objectKey', 'native_version_ref', created -> 'nativeVersion')
|
|
279
|
-
ELSE created END
|
|
280
|
-
ORDER BY ordinality
|
|
281
|
-
), '[]'::jsonb)
|
|
282
|
-
FROM jsonb_array_elements(created_objects) WITH ORDINALITY AS element(created, ordinality)
|
|
283
|
-
)
|
|
284
|
-
WHERE EXISTS (SELECT 1 FROM jsonb_array_elements(created_objects) AS element(created) WHERE jsonb_typeof(created) = 'object' AND created ? 'objectKey');
|
|
285
|
-
`.trim();
|
|
286
|
-
const REPORTING_ROW_STORAGE_TABLES = Object.freeze([
|
|
287
|
-
"adcp_persistence_installation",
|
|
288
|
-
"adcp_reporting_row_bindings",
|
|
289
|
-
"adcp_reporting_row_sets",
|
|
290
|
-
"adcp_reporting_row_chunks",
|
|
291
|
-
"adcp_reporting_chunk_bodies",
|
|
292
|
-
"adcp_reporting_row_write_intents"
|
|
293
|
-
]);
|
|
294
|
-
const REPORTING_ROW_STORAGE_REQUIRED_COLUMNS = Object.freeze([
|
|
295
|
-
"adcp_reporting_row_sets.format",
|
|
296
|
-
"adcp_reporting_row_sets.algorithm",
|
|
297
|
-
"adcp_reporting_row_sets.content_size_bytes",
|
|
298
|
-
"adcp_reporting_row_chunks.canonical_size_bytes",
|
|
299
|
-
"adcp_reporting_row_chunks.object_ref",
|
|
300
|
-
"adcp_reporting_row_chunks.native_version_ref",
|
|
301
|
-
"adcp_reporting_row_chunks.size_bytes"
|
|
302
|
-
]);
|
|
303
|
-
async function probeReportingRowStorageSchemaV1(pool) {
|
|
304
|
-
const present = await pool.query(
|
|
305
|
-
`SELECT table_name AS name FROM information_schema.tables
|
|
306
|
-
WHERE table_schema = current_schema() AND table_name = ANY($1::text[])`,
|
|
307
|
-
[[...REPORTING_ROW_STORAGE_TABLES]]
|
|
308
|
-
);
|
|
309
|
-
const names = new Set(present.rows.map((row) => row.name));
|
|
310
|
-
const missing = REPORTING_ROW_STORAGE_TABLES.filter((name) => !names.has(name));
|
|
311
|
-
if (missing.length > 0) {
|
|
312
|
-
throw new Error(
|
|
313
|
-
`Reporting row storage requires REPORTING_ROW_STORAGE_MIGRATION; missing tables: ${missing.join(", ")}`
|
|
314
|
-
);
|
|
315
|
-
}
|
|
316
|
-
const columns = await pool.query(
|
|
317
|
-
`SELECT table_name || '.' || column_name AS name FROM information_schema.columns
|
|
318
|
-
WHERE table_schema = current_schema() AND table_name = ANY($1::text[])`,
|
|
319
|
-
[["adcp_reporting_row_chunks", "adcp_reporting_row_sets"]]
|
|
320
|
-
);
|
|
321
|
-
const columnNames = new Set(columns.rows.map((row) => row.name));
|
|
322
|
-
const absent = REPORTING_ROW_STORAGE_REQUIRED_COLUMNS.filter((name) => !columnNames.has(name));
|
|
323
|
-
if (absent.length > 0) {
|
|
324
|
-
throw new Error(
|
|
325
|
-
`Reporting row storage requires the current REPORTING_ROW_STORAGE_MIGRATION; missing columns: ${absent.join(", ")}`
|
|
326
|
-
);
|
|
327
|
-
}
|
|
328
|
-
const installation = await pool.query(
|
|
329
|
-
"SELECT installation_id::text AS installation_id FROM adcp_persistence_installation WHERE singleton"
|
|
330
|
-
);
|
|
331
|
-
const installationId = installation.rows[0]?.installation_id;
|
|
332
|
-
if (!installationId) throw new Error("Reporting row storage installation identity is missing");
|
|
333
|
-
return { installationId };
|
|
334
|
-
}
|
|
335
|
-
export {
|
|
336
|
-
REPORTING_ROW_STORAGE_MIGRATION,
|
|
337
|
-
REPORTING_ROW_STORAGE_TABLES,
|
|
338
|
-
probeReportingRowStorageSchemaV1
|
|
339
|
-
};
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Object-storage providers for revision row chunks (shared SDK persistence
|
|
3
|
-
* spec, adcontextprotocol/adcp#7996 §3.3–§3.4).
|
|
4
|
-
*
|
|
5
|
-
* A provider is a thin, credential-free port over one object store. It never
|
|
6
|
-
* decides where bytes go: keys are rendered by the SDK from an allowlisted
|
|
7
|
-
* binding, and every byte a provider returns is verified against digests
|
|
8
|
-
* committed in PostgreSQL before rows are released.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
12
|
-
*/
|
|
13
|
-
export interface ReportingRowObjectContextV1 {
|
|
14
|
-
signal: AbortSignal;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
18
|
-
*/
|
|
19
|
-
export interface ReportingRowObjectLocationV1 {
|
|
20
|
-
/** Non-secret provider coordinates (bucket, container, filesystem root name, endpoint host). */
|
|
21
|
-
readonly location: Readonly<Record<string, string>>;
|
|
22
|
-
/** Host-mapped client reference; never a secret. */
|
|
23
|
-
readonly credentialRef?: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Bounds AdCP puts on `object_ref` and `native_version_ref`
|
|
27
|
-
* (`reporting-file-object-ref.json`, `reporting-native-version-ref.json`):
|
|
28
|
-
* 1 to 1024 characters. The row-storage `CHECK` constraints enforce the same.
|
|
29
|
-
*
|
|
30
|
-
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
31
|
-
*/
|
|
32
|
-
export declare const REPORTING_ROW_OBJECT_REF_MAX_LENGTH = 1024;
|
|
33
|
-
/**
|
|
34
|
-
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
35
|
-
*/
|
|
36
|
-
export declare const REPORTING_ROW_NATIVE_VERSION_REF_MAX_LENGTH = 1024;
|
|
37
|
-
/**
|
|
38
|
-
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
39
|
-
*/
|
|
40
|
-
export interface ReportingRowObjectPutInputV1 extends ReportingRowObjectLocationV1 {
|
|
41
|
-
/** AdCP `object_ref`: decoded, destination-relative object key. */
|
|
42
|
-
objectRef: string;
|
|
43
|
-
bytes: Uint8Array;
|
|
44
|
-
contentType: 'application/x-ndjson' | 'application/gzip';
|
|
45
|
-
/** Non-secret object metadata (installation and intent identifiers). */
|
|
46
|
-
metadata: Readonly<Record<string, string>>;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
50
|
-
*/
|
|
51
|
-
export interface ReportingRowObjectGetInputV1 extends ReportingRowObjectLocationV1 {
|
|
52
|
-
objectRef: string;
|
|
53
|
-
/** AdCP `native_version_ref`: the exact native version recorded at write time. */
|
|
54
|
-
nativeVersionRef: string;
|
|
55
|
-
/** Byte range within the stored object; omit for the whole object. */
|
|
56
|
-
range?: {
|
|
57
|
-
offset: number;
|
|
58
|
-
length: number;
|
|
59
|
-
};
|
|
60
|
-
/** Hard cap on bytes read; providers abort beyond it. */
|
|
61
|
-
maxBytes: number;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
65
|
-
*/
|
|
66
|
-
export interface ReportingRowObjectDeleteInputV1 extends ReportingRowObjectLocationV1 {
|
|
67
|
-
objectRef: string;
|
|
68
|
-
nativeVersionRef: string;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
72
|
-
*/
|
|
73
|
-
export interface ReportingRowObjectStatInputV1 extends ReportingRowObjectLocationV1 {
|
|
74
|
-
objectRef: string;
|
|
75
|
-
nativeVersionRef: string;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
79
|
-
*/
|
|
80
|
-
export interface ReportingRowObjectProviderV1 {
|
|
81
|
-
/** Registry name, e.g. `filesystem`, `gcs`, `s3`, `azure_blob`. */
|
|
82
|
-
readonly name: string;
|
|
83
|
-
/** Whether `get` honours `range` without reading the whole object. */
|
|
84
|
-
readonly rangedReads: boolean;
|
|
85
|
-
/**
|
|
86
|
-
* Validate binding coordinates against the provider's closed schema. Throw
|
|
87
|
-
* `INVALID_INPUT` for unknown fields or values that could carry secrets.
|
|
88
|
-
*/
|
|
89
|
-
validateLocation(location: Readonly<Record<string, string>>): void;
|
|
90
|
-
/** Fail closed (`UNSAFE_BINDING`) when the destination is unsafe or create-only writes are not enforced. */
|
|
91
|
-
probe(input: ReportingRowObjectLocationV1 & {
|
|
92
|
-
prefix: string;
|
|
93
|
-
}, context: ReportingRowObjectContextV1): Promise<void>;
|
|
94
|
-
/**
|
|
95
|
-
* Create-only write. Returns `created: true` with the new native version, or
|
|
96
|
-
* `created: false` with the existing object's version when the key is taken.
|
|
97
|
-
* Must never replace an existing object.
|
|
98
|
-
*/
|
|
99
|
-
putIfAbsent(input: ReportingRowObjectPutInputV1, context: ReportingRowObjectContextV1): Promise<{
|
|
100
|
-
created: boolean;
|
|
101
|
-
nativeVersionRef: string;
|
|
102
|
-
}>;
|
|
103
|
-
/** Bytes at the exact native version, or `null` when that version is absent. */
|
|
104
|
-
get(input: ReportingRowObjectGetInputV1, context: ReportingRowObjectContextV1): Promise<Uint8Array | null>;
|
|
105
|
-
/**
|
|
106
|
-
* Metadata of the exact native version without reading its bytes: the version it resolved (which must equal the
|
|
107
|
-
* requested `nativeVersionRef`) and its stored size (`size_bytes`), or `null` when that version is absent. Optional. The commit transaction uses it to
|
|
108
|
-
* prove an adopted object is unchanged (native versions are write-unique, so the same version at
|
|
109
|
-
* the recorded size is the same bytes) without downloading it under the account lock. A provider
|
|
110
|
-
* without `stat` falls back to a full read there. Never return a size for a different version.
|
|
111
|
-
*/
|
|
112
|
-
stat?(input: ReportingRowObjectStatInputV1, context: ReportingRowObjectContextV1): Promise<{
|
|
113
|
-
nativeVersionRef: string;
|
|
114
|
-
sizeBytes: number;
|
|
115
|
-
} | null>;
|
|
116
|
-
/** Delete the exact native version. Idempotent: `absent` is success. */
|
|
117
|
-
delete(input: ReportingRowObjectDeleteInputV1, context: ReportingRowObjectContextV1): Promise<'deleted' | 'absent'>;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Placeholders allowed in object key templates. `{period_date}` renders AdCP's `YYYY-MM-DD`: the calendar
|
|
121
|
-
* date of the period start in the period's `source_timezone` (never UTC, unless that is the source
|
|
122
|
-
* timezone). It is one path segment, so the default layout is
|
|
123
|
-
* `.../{account_key}/2026-10-02/{finality}/...`.
|
|
124
|
-
*
|
|
125
|
-
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
126
|
-
*/
|
|
127
|
-
export declare const REPORTING_ROW_KEY_PLACEHOLDERS: readonly ["prefix", "namespace_key", "account_key", "period_date", "finality", "revision_key", "content_sha256", "chunk_index"];
|
|
128
|
-
/**
|
|
129
|
-
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
130
|
-
*/
|
|
131
|
-
export declare const REPORTING_ROW_DEFAULT_KEY_TEMPLATE = "{prefix}/{namespace_key}/{account_key}/{period_date}/{finality}/{revision_key}/{content_sha256}/{chunk_index}";
|
|
132
|
-
/**
|
|
133
|
-
* Validate an object key template; throws `INVALID_INPUT`. Every template that writes must include
|
|
134
|
-
* `{revision_key}`, so no two row sets can ever name the same object key; `requireRevisionKey: false`
|
|
135
|
-
* is for a read-only binding that only reads rows written under an older template.
|
|
136
|
-
*
|
|
137
|
-
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
138
|
-
*/
|
|
139
|
-
export declare function assertReportingRowKeyTemplateV1(template: string, options?: {
|
|
140
|
-
requireRevisionKey?: boolean;
|
|
141
|
-
}): void;
|
|
142
|
-
/**
|
|
143
|
-
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
144
|
-
*/
|
|
145
|
-
export declare function assertReportingRowPrefixV1(prefix: string): void;
|
|
146
|
-
/**
|
|
147
|
-
* Pseudonymous account segment; never a raw account ID.
|
|
148
|
-
*
|
|
149
|
-
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
150
|
-
*/
|
|
151
|
-
export declare function reportingRowAccountKeyV1(namespaceKey: string, accountId: string): string;
|
|
152
|
-
/**
|
|
153
|
-
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
154
|
-
*/
|
|
155
|
-
export declare function reportingRowRevisionKeyV1(rowSetId: string): string;
|
|
156
|
-
/**
|
|
157
|
-
* Render one chunk's object key and confine it to the binding's owned prefix.
|
|
158
|
-
*
|
|
159
|
-
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
160
|
-
*/
|
|
161
|
-
export declare function renderReportingRowObjectKeyV1(input: {
|
|
162
|
-
template: string;
|
|
163
|
-
prefix: string;
|
|
164
|
-
namespaceKey: string;
|
|
165
|
-
accountId: string;
|
|
166
|
-
rowSetId: string;
|
|
167
|
-
/** Period start instant; with `sourceTimezone`, renders `{period_date}`. Absent renders `undated`. */
|
|
168
|
-
periodStart?: string;
|
|
169
|
-
/** The period's `source_timezone`; required whenever `periodStart` is set. Invalid values fail closed. */
|
|
170
|
-
sourceTimezone?: string;
|
|
171
|
-
finality?: 'snapshot' | 'official';
|
|
172
|
-
contentSha256: string;
|
|
173
|
-
chunkIndex: number;
|
|
174
|
-
compression: 'none' | 'gzip';
|
|
175
|
-
}): string;
|
|
176
|
-
/**
|
|
177
|
-
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
178
|
-
*/
|
|
179
|
-
export interface FilesystemReportingRowObjectProviderOptionsV1 {
|
|
180
|
-
/**
|
|
181
|
-
* Root name → absolute directory. Bindings name a root (`location.root`);
|
|
182
|
-
* they never carry paths, so the database cannot point writes elsewhere.
|
|
183
|
-
*/
|
|
184
|
-
roots: Readonly<Record<string, string>>;
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Local filesystem provider for tests and single-host deployments. Create-only
|
|
188
|
-
* writes use a temporary file, `fsync`, and `link()` to the final name, which
|
|
189
|
-
* fails rather than replacing an existing object.
|
|
190
|
-
*
|
|
191
|
-
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
192
|
-
*/
|
|
193
|
-
export declare function createFilesystemReportingRowObjectProviderV1(options: FilesystemReportingRowObjectProviderOptionsV1): ReportingRowObjectProviderV1;
|
|
194
|
-
/**
|
|
195
|
-
* Behavioural conformance for a custom object provider. Writes and deletes
|
|
196
|
-
* only under `prefix`; run it against a dedicated test bucket or prefix.
|
|
197
|
-
* Resolves with the checks that passed; rejects on the first violation.
|
|
198
|
-
*
|
|
199
|
-
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
200
|
-
*/
|
|
201
|
-
export declare function runReportingRowObjectProviderConformanceV1(provider: ReportingRowObjectProviderV1, input: ReportingRowObjectLocationV1 & {
|
|
202
|
-
prefix: string;
|
|
203
|
-
}): Promise<string[]>;
|