SongGuess
    Preparing search index...

    Repository capability returned by Artifacts.get.

    Metadata is available through info, not as properties on the capability. Methods may throw ArtifactsError with code INTERNAL_ERROR if an unexpected service error occurs.

    The capability is an RPC stub. Dispose of it when finished, for example with using repo = await env.ARTIFACTS.get(name);, to release it before the request ends.

    interface ArtifactsRepo {
        "[dispose]"(): void;
        createToken(
            scope?: "read" | "write",
            ttl?: number,
        ): Promise<ArtifactsCreateTokenResult>;
        fork(
            name: string,
            opts?: {
                defaultBranchOnly?: boolean;
                description?: string;
                readOnly?: boolean;
            },
        ): Promise<ArtifactsCreateRepoResult>;
        info(): Promise<ArtifactsRepoInfo>;
        listTokens(): Promise<ArtifactsTokenListResult>;
        log(
            opts?: { limit?: number; offset?: number; ref?: string },
        ): Promise<ArtifactsCommitMetadata[]>;
        readBlob(hash: string): Promise<Blob | null>;
        readCommit(hash: string): Promise<ArtifactsCommitMetadata | null>;
        readFile(args: { path: string; ref: string }): Promise<Blob | null>;
        readTree(hash: string): Promise<ArtifactsTreeEntry[] | null>;
        revokeToken(tokenOrId: string): Promise<boolean>;
    }

    Hierarchy (View Summary)

    Index
    • Returns void

    • Create an access token for this repo.

      Parameters

      • Optionalscope: "read" | "write"

        Token scope: "write" (default) or "read".

      • Optionalttl: number

        Time-to-live in seconds (default 86400, min 60, max 31536000).

      Returns Promise<ArtifactsCreateTokenResult>

      with code INVALID_TTL if ttl is out of range.

    • Fork this repo to a new repo.

      Parameters

      • name: string

        Target repository name.

      • Optionalopts: { defaultBranchOnly?: boolean; description?: string; readOnly?: boolean }

        Optional: description, readOnly flag, defaultBranchOnly (default true).

      Returns Promise<ArtifactsCreateRepoResult>

      with code INVALID_REPO_NAME if name is invalid.

      with code ALREADY_EXISTS if the target repo already exists.

      with code FORK_IN_PROGRESS if a fork is already running.

    • Retrieve current repository metadata. Each call performs a fresh lookup.

      Returns Promise<ArtifactsRepoInfo>

      Current public repository metadata.

      NOT_FOUND if the repository was deleted, or INTERNAL_ERROR on an unexpected lookup failure.

    • List commits along the first-parent chain, newest first.

      Parameters

      • Optionalopts: { limit?: number; offset?: number; ref?: string }

        History options. All fields are optional.

        • Optionallimit?: number

          Maximum results; defaults to 50 and is capped at 1000.

        • Optionaloffset?: number

          Number of matching commits to skip; defaults to 0.

        • Optionalref?: string

          Branch, tag, or commit ID; defaults to HEAD.

      Returns Promise<ArtifactsCommitMetadata[]>

      Commit metadata, or an empty array if the ref cannot be resolved.

      INTERNAL_ERROR on an unexpected traversal failure.

    • Read the raw bytes of a Git blob by object ID.

      Parameters

      • hash: string

        Lowercase, 40-character SHA-1 object ID.

      Returns Promise<Blob | null>

      An untyped Blob, or null if the object is missing or is not a Git blob.

      INVALID_INPUT for a malformed hash, MEMORY_LIMIT if the object cannot be buffered safely, or INTERNAL_ERROR on an unexpected read failure.

      ArtifactsRepo.readFile to resolve a file by ref and path.

    • Decode a Git commit by object ID.

      Parameters

      • hash: string

        Lowercase, 40-character SHA-1 commit ID.

      Returns Promise<ArtifactsCommitMetadata | null>

      Commit metadata, or null if the object is missing.

      INVALID_INPUT for a malformed hash, or INTERNAL_ERROR if the object is not a valid commit or the read fails unexpectedly.

    • Resolve a file from a branch, tag, or commit ID and return its bytes with a browser-safe content type in Blob.type.

      Parameters

      • args: { path: string; ref: string }

        File lookup options.

        • path: string

          Non-empty repository-relative path.

        • ref: string

          Branch, tag, or commit ID to resolve.

      Returns Promise<Blob | null>

      A MIME-typed Blob, or null if the ref or path cannot resolve to a file.

      INVALID_INPUT if either argument is empty, MEMORY_LIMIT if the file cannot be buffered safely, or INTERNAL_ERROR on an unexpected read failure.

    • Read the immediate children of a Git tree by object ID.

      Parameters

      • hash: string

        Lowercase, 40-character SHA-1 tree ID.

      Returns Promise<ArtifactsTreeEntry[] | null>

      Tree entries, or null if the object is missing.

      INVALID_INPUT for a malformed hash, or INTERNAL_ERROR if the object is not a valid tree or the read fails unexpectedly.

    • Revoke a token by plaintext or ID.

      Parameters

      • tokenOrId: string

        Plaintext token or token ID.

      Returns Promise<boolean>

      true if revoked, false if not found.

      with code INVALID_INPUT if tokenOrId is empty.