Skip to content

Conversation

@killagu
Copy link
Member

@killagu killagu commented Nov 17, 2025

Add comprehensive type definitions and tests for multiple OSS operations:

  • Batch operations: deleteMulti for deleting multiple objects
  • Object tagging: getObjectTagging, putObjectTagging, deleteObjectTagging
  • Multipart upload: initMultipartUpload, completeMultipartUpload, multipartUpload, multipartUploadCopy, abortMultipartUpload, listUploads, uploadPartCopy
  • Append operations: append for appendable objects

All methods include complete TypeScript type definitions with options and result interfaces, along with comprehensive type tests.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added append functionality for objects with position support.
    • Added bulk delete operations supporting multiple syntax options.
    • Added object tagging capabilities (get, set, delete).
    • Added multipart upload workflow (init, complete, abort).
    • Added list uploads and upload part copy operations.
  • Chores

    • Updated development dependencies.
    • Added CommonJS and ESM export entry points.

Add comprehensive type definitions and tests for multiple OSS operations:
- Batch operations: deleteMulti for deleting multiple objects
- Object tagging: getObjectTagging, putObjectTagging, deleteObjectTagging
- Multipart upload: initMultipartUpload, completeMultipartUpload, multipartUpload, multipartUploadCopy, abortMultipartUpload, listUploads, uploadPartCopy
- Append operations: append for appendable objects

All methods include complete TypeScript type definitions with options and result interfaces, along with comprehensive type tests.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Nov 17, 2025

Walkthrough

The pull request expands the SimpleClient API surface with new methods for object append, bulk deletion, object tagging, multipart uploads, and part copy operations. Corresponding TypeScript types and test coverage are added. Build configuration is updated with entry points and tooling dependencies.

Changes

Cohort / File(s) Summary
Build Configuration
package.json
Added explicit main and module entry points, set tshy.selfLink to false, and updated dev dependencies: tsd (0.29→0.33), tshy (1.0→3.1), tshy-after (1.0→1.4)
Type Definitions
src/index.ts
Introduced 20+ new types for append, delete-multi, object tagging, multipart uploads, and part-copy operations; extended IObjectSimple interface with 12 new methods including append, deleteMulti, getObjectTagging, putObjectTagging, deleteObjectTagging, initMultipartUpload, completeMultipartUpload, multipartUpload, multipartUploadCopy, abortMultipartUpload, listUploads, and uploadPartCopy
Type Tests
index.test-d.ts
Added comprehensive type assertions and usage tests for all new methods, covering delete-multi variants, tagging workflows, multipart lifecycle, part-copy scenarios, append with path/buffer/stream inputs, and list-uploads variations

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Areas requiring attention:

  • Verify all new method signatures in IObjectSimple align with underlying implementation expectations
  • Validate optional fields in options objects (e.g., position in AppendObjectOptions, versionId in delete targets) match intended behavior
  • Confirm type overloads for deleteMulti are comprehensive and handle both string arrays and key-object arrays correctly
  • Review multipart upload lifecycle types (InitMultipartUploadResult, PartInfo, CompleteMultipartUploadOptions) for consistency with actual usage
  • Check that UploadPartCopySourceData and SourceData type definitions support all required source scenarios

Poem

🐰 A warren of objects now finds new ways to flow,
Tagging and splitting, appending with glow,
Multipart symphonies, copies that soar,
The API expands—what wonders in store!
With types so precise, the rabbits rejoice. 🎉

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main objective of the PR, which is to add TypeScript type definitions for multiple OSS object operations including append, tagging, multipart uploads, and batch operations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/additional_apis

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @killagu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the type safety and developer experience for interacting with Alibaba Cloud OSS by introducing a broad set of new TypeScript type definitions. It covers advanced object operations such as batch deletions, object tagging, and a full suite of multipart upload functionalities, along with append operations. These additions are complemented by thorough type tests, ensuring the robustness and accuracy of the new definitions.

Highlights

  • Expanded Type Definitions: Introduced comprehensive TypeScript type definitions for a wide array of OSS object operations, ensuring better type safety and developer experience.
  • Batch Operations: Added type definitions for 'deleteMulti', allowing for batch deletion of objects with options for quiet mode and versioning.
  • Object Tagging: Implemented type definitions for 'getObjectTagging', 'putObjectTagging', and 'deleteObjectTagging', enabling typed interactions with object tags.
  • Multipart Uploads: Provided extensive type definitions for multipart upload functionalities, including 'initMultipartUpload', 'completeMultipartUpload', 'multipartUpload', 'multipartUploadCopy', 'abortMultipartUpload', 'listUploads', and 'uploadPartCopy'.
  • Append Operations: Introduced type definitions for 'append' operations on appendable objects, including options for specifying the append position.
  • Comprehensive Type Tests: Accompanying all new type definitions are detailed type tests in 'index.test-d.ts' to validate their correctness and usage.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@socket-security
Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedtsd@​0.29.0 ⏵ 0.33.099 +1100100 +181100
Updatedtshy@​1.18.0 ⏵ 3.1.098 -1100100 +187 +6100

View full report

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a significant number of new type definitions for OSS operations, along with corresponding type tests. The changes are well-organized and the new types are comprehensive. My review focuses on improving consistency and clarity in the newly added interfaces. I've identified a few areas where the API can be made more consistent with existing patterns in the library and where some redundancy can be removed.

Comment on lines +222 to +227
export interface DeletedObject {
Key: string;
VersionId?: string;
DeleteMarker?: boolean;
DeleteMarkerVersionId?: string;
}

Choose a reason for hiding this comment

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

medium

The properties in the DeletedObject interface use PascalCase (Key, VersionId, etc.). This is inconsistent with other data-transfer interfaces in this file, such as ObjectMeta and the newly added Upload, which use camelCase. For a consistent API surface, I recommend using camelCase for these properties as well. The library can handle the mapping from the PascalCase XML response internally.

Suggested change
export interface DeletedObject {
Key: string;
VersionId?: string;
DeleteMarker?: boolean;
DeleteMarkerVersionId?: string;
}
export interface DeletedObject {
key: string;
versionId?: string;
deleteMarker?: boolean;
deleteMarkerVersionId?: string;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

image

Comment on lines +314 to +321
export interface MultipartUploadResult {
res: NormalSuccessResponse;
bucket: string;
name: string;
etag: string;
/** callback response data */
data?: object;
}

Choose a reason for hiding this comment

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

medium

The MultipartUploadResult interface is structurally identical to CompleteMultipartUploadResult. To avoid redundancy and improve maintainability, I suggest removing MultipartUploadResult and using CompleteMultipartUploadResult for the multipartUpload method as well. The multipartUpload is a high-level wrapper that internally completes the upload, so it makes sense for it to return the same result type. You would then also update the multipartUpload method signature in the IObjectSimple interface.

Comment on lines +399 to +404
export interface UploadPartCopyOptions extends RequestOptions {
/** version id of source object */
versionId?: string;
headers?: IncomingHttpHeaders;
mime?: string;
}

Choose a reason for hiding this comment

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

medium

The mime property in UploadPartCopyOptions seems out of place. The uploadPartCopy operation copies a part of an existing object, and the MIME type of an object is typically determined during initMultipartUpload. It's not usually specified on a per-part basis during a copy operation. If this is not supported by the OSS API for this specific operation, I recommend removing it to avoid confusion.

export interface UploadPartCopyOptions extends RequestOptions {
  /** version id of source object */
  versionId?: string;
  headers?: IncomingHttpHeaders;
}

/**
* Upload a file to OSS using multipart uploads.
*/
multipartUpload(name: string, file: string | Buffer | Readable, options?: MultipartUploadOptions): Promise<MultipartUploadResult>;

Choose a reason for hiding this comment

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

medium

To address the redundancy between MultipartUploadResult and CompleteMultipartUploadResult, I suggest changing the return type of multipartUpload to Promise<CompleteMultipartUploadResult>. This would allow you to remove the MultipartUploadResult interface entirely.

  multipartUpload(name: string, file: string | Buffer | Readable, options?: MultipartUploadOptions): Promise<CompleteMultipartUploadResult>;

@killagu killagu requested a review from gxkl November 17, 2025 03:57
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
package.json (1)

53-59: Dev dependency bumps: ensure toolchain compatibility

tsd, tshy, and tshy-after all moved to newer major/minor versions. That’s fine, but these tools can change CLI behavior or defaults, so please confirm the generated d.ts output and type tests still behave as expected across Node/TS versions you care about.

If you’d like, I can sketch a small script to run npm test and inspect the generated dist layout in CI.

src/index.ts (2)

217-355: New DeleteMulti, tagging, and multipart types look coherent

The new option/result interfaces:

  • Reuse RequestOptions, UserMeta, ObjectCallback, and NormalSuccessResponse consistently.
  • Mirror expected OSS semantics for delete-multi (quiet, DeletedObject fields), object tagging (status + tag map), and multipart lifecycle (init, complete, resumable upload/copy, abort, and list uploads).
  • Use specific structs (SourceData, Upload, UploadPartCopySourceData) to keep response shapes explicit.

From a type-safety perspective this all looks solid and matches how the tests consume these types.

One optional improvement: the various progress callbacks now appear in multiple interfaces with very similar signatures. You could factor out a shared type ProgressCallback = (...) => void | Promise<void> (or a small family of them) to reduce duplication and keep future changes localized.

Also applies to: 369-411


472-476: Consider exposing the union overload for deleteMulti on IObjectSimple as well

The new methods on IObjectSimple (append, deleteMulti, tagging, multipart, listUploads, uploadPartCopy) line up with their option/result interfaces and the SimpleClient test implementation.

One small ergonomic gap: IObjectSimple.deleteMulti only exposes the two specific overloads

  • names: string[]
  • names: Array<{ key: string; versionId?: string }>

while the concrete SimpleClient implementation also has a union signature. That means a value typed as string[] | Array<{ key: string; versionId?: string }> cannot be passed through an IObjectSimple reference, even though the implementation can handle it.

You can make the interface friendlier by adding a third, more general overload mirroring the implementation and placing it last:

 export interface IObjectSimple {
   …
   /**
    * Delete multiple objects from the bucket.
    */
   deleteMulti(names: string[], options?: DeleteMultiOptions): Promise<DeleteMultiResult>;
   deleteMulti(names: Array<{ key: string; versionId?: string }>, options?: DeleteMultiOptions): Promise<DeleteMultiResult>;
+  deleteMulti(
+    names: string[] | Array<{ key: string; versionId?: string }>,
+    options?: DeleteMultiOptions,
+  ): Promise<DeleteMultiResult>;
   …
 }

Also applies to: 498-503, 510-558

index.test-d.ts (1)

60-63: SimpleClient implementation correctly tracks IObjectSimple, with a nice deleteMulti union implementation

The SimpleClient class:

  • Implements append, deleteMulti, tagging, multipart, listUploads, and uploadPartCopy with signatures matching IObjectSimple.
  • Uses overloaded declarations for deleteMulti followed by a union implementation signature, which is a good pattern for accommodating both string[] and { key, versionId? }[] inputs from callers.
  • Keeps all implementations trivial (console logging + any casting) as appropriate for tsd-style type tests.

One small nuance: delete is declared as taking RequestOptions | DeleteObjectOptions, whereas IObjectSimple.delete only mentions DeleteObjectOptions. That widening is safe but slightly asymmetrical; you could simplify it to DeleteObjectOptions for direct alignment if you want to avoid surprises when reading the test implementation.

Also applies to: 93-98, 107-155

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a141564 and 27c58d1.

📒 Files selected for processing (3)
  • index.test-d.ts (5 hunks)
  • package.json (2 hunks)
  • src/index.ts (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
index.test-d.ts (1)
src/index.ts (25)
  • AppendObjectOptions (124-127)
  • AppendObjectResult (129-138)
  • DeleteMultiOptions (217-220)
  • DeleteMultiResult (229-233)
  • ObjectTaggingOptions (235-237)
  • GetObjectTaggingResult (239-245)
  • PutObjectTaggingResult (247-251)
  • DeleteObjectTaggingResult (253-257)
  • InitMultipartUploadOptions (259-265)
  • InitMultipartUploadResult (267-272)
  • PartInfo (274-279)
  • CompleteMultipartUploadOptions (281-286)
  • CompleteMultipartUploadResult (288-295)
  • MultipartUploadOptions (297-312)
  • MultipartUploadResult (314-321)
  • SourceData (323-332)
  • MultipartUploadCopyOptions (334-348)
  • AbortMultipartUploadOptions (350-350)
  • AbortMultipartUploadResult (352-354)
  • ListUploadsQuery (356-367)
  • RequestOptions (12-15)
  • ListUploadsResult (378-390)
  • UploadPartCopySourceData (392-397)
  • UploadPartCopyOptions (399-404)
  • UploadPartCopyResult (406-411)
🔇 Additional comments (5)
package.json (2)

11-16: tshy selfLink config looks consistent

Disabling tshy.selfLink fits with the explicit tshy.exports mapping you already have; nothing stands out as problematic here.


63-65: Remove legacy "types", "main", and "module" fields—they're redundant and ignored.

Your package.json already defines proper conditional exports with "require" and "import" conditions. When the "exports" field is present, Node.js uses it exclusively and ignores the legacy fallback fields ("types", "main", "module"). This modern configuration correctly routes CJS and ESM under type: "module" without any .js extension issue.

The lines you flagged (63–65) can be safely removed. The actual module resolution is already correct via your "exports" field, which separates type definitions and entry points for each module type. No nested package.json or .cjs extension is needed here.

Likely an incorrect or invalid review comment.

src/index.ts (1)

124-127: Append types align well with existing put-object shapes

Introducing AppendObjectOptions extending PutObjectOptions and adding the optional data field to AppendObjectResult keeps append operations symmetric with normal put (meta, callback, headers, and callback response data), without changing existing fields.

Also applies to: 136-137

index.test-d.ts (2)

11-45: Extended imports are consistent with the new public API

The additional imports (AppendObject*, DeleteMulti*, tagging, multipart, listUploads, uploadPartCopy types, PartInfo, SourceData) line up with the interfaces exported from src/index.ts. This keeps the test surface in sync with the public API surface.


203-478: New tsd assertions give broad coverage of the added operations

The added tsd scenarios exercise:

  • deleteMulti with both string-name arrays and versioned key objects, with and without quiet/timeout.
  • Tagging operations (get/put/delete) with and without versionId and timeout, checking both status and tag map types.
  • Multipart lifecycle: init (with mime/meta/options), complete (with/without callback), upload (string path, Buffer, Readable + options), multipart copy (with SourceData, offsets, and options).
  • Abort and listUploads flows, including pagination markers and encoding-type.
  • Append flows across string path, Buffer, Readable, different position types, and callback responses.
  • Upload-part-copy flows, including empty-range usage and full options including headers and versioning.

These checks collectively validate the new option/result interfaces in src/index.ts and confirm that the method overloads behave as intended from a consumer’s point of view.

Copy link

@gxkl gxkl left a comment

Choose a reason for hiding this comment

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

LGTM

@gxkl gxkl merged commit 823562e into master Nov 17, 2025
7 checks passed
@gxkl gxkl deleted the feat/additional_apis branch November 17, 2025 04:08
@fengmk2
Copy link
Member

fengmk2 commented Nov 17, 2025

我修复一下自动发布的问题

fengmk2 pushed a commit that referenced this pull request Nov 17, 2025
[skip ci]

## 1.4.0 (2025-11-17)

* chore: use trust publish ([a69d91e](a69d91e))
* feat: add type definitions for additional OSS object operations (#11) ([823562e](823562e)), closes [#11](#11)
@github-actions
Copy link

🎉 This PR is included in version 1.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants