@nomad-media/full 1.1.4 → 1.1.6
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.
|
@@ -17001,6 +17001,8 @@ async function _addTagOrCollection(AUTH_TOKEN, URL, TYPE, CONTENT_ID, CONTENT_DE
|
|
|
17001
17001
|
|
|
17002
17002
|
|
|
17003
17003
|
|
|
17004
|
+
|
|
17005
|
+
|
|
17004
17006
|
async function _bulkUpdateMetadata(AUTH_TOKEN, URL, CONTENT_IDS, COLLECTION_IDS,
|
|
17005
17007
|
RELATED_CONTENT_IDS, TAG_IDS, SCHEMA_NAME, DEBUG_MODE)
|
|
17006
17008
|
{
|
|
@@ -17011,12 +17013,23 @@ async function _bulkUpdateMetadata(AUTH_TOKEN, URL, CONTENT_IDS, COLLECTION_IDS,
|
|
|
17011
17013
|
HEADERS.append("Content-Type", "application/json");
|
|
17012
17014
|
HEADERS.append("Authorization", `Bearer ${AUTH_TOKEN}`);
|
|
17013
17015
|
|
|
17016
|
+
const ASSET_DETAILS = await _getAssetDetails(AUTH_TOKEN, URL, CONTENT_IDS[0], "admin", DEBUG_MODE);
|
|
17017
|
+
|
|
17014
17018
|
// Create body for the request
|
|
17015
17019
|
const BODY = {
|
|
17016
|
-
collections:
|
|
17020
|
+
collections: [
|
|
17021
|
+
...(COLLECTION_IDS ? COLLECTION_IDS : []),
|
|
17022
|
+
...(ASSET_DETAILS.collections ? ASSET_DETAILS.collections.map(item => item.id) : [])
|
|
17023
|
+
],
|
|
17017
17024
|
contents: CONTENT_IDS,
|
|
17018
|
-
relatedContents:
|
|
17019
|
-
|
|
17025
|
+
relatedContents: [
|
|
17026
|
+
...(RELATED_CONTENT_IDS ? RELATED_CONTENT_IDS : []),
|
|
17027
|
+
...(ASSET_DETAILS.relatedContents ? ASSET_DETAILS.relatedContents.map(item => item.id) : [])
|
|
17028
|
+
],
|
|
17029
|
+
tags: [
|
|
17030
|
+
...(TAG_IDS ? TAG_IDS : []),
|
|
17031
|
+
...(ASSET_DETAILS.tags ? ASSET_DETAILS.tags.map(item => item.id) : [])
|
|
17032
|
+
],
|
|
17020
17033
|
schemaName: SCHEMA_NAME
|
|
17021
17034
|
};
|
|
17022
17035
|
|
|
@@ -17349,7 +17362,7 @@ async function _search(AUTH_TOKEN, URL, QUERY, OFFSET, SIZE , FILTERS, SORT_FIEL
|
|
|
17349
17362
|
if (SEARCH_RESULT_FIELDS) BODY["searchResultFields"] = SEARCH_RESULT_FIELDS;
|
|
17350
17363
|
if (SIMILAR_ASSET_ID) BODY["similarAssetId"] = SIMILAR_ASSET_ID;
|
|
17351
17364
|
if (MIN_SCORE) BODY["minScore"] = MIN_SCORE;
|
|
17352
|
-
if (EXCLUDE_TOTAL_RECORD_COUNT) BODY["excludeTotalRecordCount"] = EXCLUDE_TOTAL_RECORD_COUNT;
|
|
17365
|
+
if (EXCLUDE_TOTAL_RECORD_COUNT !== null) BODY["excludeTotalRecordCount"] = EXCLUDE_TOTAL_RECORD_COUNT;
|
|
17353
17366
|
if (FILTER_BINDER) BODY["filterBinder"] = FILTER_BINDER;
|
|
17354
17367
|
|
|
17355
17368
|
if (DEBUG_MODE) console.log(`URL: ${API_URL}\nMETHOD: POST\nBODY: ${JSON.stringify(BODY, null, 4 )}`);
|
|
@@ -243,9 +243,9 @@ BODY: `+JSON.stringify(e,null,4));try{var s=await fetch(t,{method:"PATCH",header
|
|
|
243
243
|
METHOD: POST
|
|
244
244
|
BODY: `+JSON.stringify(e,null,4));try{var s=await fetch(r,{method:"POST",headers:t,body:JSON.stringify(e)});if(s.ok)return await s.json();throw await s.json()}catch(e){_apiExceptionHandler(e,"Adding Related Content Failed")}}async function _addTagOrCollection(e,t,i,a,n,r,o,s,l,d){l="admin"===l?t+`/api/admin/${i}/content`:t+"/api/content/"+i,t=new Headers,t.append("Content-Type","application/json"),t.append("Authorization","Bearer "+e),e={items:[{contentDefinition:n,contentId:a,name:r,createNew:s}]};e.items[0][i+"Id"]=o,d&&console.log(`URL: ${l}
|
|
245
245
|
METHOD: POST
|
|
246
|
-
BODY: `+JSON.stringify(e,null,4));try{var p=await fetch(l,{method:"POST",headers:t,body:JSON.stringify(e)});if(p.ok)return await p.json();throw await p.json()}catch(e){_apiExceptionHandler(e,"Adding Tag or Collection Failed")}}async function _bulkUpdateMetadata(e,t,i,a,n,r,o,s){var
|
|
246
|
+
BODY: `+JSON.stringify(e,null,4));try{var p=await fetch(l,{method:"POST",headers:t,body:JSON.stringify(e)});if(p.ok)return await p.json();throw await p.json()}catch(e){_apiExceptionHandler(e,"Adding Tag or Collection Failed")}}async function _bulkUpdateMetadata(e,t,i,a,n,r,o,s){var l=t+"/api/admin/content/bulk-metadata-update",d=new Headers,e=(d.append("Content-Type","application/json"),d.append("Authorization","Bearer "+e),await _getAssetDetails(e,t,i[0],"admin",s)),t={collections:[...a||[],...e.collections?e.collections.map(e=>e.id):[]],contents:i,relatedContents:[...n||[],...e.relatedContents?e.relatedContents.map(e=>e.id):[]],tags:[...r||[],...e.tags?e.tags.map(e=>e.id):[]],schemaName:o};s&&console.log(`URL: ${l}
|
|
247
247
|
METHOD: POST
|
|
248
|
-
BODY: `+JSON.stringify(
|
|
248
|
+
BODY: `+JSON.stringify(t,null,4));try{var p=await fetch(l,{method:"POST",headers:d,body:JSON.stringify(t)});if(!p.ok)throw await p.json()}catch(e){_apiExceptionHandler(e,"Bulk Update Metadata Failed")}}async function _createTagOrCollection(e,t,i,a,n){t=t+"/api/admin/"+i,i=new Headers,i.append("Content-Type","application/json"),i.append("Authorization","Bearer "+e),e={name:a};n&&console.log(`URL: ${t}
|
|
249
249
|
METHOD: POST
|
|
250
250
|
BODY: `+JSON.stringify(e,null,4));try{var r=await fetch(t,{method:"POST",headers:i,body:JSON.stringify(e)});if(r.ok)return await r.json();throw await r.json()}catch(e){_apiExceptionHandler(e,"Adding Tag or Collection Failed")}}async function _deleteRelatedContent(e,t,i,a,n,r,o){r="admin"===r?t+"/api/admin/related/delete":t+"/api/content/related/delete",t=new Headers,t.append("Content-Type","application/json"),t.append("Authorization","Bearer "+e),e={items:[{contentDefinition:n,contentId:i,relatedContentId:a}]};o&&console.log(`URL: ${r}
|
|
251
251
|
METHOD: POST
|
|
@@ -257,7 +257,7 @@ BODY: `+JSON.stringify(e,null,4));try{var l=await fetch(o,{method:"POST",headers
|
|
|
257
257
|
METHOD: POST
|
|
258
258
|
BODY: `+JSON.stringify(e,null,4));try{var o=await fetch(t,{method:"POST",headers:r,body:JSON.stringify(e)});if(o.ok)return await o.json();throw await o.json()}catch(e){_apiExceptionHandler(e,"Ping user failed")}}async function _pingAuth(e,t,i,a,n){var t=t+"/api/account/ping/auth",r=new Headers,e=(r.append("Content-Type","application/json"),r.append("Authorization","Bearer "+e),{userId:a});i&&(e.applicationId=i),n&&console.log(`URL: ${t}
|
|
259
259
|
METHOD: POST
|
|
260
|
-
BODY: `+JSON.stringify(e,null,4));try{var o=await fetch(t,{method:"POST",headers:r,body:JSON.stringify(e)});if(o.ok)return await o.json();throw await o.json()}catch(e){_apiExceptionHandler(e,"Ping user failed")}}async function _search(e,t,i,a,n,r,o,s,l,d,p,c,h,u){t+=`/api/${h}/search`,h=new Headers,h.append("Content-Type","application/json"),h.append("Authorization","Bearer "+e),e={};i&&(e.searchQuery=i),e.pageOffset=a||0,e.pageSize=n||100,r&&(e.filters=r),o&&(e.sortFields=o),s&&(e.searchResultFields=s),l&&(e.similarAssetId=l),d&&(e.minScore=d),p&&(e.excludeTotalRecordCount=p),c&&(e.filterBinder=c),u&&console.log(`URL: ${t}
|
|
260
|
+
BODY: `+JSON.stringify(e,null,4));try{var o=await fetch(t,{method:"POST",headers:r,body:JSON.stringify(e)});if(o.ok)return await o.json();throw await o.json()}catch(e){_apiExceptionHandler(e,"Ping user failed")}}async function _search(e,t,i,a,n,r,o,s,l,d,p,c,h,u){t+=`/api/${h}/search`,h=new Headers,h.append("Content-Type","application/json"),h.append("Authorization","Bearer "+e),e={};i&&(e.searchQuery=i),e.pageOffset=a||0,e.pageSize=n||100,r&&(e.filters=r),o&&(e.sortFields=o),s&&(e.searchResultFields=s),l&&(e.similarAssetId=l),d&&(e.minScore=d),null!==p&&(e.excludeTotalRecordCount=p),c&&(e.filterBinder=c),u&&console.log(`URL: ${t}
|
|
261
261
|
METHOD: POST
|
|
262
262
|
BODY: `+JSON.stringify(e,null,4));try{var f=await fetch(t,{method:"POST",headers:h,body:JSON.stringify(e)});if(f.ok)return await f.json();throw await f.json()}catch(e){_apiExceptionHandler(e,"Search Failed")}}function _apiExceptionHandler(i,a){if(!i)throw new Error(a);if("string"==typeof i)throw new Error(a+": "+i);if(!i.errors)throw new Error(a+": "+i.message);if(Array.isArray(i.errors)){let t="";for(let e=0;e<i.errors.length;e++)t+=`${i.errors[e].code}: ${i.errors[e].field}: ${i.errors[e].message}\n`;throw new Error(a+": "+t)}if("object"==typeof i.errors){let e="";for(var t in i.errors)Object.prototype.hasOwnProperty.call(i.errors,t)&&(e+=`${t}: ${i.errors[t]}\n`);throw new Error(a+": "+e)}}import{getRandomValues}from"crypto";function _newGuid(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e=>(e^getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))}function _printDatetime(e){var t=(new Date).toLocaleTimeString();console.log(t+": "+e)}async function _sleep(t){if(t&&0!==t)return new Promise(e=>{setTimeout(()=>{e()},1e3*t)})}function _slugify(e){return e&&0!==e.trim().length?e.toString().normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim().replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-"):""}async function _changeEmail(e,t,i,a,n){var t=t+"/api/account/change-email",r=new Headers,e=(r.append("Content-Type","application/json"),r.append("Authorization","Bearer "+e),{password:a,newEmail:i});n&&console.log(`URL: ${t}
|
|
263
263
|
METHOD: POST
|