namirasoft-site 1.4.43 → 1.4.45

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.
@@ -14,6 +14,6 @@ export declare class NSBaseMetaTable_Backend<Row> {
14
14
  create?: (body: any) => Promise<any>;
15
15
  _update?: (id: string, body: any) => Promise<Row>;
16
16
  update?: (id: string, body: any) => Promise<Row>;
17
- _delete?: (id: string) => Promise<Row>;
18
- delete?: (id: string) => Promise<Row>;
17
+ _delete?: (id: string) => Promise<void>;
18
+ delete?: (id: string) => Promise<void>;
19
19
  }
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "framework": "npm",
9
9
  "application": "package",
10
10
  "private": false,
11
- "version": "1.4.43",
11
+ "version": "1.4.45",
12
12
  "author": "Amir Abolhasani",
13
13
  "license": "MIT",
14
14
  "main": "./dist/index.js",
@@ -17,7 +17,7 @@
17
17
  "build": ""
18
18
  },
19
19
  "dependencies": {
20
- "axios": "^1.13.2",
21
- "namirasoft-core": "^1.4.108"
20
+ "axios": "^1.14.0",
21
+ "namirasoft-core": "^1.4.114"
22
22
  }
23
23
  }
@@ -1,69 +1,69 @@
1
- import { BaseMetaDatabase } from "namirasoft-core";
2
- import { NSBaseMetaTable } from "./NSBaseMetaTable";
3
- import { NSBaseServer } from "./NSBaseServer";
4
-
5
- export abstract class NSBaseMetaDatabase<Server extends NSBaseServer> extends BaseMetaDatabase
6
- {
7
- public static getServerBaseURL(product_name: string): string
8
- {
9
- throw new Error(`NSBaseMetaDatabase.getServerBaseURL was not overriden. Requested: ${product_name}`);
10
- }
11
- override tables: { [name: string]: NSBaseMetaTable<Server, any>; } = {};
12
- public product: {
13
- id: string;
14
- name: string;
15
- headline: string;
16
- description: string;
17
- logo: string;
18
- link: string;
19
- };
20
- public abstract getServer(): Server;
21
- constructor(product: {
22
- id: string;
23
- name: string;
24
- headline: string;
25
- description: string;
26
- logo: string;
27
- link: string;
28
- })
29
- {
30
- super();
31
- this.product = product;
32
- }
33
- getByShortNameOrNull(short_name: string):
34
- {
35
- product: {
36
- id: string;
37
- name: string;
38
- headline: string;
39
- description: string;
40
- logo: string;
41
- link: string;
42
- };
43
- table: NSBaseMetaTable<NSBaseServer, any>;
44
- } | null
45
- {
46
- for (let table in this.tables)
47
- if (this.tables[table].uuid.short === short_name)
48
- return { product: this.product, table: this.tables[table] };
49
- return null;
50
- }
51
- getByShortName(short_name: string):
52
- {
53
- product: {
54
- id: string;
55
- name: string;
56
- headline: string;
57
- description: string;
58
- logo: string;
59
- link: string;
60
- };
61
- table: NSBaseMetaTable<NSBaseServer, any>;
62
- }
63
- {
64
- let ans = this.getByShortNameOrNull(short_name);
65
- if (ans)
66
- return ans;
67
- throw new Error(`Result could not be found for short name: ${short_name}`);
68
- }
1
+ import { BaseMetaDatabase } from "namirasoft-core";
2
+ import { NSBaseMetaTable } from "./NSBaseMetaTable";
3
+ import { NSBaseServer } from "./NSBaseServer";
4
+
5
+ export abstract class NSBaseMetaDatabase<Server extends NSBaseServer> extends BaseMetaDatabase
6
+ {
7
+ public static getServerBaseURL(product_name: string): string
8
+ {
9
+ throw new Error(`NSBaseMetaDatabase.getServerBaseURL was not overriden. Requested: ${product_name}`);
10
+ }
11
+ override tables: { [name: string]: NSBaseMetaTable<Server, any>; } = {};
12
+ public product: {
13
+ id: string;
14
+ name: string;
15
+ headline: string;
16
+ description: string;
17
+ logo: string;
18
+ link: string;
19
+ };
20
+ public abstract getServer(): Server;
21
+ constructor(product: {
22
+ id: string;
23
+ name: string;
24
+ headline: string;
25
+ description: string;
26
+ logo: string;
27
+ link: string;
28
+ })
29
+ {
30
+ super();
31
+ this.product = product;
32
+ }
33
+ getByShortNameOrNull(short_name: string):
34
+ {
35
+ product: {
36
+ id: string;
37
+ name: string;
38
+ headline: string;
39
+ description: string;
40
+ logo: string;
41
+ link: string;
42
+ };
43
+ table: NSBaseMetaTable<NSBaseServer, any>;
44
+ } | null
45
+ {
46
+ for (let table in this.tables)
47
+ if (this.tables[table].uuid.short === short_name)
48
+ return { product: this.product, table: this.tables[table] };
49
+ return null;
50
+ }
51
+ getByShortName(short_name: string):
52
+ {
53
+ product: {
54
+ id: string;
55
+ name: string;
56
+ headline: string;
57
+ description: string;
58
+ logo: string;
59
+ link: string;
60
+ };
61
+ table: NSBaseMetaTable<NSBaseServer, any>;
62
+ }
63
+ {
64
+ let ans = this.getByShortNameOrNull(short_name);
65
+ if (ans)
66
+ return ans;
67
+ throw new Error(`Result could not be found for short name: ${short_name}`);
68
+ }
69
69
  };
@@ -1,75 +1,75 @@
1
- import { BaseMetaTable, BaseUUID, NamingConvention } from "namirasoft-core";
2
- import { NSBaseMetaTable_Frontend } from "./NSBaseMetaTable_Frontend";
3
- import { NSBaseMetaDatabase } from "./NSBaseMetaDatabase";
4
- import { NSBaseMetaTable_Backend } from "./NSBaseMetaTable_Backend";
5
- import { NSBaseServer } from "./NSBaseServer";
6
-
7
- export abstract class NSBaseMetaTable<Server extends NSBaseServer, Row> extends BaseMetaTable
8
- {
9
- private static cft_tables = ["category", "field", "tag"];
10
- static getTableAndCFTsIfExists(naming: NamingConvention, tables: string[], name: string): string[]
11
- {
12
- name = NamingConvention.auto.convert(name, naming);
13
- tables = tables.map(t => NamingConvention.auto.convert(t, naming));
14
- return NSBaseMetaTable.getTableAndCFTs(naming, name).filter(t => tables.includes(t));
15
- }
16
- static getTableAndCFTs(naming: NamingConvention, name: string): string[]
17
- {
18
- name = NamingConvention.auto.convert(name, naming);
19
- return [name, ...NSBaseMetaTable.getCFTTables(naming, name)];
20
- }
21
- static getCFTTablesIfExists(naming: NamingConvention, tables: string[], name: string): string[]
22
- {
23
- name = NamingConvention.auto.convert(name, naming);
24
- tables = tables.map(t => NamingConvention.auto.convert(t, naming));
25
- return NSBaseMetaTable.getCFTTables(naming, name).filter(t => tables.includes(t));
26
- }
27
- static getCFTTables(naming: NamingConvention, name: string): string[]
28
- {
29
- name = NamingConvention.auto.convert(name, naming);
30
- let tables = NSBaseMetaTable.cft_tables.map(cft => name + "_" + cft);
31
- return tables.map(t => NamingConvention.auto.convert(t, naming));
32
- }
33
- static HasCFTTable(naming: NamingConvention, tables: string[], name: string): boolean
34
- {
35
- name = NamingConvention.auto.convert(name, naming);
36
- tables = tables.map(t => NamingConvention.auto.convert(t, naming))
37
- return NSBaseMetaTable.getCFTTables(naming, name).some(t => tables.includes(t));
38
- }
39
- static IsCFTTable(naming: NamingConvention, name: string): boolean
40
- {
41
- name = NamingConvention.auto.convert(name, naming);
42
- for (let i = 0; i < NSBaseMetaTable.cft_tables.length; i++)
43
- {
44
- let table = NSBaseMetaTable.cft_tables[i];
45
- table = NamingConvention.auto.convert(table, naming);
46
- if (name !== table)
47
- if (name.endsWith("_" + table))
48
- return true;
49
- }
50
- return false;
51
- }
52
-
53
- override database: NSBaseMetaDatabase<Server>;
54
- public uuid: BaseUUID;
55
- public front_end: NSBaseMetaTable_Frontend;
56
- public back_end: NSBaseMetaTable_Backend<Row>;
57
- constructor(database: NSBaseMetaDatabase<Server>, name: string, text: string, uuid: BaseUUID)
58
- {
59
- super(database, name, text);
60
- this.database = database;
61
- this.uuid = uuid;
62
- this.front_end = new NSBaseMetaTable_Frontend(this, name);
63
- this.back_end = new NSBaseMetaTable_Backend<Row>();
64
- }
65
- isCFTTable(): boolean
66
- {
67
- return NSBaseMetaTable.IsCFTTable(NamingConvention.lower_case_dash, this.name);
68
- }
69
- hasFieldTables(): boolean
70
- {
71
- if (this.database)
72
- return NSBaseMetaTable.HasCFTTable(NamingConvention.lower_case_dash, Object.keys(this.database.tables), this.name);
73
- return false;
74
- }
1
+ import { BaseMetaTable, BaseUUID, NamingConvention } from "namirasoft-core";
2
+ import { NSBaseMetaTable_Frontend } from "./NSBaseMetaTable_Frontend";
3
+ import { NSBaseMetaDatabase } from "./NSBaseMetaDatabase";
4
+ import { NSBaseMetaTable_Backend } from "./NSBaseMetaTable_Backend";
5
+ import { NSBaseServer } from "./NSBaseServer";
6
+
7
+ export abstract class NSBaseMetaTable<Server extends NSBaseServer, Row> extends BaseMetaTable
8
+ {
9
+ private static cft_tables = ["category", "field", "tag"];
10
+ static getTableAndCFTsIfExists(naming: NamingConvention, tables: string[], name: string): string[]
11
+ {
12
+ name = NamingConvention.auto.convert(name, naming);
13
+ tables = tables.map(t => NamingConvention.auto.convert(t, naming));
14
+ return NSBaseMetaTable.getTableAndCFTs(naming, name).filter(t => tables.includes(t));
15
+ }
16
+ static getTableAndCFTs(naming: NamingConvention, name: string): string[]
17
+ {
18
+ name = NamingConvention.auto.convert(name, naming);
19
+ return [name, ...NSBaseMetaTable.getCFTTables(naming, name)];
20
+ }
21
+ static getCFTTablesIfExists(naming: NamingConvention, tables: string[], name: string): string[]
22
+ {
23
+ name = NamingConvention.auto.convert(name, naming);
24
+ tables = tables.map(t => NamingConvention.auto.convert(t, naming));
25
+ return NSBaseMetaTable.getCFTTables(naming, name).filter(t => tables.includes(t));
26
+ }
27
+ static getCFTTables(naming: NamingConvention, name: string): string[]
28
+ {
29
+ name = NamingConvention.auto.convert(name, naming);
30
+ let tables = NSBaseMetaTable.cft_tables.map(cft => name + "_" + cft);
31
+ return tables.map(t => NamingConvention.auto.convert(t, naming));
32
+ }
33
+ static HasCFTTable(naming: NamingConvention, tables: string[], name: string): boolean
34
+ {
35
+ name = NamingConvention.auto.convert(name, naming);
36
+ tables = tables.map(t => NamingConvention.auto.convert(t, naming))
37
+ return NSBaseMetaTable.getCFTTables(naming, name).some(t => tables.includes(t));
38
+ }
39
+ static IsCFTTable(naming: NamingConvention, name: string): boolean
40
+ {
41
+ name = NamingConvention.auto.convert(name, naming);
42
+ for (let i = 0; i < NSBaseMetaTable.cft_tables.length; i++)
43
+ {
44
+ let table = NSBaseMetaTable.cft_tables[i];
45
+ table = NamingConvention.auto.convert(table, naming);
46
+ if (name !== table)
47
+ if (name.endsWith("_" + table))
48
+ return true;
49
+ }
50
+ return false;
51
+ }
52
+
53
+ override database: NSBaseMetaDatabase<Server>;
54
+ public uuid: BaseUUID;
55
+ public front_end: NSBaseMetaTable_Frontend;
56
+ public back_end: NSBaseMetaTable_Backend<Row>;
57
+ constructor(database: NSBaseMetaDatabase<Server>, name: string, text: string, uuid: BaseUUID)
58
+ {
59
+ super(database, name, text);
60
+ this.database = database;
61
+ this.uuid = uuid;
62
+ this.front_end = new NSBaseMetaTable_Frontend(this, name);
63
+ this.back_end = new NSBaseMetaTable_Backend<Row>();
64
+ }
65
+ isCFTTable(): boolean
66
+ {
67
+ return NSBaseMetaTable.IsCFTTable(NamingConvention.lower_case_dash, this.name);
68
+ }
69
+ hasFieldTables(): boolean
70
+ {
71
+ if (this.database)
72
+ return NSBaseMetaTable.HasCFTTable(NamingConvention.lower_case_dash, Object.keys(this.database.tables), this.name);
73
+ return false;
74
+ }
75
75
  };
@@ -1,15 +1,15 @@
1
- import { FilterItem, SortItem } from "namirasoft-core";
2
-
3
- export class NSBaseMetaTable_Backend<Row>
4
- {
5
- _get?: (id: string) => Promise<Row>;
6
- get?: (id: string) => Promise<Row>;
7
- _list?: (filters: FilterItem[] | null, page: (number | null), size: (number | null), sorts: SortItem[]) => Promise<{ rows: Row[], count: number }>;
8
- list?: (filters: FilterItem[] | null, page: (number | null), size: (number | null), sorts: SortItem[]) => Promise<{ rows: Row[], count: number }>;
9
- _create?: (body: any) => Promise<any>;
10
- create?: (body: any) => Promise<any>;
11
- _update?: (id: string, body: any) => Promise<Row>;
12
- update?: (id: string, body: any) => Promise<Row>;
13
- _delete?: (id: string) => Promise<Row>;
14
- delete?: (id: string) => Promise<Row>;
1
+ import { FilterItem, SortItem } from "namirasoft-core";
2
+
3
+ export class NSBaseMetaTable_Backend<Row>
4
+ {
5
+ _get?: (id: string) => Promise<Row>;
6
+ get?: (id: string) => Promise<Row>;
7
+ _list?: (filters: FilterItem[] | null, page: (number | null), size: (number | null), sorts: SortItem[]) => Promise<{ rows: Row[], count: number }>;
8
+ list?: (filters: FilterItem[] | null, page: (number | null), size: (number | null), sorts: SortItem[]) => Promise<{ rows: Row[], count: number }>;
9
+ _create?: (body: any) => Promise<any>;
10
+ create?: (body: any) => Promise<any>;
11
+ _update?: (id: string, body: any) => Promise<Row>;
12
+ update?: (id: string, body: any) => Promise<Row>;
13
+ _delete?: (id: string) => Promise<void>;
14
+ delete?: (id: string) => Promise<void>;
15
15
  };
@@ -1,38 +1,38 @@
1
- import { NamingConvention } from "namirasoft-core";
2
- import { NSBaseMetaTable } from "./NSBaseMetaTable";
3
-
4
- export class NSBaseMetaTable_Frontend
5
- {
6
- private table: NSBaseMetaTable<any, any>;
7
- private base: string;
8
- constructor(table: NSBaseMetaTable<any, any>, name: string)
9
- {
10
- this.table = table;
11
- this.base = NamingConvention.lower_case_underscore.convert(name, NamingConvention.lower_case_slash)
12
- this.getBaseLink = this.getBaseLink.bind(this);
13
- this.getListLink = this.getListLink.bind(this);
14
- this.getNewLink = this.getNewLink.bind(this);
15
- this.getViewLink = this.getViewLink.bind(this);
16
- this.getUpdateLink = this.getUpdateLink.bind(this);
17
- }
18
- public getBaseLink(): string
19
- {
20
- return this.table.database.product.link + "/" + this.base;
21
- }
22
- public getListLink(): string
23
- {
24
- return this.getBaseLink() + "/list";
25
- }
26
- public getNewLink(): string
27
- {
28
- return this.getBaseLink() + "/new";
29
- }
30
- public getViewLink(id: string): string
31
- {
32
- return this.getBaseLink() + "/" + id + "/view";
33
- }
34
- public getUpdateLink(id: string): string
35
- {
36
- return this.getBaseLink() + "/" + id + "/edit";
37
- }
1
+ import { NamingConvention } from "namirasoft-core";
2
+ import { NSBaseMetaTable } from "./NSBaseMetaTable";
3
+
4
+ export class NSBaseMetaTable_Frontend
5
+ {
6
+ private table: NSBaseMetaTable<any, any>;
7
+ private base: string;
8
+ constructor(table: NSBaseMetaTable<any, any>, name: string)
9
+ {
10
+ this.table = table;
11
+ this.base = NamingConvention.lower_case_underscore.convert(name, NamingConvention.lower_case_slash)
12
+ this.getBaseLink = this.getBaseLink.bind(this);
13
+ this.getListLink = this.getListLink.bind(this);
14
+ this.getNewLink = this.getNewLink.bind(this);
15
+ this.getViewLink = this.getViewLink.bind(this);
16
+ this.getUpdateLink = this.getUpdateLink.bind(this);
17
+ }
18
+ public getBaseLink(): string
19
+ {
20
+ return this.table.database.product.link + "/" + this.base;
21
+ }
22
+ public getListLink(): string
23
+ {
24
+ return this.getBaseLink() + "/list";
25
+ }
26
+ public getNewLink(): string
27
+ {
28
+ return this.getBaseLink() + "/new";
29
+ }
30
+ public getViewLink(id: string): string
31
+ {
32
+ return this.getBaseLink() + "/" + id + "/view";
33
+ }
34
+ public getUpdateLink(id: string): string
35
+ {
36
+ return this.getBaseLink() + "/" + id + "/edit";
37
+ }
38
38
  };
@@ -1,47 +1,47 @@
1
- import { BaseServer } from "namirasoft-core";
2
- import { AxiosRequestConfig, AxiosResponse } from "axios";
3
- import { NSHeader } from "./NSHeader";
4
-
5
- export abstract class NSBaseServer extends BaseServer
6
- {
7
- static onBeforeRequest_SetVersion<ReqData>(version: string, config?: AxiosRequestConfig<ReqData>): void
8
- {
9
- let header = NSHeader.req.VERSION();
10
- if (config?.headers)
11
- config.headers[header] = version;
12
- }
13
-
14
- static onAfterRequest_GetVersion<ReqData>(res?: AxiosResponse<ReqData>): string
15
- {
16
- let header = NSHeader.req.VERSION();
17
- if (res?.headers)
18
- return res.headers[header];
19
- return "";
20
- }
21
-
22
- private version: string;
23
-
24
- public backend: {
25
- version: string
26
- } = { version: "" };
27
-
28
- constructor(base_url: string, version: string)
29
- {
30
- super(base_url);
31
- this.version = version;
32
-
33
- this.NSOnBeforeRequest = this.NSOnBeforeRequest.bind(this);
34
- this.NSOnAfterRequest = this.NSOnAfterRequest.bind(this);
35
-
36
- this.addOnBeforeRequest(this.NSOnBeforeRequest);
37
- this.addOnAfterRequest(this.NSOnAfterRequest);
38
- }
39
- private NSOnBeforeRequest<ReqData = any>(_: string, config?: AxiosRequestConfig<ReqData> | undefined): void
40
- {
41
- NSBaseServer.onBeforeRequest_SetVersion(this.version, config);
42
- }
43
- private NSOnAfterRequest<ResData = any>(_: string, res: AxiosResponse<ResData, any>): void
44
- {
45
- this.backend.version = NSBaseServer.onAfterRequest_GetVersion(res);
46
- }
1
+ import { BaseServer } from "namirasoft-core";
2
+ import { AxiosRequestConfig, AxiosResponse } from "axios";
3
+ import { NSHeader } from "./NSHeader";
4
+
5
+ export abstract class NSBaseServer extends BaseServer
6
+ {
7
+ static onBeforeRequest_SetVersion<ReqData>(version: string, config?: AxiosRequestConfig<ReqData>): void
8
+ {
9
+ let header = NSHeader.req.VERSION();
10
+ if (config?.headers)
11
+ config.headers[header] = version;
12
+ }
13
+
14
+ static onAfterRequest_GetVersion<ReqData>(res?: AxiosResponse<ReqData>): string
15
+ {
16
+ let header = NSHeader.req.VERSION();
17
+ if (res?.headers)
18
+ return res.headers[header];
19
+ return "";
20
+ }
21
+
22
+ private version: string;
23
+
24
+ public backend: {
25
+ version: string
26
+ } = { version: "" };
27
+
28
+ constructor(base_url: string, version: string)
29
+ {
30
+ super(base_url);
31
+ this.version = version;
32
+
33
+ this.NSOnBeforeRequest = this.NSOnBeforeRequest.bind(this);
34
+ this.NSOnAfterRequest = this.NSOnAfterRequest.bind(this);
35
+
36
+ this.addOnBeforeRequest(this.NSOnBeforeRequest);
37
+ this.addOnAfterRequest(this.NSOnAfterRequest);
38
+ }
39
+ private NSOnBeforeRequest<ReqData = any>(_: string, config?: AxiosRequestConfig<ReqData> | undefined): void
40
+ {
41
+ NSBaseServer.onBeforeRequest_SetVersion(this.version, config);
42
+ }
43
+ private NSOnAfterRequest<ResData = any>(_: string, res: AxiosResponse<ResData, any>): void
44
+ {
45
+ this.backend.version = NSBaseServer.onAfterRequest_GetVersion(res);
46
+ }
47
47
  };
@@ -1,3 +1,3 @@
1
- export class NSCookiesHeader
2
- {
1
+ export class NSCookiesHeader
2
+ {
3
3
  }
package/src/NSHeader.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { NSCookiesHeader } from "./NSCookiesHeader";
2
- import { NSReqHeader } from "./NSReqHeader";
3
- import { NSResHeader } from "./NSResHeader";
4
-
5
- export class NSHeader
6
- {
7
- static cookies: NSCookiesHeader = new NSCookiesHeader();
8
- static req: NSReqHeader = new NSReqHeader();
9
- static res: NSResHeader = new NSResHeader();
1
+ import { NSCookiesHeader } from "./NSCookiesHeader";
2
+ import { NSReqHeader } from "./NSReqHeader";
3
+ import { NSResHeader } from "./NSResHeader";
4
+
5
+ export class NSHeader
6
+ {
7
+ static cookies: NSCookiesHeader = new NSCookiesHeader();
8
+ static req: NSReqHeader = new NSReqHeader();
9
+ static res: NSResHeader = new NSResHeader();
10
10
  }
@@ -1,144 +1,144 @@
1
- import { NamingConvention } from "namirasoft-core";
2
-
3
- export type NSNameParserStructure =
4
- {
5
- // Name
6
- name_namirasoft: string;
7
- name_short: string;
8
-
9
- // Title
10
- title_namirasoft: string;
11
- title_short: string;
12
-
13
- // Class
14
- class_namirasoft: string;
15
- class_short: string;
16
- };
17
-
18
- export class NSNameParser
19
- {
20
- // Input
21
- public name_full: string;
22
- public title_full: string;
23
-
24
- // Is
25
- public isAPI: boolean;
26
- public isConsole: boolean;
27
- public isLibrary: boolean;
28
- public isNPM: boolean;
29
- public isPHP: boolean;
30
- public isAccountAPI: boolean;
31
-
32
- public api: NSNameParserStructure = {
33
- // Name
34
- name_namirasoft: "",
35
- name_short: "",
36
-
37
- // Title
38
- title_namirasoft: "",
39
- title_short: "",
40
-
41
- // Class
42
- class_namirasoft: "",
43
- class_short: "",
44
- };
45
-
46
- public console: NSNameParserStructure = {
47
- // Name
48
- name_namirasoft: "",
49
- name_short: "",
50
-
51
- // Title
52
- title_namirasoft: "",
53
- title_short: "",
54
-
55
- // Class
56
- class_namirasoft: "",
57
- class_short: "",
58
- };
59
-
60
- public library: NSNameParserStructure = {
61
- // Name
62
- name_namirasoft: "",
63
- name_short: "",
64
-
65
- // Title
66
- title_namirasoft: "",
67
- title_short: "",
68
-
69
- // Class
70
- class_namirasoft: "",
71
- class_short: "",
72
- };
73
- public command: {
74
- name: string
75
- } = { name: "" };
76
-
77
- constructor(name_full: string, title_full: string)
78
- {
79
- // Input
80
- this.name_full = name_full;
81
- this.title_full = title_full;
82
-
83
- // Is
84
- this.isAPI = /^namirasoft(-\w*)*-api(-\w*)*-v\d+$/gm.test(name_full);
85
- this.isConsole = /^namirasoft-(\w+-)+console$/gm.test(name_full);
86
- this.isLibrary = !this.isAPI && !this.isConsole && /^namirasoft-\w+/gm.test(name_full);
87
- this.isNPM = this.isLibrary && /NPM Package$/gm.test(title_full);
88
- this.isPHP = this.isLibrary && /PHP Package$/gm.test(title_full);
89
- this.isAccountAPI = /^namirasoft-account-api-v\d+$/gm.test(name_full);
90
-
91
- if (this.isAPI)
92
- {
93
- // Name
94
- this.api.name_namirasoft = this.name_full.replace(/(-api)?-v\d+$/gm, "");
95
- this.api.name_short = this.api.name_namirasoft.replace(/^namirasoft-/gm, "");
96
-
97
- // Title
98
- this.api.title_namirasoft = this.title_full.replace(/(\sAPI)?\sV\d+$/gm, "");
99
- this.api.title_short = this.api.title_namirasoft.replace(/^Namirasoft\s/gm, "");
100
-
101
- // Class
102
- this.api.class_namirasoft = NamingConvention.auto.convert(this.api.title_namirasoft, NamingConvention.Pascal_Case);
103
- this.api.class_short = NamingConvention.auto.convert(this.api.title_short, NamingConvention.Pascal_Case);
104
-
105
- // Command
106
- this.command.name = this.api.name_namirasoft;
107
- }
108
-
109
- if (this.isConsole)
110
- {
111
- // Name
112
- this.console.name_namirasoft = this.name_full.replace(/-console$/gm, "");
113
- this.console.name_short = this.console.name_namirasoft.replace(/^namirasoft-/gm, "");
114
-
115
- // Title
116
- this.console.title_namirasoft = this.title_full.replace(/\sConsole$/gm, "");
117
- this.console.title_short = this.console.title_namirasoft.replace(/^Namirasoft\s/gm, "");
118
-
119
- // Class
120
- this.console.class_namirasoft = NamingConvention.auto.convert(this.console.title_namirasoft, NamingConvention.Pascal_Case);
121
- this.console.class_short = NamingConvention.auto.convert(this.console.title_short, NamingConvention.Pascal_Case);
122
- }
123
-
124
- if (this.isLibrary)
125
- {
126
- // Name
127
- this.library.name_namirasoft = this.name_full;
128
- this.library.name_short = this.library.name_namirasoft.replace(/^namirasoft-/gm, "");
129
-
130
- // Title
131
- this.library.title_namirasoft = this.title_full.replace(/\s(NPM|PHP)\sPackage$/gm, "");
132
- this.library.title_short = this.library.title_namirasoft.replace(/^Namirasoft\s/gm, "");
133
-
134
- // Class
135
- this.library.class_namirasoft = NamingConvention.auto.convert(this.library.title_namirasoft, NamingConvention.Pascal_Case);
136
- this.library.class_short = NamingConvention.auto.convert(this.library.title_short, NamingConvention.Pascal_Case);
137
-
138
- // Command
139
- this.command.name = this.library.name_namirasoft;
140
- }
141
-
142
- this.command.name = this.command.name.replace("namirasoft-", "ns-");
143
- }
1
+ import { NamingConvention } from "namirasoft-core";
2
+
3
+ export type NSNameParserStructure =
4
+ {
5
+ // Name
6
+ name_namirasoft: string;
7
+ name_short: string;
8
+
9
+ // Title
10
+ title_namirasoft: string;
11
+ title_short: string;
12
+
13
+ // Class
14
+ class_namirasoft: string;
15
+ class_short: string;
16
+ };
17
+
18
+ export class NSNameParser
19
+ {
20
+ // Input
21
+ public name_full: string;
22
+ public title_full: string;
23
+
24
+ // Is
25
+ public isAPI: boolean;
26
+ public isConsole: boolean;
27
+ public isLibrary: boolean;
28
+ public isNPM: boolean;
29
+ public isPHP: boolean;
30
+ public isAccountAPI: boolean;
31
+
32
+ public api: NSNameParserStructure = {
33
+ // Name
34
+ name_namirasoft: "",
35
+ name_short: "",
36
+
37
+ // Title
38
+ title_namirasoft: "",
39
+ title_short: "",
40
+
41
+ // Class
42
+ class_namirasoft: "",
43
+ class_short: "",
44
+ };
45
+
46
+ public console: NSNameParserStructure = {
47
+ // Name
48
+ name_namirasoft: "",
49
+ name_short: "",
50
+
51
+ // Title
52
+ title_namirasoft: "",
53
+ title_short: "",
54
+
55
+ // Class
56
+ class_namirasoft: "",
57
+ class_short: "",
58
+ };
59
+
60
+ public library: NSNameParserStructure = {
61
+ // Name
62
+ name_namirasoft: "",
63
+ name_short: "",
64
+
65
+ // Title
66
+ title_namirasoft: "",
67
+ title_short: "",
68
+
69
+ // Class
70
+ class_namirasoft: "",
71
+ class_short: "",
72
+ };
73
+ public command: {
74
+ name: string
75
+ } = { name: "" };
76
+
77
+ constructor(name_full: string, title_full: string)
78
+ {
79
+ // Input
80
+ this.name_full = name_full;
81
+ this.title_full = title_full;
82
+
83
+ // Is
84
+ this.isAPI = /^namirasoft(-\w*)*-api(-\w*)*-v\d+$/gm.test(name_full);
85
+ this.isConsole = /^namirasoft-(\w+-)+console$/gm.test(name_full);
86
+ this.isLibrary = !this.isAPI && !this.isConsole && /^namirasoft-\w+/gm.test(name_full);
87
+ this.isNPM = this.isLibrary && /NPM Package$/gm.test(title_full);
88
+ this.isPHP = this.isLibrary && /PHP Package$/gm.test(title_full);
89
+ this.isAccountAPI = /^namirasoft-account-api-v\d+$/gm.test(name_full);
90
+
91
+ if (this.isAPI)
92
+ {
93
+ // Name
94
+ this.api.name_namirasoft = this.name_full.replace(/(-api)?-v\d+$/gm, "");
95
+ this.api.name_short = this.api.name_namirasoft.replace(/^namirasoft-/gm, "");
96
+
97
+ // Title
98
+ this.api.title_namirasoft = this.title_full.replace(/(\sAPI)?\sV\d+$/gm, "");
99
+ this.api.title_short = this.api.title_namirasoft.replace(/^Namirasoft\s/gm, "");
100
+
101
+ // Class
102
+ this.api.class_namirasoft = NamingConvention.auto.convert(this.api.title_namirasoft, NamingConvention.Pascal_Case);
103
+ this.api.class_short = NamingConvention.auto.convert(this.api.title_short, NamingConvention.Pascal_Case);
104
+
105
+ // Command
106
+ this.command.name = this.api.name_namirasoft;
107
+ }
108
+
109
+ if (this.isConsole)
110
+ {
111
+ // Name
112
+ this.console.name_namirasoft = this.name_full.replace(/-console$/gm, "");
113
+ this.console.name_short = this.console.name_namirasoft.replace(/^namirasoft-/gm, "");
114
+
115
+ // Title
116
+ this.console.title_namirasoft = this.title_full.replace(/\sConsole$/gm, "");
117
+ this.console.title_short = this.console.title_namirasoft.replace(/^Namirasoft\s/gm, "");
118
+
119
+ // Class
120
+ this.console.class_namirasoft = NamingConvention.auto.convert(this.console.title_namirasoft, NamingConvention.Pascal_Case);
121
+ this.console.class_short = NamingConvention.auto.convert(this.console.title_short, NamingConvention.Pascal_Case);
122
+ }
123
+
124
+ if (this.isLibrary)
125
+ {
126
+ // Name
127
+ this.library.name_namirasoft = this.name_full;
128
+ this.library.name_short = this.library.name_namirasoft.replace(/^namirasoft-/gm, "");
129
+
130
+ // Title
131
+ this.library.title_namirasoft = this.title_full.replace(/\s(NPM|PHP)\sPackage$/gm, "");
132
+ this.library.title_short = this.library.title_namirasoft.replace(/^Namirasoft\s/gm, "");
133
+
134
+ // Class
135
+ this.library.class_namirasoft = NamingConvention.auto.convert(this.library.title_namirasoft, NamingConvention.Pascal_Case);
136
+ this.library.class_short = NamingConvention.auto.convert(this.library.title_short, NamingConvention.Pascal_Case);
137
+
138
+ // Command
139
+ this.command.name = this.library.name_namirasoft;
140
+ }
141
+
142
+ this.command.name = this.command.name.replace("namirasoft-", "ns-");
143
+ }
144
144
  };
@@ -1,7 +1,7 @@
1
- export class NSReqHeader
2
- {
3
- VERSION()
4
- {
5
- return `ns-site-version`;
6
- }
1
+ export class NSReqHeader
2
+ {
3
+ VERSION()
4
+ {
5
+ return `ns-site-version`;
6
+ }
7
7
  }
@@ -1,7 +1,7 @@
1
- export class NSResHeader
2
- {
3
- VERSION()
4
- {
5
- return `ns-site-version`;
6
- }
1
+ export class NSResHeader
2
+ {
3
+ VERSION()
4
+ {
5
+ return `ns-site-version`;
6
+ }
7
7
  }
package/src/index.ts CHANGED
@@ -1,8 +1,8 @@
1
- export * from "./NSBaseServer";
2
- export * from "./NSBaseMetaDatabase";
3
- export * from "./NSBaseMetaTable";
4
- export * from "./NSCookiesHeader";
5
- export * from "./NSHeader";
6
- export * from "./NSNameParser";
7
- export * from "./NSReqHeader";
1
+ export * from "./NSBaseServer";
2
+ export * from "./NSBaseMetaDatabase";
3
+ export * from "./NSBaseMetaTable";
4
+ export * from "./NSCookiesHeader";
5
+ export * from "./NSHeader";
6
+ export * from "./NSNameParser";
7
+ export * from "./NSReqHeader";
8
8
  export * from "./NSResHeader";