@colijnit/mainapi 1.0.28 → 1.0.29
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/enum/document-allowed-type.enum.d.ts +10 -0
- package/build/enum/document-allowed-type.enum.js +14 -0
- package/build/enum/general-method.enum.d.ts +33 -2
- package/build/enum/general-method.enum.js +32 -1
- package/build/enum/module-name.enum.d.ts +6 -4
- package/build/enum/module-name.enum.js +6 -4
- package/build/enum/sequence-name.enum.d.ts +28 -1
- package/build/enum/sequence-name.enum.js +27 -0
- package/build/main-api-connection.d.ts +3 -0
- package/build/main-api.d.ts +3 -0
- package/build/main-api.js +8 -0
- package/build/main-api.unit.test.js +5 -0
- package/build/main-auth.d.ts +3 -1
- package/build/main-auth.js +18 -3
- package/build/main-public.d.ts +3 -0
- package/build/main-public.js +8 -0
- package/build/model/document-allowed-extension.bo.d.ts +6 -0
- package/build/model/document-allowed-extension.bo.js +7 -0
- package/build/model/get-postal-code-retrieval-output-params.d.ts +7 -0
- package/build/model/get-postal-code-retrieval-output-params.js +6 -0
- package/build/model/language.bo.d.ts +5 -0
- package/build/model/language.bo.js +7 -0
- package/build/model/title.bo.d.ts +9 -0
- package/build/model/title.bo.js +13 -0
- package/build/utils/file-utils.d.ts +29 -0
- package/build/utils/file-utils.js +348 -0
- package/package.json +2 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DocumentAllowedType = void 0;
|
|
4
|
+
var DocumentAllowedType;
|
|
5
|
+
(function (DocumentAllowedType) {
|
|
6
|
+
DocumentAllowedType["Image"] = "Image";
|
|
7
|
+
DocumentAllowedType["Document"] = "Document";
|
|
8
|
+
DocumentAllowedType["Text"] = "Text";
|
|
9
|
+
DocumentAllowedType["ThreeD"] = "3D";
|
|
10
|
+
DocumentAllowedType["JasperReport"] = "Jasper report";
|
|
11
|
+
DocumentAllowedType["Video"] = "Video";
|
|
12
|
+
DocumentAllowedType["Audio"] = "Audio";
|
|
13
|
+
DocumentAllowedType["Archive"] = "Archive";
|
|
14
|
+
})(DocumentAllowedType = exports.DocumentAllowedType || (exports.DocumentAllowedType = {}));
|
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
export declare enum GeneralMethod {
|
|
2
|
+
AddErrorLog = "addErrorLog",
|
|
3
|
+
CheckHiddenByPolicy = "checkHiddenByPolicy",
|
|
4
|
+
GetAdminStartupValidations = "getAdminStartupValidations",
|
|
5
|
+
GetDatabaseName = "getDatabaseName",
|
|
6
|
+
GetDefaultValue = "getDefaultValue",
|
|
2
7
|
GetDocumentContent = "getDocumentContent",
|
|
8
|
+
GetDocumentStandards = "getDocumentStandards",
|
|
9
|
+
GetDomainValues = "getDomainValues",
|
|
10
|
+
GetEdition = "getEdition",
|
|
11
|
+
GetMessageNotifications = "getMessageNotificationsByTableKey",
|
|
12
|
+
SaveAndSendMessageNotification = "saveAndSend",
|
|
13
|
+
GetModuleSettings = "getModuleSettings",
|
|
14
|
+
GetNotition = "getNotition",
|
|
15
|
+
GetNumberOfActiveUsers = "getNumberOfActiveUsers",
|
|
16
|
+
GetParamValue = "getParamValue",
|
|
17
|
+
GetProfileCompletionPercentageForContactPerson = "GetProfileCompletionPercentageForContactPerson",
|
|
18
|
+
GetRelationSmallObject = "getRelationSmallObject",
|
|
19
|
+
GetRightValue = "getRightValue",
|
|
3
20
|
GetSequenceValue = "getSequenceValue",
|
|
4
|
-
|
|
5
|
-
|
|
21
|
+
MergeDocuments = "mergeDocuments",
|
|
22
|
+
MergeDocument = "mergeDocument",
|
|
23
|
+
DeleteDocument = "deleteDocument",
|
|
24
|
+
MergeCollectiveSalary = "mergeCollectiveSalary",
|
|
25
|
+
MergeNotes = "mergeNotes",
|
|
26
|
+
SelectDocsByTableKey = "selectDocsByTableKey",
|
|
27
|
+
SelectCollectiveSalaryInfo = "selectCollectiveSalaryInfo",
|
|
28
|
+
SelectNotesByTableKey = "selectNotesByTableKey",
|
|
29
|
+
SelectColoursByTableKey = "selectColoursByTableKey",
|
|
30
|
+
SetNewLicense = "setNewLicense",
|
|
31
|
+
SelectArticleTexts = "selectArticleTexts",
|
|
32
|
+
MergeArticleTexts = "mergeArticleTexts",
|
|
33
|
+
MergeTexts = "mergeTexts",
|
|
34
|
+
SelectTextsByTableKey = "selectTextsByTableKey",
|
|
35
|
+
GetResultOfValidationCurrentDatabaseObjectsChecksum = "getResultOfValidationCurrentDatabaseObjectsChecksum",
|
|
36
|
+
PostalCodeRetrieval = "postalCodeRetrieval"
|
|
6
37
|
}
|
|
@@ -3,8 +3,39 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GeneralMethod = void 0;
|
|
4
4
|
var GeneralMethod;
|
|
5
5
|
(function (GeneralMethod) {
|
|
6
|
+
GeneralMethod["AddErrorLog"] = "addErrorLog";
|
|
7
|
+
GeneralMethod["CheckHiddenByPolicy"] = "checkHiddenByPolicy";
|
|
8
|
+
GeneralMethod["GetAdminStartupValidations"] = "getAdminStartupValidations";
|
|
9
|
+
GeneralMethod["GetDatabaseName"] = "getDatabaseName";
|
|
10
|
+
GeneralMethod["GetDefaultValue"] = "getDefaultValue";
|
|
6
11
|
GeneralMethod["GetDocumentContent"] = "getDocumentContent";
|
|
12
|
+
GeneralMethod["GetDocumentStandards"] = "getDocumentStandards";
|
|
13
|
+
GeneralMethod["GetDomainValues"] = "getDomainValues";
|
|
14
|
+
GeneralMethod["GetEdition"] = "getEdition";
|
|
15
|
+
GeneralMethod["GetMessageNotifications"] = "getMessageNotificationsByTableKey";
|
|
16
|
+
GeneralMethod["SaveAndSendMessageNotification"] = "saveAndSend";
|
|
17
|
+
GeneralMethod["GetModuleSettings"] = "getModuleSettings";
|
|
18
|
+
GeneralMethod["GetNotition"] = "getNotition";
|
|
19
|
+
GeneralMethod["GetNumberOfActiveUsers"] = "getNumberOfActiveUsers";
|
|
20
|
+
GeneralMethod["GetParamValue"] = "getParamValue";
|
|
21
|
+
GeneralMethod["GetProfileCompletionPercentageForContactPerson"] = "GetProfileCompletionPercentageForContactPerson";
|
|
22
|
+
GeneralMethod["GetRelationSmallObject"] = "getRelationSmallObject";
|
|
23
|
+
GeneralMethod["GetRightValue"] = "getRightValue";
|
|
7
24
|
GeneralMethod["GetSequenceValue"] = "getSequenceValue";
|
|
25
|
+
GeneralMethod["MergeDocuments"] = "mergeDocuments";
|
|
26
|
+
GeneralMethod["MergeDocument"] = "mergeDocument";
|
|
27
|
+
GeneralMethod["DeleteDocument"] = "deleteDocument";
|
|
28
|
+
GeneralMethod["MergeCollectiveSalary"] = "mergeCollectiveSalary";
|
|
29
|
+
GeneralMethod["MergeNotes"] = "mergeNotes";
|
|
30
|
+
GeneralMethod["SelectDocsByTableKey"] = "selectDocsByTableKey";
|
|
31
|
+
GeneralMethod["SelectCollectiveSalaryInfo"] = "selectCollectiveSalaryInfo";
|
|
32
|
+
GeneralMethod["SelectNotesByTableKey"] = "selectNotesByTableKey";
|
|
33
|
+
GeneralMethod["SelectColoursByTableKey"] = "selectColoursByTableKey";
|
|
34
|
+
GeneralMethod["SetNewLicense"] = "setNewLicense";
|
|
35
|
+
GeneralMethod["SelectArticleTexts"] = "selectArticleTexts";
|
|
36
|
+
GeneralMethod["MergeArticleTexts"] = "mergeArticleTexts";
|
|
37
|
+
GeneralMethod["MergeTexts"] = "mergeTexts";
|
|
38
|
+
GeneralMethod["SelectTextsByTableKey"] = "selectTextsByTableKey";
|
|
39
|
+
GeneralMethod["GetResultOfValidationCurrentDatabaseObjectsChecksum"] = "getResultOfValidationCurrentDatabaseObjectsChecksum";
|
|
8
40
|
GeneralMethod["PostalCodeRetrieval"] = "postalCodeRetrieval";
|
|
9
|
-
GeneralMethod["GetParamValue"] = "getParamValue";
|
|
10
41
|
})(GeneralMethod = exports.GeneralMethod || (exports.GeneralMethod = {}));
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export declare enum ModuleName {
|
|
2
|
+
Address = "address",
|
|
3
|
+
Articles = "Articles",
|
|
4
|
+
Config = "Config",
|
|
2
5
|
General = "General",
|
|
6
|
+
Preset = "Preset",
|
|
7
|
+
Relation = "Rel_man",
|
|
3
8
|
Report = "Report",
|
|
4
9
|
ReportingDocuments = "ReportingDocuments",
|
|
5
|
-
Tags = "Tags",
|
|
6
10
|
SimpleBaseData = "SimpleBaseData",
|
|
7
|
-
|
|
8
|
-
Articles = "Articles",
|
|
9
|
-
Preset = "Preset"
|
|
11
|
+
Tags = "Tags"
|
|
10
12
|
}
|
|
@@ -3,12 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ModuleName = void 0;
|
|
4
4
|
var ModuleName;
|
|
5
5
|
(function (ModuleName) {
|
|
6
|
+
ModuleName["Address"] = "address";
|
|
7
|
+
ModuleName["Articles"] = "Articles";
|
|
8
|
+
ModuleName["Config"] = "Config";
|
|
6
9
|
ModuleName["General"] = "General";
|
|
10
|
+
ModuleName["Preset"] = "Preset";
|
|
11
|
+
ModuleName["Relation"] = "Rel_man";
|
|
7
12
|
ModuleName["Report"] = "Report";
|
|
8
13
|
ModuleName["ReportingDocuments"] = "ReportingDocuments";
|
|
9
|
-
ModuleName["Tags"] = "Tags";
|
|
10
14
|
ModuleName["SimpleBaseData"] = "SimpleBaseData";
|
|
11
|
-
ModuleName["
|
|
12
|
-
ModuleName["Articles"] = "Articles";
|
|
13
|
-
ModuleName["Preset"] = "Preset";
|
|
15
|
+
ModuleName["Tags"] = "Tags";
|
|
14
16
|
})(ModuleName = exports.ModuleName || (exports.ModuleName = {}));
|
|
@@ -1,4 +1,31 @@
|
|
|
1
1
|
export declare enum SequenceName {
|
|
2
|
+
DebtorNumber = "seq_debnr",
|
|
3
|
+
CreditorNumber = "seq_crednr",
|
|
4
|
+
EmployeeNumber = "seq_personeelsnummer",
|
|
5
|
+
BranchNumber = "seq_filiaalnr",
|
|
6
|
+
CompanyNumber = "seq_bedrijfnr",
|
|
7
|
+
ContactPersonNumber = "seq_contactpersoonnummer",
|
|
8
|
+
CommunicationNumber = "seq_communicatie",
|
|
2
9
|
RelationId = "seq_relatieid",
|
|
3
|
-
|
|
10
|
+
DepartmentNo = "seq_afdeling",
|
|
11
|
+
TaskId = "seq_taak_id",
|
|
12
|
+
WorkId = "SEQ_WERKZAAMHEDEN",
|
|
13
|
+
RemarkId = "SEQ_OPMERKINGEN",
|
|
14
|
+
ArticleNr = "seq_artnr",
|
|
15
|
+
ReceiptTransNr = "kassabon",
|
|
16
|
+
TransactionId = "seq_transid",
|
|
17
|
+
SalesInvoiceTransNr = "seq_v_faktuurnr",
|
|
18
|
+
SalesOrderTransNr = "seq_v_ordernr",
|
|
19
|
+
SalesQuotationTransNr = "seq_v_offertenr",
|
|
20
|
+
PurchaseOrderTransNr = "seq_i_ordernr",
|
|
21
|
+
ServiceOrderTransNr = "seq_s_ordernr",
|
|
22
|
+
Form = "seq_form",
|
|
23
|
+
FormQuestion = "seq_form_question",
|
|
24
|
+
FormAnswer = "seq_form_question_answer",
|
|
25
|
+
FormResponse = "seq_form_response",
|
|
26
|
+
EmolumentType = "seq_emolument_type",
|
|
27
|
+
Salary = "seq_salary",
|
|
28
|
+
EmployeeContract = "seq_employee_contract",
|
|
29
|
+
RelationContract = "SEQ_SLA_ID",
|
|
30
|
+
GuaranteeCode = "seq_garantie"
|
|
4
31
|
}
|
|
@@ -3,6 +3,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SequenceName = void 0;
|
|
4
4
|
var SequenceName;
|
|
5
5
|
(function (SequenceName) {
|
|
6
|
+
SequenceName["DebtorNumber"] = "seq_debnr";
|
|
7
|
+
SequenceName["CreditorNumber"] = "seq_crednr";
|
|
8
|
+
SequenceName["EmployeeNumber"] = "seq_personeelsnummer";
|
|
9
|
+
SequenceName["BranchNumber"] = "seq_filiaalnr";
|
|
10
|
+
SequenceName["CompanyNumber"] = "seq_bedrijfnr";
|
|
11
|
+
SequenceName["ContactPersonNumber"] = "seq_contactpersoonnummer";
|
|
12
|
+
SequenceName["CommunicationNumber"] = "seq_communicatie";
|
|
6
13
|
SequenceName["RelationId"] = "seq_relatieid";
|
|
14
|
+
SequenceName["DepartmentNo"] = "seq_afdeling";
|
|
15
|
+
SequenceName["TaskId"] = "seq_taak_id";
|
|
16
|
+
SequenceName["WorkId"] = "SEQ_WERKZAAMHEDEN";
|
|
17
|
+
SequenceName["RemarkId"] = "SEQ_OPMERKINGEN";
|
|
18
|
+
SequenceName["ArticleNr"] = "seq_artnr";
|
|
19
|
+
SequenceName["ReceiptTransNr"] = "kassabon";
|
|
7
20
|
SequenceName["TransactionId"] = "seq_transid";
|
|
21
|
+
SequenceName["SalesInvoiceTransNr"] = "seq_v_faktuurnr";
|
|
22
|
+
SequenceName["SalesOrderTransNr"] = "seq_v_ordernr";
|
|
23
|
+
SequenceName["SalesQuotationTransNr"] = "seq_v_offertenr";
|
|
24
|
+
SequenceName["PurchaseOrderTransNr"] = "seq_i_ordernr";
|
|
25
|
+
SequenceName["ServiceOrderTransNr"] = "seq_s_ordernr";
|
|
26
|
+
SequenceName["Form"] = "seq_form";
|
|
27
|
+
SequenceName["FormQuestion"] = "seq_form_question";
|
|
28
|
+
SequenceName["FormAnswer"] = "seq_form_question_answer";
|
|
29
|
+
SequenceName["FormResponse"] = "seq_form_response";
|
|
30
|
+
SequenceName["EmolumentType"] = "seq_emolument_type";
|
|
31
|
+
SequenceName["Salary"] = "seq_salary";
|
|
32
|
+
SequenceName["EmployeeContract"] = "seq_employee_contract";
|
|
33
|
+
SequenceName["RelationContract"] = "SEQ_SLA_ID";
|
|
34
|
+
SequenceName["GuaranteeCode"] = "seq_garantie";
|
|
8
35
|
})(SequenceName = exports.SequenceName || (exports.SequenceName = {}));
|
|
@@ -8,6 +8,7 @@ import { TagCategory } from "./enum/tab-category.enum";
|
|
|
8
8
|
import { TagTreeItem } from "./model/tag-tree-item.bo";
|
|
9
9
|
import { Preset } from "./model/preset.bo";
|
|
10
10
|
import { ReportType } from './enum/report-type.enum';
|
|
11
|
+
import { ModuleName } from './enum/module-name.enum';
|
|
11
12
|
export declare abstract class MainApiConnection {
|
|
12
13
|
readonly showLoader: Subject<boolean>;
|
|
13
14
|
readonly connectionAborted: Subject<void>;
|
|
@@ -42,5 +43,7 @@ export declare abstract class MainApiConnection {
|
|
|
42
43
|
abstract savePreset(preset: Preset): Promise<DataServiceResponseData>;
|
|
43
44
|
abstract updatePreset(presetName: string): Promise<DataServiceResponseData>;
|
|
44
45
|
abstract getOrderLineSetCategories(): Promise<DataServiceResponseData>;
|
|
46
|
+
abstract getPostalCodeRetrieval(postalCode: string, houseNumber: string, showLoader?: boolean): Promise<DataServiceResponseData>;
|
|
47
|
+
abstract selectMultiple(moduleName: ModuleName, objectName: string, operationName?: string, parameterValues?: any, showLoader?: boolean): Promise<DataServiceResponseData>;
|
|
45
48
|
protected endPoint: string;
|
|
46
49
|
}
|
package/build/main-api.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { TagTreeItem } from "./model/tag-tree-item.bo";
|
|
|
10
10
|
import { Preset } from "./model/preset.bo";
|
|
11
11
|
import { ServerResponseData } from '@colijnit/ioneconnector/build/model/server-response-data';
|
|
12
12
|
import { ReportType } from './enum/report-type.enum';
|
|
13
|
+
import { ModuleName } from './enum/module-name.enum';
|
|
13
14
|
export declare class MainApi {
|
|
14
15
|
readonly showLoader: Subject<boolean>;
|
|
15
16
|
readonly connectionAborted: Subject<void>;
|
|
@@ -27,6 +28,7 @@ export declare class MainApi {
|
|
|
27
28
|
constructor(options?: Options);
|
|
28
29
|
connect(): Promise<boolean>;
|
|
29
30
|
logOut(): Promise<ServerResponseData>;
|
|
31
|
+
selectMultiple(module: ModuleName, objectClass: string, operation?: string, params?: {}, showLoader?: boolean): Promise<DataServiceResponseData>;
|
|
30
32
|
getSequenceValue(sequenceName: SequenceName, noSequence?: boolean): Promise<DataServiceResponseData>;
|
|
31
33
|
getDefaultTemplate(documentCode: ReportType): Promise<DataServiceResponseData>;
|
|
32
34
|
listAllPrinters(): Promise<DataServiceResponseData>;
|
|
@@ -55,6 +57,7 @@ export declare class MainApi {
|
|
|
55
57
|
savePreset(preset: Preset): Promise<DataServiceResponseData>;
|
|
56
58
|
updatePreset(presetName: string): Promise<DataServiceResponseData>;
|
|
57
59
|
getOrderLineSetCategories(): Promise<DataServiceResponseData>;
|
|
60
|
+
getPostalCodeRetrieval(postalCode: string, houseNumber: string, showLoader?: boolean): Promise<DataServiceResponseData>;
|
|
58
61
|
static createConnector(options: Options, sessionExists: boolean): MainApiConnection;
|
|
59
62
|
private _handleConnectionReset;
|
|
60
63
|
}
|
package/build/main-api.js
CHANGED
|
@@ -48,6 +48,11 @@ class MainApi {
|
|
|
48
48
|
return this._connector.logOut();
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
+
selectMultiple(module, objectClass, operation, params, showLoader) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
return this.mainApi.selectMultiple(module, objectClass, operation, params, showLoader);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
51
56
|
getSequenceValue(sequenceName, noSequence = false) {
|
|
52
57
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
58
|
return this.mainApi.getSequenceValue(sequenceName, noSequence);
|
|
@@ -150,6 +155,9 @@ class MainApi {
|
|
|
150
155
|
return this.mainApi.getOrderLineSetCategories();
|
|
151
156
|
});
|
|
152
157
|
}
|
|
158
|
+
getPostalCodeRetrieval(postalCode, houseNumber, showLoader) {
|
|
159
|
+
return this.mainApi.getPostalCodeRetrieval(postalCode, houseNumber, showLoader);
|
|
160
|
+
}
|
|
153
161
|
static createConnector(options, sessionExists) {
|
|
154
162
|
if ((options.username && options.password) || sessionExists) {
|
|
155
163
|
return new main_auth_1.MainAuth();
|
|
@@ -120,4 +120,9 @@ describe("Connector", () => {
|
|
|
120
120
|
const result = yield connector.getDefaultTemplate(report_type_enum_1.ReportType.NewUserAccountMessage);
|
|
121
121
|
expect(result).toBeDefined();
|
|
122
122
|
}));
|
|
123
|
+
it('getPostalCode', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
124
|
+
yield connector.connect();
|
|
125
|
+
const result = yield connector.getPostalCodeRetrieval('4462gp', '6');
|
|
126
|
+
expect(result).toBeDefined();
|
|
127
|
+
}));
|
|
123
128
|
});
|
package/build/main-auth.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MainApiConnection } from './main-api-connection';
|
|
2
2
|
import { SequenceName } from './enum/sequence-name.enum';
|
|
3
|
+
import { ModuleName } from './enum/module-name.enum';
|
|
3
4
|
import { DataServiceResponseData } from '@colijnit/ioneconnector/build/model/data-service-response-data';
|
|
4
5
|
import { InternalParam } from './enum/internal-param.enum';
|
|
5
6
|
import { DomainName } from './enum/domain-name.enum';
|
|
@@ -36,6 +37,7 @@ export declare class MainAuth extends MainApiConnection {
|
|
|
36
37
|
savePreset(preset: Preset): Promise<DataServiceResponseData>;
|
|
37
38
|
updatePreset(presetName: string): Promise<DataServiceResponseData>;
|
|
38
39
|
getOrderLineSetCategories(): Promise<DataServiceResponseData>;
|
|
39
|
-
|
|
40
|
+
getPostalCodeRetrieval(postalCode: string, houseNumber: string, showLoader?: boolean): Promise<DataServiceResponseData>;
|
|
41
|
+
selectMultiple(moduleName: ModuleName, objectName: string, operationName?: string, parameterValues?: any, showLoader?: boolean): Promise<DataServiceResponseData>;
|
|
40
42
|
private _call;
|
|
41
43
|
}
|
package/build/main-auth.js
CHANGED
|
@@ -291,8 +291,23 @@ class MainAuth extends main_api_connection_1.MainApiConnection {
|
|
|
291
291
|
return this.selectMultiple(module_name_enum_1.ModuleName.SimpleBaseData, master_data_object_name_enum_1.MasterDataObjectName.OrderLineSetCategory, undefined, null);
|
|
292
292
|
});
|
|
293
293
|
}
|
|
294
|
-
|
|
295
|
-
|
|
294
|
+
getPostalCodeRetrieval(postalCode, houseNumber, showLoader) {
|
|
295
|
+
const params = {
|
|
296
|
+
postalCode: postalCode,
|
|
297
|
+
houseNumber: houseNumber
|
|
298
|
+
};
|
|
299
|
+
const data = {
|
|
300
|
+
moduleName: module_name_enum_1.ModuleName.Relation,
|
|
301
|
+
methodName: general_method_enum_1.GeneralMethod.PostalCodeRetrieval,
|
|
302
|
+
parameterValues: params,
|
|
303
|
+
refCursorAsArray: true
|
|
304
|
+
};
|
|
305
|
+
return this._call(data_service_method_enum_1.DataServiceMethod.ExecuteMethod, data, backend_service_name_enum_1.BackendServiceName.DataService, showLoader);
|
|
306
|
+
}
|
|
307
|
+
selectMultiple(moduleName, objectName, operationName, parameterValues, showLoader) {
|
|
308
|
+
if (showLoader === undefined) {
|
|
309
|
+
showLoader = false;
|
|
310
|
+
}
|
|
296
311
|
const data = {
|
|
297
312
|
moduleName: moduleName,
|
|
298
313
|
objectName: objectName
|
|
@@ -303,7 +318,7 @@ class MainAuth extends main_api_connection_1.MainApiConnection {
|
|
|
303
318
|
if (parameterValues) {
|
|
304
319
|
data.parameterValues = parameterValues;
|
|
305
320
|
}
|
|
306
|
-
return this._call(data_service_method_enum_1.DataServiceMethod.SelectMultipleObjects, data);
|
|
321
|
+
return this._call(data_service_method_enum_1.DataServiceMethod.SelectMultipleObjects, data, backend_service_name_enum_1.BackendServiceName.DataService, showLoader);
|
|
307
322
|
}
|
|
308
323
|
_call(method, data, service = backend_service_name_enum_1.BackendServiceName.DataService, showLoader = false) {
|
|
309
324
|
return __awaiter(this, void 0, void 0, function* () {
|
package/build/main-public.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { TagCategory } from "./enum/tab-category.enum";
|
|
|
7
7
|
import { TagTreeItem } from "./model/tag-tree-item.bo";
|
|
8
8
|
import { Preset } from "./model/preset.bo";
|
|
9
9
|
import { ReportType } from './enum/report-type.enum';
|
|
10
|
+
import { ModuleName } from './enum/module-name.enum';
|
|
10
11
|
export declare class MainPublic extends MainApiConnection {
|
|
11
12
|
protected endPoint: string;
|
|
12
13
|
getSequenceValue(sequenceName: SequenceName, noSequence?: boolean): Promise<DataServiceResponseData>;
|
|
@@ -36,6 +37,8 @@ export declare class MainPublic extends MainApiConnection {
|
|
|
36
37
|
savePreset(preset: Preset): Promise<DataServiceResponseData>;
|
|
37
38
|
updatePreset(presetName: string): Promise<DataServiceResponseData>;
|
|
38
39
|
getOrderLineSetCategories(): Promise<DataServiceResponseData>;
|
|
40
|
+
getPostalCodeRetrieval(postalCode: string, houseNumber: string, showLoader?: boolean): Promise<DataServiceResponseData>;
|
|
41
|
+
selectMultiple(moduleName: ModuleName, objectName: string, operationName?: string, parameterValues?: any, showLoader?: boolean): Promise<DataServiceResponseData>;
|
|
39
42
|
private createServiceRequestData;
|
|
40
43
|
private _call;
|
|
41
44
|
private _callAjaxService;
|
package/build/main-public.js
CHANGED
|
@@ -158,6 +158,14 @@ class MainPublic extends main_api_connection_1.MainApiConnection {
|
|
|
158
158
|
return Promise.resolve(new data_service_response_data_1.DataServiceResponseData());
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
|
+
getPostalCodeRetrieval(postalCode, houseNumber, showLoader) {
|
|
162
|
+
console.warn('getPostalCodeRetrieval not implemented');
|
|
163
|
+
return Promise.resolve(new data_service_response_data_1.DataServiceResponseData());
|
|
164
|
+
}
|
|
165
|
+
selectMultiple(moduleName, objectName, operationName, parameterValues, showLoader) {
|
|
166
|
+
console.warn('getOrderLineSetCategories not implemented');
|
|
167
|
+
return Promise.resolve(new data_service_response_data_1.DataServiceResponseData());
|
|
168
|
+
}
|
|
161
169
|
createServiceRequestData() {
|
|
162
170
|
const data = { languageCode: this.languageCode };
|
|
163
171
|
return data;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BusinessObject } from '@colijnit/ioneconnector/build/model/business-object';
|
|
2
|
+
import { DocumentAllowedType } from '../enum/document-allowed-type.enum';
|
|
3
|
+
export declare class DocumentAllowedExtension extends BusinessObject {
|
|
4
|
+
extension: string;
|
|
5
|
+
type: DocumentAllowedType;
|
|
6
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DocumentAllowedExtension = void 0;
|
|
4
|
+
const business_object_1 = require("@colijnit/ioneconnector/build/model/business-object");
|
|
5
|
+
class DocumentAllowedExtension extends business_object_1.BusinessObject {
|
|
6
|
+
}
|
|
7
|
+
exports.DocumentAllowedExtension = DocumentAllowedExtension;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Language = void 0;
|
|
4
|
+
const business_object_1 = require("@colijnit/ioneconnector/build/model/business-object");
|
|
5
|
+
class Language extends business_object_1.BusinessObject {
|
|
6
|
+
}
|
|
7
|
+
exports.Language = Language;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Title = void 0;
|
|
4
|
+
const business_object_1 = require("@colijnit/ioneconnector/build/model/business-object");
|
|
5
|
+
class Title extends business_object_1.BusinessObject {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
}
|
|
9
|
+
getId() {
|
|
10
|
+
return this.titleId;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.Title = Title;
|
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
import { FileTypeInternal } from '../enum/file-type-internal.enum';
|
|
2
|
+
import { CoDocument } from '../model/co-document';
|
|
3
|
+
import { DocumentAllowedExtension } from '../model/document-allowed-extension.bo';
|
|
2
4
|
export declare class FileUtils {
|
|
5
|
+
static get DefaultMaxUploadSizeInMb(): number;
|
|
6
|
+
static getMaxUploadSizeInMb(sizeInBytes: number): number;
|
|
3
7
|
static DocumentBodyToDataUri(documentBody: string, mimeType: string): string;
|
|
4
8
|
static FileNameToFileTypeInternal(fileName: string): FileTypeInternal;
|
|
9
|
+
static IsImageFile(file: File | CoDocument): boolean;
|
|
10
|
+
static GetGlobalFileType(document: CoDocument): FileTypeInternal;
|
|
11
|
+
static CheckMaxUploadSize(file: CoDocument | File, maxSizeInBytesFromParameter?: number): boolean;
|
|
12
|
+
static CheckExtension(file: CoDocument | File, allowedExtensions: DocumentAllowedExtension[]): boolean;
|
|
13
|
+
static ConvertFileToDataUri(file: File): Promise<string>;
|
|
14
|
+
static StripMimeStringFromDataUri(dataUri: string): string;
|
|
15
|
+
static GetMimeStringFromDataUri(dataUri: string): string;
|
|
16
|
+
static ConvertStringToArrayBuffer(stringData: string): Uint8Array;
|
|
17
|
+
static ConvertByteArrayToString(byteArray: number[]): string;
|
|
18
|
+
static StringIsImageDataUriOrURL(str: string): boolean;
|
|
19
|
+
static FixAssetUrl(assetUrl: string): string;
|
|
20
|
+
static MimeTypeFromFilename(fileName: string): string;
|
|
21
|
+
static DownloadFile(fileName: string, content: string, mimeType?: string): void;
|
|
22
|
+
static ReadAsText(file: File): Promise<string>;
|
|
23
|
+
static readAsDataURL(file: File): Promise<string>;
|
|
24
|
+
static ReadFileAsNewCoDocument(file: File, resize?: boolean, maxSizeInPixels?: number): Promise<CoDocument>;
|
|
25
|
+
static ResizeImage(src: string, fileType: string, maxSizeInPixels: number): Promise<string>;
|
|
26
|
+
static ReadFileAsDataURL(file: File): Promise<string>;
|
|
27
|
+
static DataURLtoFile(dataURL: string, filename: string): File;
|
|
28
|
+
static GetExtensionFromDataUri(dataUri: string): string;
|
|
29
|
+
static CreateDownloadFileNameFromBase64(dataUri: string): string;
|
|
30
|
+
static DownloadFromDataUri(dataUri: string, fileName: string): void;
|
|
31
|
+
static ValidUrl(stringToCheck: string): boolean;
|
|
32
|
+
static ReplaceExtension(fileName: string, newExtension: string): string;
|
|
33
|
+
static GenerateQRCode(url: string): string;
|
|
5
34
|
}
|
|
@@ -1,9 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
2
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
31
|
exports.FileUtils = void 0;
|
|
4
32
|
const string_utils_1 = require("@colijnit/ioneconnector/build/utils/string-utils");
|
|
5
33
|
const file_type_internal_enum_1 = require("../enum/file-type-internal.enum");
|
|
34
|
+
const co_document_type_enum_1 = require("../enum/co-document-type.enum");
|
|
35
|
+
const co_document_1 = require("../model/co-document");
|
|
36
|
+
const number_utils_1 = require("@colijnit/ioneconnector/build/utils/number-utils");
|
|
37
|
+
const QRCode = __importStar(require("qrcode"));
|
|
38
|
+
const DefaultMaxUploadSize = 3145728;
|
|
6
39
|
class FileUtils {
|
|
40
|
+
static get DefaultMaxUploadSizeInMb() {
|
|
41
|
+
return DefaultMaxUploadSize / 1024 / 1024;
|
|
42
|
+
}
|
|
43
|
+
static getMaxUploadSizeInMb(sizeInBytes) {
|
|
44
|
+
return sizeInBytes ? sizeInBytes / 1024 / 1024 : DefaultMaxUploadSize / 1024 / 1024;
|
|
45
|
+
}
|
|
7
46
|
static DocumentBodyToDataUri(documentBody, mimeType) {
|
|
8
47
|
return string_utils_1.StringUtils.IsStringWithLength(documentBody) ? "data:" + mimeType + ";base64," + documentBody : "";
|
|
9
48
|
}
|
|
@@ -45,5 +84,314 @@ class FileUtils {
|
|
|
45
84
|
return file_type_internal_enum_1.FileTypeInternal.Undefined;
|
|
46
85
|
}
|
|
47
86
|
}
|
|
87
|
+
static IsImageFile(file) {
|
|
88
|
+
if (!file) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
let fileName;
|
|
92
|
+
let mimeType;
|
|
93
|
+
if (file instanceof co_document_1.CoDocument) {
|
|
94
|
+
fileName = file.fileName;
|
|
95
|
+
mimeType = file.mimeTypeInternal;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
fileName = file.name;
|
|
99
|
+
mimeType = file.type;
|
|
100
|
+
}
|
|
101
|
+
if (mimeType !== "") {
|
|
102
|
+
return mimeType.startsWith("image/");
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
return (FileUtils.FileNameToFileTypeInternal(fileName) === file_type_internal_enum_1.FileTypeInternal.Image);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
static GetGlobalFileType(document) {
|
|
109
|
+
if (!document) {
|
|
110
|
+
return file_type_internal_enum_1.FileTypeInternal.Undefined;
|
|
111
|
+
}
|
|
112
|
+
if (document.mimeType !== "") {
|
|
113
|
+
switch (document.mimeType) {
|
|
114
|
+
case "application/pdf":
|
|
115
|
+
return file_type_internal_enum_1.FileTypeInternal.Pdf;
|
|
116
|
+
case "application/msword":
|
|
117
|
+
return file_type_internal_enum_1.FileTypeInternal.WordDocument;
|
|
118
|
+
case "application/excel":
|
|
119
|
+
case "application/vnd.ms-excel":
|
|
120
|
+
case "application/x-excel":
|
|
121
|
+
case "application/x-msexcel":
|
|
122
|
+
return file_type_internal_enum_1.FileTypeInternal.ExcelSheet;
|
|
123
|
+
case "text/plain":
|
|
124
|
+
case "application/plain":
|
|
125
|
+
return file_type_internal_enum_1.FileTypeInternal.TextFile;
|
|
126
|
+
default:
|
|
127
|
+
return file_type_internal_enum_1.FileTypeInternal.Undefined;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
return FileUtils.FileNameToFileTypeInternal(document.fileName);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
static CheckMaxUploadSize(file, maxSizeInBytesFromParameter) {
|
|
135
|
+
let fileSize = 0;
|
|
136
|
+
if (file instanceof co_document_1.CoDocument) {
|
|
137
|
+
fileSize = number_utils_1.NumberUtils.ParseInt(file.fileSize);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
fileSize = file.size;
|
|
141
|
+
}
|
|
142
|
+
const sizeToCompare = maxSizeInBytesFromParameter ? maxSizeInBytesFromParameter : DefaultMaxUploadSize;
|
|
143
|
+
return (fileSize <= sizeToCompare);
|
|
144
|
+
}
|
|
145
|
+
static CheckExtension(file, allowedExtensions) {
|
|
146
|
+
let filename = '';
|
|
147
|
+
if (file instanceof co_document_1.CoDocument) {
|
|
148
|
+
filename = file.fileName;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
filename = file.name;
|
|
152
|
+
}
|
|
153
|
+
const extension = filename.substr(filename.lastIndexOf(".") + 1);
|
|
154
|
+
let isAllowed = false;
|
|
155
|
+
for (const allowedExtension of allowedExtensions) {
|
|
156
|
+
if (extension.toLowerCase() === allowedExtension.extension.toLowerCase()) {
|
|
157
|
+
isAllowed = true;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return isAllowed;
|
|
162
|
+
}
|
|
163
|
+
static ConvertFileToDataUri(file) {
|
|
164
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
+
if (file) {
|
|
166
|
+
return new Promise((resolve) => {
|
|
167
|
+
const fileReader = new FileReader();
|
|
168
|
+
fileReader.onload = () => {
|
|
169
|
+
resolve(fileReader.result);
|
|
170
|
+
};
|
|
171
|
+
fileReader.readAsDataURL(file);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
static StripMimeStringFromDataUri(dataUri) {
|
|
177
|
+
if (!dataUri) {
|
|
178
|
+
return "";
|
|
179
|
+
}
|
|
180
|
+
const mimeString = this.GetMimeStringFromDataUri(dataUri);
|
|
181
|
+
return dataUri.substr(mimeString.length + 1);
|
|
182
|
+
}
|
|
183
|
+
static GetMimeStringFromDataUri(dataUri) {
|
|
184
|
+
if (!dataUri) {
|
|
185
|
+
return "";
|
|
186
|
+
}
|
|
187
|
+
return dataUri.split(",")[0];
|
|
188
|
+
}
|
|
189
|
+
static ConvertStringToArrayBuffer(stringData) {
|
|
190
|
+
if (!stringData) {
|
|
191
|
+
return undefined;
|
|
192
|
+
}
|
|
193
|
+
const arrayBuffer = new ArrayBuffer(stringData.length);
|
|
194
|
+
const bufView = new Uint8Array(arrayBuffer);
|
|
195
|
+
for (let i = 0, len = stringData.length; i < len; i++) {
|
|
196
|
+
bufView[i] = stringData.charCodeAt(i);
|
|
197
|
+
}
|
|
198
|
+
return bufView;
|
|
199
|
+
}
|
|
200
|
+
static ConvertByteArrayToString(byteArray) {
|
|
201
|
+
let str = "";
|
|
202
|
+
if (byteArray) {
|
|
203
|
+
for (let i = 0, len = byteArray.length; i < len; i++) {
|
|
204
|
+
str += String.fromCharCode(byteArray[i]);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return str;
|
|
208
|
+
}
|
|
209
|
+
static StringIsImageDataUriOrURL(str) {
|
|
210
|
+
if (!str) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
const mimeString = str.split(",")[0];
|
|
214
|
+
if (this.ValidUrl(str) || mimeString.indexOf("base64") > -1) {
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
static FixAssetUrl(assetUrl) {
|
|
219
|
+
if (!assetUrl) {
|
|
220
|
+
return "";
|
|
221
|
+
}
|
|
222
|
+
let fixedUrl;
|
|
223
|
+
if (assetUrl.indexOf("_webplayer") === -1) {
|
|
224
|
+
fixedUrl = assetUrl.replace(".unity3d", "_webplayer.ione3d");
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
fixedUrl = assetUrl.replace("_webplayer.unity3d", "_webplayer.ione3d");
|
|
228
|
+
}
|
|
229
|
+
fixedUrl = fixedUrl.replace("content/", "content43/");
|
|
230
|
+
if (!fixedUrl.endsWith(".gz")) {
|
|
231
|
+
fixedUrl = fixedUrl.concat(".gz");
|
|
232
|
+
}
|
|
233
|
+
return fixedUrl;
|
|
234
|
+
}
|
|
235
|
+
static MimeTypeFromFilename(fileName) {
|
|
236
|
+
const regEx = /(?:\.([^.]+))?$/;
|
|
237
|
+
const extension = regEx.exec(fileName)[1];
|
|
238
|
+
switch (extension) {
|
|
239
|
+
case "jpg":
|
|
240
|
+
case "jpeg":
|
|
241
|
+
return "image/jpeg";
|
|
242
|
+
case "png":
|
|
243
|
+
return "image/png";
|
|
244
|
+
case "bmp":
|
|
245
|
+
return "image/bmp";
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
static DownloadFile(fileName, content, mimeType = "text/plain") {
|
|
249
|
+
const element = document.createElement("a");
|
|
250
|
+
element.setAttribute("href", "data:" + mimeType + ";charset=utf-8," + encodeURIComponent(content));
|
|
251
|
+
element.setAttribute("download", fileName);
|
|
252
|
+
element.style.display = "none";
|
|
253
|
+
document.body.appendChild(element);
|
|
254
|
+
element.click();
|
|
255
|
+
document.body.removeChild(element);
|
|
256
|
+
}
|
|
257
|
+
static ReadAsText(file) {
|
|
258
|
+
return new Promise((resolve) => {
|
|
259
|
+
const reader = new FileReader();
|
|
260
|
+
reader.readAsText(file);
|
|
261
|
+
reader.onloadend = (event) => {
|
|
262
|
+
if (event.target.readyState === 2) {
|
|
263
|
+
resolve(event.target.result);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
static readAsDataURL(file) {
|
|
269
|
+
return new Promise((resolve) => {
|
|
270
|
+
const reader = new FileReader();
|
|
271
|
+
reader.readAsDataURL(file);
|
|
272
|
+
reader.onloadend = (event) => {
|
|
273
|
+
if (event.target.readyState === 2) {
|
|
274
|
+
resolve(FileUtils.StripMimeStringFromDataUri(event.target.result));
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
static ReadFileAsNewCoDocument(file, resize = false, maxSizeInPixels = 1200) {
|
|
280
|
+
return new Promise((resolve) => {
|
|
281
|
+
const reader = new FileReader();
|
|
282
|
+
reader.readAsDataURL(file);
|
|
283
|
+
reader.onloadend = (event) => __awaiter(this, void 0, void 0, function* () {
|
|
284
|
+
if (event.target.readyState === 2) {
|
|
285
|
+
const coDocument = new co_document_1.CoDocument();
|
|
286
|
+
if (file.type.toLowerCase().indexOf("image") > -1 && resize) {
|
|
287
|
+
const src = yield FileUtils.ResizeImage(event.target.result, file.type, maxSizeInPixels);
|
|
288
|
+
const len = src.length - (src.indexOf(",") + 1);
|
|
289
|
+
const padding = (src.charAt(src.length - 2) === "=") ? 2 : ((src.charAt(src.length - 1) === "=") ? 1 : 0);
|
|
290
|
+
coDocument.documentBody = FileUtils.StripMimeStringFromDataUri(src);
|
|
291
|
+
coDocument.fileSize = (len * 0.75 - padding).toString();
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
coDocument.documentBody = FileUtils.StripMimeStringFromDataUri(event.target.result);
|
|
295
|
+
coDocument.fileSize = file.size.toString();
|
|
296
|
+
}
|
|
297
|
+
coDocument.mimeTypeInternal = file.type;
|
|
298
|
+
coDocument.mimeType = file.type;
|
|
299
|
+
coDocument.fileName = file.name;
|
|
300
|
+
coDocument.documentType = co_document_type_enum_1.CoDocumentType.SaveAsDocument;
|
|
301
|
+
coDocument.description = file.name;
|
|
302
|
+
resolve(coDocument);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
static ResizeImage(src, fileType, maxSizeInPixels) {
|
|
308
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
309
|
+
return new Promise((resolve) => {
|
|
310
|
+
const origImage = new Image();
|
|
311
|
+
origImage.onload = (ev) => {
|
|
312
|
+
const imgWidth = ev.target.width;
|
|
313
|
+
const imgHeight = ev.target.height;
|
|
314
|
+
if (imgWidth > maxSizeInPixels || imgHeight > maxSizeInPixels) {
|
|
315
|
+
const imgRatio = imgWidth / imgHeight;
|
|
316
|
+
const scale = imgWidth > imgHeight ? maxSizeInPixels / imgWidth : maxSizeInPixels / imgHeight;
|
|
317
|
+
const canvas = document.createElement("canvas");
|
|
318
|
+
canvas.width = imgWidth * scale;
|
|
319
|
+
canvas.height = imgHeight * scale;
|
|
320
|
+
const tileCtx = canvas.getContext("2d");
|
|
321
|
+
tileCtx.drawImage(origImage, 0, 0, canvas.width, canvas.height);
|
|
322
|
+
src = canvas.toDataURL(fileType.toLowerCase().indexOf("jp") > -1 ? "image/jpeg" : "image/png", 1);
|
|
323
|
+
}
|
|
324
|
+
return resolve(src);
|
|
325
|
+
};
|
|
326
|
+
origImage.src = src;
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
static ReadFileAsDataURL(file) {
|
|
331
|
+
return new Promise((resolve) => {
|
|
332
|
+
const reader = new FileReader();
|
|
333
|
+
reader.onloadend = (event) => {
|
|
334
|
+
if (event.target.readyState === FileReader.DONE && (typeof reader.result === "string")) {
|
|
335
|
+
resolve(event.target.result);
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
reader.readAsDataURL(file);
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
static DataURLtoFile(dataURL, filename) {
|
|
342
|
+
const arr = dataURL.split(",");
|
|
343
|
+
const mime = arr[0].match(/:(.*?);/)[1];
|
|
344
|
+
const bstr = atob(arr[1]);
|
|
345
|
+
let n = bstr.length;
|
|
346
|
+
const u8arr = new Uint8Array(n);
|
|
347
|
+
while (n--) {
|
|
348
|
+
u8arr[n] = bstr.charCodeAt(n);
|
|
349
|
+
}
|
|
350
|
+
return new File([u8arr], filename, { type: mime });
|
|
351
|
+
}
|
|
352
|
+
static GetExtensionFromDataUri(dataUri) {
|
|
353
|
+
const data = dataUri;
|
|
354
|
+
return data.replace(/(data:image\/)(.*?)(;base64.*)/gi, "$2");
|
|
355
|
+
}
|
|
356
|
+
static CreateDownloadFileNameFromBase64(dataUri) {
|
|
357
|
+
const ext = this.GetExtensionFromDataUri(dataUri);
|
|
358
|
+
return "preview." + ext;
|
|
359
|
+
}
|
|
360
|
+
static DownloadFromDataUri(dataUri, fileName) {
|
|
361
|
+
if (FileUtils.ValidUrl(dataUri)) {
|
|
362
|
+
window.open(dataUri, "_blank");
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
const link = document.createElement("a");
|
|
366
|
+
link.download = fileName;
|
|
367
|
+
link.href = dataUri;
|
|
368
|
+
document.body.appendChild(link);
|
|
369
|
+
link.click();
|
|
370
|
+
document.body.removeChild(link);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
static ValidUrl(stringToCheck) {
|
|
374
|
+
try {
|
|
375
|
+
const url = new URL(stringToCheck);
|
|
376
|
+
if (!!url) {
|
|
377
|
+
return url.protocol && url.protocol !== "data:" && url.protocol.indexOf("http") > -1;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
catch (e) {
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
static ReplaceExtension(fileName, newExtension) {
|
|
385
|
+
const regEx = /(.+?)(\.[^.]*$|$)/;
|
|
386
|
+
const base = regEx.exec(fileName)[1];
|
|
387
|
+
return base + "." + newExtension;
|
|
388
|
+
}
|
|
389
|
+
static GenerateQRCode(url) {
|
|
390
|
+
let content = "";
|
|
391
|
+
QRCode.toDataURL(url, { errorCorrectionLevel: "H" }, (err, output) => {
|
|
392
|
+
content = output;
|
|
393
|
+
});
|
|
394
|
+
return content;
|
|
395
|
+
}
|
|
48
396
|
}
|
|
49
397
|
exports.FileUtils = FileUtils;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colijnit/mainapi",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.29",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "grunt clean && tsc",
|
|
6
6
|
"browserify": "browserify build/connector.js --s colijn -o dist/out-tsc/bundle.js",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"license": "ISC",
|
|
20
20
|
"private": false,
|
|
21
21
|
"dependencies": {
|
|
22
|
+
"qrcode": "^1.4.4",
|
|
22
23
|
"reflect-metadata": "^0.1.12",
|
|
23
24
|
"rxjs": "6.6.3"
|
|
24
25
|
},
|