Function categorizeImports

  • Categorize imports into their respective categories. This does not include types.

    Returns {
        collections: {
            createCollection: ((title: string, options?: CreateCollectionOptions) => Promise<CreatedCollection>);
            getCollectionMeta: ((id: Snowflake) => Promise<CollectionMeta>);
        };
        files: {
            deleteFile: ((id: Snowflake, token: string) => Promise<string>);
            getFileMeta: ((id: Snowflake) => Promise<FileMeta>);
            uploadFile: ((file: UploadableFile, options?: FileOptions, subdomain?: string) => Promise<FileData>);
        };
        links: {
            createLink: ((url: string, subdomain?: string) => Promise<Link>);
            deleteLink: ((id: Snowflake, token: string) => Promise<string>);
        };
        subdomains: {
            checkSubdomain: ((subdomain: string) => Promise<boolean>);
            getSubdomainMeta: ((subdomain: string) => Promise<Subdomain>);
            listSubdomains: (() => Promise<SubdomainData[]>);
        };
        text: {
            createPaste: ((text: string) => Promise<Paste>);
            deletePaste: ((id: Snowflake, token: string) => Promise<string>);
        };
        userAgent: UserAgentClass;
        utility: {
            convertSxcuFile: ((file: string) => ConvertedSxcuFile);
            createError: ((message: string, code: number) => ErrorObject);
            extractToken: ((url: string) => string);
            getRateLimits: (() => {
                [key: string]: RateLimit;
            });
            parseSnowflake: ((snowflake: Snowflake) => ParsedSnowflake);
            promisifyEndpointRateLimit: ((endpoint: Endpoint) => Promise<void>);
            promisifyGlobalRateLimit: (() => Promise<void>);
            promisifyRateLimit: ((rateLimit: RateLimit) => Promise<void>);
            request: ((options: RequestOptions) => Promise<{
                [key: string]: any;
            }>);
            resolveError: ((thing: string | {
                code?: number;
                error?: string;
                message?: string;
            }) => ErrorObject);
            toggleRequestQueue: ((enabled: boolean, retryEnabled?: boolean) => void);
        };
    }

    • collections: {
          createCollection: ((title: string, options?: CreateCollectionOptions) => Promise<CreatedCollection>);
          getCollectionMeta: ((id: Snowflake) => Promise<CollectionMeta>);
      }
    • files: {
          deleteFile: ((id: Snowflake, token: string) => Promise<string>);
          getFileMeta: ((id: Snowflake) => Promise<FileMeta>);
          uploadFile: ((file: UploadableFile, options?: FileOptions, subdomain?: string) => Promise<FileData>);
      }
      • deleteFile: ((id: Snowflake, token: string) => Promise<string>)
          • (id, token): Promise<string>
          • Delete a file.

            Parameters

            • id: Snowflake

              The ID of the file.

            • token: string

              The deletion token of the file.

            Returns Promise<string>

            The response message. (Success message.)

      • getFileMeta: ((id: Snowflake) => Promise<FileMeta>)
          • (id): Promise<FileMeta>
          • Get the meta information of a file.

            Parameters

            Returns Promise<FileMeta>

            The meta information.

      • uploadFile: ((file: UploadableFile, options?: FileOptions, subdomain?: string) => Promise<FileData>)
          • (file, options?, subdomain?): Promise<FileData>
          • Upload a file.

            Parameters

            • file: UploadableFile

              The file to upload.

            • Optionaloptions: FileOptions

              File options.

            • Optionalsubdomain: string

              Subdomain to upload to.

            Returns Promise<FileData>

            The uploaded file.

    • links: {
          createLink: ((url: string, subdomain?: string) => Promise<Link>);
          deleteLink: ((id: Snowflake, token: string) => Promise<string>);
      }
      • createLink: ((url: string, subdomain?: string) => Promise<Link>)
          • (url, subdomain?): Promise<Link>
          • Create a link.

            Parameters

            • url: string

              Url to create the link for.

            • Optionalsubdomain: string

              Subdomain to create the link on.

            Returns Promise<Link>

            The created link.

      • deleteLink: ((id: Snowflake, token: string) => Promise<string>)
          • (id, token): Promise<string>
          • Delete a link.

            Parameters

            • id: Snowflake

              The ID of the link.

            • token: string

              The deletion token of the link.

            Returns Promise<string>

            The response message. (Success message.)

    • subdomains: {
          checkSubdomain: ((subdomain: string) => Promise<boolean>);
          getSubdomainMeta: ((subdomain: string) => Promise<Subdomain>);
          listSubdomains: (() => Promise<SubdomainData[]>);
      }
      • checkSubdomain: ((subdomain: string) => Promise<boolean>)
          • (subdomain): Promise<boolean>
          • Check if a subdomain exists.

            Parameters

            • subdomain: string

              The subdomain to check.

            Returns Promise<boolean>

            If the subdomain currently exists or not.

      • getSubdomainMeta: ((subdomain: string) => Promise<Subdomain>)
          • (subdomain): Promise<Subdomain>
          • Get the meta data of a subdomain.

            Parameters

            • subdomain: string

              The subdomain to get the meta data of.

            Returns Promise<Subdomain>

            The meta data of the subdomain.

      • listSubdomains: (() => Promise<SubdomainData[]>)
          • (): Promise<SubdomainData[]>
          • Get a list of all subdomains. WARNING: The returned list includes NSFW domain names.

            Returns Promise<SubdomainData[]>

            A list of subdomains.

    • text: {
          createPaste: ((text: string) => Promise<Paste>);
          deletePaste: ((id: Snowflake, token: string) => Promise<string>);
      }
      • createPaste: ((text: string) => Promise<Paste>)
          • (text): Promise<Paste>
          • Create a paste.

            Parameters

            • text: string

              The text to upload.

            Returns Promise<Paste>

            The created link.

      • deletePaste: ((id: Snowflake, token: string) => Promise<string>)
          • (id, token): Promise<string>
          • Delete a paste.

            Parameters

            • id: Snowflake

              The ID of the paste.

            • token: string

              The deletion token of the paste.

            Returns Promise<string>

            The response message. (Success message.)

    • userAgent: UserAgentClass
    • utility: {
          convertSxcuFile: ((file: string) => ConvertedSxcuFile);
          createError: ((message: string, code: number) => ErrorObject);
          extractToken: ((url: string) => string);
          getRateLimits: (() => {
              [key: string]: RateLimit;
          });
          parseSnowflake: ((snowflake: Snowflake) => ParsedSnowflake);
          promisifyEndpointRateLimit: ((endpoint: Endpoint) => Promise<void>);
          promisifyGlobalRateLimit: (() => Promise<void>);
          promisifyRateLimit: ((rateLimit: RateLimit) => Promise<void>);
          request: ((options: RequestOptions) => Promise<{
              [key: string]: any;
          }>);
          resolveError: ((thing: string | {
              code?: number;
              error?: string;
              message?: string;
          }) => ErrorObject);
          toggleRequestQueue: ((enabled: boolean, retryEnabled?: boolean) => void);
      }
      • convertSxcuFile: ((file: string) => ConvertedSxcuFile)
          • (file): ConvertedSxcuFile
          • Convert an sxcu file to a useable object.

            Parameters

            • file: string

              Path of the file to convert.

            Returns ConvertedSxcuFile

            The converted object.

      • createError: ((message: string, code: number) => ErrorObject)
          • (message, code): ErrorObject
          • Create an error code.

            Parameters

            • message: string

              Error message.

            • code: number

              Error code.

            Returns ErrorObject

      • extractToken: ((url: string) => string)
          • (url): string
          • Extracts the token or id from a url or path.

            Parameters

            • url: string

              Url to extract the token from.

            Returns string

            The token.

      • getRateLimits: (() => {
            [key: string]: RateLimit;
        })
          • (): {
                [key: string]: RateLimit;
            }
          • Returns a copy of the object containing all stored rate limits.

            Returns {
                [key: string]: RateLimit;
            }

      • parseSnowflake: ((snowflake: Snowflake) => ParsedSnowflake)
          • (snowflake): ParsedSnowflake
          • Get the data associated with a snowflake. This will attempt to parse the snowflake even if it is a number. However, numbers are unlikely to return accurate results.

            Parameters

            • snowflake: Snowflake

              The snowflake to parse.

            Returns ParsedSnowflake

            The snowflake's data.

      • promisifyEndpointRateLimit: ((endpoint: Endpoint) => Promise<void>)
          • (endpoint): Promise<void>
          • A wrapper for promisifyRateLimit that uses an endpoint's rate limit as the first argument. Note that if rate limit data for said endpoint isn't available then it will instantly resolve.

            Parameters

            • endpoint: Endpoint

              Endpoint to promisify the rate limit of.

            Returns Promise<void>

      • promisifyGlobalRateLimit: (() => Promise<void>)
          • (): Promise<void>
          • A wrapper for promisifyRateLimit that uses the global rate limit as the first argument. Note that if the global rate limit isn't available then it will instantly resolve.

            Returns Promise<void>

      • promisifyRateLimit: ((rateLimit: RateLimit) => Promise<void>)
          • (rateLimit): Promise<void>
          • Returns a promise that resolves once the rate limit is over. This will return instantly unless the rate limit has been exceeded.

            Parameters

            • rateLimit: RateLimit

              The rate limit to promisify.

            Returns Promise<void>

      • request: ((options: RequestOptions) => Promise<{
            [key: string]: any;
        }>)
          • (options): Promise<{
                [key: string]: any;
            }>
          • Create an API request.

            Parameters

            Returns Promise<{
                [key: string]: any;
            }>

      • resolveError: ((thing: string | {
            code?: number;
            error?: string;
            message?: string;
        }) => ErrorObject)
          • (thing): ErrorObject
          • Attempt to resolve an error from "thing".

            Parameters

            • thing: string | {
                  code?: number;
                  error?: string;
                  message?: string;
              }

              Thing to attempt to convert to an error.

            Returns ErrorObject

      • toggleRequestQueue: ((enabled: boolean, retryEnabled?: boolean) => void)
          • (enabled, retryEnabled?): void
          • Toggle the request queue. The request queue enables all requests to automatically respect rate limits. It's important to note that this only handles rate limit errors, nothing else. The request queue does NOT keep the current process running indefinitely.

            Parameters

            • enabled: boolean

              If the queue should be enabled or not.

            • OptionalretryEnabled: boolean

              If true, rate limit errors will automatically be retried. Default is false.

            Returns void