namirasoft-core 1.2.13 → 1.2.15
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/.gitlab-ci.yml +13 -13
- package/dist/EncryptionOperation.d.ts +2 -2
- package/dist/EncryptionOperation.js +21 -10
- package/dist/EncryptionOperation.js.map +1 -1
- package/dist/SignOperation.d.ts +4 -0
- package/dist/SignOperation.js +14 -0
- package/dist/SignOperation.js.map +1 -0
- package/package.json +15 -15
- package/src/BaseDatabaseRow.ts +6 -6
- package/src/BaseServer.ts +72 -72
- package/src/ConvertService.ts +98 -98
- package/src/Countries.ts +486 -486
- package/src/Country.ts +21 -21
- package/src/CountryOperation.ts +98 -98
- package/src/EncryptionOperation.ts +40 -29
- package/src/ErrorOperation.ts +13 -13
- package/src/FileOperation.ts +50 -50
- package/src/GeoOperation.ts +18 -18
- package/src/HTTPError.ts +8 -8
- package/src/HTTPMethod.ts +6 -6
- package/src/HashOperation.ts +24 -24
- package/src/IStorage.ts +5 -5
- package/src/IStorageLocal.ts +16 -16
- package/src/IStorageMemory.ts +17 -17
- package/src/ObjectService.ts +23 -23
- package/src/PackageService.ts +66 -66
- package/src/PhoneOperation.ts +8 -8
- package/src/StringOperation.ts +18 -18
- package/src/TimeOperation.ts +262 -262
- package/src/URLOperation.ts +54 -54
- package/src/VersionOperation.ts +46 -46
- package/src/index.ts +23 -23
- package/tsconfig.json +29 -29
package/src/ObjectService.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { ConvertService } from "./ConvertService";
|
|
2
|
-
import { ParsedNameValue } from "./ParsedNameValue";
|
|
3
|
-
|
|
4
|
-
export class ObjectService extends ConvertService
|
|
5
|
-
{
|
|
6
|
-
private object: ParsedNameValue;
|
|
7
|
-
constructor(object: ParsedNameValue, mandatory: boolean = false)
|
|
8
|
-
{
|
|
9
|
-
super(mandatory);
|
|
10
|
-
this.object = object;
|
|
11
|
-
}
|
|
12
|
-
override getNullString()
|
|
13
|
-
{
|
|
14
|
-
let ans: string | null = null;
|
|
15
|
-
if (Array.isArray(this.object))
|
|
16
|
-
{
|
|
17
|
-
if (this.object.length > 0)
|
|
18
|
-
ans = this.object[0];
|
|
19
|
-
}
|
|
20
|
-
else if (this.object != null && this.object != undefined)
|
|
21
|
-
ans = this.object + "";
|
|
22
|
-
return ans;
|
|
23
|
-
}
|
|
1
|
+
import { ConvertService } from "./ConvertService";
|
|
2
|
+
import { ParsedNameValue } from "./ParsedNameValue";
|
|
3
|
+
|
|
4
|
+
export class ObjectService extends ConvertService
|
|
5
|
+
{
|
|
6
|
+
private object: ParsedNameValue;
|
|
7
|
+
constructor(object: ParsedNameValue, mandatory: boolean = false)
|
|
8
|
+
{
|
|
9
|
+
super(mandatory);
|
|
10
|
+
this.object = object;
|
|
11
|
+
}
|
|
12
|
+
override getNullString()
|
|
13
|
+
{
|
|
14
|
+
let ans: string | null = null;
|
|
15
|
+
if (Array.isArray(this.object))
|
|
16
|
+
{
|
|
17
|
+
if (this.object.length > 0)
|
|
18
|
+
ans = this.object[0];
|
|
19
|
+
}
|
|
20
|
+
else if (this.object != null && this.object != undefined)
|
|
21
|
+
ans = this.object + "";
|
|
22
|
+
return ans;
|
|
23
|
+
}
|
|
24
24
|
}
|
package/src/PackageService.ts
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
let fs: any;
|
|
2
|
-
if (typeof window === 'undefined')
|
|
3
|
-
fs = require('fs');
|
|
4
|
-
import { FileOperation } from "./FileOperation";
|
|
5
|
-
|
|
6
|
-
export class PackageService
|
|
7
|
-
{
|
|
8
|
-
static get(path: string): PackageService
|
|
9
|
-
{
|
|
10
|
-
if (path)
|
|
11
|
-
{
|
|
12
|
-
const json = JSON.parse(fs.readFileSync(path, 'utf8'));
|
|
13
|
-
if (json)
|
|
14
|
-
return new PackageService(path, json);
|
|
15
|
-
}
|
|
16
|
-
throw new Error("Coundn't find package");
|
|
17
|
-
}
|
|
18
|
-
static getMain(): PackageService
|
|
19
|
-
{
|
|
20
|
-
const paths = FileOperation.findUp('package.json');
|
|
21
|
-
if (paths)
|
|
22
|
-
return this.get(paths[paths.length - 1]);
|
|
23
|
-
throw new Error("Coundn't find package");
|
|
24
|
-
}
|
|
25
|
-
static getThis(): PackageService
|
|
26
|
-
{
|
|
27
|
-
const paths = FileOperation.findUp('package.json');
|
|
28
|
-
if (paths)
|
|
29
|
-
return this.get(paths[0]);
|
|
30
|
-
throw new Error("Coundn't find package");
|
|
31
|
-
}
|
|
32
|
-
private path: string;
|
|
33
|
-
private json: any;
|
|
34
|
-
constructor(path: string, json: any)
|
|
35
|
-
{
|
|
36
|
-
this.json = json;
|
|
37
|
-
this.path = path;
|
|
38
|
-
}
|
|
39
|
-
getPath(): string
|
|
40
|
-
{
|
|
41
|
-
return this.path;
|
|
42
|
-
}
|
|
43
|
-
getName(): string
|
|
44
|
-
{
|
|
45
|
-
return this.json.name;
|
|
46
|
-
}
|
|
47
|
-
getTitle(): string
|
|
48
|
-
{
|
|
49
|
-
return this.json.title;
|
|
50
|
-
}
|
|
51
|
-
getDescription(): string
|
|
52
|
-
{
|
|
53
|
-
return this.json.description;
|
|
54
|
-
}
|
|
55
|
-
getIcon(): string
|
|
56
|
-
{
|
|
57
|
-
return this.json.icon;
|
|
58
|
-
}
|
|
59
|
-
getLogo(): string
|
|
60
|
-
{
|
|
61
|
-
return this.json.logo;
|
|
62
|
-
}
|
|
63
|
-
getVersion(): string
|
|
64
|
-
{
|
|
65
|
-
return this.json.version;
|
|
66
|
-
}
|
|
1
|
+
let fs: any;
|
|
2
|
+
if (typeof window === 'undefined')
|
|
3
|
+
fs = require('fs');
|
|
4
|
+
import { FileOperation } from "./FileOperation";
|
|
5
|
+
|
|
6
|
+
export class PackageService
|
|
7
|
+
{
|
|
8
|
+
static get(path: string): PackageService
|
|
9
|
+
{
|
|
10
|
+
if (path)
|
|
11
|
+
{
|
|
12
|
+
const json = JSON.parse(fs.readFileSync(path, 'utf8'));
|
|
13
|
+
if (json)
|
|
14
|
+
return new PackageService(path, json);
|
|
15
|
+
}
|
|
16
|
+
throw new Error("Coundn't find package");
|
|
17
|
+
}
|
|
18
|
+
static getMain(): PackageService
|
|
19
|
+
{
|
|
20
|
+
const paths = FileOperation.findUp('package.json');
|
|
21
|
+
if (paths)
|
|
22
|
+
return this.get(paths[paths.length - 1]);
|
|
23
|
+
throw new Error("Coundn't find package");
|
|
24
|
+
}
|
|
25
|
+
static getThis(): PackageService
|
|
26
|
+
{
|
|
27
|
+
const paths = FileOperation.findUp('package.json');
|
|
28
|
+
if (paths)
|
|
29
|
+
return this.get(paths[0]);
|
|
30
|
+
throw new Error("Coundn't find package");
|
|
31
|
+
}
|
|
32
|
+
private path: string;
|
|
33
|
+
private json: any;
|
|
34
|
+
constructor(path: string, json: any)
|
|
35
|
+
{
|
|
36
|
+
this.json = json;
|
|
37
|
+
this.path = path;
|
|
38
|
+
}
|
|
39
|
+
getPath(): string
|
|
40
|
+
{
|
|
41
|
+
return this.path;
|
|
42
|
+
}
|
|
43
|
+
getName(): string
|
|
44
|
+
{
|
|
45
|
+
return this.json.name;
|
|
46
|
+
}
|
|
47
|
+
getTitle(): string
|
|
48
|
+
{
|
|
49
|
+
return this.json.title;
|
|
50
|
+
}
|
|
51
|
+
getDescription(): string
|
|
52
|
+
{
|
|
53
|
+
return this.json.description;
|
|
54
|
+
}
|
|
55
|
+
getIcon(): string
|
|
56
|
+
{
|
|
57
|
+
return this.json.icon;
|
|
58
|
+
}
|
|
59
|
+
getLogo(): string
|
|
60
|
+
{
|
|
61
|
+
return this.json.logo;
|
|
62
|
+
}
|
|
63
|
+
getVersion(): string
|
|
64
|
+
{
|
|
65
|
+
return this.json.version;
|
|
66
|
+
}
|
|
67
67
|
}
|
package/src/PhoneOperation.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as Phone from 'phone';
|
|
2
|
-
|
|
3
|
-
export class PhoneOperation
|
|
4
|
-
{
|
|
5
|
-
static isValid(number: string): boolean
|
|
6
|
-
{
|
|
7
|
-
return Phone.phone(number).isValid;
|
|
8
|
-
}
|
|
1
|
+
import * as Phone from 'phone';
|
|
2
|
+
|
|
3
|
+
export class PhoneOperation
|
|
4
|
+
{
|
|
5
|
+
static isValid(number: string): boolean
|
|
6
|
+
{
|
|
7
|
+
return Phone.phone(number).isValid;
|
|
8
|
+
}
|
|
9
9
|
}
|
package/src/StringOperation.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export class StringOperation
|
|
2
|
-
{
|
|
3
|
-
static format(string: string, ...args: string[]): string
|
|
4
|
-
{
|
|
5
|
-
return string.replace(/{(\d+)}/g, (match, index) =>
|
|
6
|
-
{
|
|
7
|
-
const arg = args[index];
|
|
8
|
-
return typeof arg !== 'undefined' ? arg : match;
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
static repair(value: string): string
|
|
12
|
-
{
|
|
13
|
-
if (value == null)
|
|
14
|
-
value = '';
|
|
15
|
-
value = value.replace(/\s\s+/gm, ' ');
|
|
16
|
-
value = value.trim();
|
|
17
|
-
return value;
|
|
18
|
-
}
|
|
1
|
+
export class StringOperation
|
|
2
|
+
{
|
|
3
|
+
static format(string: string, ...args: string[]): string
|
|
4
|
+
{
|
|
5
|
+
return string.replace(/{(\d+)}/g, (match, index) =>
|
|
6
|
+
{
|
|
7
|
+
const arg = args[index];
|
|
8
|
+
return typeof arg !== 'undefined' ? arg : match;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
static repair(value: string): string
|
|
12
|
+
{
|
|
13
|
+
if (value == null)
|
|
14
|
+
value = '';
|
|
15
|
+
value = value.replace(/\s\s+/gm, ' ');
|
|
16
|
+
value = value.trim();
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
19
|
}
|