Skip to content

feat: add Artifacts binding TypeScript definitions#6593

Merged
16 commits merged intomainfrom
mattzcarey/feat/artifacts-binding-types
Apr 17, 2026
Merged

feat: add Artifacts binding TypeScript definitions#6593
16 commits merged intomainfrom
mattzcarey/feat/artifacts-binding-types

Conversation

@dario-piotrowicz
Copy link
Copy Markdown
Member

@dario-piotrowicz dario-piotrowicz commented Apr 16, 2026

Summary

Add TypeScript type definitions for the Artifacts binding

Changes

New file: types/defines/artifacts.d.ts


Note

This PR is a copy of #6508 in the hope to get the internal-build workflow to pass

mattzcarey and others added 14 commits April 16, 2026 15:12
Add type definitions for the Artifacts binding to types/defines/.

Defines the Artifacts interface with methods for:
- Repository management: createRepo, getRepo, listRepos, deleteRepo
- Fork operations: forkRepo, importFromGitHub
- Token management: createToken, validateToken, listTokens, revokeToken

All methods include JSDoc documentation with parameter descriptions.

Ref: cloudflare/ai-agents/artifacts#2
- Add missing fields to ArtifactsRepoInfo: description, defaultBranch,
  updatedAt, lastPushAt
- Add missing fields to ArtifactsCreateRepoResult: description,
  defaultBranch
- Fix ArtifactsRepoListResult.repos to use Omit<ArtifactsRepoInfo, 'remote'>
  since list() does not include remote URLs
- Fix token scope values from 'rw'/'r' to 'write'/'read' to match
  the public Scope type
- Add missing 'state' field to ArtifactsTokenInfo
- Update JSDoc comments to reflect correct scope values
Add Artifacts binding types to the generated snapshot files
(index.d.ts and index.ts) to match bazel-generated output.
- fork(): flatten to (name, opts?) with description, readOnly, defaultBranchOnly
- create(): add description and setDefaultBranch to opts
- import(): restructure to params object with source and target
- Flatten return types: remove '& { repo: ArtifactsRepo }' intersections
- get(): add JSDoc note about transient states (import/fork in progress)
- Update all 4 generated snapshot files to match
- Remove Artifacts.import() method entirely
- Add ArtifactsGetRepoResult type with repo handle and status field
- get() now returns { repo, status } where status is 'ready' | 'importing' | 'forking'
- Update all generated snapshots
ArtifactsGetRepoResult is now:
  | { status: 'ready'; repo: ArtifactsRepo }
  | { status: 'not_found' }
  | { status: 'importing'; retryAfter: number }
  | { status: 'forking'; retryAfter: number }
- Rename expiresAt → tokenExpiresAt on ArtifactsCreateRepoResult
- Remove ArtifactsTokenValidation and validateToken()
- Remove ArtifactsGetRepoResult union, get() returns ArtifactsRepo directly
- Inline repo fields directly on ArtifactsRepo (no more info() method)
- Restore import() with source/target params structure
- Update all generated snapshots
Co-authored-by: ask-bonk[bot] <249159057+ask-bonk[bot]@users.noreply.github.com>
Co-authored-by: ask-bonk[bot] <249159057+ask-bonk[bot]@users.noreply.github.com>
@dario-piotrowicz dario-piotrowicz requested review from a team as code owners April 16, 2026 14:40
@dario-piotrowicz dario-piotrowicz changed the title feat: add AccessContext types feat: add Artifacts binding TypeScript definitions Apr 16, 2026
Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm Bonk, and I've done a quick review of your PR.

This PR adds hand-written TypeScript type definitions for the new Artifacts binding (repo management, token management, fork operations, import) and updates the generated snapshots.

Issues

  1. ArtifactsTokenListResult is missing cursor for paginationArtifactsRepoListResult supports cursor-based pagination with an optional cursor field, but the structurally-analogous ArtifactsTokenListResult only has tokens and total. If the token list endpoint supports pagination (or will in the future), this field should be present for consistency. Similarly, listTokens() takes no arguments, so there's no way to pass limit/cursor even if the API supports it.

  2. listTokens() has no pagination parameters — Related to (1): Artifacts.list() accepts opts?: { limit?: number; cursor?: string } but ArtifactsRepo.listTokens() takes zero arguments. If a repo can accumulate many tokens, callers have no way to paginate. If the backing API genuinely doesn't support pagination here, it's fine to leave as-is, but please confirm this is intentional.

tokens: ArtifactsTokenInfo[];
/** Total number of tokens for the repository. */
total: number;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ArtifactsRepoListResult has a cursor field for pagination, but the analogous ArtifactsTokenListResult does not. If the token-list API supports (or will support) pagination, this should be consistent:

Suggested change
}
interface ArtifactsTokenListResult {
/** Tokens in this page. */
tokens: ArtifactsTokenInfo[];
/** Total number of tokens for the repository. */
total: number;
/** Cursor for the next page, if there are more results. */
cursor?: string;
}

If the backing API genuinely returns all tokens in one shot with no pagination, this is fine as-is — just confirming it's intentional.

Comment on lines +110 to +111
/** List tokens for this repo (metadata only, no plaintext). */
listTokens(): Promise<ArtifactsTokenListResult>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question: Artifacts.list() accepts { limit?, cursor? } but listTokens() takes no pagination opts. If the token-list endpoint supports pagination, this should accept similar options:

Suggested change
/** List tokens for this repo (metadata only, no plaintext). */
listTokens(): Promise<ArtifactsTokenListResult>;
/** List tokens for this repo (metadata only, no plaintext). */
listTokens(opts?: { limit?: number; cursor?: string }): Promise<ArtifactsTokenListResult>;

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Apr 16, 2026

I'm Bonk, and I've done a quick review of your PR.

This PR adds hand-written TypeScript type definitions for the new Artifacts binding (repo management, token management, fork operations, import) and updates the generated snapshots. The types follow the types/defines/ conventions well -- proper Artifacts prefix on all types, JSDoc on every interface and field, and correct ambient declaration style.

I posted two related comments about a pagination inconsistency:

  1. ArtifactsTokenListResult is missing cursor -- ArtifactsRepoListResult has cursor-based pagination but the structurally-analogous token list result does not.
  2. listTokens() takes no pagination parameters -- Artifacts.list() accepts { limit?, cursor? } but listTokens() takes zero arguments.

Both comments include suggestion blocks. If the backing API genuinely doesn't paginate tokens, these are fine to dismiss -- just wanted confirmation it's intentional.

github run

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 16, 2026

Merging this PR will not alter performance

✅ 72 untouched benchmarks
⏩ 129 skipped benchmarks1


Comparing mattzcarey/feat/artifacts-binding-types (139ff03) with main (16ead14)

Open in CodSpeed

Footnotes

  1. 129 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@dario-piotrowicz
Copy link
Copy Markdown
Member Author

Closing since this PR served its purpose (I believe)

@dario-piotrowicz dario-piotrowicz closed this pull request by merging all changes into main in ce15db6 Apr 17, 2026
@dario-piotrowicz dario-piotrowicz deleted the mattzcarey/feat/artifacts-binding-types branch April 17, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants