Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion types/defines/artifacts.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ArtifactsRepoInfo, 'remote'> {
/** Provisioning state for this repository. */
status: ArtifactsRepoStatus;
}

/** Paginated list of repositories. */
interface ArtifactsRepoListResult {
/** Repositories in this page (without the `remote` field). */
repos: Omit<ArtifactsRepoInfo, 'remote'>[];
repos: ArtifactsRepoListItem[];
/** Total number of repositories in the namespace. */
total: number;
/** Cursor for the next page, if there are more results. */
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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.
*/
Expand Down
11 changes: 10 additions & 1 deletion types/generated-snapshot/experimental/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ArtifactsRepoInfo, "remote"> {
/** Provisioning state for this repository. */
status: ArtifactsRepoStatus;
}
/** Paginated list of repositories. */
interface ArtifactsRepoListResult {
/** Repositories in this page (without the `remote` field). */
repos: Omit<ArtifactsRepoInfo, "remote">[];
repos: ArtifactsRepoListItem[];
/** Total number of repositories in the namespace. */
total: number;
/** Cursor for the next page, if there are more results. */
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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.
*/
Expand Down
18 changes: 17 additions & 1 deletion types/generated-snapshot/experimental/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ArtifactsRepoInfo, "remote">[];
repos: ArtifactsRepoListItem[];
/** Total number of repositories in the namespace. */
total: number;
/** Cursor for the next page, if there are more results. */
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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.
*/
Expand Down
11 changes: 10 additions & 1 deletion types/generated-snapshot/latest/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ArtifactsRepoInfo, "remote"> {
/** Provisioning state for this repository. */
status: ArtifactsRepoStatus;
}
/** Paginated list of repositories. */
interface ArtifactsRepoListResult {
/** Repositories in this page (without the `remote` field). */
repos: Omit<ArtifactsRepoInfo, "remote">[];
repos: ArtifactsRepoListItem[];
/** Total number of repositories in the namespace. */
total: number;
/** Cursor for the next page, if there are more results. */
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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.
*/
Expand Down
18 changes: 17 additions & 1 deletion types/generated-snapshot/latest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ArtifactsRepoInfo, "remote">[];
repos: ArtifactsRepoListItem[];
/** Total number of repositories in the namespace. */
total: number;
/** Cursor for the next page, if there are more results. */
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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.
*/
Expand Down
24 changes: 24 additions & 0 deletions types/test/types/artifacts.ts
Original file line number Diff line number Diff line change
@@ -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<T>(_value: T) {}

export const handler: ExportedHandler<{ ARTIFACTS: Artifacts }> = {
async fetch(_request, env) {
const repos = await env.ARTIFACTS.list();
expectType<ArtifactsRepoStatus>(repos.repos[0].status);

const creating: ArtifactsRepoStatus = 'creating';
expectType<ArtifactsRepoStatus>(creating);

const errorCode: ArtifactsErrorCode = 'CREATE_IN_PROGRESS';
expectType<ArtifactsErrorCode>(errorCode);

// @ts-expect-error Artifacts repo list statuses must stay constrained.
const unsupportedStatus: ArtifactsRepoStatus = 'provisioning';
void unsupportedStatus;

return new Response();
},
};
Loading