@imposium-hub/components 1.43.2 → 1.43.4

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": "@imposium-hub/components",
3
- "version": "1.43.2",
3
+ "version": "1.43.4",
4
4
  "description": "React & Typescript component / asset library for Imposium front-ends",
5
5
  "main": "dist/components.js",
6
6
  "scripts": {
@@ -49,21 +49,25 @@ export const getBatch = (api : IImposiumAPI) : any => {
49
49
  dispatch({type: batchActions.SET_BATCH, batch});
50
50
 
51
51
  const doResolve = () => {
52
-
53
- const { acts } = story;
54
- const actsKeys : string[] = Object.keys(acts);
55
- let inventory : any = {};
56
-
57
- actsKeys.forEach((actKey : string) => {
58
- inventory = {...inventory, ...acts[actKey].inventory};
59
- });
60
-
52
+ const acts = (story.data) ? story.data.acts : story.acts;
53
+ const inventory : any = parseInventory(acts);
54
+ const EGC : any[] = parseEGCOptions(acts);
61
55
  const UGC : any[] = Object.keys(inventory).map((key : string) => ({
62
56
  label: inventory[key].name,
63
57
  value: inventory[key].id
64
58
  }));
65
59
 
66
- dispatch({type: batchActions.REPLACE_ASSOCIATION_OPTIONS, associationOptions: UGC});
60
+ UGC.push({
61
+ label: 'composition_id',
62
+ value: 'composition_id'
63
+ });
64
+
65
+ UGC.push({
66
+ label: 'composition_tag',
67
+ value: 'composition_tag'
68
+ });
69
+
70
+ dispatch({type: batchActions.REPLACE_ASSOCIATION_OPTIONS, associationOptions: {UGC, EGC} });
67
71
  dispatch({type: batchActions.TOGGlE_LOADING, toggle: false});
68
72
  };
69
73
 
@@ -107,4 +111,97 @@ const onSyncError = (api : IImposiumAPI, e : Error) : any => {
107
111
  };
108
112
  };
109
113
 
114
+ const parseInventory = (acts : any) : any => {
115
+
116
+ const actsKeys : string[] = Object.keys(acts);
117
+ let inventory : any = {};
118
+
119
+ actsKeys.forEach((actKey : string) => {
120
+ inventory = {...inventory, ...acts[actKey].inventory};
121
+ });
122
+
123
+ return inventory;
124
+ };
125
+
126
+ const parseEGCOptions = (acts : any) : any[] => {
127
+ const EGCOptions : any[] = [];
128
+ const duplicateFormatKeys : string[] = [];
129
+ const actsKeys : string[] = Object.keys(acts);
130
+ const firstAct : any = acts[actsKeys[0]];
131
+
132
+ let sceneKeys : string[];
133
+ let firstVideoScene : any;
134
+
135
+ if (typeof firstAct === 'undefined') {
136
+ return [];
137
+ }
138
+
139
+ sceneKeys = Object.keys(firstAct.scenes);
140
+ firstVideoScene = firstAct.scenes[sceneKeys[0]];
141
+
142
+ if (typeof firstVideoScene === 'undefined') {
143
+ return [];
144
+ }
145
+
146
+ EGCOptions.push(
147
+ {
148
+ label: 'Experience Id',
149
+ value: 'id'
150
+ },
151
+ {
152
+ label: 'Story Id',
153
+ value: 'story_id'
154
+ }
155
+ );
156
+
157
+ firstVideoScene.sceneData.encodingSettings.forEach((encodingSetting : any) => {
158
+ if (encodingSetting.extension && encodingSetting.height) {
159
+ const formatName : string = encodingSetting.name;
160
+ const formatKey : string = `${encodingSetting.extension}_${encodingSetting.height}`;
161
+
162
+ if (typeof duplicateFormatKeys[formatKey] === 'undefined') {
163
+ duplicateFormatKeys[formatKey] = 0;
164
+ }
165
+ duplicateFormatKeys[formatKey]++;
166
+
167
+ EGCOptions.push({
168
+ label: formatName,
169
+ value: (duplicateFormatKeys[formatKey] === 1)
170
+ ? `video_url_${formatKey}`
171
+ : `video_url_${formatKey}_${duplicateFormatKeys[formatKey].toString()}`
172
+ });
173
+ }
174
+ });
175
+
176
+ if (firstVideoScene.exportAsPlaylist) {
177
+ EGCOptions.push({
178
+ label: 'M3U8',
179
+ value: 'video_url_m3u8'
180
+ });
181
+ }
182
+
183
+ if (firstVideoScene.sceneData.savePosterFrame) {
184
+ EGCOptions.push({
185
+ label: 'Poster Frame',
186
+ value: 'poster'
187
+ });
188
+ }
189
+
190
+ if (firstVideoScene.sceneData.saveSnapshotFrame) {
191
+ EGCOptions.push({
192
+ label: 'Snapshot Frame',
193
+ value: 'snapshot'
194
+ });
195
+ }
196
+
197
+ if (firstVideoScene.sceneData.saveSocialFrame) {
198
+ EGCOptions.push({
199
+ label: 'Social Frame',
200
+ value: 'social'
201
+ });
202
+ }
203
+
204
+ return EGCOptions;
205
+ };
206
+
110
207
  export default batchActions;
@@ -88,7 +88,7 @@ export const addAssetTag = (api : IImposiumAPI, id : string, tags : string, stor
88
88
  resolve();
89
89
  }
90
90
 
91
- if (freshTags.length > 0) {
91
+ if (freshTags.length === 1) {
92
92
  promises = freshTags.map((t) => (
93
93
  api.addAssetTag(id, t)
94
94
  .then(() => resolve())
@@ -102,6 +102,14 @@ export const addAssetTag = (api : IImposiumAPI, id : string, tags : string, stor
102
102
 
103
103
  dispatch({type: assetActions.ADD_TAG, id, freshTags});
104
104
  }
105
+
106
+ if (freshTags.length > 1 ) {
107
+ api.addAssetTags(id, freshTags)
108
+ .then(() => resolve())
109
+ .catch((e) => resolve(e));
110
+
111
+ dispatch({type: assetActions.ADD_TAG, id, freshTags});
112
+ }
105
113
  });
106
114
  };
107
115
  };
package/services/API.ts CHANGED
@@ -433,7 +433,7 @@ export default class API {
433
433
  });
434
434
  }
435
435
 
436
- public addAssetTag = (assetId : string, tag : string) : Promise<any | Error> => {
436
+ public addAssetTag = (assetId : string, tag : any) : Promise<any | Error> => {
437
437
  return this.doRequest({
438
438
  method: 'POST',
439
439
  url: `/assets/${assetId}/tag`,
@@ -441,6 +441,14 @@ export default class API {
441
441
  });
442
442
  }
443
443
 
444
+ public addAssetTags = (assetId : string, tags : any) : Promise<any | Error> => {
445
+ return this.doRequest({
446
+ method: 'POST',
447
+ url: `/assets/${assetId}/tags`,
448
+ data: {tags}
449
+ });
450
+ }
451
+
444
452
  public deleteAssetTag = (assetId : string, tag : string) : Promise<any | Error> => {
445
453
  return this.doRequest({
446
454
  method: 'DELETE',