/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { VantaCore } from "../core.js"; import { encodeFormQuery, encodeSimple } from "../lib/encodings.js"; import { matchStatusCode } from "../lib/http.js"; import * as M from "../lib/matchers.js"; import { compactMap } from "../lib/primitives.js"; import { safeParse } from "../lib/schemas.js"; import { RequestOptions } from "../lib/sdks.js"; import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; import { pathToFunc } from "../lib/url.js"; import * as components from "../models/components/index.js"; import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.js"; import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import { VantaError } from "../models/errors/vantaerror.js"; import * as operations from "../models/operations/index.js"; import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** * List information request activity * * @remarks * Retrieves a paginated list of activity logs for an information request, providing * an audit trail of the changes and actions taken on it. * * Activity recording Vanta's automated preparation of a request is never returned by * this endpoint, so `fillOutcome` is always null here. Some internal status transitions * are also withheld, and those are removed after a page is selected, so a page can * contain fewer entries than `pageSize` — or none at all — while more pages remain. * Follow `results.pageInfo.hasNextPage` rather than treating a short or empty page as * the end of the list. * * If the information request has been deleted, this endpoint returns a 4xx * HTTP error instead of its activity. * * This endpoint supports delta synchronization via the `changedSinceDate` parameter, * allowing efficient polling for changes without retrieving the entire dataset. * * Pagination usage: * 1. Make initial request with desired `pageSize` * 2. Check `results.pageInfo.hasNextPage` to see if more data exists * 3. If true, use `results.pageInfo.endCursor` as `pageCursor` in next request * 4. Repeat until `hasNextPage` is false * * Delta sync usage: * 1. Store the timestamp of your last sync * 2. Pass that timestamp as `changedSinceDate` * 3. Only activity created since that timestamp is returned * 4. Process updates to track all changes to the information request * 5. Update your last sync timestamp to the current time * * Rate limit: 50 requests / minute. */ export function auditsListInformationRequestActivity( client: VantaCore, request: operations.ListInformationRequestActivityRequest, options?: RequestOptions, ): APIPromise< Result< components.PaginatedResponseInformationRequestActivityLog, | VantaError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError > > { return new APIPromise($do( client, request, options, )); } async function $do( client: VantaCore, request: operations.ListInformationRequestActivityRequest, options?: RequestOptions, ): Promise< [ Result< components.PaginatedResponseInformationRequestActivityLog, | VantaError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError >, APICall, ] > { const parsed = safeParse( request, (value) => operations.ListInformationRequestActivityRequest$outboundSchema.parse( value, ), "Input validation failed", ); if (!parsed.ok) { return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; const pathParams = { auditId: encodeSimple("auditId", payload.auditId, { explode: false, charEncoding: "percent", }), requestId: encodeSimple("requestId", payload.requestId, { explode: false, charEncoding: "percent", }), }; const path = pathToFunc( "/audits/{auditId}/information-requests/{requestId}/activity", )(pathParams); const query = encodeFormQuery({ "changedSinceDate": payload.changedSinceDate, "pageCursor": payload.pageCursor, "pageSize": payload.pageSize, }); const headers = new Headers(compactMap({ Accept: "application/json", })); const secConfig = await extractSecurity(client._options.bearerAuth); const securityInput = secConfig == null ? {} : { bearerAuth: secConfig }; const requestSecurity = resolveGlobalSecurity(securityInput); const context = { options: client._options, baseURL: options?.serverURL ?? client._baseURL ?? "", operationID: "ListInformationRequestActivity", oAuth2Scopes: null, resolvedSecurity: requestSecurity, securitySource: client._options.bearerAuth, retryConfig: options?.retries || client._options.retryConfig || { strategy: "none" }, retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", baseURL: options?.serverURL, path: path, headers: headers, query: query, body: body, userAgent: client._options.userAgent, timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { return [requestRes, { status: "invalid" }]; } const req = requestRes.value; const doResult = await client._do(req, { context, isErrorStatusCode: (statusCode: number) => matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]), retryConfig: context.retryConfig, retryCodes: context.retryCodes, }); if (!doResult.ok) { return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; const [result] = await M.match< components.PaginatedResponseInformationRequestActivityLog, | VantaError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError >( M.json( 200, components.PaginatedResponseInformationRequestActivityLog$inboundSchema, ), M.fail("4XX"), M.fail("5XX"), )(response, req); if (!result.ok) { return [result, { status: "complete", request: req, response }]; } return [result, { status: "complete", request: req, response }]; }