@eluvio/elv-client-js 4.2.32 → 4.2.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "4.2.32",
3
+ "version": "4.2.33",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/index.js",
6
6
  "author": "Kevin Talmadge",
@@ -197,6 +197,10 @@ const CueInfo = async ({eventId, status}) => {
197
197
  * @param {boolean=} options.linkToSite - If enabled, will create a link in the live stream site
198
198
  * @param {boolean=} options.initializeDrm - If enabled, will initialize DRM for the object
199
199
  * @param {string=} options.ingressNodeId - ID of the ingress node used for stream allocation (required for non-public nodes)
200
+ * @param {Object=} options.metadata - Additional metadata to merge into the live stream object metadata
201
+ * @param {Array<string>=} options.tags - Fabric tags to associate with the live stream
202
+ * @param {Array<string>=} options.groups - Fabric content group IDs to associate with the live stream. Distinct from access groups.
203
+ * @param {Object<string, string>=} options.queryFields - Fabric query fields to associate with the live stream
200
204
  *
201
205
  * @return {Promise<Object>} - Object containing objectId, libraryId, writeToken, and hash if finalized
202
206
  */
@@ -212,6 +216,20 @@ exports.StreamCreate = async function({
212
216
  const existingObject = !!objectId;
213
217
  let contentType;
214
218
  let adminGroups = options.accessGroups ?? [];
219
+ const customMetadata = options.metadata === undefined ? {} : options.metadata;
220
+ const {tags, groups, queryFields} = options;
221
+
222
+ if(typeof customMetadata !== "object" || Array.isArray(customMetadata)) {
223
+ throw Error("Stream metadata must be an object");
224
+ }
225
+
226
+ if(customMetadata.public !== undefined && (customMetadata.public === null || typeof customMetadata.public !== "object" || Array.isArray(customMetadata.public))) {
227
+ throw Error("Stream public metadata must be an object");
228
+ }
229
+
230
+ if(customMetadata.public?.asset_metadata !== undefined && (customMetadata.public.asset_metadata === null || typeof customMetadata.public.asset_metadata !== "object" || Array.isArray(customMetadata.public.asset_metadata))) {
231
+ throw Error("Stream public asset metadata must be an object");
232
+ }
215
233
 
216
234
  // Retrieve live stream content type
217
235
  try {
@@ -265,7 +283,10 @@ exports.StreamCreate = async function({
265
283
  editResponse = await this.CreateContentObject({
266
284
  libraryId,
267
285
  options: {
268
- type: contentType
286
+ type: contentType,
287
+ tags,
288
+ groups,
289
+ queryFields
269
290
  }
270
291
  });
271
292
  objectId = editResponse.objectId;
@@ -273,14 +294,27 @@ exports.StreamCreate = async function({
273
294
 
274
295
  const {writeToken} = editResponse;
275
296
  const {
276
- accessGroup,
277
- name=defaultName,
278
297
  displayTitle,
279
298
  description,
280
299
  permission="editable",
281
300
  ingressNodeId,
282
301
  initializeDrm=true
283
302
  } = options;
303
+ const name = options.name ?? customMetadata.public?.name ?? defaultName;
304
+
305
+ if(existingObject) {
306
+ if(tags !== undefined) {
307
+ await this.SetContentObjectTags({libraryId, objectId, writeToken, tags});
308
+ }
309
+
310
+ if(groups !== undefined) {
311
+ await this.SetContentObjectGroups({libraryId, objectId, writeToken, groups});
312
+ }
313
+
314
+ if(queryFields !== undefined) {
315
+ await this.SetContentObjectQueryFields({libraryId, objectId, writeToken, queryFields});
316
+ }
317
+ }
284
318
 
285
319
  if(!liveRecordingConfig) {
286
320
  liveRecordingConfig = {};
@@ -311,10 +345,9 @@ exports.StreamCreate = async function({
311
345
  })
312
346
  );
313
347
 
314
- const metadata = {
348
+ const generatedMetadata = {
315
349
  public: {
316
350
  name,
317
- description,
318
351
  asset_metadata: {
319
352
  display_title: displayTitle || name,
320
353
  title: name || displayTitle || defaultName,
@@ -324,6 +357,22 @@ exports.StreamCreate = async function({
324
357
  }
325
358
  }
326
359
  };
360
+ const metadata = R.mergeDeepRight(generatedMetadata, customMetadata);
361
+
362
+ // Explicit options take precedence over custom metadata
363
+ metadata.public.name = name;
364
+ if(options.name !== undefined) {
365
+ metadata.public.asset_metadata.title = name;
366
+ metadata.public.asset_metadata.slug = slugify(name);
367
+ }
368
+
369
+ if(displayTitle !== undefined) {
370
+ metadata.public.asset_metadata.display_title = displayTitle;
371
+ }
372
+
373
+ if(description !== undefined) {
374
+ metadata.public.description = description;
375
+ }
327
376
 
328
377
  const currentLiveRecordingConfig = await this.ContentObjectMetadata({
329
378
  libraryId,