@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,34 +0,0 @@
|
|
|
1
|
-
import { type S3Client } from '@aws-sdk/client-s3';
|
|
2
|
-
import type { ReportingRowObjectProviderV1 } from '../ledger/row-storage-object.mjs';
|
|
3
|
-
/**
|
|
4
|
-
* @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
|
|
5
|
-
*/
|
|
6
|
-
export interface CreateS3ReportingRowObjectProviderOptionsV1 {
|
|
7
|
-
/** Official client used by bindings without a `credentialRef`. */
|
|
8
|
-
client?: S3Client;
|
|
9
|
-
/**
|
|
10
|
-
* Official clients keyed by `credentialRef`. This map is the closed set of
|
|
11
|
-
* references a binding may name; an unknown reference fails `UNSAFE_BINDING`.
|
|
12
|
-
* Endpoint, region, credentials and path style all come from these clients,
|
|
13
|
-
* never from binding locations.
|
|
14
|
-
*/
|
|
15
|
-
clients?: Readonly<Record<string, S3Client>>;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Amazon S3 (and S3-compatible) row-object provider (`@adcp/sdk/reporting/s3`).
|
|
19
|
-
*
|
|
20
|
-
* Inject official `S3Client`s configured by the host (region, endpoint,
|
|
21
|
-
* credentials). Bindings use `location: { bucket, region? }`; when `region` is
|
|
22
|
-
* set the probe requires the selected client to be configured for it.
|
|
23
|
-
*
|
|
24
|
-
* Writes use `PutObject` with `If-None-Match: *`. Bucket versioning must be
|
|
25
|
-
* enabled: the recorded native version is the write-unique `VersionId`, and every
|
|
26
|
-
* read and delete is pinned to it, so a delayed delete can never remove a later
|
|
27
|
-
* write that re-created identical bytes at the same key (ETags are content-derived
|
|
28
|
-
* and cannot fence that). The probe refuses unversioned or suspended buckets.
|
|
29
|
-
* Because S3-compatible stores may silently ignore `If-None-Match`, the probe
|
|
30
|
-
* also proves create-only behaviour empirically before any binding is used.
|
|
31
|
-
*
|
|
32
|
-
* @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
|
|
33
|
-
*/
|
|
34
|
-
export declare function createS3ReportingRowObjectProviderV1(options: CreateS3ReportingRowObjectProviderOptionsV1): ReportingRowObjectProviderV1;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { type S3Client } from '@aws-sdk/client-s3';
|
|
2
|
-
import type { ReportingRowObjectProviderV1 } from '../ledger/row-storage-object';
|
|
3
|
-
/**
|
|
4
|
-
* @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
|
|
5
|
-
*/
|
|
6
|
-
export interface CreateS3ReportingRowObjectProviderOptionsV1 {
|
|
7
|
-
/** Official client used by bindings without a `credentialRef`. */
|
|
8
|
-
client?: S3Client;
|
|
9
|
-
/**
|
|
10
|
-
* Official clients keyed by `credentialRef`. This map is the closed set of
|
|
11
|
-
* references a binding may name; an unknown reference fails `UNSAFE_BINDING`.
|
|
12
|
-
* Endpoint, region, credentials and path style all come from these clients,
|
|
13
|
-
* never from binding locations.
|
|
14
|
-
*/
|
|
15
|
-
clients?: Readonly<Record<string, S3Client>>;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Amazon S3 (and S3-compatible) row-object provider (`@adcp/sdk/reporting/s3`).
|
|
19
|
-
*
|
|
20
|
-
* Inject official `S3Client`s configured by the host (region, endpoint,
|
|
21
|
-
* credentials). Bindings use `location: { bucket, region? }`; when `region` is
|
|
22
|
-
* set the probe requires the selected client to be configured for it.
|
|
23
|
-
*
|
|
24
|
-
* Writes use `PutObject` with `If-None-Match: *`. Bucket versioning must be
|
|
25
|
-
* enabled: the recorded native version is the write-unique `VersionId`, and every
|
|
26
|
-
* read and delete is pinned to it, so a delayed delete can never remove a later
|
|
27
|
-
* write that re-created identical bytes at the same key (ETags are content-derived
|
|
28
|
-
* and cannot fence that). The probe refuses unversioned or suspended buckets.
|
|
29
|
-
* Because S3-compatible stores may silently ignore `If-None-Match`, the probe
|
|
30
|
-
* also proves create-only behaviour empirically before any binding is used.
|
|
31
|
-
*
|
|
32
|
-
* @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
|
|
33
|
-
*/
|
|
34
|
-
export declare function createS3ReportingRowObjectProviderV1(options: CreateS3ReportingRowObjectProviderOptionsV1): ReportingRowObjectProviderV1;
|
|
@@ -1,347 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var s3_exports = {};
|
|
20
|
-
__export(s3_exports, {
|
|
21
|
-
createS3ReportingRowObjectProviderV1: () => createS3ReportingRowObjectProviderV1
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(s3_exports);
|
|
24
|
-
var import_node_crypto = require("node:crypto");
|
|
25
|
-
var import_client_s3 = require("@aws-sdk/client-s3");
|
|
26
|
-
var import_row_storage_errors = require('../ledger/row-storage-errors.js');
|
|
27
|
-
var import_row_storage_provider_io = require('../ledger/row-storage-provider-io.js');
|
|
28
|
-
const BUCKET = /^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$/;
|
|
29
|
-
const REGION = /^[a-z0-9][a-z0-9-]{0,30}[a-z0-9]$/;
|
|
30
|
-
const VERSION_ID = /^[\x21\x23-\x7e]{1,1024}$/;
|
|
31
|
-
function statusOf(error) {
|
|
32
|
-
const status = Number(error?.$metadata?.httpStatusCode);
|
|
33
|
-
return Number.isInteger(status) ? status : void 0;
|
|
34
|
-
}
|
|
35
|
-
function nameOf(error) {
|
|
36
|
-
const value = error?.name ?? error?.Code;
|
|
37
|
-
return typeof value === "string" ? value : "";
|
|
38
|
-
}
|
|
39
|
-
const isPreconditionFailed = (error) => statusOf(error) === 412 || nameOf(error) === "PreconditionFailed";
|
|
40
|
-
const isConditionalConflict = (error) => statusOf(error) === 409 || nameOf(error) === "ConditionalRequestConflict";
|
|
41
|
-
const isNotFound = (error) => statusOf(error) === 404 || ["NoSuchKey", "NotFound", "NoSuchVersion", "NoSuchBucket"].includes(nameOf(error));
|
|
42
|
-
const isNotImplemented = (error) => statusOf(error) === 501 || nameOf(error) === "NotImplemented";
|
|
43
|
-
const isForbidden = (error) => statusOf(error) === 401 || statusOf(error) === 403;
|
|
44
|
-
const isRangeError = (error) => statusOf(error) === 416 || nameOf(error) === "InvalidRange";
|
|
45
|
-
function versionOf(output) {
|
|
46
|
-
const id = output.VersionId;
|
|
47
|
-
if (typeof id !== "string" || id === "null" || !VERSION_ID.test(id)) {
|
|
48
|
-
throw new import_row_storage_errors.ReportingRowStoreError(
|
|
49
|
-
"UNSAFE_BINDING",
|
|
50
|
-
"store returned no object VersionId; S3 bucket versioning must be enabled so deletes are fenced to one write"
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
return id;
|
|
54
|
-
}
|
|
55
|
-
function selectorOf(nativeVersionRef) {
|
|
56
|
-
if (typeof nativeVersionRef !== "string" || nativeVersionRef === "null") return null;
|
|
57
|
-
return VERSION_ID.test(nativeVersionRef) ? { VersionId: nativeVersionRef } : null;
|
|
58
|
-
}
|
|
59
|
-
function servedVersion(output, selector) {
|
|
60
|
-
return output.VersionId === selector.VersionId;
|
|
61
|
-
}
|
|
62
|
-
function liveExpirationCovers(rule, prefix) {
|
|
63
|
-
if (rule.Status !== "Enabled") return false;
|
|
64
|
-
if (rule.Expiration?.Days === void 0 && rule.Expiration?.Date === void 0) return false;
|
|
65
|
-
if (rule.Filter?.Tag !== void 0 || (rule.Filter?.And?.Tags?.length ?? 0) > 0) return false;
|
|
66
|
-
const filter = rule.Filter?.Prefix ?? rule.Filter?.And?.Prefix ?? rule.Prefix;
|
|
67
|
-
return (0, import_row_storage_provider_io.reportingRowPrefixFilterOverlaps)(filter, prefix);
|
|
68
|
-
}
|
|
69
|
-
function createS3ReportingRowObjectProviderV1(options) {
|
|
70
|
-
if (!options || typeof options !== "object") {
|
|
71
|
-
throw new import_row_storage_errors.ReportingRowStoreError("INVALID_INPUT", "S3 row provider options are required");
|
|
72
|
-
}
|
|
73
|
-
const clients = (0, import_row_storage_provider_io.reportingRowClientMap)(options.clients);
|
|
74
|
-
const isClient = (value) => !!value && typeof value === "object" && typeof value.send === "function";
|
|
75
|
-
if (options.client !== void 0 && !isClient(options.client) || [...clients.values()].some((client) => !isClient(client)) || options.client === void 0 && clients.size === 0) {
|
|
76
|
-
throw new import_row_storage_errors.ReportingRowStoreError("INVALID_INPUT", "inject an official S3Client as client or clients");
|
|
77
|
-
}
|
|
78
|
-
const validateLocation = (location) => {
|
|
79
|
-
(0, import_row_storage_provider_io.assertReportingRowLocationKeys)(location, ["bucket"], ["region"]);
|
|
80
|
-
const bucket = location.bucket;
|
|
81
|
-
if (!BUCKET.test(bucket) || bucket.includes("..") || /^\d+\.\d+\.\d+\.\d+$/.test(bucket)) {
|
|
82
|
-
throw new import_row_storage_errors.ReportingRowStoreError("INVALID_INPUT", "S3 bucket name is invalid");
|
|
83
|
-
}
|
|
84
|
-
if (location.region !== void 0 && !REGION.test(location.region)) {
|
|
85
|
-
throw new import_row_storage_errors.ReportingRowStoreError("INVALID_INPUT", "S3 region is invalid");
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
const target = (input) => {
|
|
89
|
-
validateLocation(input.location);
|
|
90
|
-
return {
|
|
91
|
-
client: (0, import_row_storage_provider_io.selectReportingRowClient)(options.client, clients, input.credentialRef),
|
|
92
|
-
Bucket: input.location.bucket
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
const assertKey = (key) => {
|
|
96
|
-
if (typeof key !== "string" || key.length === 0 || Buffer.byteLength(key) > 1024) {
|
|
97
|
-
throw new import_row_storage_errors.ReportingRowStoreError("INVALID_INPUT", "object key is invalid");
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
async function putCreateOnly(client, params, signal) {
|
|
101
|
-
for (let attempt = 0; ; attempt++) {
|
|
102
|
-
try {
|
|
103
|
-
return await client.send(new import_client_s3.PutObjectCommand({ ...params, IfNoneMatch: "*" }), { abortSignal: signal });
|
|
104
|
-
} catch (error) {
|
|
105
|
-
if (attempt === 0 && isConditionalConflict(error) && !signal.aborted) continue;
|
|
106
|
-
throw error;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
async function assertVersioningEnabled(client, Bucket, signal) {
|
|
111
|
-
let status;
|
|
112
|
-
try {
|
|
113
|
-
status = (await client.send(new import_client_s3.GetBucketVersioningCommand({ Bucket }), { abortSignal: signal })).Status;
|
|
114
|
-
} catch (error) {
|
|
115
|
-
if (isForbidden(error) || isNotImplemented(error)) {
|
|
116
|
-
throw new import_row_storage_errors.ReportingRowStoreError("UNSAFE_BINDING", "bucket versioning status cannot be verified");
|
|
117
|
-
}
|
|
118
|
-
throw error;
|
|
119
|
-
}
|
|
120
|
-
if (status !== "Enabled") {
|
|
121
|
-
throw new import_row_storage_errors.ReportingRowStoreError(
|
|
122
|
-
"UNSAFE_BINDING",
|
|
123
|
-
"S3 bucket versioning must be enabled so row object deletes are fenced to one write"
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
async function assertCreateOnlyEnforced(client, Bucket, prefix, signal) {
|
|
128
|
-
const Key = `${prefix}/.adcp-probe/${(0, import_node_crypto.randomUUID)()}`;
|
|
129
|
-
const written = [];
|
|
130
|
-
const put = async (body) => {
|
|
131
|
-
const output = await putCreateOnly(
|
|
132
|
-
client,
|
|
133
|
-
{ Bucket, Key, Body: Buffer.from(body), ContentType: "application/x-ndjson", CacheControl: "no-store" },
|
|
134
|
-
signal
|
|
135
|
-
);
|
|
136
|
-
written.push(output);
|
|
137
|
-
versionOf(output);
|
|
138
|
-
};
|
|
139
|
-
try {
|
|
140
|
-
try {
|
|
141
|
-
await put('{"probe":1}\n');
|
|
142
|
-
} catch (error) {
|
|
143
|
-
if (isNotImplemented(error) || isPreconditionFailed(error)) {
|
|
144
|
-
throw new import_row_storage_errors.ReportingRowStoreError("UNSAFE_BINDING", "store does not support create-only writes");
|
|
145
|
-
}
|
|
146
|
-
throw error;
|
|
147
|
-
}
|
|
148
|
-
try {
|
|
149
|
-
await put('{"probe":2}\n');
|
|
150
|
-
} catch (error) {
|
|
151
|
-
if (isPreconditionFailed(error)) return;
|
|
152
|
-
if (isNotImplemented(error)) {
|
|
153
|
-
throw new import_row_storage_errors.ReportingRowStoreError("UNSAFE_BINDING", "store does not support create-only writes");
|
|
154
|
-
}
|
|
155
|
-
throw error;
|
|
156
|
-
}
|
|
157
|
-
throw new import_row_storage_errors.ReportingRowStoreError("UNSAFE_BINDING", "store ignores If-None-Match and replaces objects");
|
|
158
|
-
} finally {
|
|
159
|
-
const versionIds = written.map((output) => output.VersionId).filter((id) => !!id);
|
|
160
|
-
const deletes = versionIds.length > 0 ? versionIds.map((VersionId) => ({ VersionId })) : written.length ? [{}] : [];
|
|
161
|
-
for (const selector of deletes) {
|
|
162
|
-
if (signal.aborted) break;
|
|
163
|
-
await client.send(new import_client_s3.DeleteObjectCommand({ Bucket, Key, ...selector }), { abortSignal: signal }).catch(() => void 0);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return {
|
|
168
|
-
name: "s3",
|
|
169
|
-
rangedReads: true,
|
|
170
|
-
validateLocation,
|
|
171
|
-
probe(input, context) {
|
|
172
|
-
return (0, import_row_storage_provider_io.runReportingRowProviderOperation)(context.signal, async () => {
|
|
173
|
-
const { client, Bucket } = target(input);
|
|
174
|
-
const signal = context.signal;
|
|
175
|
-
try {
|
|
176
|
-
await client.send(new import_client_s3.HeadBucketCommand({ Bucket }), { abortSignal: signal });
|
|
177
|
-
} catch (error) {
|
|
178
|
-
if (isNotFound(error)) throw new import_row_storage_errors.ReportingRowStoreError("UNSAFE_BINDING", "bucket does not exist");
|
|
179
|
-
if (isForbidden(error)) throw new import_row_storage_errors.ReportingRowStoreError("UNSAFE_BINDING", "bucket is not accessible");
|
|
180
|
-
if (statusOf(error) === 301) {
|
|
181
|
-
throw new import_row_storage_errors.ReportingRowStoreError("UNSAFE_BINDING", "bucket is in a different region");
|
|
182
|
-
}
|
|
183
|
-
throw error;
|
|
184
|
-
}
|
|
185
|
-
if (input.location.region !== void 0) {
|
|
186
|
-
const configured = client.config?.region;
|
|
187
|
-
const region = typeof configured === "function" ? await configured() : configured;
|
|
188
|
-
if (region !== input.location.region) {
|
|
189
|
-
throw new import_row_storage_errors.ReportingRowStoreError("UNSAFE_BINDING", "client region does not match the binding");
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
const policy = await client.send(new import_client_s3.GetBucketPolicyStatusCommand({ Bucket }), { abortSignal: signal }).catch(() => void 0);
|
|
193
|
-
if (policy?.PolicyStatus?.IsPublic === true) {
|
|
194
|
-
throw new import_row_storage_errors.ReportingRowStoreError("UNSAFE_BINDING", "bucket policy makes objects public");
|
|
195
|
-
}
|
|
196
|
-
let rules = [];
|
|
197
|
-
try {
|
|
198
|
-
const lifecycle = await client.send(new import_client_s3.GetBucketLifecycleConfigurationCommand({ Bucket }), {
|
|
199
|
-
abortSignal: signal
|
|
200
|
-
});
|
|
201
|
-
rules = lifecycle.Rules ?? [];
|
|
202
|
-
} catch (error) {
|
|
203
|
-
if (isForbidden(error)) {
|
|
204
|
-
throw new import_row_storage_errors.ReportingRowStoreError("UNSAFE_BINDING", "bucket lifecycle cannot be read with this client");
|
|
205
|
-
}
|
|
206
|
-
if (!isNotFound(error) && !isNotImplemented(error) && nameOf(error) !== "NoSuchLifecycleConfiguration") {
|
|
207
|
-
throw error;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
if (rules.some((rule) => liveExpirationCovers(rule, input.prefix))) {
|
|
211
|
-
throw new import_row_storage_errors.ReportingRowStoreError("UNSAFE_BINDING", "a bucket lifecycle rule can expire live row objects");
|
|
212
|
-
}
|
|
213
|
-
await assertVersioningEnabled(client, Bucket, signal);
|
|
214
|
-
await assertCreateOnlyEnforced(client, Bucket, input.prefix, signal);
|
|
215
|
-
});
|
|
216
|
-
},
|
|
217
|
-
putIfAbsent(input, context) {
|
|
218
|
-
return (0, import_row_storage_provider_io.runReportingRowProviderOperation)(context.signal, async () => {
|
|
219
|
-
const { client, Bucket } = target(input);
|
|
220
|
-
assertKey(input.objectRef);
|
|
221
|
-
const bytes = Buffer.from(input.bytes);
|
|
222
|
-
try {
|
|
223
|
-
const output = await putCreateOnly(
|
|
224
|
-
client,
|
|
225
|
-
{
|
|
226
|
-
Bucket,
|
|
227
|
-
Key: input.objectRef,
|
|
228
|
-
Body: bytes,
|
|
229
|
-
ContentLength: bytes.byteLength,
|
|
230
|
-
ContentType: input.contentType,
|
|
231
|
-
CacheControl: "no-store",
|
|
232
|
-
Metadata: { ...input.metadata }
|
|
233
|
-
},
|
|
234
|
-
context.signal
|
|
235
|
-
);
|
|
236
|
-
return { created: true, nativeVersionRef: versionOf(output) };
|
|
237
|
-
} catch (error) {
|
|
238
|
-
if (!isPreconditionFailed(error)) throw error;
|
|
239
|
-
}
|
|
240
|
-
const head = await client.send(new import_client_s3.HeadObjectCommand({ Bucket, Key: input.objectRef }), {
|
|
241
|
-
abortSignal: context.signal
|
|
242
|
-
});
|
|
243
|
-
return { created: false, nativeVersionRef: versionOf(head) };
|
|
244
|
-
});
|
|
245
|
-
},
|
|
246
|
-
get(input, context) {
|
|
247
|
-
return (0, import_row_storage_provider_io.runReportingRowProviderOperation)(context.signal, async () => {
|
|
248
|
-
const { client, Bucket } = target(input);
|
|
249
|
-
assertKey(input.objectRef);
|
|
250
|
-
(0, import_row_storage_provider_io.assertReportingRowReadBounds)(input);
|
|
251
|
-
const selector = selectorOf(input.nativeVersionRef);
|
|
252
|
-
if (selector === null) return null;
|
|
253
|
-
const Key = input.objectRef;
|
|
254
|
-
try {
|
|
255
|
-
if (input.range?.length === 0) {
|
|
256
|
-
const head = await client.send(new import_client_s3.HeadObjectCommand({ Bucket, Key, ...selector }), {
|
|
257
|
-
abortSignal: context.signal
|
|
258
|
-
});
|
|
259
|
-
if (!servedVersion(head, selector)) return null;
|
|
260
|
-
if (input.range.offset > Number(head.ContentLength ?? 0)) {
|
|
261
|
-
throw new import_row_storage_errors.ReportingRowStoreError("ROWS_INTEGRITY_FAILED", "requested range exceeds the stored object");
|
|
262
|
-
}
|
|
263
|
-
return Buffer.alloc(0);
|
|
264
|
-
}
|
|
265
|
-
const output = await client.send(
|
|
266
|
-
new import_client_s3.GetObjectCommand({
|
|
267
|
-
Bucket,
|
|
268
|
-
Key,
|
|
269
|
-
...selector,
|
|
270
|
-
...input.range ? { Range: `bytes=${input.range.offset}-${input.range.offset + input.range.length - 1}` } : {}
|
|
271
|
-
}),
|
|
272
|
-
{ abortSignal: context.signal }
|
|
273
|
-
);
|
|
274
|
-
const body = output.Body;
|
|
275
|
-
if (!body || typeof body[Symbol.asyncIterator] !== "function") {
|
|
276
|
-
throw new import_row_storage_errors.ReportingRowStoreError("PROVIDER_UNAVAILABLE", "object body is not a stream");
|
|
277
|
-
}
|
|
278
|
-
if (!servedVersion(output, selector)) {
|
|
279
|
-
body.destroy?.();
|
|
280
|
-
return null;
|
|
281
|
-
}
|
|
282
|
-
if (typeof output.ContentLength === "number" && output.ContentLength > input.maxBytes) {
|
|
283
|
-
body.destroy?.();
|
|
284
|
-
throw new import_row_storage_errors.ReportingRowStoreError("ROWS_INTEGRITY_FAILED", "stored object exceeds its recorded size");
|
|
285
|
-
}
|
|
286
|
-
return await (0, import_row_storage_provider_io.readReportingRowStream)(body, input.maxBytes, context.signal);
|
|
287
|
-
} catch (error) {
|
|
288
|
-
if (isNotFound(error) || isPreconditionFailed(error)) return null;
|
|
289
|
-
if (statusOf(error) === 400 && nameOf(error) !== "InvalidRange") return null;
|
|
290
|
-
if (isRangeError(error)) {
|
|
291
|
-
throw new import_row_storage_errors.ReportingRowStoreError("ROWS_INTEGRITY_FAILED", "requested range exceeds the stored object");
|
|
292
|
-
}
|
|
293
|
-
throw error;
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
},
|
|
297
|
-
stat(input, context) {
|
|
298
|
-
return (0, import_row_storage_provider_io.runReportingRowProviderOperation)(context.signal, async () => {
|
|
299
|
-
const { client, Bucket } = target(input);
|
|
300
|
-
assertKey(input.objectRef);
|
|
301
|
-
const selector = selectorOf(input.nativeVersionRef);
|
|
302
|
-
if (selector === null) return null;
|
|
303
|
-
try {
|
|
304
|
-
const head = await client.send(new import_client_s3.HeadObjectCommand({ Bucket, Key: input.objectRef, ...selector }), {
|
|
305
|
-
abortSignal: context.signal
|
|
306
|
-
});
|
|
307
|
-
if (!servedVersion(head, selector)) return null;
|
|
308
|
-
const size = head.ContentLength;
|
|
309
|
-
if (typeof size !== "number" || !Number.isSafeInteger(size) || size < 0) {
|
|
310
|
-
throw new import_row_storage_errors.ReportingRowStoreError("PROVIDER_UNAVAILABLE", "object metadata is malformed");
|
|
311
|
-
}
|
|
312
|
-
return { nativeVersionRef: selector.VersionId, sizeBytes: size };
|
|
313
|
-
} catch (error) {
|
|
314
|
-
if (isNotFound(error) || isPreconditionFailed(error)) return null;
|
|
315
|
-
if (statusOf(error) === 400 || statusOf(error) === 405) return null;
|
|
316
|
-
throw error;
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
|
-
},
|
|
320
|
-
delete(input, context) {
|
|
321
|
-
return (0, import_row_storage_provider_io.runReportingRowProviderOperation)(context.signal, async () => {
|
|
322
|
-
const { client, Bucket } = target(input);
|
|
323
|
-
assertKey(input.objectRef);
|
|
324
|
-
const selector = selectorOf(input.nativeVersionRef);
|
|
325
|
-
if (selector === null) return "absent";
|
|
326
|
-
const Key = input.objectRef;
|
|
327
|
-
const signal = context.signal;
|
|
328
|
-
try {
|
|
329
|
-
const head = await client.send(new import_client_s3.HeadObjectCommand({ Bucket, Key, ...selector }), { abortSignal: signal });
|
|
330
|
-
if (!servedVersion(head, selector)) return "absent";
|
|
331
|
-
} catch (error) {
|
|
332
|
-
if (isNotFound(error) || isPreconditionFailed(error)) return "absent";
|
|
333
|
-
if (statusOf(error) === 400 || statusOf(error) === 405) return "absent";
|
|
334
|
-
throw error;
|
|
335
|
-
}
|
|
336
|
-
await client.send(new import_client_s3.DeleteObjectCommand({ Bucket, Key, VersionId: selector.VersionId }), {
|
|
337
|
-
abortSignal: signal
|
|
338
|
-
});
|
|
339
|
-
return "deleted";
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
345
|
-
0 && (module.exports = {
|
|
346
|
-
createS3ReportingRowObjectProviderV1
|
|
347
|
-
});
|