@vidispine/vdt-js 22.4.0 → 23.1.0-pre.1

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.
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
9
9
  var _typeof = require('@babel/runtime/helpers/typeof');
10
10
  var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
11
11
  var _createClass = require('@babel/runtime/helpers/createClass');
12
- var parseFileSize = require('filesize');
12
+ var filesize = require('filesize');
13
13
 
14
14
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
15
 
@@ -20,7 +20,6 @@ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_definePropert
20
20
  var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
21
21
  var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck);
22
22
  var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);
23
- var parseFileSize__default = /*#__PURE__*/_interopDefaultLegacy(parseFileSize);
24
23
 
25
24
  var gcd = function gcd(a, b) {
26
25
  return b ? gcd(b, a % b) : a;
@@ -58,7 +57,7 @@ var parseKeyValuePairTypes = function parseKeyValuePairTypes(keyValuePairTypes)
58
57
  };
59
58
 
60
59
  /**
61
- * Object with all name of roles in VidiCore
60
+ * Const object with VidiCore role names
62
61
  *
63
62
  * @category Auth
64
63
  */
@@ -174,43 +173,43 @@ var ROLE_NAMES = {
174
173
  VXA_READ: '_vxa_read'
175
174
  };
176
175
 
177
- var SHARED_ATTRIBUTE_KEYS = ['uuid', 'user', 'timestamp', 'change', 'conflict', 'mode'];
178
- var SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS = ['name', 'id', 'referenced', 'data', 'inheritance'];
179
-
180
176
  /**
181
- * Array with all available metadata group attributes
177
+ * Array with all available VidiCore system/default field group names
182
178
  *
183
179
  * @category Metadata
184
180
  */
185
- var GROUP_ATTRIBUTE_KEYS = [].concat(SHARED_ATTRIBUTE_KEYS, SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS, ['cycle', 'field', 'group']);
181
+ var SYSTEM_FIELDGROUPS = ['stl_subtitle', 'stl_tti', 'stl_gsi', 'mrk_marker', 'pho_validation', 'pho_resource', 'pho_error', 'facedetect_rect', 'facedetect_face', 'originalTrackFilename', 'stl_gsiHeader'];
186
182
 
187
183
  /**
188
- * Array with all available metadata group attributes
184
+ * Array with all available VidiCore system/default field names (including transient)
189
185
  *
190
186
  * @category Metadata
191
187
  */
192
- var FIELD_ATTRIBUTE_KEYS = [].concat(SHARED_ATTRIBUTE_KEYS, SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS, ['value', 'reference', 'type', 'track']);
188
+ var SYSTEM_FIELDS = ['title', 'user', 'shapeTag', 'representativeThumbnail', 'representativeThumbnailNoAuth', 'representativeItems', 'itemId', 'collectionId', 'mediaType', 'mimeType', 'created', 'startTimeCode', 'startSeconds', 'fieldValidationError', 'schemaValidationError', 'originalFilename', 'originalUri', 'originalAudioCodec', 'originalVideoCodec', 'originalHeight', 'originalWidth', 'originalFormat', 'durationSeconds', 'durationTimeCode', 'solr-index', '__user', '__collection', '__collection_size', '__ancestor_collection', '__ancestor_collection_size', '__shape', '__shape_size', '__shape_last_added', '__placeholder_shape_size', '__version', '__version_count', '__storage', '__storage_size', '__shapetag_{tag}_hash_{hash}', '__storage_{tag}', '__storage_{tag}_size', '__storagegroup', '__storagegroup_size', '__sequence', '__sequence_size', '__metadata_last_modified', '__external_id', '__deletion_lock_id', '__deletion_lock_expiry', '__child_collection', '__child_collection_size', '__parent_collection', '__parent_collection_size', '__items_size', 'stl_text', 'stl_justification', 'stl_xrelative', 'stl_yrelative', 'stl_vertical', 'stl_verticalbase', 'stl_horizontalbase', 'stl_sizerelative', 'stl_color', 'stl_outline', 'stl_outlinecolor', 'stl_outlinesize', 'stl_font', 'stl_service', 'stl_tti', 'stl_gsi', 'cct', 'tcd', 'tcf', 'oet', 'cd', 'mnc', 'cpn', 'dfc', 'tcp', 'tcs', 'tet', 'tnb', 'tnd', 'en', 'co', 'tng', 'rd', 'mnr', 'dsc', 'opt', 'lc', 'tpt', 'tn', 'slr', 'tns', 'rn', 'pub', 'dsn', 'ecd', 'mrk_zerolength', 'mrk_text', 'mrk_color', 'pho_resource_name', 'pho_error_level', 'pho_error_code', 'pho_error_description', 'facedetect_rect_width', 'facedetect_rect_height', 'facedetect_rect_y', 'facedetect_rect_x', 'facedetect_pid', 'facedetect_rect', 'trackId', 'eidr_actor', 'eidr_alternateId', 'eidr_countryOfOrigin', 'eidr_director', 'eidr_id', 'eidr_referentType', 'eidr_releaseDate', 'eidr_resourceName', 'eidr_status', 'eidr_sync', 'ttml_div', 'ttml_root', 'vxa_collection_id', 'vxaId', 'vxaLocalPath', 'tco', 'cs', 'ebn', 'tf', 'cf', 'sgn', 'tci', 'jc', 'vp', 'sn'];
189
+
190
+ var SHARED_ATTRIBUTE_KEYS = ['uuid', 'user', 'timestamp', 'change', 'conflict', 'mode'];
191
+ var SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS = ['name', 'id', 'referenced', 'data', 'inheritance'];
193
192
 
194
193
  /**
195
194
  * Array with all available metadata field value attributes
196
195
  *
197
196
  * @category Metadata
198
197
  */
199
- var FIELD_VALUE_ATTRIBUTE_KEYS = [].concat(SHARED_ATTRIBUTE_KEYS, ['value', 'lang']);
198
+ var FIELD_VALUE_ATTRIBUTE_KEYS = [].concat(_toConsumableArray__default["default"](SHARED_ATTRIBUTE_KEYS), ['value', 'lang']);
200
199
 
201
200
  /**
202
- * Array with all available VidiCore system/default field group names
201
+ * Array with all available metadata field attributes
203
202
  *
204
203
  * @category Metadata
205
204
  */
206
- var SYSTEM_FIELDGROUPS = ['stl_subtitle', 'stl_tti', 'stl_gsi', 'mrk_marker', 'pho_validation', 'pho_resource', 'pho_error', 'facedetect_rect', 'facedetect_face', 'originalTrackFilename', 'stl_gsiHeader'];
205
+ var FIELD_ATTRIBUTE_KEYS = [].concat(_toConsumableArray__default["default"](SHARED_ATTRIBUTE_KEYS), _toConsumableArray__default["default"](SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS), ['value', 'reference', 'type', 'track']);
207
206
 
208
207
  /**
209
- * Array with all available VidiCore system/default field group names
208
+ * Array with all available metadata group attributes
210
209
  *
211
210
  * @category Metadata
212
211
  */
213
- var SYSTEM_FIELDS = ['title', 'user', 'shapeTag', 'representativeThumbnail', 'representativeThumbnailNoAuth', 'representativeItems', 'itemId', 'collectionId', 'mediaType', 'mimeType', 'created', 'startTimeCode', 'startSeconds', 'fieldValidationError', 'schemaValidationError', 'originalFilename', 'originalUri', 'originalAudioCodec', 'originalVideoCodec', 'originalHeight', 'originalWidth', 'originalFormat', 'durationSeconds', 'durationTimeCode', 'solr-index', '__user', '__collection', '__collection_size', '__ancestor_collection', '__ancestor_collection_size', '__shape', '__shape_size', '__shape_last_added', '__placeholder_shape_size', '__version', '__version_count', '__storage', '__storage_size', '__shapetag_{tag}_hash_{hash}', '__storage_{tag}', '__storage_{tag}_size', '__storagegroup', '__storagegroup_size', '__sequence', '__sequence_size', '__metadata_last_modified', '__external_id', '__deletion_lock_id', '__deletion_lock_expiry', '__child_collection', '__child_collection_size', '__parent_collection', '__parent_collection_size', '__items_size', 'stl_text', 'stl_justification', 'stl_xrelative', 'stl_yrelative', 'stl_vertical', 'stl_verticalbase', 'stl_horizontalbase', 'stl_sizerelative', 'stl_color', 'stl_outline', 'stl_outlinecolor', 'stl_outlinesize', 'stl_font', 'stl_service', 'stl_tti', 'stl_gsi', 'cct', 'tcd', 'tcf', 'oet', 'cd', 'mnc', 'cpn', 'dfc', 'tcp', 'tcs', 'tet', 'tnb', 'tnd', 'en', 'co', 'tng', 'rd', 'mnr', 'dsc', 'opt', 'lc', 'tpt', 'tn', 'slr', 'tns', 'rn', 'pub', 'dsn', 'ecd', 'mrk_zerolength', 'mrk_text', 'mrk_color', 'pho_resource_name', 'pho_error_level', 'pho_error_code', 'pho_error_description', 'facedetect_rect_width', 'facedetect_rect_height', 'facedetect_rect_y', 'facedetect_rect_x', 'facedetect_pid', 'facedetect_rect', 'trackId', 'eidr_actor', 'eidr_alternateId', 'eidr_countryOfOrigin', 'eidr_director', 'eidr_id', 'eidr_referentType', 'eidr_releaseDate', 'eidr_resourceName', 'eidr_status', 'eidr_sync', 'ttml_div', 'ttml_root', 'vxa_collection_id', 'vxaId', 'vxaLocalPath', 'tco', 'cs', 'ebn', 'tf', 'cf', 'sgn', 'tci', 'jc', 'vp', 'sn'];
212
+ var GROUP_ATTRIBUTE_KEYS = [].concat(_toConsumableArray__default["default"](SHARED_ATTRIBUTE_KEYS), _toConsumableArray__default["default"](SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS), ['cycle', 'field', 'group']);
214
213
 
215
214
  var _excluded$e = ["value"],
216
215
  _excluded2$2 = ["start", "end", "base"];
@@ -984,6 +983,7 @@ var TimeBase = /*#__PURE__*/function () {
984
983
  *
985
984
  * @remarks
986
985
  * Default format: denominator(:numerator if > 1)
986
+ *
987
987
  * `constant` has precedence over `fraction` if both are true (e.g. NTSC > 30000:1001)
988
988
  *
989
989
  * @param options For how to display it as text
@@ -1014,6 +1014,7 @@ var TimeBase = /*#__PURE__*/function () {
1014
1014
  * - `number` gives that amount of decimal places
1015
1015
  *
1016
1016
  * Default format: rate with two decimals if needed (i.e. decimals are > 0)
1017
+ *
1017
1018
  * Option precedence (when all true): `constant` > `rounded` > `fixed`
1018
1019
  *
1019
1020
  * @param options For how to display it as rate
@@ -1335,6 +1336,7 @@ var TimeCode = /*#__PURE__*/function () {
1335
1336
  *
1336
1337
  * @remarks
1337
1338
  * Default format: samples@denominator(:numerator if > 1)
1339
+ *
1338
1340
  * `constant` has precedence over `fraction` if both are true
1339
1341
  *
1340
1342
  * @param options Options for how to format text
@@ -1621,7 +1623,9 @@ var getGreatestCommonDivisor = function getGreatestCommonDivisor(num1, num2) {
1621
1623
  var _excluded$5 = ["timeBase", "useGCD"];
1622
1624
  /**
1623
1625
  * Format seconds to TimeCode object
1624
- * Input time base is always 1:1 since it expects seconds as input
1626
+ *
1627
+ * @remarks
1628
+ * Input time base is always considered as 1:1 since it expects seconds as input
1625
1629
  *
1626
1630
  * Note: Max 15 digits accuracy (double precision float64), e.g.
1627
1631
  * - 10^6 seconds can have 10^9 decimals (nanosecond) precision
@@ -2133,6 +2137,19 @@ var parseHighlightTimespanList = function parseHighlightTimespanList() {
2133
2137
  }, {});
2134
2138
  };
2135
2139
 
2140
+ /**
2141
+ * Parse Vidicore "NOW" constants to a date object
2142
+ *
2143
+ * Format: `NOW[+/-][number][HOUR/DAY/MONTH/YEAR(s)]` (e.g. "NOW-2HOURS")
2144
+ *
2145
+ * @remarks
2146
+ * Returns an approximate date since it's created client side
2147
+ *
2148
+ * @param value A "NOW" constant
2149
+ * @returns A date from the NOW constant
2150
+ *
2151
+ * @category Search
2152
+ */
2136
2153
  var parseNowDate = function parseNowDate() {
2137
2154
  var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'NOW';
2138
2155
  if (value.startsWith('NOW')) {
@@ -2191,7 +2208,7 @@ var sampleRateSymbols = {
2191
2208
  B: 'Hz',
2192
2209
  mB: 'mHz'
2193
2210
  };
2194
- var bitRateSymbols = {
2211
+ var bitRateSymbols$1 = {
2195
2212
  kB: 'kbps',
2196
2213
  B: 'bps',
2197
2214
  MB: 'mbps'
@@ -2216,16 +2233,24 @@ var parseAudioComponent = function parseAudioComponent(audioComponentType) {
2216
2233
  audioBitRateMode = audioMediaInfo.Bit_rate_mode;
2217
2234
  var audioMetadata = parseKeyValuePairTypes(metadata || []);
2218
2235
  var audioSamplerateSamples = timeBase !== null && timeBase !== void 0 && timeBase.denominator ? ((timeBase === null || timeBase === void 0 ? void 0 : timeBase.denominator) || 1) / ((timeBase === null || timeBase === void 0 ? void 0 : timeBase.numerator) || 1) : undefined;
2219
- var audioSamplerate = audioSamplerateSamples !== undefined ? parseFileSize__default["default"](audioSamplerateSamples, {
2236
+ var audioSamplerate = audioSamplerateSamples !== undefined ? filesize.filesize(audioSamplerateSamples, {
2220
2237
  base: 10,
2221
2238
  round: 1,
2222
2239
  symbols: sampleRateSymbols
2223
2240
  }) : undefined;
2224
- var audioBitrate = bitrate !== undefined ? parseFileSize__default["default"](bitrate, {
2225
- base: 10,
2226
- round: 2,
2227
- symbols: bitRateSymbols
2228
- }) : undefined;
2241
+ var audioBitrate;
2242
+ var audioBitrateKbps;
2243
+ if (bitrate !== undefined) {
2244
+ var _split;
2245
+ audioBitrate = filesize.filesize(bitrate, {
2246
+ round: 2,
2247
+ symbols: bitRateSymbols$1
2248
+ });
2249
+ audioBitrateKbps = Number((_split = filesize.filesize(bitrate, {
2250
+ exponent: 1,
2251
+ symbols: bitRateSymbols$1
2252
+ }).split(' kbps')) === null || _split === void 0 ? void 0 : _split[0]);
2253
+ }
2229
2254
  return {
2230
2255
  audioFormat: audioFormat,
2231
2256
  audioCodec: audioCodec,
@@ -2233,6 +2258,7 @@ var parseAudioComponent = function parseAudioComponent(audioComponentType) {
2233
2258
  audioSamplerateSamples: audioSamplerateSamples,
2234
2259
  audioBitDepth: audioBitDepth,
2235
2260
  audioBitrate: audioBitrate,
2261
+ audioBitrateKbps: audioBitrateKbps,
2236
2262
  audioBitRateMode: audioBitRateMode,
2237
2263
  audioChannels: audioChannels,
2238
2264
  audioMediaInfo: audioMediaInfo,
@@ -2240,9 +2266,43 @@ var parseAudioComponent = function parseAudioComponent(audioComponentType) {
2240
2266
  };
2241
2267
  };
2242
2268
 
2269
+ /**
2270
+ * Const object with all file states in VidiCore
2271
+ * (see https://apidoc.vidispine.com/latest/storage/storage.html#file-states for more info)
2272
+ *
2273
+ * @category File
2274
+ */
2275
+ var FILE_STATES = {
2276
+ /** Just created, not used. */
2277
+ NONE: 'NONE',
2278
+ /** Discovered or created, not yet marked as finished. */
2279
+ OPEN: 'OPEN',
2280
+ /** File does no longer grow. */
2281
+ CLOSED: 'CLOSED',
2282
+ /** The current state is not known. */
2283
+ UNKNOWN: 'UNKNOWN',
2284
+ /** File is missing from the file system/storage. */
2285
+ MISSING: 'MISSING',
2286
+ /** File has been missing for a longer period. Candidate for restoration from archive. */
2287
+ LOST: 'LOST',
2288
+ /** File will appear on file system/storage, transfer subsystem or transcoder will create it. */
2289
+ TO_APPEAR: 'TO_APPEAR',
2290
+ /** The file is no longer in use, and will be deleted at the next clean-up sweep. */
2291
+ TO_BE_DELETED: 'TO_BE_DELETED',
2292
+ /** File is in use by transfer subsystem or transcoder. */
2293
+ BEING_READ: 'BEING_READ',
2294
+ /** File is archived. */
2295
+ ARCHIVED: 'ARCHIVED',
2296
+ /** File will be synchronized by multi-site agent. */
2297
+ AWAITING_SYNC: 'AWAITING_SYNC'
2298
+ };
2299
+
2243
2300
  /**
2244
2301
  * Parses a VidiCore file object
2245
2302
  *
2303
+ * @remarks
2304
+ * File sizes are parsed with JEDEC standard (base 2)
2305
+ *
2246
2306
  * @param fileType VidiCore file object
2247
2307
  * @returns A parsed file object
2248
2308
  *
@@ -2257,7 +2317,10 @@ var parseFileType = function parseFileType(fileType) {
2257
2317
  fileId = fileType.id;
2258
2318
  var _uriList = _slicedToArray__default["default"](uriList, 1),
2259
2319
  uri = _uriList[0];
2260
- var fileSize = fileSizeBytes !== undefined ? parseFileSize__default["default"](fileSizeBytes) : '';
2320
+ var fileSize = fileSizeBytes !== undefined ? filesize.filesize(fileSizeBytes, {
2321
+ base: 2,
2322
+ standard: 'jedec'
2323
+ }) : '';
2261
2324
  var fileName = path ? path.split('/').pop() : undefined;
2262
2325
  return {
2263
2326
  uri: uri,
@@ -2372,6 +2435,11 @@ var parseContainerComponent = function parseContainerComponent() {
2372
2435
  return parsedContainerComponentType;
2373
2436
  };
2374
2437
 
2438
+ var bitRateSymbols = {
2439
+ kB: 'kbps',
2440
+ B: 'bps',
2441
+ MB: 'mbps'
2442
+ };
2375
2443
  /**
2376
2444
  * Parses the technical information of a VideoComponentType.
2377
2445
  * @param {Object} videoComponentType - A VideoComponentType from VidiCore.
@@ -2432,9 +2500,19 @@ var parseVideoComponent = function parseVideoComponent() {
2432
2500
  width = _ref.width;
2433
2501
  var aspectRatio = parseAspectRatio(resolution);
2434
2502
  var dimension = "".concat(width, "x").concat(height);
2435
- var videoBitrate = bitrate ? parseFileSize__default["default"](bitrate, {
2436
- bits: true
2437
- }) : undefined;
2503
+ var videoBitrate;
2504
+ var videoBitrateMbps;
2505
+ if (bitrate !== undefined) {
2506
+ var _split;
2507
+ videoBitrate = filesize.filesize(bitrate, {
2508
+ round: 2,
2509
+ symbols: bitRateSymbols
2510
+ });
2511
+ videoBitrateMbps = Number((_split = filesize.filesize(bitrate, {
2512
+ exponent: 2,
2513
+ symbols: bitRateSymbols
2514
+ }).split(' mbps')) === null || _split === void 0 ? void 0 : _split[0]);
2515
+ }
2438
2516
  return {
2439
2517
  videoFormat: videoFormat,
2440
2518
  dimension: dimension,
@@ -2446,6 +2524,7 @@ var parseVideoComponent = function parseVideoComponent() {
2446
2524
  videoCodec: videoCodec,
2447
2525
  smpte: smpte,
2448
2526
  videoBitrate: videoBitrate,
2527
+ videoBitrateMbps: videoBitrateMbps,
2449
2528
  fieldOrder: fieldOrder,
2450
2529
  colorSpace: colorSpace,
2451
2530
  chromaSubsampling: chromaSubsampling,
@@ -2512,8 +2591,11 @@ var parseShapeType = function parseShapeType() {
2512
2591
  return parsedShape;
2513
2592
  };
2514
2593
 
2515
- // eslint-disable-next-line import/no-cycle
2516
-
2594
+ /**
2595
+ * Const object with document types
2596
+ *
2597
+ * @category Shape
2598
+ */
2517
2599
  var DOCUMENT_TYPES = {
2518
2600
  PDF: 'PDF',
2519
2601
  TEXT: 'TEXT',
@@ -2521,6 +2603,21 @@ var DOCUMENT_TYPES = {
2521
2603
  JSON: 'JSON',
2522
2604
  XML: 'XML'
2523
2605
  };
2606
+
2607
+ /**
2608
+ * Const object with media types
2609
+ *
2610
+ * @category Shape
2611
+ */
2612
+ var SHAPE_MEDIA_TYPES = {
2613
+ IMAGE: 'IMAGE',
2614
+ AUDIO: 'AUDIO',
2615
+ VIDEO: 'VIDEO',
2616
+ DOCUMENT: 'DOCUMENT',
2617
+ BINARY: 'BINARY'
2618
+ };
2619
+
2620
+ // eslint-disable-next-line import/no-cycle
2524
2621
  /**
2525
2622
  * Return a const for the document type of a shape (looks at mimeType)
2526
2623
  *
@@ -2628,15 +2725,6 @@ var filterShapeSource = function filterShapeSource(itemType, options) {
2628
2725
  return filteredShapeList;
2629
2726
  };
2630
2727
 
2631
- // eslint-disable-next-line import/no-cycle
2632
-
2633
- var SHAPE_MEDIA_TYPES = {
2634
- IMAGE: 'IMAGE',
2635
- AUDIO: 'AUDIO',
2636
- VIDEO: 'VIDEO',
2637
- DOCUMENT: 'DOCUMENT',
2638
- BINARY: 'BINARY'
2639
- };
2640
2728
  /**
2641
2729
  * Returns a const for which media type a shape has
2642
2730
  *
@@ -2834,10 +2922,13 @@ var parseTranscodePreset = function parseTranscodePreset(transcodePresetType) {
2834
2922
  return output;
2835
2923
  };
2836
2924
 
2925
+ exports.DOCUMENT_TYPES = DOCUMENT_TYPES;
2837
2926
  exports.FIELD_ATTRIBUTE_KEYS = FIELD_ATTRIBUTE_KEYS;
2838
2927
  exports.FIELD_VALUE_ATTRIBUTE_KEYS = FIELD_VALUE_ATTRIBUTE_KEYS;
2928
+ exports.FILE_STATES = FILE_STATES;
2839
2929
  exports.GROUP_ATTRIBUTE_KEYS = GROUP_ATTRIBUTE_KEYS;
2840
2930
  exports.ROLE_NAMES = ROLE_NAMES;
2931
+ exports.SHAPE_MEDIA_TYPES = SHAPE_MEDIA_TYPES;
2841
2932
  exports.SYSTEM_FIELDGROUPS = SYSTEM_FIELDGROUPS;
2842
2933
  exports.SYSTEM_FIELDS = SYSTEM_FIELDS;
2843
2934
  exports.TimeBase = TimeBase;