@internetarchive/metadata-service 1.1.0 → 1.2.0-beta.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.
Files changed (56) hide show
  1. package/README.md +18 -0
  2. package/dist/index.d.ts +3 -1
  3. package/dist/index.js +1 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/src/backend/default-metadata-backend.d.ts +8 -0
  6. package/dist/src/backend/default-metadata-backend.js +32 -0
  7. package/dist/src/backend/default-metadata-backend.js.map +1 -1
  8. package/dist/src/backend/metadata-backend-interface.d.ts +14 -0
  9. package/dist/src/backend/metadata-backend-interface.js.map +1 -1
  10. package/dist/src/metadata-patch.d.ts +21 -0
  11. package/dist/src/metadata-patch.js +37 -0
  12. package/dist/src/metadata-patch.js.map +1 -0
  13. package/dist/src/metadata-service-error.d.ts +3 -1
  14. package/dist/src/metadata-service-error.js +2 -0
  15. package/dist/src/metadata-service-error.js.map +1 -1
  16. package/dist/src/metadata-service-interface.d.ts +42 -0
  17. package/dist/src/metadata-service-interface.js.map +1 -1
  18. package/dist/src/metadata-service.d.ts +6 -1
  19. package/dist/src/metadata-service.js +28 -0
  20. package/dist/src/metadata-service.js.map +1 -1
  21. package/dist/test/default-metadata-backend.test.js +52 -0
  22. package/dist/test/default-metadata-backend.test.js.map +1 -1
  23. package/dist/test/metadata-patch.test.js +41 -0
  24. package/dist/test/metadata-patch.test.js.map +1 -0
  25. package/dist/test/metadata-service-write.test.js +96 -0
  26. package/dist/test/metadata-service-write.test.js.map +1 -0
  27. package/index.ts +9 -1
  28. package/package.json +1 -1
  29. package/src/backend/default-metadata-backend.ts +47 -0
  30. package/src/backend/metadata-backend-interface.ts +19 -0
  31. package/src/metadata-patch.ts +53 -0
  32. package/src/metadata-service-error.ts +2 -0
  33. package/src/metadata-service-interface.ts +56 -0
  34. package/src/metadata-service.ts +57 -1
  35. package/test/default-metadata-backend.test.ts +66 -0
  36. package/test/metadata-patch.test.ts +53 -0
  37. package/test/metadata-service-write.test.ts +138 -0
  38. package/.claude/settings.local.json +0 -16
  39. package/dist/src/models/file.d.ts +0 -29
  40. package/dist/src/models/file.js +0 -104
  41. package/dist/src/models/file.js.map +0 -1
  42. package/dist/src/models/review.d.ts +0 -11
  43. package/dist/src/models/review.js +0 -46
  44. package/dist/src/models/review.js.map +0 -1
  45. package/dist/src/models/speech-music-asr-entry.d.ts +0 -10
  46. package/dist/src/models/speech-music-asr-entry.js +0 -2
  47. package/dist/src/models/speech-music-asr-entry.js.map +0 -1
  48. package/dist/src/models/task.d.ts +0 -11
  49. package/dist/src/models/task.js +0 -2
  50. package/dist/src/models/task.js.map +0 -1
  51. package/dist/test/models/file.test.js +0 -57
  52. package/dist/test/models/file.test.js.map +0 -1
  53. package/dist/test/models/review.test.js +0 -53
  54. package/dist/test/models/review.test.js.map +0 -1
  55. /package/dist/test/{models/file.test.d.ts → metadata-patch.test.d.ts} +0 -0
  56. /package/dist/test/{models/review.test.d.ts → metadata-service-write.test.d.ts} +0 -0
@@ -0,0 +1,138 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { expect } from '@open-wc/testing';
3
+
4
+ import { Result } from '@internetarchive/result-type';
5
+ import { MetadataBackendInterface } from '../src/backend/metadata-backend-interface';
6
+ import { MetadataService } from '../src/metadata-service';
7
+ import {
8
+ MetadataServiceError,
9
+ MetadataServiceErrorType,
10
+ } from '../src/metadata-service-error';
11
+ import type { MetadataPatchOperation } from '../src/metadata-patch';
12
+
13
+ class WritableMockBackend implements MetadataBackendInterface {
14
+ current: Record<string, unknown> = {};
15
+
16
+ readError?: MetadataServiceError;
17
+
18
+ writeError?: MetadataServiceError;
19
+
20
+ writes: { identifier: string; target: string; patch: any[] }[] = [];
21
+
22
+ async fetchMetadata(
23
+ _identifier: string,
24
+ keypath?: string,
25
+ ): Promise<Result<any, MetadataServiceError>> {
26
+ if (this.readError) return { error: this.readError };
27
+ if (keypath !== 'metadata') return { success: {} };
28
+ return { success: { result: this.current } };
29
+ }
30
+
31
+ async writeMetadata(
32
+ identifier: string,
33
+ target: string,
34
+ patch: MetadataPatchOperation[],
35
+ ): Promise<Result<any, MetadataServiceError>> {
36
+ if (this.writeError) return { error: this.writeError };
37
+ this.writes.push({ identifier, target, patch });
38
+ return { success: { success: true, task_id: 42 } };
39
+ }
40
+ }
41
+
42
+ describe('MetadataService writes', () => {
43
+ describe('patchMetadata', () => {
44
+ it('sends the patch to the metadata target by default', async () => {
45
+ const backend = new WritableMockBackend();
46
+ const service = new MetadataService(backend);
47
+ const patch = [{ op: 'remove' as const, path: '/notes' }];
48
+
49
+ const result = await service.patchMetadata('foo', patch);
50
+
51
+ expect(result.success).to.deep.equal({ changed: true, taskId: 42 });
52
+ expect(backend.writes).to.deep.equal([
53
+ { identifier: 'foo', target: 'metadata', patch },
54
+ ]);
55
+ });
56
+
57
+ it('passes a backend error through', async () => {
58
+ const backend = new WritableMockBackend();
59
+ backend.writeError = new MetadataServiceError(
60
+ MetadataServiceErrorType.writeError,
61
+ 'nope',
62
+ );
63
+ const service = new MetadataService(backend);
64
+
65
+ const result = await service.patchMetadata('foo', []);
66
+
67
+ expect(result.error?.message).to.equal('nope');
68
+ });
69
+
70
+ it('reports writeNotSupported for a backend without writes', async () => {
71
+ const readOnlyBackend: MetadataBackendInterface = {
72
+ fetchMetadata: async () => ({ success: {} }),
73
+ };
74
+ const service = new MetadataService(readOnlyBackend);
75
+
76
+ const result = await service.patchMetadata('foo', []);
77
+
78
+ expect(result.error?.type).to.equal(
79
+ MetadataServiceErrorType.writeNotSupported,
80
+ );
81
+ });
82
+ });
83
+
84
+ describe('updateMetadataField', () => {
85
+ it('replaces a field MDAPI has', async () => {
86
+ const backend = new WritableMockBackend();
87
+ backend.current = { title: 'Old' };
88
+ const service = new MetadataService(backend);
89
+
90
+ const result = await service.updateMetadataField('foo', 'title', 'New');
91
+
92
+ expect(result.success).to.deep.equal({ changed: true, taskId: 42 });
93
+ expect(backend.writes[0].patch).to.deep.equal([
94
+ { op: 'replace', path: '/title', value: 'New' },
95
+ ]);
96
+ });
97
+
98
+ it('adds a field MDAPI does not have', async () => {
99
+ const backend = new WritableMockBackend();
100
+ backend.current = { title: 'T' };
101
+ const service = new MetadataService(backend);
102
+
103
+ await service.updateMetadataField('foo', 'volume', ['2']);
104
+
105
+ expect(backend.writes[0].patch).to.deep.equal([
106
+ { op: 'add', path: '/volume', value: '2' },
107
+ ]);
108
+ });
109
+
110
+ it('skips the write when MDAPI already has the value', async () => {
111
+ const backend = new WritableMockBackend();
112
+ backend.current = { subject: ['a', 'b'] };
113
+ const service = new MetadataService(backend);
114
+
115
+ const result = await service.updateMetadataField('foo', 'subject', [
116
+ 'a',
117
+ 'b',
118
+ ]);
119
+
120
+ expect(result.success).to.deep.equal({ changed: false });
121
+ expect(backend.writes).to.be.empty;
122
+ });
123
+
124
+ it('returns the read error without writing', async () => {
125
+ const backend = new WritableMockBackend();
126
+ backend.readError = new MetadataServiceError(
127
+ MetadataServiceErrorType.searchEngineError,
128
+ "Couldn't locate item 'foo'",
129
+ );
130
+ const service = new MetadataService(backend);
131
+
132
+ const result = await service.updateMetadataField('foo', 'title', 'New');
133
+
134
+ expect(result.error?.message).to.equal("Couldn't locate item 'foo'");
135
+ expect(backend.writes).to.be.empty;
136
+ });
137
+ });
138
+ });
@@ -1,16 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "WebFetch(domain:github.com)",
5
- "Bash(gh api *)",
6
- "Bash(git -C /Users/jason/Projects/IA/iaux/iaux-metadata-service status)",
7
- "Bash(git -C /Users/jason/Projects/IA/iaux/iaux-metadata-service log --oneline -10)",
8
- "Bash(git -C /Users/jason/Projects/IA/iaux/iaux-metadata-service remote -v)",
9
- "Bash(git *)",
10
- "Bash(host local.archive.org)",
11
- "Bash(dig +short local.archive.org)",
12
- "Bash(mkcert -CAROOT)",
13
- "WebFetch(domain:archive.org)"
14
- ]
15
- }
16
- }
@@ -1,29 +0,0 @@
1
- import { Byte, Duration } from '@internetarchive/field-parsers';
2
- /**
3
- * This represents an Internet Archive File
4
- *
5
- * @export
6
- * @class File
7
- */
8
- export declare class File {
9
- readonly rawValue: Readonly<Record<string, any>>;
10
- get name(): string;
11
- get source(): string;
12
- get btih(): string;
13
- get md5(): string;
14
- get format(): string;
15
- get mtime(): Date | undefined;
16
- get crc32(): string;
17
- get sha1(): string;
18
- get original(): string | undefined;
19
- get size(): Byte | undefined;
20
- get title(): string | undefined;
21
- get length(): Duration | undefined;
22
- get height(): number | undefined;
23
- get width(): number | undefined;
24
- get track(): number | undefined;
25
- get external_identifier(): string | string[] | undefined;
26
- get creator(): string | undefined;
27
- get album(): string | undefined;
28
- constructor(json?: Record<string, any>);
29
- }
@@ -1,104 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { Memoize } from 'typescript-memoize';
3
- import { ByteParser, DurationParser, NumberParser, } from '@internetarchive/field-parsers';
4
- /**
5
- * This represents an Internet Archive File
6
- *
7
- * @export
8
- * @class File
9
- */
10
- export class File {
11
- get name() {
12
- return this.rawValue.name;
13
- }
14
- get source() {
15
- return this.rawValue.source;
16
- }
17
- get btih() {
18
- return this.rawValue.btih;
19
- }
20
- get md5() {
21
- return this.rawValue.md5;
22
- }
23
- get format() {
24
- return this.rawValue.format;
25
- }
26
- get mtime() {
27
- if (this.rawValue.mtime == null) {
28
- return undefined;
29
- }
30
- const numberValue = NumberParser.shared.parseValue(this.rawValue.mtime);
31
- if (numberValue) {
32
- return new Date(numberValue * 1000);
33
- }
34
- }
35
- get crc32() {
36
- return this.rawValue.crc32;
37
- }
38
- get sha1() {
39
- return this.rawValue.sha1;
40
- }
41
- get original() {
42
- return this.rawValue.original;
43
- }
44
- get size() {
45
- return this.rawValue.size != null
46
- ? ByteParser.shared.parseValue(this.rawValue.size)
47
- : undefined;
48
- }
49
- get title() {
50
- return this.rawValue.title;
51
- }
52
- get length() {
53
- return this.rawValue.length != null
54
- ? DurationParser.shared.parseValue(this.rawValue.length)
55
- : undefined;
56
- }
57
- get height() {
58
- return this.rawValue.height != null
59
- ? NumberParser.shared.parseValue(this.rawValue.height)
60
- : undefined;
61
- }
62
- get width() {
63
- return this.rawValue.width != null
64
- ? NumberParser.shared.parseValue(this.rawValue.width)
65
- : undefined;
66
- }
67
- get track() {
68
- return this.rawValue.track != null
69
- ? NumberParser.shared.parseValue(this.rawValue.track)
70
- : undefined;
71
- }
72
- get external_identifier() {
73
- return this.rawValue.external_identifier;
74
- }
75
- get creator() {
76
- return this.rawValue.creator;
77
- }
78
- get album() {
79
- return this.rawValue.album;
80
- }
81
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
82
- constructor(json = {}) {
83
- this.rawValue = json;
84
- }
85
- }
86
- __decorate([
87
- Memoize()
88
- ], File.prototype, "mtime", null);
89
- __decorate([
90
- Memoize()
91
- ], File.prototype, "size", null);
92
- __decorate([
93
- Memoize()
94
- ], File.prototype, "length", null);
95
- __decorate([
96
- Memoize()
97
- ], File.prototype, "height", null);
98
- __decorate([
99
- Memoize()
100
- ], File.prototype, "width", null);
101
- __decorate([
102
- Memoize()
103
- ], File.prototype, "track", null);
104
- //# sourceMappingURL=file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file.js","sourceRoot":"","sources":["../../../src/models/file.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAEL,UAAU,EAEV,cAAc,EACd,YAAY,GACb,MAAM,gCAAgC,CAAC;AAExC;;;;;GAKG;AACH,MAAM,OAAO,IAAI;IAIf,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC5B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC5B,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,QA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AC,MAAM,IAAI,IAAI;YACjC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;YACtD,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;IAEU,IAAI,KAAK;QAClB,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,IAAI;YAChC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YACrD,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;IAEU,IAAI,KAAK;QAClB,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,IAAI;YAChC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YACrD,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;IAED,IAAI,mBAAmB;QACrB,OAAO,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC;IAC3C,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;IAC/B,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;IAC7B,CAAC;IAED,iEAAiE;IACjE,YAAY,OAA4B,EAAE;QACxC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;CACF;AAxEY;IAAV,OAAO,EAAE;iCAQT;AAcU;IAAV,OAAO,EAAE;gCAIT;AAMU;IAAV,OAAO,EAAE;kCAIT;AAEU;IAAV,OAAO,EAAE;kCAIT;AAEU;IAAV,OAAO,EAAE;iCAIT;AAEU;IAAV,OAAO,EAAE;iCAIT","sourcesContent":["import { Memoize } from 'typescript-memoize';\nimport {\n Byte,\n ByteParser,\n Duration,\n DurationParser,\n NumberParser,\n} from '@internetarchive/field-parsers';\n\n/**\n * This represents an Internet Archive File\n *\n * @export\n * @class File\n */\nexport class File {\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n readonly rawValue: Readonly<Record<string, any>>;\n\n get name(): string {\n return this.rawValue.name;\n }\n\n get source(): string {\n return this.rawValue.source;\n }\n\n get btih(): string {\n return this.rawValue.btih;\n }\n\n get md5(): string {\n return this.rawValue.md5;\n }\n\n get format(): string {\n return this.rawValue.format;\n }\n\n @Memoize() get mtime(): Date | undefined {\n if (this.rawValue.mtime == null) {\n return undefined;\n }\n const numberValue = NumberParser.shared.parseValue(this.rawValue.mtime);\n if (numberValue) {\n return new Date(numberValue * 1000);\n }\n }\n\n get crc32(): string {\n return this.rawValue.crc32;\n }\n\n get sha1(): string {\n return this.rawValue.sha1;\n }\n\n get original(): string | undefined {\n return this.rawValue.original;\n }\n\n @Memoize() get size(): Byte | undefined {\n return this.rawValue.size != null\n ? ByteParser.shared.parseValue(this.rawValue.size)\n : undefined;\n }\n\n get title(): string | undefined {\n return this.rawValue.title;\n }\n\n @Memoize() get length(): Duration | undefined {\n return this.rawValue.length != null\n ? DurationParser.shared.parseValue(this.rawValue.length)\n : undefined;\n }\n\n @Memoize() get height(): number | undefined {\n return this.rawValue.height != null\n ? NumberParser.shared.parseValue(this.rawValue.height)\n : undefined;\n }\n\n @Memoize() get width(): number | undefined {\n return this.rawValue.width != null\n ? NumberParser.shared.parseValue(this.rawValue.width)\n : undefined;\n }\n\n @Memoize() get track(): number | undefined {\n return this.rawValue.track != null\n ? NumberParser.shared.parseValue(this.rawValue.track)\n : undefined;\n }\n\n get external_identifier(): string | string[] | undefined {\n return this.rawValue.external_identifier;\n }\n\n get creator(): string | undefined {\n return this.rawValue.creator;\n }\n\n get album(): string | undefined {\n return this.rawValue.album;\n }\n\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n constructor(json: Record<string, any> = {}) {\n this.rawValue = json;\n }\n}\n"]}
@@ -1,11 +0,0 @@
1
- export declare class Review {
2
- readonly rawValue: Readonly<Record<string, any>>;
3
- get reviewbody(): string | undefined;
4
- get reviewtitle(): string | undefined;
5
- get reviewer(): string | undefined;
6
- get reviewer_itemname(): string | undefined;
7
- get reviewdate(): Date | undefined;
8
- get createdate(): Date | undefined;
9
- get stars(): number | undefined;
10
- constructor(json?: Record<string, any>);
11
- }
@@ -1,46 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { Memoize } from 'typescript-memoize';
3
- import { DateParser, NumberParser } from '@internetarchive/field-parsers';
4
- export class Review {
5
- get reviewbody() {
6
- return this.rawValue.reviewbody;
7
- }
8
- get reviewtitle() {
9
- return this.rawValue.reviewtitle;
10
- }
11
- get reviewer() {
12
- return this.rawValue.reviewer;
13
- }
14
- get reviewer_itemname() {
15
- return this.rawValue.reviewer_itemname;
16
- }
17
- get reviewdate() {
18
- return this.rawValue.reviewdate != null
19
- ? DateParser.shared.parseValue(this.rawValue.reviewdate)
20
- : undefined;
21
- }
22
- get createdate() {
23
- return this.rawValue.createdate != null
24
- ? DateParser.shared.parseValue(this.rawValue.createdate)
25
- : undefined;
26
- }
27
- get stars() {
28
- return this.rawValue.stars != null
29
- ? NumberParser.shared.parseValue(this.rawValue.stars)
30
- : undefined;
31
- }
32
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
33
- constructor(json = {}) {
34
- this.rawValue = json;
35
- }
36
- }
37
- __decorate([
38
- Memoize()
39
- ], Review.prototype, "reviewdate", null);
40
- __decorate([
41
- Memoize()
42
- ], Review.prototype, "createdate", null);
43
- __decorate([
44
- Memoize()
45
- ], Review.prototype, "stars", null);
46
- //# sourceMappingURL=review.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"review.js","sourceRoot":"","sources":["../../../src/models/review.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE1E,MAAM,OAAO,MAAM;IAIjB,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;IAClC,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;IACnC,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAChC,CAAC;IAED,IAAI,iBAAiB;QACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC;IACzC,CAAC;IAEU,IAAI,UAAU;QACvB,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,IAAI,IAAI;YACrC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;YACxD,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;IAEU,IAAI,UAAU;QACvB,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,IAAI,IAAI;YACrC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;YACxD,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;IAEU,IAAI,KAAK;QAClB,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,IAAI;YAChC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YACrD,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;IAED,iEAAiE;IACjE,YAAY,OAA4B,EAAE;QACxC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;CACF;AAtBY;IAAV,OAAO,EAAE;wCAIT;AAEU;IAAV,OAAO,EAAE;wCAIT;AAEU;IAAV,OAAO,EAAE;mCAIT","sourcesContent":["import { Memoize } from 'typescript-memoize';\nimport { DateParser, NumberParser } from '@internetarchive/field-parsers';\n\nexport class Review {\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n readonly rawValue: Readonly<Record<string, any>>;\n\n get reviewbody(): string | undefined {\n return this.rawValue.reviewbody;\n }\n\n get reviewtitle(): string | undefined {\n return this.rawValue.reviewtitle;\n }\n\n get reviewer(): string | undefined {\n return this.rawValue.reviewer;\n }\n\n get reviewer_itemname(): string | undefined {\n return this.rawValue.reviewer_itemname;\n }\n\n @Memoize() get reviewdate(): Date | undefined {\n return this.rawValue.reviewdate != null\n ? DateParser.shared.parseValue(this.rawValue.reviewdate)\n : undefined;\n }\n\n @Memoize() get createdate(): Date | undefined {\n return this.rawValue.createdate != null\n ? DateParser.shared.parseValue(this.rawValue.createdate)\n : undefined;\n }\n\n @Memoize() get stars(): number | undefined {\n return this.rawValue.stars != null\n ? NumberParser.shared.parseValue(this.rawValue.stars)\n : undefined;\n }\n\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n constructor(json: Record<string, any> = {}) {\n this.rawValue = json;\n }\n}\n"]}
@@ -1,10 +0,0 @@
1
- /**
2
- * This is the format used for radio transcripts
3
- */
4
- export type SpeechMusicASREntry = {
5
- readonly end: number;
6
- readonly id: number;
7
- readonly is_music: boolean;
8
- readonly start: number;
9
- readonly text: string;
10
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=speech-music-asr-entry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"speech-music-asr-entry.js","sourceRoot":"","sources":["../../../src/models/speech-music-asr-entry.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * This is the format used for radio transcripts\n */\nexport type SpeechMusicASREntry = {\n readonly end: number;\n readonly id: number;\n readonly is_music: boolean;\n readonly start: number;\n readonly text: string;\n};\n"]}
@@ -1,11 +0,0 @@
1
- export type TaskColor = 'red' | 'green' | 'blue' | 'purple' | 'brown';
2
- export type TaskStatus = 'error' | 'queued' | 'running' | 'passed' | 'paused';
3
- export type Task = {
4
- task_id: number;
5
- cmd: string;
6
- priority: number;
7
- wait_admin: number;
8
- args: Record<string, string>;
9
- color: TaskColor;
10
- status: TaskStatus;
11
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=task.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"task.js","sourceRoot":"","sources":["../../../src/models/task.ts"],"names":[],"mappings":"","sourcesContent":["export type TaskColor = 'red' | 'green' | 'blue' | 'purple' | 'brown';\n\nexport type TaskStatus = 'error' | 'queued' | 'running' | 'passed' | 'paused';\n\nexport type Task = {\n task_id: number;\n cmd: string;\n priority: number;\n wait_admin: number;\n args: Record<string, string>;\n color: TaskColor;\n status: TaskStatus;\n};\n"]}
@@ -1,57 +0,0 @@
1
- import { expect } from '@open-wc/testing';
2
- import { File } from '../../src/models/file';
3
- describe('File', () => {
4
- it('can be instantiated with an object', async () => {
5
- const file = new File({ name: 'foo.jpg' });
6
- expect(file.name).to.equal('foo.jpg');
7
- });
8
- // some fields like size and length get converted to their proper types
9
- it('properly instantiates modeled fields', async () => {
10
- const file = new File({
11
- name: 'foo.jpg',
12
- size: '1234',
13
- length: '1:23',
14
- height: '1080',
15
- width: '1920',
16
- track: '1',
17
- });
18
- expect(file.size).to.equal(1234);
19
- expect(file.length).to.equal(83);
20
- expect(file.height).to.equal(1080);
21
- expect(file.width).to.equal(1920);
22
- expect(file.track).to.equal(1);
23
- });
24
- it('external_identifier can be a single value', async () => {
25
- const file = new File({ name: 'foo.jpg', external_identifier: 'bar' });
26
- expect(file.external_identifier).to.equal('bar');
27
- });
28
- it('external_identifier can be an array', async () => {
29
- const file = new File({
30
- name: 'foo.jpg',
31
- external_identifier: ['foo', 'bar'],
32
- });
33
- expect(file.external_identifier).to.deep.equal(['foo', 'bar']);
34
- });
35
- it('handles falsy values properly', async () => {
36
- const file = new File({
37
- name: 'foo.jpg',
38
- size: 0,
39
- track: 0,
40
- });
41
- expect(file.size).to.not.be.undefined;
42
- expect(file.size).to.equal(0);
43
- expect(file.track).to.not.be.undefined;
44
- expect(file.track).to.equal(0);
45
- });
46
- it('parses mtime properly', async () => {
47
- var _a;
48
- const file = new File({
49
- name: 'foo.jpg',
50
- mtime: '1639591034',
51
- });
52
- expect(file.mtime).to.not.be.undefined;
53
- expect(file.mtime instanceof Date).to.be.true;
54
- expect((_a = file.mtime) === null || _a === void 0 ? void 0 : _a.getTime()).to.equal(1639591034000);
55
- });
56
- });
57
- //# sourceMappingURL=file.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file.test.js","sourceRoot":"","sources":["../../../test/models/file.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IACpB,EAAE,CAAC,oCAAoC,EAAE,KAAK,IAAI,EAAE;QAClD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;QAC3C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,uEAAuE;IACvE,EAAE,CAAC,sCAAsC,EAAE,KAAK,IAAI,EAAE;QACpD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC;YACpB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,MAAM;YACb,KAAK,EAAE,GAAG;SACX,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACnC,MAAM,CAAC,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,CAAC,EAAE,CAAC,SAAS,CAAC;QACvC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE;;QACrC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC;YACpB,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,YAAY;SACpB,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC;QACvC,MAAM,CAAC,IAAI,CAAC,KAAK,YAAY,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QAC9C,MAAM,CAAC,MAAA,IAAI,CAAC,KAAK,0CAAE,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\n\nimport { File } from '../../src/models/file';\n\ndescribe('File', () => {\n it('can be instantiated with an object', async () => {\n const file = new File({ name: 'foo.jpg' });\n expect(file.name).to.equal('foo.jpg');\n });\n\n // some fields like size and length get converted to their proper types\n it('properly instantiates modeled fields', async () => {\n const file = new File({\n name: 'foo.jpg',\n size: '1234',\n length: '1:23',\n height: '1080',\n width: '1920',\n track: '1',\n });\n expect(file.size).to.equal(1234);\n expect(file.length).to.equal(83);\n expect(file.height).to.equal(1080);\n expect(file.width).to.equal(1920);\n expect(file.track).to.equal(1);\n });\n\n it('external_identifier can be a single value', async () => {\n const file = new File({ name: 'foo.jpg', external_identifier: 'bar' });\n expect(file.external_identifier).to.equal('bar');\n });\n\n it('external_identifier can be an array', async () => {\n const file = new File({\n name: 'foo.jpg',\n external_identifier: ['foo', 'bar'],\n });\n expect(file.external_identifier).to.deep.equal(['foo', 'bar']);\n });\n\n it('handles falsy values properly', async () => {\n const file = new File({\n name: 'foo.jpg',\n size: 0,\n track: 0,\n });\n expect(file.size).to.not.be.undefined;\n expect(file.size).to.equal(0);\n expect(file.track).to.not.be.undefined;\n expect(file.track).to.equal(0);\n });\n\n it('parses mtime properly', async () => {\n const file = new File({\n name: 'foo.jpg',\n mtime: '1639591034',\n });\n expect(file.mtime).to.not.be.undefined;\n expect(file.mtime instanceof Date).to.be.true;\n expect(file.mtime?.getTime()).to.equal(1639591034000);\n });\n});\n"]}
@@ -1,53 +0,0 @@
1
- import { expect } from '@open-wc/testing';
2
- import { Review } from '../../src/models/review';
3
- describe('Review', () => {
4
- it('can be instantiated with a title', async () => {
5
- const review = new Review({
6
- reviewtitle: 'It was awesome!',
7
- });
8
- expect(review.reviewtitle).to.equal('It was awesome!');
9
- });
10
- it('stars get converted to a number', async () => {
11
- const review = new Review({
12
- stars: '5',
13
- });
14
- expect(review.stars).to.equal(5);
15
- });
16
- it('reviewdate get converted to a date', async () => {
17
- var _a;
18
- const review = new Review({
19
- reviewdate: '2014-05-09 09:47:15',
20
- });
21
- const expected = new Date();
22
- expected.setHours(9);
23
- expected.setMinutes(47);
24
- expected.setSeconds(15);
25
- expected.setMilliseconds(0);
26
- expected.setMonth(4);
27
- expected.setDate(9);
28
- expected.setFullYear(2014);
29
- expect((_a = review.reviewdate) === null || _a === void 0 ? void 0 : _a.getTime()).to.equal(expected.getTime());
30
- });
31
- it('handles falsy values properly', async () => {
32
- var _a;
33
- const review = new Review({
34
- reviewtitle: 'yay',
35
- reviewdate: '0',
36
- stars: 0,
37
- });
38
- const expected = new Date();
39
- expected.setHours(0);
40
- expected.setMinutes(0);
41
- expected.setSeconds(0);
42
- expected.setMilliseconds(0);
43
- expected.setMonth(0);
44
- expected.setDate(1);
45
- expected.setFullYear(2000);
46
- expect(review.reviewtitle).to.equal('yay');
47
- expect(review.reviewdate).to.not.be.undefined;
48
- expect((_a = review.reviewdate) === null || _a === void 0 ? void 0 : _a.getTime()).to.equal(expected.getTime());
49
- expect(review.stars).to.not.be.undefined;
50
- expect(review.stars).to.equal(0);
51
- });
52
- });
53
- //# sourceMappingURL=review.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"review.test.js","sourceRoot":"","sources":["../../../test/models/review.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;QAChD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;YACxB,WAAW,EAAE,iBAAiB;SAC/B,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;QAC/C,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;YACxB,KAAK,EAAE,GAAG;SACX,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oCAAoC,EAAE,KAAK,IAAI,EAAE;;QAClD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;YACxB,UAAU,EAAE,qBAAqB;SAClC,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,IAAI,IAAI,EAAE,CAAC;QAC5B,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACrB,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QACxB,QAAQ,CAAC,eAAe,CAAC,CAAC,CAA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MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC;QACzC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\n\nimport { Review } from '../../src/models/review';\n\ndescribe('Review', () => {\n it('can be instantiated with a title', async () => {\n const review = new Review({\n reviewtitle: 'It was awesome!',\n });\n expect(review.reviewtitle).to.equal('It was awesome!');\n });\n\n it('stars get converted to a number', async () => {\n const review = new Review({\n stars: '5',\n });\n expect(review.stars).to.equal(5);\n });\n\n it('reviewdate get converted to a date', async () => {\n const review = new Review({\n reviewdate: '2014-05-09 09:47:15',\n });\n\n const expected = new Date();\n expected.setHours(9);\n expected.setMinutes(47);\n expected.setSeconds(15);\n expected.setMilliseconds(0);\n expected.setMonth(4);\n expected.setDate(9);\n expected.setFullYear(2014);\n\n expect(review.reviewdate?.getTime()).to.equal(expected.getTime());\n });\n\n it('handles falsy values properly', async () => {\n const review = new Review({\n reviewtitle: 'yay',\n reviewdate: '0',\n stars: 0,\n });\n\n const expected = new Date();\n expected.setHours(0);\n expected.setMinutes(0);\n expected.setSeconds(0);\n expected.setMilliseconds(0);\n expected.setMonth(0);\n expected.setDate(1);\n expected.setFullYear(2000);\n\n expect(review.reviewtitle).to.equal('yay');\n expect(review.reviewdate).to.not.be.undefined;\n expect(review.reviewdate?.getTime()).to.equal(expected.getTime());\n expect(review.stars).to.not.be.undefined;\n expect(review.stars).to.equal(0);\n });\n});\n"]}