@eluvio/elv-client-js 4.0.11 → 4.0.12
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/.keep +0 -0
- package/dist/ElvClient-min.js +11 -10
- package/dist/ElvClient-node-min.js +11 -10
- package/dist/ElvFrameClient-min.js +11 -10
- package/dist/ElvPermissionsClient-min.js +10 -9
- package/dist/ElvWalletClient-min.js +10 -9
- package/dist/ElvWalletClient-node-min.js +10 -9
- package/dist/src/AuthorizationClient.js +1555 -2076
- package/dist/src/ContentObjectVerification.js +134 -185
- package/dist/src/Crypto.js +224 -319
- package/dist/src/ElvClient.js +822 -1114
- package/dist/src/ElvWallet.js +64 -106
- package/dist/src/EthClient.js +719 -974
- package/dist/src/FrameClient.js +222 -318
- package/dist/src/HttpClient.js +112 -154
- package/dist/src/Id.js +1 -6
- package/dist/src/LogMessage.js +4 -8
- package/dist/src/PermissionsClient.js +973 -1271
- package/dist/src/RemoteSigner.js +161 -232
- package/dist/src/UserProfileClient.js +781 -1038
- package/dist/src/Utils.js +159 -299
- package/dist/src/Validation.js +2 -17
- package/dist/src/client/ABRPublishing.js +772 -942
- package/dist/src/client/AccessGroups.js +849 -1095
- package/dist/src/client/ContentAccess.js +3322 -4195
- package/dist/src/client/ContentManagement.js +1814 -2288
- package/dist/src/client/Contracts.js +468 -614
- package/dist/src/client/Files.js +1506 -1846
- package/dist/src/client/NFT.js +94 -116
- package/dist/src/client/NTP.js +326 -425
- package/dist/src/index.js +2 -5
- package/dist/src/walletClient/ClientMethods.js +1368 -1763
- package/dist/src/walletClient/Configuration.js +4 -2
- package/dist/src/walletClient/Notifications.js +98 -127
- package/dist/src/walletClient/Profile.js +184 -246
- package/dist/src/walletClient/Utils.js +76 -122
- package/dist/src/walletClient/index.js +1171 -1496
- package/package.json +4 -21
- package/dist/AccessClient-min.js +0 -54
- package/dist/AccessClient-node-min.js +0 -74
- package/dist/src/AccessClient.js +0 -798
- package/dist/src/LimitedMap.js +0 -120
- package/dist/src/client/Access.js +0 -1
- package/dist/src/client/Management.js +0 -1606
- package/dist/src/contracts/AccessIndexor.js +0 -831
- package/dist/src/contracts/Accessible.js +0 -31
- package/dist/src/contracts/AdmgrAdvertisement.js +0 -695
- package/dist/src/contracts/AdmgrCampaign.js +0 -648
- package/dist/src/contracts/AdmgrCampaignManager.js +0 -493
- package/dist/src/contracts/AdmgrCommercialOffering.js +0 -622
- package/dist/src/contracts/AdmgrCommercialOfferingManager.js +0 -413
- package/dist/src/contracts/AdmgrMarketPlace.js +0 -413
- package/dist/src/contracts/AvailsDelivery.js +0 -535
- package/dist/src/contracts/BaseAccessControlGroup.js +0 -1221
- package/dist/src/contracts/BaseAccessWallet.js +0 -1575
- package/dist/src/contracts/BaseAccessWalletFactory.js +0 -93
- package/dist/src/contracts/BaseContent.js +0 -1104
- package/dist/src/contracts/BaseContentFactory.js +0 -99
- package/dist/src/contracts/BaseContentFactoryExt.js +0 -219
- package/dist/src/contracts/BaseContentSpace.js +0 -1346
- package/dist/src/contracts/BaseContentType.js +0 -353
- package/dist/src/contracts/BaseFactory.js +0 -107
- package/dist/src/contracts/BaseGroupFactory.js +0 -93
- package/dist/src/contracts/BaseLibrary.js +0 -1035
- package/dist/src/contracts/BaseLibraryFactory.js +0 -96
- package/dist/src/contracts/Certifyer.js +0 -87
- package/dist/src/contracts/Container.js +0 -543
- package/dist/src/contracts/Content.js +0 -432
- package/dist/src/contracts/Editable.js +0 -295
- package/dist/src/contracts/FactorySpace.js +0 -57
- package/dist/src/contracts/KmsSpace.js +0 -52
- package/dist/src/contracts/LvProvider.js +0 -512
- package/dist/src/contracts/LvRecordableStream.js +0 -1026
- package/dist/src/contracts/LvRecording.js +0 -627
- package/dist/src/contracts/LvStreamRightsHolder.js +0 -551
- package/dist/src/contracts/MetaObject.js +0 -110
- package/dist/src/contracts/Node.js +0 -167
- package/dist/src/contracts/NodeSpace.js +0 -18
- package/dist/src/contracts/NodeSpaceImpl.js +0 -273
- package/dist/src/contracts/Ownable.js +0 -87
- package/dist/src/contracts/PaymentService.js +0 -616
- package/dist/src/contracts/Precompile.js +0 -15
- package/dist/src/contracts/SampleContentAdMarketplace.js +0 -564
- package/dist/src/contracts/SampleContentAdvertising.js +0 -444
- package/dist/src/contracts/SampleContentHelloWorld.js +0 -459
- package/dist/src/contracts/SampleContentLicensing.js +0 -618
- package/dist/src/contracts/SampleContentSigned.js +0 -447
- package/dist/src/contracts/SampleInstance.js +0 -438
- package/dist/src/contracts/SampleInstanceFactory.js +0 -451
- package/dist/src/contracts/Transactable.js +0 -82
- package/dist/src/contracts/UserSpace.js +0 -18
- package/dist/src/contracts/UserSpaceImpl.js +0 -43
- package/dist/src/contracts/Utils.js +0 -18
- package/dist/src/contracts/Verifier.js +0 -53
- package/dist/src/contracts/strings.js +0 -4
- package/dist/src/contracts/v2/BaseContentFactoryExt.js +0 -219
- package/dist/src/contracts/v2/FactorySpace.js +0 -57
- package/dist/src/contracts/v2/KmsSpace.js +0 -52
- package/dist/src/contracts/v2/NodeSpaceImpl.js +0 -273
- package/dist/src/contracts/v2/UserSpaceImpl.js +0 -43
- package/dist/src/marketplaceClient/ClientMethods.js +0 -1918
- package/dist/src/marketplaceClient/Configuration.js +0 -29
- package/dist/src/marketplaceClient/Utils.js +0 -304
- package/dist/src/marketplaceClient/index.js +0 -1553
|
@@ -1,1606 +0,0 @@
|
|
|
1
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
2
|
-
|
|
3
|
-
var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
4
|
-
|
|
5
|
-
var _defineProperty = require("@babel/runtime/helpers/defineProperty");
|
|
6
|
-
|
|
7
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
8
|
-
|
|
9
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
10
|
-
|
|
11
|
-
var UrlJoin = require("url-join");
|
|
12
|
-
|
|
13
|
-
var _require = require("../Validation"),
|
|
14
|
-
ValidateLibrary = _require.ValidateLibrary,
|
|
15
|
-
ValidateObject = _require.ValidateObject,
|
|
16
|
-
ValidateVersion = _require.ValidateVersion,
|
|
17
|
-
ValidateWriteToken = _require.ValidateWriteToken,
|
|
18
|
-
ValidatePartHash = _require.ValidatePartHash,
|
|
19
|
-
ValidateParameters = _require.ValidateParameters;
|
|
20
|
-
/* Content Type Creation */
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Create a new content type.
|
|
24
|
-
*
|
|
25
|
-
* A new content type contract is deployed from
|
|
26
|
-
* the content space, and that contract ID is used to determine the object ID to
|
|
27
|
-
* create in the fabric. The content type object will be created in the special
|
|
28
|
-
* content space library (ilib<content-space-hash>)
|
|
29
|
-
*
|
|
30
|
-
* @methodGroup Content Types
|
|
31
|
-
* @namedParams
|
|
32
|
-
* @param libraryId {string=} - ID of the library in which to create the content type. If not specified,
|
|
33
|
-
* it will be created in the content space library
|
|
34
|
-
* @param {string} name - Name of the content type
|
|
35
|
-
* @param {object} metadata - Metadata for the new content type
|
|
36
|
-
* @param {(Blob | Buffer)=} bitcode - Bitcode to be used for the content type
|
|
37
|
-
*
|
|
38
|
-
* @returns {Promise<string>} - Object ID of created content type
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
exports.CreateContentType = function _callee(_ref) {
|
|
43
|
-
var name, _ref$metadata, metadata, bitcode, _ref2, contractAddress, objectId, path, createResponse, uploadResponse;
|
|
44
|
-
|
|
45
|
-
return _regeneratorRuntime.async(function _callee$(_context) {
|
|
46
|
-
while (1) {
|
|
47
|
-
switch (_context.prev = _context.next) {
|
|
48
|
-
case 0:
|
|
49
|
-
name = _ref.name, _ref$metadata = _ref.metadata, metadata = _ref$metadata === void 0 ? {} : _ref$metadata, bitcode = _ref.bitcode;
|
|
50
|
-
this.Log("Creating content type: ".concat(name));
|
|
51
|
-
metadata.name = name;
|
|
52
|
-
metadata["public"] = _objectSpread({
|
|
53
|
-
name: name
|
|
54
|
-
}, metadata["public"] || {});
|
|
55
|
-
_context.next = 6;
|
|
56
|
-
return _regeneratorRuntime.awrap(this.authClient.CreateContentType());
|
|
57
|
-
|
|
58
|
-
case 6:
|
|
59
|
-
_ref2 = _context.sent;
|
|
60
|
-
contractAddress = _ref2.contractAddress;
|
|
61
|
-
objectId = this.utils.AddressToObjectId(contractAddress);
|
|
62
|
-
path = UrlJoin("qlibs", this.contentSpaceLibraryId, "qid", objectId);
|
|
63
|
-
this.Log("Created type: ".concat(contractAddress, " ").concat(objectId));
|
|
64
|
-
/* Create object, upload bitcode and finalize */
|
|
65
|
-
|
|
66
|
-
_context.t0 = _regeneratorRuntime;
|
|
67
|
-
_context.t1 = this.utils;
|
|
68
|
-
_context.t2 = this.HttpClient;
|
|
69
|
-
_context.next = 16;
|
|
70
|
-
return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
|
|
71
|
-
libraryId: this.contentSpaceLibraryId,
|
|
72
|
-
objectId: objectId,
|
|
73
|
-
update: true
|
|
74
|
-
}));
|
|
75
|
-
|
|
76
|
-
case 16:
|
|
77
|
-
_context.t3 = _context.sent;
|
|
78
|
-
_context.t4 = path;
|
|
79
|
-
_context.t5 = {
|
|
80
|
-
headers: _context.t3,
|
|
81
|
-
method: "POST",
|
|
82
|
-
path: _context.t4,
|
|
83
|
-
failover: false
|
|
84
|
-
};
|
|
85
|
-
_context.t6 = _context.t2.Request.call(_context.t2, _context.t5);
|
|
86
|
-
_context.t7 = _context.t1.ResponseToJson.call(_context.t1, _context.t6);
|
|
87
|
-
_context.next = 23;
|
|
88
|
-
return _context.t0.awrap.call(_context.t0, _context.t7);
|
|
89
|
-
|
|
90
|
-
case 23:
|
|
91
|
-
createResponse = _context.sent;
|
|
92
|
-
_context.next = 26;
|
|
93
|
-
return _regeneratorRuntime.awrap(this.ReplaceMetadata({
|
|
94
|
-
libraryId: this.contentSpaceLibraryId,
|
|
95
|
-
objectId: objectId,
|
|
96
|
-
writeToken: createResponse.write_token,
|
|
97
|
-
metadata: metadata
|
|
98
|
-
}));
|
|
99
|
-
|
|
100
|
-
case 26:
|
|
101
|
-
if (!bitcode) {
|
|
102
|
-
_context.next = 32;
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
_context.next = 29;
|
|
107
|
-
return _regeneratorRuntime.awrap(this.UploadPart({
|
|
108
|
-
libraryId: this.contentSpaceLibraryId,
|
|
109
|
-
objectId: objectId,
|
|
110
|
-
writeToken: createResponse.write_token,
|
|
111
|
-
data: bitcode,
|
|
112
|
-
encrypted: false
|
|
113
|
-
}));
|
|
114
|
-
|
|
115
|
-
case 29:
|
|
116
|
-
uploadResponse = _context.sent;
|
|
117
|
-
_context.next = 32;
|
|
118
|
-
return _regeneratorRuntime.awrap(this.ReplaceMetadata({
|
|
119
|
-
libraryId: this.contentSpaceLibraryId,
|
|
120
|
-
objectId: objectId,
|
|
121
|
-
writeToken: createResponse.write_token,
|
|
122
|
-
metadataSubtree: "bitcode_part",
|
|
123
|
-
metadata: uploadResponse.part.hash
|
|
124
|
-
}));
|
|
125
|
-
|
|
126
|
-
case 32:
|
|
127
|
-
_context.next = 34;
|
|
128
|
-
return _regeneratorRuntime.awrap(this.FinalizeContentObject({
|
|
129
|
-
libraryId: this.contentSpaceLibraryId,
|
|
130
|
-
objectId: objectId,
|
|
131
|
-
writeToken: createResponse.write_token
|
|
132
|
-
}));
|
|
133
|
-
|
|
134
|
-
case 34:
|
|
135
|
-
return _context.abrupt("return", objectId);
|
|
136
|
-
|
|
137
|
-
case 35:
|
|
138
|
-
case "end":
|
|
139
|
-
return _context.stop();
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}, null, this);
|
|
143
|
-
};
|
|
144
|
-
/* Library creation and deletion */
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Create a new content library.
|
|
148
|
-
*
|
|
149
|
-
* A new content library contract is deployed from
|
|
150
|
-
* the content space, and that contract ID is used to determine the library ID to
|
|
151
|
-
* create in the fabric.
|
|
152
|
-
*
|
|
153
|
-
* @methodGroup Content Libraries
|
|
154
|
-
*
|
|
155
|
-
* @namedParams
|
|
156
|
-
* @param {string} name - Library name
|
|
157
|
-
* @param {string=} description - Library description
|
|
158
|
-
* @param {blob=} image - Image associated with the library
|
|
159
|
-
* @param {Object=} metadata - Metadata of library object
|
|
160
|
-
* @param {string=} kmsId - ID of the KMS to use for content in this library. If not specified,
|
|
161
|
-
* the default KMS will be used.
|
|
162
|
-
*
|
|
163
|
-
* @returns {Promise<string>} - Library ID of created library
|
|
164
|
-
*/
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
exports.CreateContentLibrary = function _callee2(_ref3) {
|
|
168
|
-
var name, description, image, _ref3$metadata, metadata, kmsId, _ref4, contractAddress, libraryId, objectId, editResponse;
|
|
169
|
-
|
|
170
|
-
return _regeneratorRuntime.async(function _callee2$(_context2) {
|
|
171
|
-
while (1) {
|
|
172
|
-
switch (_context2.prev = _context2.next) {
|
|
173
|
-
case 0:
|
|
174
|
-
name = _ref3.name, description = _ref3.description, image = _ref3.image, _ref3$metadata = _ref3.metadata, metadata = _ref3$metadata === void 0 ? {} : _ref3$metadata, kmsId = _ref3.kmsId;
|
|
175
|
-
|
|
176
|
-
if (kmsId) {
|
|
177
|
-
_context2.next = 9;
|
|
178
|
-
break;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
_context2.t0 = "ikms";
|
|
182
|
-
_context2.t1 = this.utils;
|
|
183
|
-
_context2.next = 6;
|
|
184
|
-
return _regeneratorRuntime.awrap(this.DefaultKMSAddress());
|
|
185
|
-
|
|
186
|
-
case 6:
|
|
187
|
-
_context2.t2 = _context2.sent;
|
|
188
|
-
_context2.t3 = _context2.t1.AddressToHash.call(_context2.t1, _context2.t2);
|
|
189
|
-
kmsId = _context2.t0.concat.call(_context2.t0, _context2.t3);
|
|
190
|
-
|
|
191
|
-
case 9:
|
|
192
|
-
this.Log("Creating content library");
|
|
193
|
-
this.Log("KMS ID: ".concat(kmsId));
|
|
194
|
-
_context2.next = 13;
|
|
195
|
-
return _regeneratorRuntime.awrap(this.authClient.CreateContentLibrary({
|
|
196
|
-
kmsId: kmsId
|
|
197
|
-
}));
|
|
198
|
-
|
|
199
|
-
case 13:
|
|
200
|
-
_ref4 = _context2.sent;
|
|
201
|
-
contractAddress = _ref4.contractAddress;
|
|
202
|
-
metadata = _objectSpread({}, metadata, {
|
|
203
|
-
name: name,
|
|
204
|
-
description: description,
|
|
205
|
-
"public": {
|
|
206
|
-
name: name,
|
|
207
|
-
description: description
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
libraryId = this.utils.AddressToLibraryId(contractAddress);
|
|
211
|
-
this.Log("Library ID: ".concat(libraryId));
|
|
212
|
-
this.Log("Contract address: ".concat(contractAddress)); // Set library content object type and metadata on automatically created library object
|
|
213
|
-
|
|
214
|
-
objectId = libraryId.replace("ilib", "iq__");
|
|
215
|
-
_context2.next = 22;
|
|
216
|
-
return _regeneratorRuntime.awrap(this.EditContentObject({
|
|
217
|
-
libraryId: libraryId,
|
|
218
|
-
objectId: objectId,
|
|
219
|
-
options: {
|
|
220
|
-
type: "library"
|
|
221
|
-
}
|
|
222
|
-
}));
|
|
223
|
-
|
|
224
|
-
case 22:
|
|
225
|
-
editResponse = _context2.sent;
|
|
226
|
-
_context2.next = 25;
|
|
227
|
-
return _regeneratorRuntime.awrap(this.ReplaceMetadata({
|
|
228
|
-
libraryId: libraryId,
|
|
229
|
-
objectId: objectId,
|
|
230
|
-
metadata: metadata,
|
|
231
|
-
writeToken: editResponse.write_token
|
|
232
|
-
}));
|
|
233
|
-
|
|
234
|
-
case 25:
|
|
235
|
-
_context2.next = 27;
|
|
236
|
-
return _regeneratorRuntime.awrap(this.FinalizeContentObject({
|
|
237
|
-
libraryId: libraryId,
|
|
238
|
-
objectId: objectId,
|
|
239
|
-
writeToken: editResponse.write_token
|
|
240
|
-
}));
|
|
241
|
-
|
|
242
|
-
case 27:
|
|
243
|
-
if (!image) {
|
|
244
|
-
_context2.next = 30;
|
|
245
|
-
break;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
_context2.next = 30;
|
|
249
|
-
return _regeneratorRuntime.awrap(this.SetContentLibraryImage({
|
|
250
|
-
libraryId: libraryId,
|
|
251
|
-
image: image
|
|
252
|
-
}));
|
|
253
|
-
|
|
254
|
-
case 30:
|
|
255
|
-
this.Log("Library ".concat(libraryId, " created"));
|
|
256
|
-
return _context2.abrupt("return", libraryId);
|
|
257
|
-
|
|
258
|
-
case 32:
|
|
259
|
-
case "end":
|
|
260
|
-
return _context2.stop();
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}, null, this);
|
|
264
|
-
};
|
|
265
|
-
/**
|
|
266
|
-
* Set the image associated with this library
|
|
267
|
-
*
|
|
268
|
-
* @methodGroup Content Libraries
|
|
269
|
-
* @namedParams
|
|
270
|
-
* @param {string} libraryId - ID of the library
|
|
271
|
-
* @param {Blob | ArrayBuffer | Buffer} image - Image to upload
|
|
272
|
-
*/
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
exports.SetContentLibraryImage = function _callee3(_ref5) {
|
|
276
|
-
var libraryId, image, objectId;
|
|
277
|
-
return _regeneratorRuntime.async(function _callee3$(_context3) {
|
|
278
|
-
while (1) {
|
|
279
|
-
switch (_context3.prev = _context3.next) {
|
|
280
|
-
case 0:
|
|
281
|
-
libraryId = _ref5.libraryId, image = _ref5.image;
|
|
282
|
-
ValidateLibrary(libraryId);
|
|
283
|
-
objectId = libraryId.replace("ilib", "iq__");
|
|
284
|
-
return _context3.abrupt("return", this.SetContentObjectImage({
|
|
285
|
-
libraryId: libraryId,
|
|
286
|
-
objectId: objectId,
|
|
287
|
-
image: image
|
|
288
|
-
}));
|
|
289
|
-
|
|
290
|
-
case 4:
|
|
291
|
-
case "end":
|
|
292
|
-
return _context3.stop();
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}, null, this);
|
|
296
|
-
};
|
|
297
|
-
/**
|
|
298
|
-
* Set the image associated with this object
|
|
299
|
-
*
|
|
300
|
-
* Note: The content type of the object must support /rep/image
|
|
301
|
-
*
|
|
302
|
-
* @methodGroup Content Objects
|
|
303
|
-
* @namedParams
|
|
304
|
-
* @param {string} libraryId - ID of the library
|
|
305
|
-
* @param {string} objectId - ID of the object
|
|
306
|
-
* @param {Blob | ArrayBuffer | Buffer} image - Image to upload
|
|
307
|
-
*/
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
exports.SetContentObjectImage = function _callee4(_ref6) {
|
|
311
|
-
var libraryId, objectId, image, editResponse, uploadResponse;
|
|
312
|
-
return _regeneratorRuntime.async(function _callee4$(_context4) {
|
|
313
|
-
while (1) {
|
|
314
|
-
switch (_context4.prev = _context4.next) {
|
|
315
|
-
case 0:
|
|
316
|
-
libraryId = _ref6.libraryId, objectId = _ref6.objectId, image = _ref6.image;
|
|
317
|
-
ValidateParameters({
|
|
318
|
-
libraryId: libraryId,
|
|
319
|
-
objectId: objectId
|
|
320
|
-
});
|
|
321
|
-
_context4.next = 4;
|
|
322
|
-
return _regeneratorRuntime.awrap(this.EditContentObject({
|
|
323
|
-
libraryId: libraryId,
|
|
324
|
-
objectId: objectId
|
|
325
|
-
}));
|
|
326
|
-
|
|
327
|
-
case 4:
|
|
328
|
-
editResponse = _context4.sent;
|
|
329
|
-
_context4.next = 7;
|
|
330
|
-
return _regeneratorRuntime.awrap(this.UploadPart({
|
|
331
|
-
libraryId: libraryId,
|
|
332
|
-
objectId: objectId,
|
|
333
|
-
writeToken: editResponse.write_token,
|
|
334
|
-
data: image,
|
|
335
|
-
encrypted: false
|
|
336
|
-
}));
|
|
337
|
-
|
|
338
|
-
case 7:
|
|
339
|
-
uploadResponse = _context4.sent;
|
|
340
|
-
_context4.next = 10;
|
|
341
|
-
return _regeneratorRuntime.awrap(this.MergeMetadata({
|
|
342
|
-
libraryId: libraryId,
|
|
343
|
-
objectId: objectId,
|
|
344
|
-
writeToken: editResponse.write_token,
|
|
345
|
-
metadata: {
|
|
346
|
-
"image": uploadResponse.part.hash
|
|
347
|
-
}
|
|
348
|
-
}));
|
|
349
|
-
|
|
350
|
-
case 10:
|
|
351
|
-
_context4.next = 12;
|
|
352
|
-
return _regeneratorRuntime.awrap(this.MergeMetadata({
|
|
353
|
-
libraryId: libraryId,
|
|
354
|
-
objectId: objectId,
|
|
355
|
-
writeToken: editResponse.write_token,
|
|
356
|
-
metadataSubtree: "public",
|
|
357
|
-
metadata: {
|
|
358
|
-
"image": uploadResponse.part.hash
|
|
359
|
-
}
|
|
360
|
-
}));
|
|
361
|
-
|
|
362
|
-
case 12:
|
|
363
|
-
_context4.next = 14;
|
|
364
|
-
return _regeneratorRuntime.awrap(this.FinalizeContentObject({
|
|
365
|
-
libraryId: libraryId,
|
|
366
|
-
objectId: objectId,
|
|
367
|
-
writeToken: editResponse.write_token
|
|
368
|
-
}));
|
|
369
|
-
|
|
370
|
-
case 14:
|
|
371
|
-
case "end":
|
|
372
|
-
return _context4.stop();
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
}, null, this);
|
|
376
|
-
};
|
|
377
|
-
/**
|
|
378
|
-
* Delete the specified content library
|
|
379
|
-
*
|
|
380
|
-
* @methodGroup Content Libraries
|
|
381
|
-
*
|
|
382
|
-
* @namedParams
|
|
383
|
-
* @param {string} libraryId - ID of the library to delete
|
|
384
|
-
*/
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
exports.DeleteContentLibrary = function _callee5(_ref7) {
|
|
388
|
-
var libraryId, path, authorizationHeader;
|
|
389
|
-
return _regeneratorRuntime.async(function _callee5$(_context5) {
|
|
390
|
-
while (1) {
|
|
391
|
-
switch (_context5.prev = _context5.next) {
|
|
392
|
-
case 0:
|
|
393
|
-
libraryId = _ref7.libraryId;
|
|
394
|
-
ValidateLibrary(libraryId);
|
|
395
|
-
path = UrlJoin("qlibs", libraryId);
|
|
396
|
-
_context5.next = 5;
|
|
397
|
-
return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
|
|
398
|
-
libraryId: libraryId,
|
|
399
|
-
update: true
|
|
400
|
-
}));
|
|
401
|
-
|
|
402
|
-
case 5:
|
|
403
|
-
authorizationHeader = _context5.sent;
|
|
404
|
-
_context5.next = 8;
|
|
405
|
-
return _regeneratorRuntime.awrap(this.CallContractMethodAndWait({
|
|
406
|
-
contractAddress: Utils.HashToAddress(libraryId),
|
|
407
|
-
abi: LibraryContract.abi,
|
|
408
|
-
methodName: "kill",
|
|
409
|
-
methodArgs: []
|
|
410
|
-
}));
|
|
411
|
-
|
|
412
|
-
case 8:
|
|
413
|
-
_context5.next = 10;
|
|
414
|
-
return _regeneratorRuntime.awrap(this.HttpClient.Request({
|
|
415
|
-
headers: authorizationHeader,
|
|
416
|
-
method: "DELETE",
|
|
417
|
-
path: path
|
|
418
|
-
}));
|
|
419
|
-
|
|
420
|
-
case 10:
|
|
421
|
-
case "end":
|
|
422
|
-
return _context5.stop();
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
}, null, this);
|
|
426
|
-
};
|
|
427
|
-
/* Library Content Type Management */
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Add a specified content type to a library
|
|
431
|
-
*
|
|
432
|
-
* @methodGroup Content Libraries
|
|
433
|
-
* @namedParams
|
|
434
|
-
* @param {string} libraryId - ID of the library
|
|
435
|
-
* @param {string=} typeId - ID of the content type
|
|
436
|
-
* @param {string=} typeName - Name of the content type
|
|
437
|
-
* @param {string=} typeHash - Version hash of the content type
|
|
438
|
-
* @param {string=} customContractAddress - Address of the custom contract to associate with
|
|
439
|
-
* this content type for this library
|
|
440
|
-
*
|
|
441
|
-
* @returns {Promise<string>} - Hash of the addContentType transaction
|
|
442
|
-
*/
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
exports.AddLibraryContentType = function _callee6(_ref8) {
|
|
446
|
-
var libraryId, typeId, typeName, typeHash, customContractAddress, type, typeAddress, event;
|
|
447
|
-
return _regeneratorRuntime.async(function _callee6$(_context6) {
|
|
448
|
-
while (1) {
|
|
449
|
-
switch (_context6.prev = _context6.next) {
|
|
450
|
-
case 0:
|
|
451
|
-
libraryId = _ref8.libraryId, typeId = _ref8.typeId, typeName = _ref8.typeName, typeHash = _ref8.typeHash, customContractAddress = _ref8.customContractAddress;
|
|
452
|
-
ValidateLibrary(libraryId);
|
|
453
|
-
this.Log("Adding library content type to ".concat(libraryId, ": ").concat(typeId || typeHash || typeName));
|
|
454
|
-
|
|
455
|
-
if (typeHash) {
|
|
456
|
-
typeId = this.utils.DecodeVersionHash(typeHash).objectId;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
if (typeId) {
|
|
460
|
-
_context6.next = 9;
|
|
461
|
-
break;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
_context6.next = 7;
|
|
465
|
-
return _regeneratorRuntime.awrap(this.ContentType({
|
|
466
|
-
name: typeName
|
|
467
|
-
}));
|
|
468
|
-
|
|
469
|
-
case 7:
|
|
470
|
-
type = _context6.sent;
|
|
471
|
-
typeId = type.id;
|
|
472
|
-
|
|
473
|
-
case 9:
|
|
474
|
-
this.Log("Type ID: ".concat(typeId));
|
|
475
|
-
typeAddress = this.utils.HashToAddress(typeId);
|
|
476
|
-
customContractAddress = customContractAddress || this.utils.nullAddress;
|
|
477
|
-
_context6.next = 14;
|
|
478
|
-
return _regeneratorRuntime.awrap(this.ethClient.CallContractMethodAndWait({
|
|
479
|
-
contractAddress: Utils.HashToAddress(libraryId),
|
|
480
|
-
abi: LibraryContract.abi,
|
|
481
|
-
methodName: "addContentType",
|
|
482
|
-
methodArgs: [typeAddress, customContractAddress],
|
|
483
|
-
signer: this.signer
|
|
484
|
-
}));
|
|
485
|
-
|
|
486
|
-
case 14:
|
|
487
|
-
event = _context6.sent;
|
|
488
|
-
return _context6.abrupt("return", event.transactionHash);
|
|
489
|
-
|
|
490
|
-
case 16:
|
|
491
|
-
case "end":
|
|
492
|
-
return _context6.stop();
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
}, null, this);
|
|
496
|
-
};
|
|
497
|
-
/**
|
|
498
|
-
* Remove the specified content type from a library
|
|
499
|
-
*
|
|
500
|
-
* @methodGroup Content Libraries
|
|
501
|
-
* @namedParams
|
|
502
|
-
* @param {string} libraryId - ID of the library
|
|
503
|
-
* @param {string=} typeId - ID of the content type (required unless typeName is specified)
|
|
504
|
-
* @param {string=} typeName - Name of the content type (required unless typeId is specified)
|
|
505
|
-
* @param {string=} typeHash - Version hash of the content type
|
|
506
|
-
*
|
|
507
|
-
* @returns {Promise<string>} - Hash of the removeContentType transaction
|
|
508
|
-
*/
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
exports.RemoveLibraryContentType = function _callee7(_ref9) {
|
|
512
|
-
var libraryId, typeId, typeName, typeHash, type, typeAddress, event;
|
|
513
|
-
return _regeneratorRuntime.async(function _callee7$(_context7) {
|
|
514
|
-
while (1) {
|
|
515
|
-
switch (_context7.prev = _context7.next) {
|
|
516
|
-
case 0:
|
|
517
|
-
libraryId = _ref9.libraryId, typeId = _ref9.typeId, typeName = _ref9.typeName, typeHash = _ref9.typeHash;
|
|
518
|
-
ValidateLibrary(libraryId);
|
|
519
|
-
this.Log("Removing library content type from ".concat(libraryId, ": ").concat(typeId || typeHash || typeName));
|
|
520
|
-
|
|
521
|
-
if (typeHash) {
|
|
522
|
-
typeId = this.utils.DecodeVersionHash(typeHash).objectId;
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
if (typeId) {
|
|
526
|
-
_context7.next = 9;
|
|
527
|
-
break;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
_context7.next = 7;
|
|
531
|
-
return _regeneratorRuntime.awrap(this.ContentType({
|
|
532
|
-
name: typeName
|
|
533
|
-
}));
|
|
534
|
-
|
|
535
|
-
case 7:
|
|
536
|
-
type = _context7.sent;
|
|
537
|
-
typeId = type.id;
|
|
538
|
-
|
|
539
|
-
case 9:
|
|
540
|
-
this.Log("Type ID: ".concat(typeId));
|
|
541
|
-
typeAddress = this.utils.HashToAddress(typeId);
|
|
542
|
-
_context7.next = 13;
|
|
543
|
-
return _regeneratorRuntime.awrap(this.ethClient.CallContractMethodAndWait({
|
|
544
|
-
contractAddress: Utils.HashToAddress(libraryId),
|
|
545
|
-
abi: LibraryContract.abi,
|
|
546
|
-
methodName: "removeContentType",
|
|
547
|
-
methodArgs: [typeAddress],
|
|
548
|
-
signer: this.signer
|
|
549
|
-
}));
|
|
550
|
-
|
|
551
|
-
case 13:
|
|
552
|
-
event = _context7.sent;
|
|
553
|
-
return _context7.abrupt("return", event.transactionHash);
|
|
554
|
-
|
|
555
|
-
case 15:
|
|
556
|
-
case "end":
|
|
557
|
-
return _context7.stop();
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
}, null, this);
|
|
561
|
-
};
|
|
562
|
-
/* Content object creation, modification, deletion */
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* Create a new content object draft.
|
|
566
|
-
*
|
|
567
|
-
* A new content object contract is deployed from
|
|
568
|
-
* the content library, and that contract ID is used to determine the object ID to
|
|
569
|
-
* create in the fabric.
|
|
570
|
-
*
|
|
571
|
-
* @methodGroup Content Objects
|
|
572
|
-
* @namedParams
|
|
573
|
-
* @param {string} libraryId - ID of the library
|
|
574
|
-
* @param {string=} objectId - ID of the object (if contract already exists)
|
|
575
|
-
* @param {Object=} options -
|
|
576
|
-
* type: Version hash of the content type to associate with the object
|
|
577
|
-
*
|
|
578
|
-
* meta: Metadata to use for the new object
|
|
579
|
-
*
|
|
580
|
-
* @returns {Promise<Object>} - Response containing the object ID and write token of the draft
|
|
581
|
-
*/
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
exports.CreateContentObject = function _callee8(_ref10) {
|
|
585
|
-
var libraryId, objectId, _ref10$options, options, typeId, type, _ref11, contractAddress, path;
|
|
586
|
-
|
|
587
|
-
return _regeneratorRuntime.async(function _callee8$(_context8) {
|
|
588
|
-
while (1) {
|
|
589
|
-
switch (_context8.prev = _context8.next) {
|
|
590
|
-
case 0:
|
|
591
|
-
libraryId = _ref10.libraryId, objectId = _ref10.objectId, _ref10$options = _ref10.options, options = _ref10$options === void 0 ? {} : _ref10$options;
|
|
592
|
-
ValidateLibrary(libraryId);
|
|
593
|
-
|
|
594
|
-
if (objectId) {
|
|
595
|
-
ValidateObject(objectId);
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
this.Log("Creating content object: ".concat(libraryId, " ").concat(objectId || "")); // Look up content type, if specified
|
|
599
|
-
|
|
600
|
-
if (!options.type) {
|
|
601
|
-
_context8.next = 26;
|
|
602
|
-
break;
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
this.Log("Type specified: ".concat(options.type));
|
|
606
|
-
type = options.type;
|
|
607
|
-
|
|
608
|
-
if (!type.startsWith("hq__")) {
|
|
609
|
-
_context8.next = 13;
|
|
610
|
-
break;
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
_context8.next = 10;
|
|
614
|
-
return _regeneratorRuntime.awrap(this.ContentType({
|
|
615
|
-
versionHash: type
|
|
616
|
-
}));
|
|
617
|
-
|
|
618
|
-
case 10:
|
|
619
|
-
type = _context8.sent;
|
|
620
|
-
_context8.next = 22;
|
|
621
|
-
break;
|
|
622
|
-
|
|
623
|
-
case 13:
|
|
624
|
-
if (!type.startsWith("iq__")) {
|
|
625
|
-
_context8.next = 19;
|
|
626
|
-
break;
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
_context8.next = 16;
|
|
630
|
-
return _regeneratorRuntime.awrap(this.ContentType({
|
|
631
|
-
typeId: type
|
|
632
|
-
}));
|
|
633
|
-
|
|
634
|
-
case 16:
|
|
635
|
-
type = _context8.sent;
|
|
636
|
-
_context8.next = 22;
|
|
637
|
-
break;
|
|
638
|
-
|
|
639
|
-
case 19:
|
|
640
|
-
_context8.next = 21;
|
|
641
|
-
return _regeneratorRuntime.awrap(this.ContentType({
|
|
642
|
-
name: type
|
|
643
|
-
}));
|
|
644
|
-
|
|
645
|
-
case 21:
|
|
646
|
-
type = _context8.sent;
|
|
647
|
-
|
|
648
|
-
case 22:
|
|
649
|
-
if (type) {
|
|
650
|
-
_context8.next = 24;
|
|
651
|
-
break;
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
throw Error("Unable to find content type '".concat(options.type, "'"));
|
|
655
|
-
|
|
656
|
-
case 24:
|
|
657
|
-
typeId = type.id;
|
|
658
|
-
options.type = type.hash;
|
|
659
|
-
|
|
660
|
-
case 26:
|
|
661
|
-
if (objectId) {
|
|
662
|
-
_context8.next = 36;
|
|
663
|
-
break;
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
this.Log("Deploying contract...");
|
|
667
|
-
_context8.next = 30;
|
|
668
|
-
return _regeneratorRuntime.awrap(this.authClient.CreateContentObject({
|
|
669
|
-
libraryId: libraryId,
|
|
670
|
-
typeId: typeId
|
|
671
|
-
}));
|
|
672
|
-
|
|
673
|
-
case 30:
|
|
674
|
-
_ref11 = _context8.sent;
|
|
675
|
-
contractAddress = _ref11.contractAddress;
|
|
676
|
-
objectId = this.utils.AddressToObjectId(contractAddress);
|
|
677
|
-
this.Log("Contract deployed: ".concat(contractAddress, " ").concat(objectId));
|
|
678
|
-
_context8.next = 43;
|
|
679
|
-
break;
|
|
680
|
-
|
|
681
|
-
case 36:
|
|
682
|
-
_context8.t0 = this;
|
|
683
|
-
_context8.t1 = "Contract already deployed for contract type: ";
|
|
684
|
-
_context8.next = 40;
|
|
685
|
-
return _regeneratorRuntime.awrap(this.AccessType({
|
|
686
|
-
id: objectId
|
|
687
|
-
}));
|
|
688
|
-
|
|
689
|
-
case 40:
|
|
690
|
-
_context8.t2 = _context8.sent;
|
|
691
|
-
_context8.t3 = _context8.t1.concat.call(_context8.t1, _context8.t2);
|
|
692
|
-
|
|
693
|
-
_context8.t0.Log.call(_context8.t0, _context8.t3);
|
|
694
|
-
|
|
695
|
-
case 43:
|
|
696
|
-
if (!options.visibility) {
|
|
697
|
-
_context8.next = 47;
|
|
698
|
-
break;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
this.Log("Setting visibility to ".concat(options.visibility));
|
|
702
|
-
_context8.next = 47;
|
|
703
|
-
return _regeneratorRuntime.awrap(this.CallContractMethod({
|
|
704
|
-
abi: ContentContract.abi,
|
|
705
|
-
contractAddress: this.utils.HashToAddress(objectId),
|
|
706
|
-
methodName: "setVisibility",
|
|
707
|
-
methodArgs: [options.visibility]
|
|
708
|
-
}));
|
|
709
|
-
|
|
710
|
-
case 47:
|
|
711
|
-
path = UrlJoin("qid", objectId);
|
|
712
|
-
_context8.t4 = _regeneratorRuntime;
|
|
713
|
-
_context8.t5 = this.utils;
|
|
714
|
-
_context8.t6 = this.HttpClient;
|
|
715
|
-
_context8.next = 53;
|
|
716
|
-
return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
|
|
717
|
-
libraryId: libraryId,
|
|
718
|
-
objectId: objectId,
|
|
719
|
-
update: true
|
|
720
|
-
}));
|
|
721
|
-
|
|
722
|
-
case 53:
|
|
723
|
-
_context8.t7 = _context8.sent;
|
|
724
|
-
_context8.t8 = path;
|
|
725
|
-
_context8.t9 = options;
|
|
726
|
-
_context8.t10 = {
|
|
727
|
-
headers: _context8.t7,
|
|
728
|
-
method: "POST",
|
|
729
|
-
path: _context8.t8,
|
|
730
|
-
body: _context8.t9,
|
|
731
|
-
failover: false
|
|
732
|
-
};
|
|
733
|
-
_context8.t11 = _context8.t6.Request.call(_context8.t6, _context8.t10);
|
|
734
|
-
_context8.t12 = _context8.t5.ResponseToJson.call(_context8.t5, _context8.t11);
|
|
735
|
-
_context8.next = 61;
|
|
736
|
-
return _context8.t4.awrap.call(_context8.t4, _context8.t12);
|
|
737
|
-
|
|
738
|
-
case 61:
|
|
739
|
-
return _context8.abrupt("return", _context8.sent);
|
|
740
|
-
|
|
741
|
-
case 62:
|
|
742
|
-
case "end":
|
|
743
|
-
return _context8.stop();
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
}, null, this);
|
|
747
|
-
};
|
|
748
|
-
/**
|
|
749
|
-
* Create a new content object draft from an existing content object version.
|
|
750
|
-
*
|
|
751
|
-
* Note: The type of the new copy can be different from the original object.
|
|
752
|
-
*
|
|
753
|
-
* @see <a href="#CreateContentObject">CreateContentObject</a>
|
|
754
|
-
*
|
|
755
|
-
* @methodGroup Content Objects
|
|
756
|
-
* @namedParams
|
|
757
|
-
* @param {string} libraryId - ID of the library in which to create the new object
|
|
758
|
-
* @param originalVersionHash - Version hash of the object to copy
|
|
759
|
-
* @param {Object=} options -
|
|
760
|
-
* type: Version hash of the content type to associate with the object - may be different from the original object
|
|
761
|
-
*
|
|
762
|
-
* meta: Metadata to use for the new object - This will be merged into the metadata of the original object
|
|
763
|
-
*
|
|
764
|
-
* @returns {Promise<Object>} - Response containing the object ID and write token of the draft
|
|
765
|
-
*/
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
exports.CopyContentObject = function _callee9(_ref12) {
|
|
769
|
-
var libraryId, originalVersionHash, _ref12$options, options;
|
|
770
|
-
|
|
771
|
-
return _regeneratorRuntime.async(function _callee9$(_context9) {
|
|
772
|
-
while (1) {
|
|
773
|
-
switch (_context9.prev = _context9.next) {
|
|
774
|
-
case 0:
|
|
775
|
-
libraryId = _ref12.libraryId, originalVersionHash = _ref12.originalVersionHash, _ref12$options = _ref12.options, options = _ref12$options === void 0 ? {} : _ref12$options;
|
|
776
|
-
ValidateLibrary(libraryId);
|
|
777
|
-
ValidateVersion(originalVersionHash);
|
|
778
|
-
options.copy_from = originalVersionHash;
|
|
779
|
-
_context9.next = 6;
|
|
780
|
-
return _regeneratorRuntime.awrap(this.CreateContentObject({
|
|
781
|
-
libraryId: libraryId,
|
|
782
|
-
options: options
|
|
783
|
-
}));
|
|
784
|
-
|
|
785
|
-
case 6:
|
|
786
|
-
return _context9.abrupt("return", _context9.sent);
|
|
787
|
-
|
|
788
|
-
case 7:
|
|
789
|
-
case "end":
|
|
790
|
-
return _context9.stop();
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
}, null, this);
|
|
794
|
-
};
|
|
795
|
-
/**
|
|
796
|
-
* Create a new content object draft from an existing object.
|
|
797
|
-
*
|
|
798
|
-
* @methodGroup Content Objects
|
|
799
|
-
* @namedParams
|
|
800
|
-
* @param {string} libraryId - ID of the library
|
|
801
|
-
* @param {string} objectId - ID of the object
|
|
802
|
-
* @param {object=} options -
|
|
803
|
-
* meta: New metadata for the object - will be merged into existing metadata if specified
|
|
804
|
-
* type: New type for the object - Object ID, version hash or name of type
|
|
805
|
-
*
|
|
806
|
-
* @returns {Promise<object>} - Response containing the object ID and write token of the draft
|
|
807
|
-
*/
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
exports.EditContentObject = function _callee10(_ref13) {
|
|
811
|
-
var libraryId, objectId, _ref13$options, options, path;
|
|
812
|
-
|
|
813
|
-
return _regeneratorRuntime.async(function _callee10$(_context10) {
|
|
814
|
-
while (1) {
|
|
815
|
-
switch (_context10.prev = _context10.next) {
|
|
816
|
-
case 0:
|
|
817
|
-
libraryId = _ref13.libraryId, objectId = _ref13.objectId, _ref13$options = _ref13.options, options = _ref13$options === void 0 ? {} : _ref13$options;
|
|
818
|
-
ValidateParameters({
|
|
819
|
-
libraryId: libraryId,
|
|
820
|
-
objectId: objectId
|
|
821
|
-
});
|
|
822
|
-
this.Log("Opening content draft: ".concat(libraryId, " ").concat(objectId));
|
|
823
|
-
|
|
824
|
-
if (!options.type) {
|
|
825
|
-
_context10.next = 19;
|
|
826
|
-
break;
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
if (!options.type.startsWith("hq__")) {
|
|
830
|
-
_context10.next = 10;
|
|
831
|
-
break;
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
_context10.next = 7;
|
|
835
|
-
return _regeneratorRuntime.awrap(this.ContentType({
|
|
836
|
-
versionHash: options.type
|
|
837
|
-
}));
|
|
838
|
-
|
|
839
|
-
case 7:
|
|
840
|
-
options.type = _context10.sent.hash;
|
|
841
|
-
_context10.next = 19;
|
|
842
|
-
break;
|
|
843
|
-
|
|
844
|
-
case 10:
|
|
845
|
-
if (!options.type.startsWith("iq__")) {
|
|
846
|
-
_context10.next = 16;
|
|
847
|
-
break;
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
_context10.next = 13;
|
|
851
|
-
return _regeneratorRuntime.awrap(this.ContentType({
|
|
852
|
-
typeId: options.type
|
|
853
|
-
}));
|
|
854
|
-
|
|
855
|
-
case 13:
|
|
856
|
-
options.type = _context10.sent.hash;
|
|
857
|
-
_context10.next = 19;
|
|
858
|
-
break;
|
|
859
|
-
|
|
860
|
-
case 16:
|
|
861
|
-
_context10.next = 18;
|
|
862
|
-
return _regeneratorRuntime.awrap(this.ContentType({
|
|
863
|
-
name: options.type
|
|
864
|
-
}));
|
|
865
|
-
|
|
866
|
-
case 18:
|
|
867
|
-
options.type = _context10.sent.hash;
|
|
868
|
-
|
|
869
|
-
case 19:
|
|
870
|
-
path = UrlJoin("qid", objectId);
|
|
871
|
-
_context10.t0 = this.utils;
|
|
872
|
-
_context10.t1 = this.HttpClient;
|
|
873
|
-
_context10.next = 24;
|
|
874
|
-
return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
|
|
875
|
-
libraryId: libraryId,
|
|
876
|
-
objectId: objectId,
|
|
877
|
-
update: true
|
|
878
|
-
}));
|
|
879
|
-
|
|
880
|
-
case 24:
|
|
881
|
-
_context10.t2 = _context10.sent;
|
|
882
|
-
_context10.t3 = path;
|
|
883
|
-
_context10.t4 = options;
|
|
884
|
-
_context10.t5 = {
|
|
885
|
-
headers: _context10.t2,
|
|
886
|
-
method: "POST",
|
|
887
|
-
path: _context10.t3,
|
|
888
|
-
body: _context10.t4,
|
|
889
|
-
failover: false
|
|
890
|
-
};
|
|
891
|
-
_context10.t6 = _context10.t1.Request.call(_context10.t1, _context10.t5);
|
|
892
|
-
return _context10.abrupt("return", _context10.t0.ResponseToJson.call(_context10.t0, _context10.t6));
|
|
893
|
-
|
|
894
|
-
case 30:
|
|
895
|
-
case "end":
|
|
896
|
-
return _context10.stop();
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
}, null, this);
|
|
900
|
-
};
|
|
901
|
-
/**
|
|
902
|
-
* Finalize content draft
|
|
903
|
-
*
|
|
904
|
-
* @methodGroup Content Objects
|
|
905
|
-
* @namedParams
|
|
906
|
-
* @param {string} libraryId - ID of the library
|
|
907
|
-
* @param {string} objectId - ID of the object
|
|
908
|
-
* @param {string} writeToken - Write token of the draft
|
|
909
|
-
* @param {boolean=} publish=true - If specified, the object will also be published
|
|
910
|
-
* @param {boolean=} awaitCommitConfirmation=true - If specified, will wait for the publish commit to be confirmed.
|
|
911
|
-
* Irrelevant if not publishing.
|
|
912
|
-
*/
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
exports.FinalizeContentObject = function _callee11(_ref14) {
|
|
916
|
-
var libraryId, objectId, writeToken, _ref14$publish, publish, _ref14$awaitCommitCon, awaitCommitConfirmation, path, finalizeResponse;
|
|
917
|
-
|
|
918
|
-
return _regeneratorRuntime.async(function _callee11$(_context11) {
|
|
919
|
-
while (1) {
|
|
920
|
-
switch (_context11.prev = _context11.next) {
|
|
921
|
-
case 0:
|
|
922
|
-
libraryId = _ref14.libraryId, objectId = _ref14.objectId, writeToken = _ref14.writeToken, _ref14$publish = _ref14.publish, publish = _ref14$publish === void 0 ? true : _ref14$publish, _ref14$awaitCommitCon = _ref14.awaitCommitConfirmation, awaitCommitConfirmation = _ref14$awaitCommitCon === void 0 ? true : _ref14$awaitCommitCon;
|
|
923
|
-
ValidateParameters({
|
|
924
|
-
libraryId: libraryId,
|
|
925
|
-
objectId: objectId
|
|
926
|
-
});
|
|
927
|
-
ValidateWriteToken(writeToken);
|
|
928
|
-
this.Log("Finalizing content draft: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
929
|
-
path = UrlJoin("q", writeToken);
|
|
930
|
-
_context11.t0 = _regeneratorRuntime;
|
|
931
|
-
_context11.t1 = this.utils;
|
|
932
|
-
_context11.t2 = this.HttpClient;
|
|
933
|
-
_context11.next = 10;
|
|
934
|
-
return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
|
|
935
|
-
libraryId: libraryId,
|
|
936
|
-
objectId: objectId,
|
|
937
|
-
update: true
|
|
938
|
-
}));
|
|
939
|
-
|
|
940
|
-
case 10:
|
|
941
|
-
_context11.t3 = _context11.sent;
|
|
942
|
-
_context11.t4 = path;
|
|
943
|
-
_context11.t5 = {
|
|
944
|
-
headers: _context11.t3,
|
|
945
|
-
method: "POST",
|
|
946
|
-
path: _context11.t4,
|
|
947
|
-
failover: false
|
|
948
|
-
};
|
|
949
|
-
_context11.t6 = _context11.t2.Request.call(_context11.t2, _context11.t5);
|
|
950
|
-
_context11.t7 = _context11.t1.ResponseToJson.call(_context11.t1, _context11.t6);
|
|
951
|
-
_context11.next = 17;
|
|
952
|
-
return _context11.t0.awrap.call(_context11.t0, _context11.t7);
|
|
953
|
-
|
|
954
|
-
case 17:
|
|
955
|
-
finalizeResponse = _context11.sent;
|
|
956
|
-
this.Log("Finalized: ".concat(finalizeResponse.hash));
|
|
957
|
-
|
|
958
|
-
if (!publish) {
|
|
959
|
-
_context11.next = 22;
|
|
960
|
-
break;
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
_context11.next = 22;
|
|
964
|
-
return _regeneratorRuntime.awrap(this.PublishContentVersion({
|
|
965
|
-
objectId: objectId,
|
|
966
|
-
versionHash: finalizeResponse.hash,
|
|
967
|
-
awaitCommitConfirmation: awaitCommitConfirmation
|
|
968
|
-
}));
|
|
969
|
-
|
|
970
|
-
case 22:
|
|
971
|
-
// Invalidate cached content type, if this is one.
|
|
972
|
-
delete this.contentTypes[objectId];
|
|
973
|
-
return _context11.abrupt("return", finalizeResponse);
|
|
974
|
-
|
|
975
|
-
case 24:
|
|
976
|
-
case "end":
|
|
977
|
-
return _context11.stop();
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
}, null, this);
|
|
981
|
-
};
|
|
982
|
-
/**
|
|
983
|
-
* Publish a previously finalized content object version
|
|
984
|
-
*
|
|
985
|
-
* @methodGroup Content Objects
|
|
986
|
-
* @namedParams
|
|
987
|
-
* @param {string} libraryId - ID of the library
|
|
988
|
-
* @param {string} objectId - ID of the object
|
|
989
|
-
* @param {string} versionHash - The version hash of the content object to publish
|
|
990
|
-
* @param {boolean=} awaitCommitConfirmation=true - If specified, will wait for the publish commit to be confirmed.
|
|
991
|
-
*/
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
exports.PublishContentVersion = function _callee12(_ref15) {
|
|
995
|
-
var objectId, versionHash, _ref15$awaitCommitCon, awaitCommitConfirmation;
|
|
996
|
-
|
|
997
|
-
return _regeneratorRuntime.async(function _callee12$(_context12) {
|
|
998
|
-
while (1) {
|
|
999
|
-
switch (_context12.prev = _context12.next) {
|
|
1000
|
-
case 0:
|
|
1001
|
-
objectId = _ref15.objectId, versionHash = _ref15.versionHash, _ref15$awaitCommitCon = _ref15.awaitCommitConfirmation, awaitCommitConfirmation = _ref15$awaitCommitCon === void 0 ? true : _ref15$awaitCommitCon;
|
|
1002
|
-
versionHash ? ValidateVersion(versionHash) : ValidateObject(objectId);
|
|
1003
|
-
this.Log("Publishing: ".concat(objectId || versionHash));
|
|
1004
|
-
|
|
1005
|
-
if (versionHash) {
|
|
1006
|
-
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
_context12.next = 6;
|
|
1010
|
-
return _regeneratorRuntime.awrap(this.ethClient.CommitContent({
|
|
1011
|
-
contentObjectAddress: this.utils.HashToAddress(objectId),
|
|
1012
|
-
versionHash: versionHash,
|
|
1013
|
-
signer: this.signer
|
|
1014
|
-
}));
|
|
1015
|
-
|
|
1016
|
-
case 6:
|
|
1017
|
-
if (!awaitCommitConfirmation) {
|
|
1018
|
-
_context12.next = 10;
|
|
1019
|
-
break;
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
this.Log("Awaiting commit confirmation...");
|
|
1023
|
-
_context12.next = 10;
|
|
1024
|
-
return _regeneratorRuntime.awrap(this.ethClient.AwaitEvent({
|
|
1025
|
-
contractAddress: this.utils.HashToAddress(objectId),
|
|
1026
|
-
abi: ContentContract.abi,
|
|
1027
|
-
eventName: "VersionConfirm",
|
|
1028
|
-
signer: this.signer
|
|
1029
|
-
}));
|
|
1030
|
-
|
|
1031
|
-
case 10:
|
|
1032
|
-
case "end":
|
|
1033
|
-
return _context12.stop();
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
}, null, this);
|
|
1037
|
-
};
|
|
1038
|
-
/**
|
|
1039
|
-
* Delete specified version of the content object
|
|
1040
|
-
*
|
|
1041
|
-
* @methodGroup Content Objects
|
|
1042
|
-
* @namedParams
|
|
1043
|
-
* @param {string=} versionHash - Hash of the object version - if not specified, most recent version will be deleted
|
|
1044
|
-
*/
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
exports.DeleteContentVersion = function _callee13(_ref16) {
|
|
1048
|
-
var versionHash, _this$utils$DecodeVer, objectId;
|
|
1049
|
-
|
|
1050
|
-
return _regeneratorRuntime.async(function _callee13$(_context13) {
|
|
1051
|
-
while (1) {
|
|
1052
|
-
switch (_context13.prev = _context13.next) {
|
|
1053
|
-
case 0:
|
|
1054
|
-
versionHash = _ref16.versionHash;
|
|
1055
|
-
ValidateVersion(versionHash);
|
|
1056
|
-
this.Log("Deleting content version: ".concat(versionHash));
|
|
1057
|
-
_this$utils$DecodeVer = this.utils.DecodeVersionHash(versionHash), objectId = _this$utils$DecodeVer.objectId;
|
|
1058
|
-
_context13.next = 6;
|
|
1059
|
-
return _regeneratorRuntime.awrap(this.CallContractMethodAndWait({
|
|
1060
|
-
contractAddress: this.utils.HashToAddress(objectId),
|
|
1061
|
-
abi: ContentContract.abi,
|
|
1062
|
-
methodName: "deleteVersion",
|
|
1063
|
-
methodArgs: [versionHash]
|
|
1064
|
-
}));
|
|
1065
|
-
|
|
1066
|
-
case 6:
|
|
1067
|
-
case "end":
|
|
1068
|
-
return _context13.stop();
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
}, null, this);
|
|
1072
|
-
};
|
|
1073
|
-
/**
|
|
1074
|
-
* Delete specified content object
|
|
1075
|
-
*
|
|
1076
|
-
* @methodGroup Content Objects
|
|
1077
|
-
* @namedParams
|
|
1078
|
-
* @param {string} libraryId - ID of the library
|
|
1079
|
-
* @param {string} objectId - ID of the object
|
|
1080
|
-
*/
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
exports.DeleteContentObject = function _callee14(_ref17) {
|
|
1084
|
-
var libraryId, objectId;
|
|
1085
|
-
return _regeneratorRuntime.async(function _callee14$(_context14) {
|
|
1086
|
-
while (1) {
|
|
1087
|
-
switch (_context14.prev = _context14.next) {
|
|
1088
|
-
case 0:
|
|
1089
|
-
libraryId = _ref17.libraryId, objectId = _ref17.objectId;
|
|
1090
|
-
ValidateParameters({
|
|
1091
|
-
libraryId: libraryId,
|
|
1092
|
-
objectId: objectId
|
|
1093
|
-
});
|
|
1094
|
-
this.Log("Deleting content version: ".concat(libraryId, " ").concat(objectId));
|
|
1095
|
-
_context14.next = 5;
|
|
1096
|
-
return _regeneratorRuntime.awrap(this.CallContractMethodAndWait({
|
|
1097
|
-
contractAddress: Utils.HashToAddress(libraryId),
|
|
1098
|
-
abi: LibraryContract.abi,
|
|
1099
|
-
methodName: "deleteContent",
|
|
1100
|
-
methodArgs: [this.utils.HashToAddress(objectId)]
|
|
1101
|
-
}));
|
|
1102
|
-
|
|
1103
|
-
case 5:
|
|
1104
|
-
case "end":
|
|
1105
|
-
return _context14.stop();
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
}, null, this);
|
|
1109
|
-
};
|
|
1110
|
-
/* Content object metadata */
|
|
1111
|
-
|
|
1112
|
-
/**
|
|
1113
|
-
* Merge specified metadata into existing content object metadata
|
|
1114
|
-
*
|
|
1115
|
-
* @methodGroup Metadata
|
|
1116
|
-
* @namedParams
|
|
1117
|
-
* @param {string} libraryId - ID of the library
|
|
1118
|
-
* @param {string} objectId - ID of the object
|
|
1119
|
-
* @param {string} writeToken - Write token of the draft
|
|
1120
|
-
* @param {Object} metadata - New metadata to merge
|
|
1121
|
-
* @param {string=} metadataSubtree - Subtree of the object metadata to modify
|
|
1122
|
-
*/
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
exports.MergeMetadata = function _callee15(_ref18) {
|
|
1126
|
-
var libraryId, objectId, writeToken, _ref18$metadataSubtre, metadataSubtree, _ref18$metadata, metadata, path;
|
|
1127
|
-
|
|
1128
|
-
return _regeneratorRuntime.async(function _callee15$(_context15) {
|
|
1129
|
-
while (1) {
|
|
1130
|
-
switch (_context15.prev = _context15.next) {
|
|
1131
|
-
case 0:
|
|
1132
|
-
libraryId = _ref18.libraryId, objectId = _ref18.objectId, writeToken = _ref18.writeToken, _ref18$metadataSubtre = _ref18.metadataSubtree, metadataSubtree = _ref18$metadataSubtre === void 0 ? "/" : _ref18$metadataSubtre, _ref18$metadata = _ref18.metadata, metadata = _ref18$metadata === void 0 ? {} : _ref18$metadata;
|
|
1133
|
-
ValidateParameters({
|
|
1134
|
-
libraryId: libraryId,
|
|
1135
|
-
objectId: objectId
|
|
1136
|
-
});
|
|
1137
|
-
ValidateWriteToken(writeToken);
|
|
1138
|
-
this.Log("Merging metadata: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken, "\n Subtree: ").concat(metadataSubtree));
|
|
1139
|
-
this.Log(metadata);
|
|
1140
|
-
path = UrlJoin("q", writeToken, "meta", metadataSubtree);
|
|
1141
|
-
_context15.t0 = _regeneratorRuntime;
|
|
1142
|
-
_context15.t1 = this.HttpClient;
|
|
1143
|
-
_context15.next = 10;
|
|
1144
|
-
return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
|
|
1145
|
-
libraryId: libraryId,
|
|
1146
|
-
objectId: objectId,
|
|
1147
|
-
update: true
|
|
1148
|
-
}));
|
|
1149
|
-
|
|
1150
|
-
case 10:
|
|
1151
|
-
_context15.t2 = _context15.sent;
|
|
1152
|
-
_context15.t3 = path;
|
|
1153
|
-
_context15.t4 = metadata;
|
|
1154
|
-
_context15.t5 = {
|
|
1155
|
-
headers: _context15.t2,
|
|
1156
|
-
method: "POST",
|
|
1157
|
-
path: _context15.t3,
|
|
1158
|
-
body: _context15.t4,
|
|
1159
|
-
failover: false
|
|
1160
|
-
};
|
|
1161
|
-
_context15.t6 = _context15.t1.Request.call(_context15.t1, _context15.t5);
|
|
1162
|
-
_context15.next = 17;
|
|
1163
|
-
return _context15.t0.awrap.call(_context15.t0, _context15.t6);
|
|
1164
|
-
|
|
1165
|
-
case 17:
|
|
1166
|
-
case "end":
|
|
1167
|
-
return _context15.stop();
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
}, null, this);
|
|
1171
|
-
};
|
|
1172
|
-
/**
|
|
1173
|
-
* Replace content object metadata with specified metadata
|
|
1174
|
-
*
|
|
1175
|
-
* @methodGroup Metadata
|
|
1176
|
-
* @namedParams
|
|
1177
|
-
* @param {string} libraryId - ID of the library
|
|
1178
|
-
* @param {string} objectId - ID of the object
|
|
1179
|
-
* @param {string} writeToken - Write token of the draft
|
|
1180
|
-
* @param {Object} metadata - New metadata to merge
|
|
1181
|
-
* @param {string=} metadataSubtree - Subtree of the object metadata to modify
|
|
1182
|
-
*/
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
exports.ReplaceMetadata = function _callee16(_ref19) {
|
|
1186
|
-
var libraryId, objectId, writeToken, _ref19$metadataSubtre, metadataSubtree, _ref19$metadata, metadata, path;
|
|
1187
|
-
|
|
1188
|
-
return _regeneratorRuntime.async(function _callee16$(_context16) {
|
|
1189
|
-
while (1) {
|
|
1190
|
-
switch (_context16.prev = _context16.next) {
|
|
1191
|
-
case 0:
|
|
1192
|
-
libraryId = _ref19.libraryId, objectId = _ref19.objectId, writeToken = _ref19.writeToken, _ref19$metadataSubtre = _ref19.metadataSubtree, metadataSubtree = _ref19$metadataSubtre === void 0 ? "/" : _ref19$metadataSubtre, _ref19$metadata = _ref19.metadata, metadata = _ref19$metadata === void 0 ? {} : _ref19$metadata;
|
|
1193
|
-
ValidateParameters({
|
|
1194
|
-
libraryId: libraryId,
|
|
1195
|
-
objectId: objectId
|
|
1196
|
-
});
|
|
1197
|
-
ValidateWriteToken(writeToken);
|
|
1198
|
-
this.Log("Replacing metadata: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken, "\n Subtree: ").concat(metadataSubtree));
|
|
1199
|
-
this.Log(metadata);
|
|
1200
|
-
path = UrlJoin("q", writeToken, "meta", metadataSubtree);
|
|
1201
|
-
_context16.t0 = _regeneratorRuntime;
|
|
1202
|
-
_context16.t1 = this.HttpClient;
|
|
1203
|
-
_context16.next = 10;
|
|
1204
|
-
return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
|
|
1205
|
-
libraryId: libraryId,
|
|
1206
|
-
objectId: objectId,
|
|
1207
|
-
update: true
|
|
1208
|
-
}));
|
|
1209
|
-
|
|
1210
|
-
case 10:
|
|
1211
|
-
_context16.t2 = _context16.sent;
|
|
1212
|
-
_context16.t3 = path;
|
|
1213
|
-
_context16.t4 = metadata;
|
|
1214
|
-
_context16.t5 = {
|
|
1215
|
-
headers: _context16.t2,
|
|
1216
|
-
method: "PUT",
|
|
1217
|
-
path: _context16.t3,
|
|
1218
|
-
body: _context16.t4,
|
|
1219
|
-
failover: false
|
|
1220
|
-
};
|
|
1221
|
-
_context16.t6 = _context16.t1.Request.call(_context16.t1, _context16.t5);
|
|
1222
|
-
_context16.next = 17;
|
|
1223
|
-
return _context16.t0.awrap.call(_context16.t0, _context16.t6);
|
|
1224
|
-
|
|
1225
|
-
case 17:
|
|
1226
|
-
case "end":
|
|
1227
|
-
return _context16.stop();
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
}, null, this);
|
|
1231
|
-
};
|
|
1232
|
-
/**
|
|
1233
|
-
* Delete content object metadata of specified subtree
|
|
1234
|
-
*
|
|
1235
|
-
* @methodGroup Metadata
|
|
1236
|
-
* @namedParams
|
|
1237
|
-
* @param {string} libraryId - ID of the library
|
|
1238
|
-
* @param {string} objectId - ID of the object
|
|
1239
|
-
* @param {string} writeToken - Write token of the draft
|
|
1240
|
-
* @param {string=} metadataSubtree - Subtree of the object metadata to modify
|
|
1241
|
-
* - if not specified, all metadata will be deleted
|
|
1242
|
-
*/
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
exports.DeleteMetadata = function _callee17(_ref20) {
|
|
1246
|
-
var libraryId, objectId, writeToken, _ref20$metadataSubtre, metadataSubtree, path;
|
|
1247
|
-
|
|
1248
|
-
return _regeneratorRuntime.async(function _callee17$(_context17) {
|
|
1249
|
-
while (1) {
|
|
1250
|
-
switch (_context17.prev = _context17.next) {
|
|
1251
|
-
case 0:
|
|
1252
|
-
libraryId = _ref20.libraryId, objectId = _ref20.objectId, writeToken = _ref20.writeToken, _ref20$metadataSubtre = _ref20.metadataSubtree, metadataSubtree = _ref20$metadataSubtre === void 0 ? "/" : _ref20$metadataSubtre;
|
|
1253
|
-
ValidateParameters({
|
|
1254
|
-
libraryId: libraryId,
|
|
1255
|
-
objectId: objectId
|
|
1256
|
-
});
|
|
1257
|
-
ValidateWriteToken(writeToken);
|
|
1258
|
-
this.Log("Deleting metadata: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken, "\n Subtree: ").concat(metadataSubtree));
|
|
1259
|
-
this.Log("Subtree: ".concat(metadataSubtree));
|
|
1260
|
-
path = UrlJoin("q", writeToken, "meta", metadataSubtree);
|
|
1261
|
-
_context17.t0 = _regeneratorRuntime;
|
|
1262
|
-
_context17.t1 = this.HttpClient;
|
|
1263
|
-
_context17.next = 10;
|
|
1264
|
-
return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
|
|
1265
|
-
libraryId: libraryId,
|
|
1266
|
-
objectId: objectId,
|
|
1267
|
-
update: true
|
|
1268
|
-
}));
|
|
1269
|
-
|
|
1270
|
-
case 10:
|
|
1271
|
-
_context17.t2 = _context17.sent;
|
|
1272
|
-
_context17.t3 = path;
|
|
1273
|
-
_context17.t4 = {
|
|
1274
|
-
headers: _context17.t2,
|
|
1275
|
-
method: "DELETE",
|
|
1276
|
-
path: _context17.t3,
|
|
1277
|
-
failover: false
|
|
1278
|
-
};
|
|
1279
|
-
_context17.t5 = _context17.t1.Request.call(_context17.t1, _context17.t4);
|
|
1280
|
-
_context17.next = 16;
|
|
1281
|
-
return _context17.t0.awrap.call(_context17.t0, _context17.t5);
|
|
1282
|
-
|
|
1283
|
-
case 16:
|
|
1284
|
-
case "end":
|
|
1285
|
-
return _context17.stop();
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
}, null, this);
|
|
1289
|
-
};
|
|
1290
|
-
/**
|
|
1291
|
-
* Set the access charge for the specified object
|
|
1292
|
-
*
|
|
1293
|
-
* @methodGroup Access Requests
|
|
1294
|
-
* @namedParams
|
|
1295
|
-
* @param {string} objectId - ID of the object
|
|
1296
|
-
* @param {number | string} accessCharge - The new access charge, in ether
|
|
1297
|
-
*/
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
exports.SetAccessCharge = function _callee18(_ref21) {
|
|
1301
|
-
var objectId, accessCharge;
|
|
1302
|
-
return _regeneratorRuntime.async(function _callee18$(_context18) {
|
|
1303
|
-
while (1) {
|
|
1304
|
-
switch (_context18.prev = _context18.next) {
|
|
1305
|
-
case 0:
|
|
1306
|
-
objectId = _ref21.objectId, accessCharge = _ref21.accessCharge;
|
|
1307
|
-
ValidateObject(objectId);
|
|
1308
|
-
this.Log("Setting access charge: ".concat(objectId, " ").concat(accessCharge));
|
|
1309
|
-
_context18.next = 5;
|
|
1310
|
-
return _regeneratorRuntime.awrap(this.ethClient.CallContractMethodAndWait({
|
|
1311
|
-
contractAddress: Utils.HashToAddress(objectId),
|
|
1312
|
-
abi: ContentContract.abi,
|
|
1313
|
-
methodName: "setAccessCharge",
|
|
1314
|
-
methodArgs: [Utils.EtherToWei(accessCharge).toString()],
|
|
1315
|
-
signer: this.signer
|
|
1316
|
-
}));
|
|
1317
|
-
|
|
1318
|
-
case 5:
|
|
1319
|
-
case "end":
|
|
1320
|
-
return _context18.stop();
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
}, null, this);
|
|
1324
|
-
};
|
|
1325
|
-
/**
|
|
1326
|
-
* Recursively update all auto_update links in the specified object.
|
|
1327
|
-
*
|
|
1328
|
-
* Note: Links will not be updated unless they are specifically marked as auto_update
|
|
1329
|
-
*
|
|
1330
|
-
* @param {string=} libraryId - ID of the library
|
|
1331
|
-
* @param {string=} objectId - ID of the object
|
|
1332
|
-
* @param {string=} versionHash - Version hash of the object -- if not specified, latest version is returned
|
|
1333
|
-
* @param {function=} callback - If specified, the callback will be called each time an object is updated with
|
|
1334
|
-
* current progress as well as information about the last update (action)
|
|
1335
|
-
* - Format: {completed: number, total: number, action: string}
|
|
1336
|
-
*/
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
exports.UpdateContentObjectGraph = function _callee20(_ref22) {
|
|
1340
|
-
var _this = this;
|
|
1341
|
-
|
|
1342
|
-
var libraryId, objectId, versionHash, callback, total, completed, _loop, _ret;
|
|
1343
|
-
|
|
1344
|
-
return _regeneratorRuntime.async(function _callee20$(_context21) {
|
|
1345
|
-
while (1) {
|
|
1346
|
-
switch (_context21.prev = _context21.next) {
|
|
1347
|
-
case 0:
|
|
1348
|
-
libraryId = _ref22.libraryId, objectId = _ref22.objectId, versionHash = _ref22.versionHash, callback = _ref22.callback;
|
|
1349
|
-
ValidateParameters({
|
|
1350
|
-
libraryId: libraryId,
|
|
1351
|
-
objectId: objectId,
|
|
1352
|
-
versionHash: versionHash
|
|
1353
|
-
});
|
|
1354
|
-
this.Log("Updating content object graph: ".concat(libraryId || "", " ").concat(objectId || versionHash));
|
|
1355
|
-
|
|
1356
|
-
if (versionHash) {
|
|
1357
|
-
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
|
-
completed = 0; // eslint-disable-next-line no-constant-condition
|
|
1361
|
-
|
|
1362
|
-
_loop = function _loop() {
|
|
1363
|
-
var graph, currentHash, links, details, name, currentLibraryId, currentObjectId, _ref23, write_token, _ref25, hash;
|
|
1364
|
-
|
|
1365
|
-
return _regeneratorRuntime.async(function _loop$(_context20) {
|
|
1366
|
-
while (1) {
|
|
1367
|
-
switch (_context20.prev = _context20.next) {
|
|
1368
|
-
case 0:
|
|
1369
|
-
_context20.next = 2;
|
|
1370
|
-
return _regeneratorRuntime.awrap(_this.ContentObjectGraph({
|
|
1371
|
-
libraryId: libraryId,
|
|
1372
|
-
objectId: objectId,
|
|
1373
|
-
versionHash: versionHash,
|
|
1374
|
-
autoUpdate: true,
|
|
1375
|
-
select: ["name", "public/name", "public/asset_metadata/display_title"]
|
|
1376
|
-
}));
|
|
1377
|
-
|
|
1378
|
-
case 2:
|
|
1379
|
-
graph = _context20.sent;
|
|
1380
|
-
|
|
1381
|
-
if (!(Object.keys(graph.auto_updates).length === 0)) {
|
|
1382
|
-
_context20.next = 6;
|
|
1383
|
-
break;
|
|
1384
|
-
}
|
|
1385
|
-
|
|
1386
|
-
_this.Log("No more updates required");
|
|
1387
|
-
|
|
1388
|
-
return _context20.abrupt("return", {
|
|
1389
|
-
v: void 0
|
|
1390
|
-
});
|
|
1391
|
-
|
|
1392
|
-
case 6:
|
|
1393
|
-
if (!total) {
|
|
1394
|
-
total = graph.auto_updates.order.length;
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
currentHash = graph.auto_updates.order[0];
|
|
1398
|
-
links = graph.auto_updates.links[currentHash];
|
|
1399
|
-
details = graph.details[currentHash].meta;
|
|
1400
|
-
name = details["public"] && details["public"].asset_metadata && details["public"].asset_metadata.display_title || details["public"] && details["public"].name || details.name || versionHash || objectId;
|
|
1401
|
-
_context20.next = 13;
|
|
1402
|
-
return _regeneratorRuntime.awrap(_this.ContentObjectLibraryId({
|
|
1403
|
-
versionHash: currentHash
|
|
1404
|
-
}));
|
|
1405
|
-
|
|
1406
|
-
case 13:
|
|
1407
|
-
currentLibraryId = _context20.sent;
|
|
1408
|
-
currentObjectId = _this.utils.DecodeVersionHash(currentHash).objectId;
|
|
1409
|
-
|
|
1410
|
-
if (callback) {
|
|
1411
|
-
callback({
|
|
1412
|
-
completed: completed,
|
|
1413
|
-
total: total,
|
|
1414
|
-
action: "Updating ".concat(name, " (").concat(currentObjectId, ")...")
|
|
1415
|
-
});
|
|
1416
|
-
}
|
|
1417
|
-
|
|
1418
|
-
_this.Log("Updating links for ".concat(name, " (").concat(currentObjectId, " / ").concat(currentHash, ")"));
|
|
1419
|
-
|
|
1420
|
-
_context20.next = 19;
|
|
1421
|
-
return _regeneratorRuntime.awrap(_this.EditContentObject({
|
|
1422
|
-
libraryId: currentLibraryId,
|
|
1423
|
-
objectId: currentObjectId
|
|
1424
|
-
}));
|
|
1425
|
-
|
|
1426
|
-
case 19:
|
|
1427
|
-
_ref23 = _context20.sent;
|
|
1428
|
-
write_token = _ref23.write_token;
|
|
1429
|
-
_context20.next = 23;
|
|
1430
|
-
return _regeneratorRuntime.awrap(Promise.all(links.map(function _callee19(_ref24) {
|
|
1431
|
-
var path, updated;
|
|
1432
|
-
return _regeneratorRuntime.async(function _callee19$(_context19) {
|
|
1433
|
-
while (1) {
|
|
1434
|
-
switch (_context19.prev = _context19.next) {
|
|
1435
|
-
case 0:
|
|
1436
|
-
path = _ref24.path, updated = _ref24.updated;
|
|
1437
|
-
_context19.next = 3;
|
|
1438
|
-
return _regeneratorRuntime.awrap(_this.ReplaceMetadata({
|
|
1439
|
-
libraryId: currentLibraryId,
|
|
1440
|
-
objectId: currentObjectId,
|
|
1441
|
-
writeToken: write_token,
|
|
1442
|
-
metadataSubtree: path,
|
|
1443
|
-
metadata: updated
|
|
1444
|
-
}));
|
|
1445
|
-
|
|
1446
|
-
case 3:
|
|
1447
|
-
case "end":
|
|
1448
|
-
return _context19.stop();
|
|
1449
|
-
}
|
|
1450
|
-
}
|
|
1451
|
-
});
|
|
1452
|
-
})));
|
|
1453
|
-
|
|
1454
|
-
case 23:
|
|
1455
|
-
_context20.next = 25;
|
|
1456
|
-
return _regeneratorRuntime.awrap(_this.FinalizeContentObject({
|
|
1457
|
-
libraryId: currentLibraryId,
|
|
1458
|
-
objectId: currentObjectId,
|
|
1459
|
-
writeToken: write_token
|
|
1460
|
-
}));
|
|
1461
|
-
|
|
1462
|
-
case 25:
|
|
1463
|
-
_ref25 = _context20.sent;
|
|
1464
|
-
hash = _ref25.hash;
|
|
1465
|
-
|
|
1466
|
-
// If root object was specified by hash and updated, update hash
|
|
1467
|
-
if (currentHash === versionHash) {
|
|
1468
|
-
versionHash = hash;
|
|
1469
|
-
}
|
|
1470
|
-
|
|
1471
|
-
completed += 1;
|
|
1472
|
-
|
|
1473
|
-
case 29:
|
|
1474
|
-
case "end":
|
|
1475
|
-
return _context20.stop();
|
|
1476
|
-
}
|
|
1477
|
-
}
|
|
1478
|
-
});
|
|
1479
|
-
};
|
|
1480
|
-
|
|
1481
|
-
case 6:
|
|
1482
|
-
if (!1) {
|
|
1483
|
-
_context21.next = 14;
|
|
1484
|
-
break;
|
|
1485
|
-
}
|
|
1486
|
-
|
|
1487
|
-
_context21.next = 9;
|
|
1488
|
-
return _regeneratorRuntime.awrap(_loop());
|
|
1489
|
-
|
|
1490
|
-
case 9:
|
|
1491
|
-
_ret = _context21.sent;
|
|
1492
|
-
|
|
1493
|
-
if (!(_typeof(_ret) === "object")) {
|
|
1494
|
-
_context21.next = 12;
|
|
1495
|
-
break;
|
|
1496
|
-
}
|
|
1497
|
-
|
|
1498
|
-
return _context21.abrupt("return", _ret.v);
|
|
1499
|
-
|
|
1500
|
-
case 12:
|
|
1501
|
-
_context21.next = 6;
|
|
1502
|
-
break;
|
|
1503
|
-
|
|
1504
|
-
case 14:
|
|
1505
|
-
case "end":
|
|
1506
|
-
return _context21.stop();
|
|
1507
|
-
}
|
|
1508
|
-
}
|
|
1509
|
-
}, null, this);
|
|
1510
|
-
};
|
|
1511
|
-
/**
|
|
1512
|
-
* Create links to files, metadata and/or representations of this or or other
|
|
1513
|
-
* content objects.
|
|
1514
|
-
*
|
|
1515
|
-
* Expected format of links:
|
|
1516
|
-
*
|
|
1517
|
-
|
|
1518
|
-
[
|
|
1519
|
-
{
|
|
1520
|
-
path: string (metadata path for the link)
|
|
1521
|
-
target: string (path to link target),
|
|
1522
|
-
type: string ("file", "meta" | "metadata", "rep" - default "metadata")
|
|
1523
|
-
targetHash: string (optional, for cross-object links),
|
|
1524
|
-
autoUpdate: boolean (if specified, link will be automatically updated to latest version by UpdateContentObjectGraph method)
|
|
1525
|
-
}
|
|
1526
|
-
]
|
|
1527
|
-
|
|
1528
|
-
* @methodGroup Links
|
|
1529
|
-
* @namedParams
|
|
1530
|
-
* @param {string} libraryId - ID of the library
|
|
1531
|
-
* @param {string} objectId - ID of the object
|
|
1532
|
-
* @param {string} writeToken - Write token of the draft
|
|
1533
|
-
* @param {Array<Object>} links - Link specifications
|
|
1534
|
-
*/
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
exports.CreateLinks = function _callee21(_ref26) {
|
|
1538
|
-
var libraryId, objectId, writeToken, _ref26$links, links, i, info, path, type, target, link;
|
|
1539
|
-
|
|
1540
|
-
return _regeneratorRuntime.async(function _callee21$(_context22) {
|
|
1541
|
-
while (1) {
|
|
1542
|
-
switch (_context22.prev = _context22.next) {
|
|
1543
|
-
case 0:
|
|
1544
|
-
libraryId = _ref26.libraryId, objectId = _ref26.objectId, writeToken = _ref26.writeToken, _ref26$links = _ref26.links, links = _ref26$links === void 0 ? [] : _ref26$links;
|
|
1545
|
-
ValidateParameters({
|
|
1546
|
-
libraryId: libraryId,
|
|
1547
|
-
objectId: objectId
|
|
1548
|
-
});
|
|
1549
|
-
ValidateWriteToken(writeToken);
|
|
1550
|
-
i = 0;
|
|
1551
|
-
|
|
1552
|
-
case 4:
|
|
1553
|
-
if (!(i < links.length)) {
|
|
1554
|
-
_context22.next = 18;
|
|
1555
|
-
break;
|
|
1556
|
-
}
|
|
1557
|
-
|
|
1558
|
-
info = links[i];
|
|
1559
|
-
path = info.path.replace(/^(\/|\.)+/, "");
|
|
1560
|
-
type = (info.type || "file") === "file" ? "files" : info.type;
|
|
1561
|
-
|
|
1562
|
-
if (type === "metadata") {
|
|
1563
|
-
type = "meta";
|
|
1564
|
-
}
|
|
1565
|
-
|
|
1566
|
-
target = info.target.replace(/^(\/|\.)+/, "");
|
|
1567
|
-
|
|
1568
|
-
if (info.targetHash) {
|
|
1569
|
-
target = "/qfab/".concat(info.targetHash, "/").concat(type, "/").concat(target);
|
|
1570
|
-
} else {
|
|
1571
|
-
target = "./".concat(type, "/").concat(target);
|
|
1572
|
-
}
|
|
1573
|
-
|
|
1574
|
-
link = {
|
|
1575
|
-
"/": target
|
|
1576
|
-
};
|
|
1577
|
-
|
|
1578
|
-
if (info.autoUpdate) {
|
|
1579
|
-
link["."] = {
|
|
1580
|
-
auto_update: {
|
|
1581
|
-
tag: "latest"
|
|
1582
|
-
}
|
|
1583
|
-
};
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
|
-
_context22.next = 15;
|
|
1587
|
-
return _regeneratorRuntime.awrap(this.ReplaceMetadata({
|
|
1588
|
-
libraryId: libraryId,
|
|
1589
|
-
objectId: objectId,
|
|
1590
|
-
writeToken: writeToken,
|
|
1591
|
-
metadataSubtree: path,
|
|
1592
|
-
metadata: link
|
|
1593
|
-
}));
|
|
1594
|
-
|
|
1595
|
-
case 15:
|
|
1596
|
-
i++;
|
|
1597
|
-
_context22.next = 4;
|
|
1598
|
-
break;
|
|
1599
|
-
|
|
1600
|
-
case 18:
|
|
1601
|
-
case "end":
|
|
1602
|
-
return _context22.stop();
|
|
1603
|
-
}
|
|
1604
|
-
}
|
|
1605
|
-
}, null, this);
|
|
1606
|
-
};
|