-
Notifications
You must be signed in to change notification settings - Fork 621
feat: add Artifacts binding TypeScript definitions #6508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dario-piotrowicz
merged 16 commits into
cloudflare:main
from
mattzcarey:feat/artifacts-binding-types
Apr 17, 2026
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
54e42f1
feat: add Artifacts binding TypeScript definitions
mattzcarey fc36f61
fix: correct fork() return type to include repo handle instead of obj…
mattzcarey 62e230b
fix: align Artifacts type definitions with actual binding API
mattzcarey f0ba2b1
chore: update generated type snapshots with Artifacts types
mattzcarey f73fccb
fix: apply PR review suggestions
mattzcarey 35e8d87
fix: remove import(), return typed status from get()
mattzcarey b7f2572
fix: use discriminated union for get() result with retryAfter
mattzcarey 56bc9da
fix: apply artifacts types cleanup
mattzcarey 3507b00
Update types/defines/artifacts.d.ts
dario-piotrowicz 501c7f1
update `ArtifactsRepo` to extend `ArtifactsRepoInfo`
dario-piotrowicz 603862b
Update incorrect jsdoc comment
dario-piotrowicz 3798d21
Update types/defines/artifacts.d.ts
dario-piotrowicz ddbc54a
Update token scope to use strings union
dario-piotrowicz 0996d4f
update generated types
dario-piotrowicz 77824cf
Merge branch 'main' into feat/artifacts-binding-types
mattzcarey 139ff03
Merge branch 'main' into feat/artifacts-binding-types
mattzcarey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,192 @@ | ||
| // Copyright (c) 2022-2025 Cloudflare, Inc. | ||
| // Licensed under the Apache 2.0 license found in the LICENSE file or at: | ||
| // https://opensource.org/licenses/Apache-2.0 | ||
|
|
||
| /** | ||
| * Artifacts — Git-compatible file storage on Cloudflare Workers. | ||
| * | ||
| * Provides programmatic access to create, manage, and fork repositories, | ||
| * and to issue and revoke scoped access tokens. | ||
| */ | ||
|
|
||
| /** Information about a repository. */ | ||
| interface ArtifactsRepoInfo { | ||
| /** Unique repository ID. */ | ||
| id: string; | ||
| /** Repository name. */ | ||
| name: string; | ||
| /** Repository description, or null if not set. */ | ||
| description: string | null; | ||
| /** Default branch name (e.g. "main"). */ | ||
| defaultBranch: string; | ||
| /** ISO 8601 creation timestamp. */ | ||
| createdAt: string; | ||
| /** ISO 8601 last-updated timestamp. */ | ||
| updatedAt: string; | ||
| /** ISO 8601 timestamp of the last push, or null if never pushed. */ | ||
| lastPushAt: string | null; | ||
| /** Fork source (e.g. "github:owner/repo", "artifacts:namespace/repo"), or null if not a fork. */ | ||
| source: string | null; | ||
| /** Whether the repository is read-only. */ | ||
| readOnly: boolean; | ||
| /** HTTPS git remote URL. */ | ||
| remote: string; | ||
| } | ||
|
|
||
| /** Result of creating a repository — includes the initial access token. */ | ||
| interface ArtifactsCreateRepoResult { | ||
| /** Unique repository ID. */ | ||
| id: string; | ||
| /** Repository name. */ | ||
| name: string; | ||
| /** Repository description, or null if not set. */ | ||
| description: string | null; | ||
| /** Default branch name. */ | ||
| defaultBranch: string; | ||
| /** HTTPS git remote URL. */ | ||
| remote: string; | ||
| /** Plaintext access token (only returned at creation time). */ | ||
| token: string; | ||
| /** ISO 8601 token expiry timestamp. */ | ||
| tokenExpiresAt: string; | ||
| } | ||
|
|
||
| /** Paginated list of repositories. */ | ||
| interface ArtifactsRepoListResult { | ||
| /** Repositories in this page (without the `remote` field). */ | ||
| repos: Omit<ArtifactsRepoInfo, 'remote'>[]; | ||
| /** Total number of repositories in the namespace. */ | ||
| total: number; | ||
| /** Cursor for the next page, if there are more results. */ | ||
| cursor?: string; | ||
| } | ||
|
|
||
| /** Result of creating an access token. */ | ||
| interface ArtifactsCreateTokenResult { | ||
| /** Unique token ID. */ | ||
| id: string; | ||
| /** Plaintext token (only returned at creation time). */ | ||
| plaintext: string; | ||
| /** Token scope: "read" or "write". */ | ||
| scope: 'read' | 'write'; | ||
| /** ISO 8601 token expiry timestamp. */ | ||
| expiresAt: string; | ||
| } | ||
|
|
||
| /** Token metadata (no plaintext). */ | ||
| interface ArtifactsTokenInfo { | ||
| /** Unique token ID. */ | ||
| id: string; | ||
| /** Token scope: "read" or "write". */ | ||
| scope: 'read' | 'write'; | ||
| /** Token state: "active", "expired", or "revoked". */ | ||
| state: 'active' | 'expired' | 'revoked'; | ||
| /** ISO 8601 creation timestamp. */ | ||
| createdAt: string; | ||
| /** ISO 8601 expiry timestamp. */ | ||
| expiresAt: string; | ||
| } | ||
|
|
||
| /** Paginated list of tokens for a repository. */ | ||
| interface ArtifactsTokenListResult { | ||
| /** Tokens in this page. */ | ||
| tokens: ArtifactsTokenInfo[]; | ||
| /** Total number of tokens for the repository. */ | ||
| total: number; | ||
| } | ||
|
|
||
| /** Handle for a single repository. Returned by Artifacts.get(). */ | ||
| interface ArtifactsRepo extends ArtifactsRepoInfo { | ||
| /** | ||
| * Create an access token for this repo. | ||
| * @param scope Token scope: "write" (default) or "read". | ||
| * @param ttl Time-to-live in seconds (default 86400, min 60, max 31536000). | ||
| */ | ||
| createToken( | ||
| scope?: 'write' | 'read', | ||
| ttl?: number | ||
| ): Promise<ArtifactsCreateTokenResult>; | ||
|
|
||
| /** List tokens for this repo (metadata only, no plaintext). */ | ||
| listTokens(): Promise<ArtifactsTokenListResult>; | ||
|
|
||
| /** | ||
| * Revoke a token by plaintext or ID. | ||
| * @param tokenOrId Plaintext token or token ID. | ||
| * @returns true if revoked, false if not found. | ||
| */ | ||
| revokeToken(tokenOrId: string): Promise<boolean>; | ||
|
|
||
| // ── Fork ── | ||
|
|
||
| /** | ||
| * Fork this repo to a new repo. | ||
| * @param name Target repository name. | ||
| * @param opts Optional: description, readOnly flag, defaultBranchOnly (default true). | ||
| */ | ||
| fork( | ||
| name: string, | ||
| opts?: { | ||
| description?: string; | ||
| readOnly?: boolean; | ||
| defaultBranchOnly?: boolean; | ||
| } | ||
| ): Promise<ArtifactsCreateRepoResult>; | ||
| } | ||
|
|
||
| /** Artifacts binding — namespace-level operations. */ | ||
| interface Artifacts { | ||
| /** | ||
| * Create a new repository with an initial access token. | ||
| * @param name Repository name (alphanumeric, dots, hyphens, underscores). | ||
| * @param opts Optional: readOnly flag, description, default branch name. | ||
| * @returns Repo metadata with initial token. | ||
| */ | ||
| create( | ||
| name: string, | ||
| opts?: { readOnly?: boolean; description?: string; setDefaultBranch?: string } | ||
|
mattzcarey marked this conversation as resolved.
|
||
| ): Promise<ArtifactsCreateRepoResult>; | ||
|
|
||
| /** | ||
| * Get a handle to an existing repository. | ||
| * @param name Repository name. | ||
| * @returns Repo handle. | ||
| */ | ||
| get(name: string): Promise<ArtifactsRepo>; | ||
|
dario-piotrowicz marked this conversation as resolved.
|
||
|
|
||
| /** | ||
| * Import a repository from an external git remote. | ||
| * @param params Source URL and optional branch/depth, plus target name and options. | ||
| * @returns Repo metadata with initial token. | ||
| */ | ||
| import(params: { | ||
| source: { | ||
| url: string; | ||
| branch?: string; | ||
| depth?: number; | ||
| }; | ||
| target: { | ||
| name: string; | ||
| opts?: { | ||
| description?: string; | ||
| readOnly?: boolean; | ||
| }; | ||
| }; | ||
|
mattzcarey marked this conversation as resolved.
|
||
| }): Promise<ArtifactsCreateRepoResult>; | ||
|
|
||
| /** | ||
| * List repositories with cursor-based pagination. | ||
| * @param opts Optional: limit (1–200, default 50), cursor for next page. | ||
| */ | ||
| list(opts?: { | ||
| limit?: number; | ||
| cursor?: string; | ||
| }): Promise<ArtifactsRepoListResult>; | ||
|
|
||
| /** | ||
| * Delete a repository and all associated tokens. | ||
| * @param name Repository name. | ||
| * @returns true if deleted, false if not found. | ||
| */ | ||
| delete(name: string): Promise<boolean>; | ||
| } | ||
|
mattzcarey marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.