@colijnit/mainapi 259.1.1 → 259.1.2
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/build/main-public.d.ts +4 -1
- package/build/main-public.js +84 -5
- package/package.json +1 -1
package/build/main-public.d.ts
CHANGED
|
@@ -74,10 +74,13 @@ export declare class MainPublic extends MainApiConnection {
|
|
|
74
74
|
getInternalDefaultValue(param: InternalDefault): Promise<DataServiceResponseData>;
|
|
75
75
|
emailActivity(request: EmailActivityRequest, showLoader?: boolean): Promise<DataServiceResponseData>;
|
|
76
76
|
selectMultiple(moduleName: ModuleName, objectName: string, operationName?: string, parameterValues?: any, showLoader?: boolean): Promise<DataServiceResponseData>;
|
|
77
|
-
getSingleImage(nodeId: number | string, publication?: number, includeMimetype?: boolean, thumb?: boolean): Promise<DataServiceResponseData>;
|
|
77
|
+
getSingleImage(nodeId: number | string, publication?: number, includeMimetype?: boolean, thumb?: boolean, tableName?: TableName): Promise<DataServiceResponseData>;
|
|
78
78
|
getImage(key: number | string, publication?: number, includeMimetype?: boolean, thumb?: boolean): Promise<DataServiceResponseData>;
|
|
79
79
|
getImageForCoDocument(document: CoDocument, thumb?: boolean): Promise<DataServiceResponseData>;
|
|
80
80
|
private createServiceRequestData;
|
|
81
81
|
private _call;
|
|
82
82
|
private _callAjaxService;
|
|
83
|
+
private _handleDocumentBody;
|
|
84
|
+
private _handleDocumentUrl;
|
|
85
|
+
private _handleCoDocumentRequest;
|
|
83
86
|
}
|
package/build/main-public.js
CHANGED
|
@@ -15,6 +15,10 @@ const end_point_enum_1 = require("@colijnit/ioneconnector/build/enum/end-point.e
|
|
|
15
15
|
const public_service_method_1 = require("./enum/public-service-method");
|
|
16
16
|
const data_service_response_data_1 = require("@colijnit/ioneconnector/build/model/data-service-response-data");
|
|
17
17
|
const backend_service_name_enum_1 = require("./enum/backend-service-name.enum");
|
|
18
|
+
const table_name_enum_1 = require("./enum/table-name.enum");
|
|
19
|
+
const co_document_type_enum_1 = require("./enum/co-document-type.enum");
|
|
20
|
+
const image_content_bo_1 = require("./model/image-content.bo");
|
|
21
|
+
const file_utils_1 = require("./utils/file-utils");
|
|
18
22
|
class MainPublic extends main_api_connection_1.MainApiConnection {
|
|
19
23
|
constructor() {
|
|
20
24
|
super(...arguments);
|
|
@@ -297,14 +301,32 @@ class MainPublic extends main_api_connection_1.MainApiConnection {
|
|
|
297
301
|
console.warn('getOrderLineSetCategories not implemented');
|
|
298
302
|
return Promise.resolve(new data_service_response_data_1.DataServiceResponseData());
|
|
299
303
|
}
|
|
300
|
-
getSingleImage(nodeId, publication = 4, includeMimetype = false, thumb = true) {
|
|
301
|
-
|
|
302
|
-
|
|
304
|
+
getSingleImage(nodeId, publication = 4, includeMimetype = false, thumb = true, tableName = table_name_enum_1.TableName.Goods) {
|
|
305
|
+
if (!nodeId) {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
const params = {
|
|
309
|
+
table: tableName,
|
|
310
|
+
key: nodeId.toString(),
|
|
311
|
+
includeBody: thumb === undefined || thumb === false,
|
|
312
|
+
includeThumbnail: thumb === true,
|
|
313
|
+
publication: publication
|
|
314
|
+
};
|
|
315
|
+
const data = Object.assign(Object.assign({}, this.createServiceRequestData()), { parameterValues: params });
|
|
316
|
+
return this._call(public_service_method_1.PublicServiceMethod.GetSingleImage, data);
|
|
303
317
|
}
|
|
304
318
|
getImage(key, publication = 4, includeMimetype = false, thumb = true) {
|
|
305
319
|
return __awaiter(this, void 0, void 0, function* () {
|
|
306
|
-
|
|
307
|
-
|
|
320
|
+
const getImageObject = yield this.getSingleImage(key, publication, includeMimetype, thumb, table_name_enum_1.TableName.Goods);
|
|
321
|
+
if (getImageObject.validationResult && getImageObject.validationResult.success) {
|
|
322
|
+
if (getImageObject.resultObject) {
|
|
323
|
+
const document = getImageObject.resultObject;
|
|
324
|
+
const type = document.documentType;
|
|
325
|
+
const fileType = document.fileType;
|
|
326
|
+
const hasPublicAccess = document.hasPublicAccess;
|
|
327
|
+
return this._handleCoDocumentRequest(type, fileType, hasPublicAccess, document.documentId, document.mimeTypeInternal, thumb, document.filePath);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
308
330
|
});
|
|
309
331
|
}
|
|
310
332
|
getImageForCoDocument(document, thumb = false) {
|
|
@@ -325,5 +347,62 @@ class MainPublic extends main_api_connection_1.MainApiConnection {
|
|
|
325
347
|
return this.connector.call(method, data, showLoader, service, end_point_enum_1.EndPoint.AjaxService, ownMessage);
|
|
326
348
|
});
|
|
327
349
|
}
|
|
350
|
+
_handleDocumentBody(documentId, mimeType, thumb, fileType) {
|
|
351
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
352
|
+
const returnObject = new data_service_response_data_1.DataServiceResponseData();
|
|
353
|
+
const documentBody = yield this.getDocumentContent(documentId, thumb);
|
|
354
|
+
const imageObject = new image_content_bo_1.ImageContent();
|
|
355
|
+
if (mimeType === undefined) {
|
|
356
|
+
mimeType = 'image/jpeg';
|
|
357
|
+
}
|
|
358
|
+
imageObject.mimeType = mimeType;
|
|
359
|
+
imageObject.fileType = fileType;
|
|
360
|
+
if (documentBody && documentBody.validationResult.success) {
|
|
361
|
+
returnObject.validationResult.success = true;
|
|
362
|
+
imageObject.image = file_utils_1.FileUtils.DocumentBodyToDataUri(documentBody.resultObject.documentContent, mimeType);
|
|
363
|
+
returnObject.resultObject = imageObject;
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
returnObject.validationResult.success = false;
|
|
367
|
+
imageObject.image = null;
|
|
368
|
+
returnObject.resultObject = imageObject;
|
|
369
|
+
}
|
|
370
|
+
return returnObject;
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
_handleDocumentUrl(url, fileType) {
|
|
374
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
375
|
+
const returnObject = new data_service_response_data_1.DataServiceResponseData();
|
|
376
|
+
const imageObject = new image_content_bo_1.ImageContent();
|
|
377
|
+
imageObject.fileType = fileType;
|
|
378
|
+
if (url) {
|
|
379
|
+
returnObject.validationResult.success = true;
|
|
380
|
+
imageObject.image = url;
|
|
381
|
+
returnObject.resultObject = imageObject;
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
returnObject.validationResult.success = false;
|
|
385
|
+
imageObject.image = null;
|
|
386
|
+
returnObject.resultObject = imageObject;
|
|
387
|
+
}
|
|
388
|
+
return returnObject;
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
_handleCoDocumentRequest(type, fileType, hasPublicAccess, documentId, mimeType, thumb, filePath) {
|
|
392
|
+
if (type === co_document_type_enum_1.CoDocumentType.SaveAsDocument) {
|
|
393
|
+
return this._handleDocumentBody(documentId, mimeType, thumb, fileType);
|
|
394
|
+
}
|
|
395
|
+
else if (type === co_document_type_enum_1.CoDocumentType.SaveAsLinkOnRandomLocation) {
|
|
396
|
+
return this._handleDocumentUrl(filePath, fileType);
|
|
397
|
+
}
|
|
398
|
+
else if (type === co_document_type_enum_1.CoDocumentType.SaveAsLinkOnDefaultLocation) {
|
|
399
|
+
}
|
|
400
|
+
else if (type === co_document_type_enum_1.CoDocumentType.SaveAsLinkOnCdnServerLocation && hasPublicAccess === 'T') {
|
|
401
|
+
return this._handleDocumentUrl(filePath, fileType);
|
|
402
|
+
}
|
|
403
|
+
else if (type === co_document_type_enum_1.CoDocumentType.SaveAsLinkOnCdnServerLocation && hasPublicAccess === 'F') {
|
|
404
|
+
return this._handleDocumentBody(documentId, mimeType, thumb, fileType);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
328
407
|
}
|
|
329
408
|
exports.MainPublic = MainPublic;
|