@adcp/sdk 15.2.2 → 15.4.0
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/core/ConversationTypes.d.mts +5 -0
- package/dist/lib/core/ConversationTypes.d.ts +5 -0
- package/dist/lib/core/SingleAgentClient.d.mts +19 -1
- package/dist/lib/core/SingleAgentClient.d.ts +19 -1
- package/dist/lib/core/SingleAgentClient.js +38 -7
- package/dist/lib/core/SingleAgentClient.mjs +38 -7
- package/dist/lib/index.d.mts +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/reporting/ledger/handler.d.mts +6 -0
- package/dist/lib/reporting/ledger/handler.d.ts +6 -0
- package/dist/lib/reporting/ledger/handler.js +36 -7
- package/dist/lib/reporting/ledger/handler.mjs +35 -7
- package/dist/lib/reporting/ledger/index.d.mts +1 -0
- package/dist/lib/reporting/ledger/index.d.ts +1 -0
- package/dist/lib/reporting/ledger/index.js +3 -1
- package/dist/lib/reporting/ledger/index.mjs +1 -0
- package/dist/lib/reporting/ledger/lifecycle.js +3 -2
- package/dist/lib/reporting/ledger/lifecycle.mjs +3 -2
- package/dist/lib/reporting/ledger/managed-postgres.js +5 -5
- package/dist/lib/reporting/ledger/managed-postgres.mjs +5 -5
- package/dist/lib/reporting/ledger/postgres.d.mts +4 -1
- package/dist/lib/reporting/ledger/postgres.d.ts +4 -1
- package/dist/lib/reporting/ledger/postgres.js +38 -0
- package/dist/lib/reporting/ledger/postgres.mjs +38 -0
- package/dist/lib/reporting/ledger/producer.js +3 -2
- package/dist/lib/reporting/ledger/producer.mjs +3 -2
- package/dist/lib/reporting/ledger/revision-metadata.d.mts +17 -0
- package/dist/lib/reporting/ledger/revision-metadata.d.ts +17 -0
- package/dist/lib/reporting/ledger/revision-metadata.js +71 -0
- package/dist/lib/reporting/ledger/revision-metadata.mjs +44 -0
- package/dist/lib/reporting/ledger/row-encoding.d.mts +128 -0
- package/dist/lib/reporting/ledger/row-encoding.d.ts +128 -0
- package/dist/lib/reporting/ledger/row-encoding.js +355 -0
- package/dist/lib/reporting/ledger/row-encoding.mjs +315 -0
- package/dist/lib/reporting/ledger/types.d.mts +37 -0
- package/dist/lib/reporting/ledger/types.d.ts +37 -0
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/version.d.mts +3 -3
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.js +3 -3
- package/dist/lib/version.mjs +3 -3
- package/docs/TYPE-SUMMARY.md +2 -1
- package/docs/guides/PUSH-NOTIFICATION-CONFIG.md +39 -0
- package/docs/llms.txt +1 -1
- package/docs/migration-14.x-rc-worksheet.md +4 -4
- package/package.json +1 -1
|
@@ -121,6 +121,11 @@ export type WebhookUrlTemplate = string | {
|
|
|
121
121
|
* Options for task execution
|
|
122
122
|
*/
|
|
123
123
|
export interface TaskOptions {
|
|
124
|
+
/**
|
|
125
|
+
* Skip inline completion status handlers for this call and its continuations.
|
|
126
|
+
* Defaults to false. Independently delivered webhook handlers are unaffected.
|
|
127
|
+
*/
|
|
128
|
+
skipStatusHandlers?: boolean;
|
|
124
129
|
/**
|
|
125
130
|
* Absolute wall-clock deadline for the entire SDK task call (ms), including
|
|
126
131
|
* discovery and capability/version preflight. Unlike `workingTimeout`, this
|
|
@@ -121,6 +121,11 @@ export type WebhookUrlTemplate = string | {
|
|
|
121
121
|
* Options for task execution
|
|
122
122
|
*/
|
|
123
123
|
export interface TaskOptions {
|
|
124
|
+
/**
|
|
125
|
+
* Skip inline completion status handlers for this call and its continuations.
|
|
126
|
+
* Defaults to false. Independently delivered webhook handlers are unaffected.
|
|
127
|
+
*/
|
|
128
|
+
skipStatusHandlers?: boolean;
|
|
124
129
|
/**
|
|
125
130
|
* Absolute wall-clock deadline for the entire SDK task call (ms), including
|
|
126
131
|
* discovery and capability/version preflight. Unlike `workingTimeout`, this
|
|
@@ -9,7 +9,7 @@ type TaskStatusUpdateEvent = Record<string, any>;
|
|
|
9
9
|
import type { InputHandler, Message, TaskOptions, TaskResult, ConversationConfig, TaskInfo, TaskState, WebhookUrlTemplate, DirectPauseRecoveryRequest } from './ConversationTypes.mjs';
|
|
10
10
|
import type { AdcpTaskName, TaskRequestFor, TaskResponseTypeMap } from './AgentClient.mjs';
|
|
11
11
|
import type { DeferredTaskStorage } from '../storage/interfaces.mjs';
|
|
12
|
-
import type { Activity, AsyncHandlerConfig } from './AsyncHandler.mjs';
|
|
12
|
+
import type { Activity, AsyncHandlerConfig, WebhookMetadata } from './AsyncHandler.mjs';
|
|
13
13
|
import { type WebhookHeaderValue, type WebhookHeadersLike } from '../webhooks/index.mjs';
|
|
14
14
|
import { type WebhookRegistration, type WebhookRegistrationStore } from './webhook-registration.mjs';
|
|
15
15
|
import { type ReplayStore, type RevocationStore, type JwksResolver, type WebhookSignatureErrorCode, type ResolvedAgentJwksResolverOptions } from '../signing/server.mjs';
|
|
@@ -191,6 +191,11 @@ export declare class WebhookDispatchError extends Error {
|
|
|
191
191
|
readonly cause?: unknown;
|
|
192
192
|
constructor(code: WebhookParseErrorCode, message: string, cause?: unknown);
|
|
193
193
|
}
|
|
194
|
+
/** Context for an isolated inline completion status-handler failure. */
|
|
195
|
+
export interface StatusHandlerErrorContext {
|
|
196
|
+
handlerName: keyof AsyncHandlerConfig;
|
|
197
|
+
metadata: WebhookMetadata;
|
|
198
|
+
}
|
|
194
199
|
/**
|
|
195
200
|
* Configuration for SingleAgentClient (and multi-agent client)
|
|
196
201
|
*/
|
|
@@ -266,8 +271,21 @@ export interface SingleAgentClientConfig extends ConversationConfig {
|
|
|
266
271
|
* For at-least-once webhook delivery, set `handlers.webhookDedup` to
|
|
267
272
|
* drop duplicate retries by `idempotency_key`. See
|
|
268
273
|
* `docs/guides/PUSH-NOTIFICATION-CONFIG.md#deduplication`.
|
|
274
|
+
* For per-call skipping and inline error isolation, see
|
|
275
|
+
* `docs/guides/PUSH-NOTIFICATION-CONFIG.md#inline-completion-handlers`.
|
|
269
276
|
*/
|
|
270
277
|
handlers?: AsyncHandlerConfig;
|
|
278
|
+
/**
|
|
279
|
+
* Return successful completed results even if an inline status handler throws.
|
|
280
|
+
* Defaults to false, preserving handler rejection and durable finalization retry.
|
|
281
|
+
* Does not change webhook error handling or cancellation behavior.
|
|
282
|
+
*/
|
|
283
|
+
isolateStatusHandlerErrors?: boolean;
|
|
284
|
+
/**
|
|
285
|
+
* Reports inline status-handler errors when isolateStatusHandlerErrors is true.
|
|
286
|
+
* Errors thrown by this observer are recorded as warnings and do not reject the task.
|
|
287
|
+
*/
|
|
288
|
+
onStatusHandlerError?: (error: unknown, context: StatusHandlerErrorContext) => void | Promise<void>;
|
|
271
289
|
/** Select legacy HMAC-SHA256 push verification. Omit to use RFC 9421. */
|
|
272
290
|
webhookSecret?: string;
|
|
273
291
|
/** Durable provenance for outbound push registrations. Defaults to process-local memory. */
|
|
@@ -9,7 +9,7 @@ type TaskStatusUpdateEvent = Record<string, any>;
|
|
|
9
9
|
import type { InputHandler, Message, TaskOptions, TaskResult, ConversationConfig, TaskInfo, TaskState, WebhookUrlTemplate, DirectPauseRecoveryRequest } from './ConversationTypes';
|
|
10
10
|
import type { AdcpTaskName, TaskRequestFor, TaskResponseTypeMap } from './AgentClient';
|
|
11
11
|
import type { DeferredTaskStorage } from '../storage/interfaces';
|
|
12
|
-
import type { Activity, AsyncHandlerConfig } from './AsyncHandler';
|
|
12
|
+
import type { Activity, AsyncHandlerConfig, WebhookMetadata } from './AsyncHandler';
|
|
13
13
|
import { type WebhookHeaderValue, type WebhookHeadersLike } from '../webhooks';
|
|
14
14
|
import { type WebhookRegistration, type WebhookRegistrationStore } from './webhook-registration';
|
|
15
15
|
import { type ReplayStore, type RevocationStore, type JwksResolver, type WebhookSignatureErrorCode, type ResolvedAgentJwksResolverOptions } from '../signing/server';
|
|
@@ -191,6 +191,11 @@ export declare class WebhookDispatchError extends Error {
|
|
|
191
191
|
readonly cause?: unknown;
|
|
192
192
|
constructor(code: WebhookParseErrorCode, message: string, cause?: unknown);
|
|
193
193
|
}
|
|
194
|
+
/** Context for an isolated inline completion status-handler failure. */
|
|
195
|
+
export interface StatusHandlerErrorContext {
|
|
196
|
+
handlerName: keyof AsyncHandlerConfig;
|
|
197
|
+
metadata: WebhookMetadata;
|
|
198
|
+
}
|
|
194
199
|
/**
|
|
195
200
|
* Configuration for SingleAgentClient (and multi-agent client)
|
|
196
201
|
*/
|
|
@@ -266,8 +271,21 @@ export interface SingleAgentClientConfig extends ConversationConfig {
|
|
|
266
271
|
* For at-least-once webhook delivery, set `handlers.webhookDedup` to
|
|
267
272
|
* drop duplicate retries by `idempotency_key`. See
|
|
268
273
|
* `docs/guides/PUSH-NOTIFICATION-CONFIG.md#deduplication`.
|
|
274
|
+
* For per-call skipping and inline error isolation, see
|
|
275
|
+
* `docs/guides/PUSH-NOTIFICATION-CONFIG.md#inline-completion-handlers`.
|
|
269
276
|
*/
|
|
270
277
|
handlers?: AsyncHandlerConfig;
|
|
278
|
+
/**
|
|
279
|
+
* Return successful completed results even if an inline status handler throws.
|
|
280
|
+
* Defaults to false, preserving handler rejection and durable finalization retry.
|
|
281
|
+
* Does not change webhook error handling or cancellation behavior.
|
|
282
|
+
*/
|
|
283
|
+
isolateStatusHandlerErrors?: boolean;
|
|
284
|
+
/**
|
|
285
|
+
* Reports inline status-handler errors when isolateStatusHandlerErrors is true.
|
|
286
|
+
* Errors thrown by this observer are recorded as warnings and do not reject the task.
|
|
287
|
+
*/
|
|
288
|
+
onStatusHandlerError?: (error: unknown, context: StatusHandlerErrorContext) => void | Promise<void>;
|
|
271
289
|
/** Select legacy HMAC-SHA256 push verification. Omit to use RFC 9421. */
|
|
272
290
|
webhookSecret?: string;
|
|
273
291
|
/** Durable provenance for outbound push registrations. Defaults to process-local memory. */
|
|
@@ -240,7 +240,7 @@ const WEBHOOK_JWKS_RESOLVER_LIMIT = 1024;
|
|
|
240
240
|
function isDeferredClientFinalizationContext(value) {
|
|
241
241
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
242
242
|
const context = value;
|
|
243
|
-
return context.kind === "single-agent" && typeof context.taskType === "string" && typeof context.canonical === "boolean" && !!context.productPolicyRequest && typeof context.productPolicyRequest === "object" && !Array.isArray(context.productPolicyRequest) && (context.serverVersion === void 0 || context.serverVersion === "v2" || context.serverVersion === "v3") && (context.serverVersionSynthetic === void 0 || typeof context.serverVersionSynthetic === "boolean") && (context.projectionCatalogs === void 0 || Array.isArray(context.projectionCatalogs)) && (context.handlerName === void 0 || typeof context.handlerName === "string");
|
|
243
|
+
return context.kind === "single-agent" && typeof context.taskType === "string" && typeof context.canonical === "boolean" && !!context.productPolicyRequest && typeof context.productPolicyRequest === "object" && !Array.isArray(context.productPolicyRequest) && (context.serverVersion === void 0 || context.serverVersion === "v2" || context.serverVersion === "v3") && (context.serverVersionSynthetic === void 0 || typeof context.serverVersionSynthetic === "boolean") && (context.projectionCatalogs === void 0 || Array.isArray(context.projectionCatalogs)) && (context.handlerName === void 0 || typeof context.handlerName === "string") && (context.skipStatusHandlers === void 0 || typeof context.skipStatusHandlers === "boolean");
|
|
244
244
|
}
|
|
245
245
|
const CANONICAL_PACKAGE_ROUTE_TASKS = /* @__PURE__ */ new Set(["create_media_buy", "update_media_buy", "get_media_buys"]);
|
|
246
246
|
const canonicalCreativeRoutingSnapshots = /* @__PURE__ */ new WeakSet();
|
|
@@ -3189,7 +3189,10 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
3189
3189
|
...projectionCatalogs !== void 0 && { projectionCatalogs },
|
|
3190
3190
|
...routingSnapshot !== void 0 && { routingSnapshot },
|
|
3191
3191
|
...effectiveOptions?.taskId !== void 0 && { optionTaskId: effectiveOptions.taskId },
|
|
3192
|
-
...effectiveOptions?.contextId !== void 0 && { optionContextId: effectiveOptions.contextId }
|
|
3192
|
+
...effectiveOptions?.contextId !== void 0 && { optionContextId: effectiveOptions.contextId },
|
|
3193
|
+
...effectiveOptions?.skipStatusHandlers !== void 0 && {
|
|
3194
|
+
skipStatusHandlers: effectiveOptions.skipStatusHandlers
|
|
3195
|
+
}
|
|
3193
3196
|
};
|
|
3194
3197
|
let result = await canonicalCreativeExecutionStorage.run(
|
|
3195
3198
|
{
|
|
@@ -3300,7 +3303,8 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
3300
3303
|
const resumedOptions = {
|
|
3301
3304
|
...options ?? {},
|
|
3302
3305
|
...context.optionTaskId !== void 0 && { taskId: context.optionTaskId },
|
|
3303
|
-
...context.optionContextId !== void 0 && { contextId: context.optionContextId }
|
|
3306
|
+
...context.optionContextId !== void 0 && { contextId: context.optionContextId },
|
|
3307
|
+
...context.skipStatusHandlers !== void 0 && { skipStatusHandlers: context.skipStatusHandlers }
|
|
3304
3308
|
};
|
|
3305
3309
|
const rawDeferredResume = result.deferred?.resume;
|
|
3306
3310
|
const rawSubmittedWaitForCompletion = result.submitted?.waitForCompletion;
|
|
@@ -3390,11 +3394,12 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
3390
3394
|
return finalized;
|
|
3391
3395
|
}
|
|
3392
3396
|
async notifyCompletedStatusHandler(result, taskType, handlerName, options) {
|
|
3393
|
-
if (result.status !== "completed" || !result.success || !this.asyncHandler)
|
|
3397
|
+
if (options?.skipStatusHandlers === true || result.status !== "completed" || !result.success || !this.asyncHandler)
|
|
3398
|
+
return;
|
|
3394
3399
|
const handler = this.config.handlers?.[handlerName];
|
|
3395
3400
|
if (!handler) return;
|
|
3396
3401
|
(0, import_abort2.throwIfAborted)(options?.signal);
|
|
3397
|
-
|
|
3402
|
+
const metadata = {
|
|
3398
3403
|
operation_id: options?.contextId || "sync",
|
|
3399
3404
|
context_id: options?.contextId,
|
|
3400
3405
|
task_id: result.metadata.taskId,
|
|
@@ -3402,7 +3407,30 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
3402
3407
|
task_type: taskType,
|
|
3403
3408
|
status: result.status,
|
|
3404
3409
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
3405
|
-
}
|
|
3410
|
+
};
|
|
3411
|
+
try {
|
|
3412
|
+
await handler(result.data, metadata);
|
|
3413
|
+
} catch (error) {
|
|
3414
|
+
if (this.config.isolateStatusHandlerErrors !== true) throw error;
|
|
3415
|
+
(0, import_abort2.throwIfAborted)(options?.signal);
|
|
3416
|
+
result.debug_logs = [
|
|
3417
|
+
...result.debug_logs ?? [],
|
|
3418
|
+
{
|
|
3419
|
+
level: "warn",
|
|
3420
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3421
|
+
message: "Inline status handler failed. The seller operation completed; reconcile local post-processing."
|
|
3422
|
+
}
|
|
3423
|
+
];
|
|
3424
|
+
try {
|
|
3425
|
+
await this.config.onStatusHandlerError?.(error, { handlerName, metadata });
|
|
3426
|
+
} catch {
|
|
3427
|
+
result.debug_logs.push({
|
|
3428
|
+
level: "warn",
|
|
3429
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3430
|
+
message: "onStatusHandlerError observer failed. The seller operation completed."
|
|
3431
|
+
});
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3406
3434
|
(0, import_abort2.throwIfAborted)(options?.signal);
|
|
3407
3435
|
}
|
|
3408
3436
|
canonicalCreativeInputHandler(taskType, inputHandler, canonical = CANONICAL_CREATIVE_ACTIVITY_TASKS.has(taskType)) {
|
|
@@ -5678,7 +5706,10 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
5678
5706
|
productPolicyRequest: productPolicyRequestSnapshot(normalizedParams),
|
|
5679
5707
|
accountRegistry: this.accountRegistryContext(taskName, normalizedParams, effectiveOptions),
|
|
5680
5708
|
...effectiveOptions?.taskId !== void 0 && { optionTaskId: effectiveOptions.taskId },
|
|
5681
|
-
...effectiveOptions?.contextId !== void 0 && { optionContextId: effectiveOptions.contextId }
|
|
5709
|
+
...effectiveOptions?.contextId !== void 0 && { optionContextId: effectiveOptions.contextId },
|
|
5710
|
+
...effectiveOptions?.skipStatusHandlers !== void 0 && {
|
|
5711
|
+
skipStatusHandlers: effectiveOptions.skipStatusHandlers
|
|
5712
|
+
}
|
|
5682
5713
|
};
|
|
5683
5714
|
let result = await this.executor.executeTask(
|
|
5684
5715
|
agent,
|
|
@@ -310,7 +310,7 @@ const WEBHOOK_JWKS_RESOLVER_LIMIT = 1024;
|
|
|
310
310
|
function isDeferredClientFinalizationContext(value) {
|
|
311
311
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
312
312
|
const context = value;
|
|
313
|
-
return context.kind === "single-agent" && typeof context.taskType === "string" && typeof context.canonical === "boolean" && !!context.productPolicyRequest && typeof context.productPolicyRequest === "object" && !Array.isArray(context.productPolicyRequest) && (context.serverVersion === void 0 || context.serverVersion === "v2" || context.serverVersion === "v3") && (context.serverVersionSynthetic === void 0 || typeof context.serverVersionSynthetic === "boolean") && (context.projectionCatalogs === void 0 || Array.isArray(context.projectionCatalogs)) && (context.handlerName === void 0 || typeof context.handlerName === "string");
|
|
313
|
+
return context.kind === "single-agent" && typeof context.taskType === "string" && typeof context.canonical === "boolean" && !!context.productPolicyRequest && typeof context.productPolicyRequest === "object" && !Array.isArray(context.productPolicyRequest) && (context.serverVersion === void 0 || context.serverVersion === "v2" || context.serverVersion === "v3") && (context.serverVersionSynthetic === void 0 || typeof context.serverVersionSynthetic === "boolean") && (context.projectionCatalogs === void 0 || Array.isArray(context.projectionCatalogs)) && (context.handlerName === void 0 || typeof context.handlerName === "string") && (context.skipStatusHandlers === void 0 || typeof context.skipStatusHandlers === "boolean");
|
|
314
314
|
}
|
|
315
315
|
const CANONICAL_PACKAGE_ROUTE_TASKS = /* @__PURE__ */ new Set(["create_media_buy", "update_media_buy", "get_media_buys"]);
|
|
316
316
|
const canonicalCreativeRoutingSnapshots = /* @__PURE__ */ new WeakSet();
|
|
@@ -3259,7 +3259,10 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
3259
3259
|
...projectionCatalogs !== void 0 && { projectionCatalogs },
|
|
3260
3260
|
...routingSnapshot !== void 0 && { routingSnapshot },
|
|
3261
3261
|
...effectiveOptions?.taskId !== void 0 && { optionTaskId: effectiveOptions.taskId },
|
|
3262
|
-
...effectiveOptions?.contextId !== void 0 && { optionContextId: effectiveOptions.contextId }
|
|
3262
|
+
...effectiveOptions?.contextId !== void 0 && { optionContextId: effectiveOptions.contextId },
|
|
3263
|
+
...effectiveOptions?.skipStatusHandlers !== void 0 && {
|
|
3264
|
+
skipStatusHandlers: effectiveOptions.skipStatusHandlers
|
|
3265
|
+
}
|
|
3263
3266
|
};
|
|
3264
3267
|
let result = await canonicalCreativeExecutionStorage.run(
|
|
3265
3268
|
{
|
|
@@ -3370,7 +3373,8 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
3370
3373
|
const resumedOptions = {
|
|
3371
3374
|
...options ?? {},
|
|
3372
3375
|
...context.optionTaskId !== void 0 && { taskId: context.optionTaskId },
|
|
3373
|
-
...context.optionContextId !== void 0 && { contextId: context.optionContextId }
|
|
3376
|
+
...context.optionContextId !== void 0 && { contextId: context.optionContextId },
|
|
3377
|
+
...context.skipStatusHandlers !== void 0 && { skipStatusHandlers: context.skipStatusHandlers }
|
|
3374
3378
|
};
|
|
3375
3379
|
const rawDeferredResume = result.deferred?.resume;
|
|
3376
3380
|
const rawSubmittedWaitForCompletion = result.submitted?.waitForCompletion;
|
|
@@ -3460,11 +3464,12 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
3460
3464
|
return finalized;
|
|
3461
3465
|
}
|
|
3462
3466
|
async notifyCompletedStatusHandler(result, taskType, handlerName, options) {
|
|
3463
|
-
if (result.status !== "completed" || !result.success || !this.asyncHandler)
|
|
3467
|
+
if (options?.skipStatusHandlers === true || result.status !== "completed" || !result.success || !this.asyncHandler)
|
|
3468
|
+
return;
|
|
3464
3469
|
const handler = this.config.handlers?.[handlerName];
|
|
3465
3470
|
if (!handler) return;
|
|
3466
3471
|
throwIfAborted(options?.signal);
|
|
3467
|
-
|
|
3472
|
+
const metadata = {
|
|
3468
3473
|
operation_id: options?.contextId || "sync",
|
|
3469
3474
|
context_id: options?.contextId,
|
|
3470
3475
|
task_id: result.metadata.taskId,
|
|
@@ -3472,7 +3477,30 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
3472
3477
|
task_type: taskType,
|
|
3473
3478
|
status: result.status,
|
|
3474
3479
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
3475
|
-
}
|
|
3480
|
+
};
|
|
3481
|
+
try {
|
|
3482
|
+
await handler(result.data, metadata);
|
|
3483
|
+
} catch (error) {
|
|
3484
|
+
if (this.config.isolateStatusHandlerErrors !== true) throw error;
|
|
3485
|
+
throwIfAborted(options?.signal);
|
|
3486
|
+
result.debug_logs = [
|
|
3487
|
+
...result.debug_logs ?? [],
|
|
3488
|
+
{
|
|
3489
|
+
level: "warn",
|
|
3490
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3491
|
+
message: "Inline status handler failed. The seller operation completed; reconcile local post-processing."
|
|
3492
|
+
}
|
|
3493
|
+
];
|
|
3494
|
+
try {
|
|
3495
|
+
await this.config.onStatusHandlerError?.(error, { handlerName, metadata });
|
|
3496
|
+
} catch {
|
|
3497
|
+
result.debug_logs.push({
|
|
3498
|
+
level: "warn",
|
|
3499
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3500
|
+
message: "onStatusHandlerError observer failed. The seller operation completed."
|
|
3501
|
+
});
|
|
3502
|
+
}
|
|
3503
|
+
}
|
|
3476
3504
|
throwIfAborted(options?.signal);
|
|
3477
3505
|
}
|
|
3478
3506
|
canonicalCreativeInputHandler(taskType, inputHandler, canonical = CANONICAL_CREATIVE_ACTIVITY_TASKS.has(taskType)) {
|
|
@@ -5748,7 +5776,10 @@ Hint: this usually means agent_uri does not include the MCP endpoint path. The S
|
|
|
5748
5776
|
productPolicyRequest: productPolicyRequestSnapshot(normalizedParams),
|
|
5749
5777
|
accountRegistry: this.accountRegistryContext(taskName, normalizedParams, effectiveOptions),
|
|
5750
5778
|
...effectiveOptions?.taskId !== void 0 && { optionTaskId: effectiveOptions.taskId },
|
|
5751
|
-
...effectiveOptions?.contextId !== void 0 && { optionContextId: effectiveOptions.contextId }
|
|
5779
|
+
...effectiveOptions?.contextId !== void 0 && { optionContextId: effectiveOptions.contextId },
|
|
5780
|
+
...effectiveOptions?.skipStatusHandlers !== void 0 && {
|
|
5781
|
+
skipStatusHandlers: effectiveOptions.skipStatusHandlers
|
|
5782
|
+
}
|
|
5752
5783
|
};
|
|
5753
5784
|
let result = await this.executor.executeTask(
|
|
5754
5785
|
agent,
|
package/dist/lib/index.d.mts
CHANGED
|
@@ -14,7 +14,7 @@ export { resolveInlinePublisherProperties, resolveSingularInline, detectInlineFe
|
|
|
14
14
|
export { fetchAgentAuthorizationsFromDirectory, type AgentAuthorizationsIterator, type FetchAgentAuthorizationsOptions, type DirectoryLookupPage, type DirectoryPublisherEntry, type DirectoryDiscoveryMethod, type DirectoryPublisherStatus, } from './discovery/agent-directory.mjs';
|
|
15
15
|
export { validateAdAgents, parseManagerDomain, type DiscoveryMethod, type AdAgentsValidationResult, type ValidateAdAgentsOptions, } from './discovery/validate-adagents.mjs';
|
|
16
16
|
export { SingleAgentClient, WebhookDispatchError, createSingleAgentClient, UnsupportedFeatureError, } from './core/SingleAgentClient.mjs';
|
|
17
|
-
export type { CapabilityEvidenceScope, CapabilityEvidenceSnapshot, ClientProductPropertyPolicy, CreativeDeliveryTaskOptions, SingleAgentClientConfig, SyncCreativesTaskOptions, VerifyAndParseWebhookOptions, WebhookHandlerAdapter, WebhookHandlerRequest, WebhookRequestContext, WebhookParseErrorCode, WebhookParseFailure, WebhookParseResult, WebhookParseSuccess, WebhookVerificationConfig, } from './core/SingleAgentClient.mjs';
|
|
17
|
+
export type { CapabilityEvidenceScope, CapabilityEvidenceSnapshot, ClientProductPropertyPolicy, CreativeDeliveryTaskOptions, SingleAgentClientConfig, StatusHandlerErrorContext, SyncCreativesTaskOptions, VerifyAndParseWebhookOptions, WebhookHandlerAdapter, WebhookHandlerRequest, WebhookRequestContext, WebhookParseErrorCode, WebhookParseFailure, WebhookParseResult, WebhookParseSuccess, WebhookVerificationConfig, } from './core/SingleAgentClient.mjs';
|
|
18
18
|
export { InMemoryWebhookRegistrationStore, type InMemoryWebhookRegistrationStoreOptions, type WebhookAuthenticationMode, type WebhookRegistration, type WebhookRegistrationStore, } from './core/webhook-registration.mjs';
|
|
19
19
|
export { pgWebhookRegistrationStore, getWebhookRegistrationMigration, WEBHOOK_REGISTRATION_MIGRATION, cleanupExpiredWebhookRegistrations, type PgWebhookRegistrationStoreOptions, type CleanupExpiredWebhookRegistrationsOptions, } from './core/postgres-webhook-registration-store.mjs';
|
|
20
20
|
export { redisWebhookRegistrationStore, type RedisWebhookRegistrationStoreOptions, } from './core/redis-webhook-registration-store.mjs';
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export { resolveInlinePublisherProperties, resolveSingularInline, detectInlineFe
|
|
|
14
14
|
export { fetchAgentAuthorizationsFromDirectory, type AgentAuthorizationsIterator, type FetchAgentAuthorizationsOptions, type DirectoryLookupPage, type DirectoryPublisherEntry, type DirectoryDiscoveryMethod, type DirectoryPublisherStatus, } from './discovery/agent-directory';
|
|
15
15
|
export { validateAdAgents, parseManagerDomain, type DiscoveryMethod, type AdAgentsValidationResult, type ValidateAdAgentsOptions, } from './discovery/validate-adagents';
|
|
16
16
|
export { SingleAgentClient, WebhookDispatchError, createSingleAgentClient, UnsupportedFeatureError, } from './core/SingleAgentClient';
|
|
17
|
-
export type { CapabilityEvidenceScope, CapabilityEvidenceSnapshot, ClientProductPropertyPolicy, CreativeDeliveryTaskOptions, SingleAgentClientConfig, SyncCreativesTaskOptions, VerifyAndParseWebhookOptions, WebhookHandlerAdapter, WebhookHandlerRequest, WebhookRequestContext, WebhookParseErrorCode, WebhookParseFailure, WebhookParseResult, WebhookParseSuccess, WebhookVerificationConfig, } from './core/SingleAgentClient';
|
|
17
|
+
export type { CapabilityEvidenceScope, CapabilityEvidenceSnapshot, ClientProductPropertyPolicy, CreativeDeliveryTaskOptions, SingleAgentClientConfig, StatusHandlerErrorContext, SyncCreativesTaskOptions, VerifyAndParseWebhookOptions, WebhookHandlerAdapter, WebhookHandlerRequest, WebhookRequestContext, WebhookParseErrorCode, WebhookParseFailure, WebhookParseResult, WebhookParseSuccess, WebhookVerificationConfig, } from './core/SingleAgentClient';
|
|
18
18
|
export { InMemoryWebhookRegistrationStore, type InMemoryWebhookRegistrationStoreOptions, type WebhookAuthenticationMode, type WebhookRegistration, type WebhookRegistrationStore, } from './core/webhook-registration';
|
|
19
19
|
export { pgWebhookRegistrationStore, getWebhookRegistrationMigration, WEBHOOK_REGISTRATION_MIGRATION, cleanupExpiredWebhookRegistrations, type PgWebhookRegistrationStoreOptions, type CleanupExpiredWebhookRegistrationsOptions, } from './core/postgres-webhook-registration-store';
|
|
20
20
|
export { redisWebhookRegistrationStore, type RedisWebhookRegistrationStoreOptions, } from './core/redis-webhook-registration-store';
|
|
@@ -15,6 +15,12 @@ export interface ReportingStatusConsumerScopeOptionsV1<TContext = unknown> {
|
|
|
15
15
|
}
|
|
16
16
|
export declare function createReportingStatusHandler(store: ReportingLedgerStore): (request: Parameters<ReportingStatusHandlerV1>[0], context: Pick<Parameters<ReportingStatusHandlerV1>[1], 'account' | 'signal'>) => ReturnType<ReportingStatusHandlerV1>;
|
|
17
17
|
export declare function createReportingStatusHandler<TContext = unknown>(store: ReportingLedgerStore, options?: ReportingStatusConsumerScopeOptionsV1<TContext>): ReportingStatusHandlerV1;
|
|
18
|
+
/**
|
|
19
|
+
* Largest revision whose rows the `get_reporting_status` `revision` view
|
|
20
|
+
* returns inline. Larger revisions omit `reporting_rows` there; callers page
|
|
21
|
+
* them through the exact `get_media_buy_delivery` read.
|
|
22
|
+
*/
|
|
23
|
+
export declare const REPORTING_STATUS_REVISION_VIEW_MAX_ROWS = 10000;
|
|
18
24
|
/** Exact revision reader for createAdcpServer's getMediaBuyDelivery slot. */
|
|
19
25
|
export declare function createReportingDeliveryHandler(store: ReportingLedgerStore): ReportingDeliveryHandlerV1;
|
|
20
26
|
export interface ProjectManagedDeliveryInputV1 {
|
|
@@ -15,6 +15,12 @@ export interface ReportingStatusConsumerScopeOptionsV1<TContext = unknown> {
|
|
|
15
15
|
}
|
|
16
16
|
export declare function createReportingStatusHandler(store: ReportingLedgerStore): (request: Parameters<ReportingStatusHandlerV1>[0], context: Pick<Parameters<ReportingStatusHandlerV1>[1], 'account' | 'signal'>) => ReturnType<ReportingStatusHandlerV1>;
|
|
17
17
|
export declare function createReportingStatusHandler<TContext = unknown>(store: ReportingLedgerStore, options?: ReportingStatusConsumerScopeOptionsV1<TContext>): ReportingStatusHandlerV1;
|
|
18
|
+
/**
|
|
19
|
+
* Largest revision whose rows the `get_reporting_status` `revision` view
|
|
20
|
+
* returns inline. Larger revisions omit `reporting_rows` there; callers page
|
|
21
|
+
* them through the exact `get_media_buy_delivery` read.
|
|
22
|
+
*/
|
|
23
|
+
export declare const REPORTING_STATUS_REVISION_VIEW_MAX_ROWS = 10000;
|
|
18
24
|
/** Exact revision reader for createAdcpServer's getMediaBuyDelivery slot. */
|
|
19
25
|
export declare function createReportingDeliveryHandler(store: ReportingLedgerStore): ReportingDeliveryHandlerV1;
|
|
20
26
|
export interface ProjectManagedDeliveryInputV1 {
|
|
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var handler_exports = {};
|
|
20
20
|
__export(handler_exports, {
|
|
21
|
+
REPORTING_STATUS_REVISION_VIEW_MAX_ROWS: () => REPORTING_STATUS_REVISION_VIEW_MAX_ROWS,
|
|
21
22
|
ReportingReadCapacityError: () => ReportingReadCapacityError,
|
|
22
23
|
acquireAccountReadSlot: () => acquireAccountReadSlot,
|
|
23
24
|
aggregateReportingCoverageV1: () => aggregateReportingCoverageV1,
|
|
@@ -34,6 +35,7 @@ var import_source = require('../source/index.js');
|
|
|
34
35
|
var import_coverage = require('./coverage.js');
|
|
35
36
|
var import_health = require('./health.js');
|
|
36
37
|
var import_instant = require('./instant.js');
|
|
38
|
+
var import_revision_metadata = require('./revision-metadata.js');
|
|
37
39
|
var import_schedule = require('./schedule.js');
|
|
38
40
|
var import_types = require('./types.js');
|
|
39
41
|
function createReportingStatusHandler(store, options) {
|
|
@@ -248,9 +250,22 @@ function createReportingStatusHandler(store, options) {
|
|
|
248
250
|
const id = query.reporting_revision_id;
|
|
249
251
|
const inSnapshot = id ? page.snapshot.revisions.some((value) => value.reporting_revision_id === id) : false;
|
|
250
252
|
let revision = null;
|
|
253
|
+
let revisionRows;
|
|
251
254
|
if (id && inSnapshot) {
|
|
252
255
|
try {
|
|
253
|
-
revision = await
|
|
256
|
+
revision = await (0, import_revision_metadata.getRevisionMetadataFromStore)(store, id, accountId);
|
|
257
|
+
const rowCount = revision?.binding.rowCount ?? 0;
|
|
258
|
+
if (revision && rowCount <= REPORTING_STATUS_REVISION_VIEW_MAX_ROWS) {
|
|
259
|
+
const page2 = rowCount === 0 ? { rows: [], total: 0 } : await (0, import_revision_metadata.readRevisionRowsFromStore)(store, {
|
|
260
|
+
reporting_revision_id: id,
|
|
261
|
+
account_id: accountId,
|
|
262
|
+
offset: 0,
|
|
263
|
+
limit: rowCount,
|
|
264
|
+
...context.signal ? { signal: context.signal } : {}
|
|
265
|
+
});
|
|
266
|
+
if (!page2 || page2.total !== rowCount) revision = null;
|
|
267
|
+
else revisionRows = page2.rows;
|
|
268
|
+
}
|
|
254
269
|
} catch (error) {
|
|
255
270
|
if (error instanceof ReportingReadCapacityError) return lookupUnavailable(view);
|
|
256
271
|
throw error;
|
|
@@ -278,7 +293,7 @@ function createReportingStatusHandler(store, options) {
|
|
|
278
293
|
revision_content_sha256: revision.wireRevision.revision_content_sha256,
|
|
279
294
|
row_count: revision.binding.rowCount
|
|
280
295
|
},
|
|
281
|
-
reporting_rows:
|
|
296
|
+
...revisionRows ? { reporting_rows: revisionRows } : {},
|
|
282
297
|
adjustments: revisionAdjustments.map((value) => value.wireAdjustment),
|
|
283
298
|
...consumerId ? { consumer_statuses: (page.consumerStatuses ?? []).map(wireConsumerStatus) } : {},
|
|
284
299
|
materializations: (page.materializations ?? []).filter(
|
|
@@ -391,6 +406,7 @@ function createReportingStatusHandler(store, options) {
|
|
|
391
406
|
}
|
|
392
407
|
};
|
|
393
408
|
}
|
|
409
|
+
const REPORTING_STATUS_REVISION_VIEW_MAX_ROWS = 1e4;
|
|
394
410
|
function createReportingDeliveryHandler(store) {
|
|
395
411
|
const activeReadsByAccount = /* @__PURE__ */ new Map();
|
|
396
412
|
return async (request, context) => {
|
|
@@ -411,7 +427,7 @@ function createReportingDeliveryHandler(store) {
|
|
|
411
427
|
if (typeof raw.reporting_revision_id !== "string" || !raw.reporting_revision_id) {
|
|
412
428
|
throw new Error("Ledger delivery reads require reporting_revision_id");
|
|
413
429
|
}
|
|
414
|
-
const revision = await
|
|
430
|
+
const revision = await (0, import_revision_metadata.getRevisionMetadataFromStore)(store, raw.reporting_revision_id, accountId);
|
|
415
431
|
if (!revision) throw new Error("Reporting revision is unavailable");
|
|
416
432
|
const obligation = await store.getObligation(revision.reporting_obligation_id);
|
|
417
433
|
if (!obligation || obligation.account.account_id !== accountId) {
|
|
@@ -419,11 +435,12 @@ function createReportingDeliveryHandler(store) {
|
|
|
419
435
|
}
|
|
420
436
|
const pagination = isRecord(raw.pagination) ? raw.pagination : {};
|
|
421
437
|
const maxResults = typeof pagination.max_results === "number" && Number.isFinite(pagination.max_results) ? Math.max(1, Math.min(500, Math.trunc(pagination.max_results))) : 100;
|
|
438
|
+
const totalCount = revision.binding.rowCount;
|
|
422
439
|
let offset = 0;
|
|
423
440
|
if (typeof pagination.cursor === "string") {
|
|
424
441
|
try {
|
|
425
442
|
const cursor = JSON.parse(Buffer.from(pagination.cursor, "base64url").toString("utf8"));
|
|
426
|
-
if (cursor.revisionId !== revision.reporting_revision_id || typeof cursor.offset !== "number" || !Number.isSafeInteger(cursor.offset) || cursor.offset < 0 || cursor.offset >=
|
|
443
|
+
if (cursor.revisionId !== revision.reporting_revision_id || typeof cursor.offset !== "number" || !Number.isSafeInteger(cursor.offset) || cursor.offset < 0 || cursor.offset >= totalCount) {
|
|
427
444
|
throw new Error("invalid");
|
|
428
445
|
}
|
|
429
446
|
offset = cursor.offset;
|
|
@@ -431,9 +448,20 @@ function createReportingDeliveryHandler(store) {
|
|
|
431
448
|
throw new Error("Reporting delivery cursor is invalid");
|
|
432
449
|
}
|
|
433
450
|
}
|
|
434
|
-
|
|
451
|
+
let reportingRows = [];
|
|
452
|
+
if (totalCount > 0) {
|
|
453
|
+
const page = await (0, import_revision_metadata.readRevisionRowsFromStore)(store, {
|
|
454
|
+
reporting_revision_id: revision.reporting_revision_id,
|
|
455
|
+
account_id: accountId,
|
|
456
|
+
offset,
|
|
457
|
+
limit: maxResults,
|
|
458
|
+
...context.signal ? { signal: context.signal } : {}
|
|
459
|
+
});
|
|
460
|
+
if (!page || page.total !== totalCount) throw new Error("Reporting revision is unavailable");
|
|
461
|
+
reportingRows = page.rows;
|
|
462
|
+
}
|
|
435
463
|
const nextOffset = offset + reportingRows.length;
|
|
436
|
-
const hasMore = nextOffset <
|
|
464
|
+
const hasMore = nextOffset < totalCount;
|
|
437
465
|
return {
|
|
438
466
|
reporting_period: { start: obligation.period.start, end: obligation.period.end },
|
|
439
467
|
media_buy_deliveries: [],
|
|
@@ -453,7 +481,7 @@ function createReportingDeliveryHandler(store) {
|
|
|
453
481
|
errors: [],
|
|
454
482
|
pagination: {
|
|
455
483
|
has_more: hasMore,
|
|
456
|
-
total_count:
|
|
484
|
+
total_count: totalCount,
|
|
457
485
|
...hasMore ? {
|
|
458
486
|
cursor: Buffer.from(
|
|
459
487
|
JSON.stringify({ revisionId: revision.reporting_revision_id, offset: nextOffset }),
|
|
@@ -966,6 +994,7 @@ function wireSchedule(obligation) {
|
|
|
966
994
|
}
|
|
967
995
|
// Annotate the CommonJS export names for ESM import in node:
|
|
968
996
|
0 && (module.exports = {
|
|
997
|
+
REPORTING_STATUS_REVISION_VIEW_MAX_ROWS,
|
|
969
998
|
ReportingReadCapacityError,
|
|
970
999
|
acquireAccountReadSlot,
|
|
971
1000
|
aggregateReportingCoverageV1,
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
projectReportingObligationHealthV1
|
|
19
19
|
} from "./health.mjs";
|
|
20
20
|
import { compareReportingInstants } from "./instant.mjs";
|
|
21
|
+
import { getRevisionMetadataFromStore, readRevisionRowsFromStore } from "./revision-metadata.mjs";
|
|
21
22
|
import { reportingPeriodSchedule } from "./schedule.mjs";
|
|
22
23
|
import { ReportingLedgerSnapshotUnavailableError } from "./types.mjs";
|
|
23
24
|
function createReportingStatusHandler(store, options) {
|
|
@@ -232,9 +233,22 @@ function createReportingStatusHandler(store, options) {
|
|
|
232
233
|
const id = query.reporting_revision_id;
|
|
233
234
|
const inSnapshot = id ? page.snapshot.revisions.some((value) => value.reporting_revision_id === id) : false;
|
|
234
235
|
let revision = null;
|
|
236
|
+
let revisionRows;
|
|
235
237
|
if (id && inSnapshot) {
|
|
236
238
|
try {
|
|
237
|
-
revision = await store
|
|
239
|
+
revision = await getRevisionMetadataFromStore(store, id, accountId);
|
|
240
|
+
const rowCount = revision?.binding.rowCount ?? 0;
|
|
241
|
+
if (revision && rowCount <= REPORTING_STATUS_REVISION_VIEW_MAX_ROWS) {
|
|
242
|
+
const page2 = rowCount === 0 ? { rows: [], total: 0 } : await readRevisionRowsFromStore(store, {
|
|
243
|
+
reporting_revision_id: id,
|
|
244
|
+
account_id: accountId,
|
|
245
|
+
offset: 0,
|
|
246
|
+
limit: rowCount,
|
|
247
|
+
...context.signal ? { signal: context.signal } : {}
|
|
248
|
+
});
|
|
249
|
+
if (!page2 || page2.total !== rowCount) revision = null;
|
|
250
|
+
else revisionRows = page2.rows;
|
|
251
|
+
}
|
|
238
252
|
} catch (error) {
|
|
239
253
|
if (error instanceof ReportingReadCapacityError) return lookupUnavailable(view);
|
|
240
254
|
throw error;
|
|
@@ -262,7 +276,7 @@ function createReportingStatusHandler(store, options) {
|
|
|
262
276
|
revision_content_sha256: revision.wireRevision.revision_content_sha256,
|
|
263
277
|
row_count: revision.binding.rowCount
|
|
264
278
|
},
|
|
265
|
-
reporting_rows:
|
|
279
|
+
...revisionRows ? { reporting_rows: revisionRows } : {},
|
|
266
280
|
adjustments: revisionAdjustments.map((value) => value.wireAdjustment),
|
|
267
281
|
...consumerId ? { consumer_statuses: (page.consumerStatuses ?? []).map(wireConsumerStatus) } : {},
|
|
268
282
|
materializations: (page.materializations ?? []).filter(
|
|
@@ -375,6 +389,7 @@ function createReportingStatusHandler(store, options) {
|
|
|
375
389
|
}
|
|
376
390
|
};
|
|
377
391
|
}
|
|
392
|
+
const REPORTING_STATUS_REVISION_VIEW_MAX_ROWS = 1e4;
|
|
378
393
|
function createReportingDeliveryHandler(store) {
|
|
379
394
|
const activeReadsByAccount = /* @__PURE__ */ new Map();
|
|
380
395
|
return async (request, context) => {
|
|
@@ -395,7 +410,7 @@ function createReportingDeliveryHandler(store) {
|
|
|
395
410
|
if (typeof raw.reporting_revision_id !== "string" || !raw.reporting_revision_id) {
|
|
396
411
|
throw new Error("Ledger delivery reads require reporting_revision_id");
|
|
397
412
|
}
|
|
398
|
-
const revision = await store
|
|
413
|
+
const revision = await getRevisionMetadataFromStore(store, raw.reporting_revision_id, accountId);
|
|
399
414
|
if (!revision) throw new Error("Reporting revision is unavailable");
|
|
400
415
|
const obligation = await store.getObligation(revision.reporting_obligation_id);
|
|
401
416
|
if (!obligation || obligation.account.account_id !== accountId) {
|
|
@@ -403,11 +418,12 @@ function createReportingDeliveryHandler(store) {
|
|
|
403
418
|
}
|
|
404
419
|
const pagination = isRecord(raw.pagination) ? raw.pagination : {};
|
|
405
420
|
const maxResults = typeof pagination.max_results === "number" && Number.isFinite(pagination.max_results) ? Math.max(1, Math.min(500, Math.trunc(pagination.max_results))) : 100;
|
|
421
|
+
const totalCount = revision.binding.rowCount;
|
|
406
422
|
let offset = 0;
|
|
407
423
|
if (typeof pagination.cursor === "string") {
|
|
408
424
|
try {
|
|
409
425
|
const cursor = JSON.parse(Buffer.from(pagination.cursor, "base64url").toString("utf8"));
|
|
410
|
-
if (cursor.revisionId !== revision.reporting_revision_id || typeof cursor.offset !== "number" || !Number.isSafeInteger(cursor.offset) || cursor.offset < 0 || cursor.offset >=
|
|
426
|
+
if (cursor.revisionId !== revision.reporting_revision_id || typeof cursor.offset !== "number" || !Number.isSafeInteger(cursor.offset) || cursor.offset < 0 || cursor.offset >= totalCount) {
|
|
411
427
|
throw new Error("invalid");
|
|
412
428
|
}
|
|
413
429
|
offset = cursor.offset;
|
|
@@ -415,9 +431,20 @@ function createReportingDeliveryHandler(store) {
|
|
|
415
431
|
throw new Error("Reporting delivery cursor is invalid");
|
|
416
432
|
}
|
|
417
433
|
}
|
|
418
|
-
|
|
434
|
+
let reportingRows = [];
|
|
435
|
+
if (totalCount > 0) {
|
|
436
|
+
const page = await readRevisionRowsFromStore(store, {
|
|
437
|
+
reporting_revision_id: revision.reporting_revision_id,
|
|
438
|
+
account_id: accountId,
|
|
439
|
+
offset,
|
|
440
|
+
limit: maxResults,
|
|
441
|
+
...context.signal ? { signal: context.signal } : {}
|
|
442
|
+
});
|
|
443
|
+
if (!page || page.total !== totalCount) throw new Error("Reporting revision is unavailable");
|
|
444
|
+
reportingRows = page.rows;
|
|
445
|
+
}
|
|
419
446
|
const nextOffset = offset + reportingRows.length;
|
|
420
|
-
const hasMore = nextOffset <
|
|
447
|
+
const hasMore = nextOffset < totalCount;
|
|
421
448
|
return {
|
|
422
449
|
reporting_period: { start: obligation.period.start, end: obligation.period.end },
|
|
423
450
|
media_buy_deliveries: [],
|
|
@@ -437,7 +464,7 @@ function createReportingDeliveryHandler(store) {
|
|
|
437
464
|
errors: [],
|
|
438
465
|
pagination: {
|
|
439
466
|
has_more: hasMore,
|
|
440
|
-
total_count:
|
|
467
|
+
total_count: totalCount,
|
|
441
468
|
...hasMore ? {
|
|
442
469
|
cursor: Buffer.from(
|
|
443
470
|
JSON.stringify({ revisionId: revision.reporting_revision_id, offset: nextOffset }),
|
|
@@ -949,6 +976,7 @@ function wireSchedule(obligation) {
|
|
|
949
976
|
};
|
|
950
977
|
}
|
|
951
978
|
export {
|
|
979
|
+
REPORTING_STATUS_REVISION_VIEW_MAX_ROWS,
|
|
952
980
|
ReportingReadCapacityError,
|
|
953
981
|
acquireAccountReadSlot,
|
|
954
982
|
aggregateReportingCoverageV1,
|
|
@@ -28,6 +28,7 @@ __reExport(ledger_exports, require('./managed.js'), module.exports);
|
|
|
28
28
|
__reExport(ledger_exports, require('./managed-postgres.js'), module.exports);
|
|
29
29
|
__reExport(ledger_exports, require('./object-writes.js'), module.exports);
|
|
30
30
|
__reExport(ledger_exports, require('./notification-activity.js'), module.exports);
|
|
31
|
+
__reExport(ledger_exports, require('./row-encoding.js'), module.exports);
|
|
31
32
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
33
|
0 && (module.exports = {
|
|
33
34
|
...require('./types.js'),
|
|
@@ -42,5 +43,6 @@ __reExport(ledger_exports, require('./notification-activity.js'), module.exports
|
|
|
42
43
|
...require('./managed.js'),
|
|
43
44
|
...require('./managed-postgres.js'),
|
|
44
45
|
...require('./object-writes.js'),
|
|
45
|
-
...require('./notification-activity.js')
|
|
46
|
+
...require('./notification-activity.js'),
|
|
47
|
+
...require('./row-encoding.js')
|
|
46
48
|
});
|
|
@@ -28,6 +28,7 @@ var import_source = require('../source/index.js');
|
|
|
28
28
|
var import_handler = require('./handler.js');
|
|
29
29
|
var import_instant = require('./instant.js');
|
|
30
30
|
var import_health = require('./health.js');
|
|
31
|
+
var import_revision_metadata = require('./revision-metadata.js');
|
|
31
32
|
async function resolveLedgerAsOf(input, attempt) {
|
|
32
33
|
const resolved = await input.store.readLedgerInstant?.() ?? (input.now ?? (() => /* @__PURE__ */ new Date()))().toISOString();
|
|
33
34
|
if (input.ledgerAsOf === void 0) return resolved;
|
|
@@ -78,7 +79,7 @@ async function reconcileReportingStatusLifecycleV1(input, attempt = 0) {
|
|
|
78
79
|
const transactionalNotifications = input.store.transactionalNotificationActivity === true;
|
|
79
80
|
assertNotificationModesCompatible(input.store, input.subscribers);
|
|
80
81
|
let ledgerAsOf = await resolveLedgerAsOf(input, attempt);
|
|
81
|
-
const revisions = await input.store
|
|
82
|
+
const revisions = await (0, import_revision_metadata.listRevisionMetadataFromStore)(input.store, obligation.reporting_obligation_id);
|
|
82
83
|
let projected = revisions;
|
|
83
84
|
const projectCore = (at) => (0, import_health.projectReportingObligationHealthV1)(
|
|
84
85
|
obligation,
|
|
@@ -207,7 +208,7 @@ async function composeManagedLifecycleProjection(input, obligation, revisions, c
|
|
|
207
208
|
ledgerAsOf: input.ledgerAsOf
|
|
208
209
|
});
|
|
209
210
|
if (!managed) return { projection: coreProjection };
|
|
210
|
-
const stored = await input.store
|
|
211
|
+
const stored = await (0, import_revision_metadata.listAdjustmentMetadataFromStore)(input.store, obligation.reporting_obligation_id);
|
|
211
212
|
const visibleAdjustmentIds = managed.visibleAdjustmentIds;
|
|
212
213
|
const adjustments = visibleAdjustmentIds ? stored.filter((value) => visibleAdjustmentIds.includes(value.reporting_adjustment_id)) : stored.filter((value) => (0, import_instant.compareReportingInstants)(value.createdAt, input.ledgerAsOf) <= 0);
|
|
213
214
|
const rosterAuthoritative = managed.obligatedConsumerRosterComplete === true && managed.receiptEvidenceComplete !== false;
|