sodas-sdk 1.3.11 → 1.4.0
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/SODAS_SDK_CLASS/DCAT/dataset.d.ts +1 -0
- package/dist/SODAS_SDK_CLASS/DCAT/datasetSeries.d.ts +1 -0
- package/dist/SODAS_SDK_CLASS/template/validation.d.ts +83 -0
- package/dist/__tests__/SODAS_SDK_CLASS/DCAT/dataset/rdf.medium.test.d.ts +1 -0
- package/dist/__tests__/SODAS_SDK_CLASS/DCAT/datasetSeries/rdf.medium.test.d.ts +1 -0
- package/dist/__tests__/SODAS_SDK_CLASS/template/validation/CRUD.medium.test.d.ts +1 -0
- package/dist/__tests__/SODAS_SDK_CLASS/template/validation/LIST.big.test.d.ts +1 -0
- package/dist/__tests__/SODAS_SDK_CLASS/template/validation/escape.small.test.d.ts +1 -0
- package/dist/__tests__/SODAS_SDK_CLASS/template/validation/group.small.test.d.ts +1 -0
- package/dist/__tests__/SODAS_SDK_CLASS/template/validation/manageRules.small.test.d.ts +1 -0
- package/dist/__tests__/SODAS_SDK_CLASS/template/validation/parse.small.test.d.ts +1 -0
- package/dist/__tests__/utility/validation.d.ts +6 -0
- package/dist/index.browser.js +382 -12
- package/dist/index.browser.js.map +1 -1
- package/dist/index.legacy.browser.js +382 -12
- package/dist/index.legacy.browser.js.map +1 -1
- package/dist/index.legacy.node.cjs +382 -12
- package/dist/index.legacy.node.cjs.map +1 -1
- package/dist/index.node.js +382 -12
- package/dist/index.node.js.map +1 -1
- package/package.json +1 -1
- package/dist/SODAS_SDK_FILE/artifactFile.d.ts +0 -8
|
@@ -43,6 +43,7 @@ declare class Dataset extends DCAT_RESOURCE {
|
|
|
43
43
|
*/
|
|
44
44
|
static configureAPIURL(url: string): void;
|
|
45
45
|
static listUserDBRecords(pageNumber?: number, pageSize?: number, sortOrder?: SortOrder): Promise<PaginatedResponse<Dataset>>;
|
|
46
|
+
static getRDF(id: string, depth?: number): Promise<string>;
|
|
46
47
|
static searchDBRecords(searchKeyword: string, pageNumber?: number, pageSize?: number, sortOrder?: SortOrder): Promise<PaginatedResponse<Dataset>>;
|
|
47
48
|
toDTO(): DatasetDTO;
|
|
48
49
|
populateFromDTO(dto: DCAT_MODEL_DTO): Promise<void>;
|
|
@@ -47,6 +47,7 @@ declare class DatasetSeries extends DCAT_RESOURCE {
|
|
|
47
47
|
* @param {string} url - The base URL for the dataset API.
|
|
48
48
|
*/
|
|
49
49
|
static configureAPIURL(url: string): void;
|
|
50
|
+
static getRDF(id: string, depth?: number): Promise<string>;
|
|
50
51
|
static listUserDBRecords(pageNumber?: number, pageSize?: number, sortOrder?: SortOrder): Promise<PaginatedResponse<DatasetSeries>>;
|
|
51
52
|
toDTO(): DatasetSeriesDTO;
|
|
52
53
|
populateFromDTO(dto: DCAT_MODEL_DTO): Promise<void>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { IDType, PaginatedResponse, SortOrder } from "../../core/type";
|
|
2
|
+
import GOVERNANCE_MODEL, { GOVERNANCE_MODEL_DTO } from "../governanceClass";
|
|
3
|
+
export declare enum VALIDATION_TYPE {
|
|
4
|
+
DATA_TYPE = "data_type",
|
|
5
|
+
RANGE = "range",
|
|
6
|
+
PATTERN = "pattern",
|
|
7
|
+
UNIQUENESS = "uniqueness",
|
|
8
|
+
COMPLETENESS = "completeness",
|
|
9
|
+
LENGTH = "length",
|
|
10
|
+
ALLOWED_VALUES = "allowed_values",
|
|
11
|
+
OUTLIER = "outlier",
|
|
12
|
+
STATISTICAL = "statistical"
|
|
13
|
+
}
|
|
14
|
+
export declare enum EXPECTED_TYPE {
|
|
15
|
+
NUMERIC = "numeric",
|
|
16
|
+
STRING = "string",
|
|
17
|
+
DATETIME = "datetime"
|
|
18
|
+
}
|
|
19
|
+
export interface ValidationRule {
|
|
20
|
+
column: string;
|
|
21
|
+
name: string;
|
|
22
|
+
type: VALIDATION_TYPE;
|
|
23
|
+
}
|
|
24
|
+
export interface completnessValidationRule extends ValidationRule {
|
|
25
|
+
type: VALIDATION_TYPE.COMPLETENESS;
|
|
26
|
+
min_completeness: number;
|
|
27
|
+
weight: number;
|
|
28
|
+
}
|
|
29
|
+
export interface dataTypeValidationRule extends ValidationRule {
|
|
30
|
+
type: VALIDATION_TYPE.DATA_TYPE;
|
|
31
|
+
expected_type: EXPECTED_TYPE;
|
|
32
|
+
weight: number;
|
|
33
|
+
}
|
|
34
|
+
export interface uniquenessValidationRule extends ValidationRule {
|
|
35
|
+
type: VALIDATION_TYPE.UNIQUENESS;
|
|
36
|
+
weight: number;
|
|
37
|
+
}
|
|
38
|
+
export interface patternValidationRule extends ValidationRule {
|
|
39
|
+
type: VALIDATION_TYPE.PATTERN;
|
|
40
|
+
pattern: string;
|
|
41
|
+
weight: number;
|
|
42
|
+
}
|
|
43
|
+
export interface ValidationTemplateDTO extends GOVERNANCE_MODEL_DTO {
|
|
44
|
+
name: string;
|
|
45
|
+
description?: string;
|
|
46
|
+
validationRules: ValidationRule[];
|
|
47
|
+
}
|
|
48
|
+
declare class ValidationTemplate extends GOVERNANCE_MODEL {
|
|
49
|
+
private Name;
|
|
50
|
+
private Description;
|
|
51
|
+
private ValidationRules;
|
|
52
|
+
static configureAPIURL(url: string): void;
|
|
53
|
+
toDTO(): ValidationTemplateDTO;
|
|
54
|
+
populateFromFormData(data: any): Promise<void>;
|
|
55
|
+
populateFromDTO(dto: GOVERNANCE_MODEL_DTO): Promise<void>;
|
|
56
|
+
static listDBRecords(pageNumber?: number, pageSize?: number, sortOrder?: SortOrder, vocabularyID?: IDType): Promise<PaginatedResponse<ValidationTemplate>>;
|
|
57
|
+
get name(): string;
|
|
58
|
+
set name(value: string);
|
|
59
|
+
get description(): string;
|
|
60
|
+
set description(value: string);
|
|
61
|
+
get validationRules(): ValidationRule[];
|
|
62
|
+
set validationRules(value: ValidationRule[]);
|
|
63
|
+
static parseValidationRules(rawRules: any[]): ValidationRule[];
|
|
64
|
+
private ensureValidationRulesInitialized;
|
|
65
|
+
createRule(type: VALIDATION_TYPE): ValidationRule;
|
|
66
|
+
deleteRuleAt(index: number): void;
|
|
67
|
+
deleteRuleByTypeAt(type: VALIDATION_TYPE, index: number): void;
|
|
68
|
+
static groupValidationRulesByColumn(rules: ValidationRule[]): Record<string, ValidationRule[]>;
|
|
69
|
+
static groupValidationRulesByType(rules: ValidationRule[]): Record<VALIDATION_TYPE, ValidationRule[]>;
|
|
70
|
+
/**
|
|
71
|
+
* Parse escaped JSON string containing validation_rules to ValidationRule[]
|
|
72
|
+
* @param escapedString - Escaped JSON string like "validation_rules\":[{\"column\":\"class_label\",...}]"
|
|
73
|
+
* @returns Parsed ValidationRule array
|
|
74
|
+
*/
|
|
75
|
+
static parseValidationRulesFromEscapedString(escapedString: string): ValidationRule[];
|
|
76
|
+
/**
|
|
77
|
+
* Convert ValidationRule[] to escaped JSON string
|
|
78
|
+
* @param rules - ValidationRule array to stringify
|
|
79
|
+
* @returns Escaped JSON string with format: "{\"validation_rules\":[...]}"
|
|
80
|
+
*/
|
|
81
|
+
static stringifyValidationRulesToEscapedString(rules: ValidationRule[]): string;
|
|
82
|
+
}
|
|
83
|
+
export default ValidationTemplate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import ValidationTemplate, { ValidationTemplateDTO } from "../../SODAS_SDK_CLASS/template/validation";
|
|
2
|
+
export declare function getTestCreateValidationTemplateDTO(index?: number, name?: string): ValidationTemplateDTO;
|
|
3
|
+
export declare function getTestUpdateValidationTemplateDTO(updating: ValidationTemplate, index?: number): ValidationTemplateDTO;
|
|
4
|
+
export declare function createTestValidationTemplate(index?: number, name?: string): Promise<ValidationTemplate>;
|
|
5
|
+
export declare function createNumberOfTestValidationTemplates(number?: number, name?: string): Promise<ValidationTemplate[]>;
|
|
6
|
+
export declare function deleteAllValidationTemplates(): Promise<void>;
|
package/dist/index.browser.js
CHANGED
|
@@ -2503,6 +2503,30 @@ class Dataset extends _dcatResource__WEBPACK_IMPORTED_MODULE_4__["default"] {
|
|
|
2503
2503
|
throw new _core_error__WEBPACK_IMPORTED_MODULE_0__.UnexpectedResponseFormatError(response);
|
|
2504
2504
|
});
|
|
2505
2505
|
}
|
|
2506
|
+
static getRDF(id_1) {
|
|
2507
|
+
return __awaiter(this, arguments, void 0, function* (id, depth = 1) {
|
|
2508
|
+
// @ts-ignore - static helper expects SODAS_SDK_CLASS constructor type
|
|
2509
|
+
(0,_sodasSDKClass__WEBPACK_IMPORTED_MODULE_3__.throwErrorIfAPIURLNotSetForStatic)(this);
|
|
2510
|
+
const url = `${Dataset.API_URL}/rdf`;
|
|
2511
|
+
let response;
|
|
2512
|
+
try {
|
|
2513
|
+
response = yield axios__WEBPACK_IMPORTED_MODULE_6__["default"].get(url, {
|
|
2514
|
+
headers: Object.assign({ Accept: "text/turtle" }, (Dataset.BEARER_TOKEN && {
|
|
2515
|
+
Authorization: `Bearer ${Dataset.BEARER_TOKEN}`,
|
|
2516
|
+
})),
|
|
2517
|
+
params: { id, depth },
|
|
2518
|
+
responseType: "text",
|
|
2519
|
+
});
|
|
2520
|
+
}
|
|
2521
|
+
catch (error) {
|
|
2522
|
+
(0,_core_util__WEBPACK_IMPORTED_MODULE_2__.handleAxiosError)(error);
|
|
2523
|
+
}
|
|
2524
|
+
if (typeof response.data === "string") {
|
|
2525
|
+
return response.data;
|
|
2526
|
+
}
|
|
2527
|
+
throw new _core_error__WEBPACK_IMPORTED_MODULE_0__.UnexpectedResponseFormatError(response);
|
|
2528
|
+
});
|
|
2529
|
+
}
|
|
2506
2530
|
static searchDBRecords(searchKeyword_1) {
|
|
2507
2531
|
return __awaiter(this, arguments, void 0, function* (searchKeyword, pageNumber = 1, pageSize = 10, sortOrder = _core_type__WEBPACK_IMPORTED_MODULE_1__.SortOrder.DESC) {
|
|
2508
2532
|
if (!searchKeyword || !searchKeyword.trim()) {
|
|
@@ -2958,6 +2982,30 @@ class DatasetSeries extends _dcatResource__WEBPACK_IMPORTED_MODULE_5__["default"
|
|
|
2958
2982
|
DatasetSeries.API_URL = `${url}/datasetseries`;
|
|
2959
2983
|
DatasetSeries.LIST_URL = `${DatasetSeries.API_URL}/list`;
|
|
2960
2984
|
}
|
|
2985
|
+
static getRDF(id_1) {
|
|
2986
|
+
return __awaiter(this, arguments, void 0, function* (id, depth = 1) {
|
|
2987
|
+
// @ts-ignore - static helper expects SODAS_SDK_CLASS constructor type
|
|
2988
|
+
(0,_sodasSDKClass__WEBPACK_IMPORTED_MODULE_3__.throwErrorIfAPIURLNotSetForStatic)(this);
|
|
2989
|
+
const url = `${DatasetSeries.API_URL}/rdf`;
|
|
2990
|
+
let response;
|
|
2991
|
+
try {
|
|
2992
|
+
response = yield axios__WEBPACK_IMPORTED_MODULE_6__["default"].get(url, {
|
|
2993
|
+
headers: Object.assign({ Accept: "text/turtle" }, (DatasetSeries.BEARER_TOKEN && {
|
|
2994
|
+
Authorization: `Bearer ${DatasetSeries.BEARER_TOKEN}`,
|
|
2995
|
+
})),
|
|
2996
|
+
params: { id, depth },
|
|
2997
|
+
responseType: "text",
|
|
2998
|
+
});
|
|
2999
|
+
}
|
|
3000
|
+
catch (error) {
|
|
3001
|
+
(0,_core_util__WEBPACK_IMPORTED_MODULE_2__.handleAxiosError)(error);
|
|
3002
|
+
}
|
|
3003
|
+
if (typeof response.data === "string") {
|
|
3004
|
+
return response.data;
|
|
3005
|
+
}
|
|
3006
|
+
throw new _core_error__WEBPACK_IMPORTED_MODULE_0__.UnexpectedResponseFormatError(response);
|
|
3007
|
+
});
|
|
3008
|
+
}
|
|
2961
3009
|
static listUserDBRecords() {
|
|
2962
3010
|
return __awaiter(this, arguments, void 0, function* (pageNumber = 1, pageSize = 10, sortOrder = _core_type__WEBPACK_IMPORTED_MODULE_1__.SortOrder.DESC) {
|
|
2963
3011
|
// @ts-ignore - static helper expects SODAS_SDK_CLASS constructor type
|
|
@@ -4776,26 +4824,345 @@ class SODAS_SDK_CLASS {
|
|
|
4776
4824
|
|
|
4777
4825
|
/***/ }),
|
|
4778
4826
|
|
|
4779
|
-
/***/ "./lib/
|
|
4780
|
-
|
|
4781
|
-
!*** ./lib/
|
|
4782
|
-
|
|
4827
|
+
/***/ "./lib/SODAS_SDK_CLASS/template/validation.ts":
|
|
4828
|
+
/*!****************************************************!*\
|
|
4829
|
+
!*** ./lib/SODAS_SDK_CLASS/template/validation.ts ***!
|
|
4830
|
+
\****************************************************/
|
|
4783
4831
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
4784
4832
|
|
|
4785
4833
|
__webpack_require__.r(__webpack_exports__);
|
|
4786
4834
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
4835
|
+
/* harmony export */ EXPECTED_TYPE: () => (/* binding */ EXPECTED_TYPE),
|
|
4836
|
+
/* harmony export */ VALIDATION_TYPE: () => (/* binding */ VALIDATION_TYPE),
|
|
4787
4837
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
4788
4838
|
/* harmony export */ });
|
|
4789
|
-
/* harmony import */ var
|
|
4839
|
+
/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! axios */ "./node_modules/axios/lib/axios.js");
|
|
4840
|
+
/* harmony import */ var _core_error__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../core/error */ "./lib/core/error.ts");
|
|
4841
|
+
/* harmony import */ var _core_type__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../core/type */ "./lib/core/type.ts");
|
|
4842
|
+
/* harmony import */ var _core_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../core/util */ "./lib/core/util.ts");
|
|
4843
|
+
/* harmony import */ var _governanceClass__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../governanceClass */ "./lib/SODAS_SDK_CLASS/governanceClass.ts");
|
|
4844
|
+
/* harmony import */ var _sodasSDKClass__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sodasSDKClass */ "./lib/SODAS_SDK_CLASS/sodasSDKClass.ts");
|
|
4845
|
+
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4846
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4847
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4848
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
4849
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
4850
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
4851
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
4852
|
+
});
|
|
4853
|
+
};
|
|
4854
|
+
|
|
4855
|
+
|
|
4856
|
+
|
|
4790
4857
|
|
|
4791
|
-
|
|
4858
|
+
|
|
4859
|
+
|
|
4860
|
+
var VALIDATION_TYPE;
|
|
4861
|
+
(function (VALIDATION_TYPE) {
|
|
4862
|
+
VALIDATION_TYPE["DATA_TYPE"] = "data_type";
|
|
4863
|
+
VALIDATION_TYPE["RANGE"] = "range";
|
|
4864
|
+
VALIDATION_TYPE["PATTERN"] = "pattern";
|
|
4865
|
+
VALIDATION_TYPE["UNIQUENESS"] = "uniqueness";
|
|
4866
|
+
VALIDATION_TYPE["COMPLETENESS"] = "completeness";
|
|
4867
|
+
VALIDATION_TYPE["LENGTH"] = "length";
|
|
4868
|
+
VALIDATION_TYPE["ALLOWED_VALUES"] = "allowed_values";
|
|
4869
|
+
VALIDATION_TYPE["OUTLIER"] = "outlier";
|
|
4870
|
+
VALIDATION_TYPE["STATISTICAL"] = "statistical";
|
|
4871
|
+
})(VALIDATION_TYPE || (VALIDATION_TYPE = {}));
|
|
4872
|
+
var EXPECTED_TYPE;
|
|
4873
|
+
(function (EXPECTED_TYPE) {
|
|
4874
|
+
EXPECTED_TYPE["NUMERIC"] = "numeric";
|
|
4875
|
+
EXPECTED_TYPE["STRING"] = "string";
|
|
4876
|
+
EXPECTED_TYPE["DATETIME"] = "datetime";
|
|
4877
|
+
})(EXPECTED_TYPE || (EXPECTED_TYPE = {}));
|
|
4878
|
+
class ValidationTemplate extends _governanceClass__WEBPACK_IMPORTED_MODULE_3__["default"] {
|
|
4792
4879
|
static configureAPIURL(url) {
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4880
|
+
const PREFIX = "api/v1/governance/template";
|
|
4881
|
+
ValidationTemplate.API_URL = `${url}/${PREFIX}/validation`;
|
|
4882
|
+
ValidationTemplate.LIST_URL = `${ValidationTemplate.API_URL}/list`;
|
|
4883
|
+
ValidationTemplate.GET_URL = `${ValidationTemplate.API_URL}/get`;
|
|
4884
|
+
ValidationTemplate.CREATE_URL = `${ValidationTemplate.API_URL}/create`;
|
|
4885
|
+
ValidationTemplate.UPDATE_URL = `${ValidationTemplate.API_URL}/update`;
|
|
4886
|
+
ValidationTemplate.DELETE_URL = `${ValidationTemplate.API_URL}/remove`;
|
|
4887
|
+
}
|
|
4888
|
+
toDTO() {
|
|
4889
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, super.toDTO()), { name: this.Name }), (this.ValidationRules && { validationRules: this.ValidationRules })), (this.Description && { description: this.Description }));
|
|
4890
|
+
}
|
|
4891
|
+
populateFromFormData(data) {
|
|
4892
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4893
|
+
throw new _core_error__WEBPACK_IMPORTED_MODULE_0__.NeedToImplementError();
|
|
4894
|
+
});
|
|
4895
|
+
}
|
|
4896
|
+
populateFromDTO(dto) {
|
|
4897
|
+
const _super = Object.create(null, {
|
|
4898
|
+
populateFromDTO: { get: () => super.populateFromDTO }
|
|
4899
|
+
});
|
|
4900
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4901
|
+
yield _super.populateFromDTO.call(this, dto);
|
|
4902
|
+
const validationTemplateDTO = dto;
|
|
4903
|
+
this.ValidationRules = validationTemplateDTO.validationRules;
|
|
4904
|
+
this.Name = validationTemplateDTO.name;
|
|
4905
|
+
this.Description = validationTemplateDTO.description;
|
|
4906
|
+
});
|
|
4907
|
+
}
|
|
4908
|
+
static listDBRecords() {
|
|
4909
|
+
return __awaiter(this, arguments, void 0, function* (pageNumber = 1, pageSize = 10, sortOrder = _core_type__WEBPACK_IMPORTED_MODULE_1__.SortOrder.DESC, vocabularyID) {
|
|
4910
|
+
(0,_sodasSDKClass__WEBPACK_IMPORTED_MODULE_4__.throwErrorIfAPIURLNotSetForStatic)(ValidationTemplate);
|
|
4911
|
+
try {
|
|
4912
|
+
const response = yield axios__WEBPACK_IMPORTED_MODULE_5__["default"].get(ValidationTemplate.LIST_URL, {
|
|
4913
|
+
params: {
|
|
4914
|
+
offset: (pageNumber - 1) * pageSize,
|
|
4915
|
+
limit: pageSize,
|
|
4916
|
+
ordered: sortOrder,
|
|
4917
|
+
vocabularyId: vocabularyID,
|
|
4918
|
+
},
|
|
4919
|
+
// headers,
|
|
4920
|
+
});
|
|
4921
|
+
return yield ValidationTemplate.listResponseToPaginatedResponse(response);
|
|
4922
|
+
}
|
|
4923
|
+
catch (error) {
|
|
4924
|
+
(0,_core_util__WEBPACK_IMPORTED_MODULE_2__.handleAxiosError)(error);
|
|
4925
|
+
}
|
|
4926
|
+
});
|
|
4927
|
+
}
|
|
4928
|
+
get name() {
|
|
4929
|
+
return this.Name;
|
|
4930
|
+
}
|
|
4931
|
+
set name(value) {
|
|
4932
|
+
this.Name = value;
|
|
4933
|
+
}
|
|
4934
|
+
get description() {
|
|
4935
|
+
return this.Description;
|
|
4936
|
+
}
|
|
4937
|
+
set description(value) {
|
|
4938
|
+
this.Description = value;
|
|
4939
|
+
}
|
|
4940
|
+
get validationRules() {
|
|
4941
|
+
return this.ValidationRules;
|
|
4942
|
+
}
|
|
4943
|
+
set validationRules(value) {
|
|
4944
|
+
this.ValidationRules = value;
|
|
4945
|
+
}
|
|
4946
|
+
static parseValidationRules(rawRules) {
|
|
4947
|
+
return rawRules.map((rule) => {
|
|
4948
|
+
const baseRule = {
|
|
4949
|
+
column: rule.column,
|
|
4950
|
+
name: rule.name,
|
|
4951
|
+
type: rule.type,
|
|
4952
|
+
};
|
|
4953
|
+
switch (rule.type) {
|
|
4954
|
+
case VALIDATION_TYPE.COMPLETENESS:
|
|
4955
|
+
return Object.assign(Object.assign({}, baseRule), { type: VALIDATION_TYPE.COMPLETENESS, min_completeness: rule.min_completeness, weight: rule.weight });
|
|
4956
|
+
case VALIDATION_TYPE.DATA_TYPE:
|
|
4957
|
+
return Object.assign(Object.assign({}, baseRule), { type: VALIDATION_TYPE.DATA_TYPE, expected_type: rule.expected_type, weight: rule.weight });
|
|
4958
|
+
case VALIDATION_TYPE.PATTERN:
|
|
4959
|
+
return Object.assign(Object.assign({}, baseRule), { type: VALIDATION_TYPE.PATTERN, pattern: rule.pattern, weight: rule.weight });
|
|
4960
|
+
case VALIDATION_TYPE.UNIQUENESS:
|
|
4961
|
+
return Object.assign(Object.assign({}, baseRule), { type: VALIDATION_TYPE.UNIQUENESS, weight: rule.weight });
|
|
4962
|
+
default:
|
|
4963
|
+
return baseRule;
|
|
4964
|
+
}
|
|
4965
|
+
});
|
|
4966
|
+
}
|
|
4967
|
+
ensureValidationRulesInitialized() {
|
|
4968
|
+
if (!this.ValidationRules) {
|
|
4969
|
+
this.ValidationRules = [];
|
|
4970
|
+
}
|
|
4971
|
+
}
|
|
4972
|
+
createRule(type) {
|
|
4973
|
+
this.ensureValidationRulesInitialized();
|
|
4974
|
+
let rule;
|
|
4975
|
+
const baseRule = {
|
|
4976
|
+
column: "",
|
|
4977
|
+
name: "",
|
|
4978
|
+
type,
|
|
4979
|
+
};
|
|
4980
|
+
switch (type) {
|
|
4981
|
+
case VALIDATION_TYPE.COMPLETENESS:
|
|
4982
|
+
rule = Object.assign(Object.assign({}, baseRule), { min_completeness: 0, weight: 0 });
|
|
4983
|
+
break;
|
|
4984
|
+
case VALIDATION_TYPE.DATA_TYPE:
|
|
4985
|
+
rule = Object.assign(Object.assign({}, baseRule), { expected_type: EXPECTED_TYPE.STRING, weight: 0 });
|
|
4986
|
+
break;
|
|
4987
|
+
case VALIDATION_TYPE.PATTERN:
|
|
4988
|
+
rule = Object.assign(Object.assign({}, baseRule), { pattern: "", weight: 0 });
|
|
4989
|
+
break;
|
|
4990
|
+
case VALIDATION_TYPE.UNIQUENESS:
|
|
4991
|
+
rule = Object.assign(Object.assign({}, baseRule), { weight: 0 });
|
|
4992
|
+
break;
|
|
4993
|
+
default:
|
|
4994
|
+
rule = baseRule;
|
|
4995
|
+
}
|
|
4996
|
+
this.ValidationRules.push(rule);
|
|
4997
|
+
return rule;
|
|
4998
|
+
}
|
|
4999
|
+
deleteRuleAt(index) {
|
|
5000
|
+
if (!this.ValidationRules) {
|
|
5001
|
+
return;
|
|
5002
|
+
}
|
|
5003
|
+
if (index < 0 || index >= this.ValidationRules.length) {
|
|
5004
|
+
return;
|
|
5005
|
+
}
|
|
5006
|
+
this.ValidationRules.splice(index, 1);
|
|
5007
|
+
}
|
|
5008
|
+
deleteRuleByTypeAt(type, index) {
|
|
5009
|
+
if (!this.ValidationRules) {
|
|
5010
|
+
return;
|
|
5011
|
+
}
|
|
5012
|
+
if (index < 0) {
|
|
5013
|
+
return;
|
|
5014
|
+
}
|
|
5015
|
+
let current = 0;
|
|
5016
|
+
for (let i = 0; i < this.ValidationRules.length; i++) {
|
|
5017
|
+
if (this.ValidationRules[i].type === type) {
|
|
5018
|
+
if (current === index) {
|
|
5019
|
+
this.ValidationRules.splice(i, 1);
|
|
5020
|
+
return;
|
|
5021
|
+
}
|
|
5022
|
+
current++;
|
|
5023
|
+
}
|
|
5024
|
+
}
|
|
5025
|
+
}
|
|
5026
|
+
static groupValidationRulesByColumn(rules) {
|
|
5027
|
+
return rules.reduce((acc, rule) => {
|
|
5028
|
+
const column = rule.column;
|
|
5029
|
+
if (!acc[column]) {
|
|
5030
|
+
acc[column] = [];
|
|
5031
|
+
}
|
|
5032
|
+
acc[column].push(rule);
|
|
5033
|
+
return acc;
|
|
5034
|
+
}, {});
|
|
5035
|
+
}
|
|
5036
|
+
static groupValidationRulesByType(rules) {
|
|
5037
|
+
return rules.reduce((acc, rule) => {
|
|
5038
|
+
const type = rule.type;
|
|
5039
|
+
if (!acc[type]) {
|
|
5040
|
+
acc[type] = [];
|
|
5041
|
+
}
|
|
5042
|
+
acc[type].push(rule);
|
|
5043
|
+
return acc;
|
|
5044
|
+
}, {});
|
|
5045
|
+
}
|
|
5046
|
+
/**
|
|
5047
|
+
* Parse escaped JSON string containing validation_rules to ValidationRule[]
|
|
5048
|
+
* @param escapedString - Escaped JSON string like "validation_rules\":[{\"column\":\"class_label\",...}]"
|
|
5049
|
+
* @returns Parsed ValidationRule array
|
|
5050
|
+
*/
|
|
5051
|
+
static parseValidationRulesFromEscapedString(escapedString) {
|
|
5052
|
+
let processedString = escapedString.trim();
|
|
5053
|
+
// Remove surrounding quotes if present (e.g., '"{"validation_rules":...}"' -> '{"validation_rules":...}')
|
|
5054
|
+
// Check for both single and double quotes
|
|
5055
|
+
if (((processedString.startsWith('"') && processedString.endsWith('"')) ||
|
|
5056
|
+
(processedString.startsWith("'") && processedString.endsWith("'"))) &&
|
|
5057
|
+
processedString.length > 1) {
|
|
5058
|
+
processedString = processedString.slice(1, -1).trim();
|
|
5059
|
+
}
|
|
5060
|
+
// Unescape the string (replace \" with ")
|
|
5061
|
+
// Handle both \" and \\\" cases to avoid double-escaping issues
|
|
5062
|
+
let unescapedString = processedString;
|
|
5063
|
+
// First handle \\\" -> \"
|
|
5064
|
+
unescapedString = unescapedString.replace(/\\\\"/g, '\\"');
|
|
5065
|
+
// Then handle \" -> "
|
|
5066
|
+
unescapedString = unescapedString.replace(/\\"/g, '"');
|
|
5067
|
+
// Try to parse as JSON
|
|
5068
|
+
let parsed;
|
|
5069
|
+
try {
|
|
5070
|
+
// First try parsing directly
|
|
5071
|
+
parsed = JSON.parse(unescapedString);
|
|
5072
|
+
}
|
|
5073
|
+
catch (error) {
|
|
5074
|
+
// If parsing fails, try different approaches
|
|
5075
|
+
const trimmed = unescapedString.trim();
|
|
5076
|
+
// If it starts with "validation_rules" but is not wrapped in braces
|
|
5077
|
+
if (trimmed.startsWith('"validation_rules"') ||
|
|
5078
|
+
trimmed.startsWith("validation_rules")) {
|
|
5079
|
+
// Try wrapping in braces
|
|
5080
|
+
const wrapped = trimmed.startsWith('"')
|
|
5081
|
+
? `{${trimmed}}`
|
|
5082
|
+
: `{"${trimmed}}`;
|
|
5083
|
+
try {
|
|
5084
|
+
parsed = JSON.parse(wrapped);
|
|
5085
|
+
}
|
|
5086
|
+
catch (e) {
|
|
5087
|
+
// If still fails, try without the leading quote
|
|
5088
|
+
const withoutQuote = trimmed.replace(/^"/, "");
|
|
5089
|
+
parsed = JSON.parse(`{"${withoutQuote}`);
|
|
5090
|
+
}
|
|
5091
|
+
}
|
|
5092
|
+
else if (trimmed.startsWith("{") && trimmed.endsWith("}")) {
|
|
5093
|
+
// Already looks like JSON object, try parsing again after trimming
|
|
5094
|
+
parsed = JSON.parse(trimmed);
|
|
5095
|
+
}
|
|
5096
|
+
else {
|
|
5097
|
+
throw error;
|
|
5098
|
+
}
|
|
5099
|
+
}
|
|
5100
|
+
// Extract validation_rules array
|
|
5101
|
+
let validationRules;
|
|
5102
|
+
// If it's already an array, use it directly
|
|
5103
|
+
if (Array.isArray(parsed)) {
|
|
5104
|
+
validationRules = parsed;
|
|
5105
|
+
}
|
|
5106
|
+
else if (parsed.validation_rules) {
|
|
5107
|
+
// If it's an object with validation_rules property
|
|
5108
|
+
validationRules = parsed.validation_rules;
|
|
5109
|
+
}
|
|
5110
|
+
else if (typeof parsed === "object") {
|
|
5111
|
+
// If it's an object but no validation_rules property, try to use it as is
|
|
5112
|
+
validationRules = parsed;
|
|
5113
|
+
}
|
|
5114
|
+
else {
|
|
5115
|
+
throw new Error("Invalid format: validation_rules not found");
|
|
5116
|
+
}
|
|
5117
|
+
// Ensure validationRules is an array
|
|
5118
|
+
if (!Array.isArray(validationRules)) {
|
|
5119
|
+
throw new Error("Invalid format: validation_rules must be an array");
|
|
5120
|
+
}
|
|
5121
|
+
const parsedRules = ValidationTemplate.parseValidationRules(validationRules);
|
|
5122
|
+
parsedRules._escapedString = escapedString;
|
|
5123
|
+
return parsedRules;
|
|
5124
|
+
}
|
|
5125
|
+
/**
|
|
5126
|
+
* Convert ValidationRule[] to escaped JSON string
|
|
5127
|
+
* @param rules - ValidationRule array to stringify
|
|
5128
|
+
* @returns Escaped JSON string with format: "{\"validation_rules\":[...]}"
|
|
5129
|
+
*/
|
|
5130
|
+
static stringifyValidationRulesToEscapedString(rules) {
|
|
5131
|
+
// Convert ValidationRule[] to plain objects for JSON serialization
|
|
5132
|
+
const plainRules = rules.map((rule) => {
|
|
5133
|
+
const plainRule = {
|
|
5134
|
+
column: rule.column,
|
|
5135
|
+
name: rule.name,
|
|
5136
|
+
type: rule.type,
|
|
5137
|
+
};
|
|
5138
|
+
switch (rule.type) {
|
|
5139
|
+
case VALIDATION_TYPE.COMPLETENESS:
|
|
5140
|
+
const completenessRule = rule;
|
|
5141
|
+
return Object.assign(Object.assign({}, plainRule), { min_completeness: completenessRule.min_completeness, weight: completenessRule.weight });
|
|
5142
|
+
case VALIDATION_TYPE.DATA_TYPE:
|
|
5143
|
+
const dataTypeRule = rule;
|
|
5144
|
+
return Object.assign(Object.assign({}, plainRule), { expected_type: dataTypeRule.expected_type, weight: dataTypeRule.weight });
|
|
5145
|
+
case VALIDATION_TYPE.PATTERN:
|
|
5146
|
+
const patternRule = rule;
|
|
5147
|
+
return Object.assign(Object.assign({}, plainRule), { pattern: patternRule.pattern, weight: patternRule.weight });
|
|
5148
|
+
case VALIDATION_TYPE.UNIQUENESS:
|
|
5149
|
+
const uniquenessRule = rule;
|
|
5150
|
+
return Object.assign(Object.assign({}, plainRule), { weight: uniquenessRule.weight });
|
|
5151
|
+
default:
|
|
5152
|
+
return plainRule;
|
|
5153
|
+
}
|
|
5154
|
+
});
|
|
5155
|
+
// Create object with validation_rules property
|
|
5156
|
+
if (rules._escapedString) {
|
|
5157
|
+
return rules._escapedString;
|
|
5158
|
+
}
|
|
5159
|
+
const obj = { validation_rules: plainRules };
|
|
5160
|
+
const jsonString = JSON.stringify(obj);
|
|
5161
|
+
const escaped = jsonString.replace(/"/g, '\\"');
|
|
5162
|
+
return '"' + escaped + '"';
|
|
4796
5163
|
}
|
|
4797
5164
|
}
|
|
4798
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (
|
|
5165
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ValidationTemplate);
|
|
4799
5166
|
|
|
4800
5167
|
|
|
4801
5168
|
/***/ }),
|
|
@@ -5067,7 +5434,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
5067
5434
|
/* harmony import */ var _SODAS_SDK_CLASS_DCAT_distribution__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../SODAS_SDK_CLASS/DCAT/distribution */ "./lib/SODAS_SDK_CLASS/DCAT/distribution.ts");
|
|
5068
5435
|
/* harmony import */ var _SODAS_SDK_CLASS_dictionary_term__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../SODAS_SDK_CLASS/dictionary/term */ "./lib/SODAS_SDK_CLASS/dictionary/term.ts");
|
|
5069
5436
|
/* harmony import */ var _SODAS_SDK_CLASS_dictionary_vocabulary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../SODAS_SDK_CLASS/dictionary/vocabulary */ "./lib/SODAS_SDK_CLASS/dictionary/vocabulary.ts");
|
|
5070
|
-
/* harmony import */ var
|
|
5437
|
+
/* harmony import */ var _SODAS_SDK_CLASS_template_validation__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../SODAS_SDK_CLASS/template/validation */ "./lib/SODAS_SDK_CLASS/template/validation.ts");
|
|
5071
5438
|
/* harmony import */ var _SODAS_SDK_FILE_dataFile__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../SODAS_SDK_FILE/dataFile */ "./lib/SODAS_SDK_FILE/dataFile.ts");
|
|
5072
5439
|
/* harmony import */ var _SODAS_SDK_FILE_thumbnailFile__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../SODAS_SDK_FILE/thumbnailFile */ "./lib/SODAS_SDK_FILE/thumbnailFile.ts");
|
|
5073
5440
|
/* harmony import */ var _error__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./error */ "./lib/core/error.ts");
|
|
@@ -5157,9 +5524,9 @@ class Config {
|
|
|
5157
5524
|
console.error("DATAHUB_API_URL not found in config");
|
|
5158
5525
|
}
|
|
5159
5526
|
if (this.governanceBaseUrl) {
|
|
5160
|
-
_SODAS_SDK_FILE_artifactFile__WEBPACK_IMPORTED_MODULE_6__["default"].configureAPIURL(SLASH_DELETED_GOVERNANCE_PORTAL_API_URL);
|
|
5161
5527
|
_SODAS_SDK_CLASS_dictionary_vocabulary__WEBPACK_IMPORTED_MODULE_5__["default"].configureAPIURL(SLASH_DELETED_GOVERNANCE_PORTAL_API_URL);
|
|
5162
5528
|
_SODAS_SDK_CLASS_dictionary_term__WEBPACK_IMPORTED_MODULE_4__["default"].configureAPIURL(SLASH_DELETED_GOVERNANCE_PORTAL_API_URL);
|
|
5529
|
+
_SODAS_SDK_CLASS_template_validation__WEBPACK_IMPORTED_MODULE_6__["default"].configureAPIURL(SLASH_DELETED_GOVERNANCE_PORTAL_API_URL);
|
|
5163
5530
|
}
|
|
5164
5531
|
else {
|
|
5165
5532
|
console.error("GOVERNANCE_API_URL not found in config");
|
|
@@ -5433,6 +5800,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
5433
5800
|
/* harmony import */ var _SODAS_SDK_CLASS_DCAT_distribution__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../SODAS_SDK_CLASS/DCAT/distribution */ "./lib/SODAS_SDK_CLASS/DCAT/distribution.ts");
|
|
5434
5801
|
/* harmony import */ var _SODAS_SDK_CLASS_dictionary_term__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../SODAS_SDK_CLASS/dictionary/term */ "./lib/SODAS_SDK_CLASS/dictionary/term.ts");
|
|
5435
5802
|
/* harmony import */ var _SODAS_SDK_CLASS_dictionary_vocabulary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../SODAS_SDK_CLASS/dictionary/vocabulary */ "./lib/SODAS_SDK_CLASS/dictionary/vocabulary.ts");
|
|
5803
|
+
/* harmony import */ var _SODAS_SDK_CLASS_template_validation__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../SODAS_SDK_CLASS/template/validation */ "./lib/SODAS_SDK_CLASS/template/validation.ts");
|
|
5804
|
+
|
|
5436
5805
|
|
|
5437
5806
|
|
|
5438
5807
|
|
|
@@ -5448,6 +5817,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
5448
5817
|
function setGovernanceBearerToken(token) {
|
|
5449
5818
|
_SODAS_SDK_CLASS_dictionary_vocabulary__WEBPACK_IMPORTED_MODULE_5__["default"].BEARER_TOKEN = token;
|
|
5450
5819
|
_SODAS_SDK_CLASS_dictionary_term__WEBPACK_IMPORTED_MODULE_4__["default"].BEARER_TOKEN = token;
|
|
5820
|
+
_SODAS_SDK_CLASS_template_validation__WEBPACK_IMPORTED_MODULE_6__["default"].BEARER_TOKEN = token;
|
|
5451
5821
|
}
|
|
5452
5822
|
function setLegacyDatahubBearerToken(token) {
|
|
5453
5823
|
_SODAS_SDK_CLASS_DCAT_dataset__WEBPACK_IMPORTED_MODULE_1__["default"].BEARER_TOKEN = token;
|