@workers-community/workers-types 4.20260511.1 → 4.20260514.1

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.
Files changed (3) hide show
  1. package/index.d.ts +66 -2
  2. package/index.ts +66 -2
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -11151,12 +11151,17 @@ interface ArtifactsTokenListResult {
11151
11151
  /** Total number of tokens for the repository. */
11152
11152
  total: number;
11153
11153
  }
11154
- /** Handle for a single repository. Returned by Artifacts.get(). */
11154
+ /**
11155
+ * Handle for a single repository. Returned by Artifacts.get().
11156
+ *
11157
+ * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11158
+ */
11155
11159
  interface ArtifactsRepo extends ArtifactsRepoInfo {
11156
11160
  /**
11157
11161
  * Create an access token for this repo.
11158
11162
  * @param scope Token scope: "write" (default) or "read".
11159
11163
  * @param ttl Time-to-live in seconds (default 86400, min 60, max 31536000).
11164
+ * @throws {ArtifactsError} with code `INVALID_TTL` if ttl is out of range.
11160
11165
  */
11161
11166
  createToken(
11162
11167
  scope?: "write" | "read",
@@ -11168,6 +11173,7 @@ interface ArtifactsRepo extends ArtifactsRepoInfo {
11168
11173
  * Revoke a token by plaintext or ID.
11169
11174
  * @param tokenOrId Plaintext token or token ID.
11170
11175
  * @returns true if revoked, false if not found.
11176
+ * @throws {ArtifactsError} with code `INVALID_INPUT` if tokenOrId is empty.
11171
11177
  */
11172
11178
  revokeToken(tokenOrId: string): Promise<boolean>;
11173
11179
  // ── Fork ──
@@ -11175,6 +11181,9 @@ interface ArtifactsRepo extends ArtifactsRepoInfo {
11175
11181
  * Fork this repo to a new repo.
11176
11182
  * @param name Target repository name.
11177
11183
  * @param opts Optional: description, readOnly flag, defaultBranchOnly (default true).
11184
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11185
+ * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11186
+ * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if a fork is already running.
11178
11187
  */
11179
11188
  fork(
11180
11189
  name: string,
@@ -11185,13 +11194,53 @@ interface ArtifactsRepo extends ArtifactsRepoInfo {
11185
11194
  },
11186
11195
  ): Promise<ArtifactsCreateRepoResult>;
11187
11196
  }
11188
- /** Artifacts binding namespace-level operations. */
11197
+ // ── Error types ──────────────────────────────────────────────────────────────
11198
+ /**
11199
+ * Error codes returned by Artifacts binding operations.
11200
+ *
11201
+ * Each code maps to a numeric code available on `ArtifactsError.numericCode`.
11202
+ */
11203
+ type ArtifactsErrorCode =
11204
+ | "ALREADY_EXISTS"
11205
+ | "NOT_FOUND"
11206
+ | "IMPORT_IN_PROGRESS"
11207
+ | "FORK_IN_PROGRESS"
11208
+ | "INVALID_INPUT"
11209
+ | "INVALID_REPO_NAME"
11210
+ | "INVALID_TTL"
11211
+ | "INVALID_URL"
11212
+ | "REMOTE_AUTH_REQUIRED"
11213
+ | "UPSTREAM_UNAVAILABLE"
11214
+ | "MEMORY_LIMIT"
11215
+ | "INTERNAL_ERROR";
11216
+ /**
11217
+ * Error thrown by Artifacts binding operations.
11218
+ *
11219
+ * Uses a string `.code` discriminator following the Cloudflare platform
11220
+ * convention (StreamError, ImagesError, etc.). The `.numericCode` matches
11221
+ * the REST API `errors[].code` values.
11222
+ */
11223
+ interface ArtifactsError extends Error {
11224
+ readonly name: "ArtifactsError";
11225
+ /** String error code for programmatic matching. */
11226
+ readonly code: ArtifactsErrorCode;
11227
+ /** Numeric error code matching the REST API. */
11228
+ readonly numericCode: number;
11229
+ }
11230
+ // ── Binding ──────────────────────────────────────────────────────────────────
11231
+ /**
11232
+ * Artifacts binding — namespace-level operations.
11233
+ *
11234
+ * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11235
+ */
11189
11236
  interface Artifacts {
11190
11237
  /**
11191
11238
  * Create a new repository with an initial access token.
11192
11239
  * @param name Repository name (alphanumeric, dots, hyphens, underscores).
11193
11240
  * @param opts Optional: readOnly flag, description, default branch name.
11194
11241
  * @returns Repo metadata with initial token.
11242
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11243
+ * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the repo already exists.
11195
11244
  */
11196
11245
  create(
11197
11246
  name: string,
@@ -11205,12 +11254,23 @@ interface Artifacts {
11205
11254
  * Get a handle to an existing repository.
11206
11255
  * @param name Repository name.
11207
11256
  * @returns Repo handle.
11257
+ * @throws {ArtifactsError} with code `NOT_FOUND` if the repo does not exist.
11258
+ * @throws {ArtifactsError} with code `IMPORT_IN_PROGRESS` if the repo is still importing.
11259
+ * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if the repo is still forking.
11208
11260
  */
11209
11261
  get(name: string): Promise<ArtifactsRepo>;
11210
11262
  /**
11211
11263
  * Import a repository from an external git remote.
11212
11264
  * @param params Source URL and optional branch/depth, plus target name and options.
11213
11265
  * @returns Repo metadata with initial token.
11266
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if the target name is invalid.
11267
+ * @throws {ArtifactsError} with code `INVALID_INPUT` if the source URL is not valid HTTPS.
11268
+ * @throws {ArtifactsError} with code `INVALID_URL` if the source URL does not point to a git repository.
11269
+ * @throws {ArtifactsError} with code `REMOTE_AUTH_REQUIRED` if the remote requires authentication.
11270
+ * @throws {ArtifactsError} with code `NOT_FOUND` if the remote repository does not exist.
11271
+ * @throws {ArtifactsError} with code `UPSTREAM_UNAVAILABLE` if the remote cannot be reached.
11272
+ * @throws {ArtifactsError} with code `MEMORY_LIMIT` if the import exceeds service memory limits.
11273
+ * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11214
11274
  */
11215
11275
  import(params: {
11216
11276
  source: {
@@ -11238,6 +11298,7 @@ interface Artifacts {
11238
11298
  * Delete a repository and all associated tokens.
11239
11299
  * @param name Repository name.
11240
11300
  * @returns true if deleted, false if not found.
11301
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11241
11302
  */
11242
11303
  delete(name: string): Promise<boolean>;
11243
11304
  }
@@ -14750,6 +14811,9 @@ declare namespace TailStream {
14750
14811
  // 1. This is an Onset event
14751
14812
  // 2. We are not inheriting any SpanContext. (e.g. this is a cross-account service binding or a new top-level invocation)
14752
14813
  readonly spanId?: string;
14814
+ // W3C trace flags from an upstream traceparent. Absent when no upstream
14815
+ // sampling decision was made.
14816
+ readonly traceFlags?: number;
14753
14817
  }
14754
14818
  interface TailEvent<Event extends EventType> {
14755
14819
  // invocation id of the currently invoked worker stage.
package/index.ts CHANGED
@@ -11163,12 +11163,17 @@ export interface ArtifactsTokenListResult {
11163
11163
  /** Total number of tokens for the repository. */
11164
11164
  total: number;
11165
11165
  }
11166
- /** Handle for a single repository. Returned by Artifacts.get(). */
11166
+ /**
11167
+ * Handle for a single repository. Returned by Artifacts.get().
11168
+ *
11169
+ * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11170
+ */
11167
11171
  export interface ArtifactsRepo extends ArtifactsRepoInfo {
11168
11172
  /**
11169
11173
  * Create an access token for this repo.
11170
11174
  * @param scope Token scope: "write" (default) or "read".
11171
11175
  * @param ttl Time-to-live in seconds (default 86400, min 60, max 31536000).
11176
+ * @throws {ArtifactsError} with code `INVALID_TTL` if ttl is out of range.
11172
11177
  */
11173
11178
  createToken(
11174
11179
  scope?: "write" | "read",
@@ -11180,6 +11185,7 @@ export interface ArtifactsRepo extends ArtifactsRepoInfo {
11180
11185
  * Revoke a token by plaintext or ID.
11181
11186
  * @param tokenOrId Plaintext token or token ID.
11182
11187
  * @returns true if revoked, false if not found.
11188
+ * @throws {ArtifactsError} with code `INVALID_INPUT` if tokenOrId is empty.
11183
11189
  */
11184
11190
  revokeToken(tokenOrId: string): Promise<boolean>;
11185
11191
  // ── Fork ──
@@ -11187,6 +11193,9 @@ export interface ArtifactsRepo extends ArtifactsRepoInfo {
11187
11193
  * Fork this repo to a new repo.
11188
11194
  * @param name Target repository name.
11189
11195
  * @param opts Optional: description, readOnly flag, defaultBranchOnly (default true).
11196
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11197
+ * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11198
+ * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if a fork is already running.
11190
11199
  */
11191
11200
  fork(
11192
11201
  name: string,
@@ -11197,13 +11206,53 @@ export interface ArtifactsRepo extends ArtifactsRepoInfo {
11197
11206
  },
11198
11207
  ): Promise<ArtifactsCreateRepoResult>;
11199
11208
  }
11200
- /** Artifacts binding namespace-level operations. */
11209
+ // ── Error types ──────────────────────────────────────────────────────────────
11210
+ /**
11211
+ * Error codes returned by Artifacts binding operations.
11212
+ *
11213
+ * Each code maps to a numeric code available on `ArtifactsError.numericCode`.
11214
+ */
11215
+ export type ArtifactsErrorCode =
11216
+ | "ALREADY_EXISTS"
11217
+ | "NOT_FOUND"
11218
+ | "IMPORT_IN_PROGRESS"
11219
+ | "FORK_IN_PROGRESS"
11220
+ | "INVALID_INPUT"
11221
+ | "INVALID_REPO_NAME"
11222
+ | "INVALID_TTL"
11223
+ | "INVALID_URL"
11224
+ | "REMOTE_AUTH_REQUIRED"
11225
+ | "UPSTREAM_UNAVAILABLE"
11226
+ | "MEMORY_LIMIT"
11227
+ | "INTERNAL_ERROR";
11228
+ /**
11229
+ * Error thrown by Artifacts binding operations.
11230
+ *
11231
+ * Uses a string `.code` discriminator following the Cloudflare platform
11232
+ * convention (StreamError, ImagesError, etc.). The `.numericCode` matches
11233
+ * the REST API `errors[].code` values.
11234
+ */
11235
+ export interface ArtifactsError extends Error {
11236
+ readonly name: "ArtifactsError";
11237
+ /** String error code for programmatic matching. */
11238
+ readonly code: ArtifactsErrorCode;
11239
+ /** Numeric error code matching the REST API. */
11240
+ readonly numericCode: number;
11241
+ }
11242
+ // ── Binding ──────────────────────────────────────────────────────────────────
11243
+ /**
11244
+ * Artifacts binding — namespace-level operations.
11245
+ *
11246
+ * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11247
+ */
11201
11248
  export interface Artifacts {
11202
11249
  /**
11203
11250
  * Create a new repository with an initial access token.
11204
11251
  * @param name Repository name (alphanumeric, dots, hyphens, underscores).
11205
11252
  * @param opts Optional: readOnly flag, description, default branch name.
11206
11253
  * @returns Repo metadata with initial token.
11254
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11255
+ * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the repo already exists.
11207
11256
  */
11208
11257
  create(
11209
11258
  name: string,
@@ -11217,12 +11266,23 @@ export interface Artifacts {
11217
11266
  * Get a handle to an existing repository.
11218
11267
  * @param name Repository name.
11219
11268
  * @returns Repo handle.
11269
+ * @throws {ArtifactsError} with code `NOT_FOUND` if the repo does not exist.
11270
+ * @throws {ArtifactsError} with code `IMPORT_IN_PROGRESS` if the repo is still importing.
11271
+ * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if the repo is still forking.
11220
11272
  */
11221
11273
  get(name: string): Promise<ArtifactsRepo>;
11222
11274
  /**
11223
11275
  * Import a repository from an external git remote.
11224
11276
  * @param params Source URL and optional branch/depth, plus target name and options.
11225
11277
  * @returns Repo metadata with initial token.
11278
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if the target name is invalid.
11279
+ * @throws {ArtifactsError} with code `INVALID_INPUT` if the source URL is not valid HTTPS.
11280
+ * @throws {ArtifactsError} with code `INVALID_URL` if the source URL does not point to a git repository.
11281
+ * @throws {ArtifactsError} with code `REMOTE_AUTH_REQUIRED` if the remote requires authentication.
11282
+ * @throws {ArtifactsError} with code `NOT_FOUND` if the remote repository does not exist.
11283
+ * @throws {ArtifactsError} with code `UPSTREAM_UNAVAILABLE` if the remote cannot be reached.
11284
+ * @throws {ArtifactsError} with code `MEMORY_LIMIT` if the import exceeds service memory limits.
11285
+ * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11226
11286
  */
11227
11287
  import(params: {
11228
11288
  source: {
@@ -11250,6 +11310,7 @@ export interface Artifacts {
11250
11310
  * Delete a repository and all associated tokens.
11251
11311
  * @param name Repository name.
11252
11312
  * @returns true if deleted, false if not found.
11313
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11253
11314
  */
11254
11315
  delete(name: string): Promise<boolean>;
11255
11316
  }
@@ -14711,6 +14772,9 @@ export declare namespace TailStream {
14711
14772
  // 1. This is an Onset event
14712
14773
  // 2. We are not inheriting any SpanContext. (e.g. this is a cross-account service binding or a new top-level invocation)
14713
14774
  readonly spanId?: string;
14775
+ // W3C trace flags from an upstream traceparent. Absent when no upstream
14776
+ // sampling decision was made.
14777
+ readonly traceFlags?: number;
14714
14778
  }
14715
14779
  interface TailEvent<Event extends EventType> {
14716
14780
  // invocation id of the currently invoked worker stage.
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  },
8
8
  "author": "Workers Community",
9
9
  "license": "MIT OR Apache-2.0",
10
- "version": "4.20260511.1",
10
+ "version": "4.20260514.1",
11
11
  "exports": {
12
12
  ".": {
13
13
  "types": "./index.d.ts",