@internetarchive/metadata-service 1.0.6 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,8 @@
9
9
  "Bash(git *)",
10
10
  "Bash(host local.archive.org)",
11
11
  "Bash(dig +short local.archive.org)",
12
- "Bash(mkcert -CAROOT)"
12
+ "Bash(mkcert -CAROOT)",
13
+ "WebFetch(domain:archive.org)"
13
14
  ]
14
15
  }
15
16
  }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { MetadataResponse } from './src/responses/metadata-response';
2
+ export type { AlternateLocation, AlternateLocations, } from './src/responses/metadata-response';
2
3
  export { File, Review, SpeechMusicASREntry, } from '@internetarchive/iaux-item-metadata';
3
4
  export { DefaultMetadataBackend } from './src/backend/default-metadata-backend';
4
5
  export { MetadataService } from './src/metadata-service';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,EACL,IAAI,EACJ,MAAM,GAEP,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC","sourcesContent":["export { MetadataResponse } from './src/responses/metadata-response';\n\nexport {\n File,\n Review,\n SpeechMusicASREntry,\n} from '@internetarchive/iaux-item-metadata';\n\nexport { DefaultMetadataBackend } from './src/backend/default-metadata-backend';\nexport { MetadataService } from './src/metadata-service';\nexport { MetadataServiceError } from './src/metadata-service-error';\nexport { MetadataServiceInterface } from './src/metadata-service-interface';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAMrE,OAAO,EACL,IAAI,EACJ,MAAM,GAEP,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC","sourcesContent":["export { MetadataResponse } from './src/responses/metadata-response';\nexport type {\n AlternateLocation,\n AlternateLocations,\n} from './src/responses/metadata-response';\n\nexport {\n File,\n Review,\n SpeechMusicASREntry,\n} from '@internetarchive/iaux-item-metadata';\n\nexport { DefaultMetadataBackend } from './src/backend/default-metadata-backend';\nexport { MetadataService } from './src/metadata-service';\nexport { MetadataServiceError } from './src/metadata-service-error';\nexport { MetadataServiceInterface } from './src/metadata-service-interface';\n"]}
@@ -1,4 +1,21 @@
1
1
  import { File, Metadata, Review, SpeechMusicASREntry } from '@internetarchive/iaux-item-metadata';
2
+ /**
3
+ * A single alternate download location: a server and the directory on it that
4
+ * holds the item's files.
5
+ */
6
+ export type AlternateLocation = {
7
+ server: string;
8
+ dir: string;
9
+ };
10
+ /**
11
+ * Alternate download locations for an item, beyond the primary `server`/`dir`.
12
+ * `servers` lists all known mirrors; `workable` is the subset currently
13
+ * reachable for downloads.
14
+ */
15
+ export type AlternateLocations = {
16
+ servers: AlternateLocation[];
17
+ workable: AlternateLocation[];
18
+ };
2
19
  /**
3
20
  * The main top-level reponse when fetching Metadata
4
21
  *
@@ -21,5 +38,10 @@ export declare class MetadataResponse {
21
38
  readonly workable_servers: string[];
22
39
  readonly speech_vs_music_asr?: SpeechMusicASREntry[];
23
40
  readonly reviews?: Review[];
41
+ readonly alternate_locations?: AlternateLocations;
42
+ readonly clips?: Record<string, unknown>;
43
+ readonly plays?: Record<string, unknown>;
44
+ readonly simplelists?: Record<string, unknown>;
45
+ readonly solo?: boolean;
24
46
  constructor(json: Record<string, any>);
25
47
  }
@@ -27,6 +27,11 @@ export class MetadataResponse {
27
27
  this.reviews = (_b = json.reviews) === null || _b === void 0 ? void 0 : _b.map(
28
28
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
29
29
  (entry) => new Review(entry));
30
+ this.alternate_locations = json.alternate_locations;
31
+ this.clips = json.clips;
32
+ this.plays = json.plays;
33
+ this.simplelists = json.simplelists;
34
+ this.solo = json.solo;
30
35
  }
31
36
  }
32
37
  //# sourceMappingURL=metadata-response.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"metadata-response.js","sourceRoot":"","sources":["../../../src/responses/metadata-response.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,MAAM,GAEP,MAAM,qCAAqC,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IAgC3B,iEAAiE;IACjE,YAAY,IAAyB;;QACnC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACpB,iEAAiE;QACjE,IAAI,CAAC,KAAK,GAAG,MAAA,IAAI,CAAC,KAAK,0CAAE,GAAG,CAAC,CAAC,IAAyB,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5E,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACpC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC;QAChD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAC9C,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,CAAC;QACpD,IAAI,CAAC,OAAO,GAAG,MAAA,IAAI,CAAC,OAAO,0CAAE,GAAG;QAC9B,iEAAiE;QACjE,CAAC,KAA0B,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAClD,CAAC;IACJ,CAAC;CACF","sourcesContent":["import {\n File,\n Metadata,\n Review,\n SpeechMusicASREntry,\n} from '@internetarchive/iaux-item-metadata';\n\n/**\n * The main top-level reponse when fetching Metadata\n *\n * @export\n * @class MetadataResponse\n */\nexport class MetadataResponse {\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n readonly rawResponse: Readonly<Record<string, any>>;\n\n readonly created: number;\n\n readonly d1: string;\n\n readonly d2: string;\n\n readonly dir: string;\n\n readonly files: File[];\n\n readonly files_count: number;\n\n readonly item_last_updated: number;\n\n readonly item_size: number;\n\n readonly metadata: Metadata;\n\n readonly server: string;\n\n readonly uniq: number;\n\n readonly workable_servers: string[];\n\n readonly speech_vs_music_asr?: SpeechMusicASREntry[];\n\n readonly reviews?: Review[];\n\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n constructor(json: Record<string, any>) {\n this.rawResponse = json;\n this.created = json.created;\n this.d1 = json.d1;\n this.d2 = json.d2;\n this.dir = json.dir;\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n this.files = json.files?.map((file: Record<string, any>) => new File(file));\n this.files_count = json.files_count;\n this.item_last_updated = json.item_last_updated;\n this.item_size = json.item_size;\n this.metadata = new Metadata(json.metadata);\n this.server = json.server;\n this.uniq = json.uniq;\n this.workable_servers = json.workable_servers;\n this.speech_vs_music_asr = json.speech_vs_music_asr;\n this.reviews = json.reviews?.map(\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n (entry: Record<string, any>) => new Review(entry),\n );\n }\n}\n"]}
1
+ {"version":3,"file":"metadata-response.js","sourceRoot":"","sources":["../../../src/responses/metadata-response.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,MAAM,GAEP,MAAM,qCAAqC,CAAC;AAqB7C;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IA0C3B,iEAAiE;IACjE,YAAY,IAAyB;;QACnC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACpB,iEAAiE;QACjE,IAAI,CAAC,KAAK,GAAG,MAAA,IAAI,CAAC,KAAK,0CAAE,GAAG,CAAC,CAAC,IAAyB,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5E,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACpC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC;QAChD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAC9C,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,CAAC;QACpD,IAAI,CAAC,OAAO,GAAG,MAAA,IAAI,CAAC,OAAO,0CAAE,GAAG;QAC9B,iEAAiE;QACjE,CAAC,KAA0B,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAClD,CAAC;QACF,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,CAAC;QACpD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACxB,CAAC;CACF","sourcesContent":["import {\n File,\n Metadata,\n Review,\n SpeechMusicASREntry,\n} from '@internetarchive/iaux-item-metadata';\n\n/**\n * A single alternate download location: a server and the directory on it that\n * holds the item's files.\n */\nexport type AlternateLocation = {\n server: string;\n dir: string;\n};\n\n/**\n * Alternate download locations for an item, beyond the primary `server`/`dir`.\n * `servers` lists all known mirrors; `workable` is the subset currently\n * reachable for downloads.\n */\nexport type AlternateLocations = {\n servers: AlternateLocation[];\n workable: AlternateLocation[];\n};\n\n/**\n * The main top-level reponse when fetching Metadata\n *\n * @export\n * @class MetadataResponse\n */\nexport class MetadataResponse {\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n readonly rawResponse: Readonly<Record<string, any>>;\n\n readonly created: number;\n\n readonly d1: string;\n\n readonly d2: string;\n\n readonly dir: string;\n\n readonly files: File[];\n\n readonly files_count: number;\n\n readonly item_last_updated: number;\n\n readonly item_size: number;\n\n readonly metadata: Metadata;\n\n readonly server: string;\n\n readonly uniq: number;\n\n readonly workable_servers: string[];\n\n readonly speech_vs_music_asr?: SpeechMusicASREntry[];\n\n readonly reviews?: Review[];\n\n readonly alternate_locations?: AlternateLocations;\n\n readonly clips?: Record<string, unknown>;\n\n readonly plays?: Record<string, unknown>;\n\n readonly simplelists?: Record<string, unknown>;\n\n readonly solo?: boolean;\n\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n constructor(json: Record<string, any>) {\n this.rawResponse = json;\n this.created = json.created;\n this.d1 = json.d1;\n this.d2 = json.d2;\n this.dir = json.dir;\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n this.files = json.files?.map((file: Record<string, any>) => new File(file));\n this.files_count = json.files_count;\n this.item_last_updated = json.item_last_updated;\n this.item_size = json.item_size;\n this.metadata = new Metadata(json.metadata);\n this.server = json.server;\n this.uniq = json.uniq;\n this.workable_servers = json.workable_servers;\n this.speech_vs_music_asr = json.speech_vs_music_asr;\n this.reviews = json.reviews?.map(\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n (entry: Record<string, any>) => new Review(entry),\n );\n this.alternate_locations = json.alternate_locations;\n this.clips = json.clips;\n this.plays = json.plays;\n this.simplelists = json.simplelists;\n this.solo = json.solo;\n }\n}\n"]}
@@ -56,6 +56,17 @@ export class MockResponseGenerator {
56
56
  server: 'ia800201.us.archive.org',
57
57
  uniq: 162444403,
58
58
  workable_servers: ['ia800201.us.archive.org', 'ia600201.us.archive.org'],
59
+ alternate_locations: {
60
+ servers: [
61
+ { server: 'ia800201.us.archive.org', dir: '/27/items/foo' },
62
+ { server: 'ia600201.us.archive.org', dir: '/27/items/foo' },
63
+ ],
64
+ workable: [{ server: 'ia800201.us.archive.org', dir: '/27/items/foo' }],
65
+ },
66
+ clips: { '60|120': [1, 2, 3] },
67
+ plays: {},
68
+ simplelists: {},
69
+ solo: false,
59
70
  };
60
71
  }
61
72
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mock-response-generator.js","sourceRoot":"","sources":["../../test/mock-response-generator.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,MAAM,OAAO,qBAAqB;IAChC,4BAA4B,CAAC,UAAkB;QAC7C,OAAO;YACL,OAAO,EAAE,UAAU;YACnB,EAAE,EAAE,yBAAyB;YAC7B,EAAE,EA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AAyB,CAAC;SACzE,CAAC;IACJ,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nexport class MockResponseGenerator {\n generateMockMetadataResponse(identifier: string): any {\n return {\n created: 1586477049,\n d1: 'ia600201.us.archive.org',\n d2: 'ia800201.us.archive.org',\n dir: '/27/items/rss-383924main_TWAN_09_04_09',\n files: [\n {\n name: 'foo.jpg',\n source: 'derivative',\n format: 'Thumbnail',\n original: 'foo.mp4',\n md5: '48067b43a547d3e90cb433a04ba84d5d',\n mtime: '1256675427',\n size: '1135',\n crc32: '40870038',\n sha1: '6445c2a6f51c8314c1872ec1f7daf33c5cfabd06',\n },\n {\n name: 'bar.jpg',\n source: 'derivative',\n format: 'Thumbnail',\n original: 'bar.mp4',\n md5: '5bf69912d7b796fe309cde32e61230bc',\n mtime: '1256675429',\n size: '6329',\n crc32: 'ba5f361a',\n sha1: 'cddab0e2daab29978e5efdeff735240a44aa7c80',\n },\n ],\n files_count: 2,\n item_last_updated: 1463797130,\n item_size: 99872691,\n metadata: {\n feed_id:\n '/0/rss_feeds/NASACast_Video/nasacast_video:sts128_landing/NASAcast_vodcast.rss',\n mediatype: 'movies',\n title: \"NASA TV's This Week @NASA, September 4\",\n description: \"NASA TV's This Week @NASA, September 4\",\n creator: 'NASA',\n source: 'http://www.nasa.gov/multimedia/podcasting/twan_09_04_09.html',\n date: '9/4/2009',\n year: '2009',\n rights: 'Public Domain',\n language: 'en-us',\n updater: 'BonnieReal',\n updatedate: '2009-10-27 20:23:01',\n identifier,\n uploader: 'bonnie@archive.org',\n addeddate: '2009-10-27 20:25:55',\n publicdate: '2009-10-27 20:41:27',\n collection: ['nasa', 'nasacastvideo'],\n backup_location: 'ia903604_7',\n },\n server: 'ia800201.us.archive.org',\n uniq: 162444403,\n workable_servers: ['ia800201.us.archive.org', 'ia600201.us.archive.org'],\n };\n }\n}\n"]}
1
+ {"version":3,"file":"mock-response-generator.js","sourceRoot":"","sources":["../../test/mock-response-generator.ts"],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EAAE,CAAC,MAAM,EAAE,eAAe,CAAC;gBACrC,eAAe,EAAE,YAAY;aAC9B;YACD,MAAM,EAAE,yBAAyB;YACjC,IAAI,EAAE,SAAS;YACf,gBAAgB,EAAE,CAAC,yBAAyB,EAAE,yBAAyB,CAAC;YACxE,mBAAmB,EAAE;gBACnB,OAAO,EAAE;oBACP,EAAE,MAAM,EAAE,yBAAyB,EAAE,GAAG,EAAE,eAAe,EAAE;oBAC3D,EAAE,MAAM,EAAE,yBAAyB,EAAE,GAAG,EAAE,eAAe,EAAE;iBAC5D;gBACD,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,yBAAyB,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC;aACxE;YACD,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE;YAC9B,KAAK,EAAE,EAAE;YACT,WAAW,EAAE,EAAE;YACf,IAAI,EAAE,KAAK;SACZ,CAAC;IACJ,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nexport class MockResponseGenerator {\n generateMockMetadataResponse(identifier: string): any {\n return {\n created: 1586477049,\n d1: 'ia600201.us.archive.org',\n d2: 'ia800201.us.archive.org',\n dir: '/27/items/rss-383924main_TWAN_09_04_09',\n files: [\n {\n name: 'foo.jpg',\n source: 'derivative',\n format: 'Thumbnail',\n original: 'foo.mp4',\n md5: '48067b43a547d3e90cb433a04ba84d5d',\n mtime: '1256675427',\n size: '1135',\n crc32: '40870038',\n sha1: '6445c2a6f51c8314c1872ec1f7daf33c5cfabd06',\n },\n {\n name: 'bar.jpg',\n source: 'derivative',\n format: 'Thumbnail',\n original: 'bar.mp4',\n md5: '5bf69912d7b796fe309cde32e61230bc',\n mtime: '1256675429',\n size: '6329',\n crc32: 'ba5f361a',\n sha1: 'cddab0e2daab29978e5efdeff735240a44aa7c80',\n },\n ],\n files_count: 2,\n item_last_updated: 1463797130,\n item_size: 99872691,\n metadata: {\n feed_id:\n '/0/rss_feeds/NASACast_Video/nasacast_video:sts128_landing/NASAcast_vodcast.rss',\n mediatype: 'movies',\n title: \"NASA TV's This Week @NASA, September 4\",\n description: \"NASA TV's This Week @NASA, September 4\",\n creator: 'NASA',\n source: 'http://www.nasa.gov/multimedia/podcasting/twan_09_04_09.html',\n date: '9/4/2009',\n year: '2009',\n rights: 'Public Domain',\n language: 'en-us',\n updater: 'BonnieReal',\n updatedate: '2009-10-27 20:23:01',\n identifier,\n uploader: 'bonnie@archive.org',\n addeddate: '2009-10-27 20:25:55',\n publicdate: '2009-10-27 20:41:27',\n collection: ['nasa', 'nasacastvideo'],\n backup_location: 'ia903604_7',\n },\n server: 'ia800201.us.archive.org',\n uniq: 162444403,\n workable_servers: ['ia800201.us.archive.org', 'ia600201.us.archive.org'],\n alternate_locations: {\n servers: [\n { server: 'ia800201.us.archive.org', dir: '/27/items/foo' },\n { server: 'ia600201.us.archive.org', dir: '/27/items/foo' },\n ],\n workable: [{ server: 'ia800201.us.archive.org', dir: '/27/items/foo' }],\n },\n clips: { '60|120': [1, 2, 3] },\n plays: {},\n simplelists: {},\n solo: false,\n };\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,48 @@
1
+ import { expect } from '@open-wc/testing';
2
+ import { MetadataResponse } from '../../src/responses/metadata-response';
3
+ describe('MetadataResponse', () => {
4
+ it('parses alternate_locations into servers and workable lists', async () => {
5
+ var _a, _b, _c, _d;
6
+ const response = new MetadataResponse({
7
+ metadata: { identifier: 'foo' },
8
+ alternate_locations: {
9
+ servers: [
10
+ { server: 'ia801234.us.archive.org', dir: '/12/items/foo' },
11
+ { server: 'ia601234.us.archive.org', dir: '/12/items/foo' },
12
+ ],
13
+ workable: [{ server: 'ia801234.us.archive.org', dir: '/12/items/foo' }],
14
+ },
15
+ });
16
+ expect((_a = response.alternate_locations) === null || _a === void 0 ? void 0 : _a.servers).to.have.lengthOf(2);
17
+ expect((_b = response.alternate_locations) === null || _b === void 0 ? void 0 : _b.servers[0].server).to.equal('ia801234.us.archive.org');
18
+ expect((_c = response.alternate_locations) === null || _c === void 0 ? void 0 : _c.servers[0].dir).to.equal('/12/items/foo');
19
+ expect((_d = response.alternate_locations) === null || _d === void 0 ? void 0 : _d.workable).to.have.lengthOf(1);
20
+ });
21
+ it('exposes the clips, plays, and simplelists maps', async () => {
22
+ const response = new MetadataResponse({
23
+ metadata: { identifier: 'foo' },
24
+ clips: { '60|120': [1, 2, 3] },
25
+ plays: { total: 5 },
26
+ simplelists: {},
27
+ });
28
+ expect(response.clips).to.deep.equal({ '60|120': [1, 2, 3] });
29
+ expect(response.plays).to.deep.equal({ total: 5 });
30
+ expect(response.simplelists).to.deep.equal({});
31
+ });
32
+ it('exposes the solo flag', async () => {
33
+ const response = new MetadataResponse({
34
+ metadata: { identifier: 'foo' },
35
+ solo: true,
36
+ });
37
+ expect(response.solo).to.be.true;
38
+ });
39
+ it('leaves the top-level fields undefined when absent', async () => {
40
+ const response = new MetadataResponse({ metadata: { identifier: 'foo' } });
41
+ expect(response.alternate_locations).to.be.undefined;
42
+ expect(response.clips).to.be.undefined;
43
+ expect(response.plays).to.be.undefined;
44
+ expect(response.simplelists).to.be.undefined;
45
+ expect(response.solo).to.be.undefined;
46
+ });
47
+ });
48
+ //# sourceMappingURL=metadata-response.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata-response.test.js","sourceRoot":"","sources":["../../../test/responses/metadata-response.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAEzE,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,4DAA4D,EAAE,KAAK,IAAI,EAAE;;QAC1E,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC;YACpC,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;YAC/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AS,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\n\nimport { MetadataResponse } from '../../src/responses/metadata-response';\n\ndescribe('MetadataResponse', () => {\n it('parses alternate_locations into servers and workable lists', async () => {\n const response = new MetadataResponse({\n metadata: { identifier: 'foo' },\n alternate_locations: {\n servers: [\n { server: 'ia801234.us.archive.org', dir: '/12/items/foo' },\n { server: 'ia601234.us.archive.org', dir: '/12/items/foo' },\n ],\n workable: [{ server: 'ia801234.us.archive.org', dir: '/12/items/foo' }],\n },\n });\n expect(response.alternate_locations?.servers).to.have.lengthOf(2);\n expect(response.alternate_locations?.servers[0].server).to.equal(\n 'ia801234.us.archive.org',\n );\n expect(response.alternate_locations?.servers[0].dir).to.equal(\n '/12/items/foo',\n );\n expect(response.alternate_locations?.workable).to.have.lengthOf(1);\n });\n\n it('exposes the clips, plays, and simplelists maps', async () => {\n const response = new MetadataResponse({\n metadata: { identifier: 'foo' },\n clips: { '60|120': [1, 2, 3] },\n plays: { total: 5 },\n simplelists: {},\n });\n expect(response.clips).to.deep.equal({ '60|120': [1, 2, 3] });\n expect(response.plays).to.deep.equal({ total: 5 });\n expect(response.simplelists).to.deep.equal({});\n });\n\n it('exposes the solo flag', async () => {\n const response = new MetadataResponse({\n metadata: { identifier: 'foo' },\n solo: true,\n });\n expect(response.solo).to.be.true;\n });\n\n it('leaves the top-level fields undefined when absent', async () => {\n const response = new MetadataResponse({ metadata: { identifier: 'foo' } });\n expect(response.alternate_locations).to.be.undefined;\n expect(response.clips).to.be.undefined;\n expect(response.plays).to.be.undefined;\n expect(response.simplelists).to.be.undefined;\n expect(response.solo).to.be.undefined;\n });\n});\n"]}
package/index.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  export { MetadataResponse } from './src/responses/metadata-response';
2
+ export type {
3
+ AlternateLocation,
4
+ AlternateLocations,
5
+ } from './src/responses/metadata-response';
2
6
 
3
7
  export {
4
8
  File,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/metadata-service",
3
- "version": "1.0.6",
3
+ "version": "1.1.0",
4
4
  "description": "A service for fetching metadata about items in the Internet Archive",
5
5
  "license": "AGPL-3.0-only",
6
6
  "main": "dist/index.js",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@internetarchive/field-parsers": "^0.1.4",
30
- "@internetarchive/iaux-item-metadata": "^1.1.0",
30
+ "@internetarchive/iaux-item-metadata": "^1.3.0",
31
31
  "@internetarchive/result-type": "^0.0.1",
32
32
  "typescript-memoize": "^1.1.1"
33
33
  },
@@ -5,6 +5,25 @@ import {
5
5
  SpeechMusicASREntry,
6
6
  } from '@internetarchive/iaux-item-metadata';
7
7
 
8
+ /**
9
+ * A single alternate download location: a server and the directory on it that
10
+ * holds the item's files.
11
+ */
12
+ export type AlternateLocation = {
13
+ server: string;
14
+ dir: string;
15
+ };
16
+
17
+ /**
18
+ * Alternate download locations for an item, beyond the primary `server`/`dir`.
19
+ * `servers` lists all known mirrors; `workable` is the subset currently
20
+ * reachable for downloads.
21
+ */
22
+ export type AlternateLocations = {
23
+ servers: AlternateLocation[];
24
+ workable: AlternateLocation[];
25
+ };
26
+
8
27
  /**
9
28
  * The main top-level reponse when fetching Metadata
10
29
  *
@@ -43,6 +62,16 @@ export class MetadataResponse {
43
62
 
44
63
  readonly reviews?: Review[];
45
64
 
65
+ readonly alternate_locations?: AlternateLocations;
66
+
67
+ readonly clips?: Record<string, unknown>;
68
+
69
+ readonly plays?: Record<string, unknown>;
70
+
71
+ readonly simplelists?: Record<string, unknown>;
72
+
73
+ readonly solo?: boolean;
74
+
46
75
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
47
76
  constructor(json: Record<string, any>) {
48
77
  this.rawResponse = json;
@@ -64,5 +93,10 @@ export class MetadataResponse {
64
93
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
65
94
  (entry: Record<string, any>) => new Review(entry),
66
95
  );
96
+ this.alternate_locations = json.alternate_locations;
97
+ this.clips = json.clips;
98
+ this.plays = json.plays;
99
+ this.simplelists = json.simplelists;
100
+ this.solo = json.solo;
67
101
  }
68
102
  }
@@ -57,6 +57,17 @@ export class MockResponseGenerator {
57
57
  server: 'ia800201.us.archive.org',
58
58
  uniq: 162444403,
59
59
  workable_servers: ['ia800201.us.archive.org', 'ia600201.us.archive.org'],
60
+ alternate_locations: {
61
+ servers: [
62
+ { server: 'ia800201.us.archive.org', dir: '/27/items/foo' },
63
+ { server: 'ia600201.us.archive.org', dir: '/27/items/foo' },
64
+ ],
65
+ workable: [{ server: 'ia800201.us.archive.org', dir: '/27/items/foo' }],
66
+ },
67
+ clips: { '60|120': [1, 2, 3] },
68
+ plays: {},
69
+ simplelists: {},
70
+ solo: false,
60
71
  };
61
72
  }
62
73
  }
@@ -0,0 +1,55 @@
1
+ import { expect } from '@open-wc/testing';
2
+
3
+ import { MetadataResponse } from '../../src/responses/metadata-response';
4
+
5
+ describe('MetadataResponse', () => {
6
+ it('parses alternate_locations into servers and workable lists', async () => {
7
+ const response = new MetadataResponse({
8
+ metadata: { identifier: 'foo' },
9
+ alternate_locations: {
10
+ servers: [
11
+ { server: 'ia801234.us.archive.org', dir: '/12/items/foo' },
12
+ { server: 'ia601234.us.archive.org', dir: '/12/items/foo' },
13
+ ],
14
+ workable: [{ server: 'ia801234.us.archive.org', dir: '/12/items/foo' }],
15
+ },
16
+ });
17
+ expect(response.alternate_locations?.servers).to.have.lengthOf(2);
18
+ expect(response.alternate_locations?.servers[0].server).to.equal(
19
+ 'ia801234.us.archive.org',
20
+ );
21
+ expect(response.alternate_locations?.servers[0].dir).to.equal(
22
+ '/12/items/foo',
23
+ );
24
+ expect(response.alternate_locations?.workable).to.have.lengthOf(1);
25
+ });
26
+
27
+ it('exposes the clips, plays, and simplelists maps', async () => {
28
+ const response = new MetadataResponse({
29
+ metadata: { identifier: 'foo' },
30
+ clips: { '60|120': [1, 2, 3] },
31
+ plays: { total: 5 },
32
+ simplelists: {},
33
+ });
34
+ expect(response.clips).to.deep.equal({ '60|120': [1, 2, 3] });
35
+ expect(response.plays).to.deep.equal({ total: 5 });
36
+ expect(response.simplelists).to.deep.equal({});
37
+ });
38
+
39
+ it('exposes the solo flag', async () => {
40
+ const response = new MetadataResponse({
41
+ metadata: { identifier: 'foo' },
42
+ solo: true,
43
+ });
44
+ expect(response.solo).to.be.true;
45
+ });
46
+
47
+ it('leaves the top-level fields undefined when absent', async () => {
48
+ const response = new MetadataResponse({ metadata: { identifier: 'foo' } });
49
+ expect(response.alternate_locations).to.be.undefined;
50
+ expect(response.clips).to.be.undefined;
51
+ expect(response.plays).to.be.undefined;
52
+ expect(response.simplelists).to.be.undefined;
53
+ expect(response.solo).to.be.undefined;
54
+ });
55
+ });