Skip to content
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

feat(schema): add ability to view complete signature of every api node including docs #9206

Merged
merged 3 commits into from
Sep 18, 2024

Conversation

luvkapur
Copy link
Member

This PR allows the consumer to view the entire API in detail for a given component. Previously, toString() would only print minimal details along with CLI specific formatting with chalk which doesn't serialize properly. With this PR we add a new method called toFullSignature that returns the completely serializable API details including jsdocs for every API of a component.

example output

API Schema of teambit.people/user-descriptor@b4449409a56964c68ecd99bb9d7bdedd29b9be0b
Classes

export { UserDescriptor as A };

/**
 * Class representing a user descriptor.
 */
class UserDescriptor {
  /**
   * Creates a new `UserDescriptor` instance.
   * @parameter id  - Unique identifier of the user.
   * @parameter username  - Username of the user.
   * @parameter signupDate  - Signup date of the user in ISO format.
   * @parameter email  - Email address of the user. Optional.
   * @parameter displayName  - Display name of the user. Optional.
   * @parameter image  - URL to the user's profile image. Optional.
   * @parameter bio  - Biography of the user. Optional.
   * @parameter company  - Company name associated with the user. Optional.
   * @parameter website  - Personal or company website URL. Optional.
   * @parameter location  - Geographic location of the user. Optional.
   * @parameter twitter  - Twitter handle of the user. Optional.
   * @parameter github  - GitHub username of the user. Optional.
   * @parameter linkedin  - LinkedIn profile URL of the user. Optional.
   * @parameter sso  - Indicates if the user signed up via Single Sign-On. Optional.
   * @parameter theme  - Preferred theme of the user (e.g., 'dark' or 'light'). Optional.
   * @parameter sessionIp  - Last known IP address of the user's session. Optional.
   */
  constructor(id: string, username: string, signupDate: string, email?: string, displayName?: string, image?: string, bio?: string, company?: string, website?: string, location?: string, twitter?: string, github?: string, linkedin?: string, sso?: boolean, theme?: string, sessionIp?: string): UserDescriptor
  /**
   * Retrieves the user's social media handles.
   * @return An object containing the user's Twitter, GitHub, and LinkedIn handles.
   */
  getSocial(): {
      twitter: string;
      github: string;
      linkedin: string;
  }
  get name(): string
  /**
   * Converts the `UserDescriptor` instance to a plain object.
   * @return A `UserDescriptorProps` object.
   */
  toObject(): UserDescriptorProps
  /**
   * Creates a `UserDescriptor` instance from a plain object.
   * @parameter props  - The properties of the user descriptor.
   * @return A new `UserDescriptor` instance.
   */
  static fromObject(props: UserDescriptorProps): UserDescriptor
  /**
   * Creates a `UserDescriptor` instance from an `AccountDescriptor`.
   * @parameter account  - The account descriptor containing user information.
   * @return A new `UserDescriptor` instance.
   */
  static fromAccount(account: AccountDescriptor): UserDescriptor
  /**
   * Creates an array of `UserDescriptor` instances from an array of properties.
   * @parameter props  - An array of `UserDescriptorProps`.
   * @return An array of `UserDescriptor` instances.
   */
  static fromArray(props: UserDescriptorProps[]): UserDescriptor[]
}

Functions

export { SimpleUserMock };

SimpleUserMock(props?: Partial<UserDescriptorProps>): UserDescriptor

export { createMockUserDescriptor };

createMockUserDescriptor(options?: MockUserOptions = {}): UserDescriptor

Variables

export { defaultUserOptions };

defaultUserOptions: {
    username: string;
    id: string;
    signupDate: string;
} = {
  username: 'default',
  id: 'fake-id',
  signupDate: '2022-05-18T08:52:34.084Z',
}

Types

export { UserDescriptorProps };

/**
 * Represents the properties of a user descriptor.
 */
UserDescriptorProps: {
  /**
   * Unique identifier of the user.
   */
  id: string
  /**
   * Username of the user.
   */
  username: string
  /**
   * Signup date of the user in ISO format.
   */
  signupDate: string
  /**
   * Email address of the user. Optional.
   */
  email?: string
  /**
   * Display name of the user. Optional.
   */
  displayName?: string
  /**
   * URL to the user's profile image. Optional.
   */
  image?: string
  /**
   * Biography of the user. Optional.
   */
  bio?: string
  /**
   * Company name associated with the user. Optional.
   */
  company?: string
  /**
   * Personal or company website URL. Optional.
   */
  website?: string
  /**
   * Twitter handle of the user. Optional.
   */
  twitter?: string
  /**
   * GitHub username of the user. Optional.
   */
  github?: string
  /**
   * LinkedIn profile URL of the user. Optional.
   */
  linkedin?: string
  /**
   * Geographic location of the user. Optional.
   */
  location?: string
  /**
   * Indicates if the user signed up via Single Sign-On. Optional.
   */
  sso?: boolean
  /**
   * Preferred theme of the user (e.g., 'dark' or 'light'). Optional.
   */
  theme?: string
  /**
   * Last known IP address of the user's session. Optional.
   */
  sessionIp?: string
}

@luvkapur luvkapur merged commit 8eb6644 into master Sep 18, 2024
11 checks passed
@luvkapur luvkapur deleted the api-ref-fixes-export-details branch September 18, 2024 23:57
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