internetarchive-ts - v0.1.0
    Preparing search index...

    Class IaCollection<ItemMetaType, ItemFileMetaType>Beta

    This class represents an archive.org collection.

    Type Parameters

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    exists: boolean = false
    itemsCount?: number
    rssUrl: string

    RSS feed URL for this collection

    searches: any
    session: IaSession
    subCollectionsCount?: number
    urls: {
        details: string;
        download: string;
        edit: string;
        editxml: string;
        history: string;
        manage: string;
        metadata: string;
    }

    Item URL types

    wikilink?: string

    A copyable link to the item, in MediaWiki format

    getMd5: (body: string | Buffer | Blob) => Promise<string> = getMd5

    Accessors

    • get created(): number
      Beta

      Date the item was created on

      Returns number

    • get d1(): string | undefined
      Beta

      The primary data node the item is stored on

      Returns string | undefined

    • get d2(): string | undefined
      Beta

      The secondary (backup) data node the item is stored on (unless stored on a solo node)

      Returns string | undefined

    • get dir(): string
      Beta

      The item's absolute pathname (on both data nodes)

      Returns string

    • get files(): {
          [K in string
          | number
          | symbol]: (
              {
                  format: IaFileFormat;
                  md5: string;
                  mtime: `${number}`;
                  name: string;
                  size: `${number}`;
                  source: IaFileSource;
                  [key: string]: IaMetadataValidFieldType
                  | IaMetadataValidFieldType[];
              } & Partial<
                  IaRawMetadata<
                      Omit<ItemFileMetaType, keyof IaFileBasicMetadata<string>>,
                  >,
              >
          )[K]
      }[]
      Beta

      File metadata for this item

      Returns {
          [K in string | number | symbol]: (
              {
                  format: IaFileFormat;
                  md5: string;
                  mtime: `${number}`;
                  name: string;
                  size: `${number}`;
                  source: IaFileSource;
                  [key: string]: IaMetadataValidFieldType
                  | IaMetadataValidFieldType[];
              } & Partial<
                  IaRawMetadata<
                      Omit<ItemFileMetaType, keyof IaFileBasicMetadata<string>>,
                  >,
              >
          )[K]
      }[]

    • get files_count(): number
      Beta

      Total number of files in the item

      Returns number

    • get has_redrow(): boolean
      Beta

      Indicates one or more tasks are red (halted due to error)

      Returns boolean

    • get identifier(): {
          [K in string
          | number
          | symbol]: (
              {
                  addeddate?: string;
                  collection: string
                  | string[];
                  identifier: string;
                  mediatype:
                      | "collection"
                      | "account"
                      | "audio"
                      | "data"
                      | "etree"
                      | "image"
                      | "movies"
                      | "software"
                      | "texts"
                      | "web";
                  publicdate?: string;
                  search_collection?: string;
              } & IaBaseMetadataType & Partial<IaRawMetadata<ItemMetaType>>
          )[K]
      }["identifier"]
      Beta

      Returns {
          [K in string | number | symbol]: (
              {
                  addeddate?: string;
                  collection: string
                  | string[];
                  identifier: string;
                  mediatype:
                      | "collection"
                      | "account"
                      | "audio"
                      | "data"
                      | "etree"
                      | "image"
                      | "movies"
                      | "software"
                      | "texts"
                      | "web";
                  publicdate?: string;
                  search_collection?: string;
              } & IaBaseMetadataType & Partial<IaRawMetadata<ItemMetaType>>
          )[K]
      }["identifier"]

    • get is_collection(): boolean
      Beta

      The item is a collection

      Returns boolean

    • get is_dark(): boolean
      Beta

      The item was darked and is unavailable

      Returns boolean

    • get item_last_updated(): number
      Beta

      The time when the item was last modified

      Returns number

    • get item_size(): number
      Beta

      Total size in bytes of all files in the item

      Returns number

    • get metadata(): {
          [K in string
          | number
          | symbol]: (
              {
                  addeddate?: string;
                  collection: string
                  | string[];
                  identifier: string;
                  mediatype:
                      | "collection"
                      | "account"
                      | "audio"
                      | "data"
                      | "etree"
                      | "image"
                      | "movies"
                      | "software"
                      | "texts"
                      | "web";
                  publicdate?: string;
                  search_collection?: string;
              } & IaBaseMetadataType & Partial<IaRawMetadata<ItemMetaType>>
          )[K]
      }
      Beta

      Item Metadata

      Returns {
          [K in string | number | symbol]: (
              {
                  addeddate?: string;
                  collection: string
                  | string[];
                  identifier: string;
                  mediatype:
                      | "collection"
                      | "account"
                      | "audio"
                      | "data"
                      | "etree"
                      | "image"
                      | "movies"
                      | "software"
                      | "texts"
                      | "web";
                  publicdate?: string;
                  search_collection?: string;
              } & IaBaseMetadataType & Partial<IaRawMetadata<ItemMetaType>>
          )[K]
      }

    • get nodownload(): boolean
      Beta

      The item is not ready for downloading

      Returns boolean

    • get paths(): readonly [
          "details",
          "metadata",
          "download",
          "history",
          "edit",
          "editxml",
          "manage",
      ]
      Beta

      Returns readonly [
          "details",
          "metadata",
          "download",
          "history",
          "edit",
          "editxml",
          "manage",
      ]

    • get pending_tasks(): boolean
      Beta

      Indicates one or more tasks are queued or running

      Returns boolean

    • get server(): string
      Beta

      The preferred server for reading the item's contents. Callers should use this node when constructing a URL

      Returns string

    • get servers_unavailable(): boolean
      Beta

      One or both servers are unavailable, that is, inaccessible for some reason (network problems, under service, etc.)

      Returns boolean

    • get solo(): boolean
      Beta

      The item is only stored on a single node (rare)

      Returns boolean

    • get workable_servers(): string[]
      Beta

      A list of data nodes currently available for accessing the item's contents

      Returns string[]

    Methods

    • Beta

      Dark the item.

      Parameters

      • comment: string

        The curation comment explaining reason for darking item

      • priority:
            | -10
            | -9
            | -8
            | -7
            | -6
            | -5
            | -4
            | -3
            | -2
            | -1
            | 0
            | 1
            | 2
            | 3
            | 4
            | 5
            | 6
            | 7
            | 8
            | 9
            | 10 = 0

        The task priority.

      • reducedPriority: boolean = false

        Submit your derive at a lower priority. This option is helpful to get around rate-limiting. Your task will more likely be accepted, but it might not run for a long time. Note that you still may be subject to rate-limiting. This is different than priority in that it will allow you to possibly avoid rate-limiting.

      • Optionalargs: Record<string, any>

        Additional arguments to submit with the task.

      Returns Promise<Response>

      TODO

    • Beta

      Derive an item.

      Parameters

      • priority:
            | -10
            | -9
            | -8
            | -7
            | -6
            | -5
            | -4
            | -3
            | -2
            | -1
            | 0
            | 1
            | 2
            | 3
            | 4
            | 5
            | 6
            | 7
            | 8
            | 9
            | 10 = 0

        Task priority from 10 to -10 (default: 0)

      • OptionalremoveDerived: string

        You can use wildcards ("globs") to only remove some prior derivatives. For example, "" (typed without the quotation marks) specifies that all derivatives (in the item's top directory) are to be rebuilt. ".mp4" specifies that all ".mp4" deriviatives are to be rebuilt. "{.gif,thumbs/.jpg}" specifies that all GIF and thumbs are to be rebuilt.

      • reducedPriority: boolean = false

        Submit your derive at a lower priority. This option is helpful to get around rate-limiting. Your task will more likely be accepted, but it might not run for a long time. Note that you still may be subject to rate-limiting.

      • args: Record<string, any> = {}

        Additional optional args

      • Optionalheaders: HttpHeaders

        Additional optional headers

      Returns Promise<Response>

    • Beta

      Submit a fixer task on an item.

      Parameters

      • ops: string | string[] = 'noop'

        The fixer operation(s) to run on the item. default: "noop"

      • priority:
            | -10
            | -9
            | -8
            | -7
            | -6
            | -5
            | -4
            | -3
            | -2
            | -1
            | 0
            | 1
            | 2
            | 3
            | 4
            | 5
            | 6
            | 7
            | 8
            | 9
            | 10 = 0

        The task priority.

      • reducedPriority: boolean = false

        Submit your derive at a lower priority. This option is helpful to get around rate-limiting. Your task will more likely be accepted, but it might not run for a long time. Note that you still may be subject to rate-limiting. This is different than priority in that it will allow you to possibly avoid rate-limiting.

      • data: { args?: { [key: string]: "1" }; [key: string]: string } = {}

        Additional parameters to submit with the task.

      • Optionalheaders: HttpHeaders

        Additional HTTP headers

      Returns Promise<Response>

    • Beta

      Get a IaFile object for the named file.

      Parameters

      • file:
            | string
            | {
                [K in string
                | number
                | symbol]: (
                    {
                        format: IaFileFormat;
                        md5: string;
                        mtime: `${number}`;
                        name: string;
                        size: `${number}`;
                        source: IaFileSource;
                        [key: string]: IaMetadataValidFieldType
                        | IaMetadataValidFieldType[];
                    } & Partial<
                        IaRawMetadata<
                            Omit<ItemFileMetaType, keyof IaFileBasicMetadata<string>>,
                        >,
                    >
                )[K]
            }

        File name or file metadata for the given file.

      Returns IaFile<ItemFileMetaType> | undefined

    • Beta

      Parameters

      • param0: IaItemGetFilesParams

        options

        • OptionalexcludePattern?: string | string[]

          Exclude files matching the given glob pattern

        • Optionalfiles?: string | string[]

          Only return files matching the given filenames

        • Optionalformats?: string | string[]

          Only return files matching the given formats

        • OptionalglobPattern?: string | string[]

          Only return files matching the given glob pattern

        • OptionalonTheFly?: boolean

          Include on-the-fly files (i.e. derivative EPUB)

      Returns Generator<IaFile<ItemFileMetaType>>

    • Beta

      Retrieves the currently authenticated user's review (if existing) for the this item. An item can only have one review for each user. If there is no review, this method returns undefined.

      Returns Promise<IaItemReview | undefined>

      The review, or undefined if there is no review

      IaApiError If unexpected HTTP response is returned

      IaApiUnauthorizedError If the user does not have permissions for this call or is not authenticated

      IaApiNotFoundError If there are no reviews by the user that is making this request

    • Beta

      Get a summary of the item's pending tasks.

      Parameters

      • Optionalparams: Omit<
            {
                args?: string;
                catalog?: 0
                | 1;
                cmd?: string;
                cursor?: string;
                history?: 0 | 1;
                identifier?: string;
                limit?: number;
                priority?: number;
                server?: string;
                submitter?: string;
                "submittime<"?: string;
                "submittime<="?: string;
                "submittime>"?: string;
                "submittime>="?: string;
                summary?: 0 | 1;
                task_id?: number;
                wait_admin?: number;
            },
            "identifier",
        >

        Params to send with your request.

      Returns Promise<IaTaskSummary>

      A summary of the item's pending tasks.

    • Beta

      Create hash of this item based on the stringified metadata object.

      Returns string

      MD5 hash as string

    • Beta

      Check if there is any pending task for the item.

      Parameters

      • Optionalparams: Omit<
            {
                args?: string;
                catalog?: 0
                | 1;
                cmd?: string;
                cursor?: string;
                history?: 0 | 1;
                identifier?: string;
                limit?: number;
                priority?: number;
                server?: string;
                submitter?: string;
                "submittime<"?: string;
                "submittime<="?: string;
                "submittime>"?: string;
                "submittime>="?: string;
                summary?: 0 | 1;
                task_id?: number;
                wait_admin?: number;
            },
            "identifier",
        >

        Params to send with your request.

      Returns Promise<boolean>

      true if tasks are pending, otherwise false.

    • Beta

      Type Parameters

      • Path extends "metadata" | "details" | "download" | "history" | "edit" | "editxml" | "manage"

      Parameters

      • path: Path
      • urlFormat: (itm: IaItem<any, any>, path: string) => string = IaItem.DEFAULT_URL_FORMAT

      Returns string

    • Beta

      Returns {
          details: string;
          download: string;
          edit: string;
          editxml: string;
          history: string;
          manage: string;
          metadata: string;
      }

    • Beta

      Modify the metadata of an existing item on Archive.org.

      Note: The Metadata Write API does not yet comply with the latest Json-Patch standard. It currently complies with JSON Patch version 02

      Parameters

      Returns Promise<Request | Response>

      A Request if debug else a Response.

      import {IaItem} from 'internetarchive-ts';
      const item = new IaItem('mapi_test_item1');
      const md = {'new_key': 'new_value', 'foo': ['bar', 'bar2']};
      item.modifyMetadata(md);
    • Beta

      Remove this item from a simplelist

      Parameters

      • parent: string
      • list: string

      Returns Promise<Response>

    • Beta

      Undark the item.

      Parameters

      • comment: string

        The curation comment explaining reason for undarking item

      • priority:
            | -10
            | -9
            | -8
            | -7
            | -6
            | -5
            | -4
            | -3
            | -2
            | -1
            | 0
            | 1
            | 2
            | 3
            | 4
            | 5
            | 6
            | 7
            | 8
            | 9
            | 10 = 0

        The task priority.

      • reducedPriority: boolean = false

        Submit your derive at a lower priority. This option is helpful to get around rate-limiting. Your task will more likely be accepted, but it might not run for a long time. Note that you still may be subject to rate-limiting. This is different than priority in that it will allow you to possibly avoid rate-limiting.

      • Optionalargs: Record<string, any>

        Additional arguments to submit with the task.

      Returns Promise<Response>

      TODO

    • Beta

      Upload files to an item. The item will be created if it does not exist.

      Parameters

      • files: string | string[] | IaFileObject | IaFileObject[]

        Single file or list of files to upload. Strings are assumed to be file paths. File objects can be supplied, which contain a name variable and a fileData variable. The fileData variable can be either a string or a Buffer

      • param1: {
            accessKey: string;
            checksum: boolean;
            debug: boolean;
            deleteLocalFiles: boolean;
            headers?: HttpHeaders;
            metadata?: IaBaseMetadataType;
            queueDerive: boolean;
            retries?: number;
            retriesSleep?: number;
            secretKey: string;
            validateIdentifier: boolean;
            verify: boolean;
        }
        • accessKey: string

          IA-S3 accessKey to use when making the given request.

        • checksum: boolean
        • debug: boolean
        • deleteLocalFiles: boolean
        • Optionalheaders?: HttpHeaders
        • Optionalmetadata?: IaBaseMetadataType
        • queueDerive: boolean
        • Optionalretries?: number
        • OptionalretriesSleep?: number
        • secretKey: string

          IA-S3 secretKey to use when making the given request.

        • validateIdentifier: boolean
        • verify: boolean

      Returns Promise<Response[] | Request[]>

      import {IaItem} from "internetarchive-ts";
      const item = new IaItem('identifier');
      const metadata = {'mediatype': 'image', 'creator': 'Jake Johnson'}
      item.upload('/path/to/image.jpg', {metadata, queueDerive: false})
      // [<Response [200]>]
      // Uploading multiple files

      const r1 = item.upload(['file1.txt', 'file2.txt']);
      const r2 = item.upload([fileobj, fileobj2]);
      const r3 = item.upload(('file1.txt', 'file2.txt'));
      // Uploading file objects

      const f = Buffer.from("some data");
      const r = item.upload({name: 'remote-name.txt', fileData: f});
      // Setting the remote filename with an object

      const r = item.upload({name: 'remote-name.txt', fileData: '/path/to/local/file.txt'})
    • Beta

      Upload a single file to an item. The item will be created if it does not exist.

      Type Parameters

      Parameters

      • body: string | Buffer | Blob
      • _body: {
            accessKey: string;
            checksum: boolean;
            debug: boolean;
            deleteLocalFiles: boolean;
            fileMetadata: F;
            headers?: HttpHeaders;
            key: string;
            metadata?: M;
            queueDerive: boolean;
            retries?: number;
            retriesSleep?: number;
            secretKey: string;
            validateIdentifier: boolean;
            verify: boolean;
        }

        File or data to be uploaded. Filepath or file-like object.

        • accessKey: string

          IA-S3 accessKey to use when making the given request.

        • checksum: boolean
        • debug: boolean
        • deleteLocalFiles: boolean
        • fileMetadata: F
        • Optionalheaders?: HttpHeaders
        • key: string
        • Optionalmetadata?: M
        • queueDerive: boolean
        • Optionalretries?: number
        • OptionalretriesSleep?: number
        • secretKey: string

          IA-S3 secretKey to use when making the given request.

        • validateIdentifier: boolean
        • verify: boolean

      Returns Promise<any>

      import { IaItem } from 'internetarchive-ts';
      const item = Item('identifier');
      item.uploadFile('/path/to/image.jpg',{key:'photos/image1.jpg'})