@cloudflare/workers-types 4.20260511.1 → 4.20260515.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.
@@ -11043,12 +11043,17 @@ interface ArtifactsTokenListResult {
11043
11043
  /** Total number of tokens for the repository. */
11044
11044
  total: number;
11045
11045
  }
11046
- /** Handle for a single repository. Returned by Artifacts.get(). */
11046
+ /**
11047
+ * Handle for a single repository. Returned by Artifacts.get().
11048
+ *
11049
+ * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11050
+ */
11047
11051
  interface ArtifactsRepo extends ArtifactsRepoInfo {
11048
11052
  /**
11049
11053
  * Create an access token for this repo.
11050
11054
  * @param scope Token scope: "write" (default) or "read".
11051
11055
  * @param ttl Time-to-live in seconds (default 86400, min 60, max 31536000).
11056
+ * @throws {ArtifactsError} with code `INVALID_TTL` if ttl is out of range.
11052
11057
  */
11053
11058
  createToken(
11054
11059
  scope?: "write" | "read",
@@ -11060,6 +11065,7 @@ interface ArtifactsRepo extends ArtifactsRepoInfo {
11060
11065
  * Revoke a token by plaintext or ID.
11061
11066
  * @param tokenOrId Plaintext token or token ID.
11062
11067
  * @returns true if revoked, false if not found.
11068
+ * @throws {ArtifactsError} with code `INVALID_INPUT` if tokenOrId is empty.
11063
11069
  */
11064
11070
  revokeToken(tokenOrId: string): Promise<boolean>;
11065
11071
  // ── Fork ──
@@ -11067,6 +11073,9 @@ interface ArtifactsRepo extends ArtifactsRepoInfo {
11067
11073
  * Fork this repo to a new repo.
11068
11074
  * @param name Target repository name.
11069
11075
  * @param opts Optional: description, readOnly flag, defaultBranchOnly (default true).
11076
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11077
+ * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11078
+ * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if a fork is already running.
11070
11079
  */
11071
11080
  fork(
11072
11081
  name: string,
@@ -11077,13 +11086,53 @@ interface ArtifactsRepo extends ArtifactsRepoInfo {
11077
11086
  },
11078
11087
  ): Promise<ArtifactsCreateRepoResult>;
11079
11088
  }
11080
- /** Artifacts binding namespace-level operations. */
11089
+ // ── Error types ──────────────────────────────────────────────────────────────
11090
+ /**
11091
+ * Error codes returned by Artifacts binding operations.
11092
+ *
11093
+ * Each code maps to a numeric code available on `ArtifactsError.numericCode`.
11094
+ */
11095
+ type ArtifactsErrorCode =
11096
+ | "ALREADY_EXISTS"
11097
+ | "NOT_FOUND"
11098
+ | "IMPORT_IN_PROGRESS"
11099
+ | "FORK_IN_PROGRESS"
11100
+ | "INVALID_INPUT"
11101
+ | "INVALID_REPO_NAME"
11102
+ | "INVALID_TTL"
11103
+ | "INVALID_URL"
11104
+ | "REMOTE_AUTH_REQUIRED"
11105
+ | "UPSTREAM_UNAVAILABLE"
11106
+ | "MEMORY_LIMIT"
11107
+ | "INTERNAL_ERROR";
11108
+ /**
11109
+ * Error thrown by Artifacts binding operations.
11110
+ *
11111
+ * Uses a string `.code` discriminator following the Cloudflare platform
11112
+ * convention (StreamError, ImagesError, etc.). The `.numericCode` matches
11113
+ * the REST API `errors[].code` values.
11114
+ */
11115
+ interface ArtifactsError extends Error {
11116
+ readonly name: "ArtifactsError";
11117
+ /** String error code for programmatic matching. */
11118
+ readonly code: ArtifactsErrorCode;
11119
+ /** Numeric error code matching the REST API. */
11120
+ readonly numericCode: number;
11121
+ }
11122
+ // ── Binding ──────────────────────────────────────────────────────────────────
11123
+ /**
11124
+ * Artifacts binding — namespace-level operations.
11125
+ *
11126
+ * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11127
+ */
11081
11128
  interface Artifacts {
11082
11129
  /**
11083
11130
  * Create a new repository with an initial access token.
11084
11131
  * @param name Repository name (alphanumeric, dots, hyphens, underscores).
11085
11132
  * @param opts Optional: readOnly flag, description, default branch name.
11086
11133
  * @returns Repo metadata with initial token.
11134
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11135
+ * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the repo already exists.
11087
11136
  */
11088
11137
  create(
11089
11138
  name: string,
@@ -11097,12 +11146,23 @@ interface Artifacts {
11097
11146
  * Get a handle to an existing repository.
11098
11147
  * @param name Repository name.
11099
11148
  * @returns Repo handle.
11149
+ * @throws {ArtifactsError} with code `NOT_FOUND` if the repo does not exist.
11150
+ * @throws {ArtifactsError} with code `IMPORT_IN_PROGRESS` if the repo is still importing.
11151
+ * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if the repo is still forking.
11100
11152
  */
11101
11153
  get(name: string): Promise<ArtifactsRepo>;
11102
11154
  /**
11103
11155
  * Import a repository from an external git remote.
11104
11156
  * @param params Source URL and optional branch/depth, plus target name and options.
11105
11157
  * @returns Repo metadata with initial token.
11158
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if the target name is invalid.
11159
+ * @throws {ArtifactsError} with code `INVALID_INPUT` if the source URL is not valid HTTPS.
11160
+ * @throws {ArtifactsError} with code `INVALID_URL` if the source URL does not point to a git repository.
11161
+ * @throws {ArtifactsError} with code `REMOTE_AUTH_REQUIRED` if the remote requires authentication.
11162
+ * @throws {ArtifactsError} with code `NOT_FOUND` if the remote repository does not exist.
11163
+ * @throws {ArtifactsError} with code `UPSTREAM_UNAVAILABLE` if the remote cannot be reached.
11164
+ * @throws {ArtifactsError} with code `MEMORY_LIMIT` if the import exceeds service memory limits.
11165
+ * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11106
11166
  */
11107
11167
  import(params: {
11108
11168
  source: {
@@ -11130,6 +11190,7 @@ interface Artifacts {
11130
11190
  * Delete a repository and all associated tokens.
11131
11191
  * @param name Repository name.
11132
11192
  * @returns true if deleted, false if not found.
11193
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11133
11194
  */
11134
11195
  delete(name: string): Promise<boolean>;
11135
11196
  }
@@ -14642,6 +14703,9 @@ declare namespace TailStream {
14642
14703
  // 1. This is an Onset event
14643
14704
  // 2. We are not inheriting any SpanContext. (e.g. this is a cross-account service binding or a new top-level invocation)
14644
14705
  readonly spanId?: string;
14706
+ // W3C trace flags from an upstream traceparent. Absent when no upstream
14707
+ // sampling decision was made.
14708
+ readonly traceFlags?: number;
14645
14709
  }
14646
14710
  interface TailEvent<Event extends EventType> {
14647
14711
  // invocation id of the currently invoked worker stage.
@@ -11055,12 +11055,17 @@ export interface ArtifactsTokenListResult {
11055
11055
  /** Total number of tokens for the repository. */
11056
11056
  total: number;
11057
11057
  }
11058
- /** Handle for a single repository. Returned by Artifacts.get(). */
11058
+ /**
11059
+ * Handle for a single repository. Returned by Artifacts.get().
11060
+ *
11061
+ * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11062
+ */
11059
11063
  export interface ArtifactsRepo extends ArtifactsRepoInfo {
11060
11064
  /**
11061
11065
  * Create an access token for this repo.
11062
11066
  * @param scope Token scope: "write" (default) or "read".
11063
11067
  * @param ttl Time-to-live in seconds (default 86400, min 60, max 31536000).
11068
+ * @throws {ArtifactsError} with code `INVALID_TTL` if ttl is out of range.
11064
11069
  */
11065
11070
  createToken(
11066
11071
  scope?: "write" | "read",
@@ -11072,6 +11077,7 @@ export interface ArtifactsRepo extends ArtifactsRepoInfo {
11072
11077
  * Revoke a token by plaintext or ID.
11073
11078
  * @param tokenOrId Plaintext token or token ID.
11074
11079
  * @returns true if revoked, false if not found.
11080
+ * @throws {ArtifactsError} with code `INVALID_INPUT` if tokenOrId is empty.
11075
11081
  */
11076
11082
  revokeToken(tokenOrId: string): Promise<boolean>;
11077
11083
  // ── Fork ──
@@ -11079,6 +11085,9 @@ export interface ArtifactsRepo extends ArtifactsRepoInfo {
11079
11085
  * Fork this repo to a new repo.
11080
11086
  * @param name Target repository name.
11081
11087
  * @param opts Optional: description, readOnly flag, defaultBranchOnly (default true).
11088
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11089
+ * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11090
+ * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if a fork is already running.
11082
11091
  */
11083
11092
  fork(
11084
11093
  name: string,
@@ -11089,13 +11098,53 @@ export interface ArtifactsRepo extends ArtifactsRepoInfo {
11089
11098
  },
11090
11099
  ): Promise<ArtifactsCreateRepoResult>;
11091
11100
  }
11092
- /** Artifacts binding namespace-level operations. */
11101
+ // ── Error types ──────────────────────────────────────────────────────────────
11102
+ /**
11103
+ * Error codes returned by Artifacts binding operations.
11104
+ *
11105
+ * Each code maps to a numeric code available on `ArtifactsError.numericCode`.
11106
+ */
11107
+ export type ArtifactsErrorCode =
11108
+ | "ALREADY_EXISTS"
11109
+ | "NOT_FOUND"
11110
+ | "IMPORT_IN_PROGRESS"
11111
+ | "FORK_IN_PROGRESS"
11112
+ | "INVALID_INPUT"
11113
+ | "INVALID_REPO_NAME"
11114
+ | "INVALID_TTL"
11115
+ | "INVALID_URL"
11116
+ | "REMOTE_AUTH_REQUIRED"
11117
+ | "UPSTREAM_UNAVAILABLE"
11118
+ | "MEMORY_LIMIT"
11119
+ | "INTERNAL_ERROR";
11120
+ /**
11121
+ * Error thrown by Artifacts binding operations.
11122
+ *
11123
+ * Uses a string `.code` discriminator following the Cloudflare platform
11124
+ * convention (StreamError, ImagesError, etc.). The `.numericCode` matches
11125
+ * the REST API `errors[].code` values.
11126
+ */
11127
+ export interface ArtifactsError extends Error {
11128
+ readonly name: "ArtifactsError";
11129
+ /** String error code for programmatic matching. */
11130
+ readonly code: ArtifactsErrorCode;
11131
+ /** Numeric error code matching the REST API. */
11132
+ readonly numericCode: number;
11133
+ }
11134
+ // ── Binding ──────────────────────────────────────────────────────────────────
11135
+ /**
11136
+ * Artifacts binding — namespace-level operations.
11137
+ *
11138
+ * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11139
+ */
11093
11140
  export interface Artifacts {
11094
11141
  /**
11095
11142
  * Create a new repository with an initial access token.
11096
11143
  * @param name Repository name (alphanumeric, dots, hyphens, underscores).
11097
11144
  * @param opts Optional: readOnly flag, description, default branch name.
11098
11145
  * @returns Repo metadata with initial token.
11146
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11147
+ * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the repo already exists.
11099
11148
  */
11100
11149
  create(
11101
11150
  name: string,
@@ -11109,12 +11158,23 @@ export interface Artifacts {
11109
11158
  * Get a handle to an existing repository.
11110
11159
  * @param name Repository name.
11111
11160
  * @returns Repo handle.
11161
+ * @throws {ArtifactsError} with code `NOT_FOUND` if the repo does not exist.
11162
+ * @throws {ArtifactsError} with code `IMPORT_IN_PROGRESS` if the repo is still importing.
11163
+ * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if the repo is still forking.
11112
11164
  */
11113
11165
  get(name: string): Promise<ArtifactsRepo>;
11114
11166
  /**
11115
11167
  * Import a repository from an external git remote.
11116
11168
  * @param params Source URL and optional branch/depth, plus target name and options.
11117
11169
  * @returns Repo metadata with initial token.
11170
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if the target name is invalid.
11171
+ * @throws {ArtifactsError} with code `INVALID_INPUT` if the source URL is not valid HTTPS.
11172
+ * @throws {ArtifactsError} with code `INVALID_URL` if the source URL does not point to a git repository.
11173
+ * @throws {ArtifactsError} with code `REMOTE_AUTH_REQUIRED` if the remote requires authentication.
11174
+ * @throws {ArtifactsError} with code `NOT_FOUND` if the remote repository does not exist.
11175
+ * @throws {ArtifactsError} with code `UPSTREAM_UNAVAILABLE` if the remote cannot be reached.
11176
+ * @throws {ArtifactsError} with code `MEMORY_LIMIT` if the import exceeds service memory limits.
11177
+ * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11118
11178
  */
11119
11179
  import(params: {
11120
11180
  source: {
@@ -11142,6 +11202,7 @@ export interface Artifacts {
11142
11202
  * Delete a repository and all associated tokens.
11143
11203
  * @param name Repository name.
11144
11204
  * @returns true if deleted, false if not found.
11205
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11145
11206
  */
11146
11207
  delete(name: string): Promise<boolean>;
11147
11208
  }
@@ -14603,6 +14664,9 @@ export declare namespace TailStream {
14603
14664
  // 1. This is an Onset event
14604
14665
  // 2. We are not inheriting any SpanContext. (e.g. this is a cross-account service binding or a new top-level invocation)
14605
14666
  readonly spanId?: string;
14667
+ // W3C trace flags from an upstream traceparent. Absent when no upstream
14668
+ // sampling decision was made.
14669
+ readonly traceFlags?: number;
14606
14670
  }
14607
14671
  interface TailEvent<Event extends EventType> {
14608
14672
  // invocation id of the currently invoked worker stage.
@@ -11110,12 +11110,17 @@ interface ArtifactsTokenListResult {
11110
11110
  /** Total number of tokens for the repository. */
11111
11111
  total: number;
11112
11112
  }
11113
- /** Handle for a single repository. Returned by Artifacts.get(). */
11113
+ /**
11114
+ * Handle for a single repository. Returned by Artifacts.get().
11115
+ *
11116
+ * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11117
+ */
11114
11118
  interface ArtifactsRepo extends ArtifactsRepoInfo {
11115
11119
  /**
11116
11120
  * Create an access token for this repo.
11117
11121
  * @param scope Token scope: "write" (default) or "read".
11118
11122
  * @param ttl Time-to-live in seconds (default 86400, min 60, max 31536000).
11123
+ * @throws {ArtifactsError} with code `INVALID_TTL` if ttl is out of range.
11119
11124
  */
11120
11125
  createToken(
11121
11126
  scope?: "write" | "read",
@@ -11127,6 +11132,7 @@ interface ArtifactsRepo extends ArtifactsRepoInfo {
11127
11132
  * Revoke a token by plaintext or ID.
11128
11133
  * @param tokenOrId Plaintext token or token ID.
11129
11134
  * @returns true if revoked, false if not found.
11135
+ * @throws {ArtifactsError} with code `INVALID_INPUT` if tokenOrId is empty.
11130
11136
  */
11131
11137
  revokeToken(tokenOrId: string): Promise<boolean>;
11132
11138
  // ── Fork ──
@@ -11134,6 +11140,9 @@ interface ArtifactsRepo extends ArtifactsRepoInfo {
11134
11140
  * Fork this repo to a new repo.
11135
11141
  * @param name Target repository name.
11136
11142
  * @param opts Optional: description, readOnly flag, defaultBranchOnly (default true).
11143
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11144
+ * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11145
+ * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if a fork is already running.
11137
11146
  */
11138
11147
  fork(
11139
11148
  name: string,
@@ -11144,13 +11153,53 @@ interface ArtifactsRepo extends ArtifactsRepoInfo {
11144
11153
  },
11145
11154
  ): Promise<ArtifactsCreateRepoResult>;
11146
11155
  }
11147
- /** Artifacts binding namespace-level operations. */
11156
+ // ── Error types ──────────────────────────────────────────────────────────────
11157
+ /**
11158
+ * Error codes returned by Artifacts binding operations.
11159
+ *
11160
+ * Each code maps to a numeric code available on `ArtifactsError.numericCode`.
11161
+ */
11162
+ type ArtifactsErrorCode =
11163
+ | "ALREADY_EXISTS"
11164
+ | "NOT_FOUND"
11165
+ | "IMPORT_IN_PROGRESS"
11166
+ | "FORK_IN_PROGRESS"
11167
+ | "INVALID_INPUT"
11168
+ | "INVALID_REPO_NAME"
11169
+ | "INVALID_TTL"
11170
+ | "INVALID_URL"
11171
+ | "REMOTE_AUTH_REQUIRED"
11172
+ | "UPSTREAM_UNAVAILABLE"
11173
+ | "MEMORY_LIMIT"
11174
+ | "INTERNAL_ERROR";
11175
+ /**
11176
+ * Error thrown by Artifacts binding operations.
11177
+ *
11178
+ * Uses a string `.code` discriminator following the Cloudflare platform
11179
+ * convention (StreamError, ImagesError, etc.). The `.numericCode` matches
11180
+ * the REST API `errors[].code` values.
11181
+ */
11182
+ interface ArtifactsError extends Error {
11183
+ readonly name: "ArtifactsError";
11184
+ /** String error code for programmatic matching. */
11185
+ readonly code: ArtifactsErrorCode;
11186
+ /** Numeric error code matching the REST API. */
11187
+ readonly numericCode: number;
11188
+ }
11189
+ // ── Binding ──────────────────────────────────────────────────────────────────
11190
+ /**
11191
+ * Artifacts binding — namespace-level operations.
11192
+ *
11193
+ * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11194
+ */
11148
11195
  interface Artifacts {
11149
11196
  /**
11150
11197
  * Create a new repository with an initial access token.
11151
11198
  * @param name Repository name (alphanumeric, dots, hyphens, underscores).
11152
11199
  * @param opts Optional: readOnly flag, description, default branch name.
11153
11200
  * @returns Repo metadata with initial token.
11201
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11202
+ * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the repo already exists.
11154
11203
  */
11155
11204
  create(
11156
11205
  name: string,
@@ -11164,12 +11213,23 @@ interface Artifacts {
11164
11213
  * Get a handle to an existing repository.
11165
11214
  * @param name Repository name.
11166
11215
  * @returns Repo handle.
11216
+ * @throws {ArtifactsError} with code `NOT_FOUND` if the repo does not exist.
11217
+ * @throws {ArtifactsError} with code `IMPORT_IN_PROGRESS` if the repo is still importing.
11218
+ * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if the repo is still forking.
11167
11219
  */
11168
11220
  get(name: string): Promise<ArtifactsRepo>;
11169
11221
  /**
11170
11222
  * Import a repository from an external git remote.
11171
11223
  * @param params Source URL and optional branch/depth, plus target name and options.
11172
11224
  * @returns Repo metadata with initial token.
11225
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if the target name is invalid.
11226
+ * @throws {ArtifactsError} with code `INVALID_INPUT` if the source URL is not valid HTTPS.
11227
+ * @throws {ArtifactsError} with code `INVALID_URL` if the source URL does not point to a git repository.
11228
+ * @throws {ArtifactsError} with code `REMOTE_AUTH_REQUIRED` if the remote requires authentication.
11229
+ * @throws {ArtifactsError} with code `NOT_FOUND` if the remote repository does not exist.
11230
+ * @throws {ArtifactsError} with code `UPSTREAM_UNAVAILABLE` if the remote cannot be reached.
11231
+ * @throws {ArtifactsError} with code `MEMORY_LIMIT` if the import exceeds service memory limits.
11232
+ * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11173
11233
  */
11174
11234
  import(params: {
11175
11235
  source: {
@@ -11197,6 +11257,7 @@ interface Artifacts {
11197
11257
  * Delete a repository and all associated tokens.
11198
11258
  * @param name Repository name.
11199
11259
  * @returns true if deleted, false if not found.
11260
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11200
11261
  */
11201
11262
  delete(name: string): Promise<boolean>;
11202
11263
  }
@@ -14709,6 +14770,9 @@ declare namespace TailStream {
14709
14770
  // 1. This is an Onset event
14710
14771
  // 2. We are not inheriting any SpanContext. (e.g. this is a cross-account service binding or a new top-level invocation)
14711
14772
  readonly spanId?: string;
14773
+ // W3C trace flags from an upstream traceparent. Absent when no upstream
14774
+ // sampling decision was made.
14775
+ readonly traceFlags?: number;
14712
14776
  }
14713
14777
  interface TailEvent<Event extends EventType> {
14714
14778
  // invocation id of the currently invoked worker stage.
@@ -11122,12 +11122,17 @@ export interface ArtifactsTokenListResult {
11122
11122
  /** Total number of tokens for the repository. */
11123
11123
  total: number;
11124
11124
  }
11125
- /** Handle for a single repository. Returned by Artifacts.get(). */
11125
+ /**
11126
+ * Handle for a single repository. Returned by Artifacts.get().
11127
+ *
11128
+ * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11129
+ */
11126
11130
  export interface ArtifactsRepo extends ArtifactsRepoInfo {
11127
11131
  /**
11128
11132
  * Create an access token for this repo.
11129
11133
  * @param scope Token scope: "write" (default) or "read".
11130
11134
  * @param ttl Time-to-live in seconds (default 86400, min 60, max 31536000).
11135
+ * @throws {ArtifactsError} with code `INVALID_TTL` if ttl is out of range.
11131
11136
  */
11132
11137
  createToken(
11133
11138
  scope?: "write" | "read",
@@ -11139,6 +11144,7 @@ export interface ArtifactsRepo extends ArtifactsRepoInfo {
11139
11144
  * Revoke a token by plaintext or ID.
11140
11145
  * @param tokenOrId Plaintext token or token ID.
11141
11146
  * @returns true if revoked, false if not found.
11147
+ * @throws {ArtifactsError} with code `INVALID_INPUT` if tokenOrId is empty.
11142
11148
  */
11143
11149
  revokeToken(tokenOrId: string): Promise<boolean>;
11144
11150
  // ── Fork ──
@@ -11146,6 +11152,9 @@ export interface ArtifactsRepo extends ArtifactsRepoInfo {
11146
11152
  * Fork this repo to a new repo.
11147
11153
  * @param name Target repository name.
11148
11154
  * @param opts Optional: description, readOnly flag, defaultBranchOnly (default true).
11155
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11156
+ * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11157
+ * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if a fork is already running.
11149
11158
  */
11150
11159
  fork(
11151
11160
  name: string,
@@ -11156,13 +11165,53 @@ export interface ArtifactsRepo extends ArtifactsRepoInfo {
11156
11165
  },
11157
11166
  ): Promise<ArtifactsCreateRepoResult>;
11158
11167
  }
11159
- /** Artifacts binding namespace-level operations. */
11168
+ // ── Error types ──────────────────────────────────────────────────────────────
11169
+ /**
11170
+ * Error codes returned by Artifacts binding operations.
11171
+ *
11172
+ * Each code maps to a numeric code available on `ArtifactsError.numericCode`.
11173
+ */
11174
+ export type ArtifactsErrorCode =
11175
+ | "ALREADY_EXISTS"
11176
+ | "NOT_FOUND"
11177
+ | "IMPORT_IN_PROGRESS"
11178
+ | "FORK_IN_PROGRESS"
11179
+ | "INVALID_INPUT"
11180
+ | "INVALID_REPO_NAME"
11181
+ | "INVALID_TTL"
11182
+ | "INVALID_URL"
11183
+ | "REMOTE_AUTH_REQUIRED"
11184
+ | "UPSTREAM_UNAVAILABLE"
11185
+ | "MEMORY_LIMIT"
11186
+ | "INTERNAL_ERROR";
11187
+ /**
11188
+ * Error thrown by Artifacts binding operations.
11189
+ *
11190
+ * Uses a string `.code` discriminator following the Cloudflare platform
11191
+ * convention (StreamError, ImagesError, etc.). The `.numericCode` matches
11192
+ * the REST API `errors[].code` values.
11193
+ */
11194
+ export interface ArtifactsError extends Error {
11195
+ readonly name: "ArtifactsError";
11196
+ /** String error code for programmatic matching. */
11197
+ readonly code: ArtifactsErrorCode;
11198
+ /** Numeric error code matching the REST API. */
11199
+ readonly numericCode: number;
11200
+ }
11201
+ // ── Binding ──────────────────────────────────────────────────────────────────
11202
+ /**
11203
+ * Artifacts binding — namespace-level operations.
11204
+ *
11205
+ * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11206
+ */
11160
11207
  export interface Artifacts {
11161
11208
  /**
11162
11209
  * Create a new repository with an initial access token.
11163
11210
  * @param name Repository name (alphanumeric, dots, hyphens, underscores).
11164
11211
  * @param opts Optional: readOnly flag, description, default branch name.
11165
11212
  * @returns Repo metadata with initial token.
11213
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11214
+ * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the repo already exists.
11166
11215
  */
11167
11216
  create(
11168
11217
  name: string,
@@ -11176,12 +11225,23 @@ export interface Artifacts {
11176
11225
  * Get a handle to an existing repository.
11177
11226
  * @param name Repository name.
11178
11227
  * @returns Repo handle.
11228
+ * @throws {ArtifactsError} with code `NOT_FOUND` if the repo does not exist.
11229
+ * @throws {ArtifactsError} with code `IMPORT_IN_PROGRESS` if the repo is still importing.
11230
+ * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if the repo is still forking.
11179
11231
  */
11180
11232
  get(name: string): Promise<ArtifactsRepo>;
11181
11233
  /**
11182
11234
  * Import a repository from an external git remote.
11183
11235
  * @param params Source URL and optional branch/depth, plus target name and options.
11184
11236
  * @returns Repo metadata with initial token.
11237
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if the target name is invalid.
11238
+ * @throws {ArtifactsError} with code `INVALID_INPUT` if the source URL is not valid HTTPS.
11239
+ * @throws {ArtifactsError} with code `INVALID_URL` if the source URL does not point to a git repository.
11240
+ * @throws {ArtifactsError} with code `REMOTE_AUTH_REQUIRED` if the remote requires authentication.
11241
+ * @throws {ArtifactsError} with code `NOT_FOUND` if the remote repository does not exist.
11242
+ * @throws {ArtifactsError} with code `UPSTREAM_UNAVAILABLE` if the remote cannot be reached.
11243
+ * @throws {ArtifactsError} with code `MEMORY_LIMIT` if the import exceeds service memory limits.
11244
+ * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11185
11245
  */
11186
11246
  import(params: {
11187
11247
  source: {
@@ -11209,6 +11269,7 @@ export interface Artifacts {
11209
11269
  * Delete a repository and all associated tokens.
11210
11270
  * @param name Repository name.
11211
11271
  * @returns true if deleted, false if not found.
11272
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11212
11273
  */
11213
11274
  delete(name: string): Promise<boolean>;
11214
11275
  }
@@ -14670,6 +14731,9 @@ export declare namespace TailStream {
14670
14731
  // 1. This is an Onset event
14671
14732
  // 2. We are not inheriting any SpanContext. (e.g. this is a cross-account service binding or a new top-level invocation)
14672
14733
  readonly spanId?: string;
14734
+ // W3C trace flags from an upstream traceparent. Absent when no upstream
14735
+ // sampling decision was made.
14736
+ readonly traceFlags?: number;
14673
14737
  }
14674
14738
  interface TailEvent<Event extends EventType> {
14675
14739
  // invocation id of the currently invoked worker stage.
@@ -11119,12 +11119,17 @@ interface ArtifactsTokenListResult {
11119
11119
  /** Total number of tokens for the repository. */
11120
11120
  total: number;
11121
11121
  }
11122
- /** Handle for a single repository. Returned by Artifacts.get(). */
11122
+ /**
11123
+ * Handle for a single repository. Returned by Artifacts.get().
11124
+ *
11125
+ * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11126
+ */
11123
11127
  interface ArtifactsRepo extends ArtifactsRepoInfo {
11124
11128
  /**
11125
11129
  * Create an access token for this repo.
11126
11130
  * @param scope Token scope: "write" (default) or "read".
11127
11131
  * @param ttl Time-to-live in seconds (default 86400, min 60, max 31536000).
11132
+ * @throws {ArtifactsError} with code `INVALID_TTL` if ttl is out of range.
11128
11133
  */
11129
11134
  createToken(
11130
11135
  scope?: "write" | "read",
@@ -11136,6 +11141,7 @@ interface ArtifactsRepo extends ArtifactsRepoInfo {
11136
11141
  * Revoke a token by plaintext or ID.
11137
11142
  * @param tokenOrId Plaintext token or token ID.
11138
11143
  * @returns true if revoked, false if not found.
11144
+ * @throws {ArtifactsError} with code `INVALID_INPUT` if tokenOrId is empty.
11139
11145
  */
11140
11146
  revokeToken(tokenOrId: string): Promise<boolean>;
11141
11147
  // ── Fork ──
@@ -11143,6 +11149,9 @@ interface ArtifactsRepo extends ArtifactsRepoInfo {
11143
11149
  * Fork this repo to a new repo.
11144
11150
  * @param name Target repository name.
11145
11151
  * @param opts Optional: description, readOnly flag, defaultBranchOnly (default true).
11152
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11153
+ * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11154
+ * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if a fork is already running.
11146
11155
  */
11147
11156
  fork(
11148
11157
  name: string,
@@ -11153,13 +11162,53 @@ interface ArtifactsRepo extends ArtifactsRepoInfo {
11153
11162
  },
11154
11163
  ): Promise<ArtifactsCreateRepoResult>;
11155
11164
  }
11156
- /** Artifacts binding namespace-level operations. */
11165
+ // ── Error types ──────────────────────────────────────────────────────────────
11166
+ /**
11167
+ * Error codes returned by Artifacts binding operations.
11168
+ *
11169
+ * Each code maps to a numeric code available on `ArtifactsError.numericCode`.
11170
+ */
11171
+ type ArtifactsErrorCode =
11172
+ | "ALREADY_EXISTS"
11173
+ | "NOT_FOUND"
11174
+ | "IMPORT_IN_PROGRESS"
11175
+ | "FORK_IN_PROGRESS"
11176
+ | "INVALID_INPUT"
11177
+ | "INVALID_REPO_NAME"
11178
+ | "INVALID_TTL"
11179
+ | "INVALID_URL"
11180
+ | "REMOTE_AUTH_REQUIRED"
11181
+ | "UPSTREAM_UNAVAILABLE"
11182
+ | "MEMORY_LIMIT"
11183
+ | "INTERNAL_ERROR";
11184
+ /**
11185
+ * Error thrown by Artifacts binding operations.
11186
+ *
11187
+ * Uses a string `.code` discriminator following the Cloudflare platform
11188
+ * convention (StreamError, ImagesError, etc.). The `.numericCode` matches
11189
+ * the REST API `errors[].code` values.
11190
+ */
11191
+ interface ArtifactsError extends Error {
11192
+ readonly name: "ArtifactsError";
11193
+ /** String error code for programmatic matching. */
11194
+ readonly code: ArtifactsErrorCode;
11195
+ /** Numeric error code matching the REST API. */
11196
+ readonly numericCode: number;
11197
+ }
11198
+ // ── Binding ──────────────────────────────────────────────────────────────────
11199
+ /**
11200
+ * Artifacts binding — namespace-level operations.
11201
+ *
11202
+ * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11203
+ */
11157
11204
  interface Artifacts {
11158
11205
  /**
11159
11206
  * Create a new repository with an initial access token.
11160
11207
  * @param name Repository name (alphanumeric, dots, hyphens, underscores).
11161
11208
  * @param opts Optional: readOnly flag, description, default branch name.
11162
11209
  * @returns Repo metadata with initial token.
11210
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11211
+ * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the repo already exists.
11163
11212
  */
11164
11213
  create(
11165
11214
  name: string,
@@ -11173,12 +11222,23 @@ interface Artifacts {
11173
11222
  * Get a handle to an existing repository.
11174
11223
  * @param name Repository name.
11175
11224
  * @returns Repo handle.
11225
+ * @throws {ArtifactsError} with code `NOT_FOUND` if the repo does not exist.
11226
+ * @throws {ArtifactsError} with code `IMPORT_IN_PROGRESS` if the repo is still importing.
11227
+ * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if the repo is still forking.
11176
11228
  */
11177
11229
  get(name: string): Promise<ArtifactsRepo>;
11178
11230
  /**
11179
11231
  * Import a repository from an external git remote.
11180
11232
  * @param params Source URL and optional branch/depth, plus target name and options.
11181
11233
  * @returns Repo metadata with initial token.
11234
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if the target name is invalid.
11235
+ * @throws {ArtifactsError} with code `INVALID_INPUT` if the source URL is not valid HTTPS.
11236
+ * @throws {ArtifactsError} with code `INVALID_URL` if the source URL does not point to a git repository.
11237
+ * @throws {ArtifactsError} with code `REMOTE_AUTH_REQUIRED` if the remote requires authentication.
11238
+ * @throws {ArtifactsError} with code `NOT_FOUND` if the remote repository does not exist.
11239
+ * @throws {ArtifactsError} with code `UPSTREAM_UNAVAILABLE` if the remote cannot be reached.
11240
+ * @throws {ArtifactsError} with code `MEMORY_LIMIT` if the import exceeds service memory limits.
11241
+ * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11182
11242
  */
11183
11243
  import(params: {
11184
11244
  source: {
@@ -11206,6 +11266,7 @@ interface Artifacts {
11206
11266
  * Delete a repository and all associated tokens.
11207
11267
  * @param name Repository name.
11208
11268
  * @returns true if deleted, false if not found.
11269
+ * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11209
11270
  */
11210
11271
  delete(name: string): Promise<boolean>;
11211
11272
  }
@@ -14718,6 +14779,9 @@ declare namespace TailStream {
14718
14779
  // 1. This is an Onset event
14719
14780
  // 2. We are not inheriting any SpanContext. (e.g. this is a cross-account service binding or a new top-level invocation)
14720
14781
  readonly spanId?: string;
14782
+ // W3C trace flags from an upstream traceparent. Absent when no upstream
14783
+ // sampling decision was made.
14784
+ readonly traceFlags?: number;
14721
14785
  }
14722
14786
  interface TailEvent<Event extends EventType> {
14723
14787
  // invocation id of the currently invoked worker stage.