vercel-api-js 2.9.1 → 2.9.3

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 CHANGED
@@ -72,6 +72,20 @@ await client.api.vcr.createByTeamSlugByProjectSlugByRepositoryNameBlobsUploads({
72
72
  });
73
73
  ```
74
74
 
75
+ An error thrown inside `onResponse` rejects the call with an `Error` whose message starts with `onResponse threw on` and whose `cause` is what was thrown.
76
+
77
+ ### Pushing a manifest
78
+
79
+ The manifest push encodes an object body as JSON and sends it as `application/vnd.oci.image.manifest.v1+json`. To push by digest, pass the manifest as a string or bytes instead: they are sent as is, so the registry hashes the exact bytes the digest names. An image index or a Docker v2 manifest needs its own media type, which `config.headers` sets:
80
+
81
+ ```ts
82
+ await client.api.vcr.replaceByTeamSlugByProjectSlugByRepositoryNameManifestsByReference({
83
+ pathParams: { teamSlug, projectSlug, repositoryName, reference: digest },
84
+ body: manifestBytes,
85
+ config: { headers: { "Content-Type": "application/vnd.oci.image.index.v1+json" } },
86
+ });
87
+ ```
88
+
75
89
  ## Errors
76
90
 
77
91
  A call that gets an HTTP error response rejects with `{ status, payload }`: `status` is the HTTP status code and `payload` is the parsed JSON error body, or the raw body text, up to 1000 characters, when it is not JSON. A request that gets no response at all, for example because the network failed, rejects with an `Error` whose message names the method, the path and the reason, and whose `cause` is the original exception. A request cancelled through `signal` rejects with what the signal was aborted with, as is: the `AbortError`, or the `TimeoutError` of `AbortSignal.timeout()`.
@@ -67,6 +67,13 @@ class ResponseError {
67
67
  this.error = error;
68
68
  }
69
69
  }
70
+ // What the caller's onResponse threw, kept apart from a failed request.
71
+ class ResponseHookError {
72
+ constructor(error){
73
+ this.error = error;
74
+ }
75
+ }
76
+ const errorReason = (error)=>error instanceof Error ? error.message : String(error);
70
77
  async function client({ url, method, body, headers, queryParams, signal, jsonLines = "array", onResponse, baseUrl = defaultBaseUrl, token = null, fetchImpl = fetch }) {
71
78
  try {
72
79
  const mergedHeaders = {
@@ -102,10 +109,14 @@ async function client({ url, method, body, headers, queryParams, signal, jsonLin
102
109
  duplex: "half"
103
110
  } : {}
104
111
  });
105
- onResponse?.({
106
- status: response.status,
107
- headers: response.headers ?? noHeaders
108
- });
112
+ try {
113
+ onResponse?.({
114
+ status: response.status,
115
+ headers: response.headers ?? noHeaders
116
+ });
117
+ } catch (e) {
118
+ throw new ResponseHookError(e);
119
+ }
109
120
  if (!response.ok) {
110
121
  const text = await response.text();
111
122
  let payload;
@@ -138,11 +149,16 @@ async function client({ url, method, body, headers, queryParams, signal, jsonLin
138
149
  } catch (e) {
139
150
  // Rethrown as is so the HTTP status survives; the Effect bindings map it to ApiError.
140
151
  if (e instanceof ResponseError) throw e.error;
152
+ // Only the path: query values can carry secrets.
153
+ const request = `${method.toUpperCase()} ${url.split("?")[0]}`;
154
+ if (e instanceof ResponseHookError) {
155
+ throw new Error(`onResponse threw on ${request}: ${errorReason(e.error)}`, {
156
+ cause: e.error
157
+ });
158
+ }
141
159
  // A cancelled call rejects with the signal's reason as is, such as the TimeoutError of AbortSignal.timeout().
142
160
  if (signal?.aborted || e instanceof Error && e.name === "AbortError") throw e;
143
- const reason = e instanceof Error ? e.message : String(e);
144
- // Only the path: query values can carry secrets.
145
- throw new Error(`${method.toUpperCase()} ${url.split("?")[0]} failed: ${reason}`, {
161
+ throw new Error(`${request} failed: ${errorReason(e)}`, {
146
162
  cause: e
147
163
  });
148
164
  }
@@ -8766,7 +8782,7 @@ const resolveUrl = (url, queryParams = {})=>{
8766
8782
  const data = await request({
8767
8783
  method: "PUT",
8768
8784
  url: `/v2/${encodeURIComponent(String(pathParams.teamSlug))}/${encodeURIComponent(String(pathParams.projectSlug))}/${encodeURIComponent(String(pathParams.repositoryName))}/manifests/${encodeURIComponent(String(pathParams.reference))}`,
8769
- body: body === undefined ? undefined : JSON.stringify(body),
8785
+ body: body === undefined || typeof body === "string" || body instanceof Blob || body instanceof ArrayBuffer || ArrayBuffer.isView(body) || body instanceof ReadableStream ? body : JSON.stringify(body),
8770
8786
  ...requestConfig,
8771
8787
  headers: {
8772
8788
  "Content-Type": "application/vnd.oci.image.manifest.v1+json",
@@ -5140,7 +5140,7 @@ declare function createByTeamSlugByProjectSlugByRepositoryNameBlobsUploads({ pat
5140
5140
  */
5141
5141
  declare function replaceByTeamSlugByProjectSlugByRepositoryNameManifestsByReference({ pathParams, body, config, }?: {
5142
5142
  pathParams: ReplaceByTeamSlugByProjectSlugByRepositoryNameManifestsByReferencePath;
5143
- body: ReplaceByTeamSlugByProjectSlugByRepositoryNameManifestsByReferenceBody;
5143
+ body: ReplaceByTeamSlugByProjectSlugByRepositoryNameManifestsByReferenceBody | Blob | ArrayBuffer | Uint8Array | ReadableStream | string;
5144
5144
  config?: Partial<FetcherConfig> & {
5145
5145
  client?: typeof client;
5146
5146
  };
@@ -7033,4 +7033,4 @@ declare const tagDictionary: {
7033
7033
 
7034
7034
  export { createProjectCheck as $, listAiGatewayRules as A, updateAiGatewayRule as B, deleteAiGatewayRule as C, listAiGatewayBudgets as D, upsertAiGatewayBudget as E, archiveAiGatewayBudget as F, listAiGatewayBudgetDefaults as G, upsertAiGatewayBudgetDefault as H, archiveAiGatewayBudgetDefault as I, updateApiKeyQuota as J, recordEvents as K, status as L, uploadArtifact as M, downloadArtifact as N, artifactQuery as O, deleteAllArtifacts as P, listBillingCharges as Q, listContractCommitments as R, buyCredits as S, stageRedirects as T, getRedirects as U, deleteRedirects as V, editRedirect as W, restoreRedirects as X, getVersions as Y, updateVersion as Z, listProjectChecks as _, listAccessGroups as a, updateRecord as a$, getProjectCheck as a0, updateProjectCheck as a1, deleteProjectCheck as a2, listCheckRuns as a3, listDeploymentCheckRuns as a4, createDeploymentCheckRun as a5, getDeploymentCheckRun as a6, updateDeploymentCheckRun as a7, createCheck as a8, getAllChecks as a9, listProjectConnectorConnections as aA, getConnectorToken as aB, createConnectorAuthorizationRequest as aC, getProjectBoxes as aD, putProjectDaemonInstances as aE, restartProjectDaemonInstance as aF, getDeploymentEvents as aG, updateIntegrationDeploymentAction as aH, getDeployment as aI, createDeployment as aJ, cancelDeployment as aK, uploadFile as aL, listDeploymentFiles as aM, getDeploymentFileContents as aN, getDeployments as aO, deleteDeployment as aP, gitNamespaces as aQ, searchRepo as aR, getBillingPlans as aS, connectIntegrationResourceToProject as aT, getConfigurations as aU, getConfiguration as aV, deleteConfiguration as aW, getConfigurationProducts as aX, createIntegrationStoreDirect as aY, getRecords as aZ, createRecord as a_, getCheck as aa, updateCheck as ab, rerequestCheck as ac, listNetworks as ad, createNetwork as ae, deleteNetwork as af, updateNetwork as ag, readNetwork as ah, createPrivateLinkEndpoint as ai, listPrivateLinkEndpoints as aj, readPrivateLinkEndpoint as ak, deletePrivateLinkEndpoint as al, updatePrivateLinkEndpoint as am, updateStaticIps as an, listConnectors as ao, getConnector as ap, deleteConnector as aq, createConnector as ar, updateConnector as as, replaceConnectorTriggerDestinations as at, ejectManagedConnector as au, listConnectorProjectConnections as av, getConnectorProjectConnection as aw, upsertConnectorProjectConnection as ax, deleteConnectorProjectConnection as ay, disconnectConnectorProjectEnvironment as az, listAccessGroupProjects as b, deleteEdgeConfigSchema as b$, removeRecord as b0, replaceDomainsByDomainRecords as b1, getDomainsRecordsByRecordId as b2, createApiKeys as b3, createObservabilityQuery as b4, getObservabilitySchema as b5, getObservabilitySchemaByMetricId as b6, createSpeedInsightsToggle as b7, createWebInsightsToggle as b8, searchDomains as b9, deleteDomain as bA, getConfigurableLogDrain as bB, deleteConfigurableLogDrain as bC, getAllLogDrains as bD, createConfigurableLogDrain as bE, getIntegrationLogDrains as bF, createLogDrain as bG, deleteIntegrationLogDrain as bH, createDrain as bI, getDrains as bJ, deleteDrain as bK, getDrain as bL, updateDrain as bM, testDrain as bN, invalidateByTags as bO, dangerouslyDeleteByTags as bP, invalidateBySrcImages as bQ, dangerouslyDeleteBySrcImages as bR, getEdgeConfigs as bS, createEdgeConfig as bT, getEdgeConfig as bU, updateEdgeConfig as bV, deleteEdgeConfig as bW, getEdgeConfigItems as bX, patchEdgeConfigItems as bY, getEdgeConfigSchema as bZ, patchEdgeConfigSchema as b_, getSupportedTlds as ba, getTld as bb, getTldPrice as bc, getDomainAvailability as bd, getDomainPrice as be, getBulkPrice as bf, getBulkAvailability as bg, getContactInfoSchema as bh, getDomainAuthCode as bi, buySingleDomain as bj, buyDomains as bk, transferInDomain as bl, getDomainTransferIn as bm, renewDomain as bn, updateDomainAutoRenew as bo, updateDomainNameservers as bp, getDomainContactVerification as bq, getOrder as br, getDomainConfig as bs, getDomainVerificationRecord as bt, claimDomainOwnership as bu, getDomainProjectDomains as bv, getDomain as bw, getDomains as bx, createOrTransferDomain as by, patchDomain as bz, createAccessGroup as c, submitPrepaymentBalances as c$, getEdgeConfigItem as c0, getEdgeConfigTokens as c1, deleteEdgeConfigTokens as c2, getEdgeConfigToken as c3, createEdgeConfigToken as c4, getEdgeConfigBackup as c5, restoreEdgeConfigBackup as c6, getEdgeConfigBackups as c7, createSharedEnvVariable as c8, listSharedEnvVariable as c9, listTeamFlagsV2 as cA, listTeamFlags as cB, createFlagSegment as cC, listFlagSegments as cD, getFlagSegment as cE, deleteFlagSegment as cF, updateFlagSegment as cG, getDeploymentFeatureFlags as cH, getSdkKeys as cI, createSdkKey as cJ, deleteSdkKey as cK, updateInstallation as cL, getAccountInfo as cM, getMember as cN, rotateInstallationCredential as cO, revokeInstallationCredential as cP, createEvent as cQ, getIntegrationResources as cR, getIntegrationResource as cS, deleteIntegrationResource as cT, importResource as cU, updateResource as cV, submitBillingData as cW, submitInvoice as cX, finalizeInstallation as cY, getInvoice as cZ, updateInvoice as c_, updateSharedEnvVariable as ca, deleteSharedEnvVariable as cb, getSharedEnvVar as cc, unlinkSharedEnvVariable as cd, createCustomEnvironment as ce, getProjectsByIdOrNameCustomEnvironments as cf, getCustomEnvironment as cg, updateCustomEnvironment as ch, removeCustomEnvironment as ci, listUserEvents as cj, listEventTypes as ck, getAuthUser as cl, requestDelete as cm, listFlagsV2 as cn, listFlags as co, createFlag as cp, getFlag as cq, updateFlag as cr, deleteFlag as cs, listFlagVersions as ct, getFlagSettings as cu, updateFlagSettings as cv, listFlagLabels as cw, listFlagLabelCounts as cx, lookupFlagLabels as cy, listTeamFlagSettings as cz, deleteAccessGroup as d, getProjectDomain as d$, updateResourceSecrets as d0, updateResourceSecretsById as d1, exchangeSsoToken as d2, createInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationItems as d3, updateInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationItemsByItemId as d4, deleteInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationItemsByItemId as d5, getInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfig as d6, replaceInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfig as d7, listAuthTokens as d8, createAuthToken as d9, getOrganization as dA, updateOrganization as dB, listOrganizationTeams as dC, addOrganizationTeam as dD, removeOrganizationTeam as dE, getProjectMembers as dF, addProjectMember as dG, removeProjectMember as dH, getRoutes as dI, stageRoutes as dJ, addRoute as dK, deleteRoutes as dL, editRoute as dM, generateRoute as dN, getRouteVersions as dO, updateRouteVersions as dP, getProjects as dQ, getProjectTrace as dR, createProject as dS, getProjectToken as dT, createTraceSession as dU, getProject as dV, updateProject as dW, deleteProject as dX, uploadProjectAvatar as dY, deleteProjectAvatar as dZ, getProjectDomains as d_, getAuthToken as da, deleteAuthToken as db, signKmsMessage as dc, signKmsToken as dd, listKmsIssuers as de, createKmsIssuer as df, createKmsSigningKey as dg, activateKmsSigningKey as dh, revokeKmsSigningKey as di, getKmsIssuer as dj, updateKmsIssuer as dk, deleteKmsIssuer as dl, createKmsIssuerPolicy as dm, updateKmsIssuerPolicy as dn, deleteKmsIssuerPolicy as dp, getRuntimeLogs as dq, getMicrofrontendsGroups as dr, getMicrofrontendsInGroup as ds, getMicrofrontendsConfig as dt, getMicrofrontendsConfigForProject as du, createMicrofrontendsGroupWithApplications as dv, getObservabilityConfigurationProjects as dw, updateObservabilityConfigurationProject as dx, createOrganization as dy, listOrganizations as dz, createAccessGroupProject as e, getSecurityFirewallConfig as e$, updateProjectDomain as e0, removeProjectDomain as e1, addProjectDomain as e2, moveProjectDomain as e3, verifyProjectDomain as e4, filterProjectEnvs as e5, createProjectEnv as e6, getProjectEnv as e7, removeProjectEnv as e8, editProjectEnv as e9, listSessionSnapshots as eA, getSessionSnapshot as eB, deleteSessionSnapshot as eC, listSessions as eD, getSession as eE, getNamedSandbox as eF, updateSandbox as eG, deleteSandbox as eH, listSessionCommands as eI, runSessionCommand as eJ, getSessionCommand as eK, killSessionCommand as eL, writeSessionCommandStdin as eM, getSessionCommandLogs as eN, stopSession as eO, extendSessionTimeout as eP, updateSessionNetworkPolicy as eQ, readSessionFile as eR, createSessionDirectory as eS, writeSessionFiles as eT, createSandboxesSessionsBySessionIdSnapshotV2 as eU, createSandboxesByNameForkV2 as eV, createSandboxesV3 as eW, createSandboxesSessionsBySessionIdSnapshotV3 as eX, createSandboxesByNameForkV3 as eY, createSandboxesV4 as eZ, updateAttackChallengeMode as e_, batchRemoveProjectEnv as ea, createProjectTransferRequest as eb, acceptProjectTransferRequest as ec, updateProjectProtectionBypass as ed, requestRollback as ee, updateProjectsByProjectIdRollbackByDeploymentIdUpdateDescription as ef, updateMicrofrontends as eg, requestPromote as eh, listPromoteAliases as ei, pauseProject as ej, unpauseProject as ek, getRollingReleaseBillingStatus as el, getRollingReleaseConfig as em, deleteRollingReleaseConfig as en, updateRollingReleaseConfig as eo, getRollingRelease as ep, approveRollingReleaseStage as eq, startRollingRelease as er, completeRollingRelease as es, listNamedSandboxes as et, createSandboxesV2 as eu, listDrives as ev, getDrive as ew, getOrCreateDrive as ex, deleteDrive as ey, forkDrive as ez, readAccessGroupProject as f, listVercelCiBranches as f$, putFirewallConfig as f0, updateFirewallConfig as f1, getFirewallConfig as f2, deleteSecurityFirewallConfigByConfigVersion as f3, createSecurityFirewallConfigByConfigVersionActivate as f4, getActiveAttackStatus as f5, getBypassIp as f6, addBypassIp as f7, removeBypassIp as f8, getConditionalBypass as f9, listRepositories as fA, getRepository as fB, deleteRepository as fC, listRepositoryImages as fD, addRepositoryPermission as fE, removeRepositoryPermission as fF, listRepositoryPermissions as fG, clearRepositoryPermissions as fH, listRepositoryTags as fI, getRepositoryTag as fJ, getRepositoryImage as fK, deleteRepositoryImage as fL, getRoot as fM, getByTeamSlugByProjectSlugByRepositoryNameBlobsByDigest as fN, deleteByTeamSlugByProjectSlugByRepositoryNameBlobsByDigest as fO, getByTeamSlugByProjectSlugByRepositoryNameBlobsUploadsByUuid as fP, deleteByTeamSlugByProjectSlugByRepositoryNameBlobsUploadsByUuid as fQ, updateByTeamSlugByProjectSlugByRepositoryNameBlobsUploadsByUuid as fR, replaceByTeamSlugByProjectSlugByRepositoryNameBlobsUploadsByUuid as fS, createByTeamSlugByProjectSlugByRepositoryNameBlobsUploads as fT, replaceByTeamSlugByProjectSlugByRepositoryNameManifestsByReference as fU, getByTeamSlugByProjectSlugByRepositoryNameManifestsByReference as fV, deleteByTeamSlugByProjectSlugByRepositoryNameManifestsByReference as fW, getByTeamSlugByProjectSlugByRepositoryNameTagsList as fX, getVercelCiRepositorySettings as fY, updateVercelCiRepositorySettings as fZ, listVercelCiInvocations as f_, createConditionalBypass as fa, updateConditionalBypass as fb, deleteConditionalBypass as fc, getSecurityFirewallEvents as fd, getSecurityFirewallEventsSummary as fe, generateFirewallRule as ff, getStorageStoresById as fg, createStorageStoresBlob as fh, deleteStorageStoresBlobById as fi, getTeamMembers as fj, inviteUserToTeam as fk, requestAccessToTeam as fl, getTeamAccessRequest as fm, joinTeam as fn, updateTeamMember as fo, removeTeamMember as fp, getTeam as fq, patchTeam as fr, getTeams as fs, createTeam as ft, postTeamDsyncRoles as fu, deleteTeam as fv, deleteTeamInviteCode as fw, updateMicrofrontendsGroup as fx, deleteMicrofrontendsGroup as fy, createRepository as fz, updateAccessGroupProject as g, createVercelCiTaskAnalysis as g0, getVercelCiTaskAnalysis as g1, createVercelCiTaskConfigurationPullRequest as g2, listVercelCiTaskAnalysisTasks as g3, listVercelCiInvocationAttempts as g4, getVercelCiInvocationTree as g5, getVercelCiInvocation as g6, retryVercelCiInvocation as g7, listVercelCiJobDefinitions as g8, getVercelCiJobDefinition as g9, issueCert as gA, uploadCert as gB, operationsByTag as gC, tagDictionary as gD, operationsByPath as gF, isJsonLineStream as gH, listVercelCiJobRuns as ga, getVercelCiJobRun as gb, listVercelCiTaskDefinitions as gc, listVercelCiTaskRuns as gd, getVercelCiInvocationLogs as ge, getVercelCiTaskLogs as gf, searchVercelCiLogs as gg, getVercelCiJobRunLogs as gh, getVercelCiTaskRunLogs as gi, aggregatePageviews as gj, aggregateEvents as gk, countPageviews as gl, countEvents as gm, createWebhook as gn, getWebhooks as go, getWebhook as gp, deleteWebhook as gq, listDeploymentAliases as gr, assignAlias as gs, listAliases as gt, getAlias as gu, deleteAlias as gv, patchUrlProtectionBypass as gw, getCertById as gx, removeCert as gy, getCerts as gz, deleteAccessGroupProject as h, createAiGatewayByokCredential as i, listAiGatewayByokCredentials as j, getAiGatewayByokCredential as k, listAccessGroupMembers as l, updateAiGatewayByokCredential as m, deleteAiGatewayByokCredential as n, createAiGatewayVirtualModelConfig as o, getAiGatewayVirtualModelConfig as p, updateAiGatewayVirtualModelConfig as q, readAccessGroup as r, deleteAiGatewayVirtualModelConfig as s, listAiGatewayVirtualModelConfigs as t, updateAccessGroup as u, getAiGatewayVirtualModelConfigBySlug as v, updateAiGatewayVirtualModelConfigBySlug as w, deleteAiGatewayVirtualModelConfigBySlug as x, listAiGatewayRouters as y, createAiGatewayRule as z };
7035
7035
  export type { FetchImpl as gE, ResponseInfo as gG };
7036
- //# sourceMappingURL=components-zojgsw1w.d.ts.map
7036
+ //# sourceMappingURL=components-f6cwm9fu.d.ts.map