diff --git a/types/defines/artifacts.d.ts b/types/defines/artifacts.d.ts index e8fe1004472..467b67d2995 100644 --- a/types/defines/artifacts.d.ts +++ b/types/defines/artifacts.d.ts @@ -51,10 +51,19 @@ interface ArtifactsCreateRepoResult { tokenExpiresAt: string; } +/** Provisioning state returned for repositories in Artifacts list results. */ +type ArtifactsRepoStatus = 'creating' | 'ready' | 'importing' | 'forking'; + +/** Repository entry returned by Artifacts.list(). */ +interface ArtifactsRepoListItem extends Omit { + /** Provisioning state for this repository. */ + status: ArtifactsRepoStatus; +} + /** Paginated list of repositories. */ interface ArtifactsRepoListResult { /** Repositories in this page (without the `remote` field). */ - repos: Omit[]; + repos: ArtifactsRepoListItem[]; /** Total number of repositories in the namespace. */ total: number; /** Cursor for the next page, if there are more results. */ @@ -153,6 +162,7 @@ interface ArtifactsRepo extends ArtifactsRepoInfo { type ArtifactsErrorCode = | 'ALREADY_EXISTS' | 'NOT_FOUND' + | 'CREATE_IN_PROGRESS' | 'IMPORT_IN_PROGRESS' | 'FORK_IN_PROGRESS' | 'INVALID_INPUT' @@ -205,6 +215,7 @@ interface Artifacts { * @param name Repository name. * @returns Repo handle. * @throws {ArtifactsError} with code `NOT_FOUND` if the repo does not exist. + * @throws {ArtifactsError} with code `CREATE_IN_PROGRESS` if the repo is still being created. * @throws {ArtifactsError} with code `IMPORT_IN_PROGRESS` if the repo is still importing. * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if the repo is still forking. */ diff --git a/types/generated-snapshot/experimental/index.d.ts b/types/generated-snapshot/experimental/index.d.ts index 81bdc3137ab..ac17995794a 100755 --- a/types/generated-snapshot/experimental/index.d.ts +++ b/types/generated-snapshot/experimental/index.d.ts @@ -11812,10 +11812,17 @@ interface ArtifactsCreateRepoResult { /** ISO 8601 token expiry timestamp. */ tokenExpiresAt: string; } +/** Provisioning state returned for repositories in Artifacts list results. */ +type ArtifactsRepoStatus = "creating" | "ready" | "importing" | "forking"; +/** Repository entry returned by Artifacts.list(). */ +interface ArtifactsRepoListItem extends Omit { + /** Provisioning state for this repository. */ + status: ArtifactsRepoStatus; +} /** Paginated list of repositories. */ interface ArtifactsRepoListResult { /** Repositories in this page (without the `remote` field). */ - repos: Omit[]; + repos: ArtifactsRepoListItem[]; /** Total number of repositories in the namespace. */ total: number; /** Cursor for the next page, if there are more results. */ @@ -11904,6 +11911,7 @@ interface ArtifactsRepo extends ArtifactsRepoInfo { type ArtifactsErrorCode = | "ALREADY_EXISTS" | "NOT_FOUND" + | "CREATE_IN_PROGRESS" | "IMPORT_IN_PROGRESS" | "FORK_IN_PROGRESS" | "INVALID_INPUT" @@ -11956,6 +11964,7 @@ interface Artifacts { * @param name Repository name. * @returns Repo handle. * @throws {ArtifactsError} with code `NOT_FOUND` if the repo does not exist. + * @throws {ArtifactsError} with code `CREATE_IN_PROGRESS` if the repo is still being created. * @throws {ArtifactsError} with code `IMPORT_IN_PROGRESS` if the repo is still importing. * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if the repo is still forking. */ diff --git a/types/generated-snapshot/experimental/index.ts b/types/generated-snapshot/experimental/index.ts index 2ac8e8855d4..4a0a6bf4f69 100755 --- a/types/generated-snapshot/experimental/index.ts +++ b/types/generated-snapshot/experimental/index.ts @@ -11824,10 +11824,24 @@ export interface ArtifactsCreateRepoResult { /** ISO 8601 token expiry timestamp. */ tokenExpiresAt: string; } +/** Provisioning state returned for repositories in Artifacts list results. */ +export type ArtifactsRepoStatus = + | "creating" + | "ready" + | "importing" + | "forking"; +/** Repository entry returned by Artifacts.list(). */ +export interface ArtifactsRepoListItem extends Omit< + ArtifactsRepoInfo, + "remote" +> { + /** Provisioning state for this repository. */ + status: ArtifactsRepoStatus; +} /** Paginated list of repositories. */ export interface ArtifactsRepoListResult { /** Repositories in this page (without the `remote` field). */ - repos: Omit[]; + repos: ArtifactsRepoListItem[]; /** Total number of repositories in the namespace. */ total: number; /** Cursor for the next page, if there are more results. */ @@ -11916,6 +11930,7 @@ export interface ArtifactsRepo extends ArtifactsRepoInfo { export type ArtifactsErrorCode = | "ALREADY_EXISTS" | "NOT_FOUND" + | "CREATE_IN_PROGRESS" | "IMPORT_IN_PROGRESS" | "FORK_IN_PROGRESS" | "INVALID_INPUT" @@ -11968,6 +11983,7 @@ export interface Artifacts { * @param name Repository name. * @returns Repo handle. * @throws {ArtifactsError} with code `NOT_FOUND` if the repo does not exist. + * @throws {ArtifactsError} with code `CREATE_IN_PROGRESS` if the repo is still being created. * @throws {ArtifactsError} with code `IMPORT_IN_PROGRESS` if the repo is still importing. * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if the repo is still forking. */ diff --git a/types/generated-snapshot/latest/index.d.ts b/types/generated-snapshot/latest/index.d.ts index ee157251900..14112e6c80a 100755 --- a/types/generated-snapshot/latest/index.d.ts +++ b/types/generated-snapshot/latest/index.d.ts @@ -11144,10 +11144,17 @@ interface ArtifactsCreateRepoResult { /** ISO 8601 token expiry timestamp. */ tokenExpiresAt: string; } +/** Provisioning state returned for repositories in Artifacts list results. */ +type ArtifactsRepoStatus = "creating" | "ready" | "importing" | "forking"; +/** Repository entry returned by Artifacts.list(). */ +interface ArtifactsRepoListItem extends Omit { + /** Provisioning state for this repository. */ + status: ArtifactsRepoStatus; +} /** Paginated list of repositories. */ interface ArtifactsRepoListResult { /** Repositories in this page (without the `remote` field). */ - repos: Omit[]; + repos: ArtifactsRepoListItem[]; /** Total number of repositories in the namespace. */ total: number; /** Cursor for the next page, if there are more results. */ @@ -11236,6 +11243,7 @@ interface ArtifactsRepo extends ArtifactsRepoInfo { type ArtifactsErrorCode = | "ALREADY_EXISTS" | "NOT_FOUND" + | "CREATE_IN_PROGRESS" | "IMPORT_IN_PROGRESS" | "FORK_IN_PROGRESS" | "INVALID_INPUT" @@ -11288,6 +11296,7 @@ interface Artifacts { * @param name Repository name. * @returns Repo handle. * @throws {ArtifactsError} with code `NOT_FOUND` if the repo does not exist. + * @throws {ArtifactsError} with code `CREATE_IN_PROGRESS` if the repo is still being created. * @throws {ArtifactsError} with code `IMPORT_IN_PROGRESS` if the repo is still importing. * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if the repo is still forking. */ diff --git a/types/generated-snapshot/latest/index.ts b/types/generated-snapshot/latest/index.ts index b80b35e5793..fa5fe0c23c2 100755 --- a/types/generated-snapshot/latest/index.ts +++ b/types/generated-snapshot/latest/index.ts @@ -11156,10 +11156,24 @@ export interface ArtifactsCreateRepoResult { /** ISO 8601 token expiry timestamp. */ tokenExpiresAt: string; } +/** Provisioning state returned for repositories in Artifacts list results. */ +export type ArtifactsRepoStatus = + | "creating" + | "ready" + | "importing" + | "forking"; +/** Repository entry returned by Artifacts.list(). */ +export interface ArtifactsRepoListItem extends Omit< + ArtifactsRepoInfo, + "remote" +> { + /** Provisioning state for this repository. */ + status: ArtifactsRepoStatus; +} /** Paginated list of repositories. */ export interface ArtifactsRepoListResult { /** Repositories in this page (without the `remote` field). */ - repos: Omit[]; + repos: ArtifactsRepoListItem[]; /** Total number of repositories in the namespace. */ total: number; /** Cursor for the next page, if there are more results. */ @@ -11248,6 +11262,7 @@ export interface ArtifactsRepo extends ArtifactsRepoInfo { export type ArtifactsErrorCode = | "ALREADY_EXISTS" | "NOT_FOUND" + | "CREATE_IN_PROGRESS" | "IMPORT_IN_PROGRESS" | "FORK_IN_PROGRESS" | "INVALID_INPUT" @@ -11300,6 +11315,7 @@ export interface Artifacts { * @param name Repository name. * @returns Repo handle. * @throws {ArtifactsError} with code `NOT_FOUND` if the repo does not exist. + * @throws {ArtifactsError} with code `CREATE_IN_PROGRESS` if the repo is still being created. * @throws {ArtifactsError} with code `IMPORT_IN_PROGRESS` if the repo is still importing. * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if the repo is still forking. */ diff --git a/types/test/types/artifacts.ts b/types/test/types/artifacts.ts new file mode 100644 index 00000000000..3bfcfe708fa --- /dev/null +++ b/types/test/types/artifacts.ts @@ -0,0 +1,24 @@ +// Copyright (c) 2026 Cloudflare, Inc. +// Licensed under the Apache 2.0 license found in the LICENSE file or at: +// https://opensource.org/licenses/Apache-2.0 + +function expectType(_value: T) {} + +export const handler: ExportedHandler<{ ARTIFACTS: Artifacts }> = { + async fetch(_request, env) { + const repos = await env.ARTIFACTS.list(); + expectType(repos.repos[0].status); + + const creating: ArtifactsRepoStatus = 'creating'; + expectType(creating); + + const errorCode: ArtifactsErrorCode = 'CREATE_IN_PROGRESS'; + expectType(errorCode); + + // @ts-expect-error Artifacts repo list statuses must stay constrained. + const unsupportedStatus: ArtifactsRepoStatus = 'provisioning'; + void unsupportedStatus; + + return new Response(); + }, +};