Skip to content

Conversation

wobsoriano
Copy link
Member

@wobsoriano wobsoriano commented Sep 14, 2025

Description

Adding JSDoc for Machine and M2M related backend types for typedoc

will be used to reference objects here clerk/clerk-docs#2593

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • Documentation

    • Improved in-code documentation for machine, machine scope, machine secret key, and machine-to-machine token objects to clarify purpose and usage.
    • Added guidance around many-to-many (M2M) resource types for better developer understanding.
    • No functional or public API changes.
  • Chores

    • Added a patch-level changeset entry to record this documentation-only update.

Copy link

changeset-bot bot commented Sep 14, 2025

🦋 Changeset detected

Latest commit: 2dce5b0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@clerk/backend Patch
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/remix Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Sep 14, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Sep 14, 2025 5:44pm

Copy link
Contributor

coderabbitai bot commented Sep 14, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • .typedoc/__tests__/__snapshots__/file-structure.test.ts.snap is excluded by !**/*.snap

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Documentation-only update: Added JSDoc comments to Backend resource classes (Machine, MachineScope, MachineSecretKey, M2MToken) and added a patch-level changeset documenting these doc updates. No code, signatures, or behavior changed.

Changes

Cohort / File(s) Summary
Changeset
.changeset/honest-plants-kneel.md
Added patch changeset noting documentation-only updates for @clerk/backend.
Backend resource docs
packages/backend/src/api/resources/Machine.ts, packages/backend/src/api/resources/MachineScope.ts, packages/backend/src/api/resources/MachineSecretKey.ts, packages/backend/src/api/resources/M2MToken.ts
Added JSDoc comments describing classes; no functional, signature, or behavioral changes.

Sequence Diagram(s)

(No sequence diagram generated — changes are documentation-only and do not alter control flow.)

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

I thump with joy on meadow green,
New docs bloom where code’s still clean.
Machines, scopes, and tokens set free—
Tiny notes for clarity. 🥕
No logic hopped, just words that be.


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

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title accurately and succinctly summarizes the primary change: adding JSDoc comments to backend Machine and M2M resource types, which matches the file-level summaries and the PR description. It is specific to the backend scope and uses conventional-commit style ("chore(backend):"), making the intent clear to reviewers scanning history. The phrasing is concise and avoids unnecessary detail while conveying the main change.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

Copy link
Contributor

@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)
.changeset/honest-plants-kneel.md (1)

1-5: Patch changeset looks correct for docs-only change.

Patch bump for @clerk/backend is appropriate. Consider capitalizing “M2M” for consistency with class names in the changelog entry.

packages/backend/src/api/resources/Machine.ts (1)

3-6: Enrich the JSDoc with tags, links, and property notes.

Recommend clarifying what this represents and documenting fields for TypeDoc. Also add an explicit visibility tag.

Please confirm the time unit for createdAt/updatedAt (ms vs s) so we can state it explicitly.

-/**
- * The Backend `Machine` object holds information about a machine.
- */
+/**
+ * Represents a Machine resource in the Backend API.
+ * @public
+ * @see {@link MachineJSON}
+ * @remarks A Machine can scope other machines via {@link Machine.scopedMachines}.
+ * @property id - Unique identifier of the machine.
+ * @property name - Human-readable name.
+ * @property instanceId - Owning instance ID.
+ * @property createdAt - Creation timestamp (please confirm unit).
+ * @property updatedAt - Update timestamp (please confirm unit).
+ * @property scopedMachines - Directly scoped machines (no deep nesting by default).
+ * @property defaultTokenTtl - Default token TTL for this machine.
+ * @property secretKey - Present when the secret is provisioned/returned by the API.
+ */
packages/backend/src/api/resources/MachineScope.ts (1)

3-6: Add JSDoc details and visibility; document optional fields.

Call out semantics of “deleted” and confirm timestamp units to avoid ambiguity in generated docs.

-/**
- * The Backend `MachineScope` object holds information about a machine scope.
- */
+/**
+ * Represents a scoping relationship between two machines.
+ * @public
+ * @see {@link MachineScopeJSON}
+ * @property fromMachineId - The scoping (source) machine ID.
+ * @property toMachineId - The scoped (target) machine ID.
+ * @property createdAt - When the scope was created (please confirm unit).
+ * @property deleted - Soft-deletion flag for this scope relationship.
+ */
packages/backend/src/api/resources/M2MToken.ts (1)

3-6: Clarify doc, add security/behavior notes, and tag as public.

Helpful to document token visibility, expiration units, and revocation semantics for consumers.

Please confirm:

  • Whether token is only returned at creation time.
  • Timestamp unit for expiration/createdAt/updatedAt.
-/**
- * The Backend `M2MToken` object holds information about a machine-to-machine token.
- */
+/**
+ * Represents a machine-to-machine (M2M) access token.
+ * @public
+ * @see {@link M2MTokenJSON}
+ * @property id - Token ID.
+ * @property subject - Subject (e.g., machine or service principal).
+ * @property scopes - Authorized scopes for this token.
+ * @property claims - Additional JWT claims attached to the token.
+ * @property revoked - True if the token has been revoked.
+ * @property revocationReason - Optional reason for revocation.
+ * @property expired - True if the token is past its expiration.
+ * @property expiration - Expiration timestamp (please confirm unit).
+ * @property createdAt - Creation timestamp (please confirm unit).
+ * @property updatedAt - Update timestamp (please confirm unit).
+ * @property token - Raw token string when returned by the API (often only at creation; please confirm).
+ */
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0006c82 and 806dd44.

📒 Files selected for processing (4)
  • .changeset/honest-plants-kneel.md (1 hunks)
  • packages/backend/src/api/resources/M2MToken.ts (1 hunks)
  • packages/backend/src/api/resources/Machine.ts (1 hunks)
  • packages/backend/src/api/resources/MachineScope.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
.changeset/**

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Automated releases must use Changesets.

Files:

  • .changeset/honest-plants-kneel.md
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/backend/src/api/resources/M2MToken.ts
  • packages/backend/src/api/resources/MachineScope.ts
  • packages/backend/src/api/resources/Machine.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/backend/src/api/resources/M2MToken.ts
  • packages/backend/src/api/resources/MachineScope.ts
  • packages/backend/src/api/resources/Machine.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/backend/src/api/resources/M2MToken.ts
  • packages/backend/src/api/resources/MachineScope.ts
  • packages/backend/src/api/resources/Machine.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/backend/src/api/resources/M2MToken.ts
  • packages/backend/src/api/resources/MachineScope.ts
  • packages/backend/src/api/resources/Machine.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/backend/src/api/resources/M2MToken.ts
  • packages/backend/src/api/resources/MachineScope.ts
  • packages/backend/src/api/resources/Machine.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/backend/src/api/resources/M2MToken.ts
  • packages/backend/src/api/resources/MachineScope.ts
  • packages/backend/src/api/resources/Machine.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan

Copy link

pkg-pr-new bot commented Sep 14, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@6774

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@6774

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@6774

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@6774

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@6774

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@6774

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6774

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@6774

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@6774

@clerk/express

npm i https://pkg.pr.new/@clerk/express@6774

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@6774

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@6774

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@6774

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@6774

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@6774

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@6774

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6774

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@6774

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@6774

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@6774

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6774

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6774

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@6774

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@6774

commit: 2dce5b0

@wobsoriano wobsoriano merged commit 7c976b4 into main Sep 14, 2025
65 of 66 checks passed
@wobsoriano wobsoriano deleted the rob/machine-jsdoc branch September 14, 2025 18:43
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.

3 participants