@hestia-earth/utils 0.17.15 → 0.17.17
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/esm/array.d.ts +20 -0
- package/esm/array.js +49 -0
- package/esm/bin/bin-validate-terms.d.ts +2 -0
- package/esm/bin/bin-validate-terms.js +14 -0
- package/esm/boolean.d.ts +1 -0
- package/esm/boolean.js +3 -0
- package/esm/date.d.ts +59 -0
- package/esm/date.js +108 -0
- package/esm/delta.d.ts +32 -0
- package/esm/delta.js +78 -0
- package/esm/form.js +18 -0
- package/esm/index.js +7 -0
- package/esm/number.js +218 -0
- package/esm/string.js +117 -0
- package/esm/term.js +52 -0
- package/esm/utils.js +58 -0
- package/esm/validate-terms.js +267 -0
- package/form.d.ts +1 -0
- package/index.d.ts +7 -0
- package/number.d.ts +89 -0
- package/package.json +24 -5
- package/string.d.ts +55 -0
- package/term.d.ts +21 -0
- package/utils.d.ts +5 -0
- package/validate-terms.d.ts +13 -0
- package/{dist/validate-terms.js → validate-terms.js} +1 -1
- /package/{dist/array.d.ts → array.d.ts} +0 -0
- /package/{dist/array.js → array.js} +0 -0
- /package/{dist/bin → bin}/bin-validate-terms.d.ts +0 -0
- /package/{dist/bin → bin}/bin-validate-terms.js +0 -0
- /package/{dist/boolean.d.ts → boolean.d.ts} +0 -0
- /package/{dist/boolean.js → boolean.js} +0 -0
- /package/{dist/date.d.ts → date.d.ts} +0 -0
- /package/{dist/date.js → date.js} +0 -0
- /package/{dist/delta.d.ts → delta.d.ts} +0 -0
- /package/{dist/delta.js → delta.js} +0 -0
- /package/{dist → esm}/form.d.ts +0 -0
- /package/{dist → esm}/index.d.ts +0 -0
- /package/{dist → esm}/number.d.ts +0 -0
- /package/{dist → esm}/string.d.ts +0 -0
- /package/{dist → esm}/term.d.ts +0 -0
- /package/{dist → esm}/utils.d.ts +0 -0
- /package/{dist → esm}/validate-terms.d.ts +0 -0
- /package/{dist/form.js → form.js} +0 -0
- /package/{dist/index.js → index.js} +0 -0
- /package/{dist/number.js → number.js} +0 -0
- /package/{dist/string.js → string.js} +0 -0
- /package/{dist/term.js → term.js} +0 -0
- /package/{dist/utils.js → utils.js} +0 -0
package/string.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trims the string to a certain max length and replace with `...`.
|
|
3
|
+
*
|
|
4
|
+
* @param text The text to ellipsize.
|
|
5
|
+
* @param maxlength The maximum length of the text (including `...`).
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare const ellipsis: (text?: string, maxlength?: number) => string;
|
|
9
|
+
export declare const keyToLabel: (key: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Convert a string to dash-case.
|
|
12
|
+
*
|
|
13
|
+
* @param value The original value.
|
|
14
|
+
* @returns A dash case version of the value.
|
|
15
|
+
*/
|
|
16
|
+
export declare const toDashCase: (value?: string) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Convert a string to camelCase.
|
|
19
|
+
*
|
|
20
|
+
* @param value The original value.
|
|
21
|
+
* @returns A camel case version of the value.
|
|
22
|
+
*/
|
|
23
|
+
export declare const toCamelCase: (value?: string) => string;
|
|
24
|
+
export declare const dateToString: (date: Date) => string;
|
|
25
|
+
/**
|
|
26
|
+
* Returns current date in YYYY-MM-DD format.
|
|
27
|
+
*
|
|
28
|
+
* @returns Date as a string.
|
|
29
|
+
*/
|
|
30
|
+
export declare const now: () => string;
|
|
31
|
+
/**
|
|
32
|
+
* Parse a markdown link.
|
|
33
|
+
*
|
|
34
|
+
* @param link
|
|
35
|
+
* @returns Title and link if found.
|
|
36
|
+
*/
|
|
37
|
+
export declare const parseMarkdownLink: (link: string) => {
|
|
38
|
+
title: string;
|
|
39
|
+
link: string;
|
|
40
|
+
} | {
|
|
41
|
+
title: string;
|
|
42
|
+
link?: undefined;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Parse a citation.
|
|
46
|
+
*
|
|
47
|
+
* @param value
|
|
48
|
+
* @returns
|
|
49
|
+
*/
|
|
50
|
+
export declare const parseCitation: (value: string) => {
|
|
51
|
+
original: string;
|
|
52
|
+
name: string;
|
|
53
|
+
title: string;
|
|
54
|
+
link: string;
|
|
55
|
+
};
|
package/term.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare enum ArrayTreatment {
|
|
2
|
+
mean = "mean",
|
|
3
|
+
sum = "sum",
|
|
4
|
+
first = "first"
|
|
5
|
+
}
|
|
6
|
+
export type propertyValueType = string | number | boolean | null;
|
|
7
|
+
export declare const arrayValue: (values?: propertyValueType[], arrayTreatment?: ArrayTreatment) => propertyValueType;
|
|
8
|
+
/**
|
|
9
|
+
* Calculate the final value of a property.
|
|
10
|
+
*
|
|
11
|
+
* @param value The value as an array or a string/number/boolean.
|
|
12
|
+
* @param termId Optional - us if the term should handle an array in a specific way.
|
|
13
|
+
*/
|
|
14
|
+
export declare const propertyValue: (value: propertyValueType | propertyValueType[], termId?: string) => propertyValueType;
|
|
15
|
+
/**
|
|
16
|
+
* Checks if the value is empty or if the property value is empty.
|
|
17
|
+
*
|
|
18
|
+
* @param value
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
export declare const emptyValue: (value: propertyValueType, termId?: string) => boolean;
|
package/utils.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const isEmpty: (value: any, minKeys?: number) => boolean;
|
|
2
|
+
export declare const isIri: (value?: string) => boolean;
|
|
3
|
+
export declare const isUndefined: <T>(value: T, allowNull?: boolean) => boolean;
|
|
4
|
+
export declare const reduceUndefinedValues: <T>(obj: T, allowNull?: boolean) => Partial<T>;
|
|
5
|
+
export declare const filterUndefinedValues: <T>(values: T[], allowNull?: boolean) => T[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare class Term {
|
|
2
|
+
'@id': string;
|
|
3
|
+
name: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Validate a list of Terms.
|
|
7
|
+
*
|
|
8
|
+
* @param terms The list of Terms to validate.
|
|
9
|
+
* @returns The list of ids/names that could not be found (invalid).
|
|
10
|
+
*/
|
|
11
|
+
export declare const validateTerms: (terms: Term[]) => Promise<string[]>;
|
|
12
|
+
export declare const run: () => Promise<string[]>;
|
|
13
|
+
export {};
|
|
@@ -77,7 +77,7 @@ var Term = /** @class */ (function () {
|
|
|
77
77
|
}());
|
|
78
78
|
var search = function (body) {
|
|
79
79
|
return new Promise(function (resolve, reject) {
|
|
80
|
-
var req = (0, https_1.request)("".concat(API_URL, "/search"), {
|
|
80
|
+
var req = (0, https_1.request)("".concat(API_URL, "/terms/search"), {
|
|
81
81
|
method: 'POST',
|
|
82
82
|
headers: { 'Content-Type': 'application/json' }
|
|
83
83
|
}, function (res) {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{dist → esm}/form.d.ts
RENAMED
|
File without changes
|
/package/{dist → esm}/index.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{dist → esm}/term.d.ts
RENAMED
|
File without changes
|
/package/{dist → esm}/utils.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|