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