namirasoft-scheduler 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.
Files changed (139) hide show
  1. package/dist/NamirasoftSchedulerServer.d.ts +13 -0
  2. package/dist/NamirasoftSchedulerServer.js +20 -0
  3. package/dist/NamirasoftSchedulerServer.js.map +1 -0
  4. package/dist/NamirasoftSchedulerServerBase.d.ts +5 -0
  5. package/dist/NamirasoftSchedulerServerBase.js +11 -0
  6. package/dist/NamirasoftSchedulerServerBase.js.map +1 -0
  7. package/dist/NamirasoftSchedulerServerHealthz.d.ts +7 -0
  8. package/dist/NamirasoftSchedulerServerHealthz.js +28 -0
  9. package/dist/NamirasoftSchedulerServerHealthz.js.map +1 -0
  10. package/dist/NamirasoftSchedulerServerMetrics.d.ts +7 -0
  11. package/dist/NamirasoftSchedulerServerMetrics.js +28 -0
  12. package/dist/NamirasoftSchedulerServerMetrics.js.map +1 -0
  13. package/dist/NamirasoftSchedulerServerScheduler.d.ts +19 -0
  14. package/dist/NamirasoftSchedulerServerScheduler.js +64 -0
  15. package/dist/NamirasoftSchedulerServerScheduler.js.map +1 -0
  16. package/dist/NamirasoftSchedulerServerValue.d.ts +7 -0
  17. package/dist/NamirasoftSchedulerServerValue.js +29 -0
  18. package/dist/NamirasoftSchedulerServerValue.js.map +1 -0
  19. package/dist/command/HealthzCommand.d.ts +4 -0
  20. package/dist/command/HealthzCommand.js +15 -0
  21. package/dist/command/HealthzCommand.js.map +1 -0
  22. package/dist/command/HealthzGetCommand.d.ts +5 -0
  23. package/dist/command/HealthzGetCommand.js +38 -0
  24. package/dist/command/HealthzGetCommand.js.map +1 -0
  25. package/dist/command/MetricsCommand.d.ts +4 -0
  26. package/dist/command/MetricsCommand.js +15 -0
  27. package/dist/command/MetricsCommand.js.map +1 -0
  28. package/dist/command/MetricsGetCommand.d.ts +5 -0
  29. package/dist/command/MetricsGetCommand.js +38 -0
  30. package/dist/command/MetricsGetCommand.js.map +1 -0
  31. package/dist/command/SchedulerCommand.d.ts +4 -0
  32. package/dist/command/SchedulerCommand.js +23 -0
  33. package/dist/command/SchedulerCommand.js.map +1 -0
  34. package/dist/command/SchedulerCreateCommand.d.ts +5 -0
  35. package/dist/command/SchedulerCreateCommand.js +292 -0
  36. package/dist/command/SchedulerCreateCommand.js.map +1 -0
  37. package/dist/command/SchedulerDeleteCommand.d.ts +5 -0
  38. package/dist/command/SchedulerDeleteCommand.js +38 -0
  39. package/dist/command/SchedulerDeleteCommand.js.map +1 -0
  40. package/dist/command/SchedulerGetCommand.d.ts +5 -0
  41. package/dist/command/SchedulerGetCommand.js +38 -0
  42. package/dist/command/SchedulerGetCommand.js.map +1 -0
  43. package/dist/command/SchedulerListCommand.d.ts +5 -0
  44. package/dist/command/SchedulerListCommand.js +38 -0
  45. package/dist/command/SchedulerListCommand.js.map +1 -0
  46. package/dist/command/SchedulerUpdateCommand.d.ts +5 -0
  47. package/dist/command/SchedulerUpdateCommand.js +292 -0
  48. package/dist/command/SchedulerUpdateCommand.js.map +1 -0
  49. package/dist/command/ValueCommand.d.ts +4 -0
  50. package/dist/command/ValueCommand.js +15 -0
  51. package/dist/command/ValueCommand.js.map +1 -0
  52. package/dist/command/ValueListCommand.d.ts +5 -0
  53. package/dist/command/ValueListCommand.js +38 -0
  54. package/dist/command/ValueListCommand.js.map +1 -0
  55. package/dist/command/cli.d.ts +2 -0
  56. package/dist/command/cli.js +20 -0
  57. package/dist/command/cli.js.map +1 -0
  58. package/dist/enum/SchedulerFrequencyMonthDays.d.ts +34 -0
  59. package/dist/enum/SchedulerFrequencyMonthDays.js +39 -0
  60. package/dist/enum/SchedulerFrequencyMonthDays.js.map +1 -0
  61. package/dist/enum/SchedulerFrequencyMonthNames.d.ts +13 -0
  62. package/dist/enum/SchedulerFrequencyMonthNames.js +18 -0
  63. package/dist/enum/SchedulerFrequencyMonthNames.js.map +1 -0
  64. package/dist/enum/SchedulerFrequencyMonthOnDays.d.ts +9 -0
  65. package/dist/enum/SchedulerFrequencyMonthOnDays.js +14 -0
  66. package/dist/enum/SchedulerFrequencyMonthOnDays.js.map +1 -0
  67. package/dist/enum/SchedulerFrequencyMonthOnWeek.d.ts +7 -0
  68. package/dist/enum/SchedulerFrequencyMonthOnWeek.js +12 -0
  69. package/dist/enum/SchedulerFrequencyMonthOnWeek.js.map +1 -0
  70. package/dist/enum/SchedulerFrequencyType.d.ts +5 -0
  71. package/dist/enum/SchedulerFrequencyType.js +10 -0
  72. package/dist/enum/SchedulerFrequencyType.js.map +1 -0
  73. package/dist/enum/SchedulerFrequencyWeekDays.d.ts +9 -0
  74. package/dist/enum/SchedulerFrequencyWeekDays.js +14 -0
  75. package/dist/enum/SchedulerFrequencyWeekDays.js.map +1 -0
  76. package/dist/enum/SchedulerRandomDelayUnit.d.ts +5 -0
  77. package/dist/enum/SchedulerRandomDelayUnit.js +10 -0
  78. package/dist/enum/SchedulerRandomDelayUnit.js.map +1 -0
  79. package/dist/enum/SchedulerRepeatEveryUnit.d.ts +5 -0
  80. package/dist/enum/SchedulerRepeatEveryUnit.js +10 -0
  81. package/dist/enum/SchedulerRepeatEveryUnit.js.map +1 -0
  82. package/dist/enum/SchedulerRepeatUntilUnit.d.ts +5 -0
  83. package/dist/enum/SchedulerRepeatUntilUnit.js +10 -0
  84. package/dist/enum/SchedulerRepeatUntilUnit.js.map +1 -0
  85. package/dist/index.d.ts +32 -0
  86. package/dist/index.js +49 -0
  87. package/dist/index.js.map +1 -0
  88. package/dist/meta/NamirasoftSchedulerMetaDatabase.d.ts +13 -0
  89. package/dist/meta/NamirasoftSchedulerMetaDatabase.js +27 -0
  90. package/dist/meta/NamirasoftSchedulerMetaDatabase.js.map +1 -0
  91. package/dist/meta/SchedulerMetaTable.d.ts +43 -0
  92. package/dist/meta/SchedulerMetaTable.js +66 -0
  93. package/dist/meta/SchedulerMetaTable.js.map +1 -0
  94. package/dist/row/SchedulerFullRow.d.ts +45 -0
  95. package/dist/row/SchedulerFullRow.js +3 -0
  96. package/dist/row/SchedulerFullRow.js.map +1 -0
  97. package/dist/row/SchedulerInputRow.d.ts +39 -0
  98. package/dist/row/SchedulerInputRow.js +3 -0
  99. package/dist/row/SchedulerInputRow.js.map +1 -0
  100. package/dist/row/SchedulerRow.d.ts +45 -0
  101. package/dist/row/SchedulerRow.js +3 -0
  102. package/dist/row/SchedulerRow.js.map +1 -0
  103. package/logo.png +0 -0
  104. package/package.json +28 -0
  105. package/src/NamirasoftSchedulerServer.ts +42 -0
  106. package/src/NamirasoftSchedulerServerBase.ts +30 -0
  107. package/src/NamirasoftSchedulerServerHealthz.ts +37 -0
  108. package/src/NamirasoftSchedulerServerMetrics.ts +37 -0
  109. package/src/NamirasoftSchedulerServerScheduler.ts +72 -0
  110. package/src/NamirasoftSchedulerServerValue.ts +38 -0
  111. package/src/command/HealthzCommand.ts +32 -0
  112. package/src/command/HealthzGetCommand.ts +45 -0
  113. package/src/command/MetricsCommand.ts +32 -0
  114. package/src/command/MetricsGetCommand.ts +45 -0
  115. package/src/command/SchedulerCommand.ts +40 -0
  116. package/src/command/SchedulerCreateCommand.ts +299 -0
  117. package/src/command/SchedulerDeleteCommand.ts +45 -0
  118. package/src/command/SchedulerGetCommand.ts +45 -0
  119. package/src/command/SchedulerListCommand.ts +45 -0
  120. package/src/command/SchedulerUpdateCommand.ts +299 -0
  121. package/src/command/ValueCommand.ts +32 -0
  122. package/src/command/ValueListCommand.ts +45 -0
  123. package/src/command/cli.ts +39 -0
  124. package/src/enum/SchedulerFrequencyMonthDays.ts +55 -0
  125. package/src/enum/SchedulerFrequencyMonthNames.ts +34 -0
  126. package/src/enum/SchedulerFrequencyMonthOnDays.ts +30 -0
  127. package/src/enum/SchedulerFrequencyMonthOnWeek.ts +28 -0
  128. package/src/enum/SchedulerFrequencyType.ts +26 -0
  129. package/src/enum/SchedulerFrequencyWeekDays.ts +30 -0
  130. package/src/enum/SchedulerRandomDelayUnit.ts +26 -0
  131. package/src/enum/SchedulerRepeatEveryUnit.ts +26 -0
  132. package/src/enum/SchedulerRepeatUntilUnit.ts +26 -0
  133. package/src/index.ts +52 -0
  134. package/src/meta/NamirasoftSchedulerMetaDatabase.ts +51 -0
  135. package/src/meta/SchedulerMetaTable.ts +114 -0
  136. package/src/row/SchedulerFullRow.ts +67 -0
  137. package/src/row/SchedulerInputRow.ts +61 -0
  138. package/src/row/SchedulerRow.ts +67 -0
  139. package/tsconfig.json +42 -0
@@ -0,0 +1,37 @@
1
+ /****************************************************************/
2
+ /* */
3
+ /* This is an Auto-Generated File */
4
+ /* Made By */
5
+ /* Namirasoft SDK Generator NPM Package */
6
+ /* */
7
+ /****************************************************************/
8
+ /****************************************************************/
9
+ /* */
10
+ /* Please do not make any change to this file */
11
+ /* If any change is required, ns-sdkg command must be used */
12
+ /* */
13
+ /****************************************************************/
14
+ /****************************************************************/
15
+ /* */
16
+ /* Namira Software Corporation */
17
+ /* https://namirasoft.com */
18
+ /* */
19
+ /****************************************************************/
20
+
21
+ import { BaseServerConfig } from "namirasoft-core";
22
+ import { NamirasoftSchedulerServer } from "./NamirasoftSchedulerServer";
23
+ import { NamirasoftSchedulerServerBase } from "./NamirasoftSchedulerServerBase";
24
+
25
+ export class NamirasoftSchedulerServerMetrics extends NamirasoftSchedulerServerBase
26
+ {
27
+ constructor(server: NamirasoftSchedulerServer)
28
+ {
29
+ super(server);
30
+ this.Get = this.Get.bind(this);
31
+ }
32
+ async Get(config?: BaseServerConfig<any>): Promise<void>
33
+ {
34
+ let path = `/metrics`;
35
+ await this.server._get<void>(path, {}, config);
36
+ }
37
+ };
@@ -0,0 +1,72 @@
1
+ /****************************************************************/
2
+ /* */
3
+ /* This is an Auto-Generated File */
4
+ /* Made By */
5
+ /* Namirasoft SDK Generator NPM Package */
6
+ /* */
7
+ /****************************************************************/
8
+ /****************************************************************/
9
+ /* */
10
+ /* Please do not make any change to this file */
11
+ /* If any change is required, ns-sdkg command must be used */
12
+ /* */
13
+ /****************************************************************/
14
+ /****************************************************************/
15
+ /* */
16
+ /* Namira Software Corporation */
17
+ /* https://namirasoft.com */
18
+ /* */
19
+ /****************************************************************/
20
+
21
+ import { BaseServerConfig } from "namirasoft-core";
22
+ import { FilterItem } from "namirasoft-core";
23
+ import { NamirasoftSchedulerServer } from "./NamirasoftSchedulerServer";
24
+ import { NamirasoftSchedulerServerBase } from "./NamirasoftSchedulerServerBase";
25
+ import { SchedulerFullRow } from "./row/SchedulerFullRow";
26
+ import { SchedulerInputRow } from "./row/SchedulerInputRow";
27
+ import { SchedulerRow } from "./row/SchedulerRow";
28
+ import { SortItem } from "namirasoft-core";
29
+
30
+ export class NamirasoftSchedulerServerScheduler extends NamirasoftSchedulerServerBase
31
+ {
32
+ constructor(server: NamirasoftSchedulerServer)
33
+ {
34
+ super(server);
35
+ this.List = this.List.bind(this);
36
+ this.Get = this.Get.bind(this);
37
+ this.Create = this.Create.bind(this);
38
+ this.Update = this.Update.bind(this);
39
+ this.Delete = this.Delete.bind(this);
40
+ }
41
+ async List(filters: FilterItem[] | null, page: (number | null), size: (number | null), sorts: SortItem[], config?: BaseServerConfig<any>): Promise<{ rows: SchedulerFullRow[], count: number }>
42
+ {
43
+ let filters_string_value: string = FilterItem.stringify(filters);
44
+ let sorts_string_value: string = SortItem.stringify(sorts);
45
+ let path = `/scheduler/list`;
46
+ let { data } = await this.server._get<{ rows: SchedulerFullRow[], count: number }>(path, { filters: filters_string_value, page, size, sorts: sorts_string_value }, config);
47
+ return data;
48
+ }
49
+ async Get(id: string, config?: BaseServerConfig<any>): Promise<SchedulerFullRow>
50
+ {
51
+ let path = `/scheduler/${id}`;
52
+ let { data } = await this.server._get<SchedulerFullRow>(path, {}, config);
53
+ return data;
54
+ }
55
+ async Create(body: SchedulerInputRow, config?: BaseServerConfig<any>): Promise<SchedulerRow>
56
+ {
57
+ let path = `/scheduler`;
58
+ let { data } = await this.server._post<SchedulerRow>(path, {}, body, config);
59
+ return data;
60
+ }
61
+ async Update(id: string, body: SchedulerInputRow, config?: BaseServerConfig<any>): Promise<SchedulerRow>
62
+ {
63
+ let path = `/scheduler/${id}`;
64
+ let { data } = await this.server._put<SchedulerRow>(path, {}, body, config);
65
+ return data;
66
+ }
67
+ async Delete(id: string, config?: BaseServerConfig<any>): Promise<void>
68
+ {
69
+ let path = `/scheduler/${id}`;
70
+ await this.server._delete<void>(path, {}, config);
71
+ }
72
+ };
@@ -0,0 +1,38 @@
1
+ /****************************************************************/
2
+ /* */
3
+ /* This is an Auto-Generated File */
4
+ /* Made By */
5
+ /* Namirasoft SDK Generator NPM Package */
6
+ /* */
7
+ /****************************************************************/
8
+ /****************************************************************/
9
+ /* */
10
+ /* Please do not make any change to this file */
11
+ /* If any change is required, ns-sdkg command must be used */
12
+ /* */
13
+ /****************************************************************/
14
+ /****************************************************************/
15
+ /* */
16
+ /* Namira Software Corporation */
17
+ /* https://namirasoft.com */
18
+ /* */
19
+ /****************************************************************/
20
+
21
+ import { BaseServerConfig } from "namirasoft-core";
22
+ import { NamirasoftSchedulerServer } from "./NamirasoftSchedulerServer";
23
+ import { NamirasoftSchedulerServerBase } from "./NamirasoftSchedulerServerBase";
24
+
25
+ export class NamirasoftSchedulerServerValue extends NamirasoftSchedulerServerBase
26
+ {
27
+ constructor(server: NamirasoftSchedulerServer)
28
+ {
29
+ super(server);
30
+ this.List = this.List.bind(this);
31
+ }
32
+ async List(table: string, column: string, search: (string | null), field_id: (string | null), limit: (number | null), config?: BaseServerConfig<any>): Promise<string[]>
33
+ {
34
+ let path = `/value/list/${table}/${column}`;
35
+ let { data } = await this.server._get<string[]>(path, { search, field_id, limit }, config);
36
+ return data;
37
+ }
38
+ };
@@ -0,0 +1,32 @@
1
+ /****************************************************************/
2
+ /* */
3
+ /* This is an Auto-Generated File */
4
+ /* Made By */
5
+ /* Namirasoft SDK Generator NPM Package */
6
+ /* */
7
+ /****************************************************************/
8
+ /****************************************************************/
9
+ /* */
10
+ /* Please do not make any change to this file */
11
+ /* If any change is required, ns-sdkg command must be used */
12
+ /* */
13
+ /****************************************************************/
14
+ /****************************************************************/
15
+ /* */
16
+ /* Namira Software Corporation */
17
+ /* https://namirasoft.com */
18
+ /* */
19
+ /****************************************************************/
20
+
21
+ import { BaseNavigatorCommand } from "namirasoft-node-cli";
22
+ import { HealthzGetCommand } from "./HealthzGetCommand";
23
+
24
+ export class HealthzCommand extends BaseNavigatorCommand
25
+ {
26
+ constructor(argv: string[])
27
+ {
28
+ super(argv, {
29
+ "get": HealthzGetCommand,
30
+ });
31
+ }
32
+ };
@@ -0,0 +1,45 @@
1
+ /****************************************************************/
2
+ /* */
3
+ /* This is an Auto-Generated File */
4
+ /* Made By */
5
+ /* Namirasoft SDK Generator NPM Package */
6
+ /* */
7
+ /****************************************************************/
8
+ /****************************************************************/
9
+ /* */
10
+ /* Please do not make any change to this file */
11
+ /* If any change is required, ns-sdkg command must be used */
12
+ /* */
13
+ /****************************************************************/
14
+ /****************************************************************/
15
+ /* */
16
+ /* Namira Software Corporation */
17
+ /* https://namirasoft.com */
18
+ /* */
19
+ /****************************************************************/
20
+
21
+ import { BaseFinalCommand } from "namirasoft-node-cli";
22
+ import { IStorageMemoryDedicated } from "namirasoft-core";
23
+ import { NamirasoftSchedulerServer } from "../NamirasoftSchedulerServer";
24
+ import { TokenManager } from "namirasoft-account";
25
+
26
+ export class HealthzGetCommand extends BaseFinalCommand
27
+ {
28
+ constructor(argv: string[])
29
+ {
30
+ super(argv, [], []);
31
+ }
32
+ override async exec()
33
+ {
34
+ let token = this.app.storage.getNSAToken();
35
+ if (token == null)
36
+ throw new Error("Token is not available. Please login first using:\nns-scheduler account config \nor \nns-scheduler account login.");
37
+ let storage = new IStorageMemoryDedicated();
38
+ let manager = new TokenManager(storage, () => { });
39
+ manager.setValue(token, false);
40
+ let url = this.app.storage.getItem("ns-scheduler-server-url");
41
+ let server = new NamirasoftSchedulerServer(url, manager, e => this.app.logger.error(e.message));
42
+ let ans = await server.healthz.Get();
43
+ this.app.logger.success(JSON.stringify(ans));
44
+ }
45
+ };
@@ -0,0 +1,32 @@
1
+ /****************************************************************/
2
+ /* */
3
+ /* This is an Auto-Generated File */
4
+ /* Made By */
5
+ /* Namirasoft SDK Generator NPM Package */
6
+ /* */
7
+ /****************************************************************/
8
+ /****************************************************************/
9
+ /* */
10
+ /* Please do not make any change to this file */
11
+ /* If any change is required, ns-sdkg command must be used */
12
+ /* */
13
+ /****************************************************************/
14
+ /****************************************************************/
15
+ /* */
16
+ /* Namira Software Corporation */
17
+ /* https://namirasoft.com */
18
+ /* */
19
+ /****************************************************************/
20
+
21
+ import { BaseNavigatorCommand } from "namirasoft-node-cli";
22
+ import { MetricsGetCommand } from "./MetricsGetCommand";
23
+
24
+ export class MetricsCommand extends BaseNavigatorCommand
25
+ {
26
+ constructor(argv: string[])
27
+ {
28
+ super(argv, {
29
+ "get": MetricsGetCommand,
30
+ });
31
+ }
32
+ };
@@ -0,0 +1,45 @@
1
+ /****************************************************************/
2
+ /* */
3
+ /* This is an Auto-Generated File */
4
+ /* Made By */
5
+ /* Namirasoft SDK Generator NPM Package */
6
+ /* */
7
+ /****************************************************************/
8
+ /****************************************************************/
9
+ /* */
10
+ /* Please do not make any change to this file */
11
+ /* If any change is required, ns-sdkg command must be used */
12
+ /* */
13
+ /****************************************************************/
14
+ /****************************************************************/
15
+ /* */
16
+ /* Namira Software Corporation */
17
+ /* https://namirasoft.com */
18
+ /* */
19
+ /****************************************************************/
20
+
21
+ import { BaseFinalCommand } from "namirasoft-node-cli";
22
+ import { IStorageMemoryDedicated } from "namirasoft-core";
23
+ import { NamirasoftSchedulerServer } from "../NamirasoftSchedulerServer";
24
+ import { TokenManager } from "namirasoft-account";
25
+
26
+ export class MetricsGetCommand extends BaseFinalCommand
27
+ {
28
+ constructor(argv: string[])
29
+ {
30
+ super(argv, [], []);
31
+ }
32
+ override async exec()
33
+ {
34
+ let token = this.app.storage.getNSAToken();
35
+ if (token == null)
36
+ throw new Error("Token is not available. Please login first using:\nns-scheduler account config \nor \nns-scheduler account login.");
37
+ let storage = new IStorageMemoryDedicated();
38
+ let manager = new TokenManager(storage, () => { });
39
+ manager.setValue(token, false);
40
+ let url = this.app.storage.getItem("ns-scheduler-server-url");
41
+ let server = new NamirasoftSchedulerServer(url, manager, e => this.app.logger.error(e.message));
42
+ let ans = await server.metrics.Get();
43
+ this.app.logger.success(JSON.stringify(ans));
44
+ }
45
+ };
@@ -0,0 +1,40 @@
1
+ /****************************************************************/
2
+ /* */
3
+ /* This is an Auto-Generated File */
4
+ /* Made By */
5
+ /* Namirasoft SDK Generator NPM Package */
6
+ /* */
7
+ /****************************************************************/
8
+ /****************************************************************/
9
+ /* */
10
+ /* Please do not make any change to this file */
11
+ /* If any change is required, ns-sdkg command must be used */
12
+ /* */
13
+ /****************************************************************/
14
+ /****************************************************************/
15
+ /* */
16
+ /* Namira Software Corporation */
17
+ /* https://namirasoft.com */
18
+ /* */
19
+ /****************************************************************/
20
+
21
+ import { BaseNavigatorCommand } from "namirasoft-node-cli";
22
+ import { SchedulerCreateCommand } from "./SchedulerCreateCommand";
23
+ import { SchedulerDeleteCommand } from "./SchedulerDeleteCommand";
24
+ import { SchedulerGetCommand } from "./SchedulerGetCommand";
25
+ import { SchedulerListCommand } from "./SchedulerListCommand";
26
+ import { SchedulerUpdateCommand } from "./SchedulerUpdateCommand";
27
+
28
+ export class SchedulerCommand extends BaseNavigatorCommand
29
+ {
30
+ constructor(argv: string[])
31
+ {
32
+ super(argv, {
33
+ "list": SchedulerListCommand,
34
+ "get": SchedulerGetCommand,
35
+ "create": SchedulerCreateCommand,
36
+ "update": SchedulerUpdateCommand,
37
+ "delete": SchedulerDeleteCommand,
38
+ });
39
+ }
40
+ };
@@ -0,0 +1,299 @@
1
+ /****************************************************************/
2
+ /* */
3
+ /* This is an Auto-Generated File */
4
+ /* Made By */
5
+ /* Namirasoft SDK Generator NPM Package */
6
+ /* */
7
+ /****************************************************************/
8
+ /****************************************************************/
9
+ /* */
10
+ /* Please do not make any change to this file */
11
+ /* If any change is required, ns-sdkg command must be used */
12
+ /* */
13
+ /****************************************************************/
14
+ /****************************************************************/
15
+ /* */
16
+ /* Namira Software Corporation */
17
+ /* https://namirasoft.com */
18
+ /* */
19
+ /****************************************************************/
20
+
21
+ import { BaseFinalCommand } from "namirasoft-node-cli";
22
+ import { IStorageMemoryDedicated } from "namirasoft-core";
23
+ import { NamirasoftSchedulerServer } from "../NamirasoftSchedulerServer";
24
+ import { TokenManager } from "namirasoft-account";
25
+
26
+ export class SchedulerCreateCommand extends BaseFinalCommand
27
+ {
28
+ constructor(argv: string[])
29
+ {
30
+ super(argv, [], [
31
+ {
32
+ name: "name",
33
+ short: "",
34
+ description: "Provides the value of 'name' in body",
35
+ optional: false,
36
+ args: ["name"],
37
+ defaults: [""]
38
+ },
39
+ {
40
+ name: "start_date",
41
+ short: "",
42
+ description: "Provides the value of 'start_date' in body",
43
+ optional: false,
44
+ args: ["start_date"],
45
+ defaults: [""]
46
+ },
47
+ {
48
+ name: "start_time",
49
+ short: "",
50
+ description: "Provides the value of 'start_time' in body",
51
+ optional: false,
52
+ args: ["start_time"],
53
+ defaults: [""]
54
+ },
55
+ {
56
+ name: "end_date",
57
+ short: "",
58
+ description: "Provides the value of 'end_date' in body",
59
+ optional: true,
60
+ args: ["end_date"],
61
+ defaults: [""]
62
+ },
63
+ {
64
+ name: "end_time",
65
+ short: "",
66
+ description: "Provides the value of 'end_time' in body",
67
+ optional: true,
68
+ args: ["end_time"],
69
+ defaults: [""]
70
+ },
71
+ {
72
+ name: "max_repeat_count",
73
+ short: "",
74
+ description: "Provides the value of 'max_repeat_count' in body",
75
+ optional: true,
76
+ args: ["max_repeat_count"],
77
+ defaults: [""]
78
+ },
79
+ {
80
+ name: "frequency_type",
81
+ short: "",
82
+ description: "Provides the value of 'frequency_type' in body",
83
+ optional: true,
84
+ args: ["frequency_type"],
85
+ defaults: [""]
86
+ },
87
+ {
88
+ name: "frequency_day_every",
89
+ short: "",
90
+ description: "Provides the value of 'frequency_day_every' in body",
91
+ optional: true,
92
+ args: ["frequency_day_every"],
93
+ defaults: [""]
94
+ },
95
+ {
96
+ name: "frequency_week_every",
97
+ short: "",
98
+ description: "Provides the value of 'frequency_week_every' in body",
99
+ optional: true,
100
+ args: ["frequency_week_every"],
101
+ defaults: [""]
102
+ },
103
+ {
104
+ name: "frequency_week_days",
105
+ short: "",
106
+ description: "Provides the value of 'frequency_week_days' in body",
107
+ optional: true,
108
+ args: ["frequency_week_days"],
109
+ defaults: [""]
110
+ },
111
+ {
112
+ name: "frequency_month_names",
113
+ short: "",
114
+ description: "Provides the value of 'frequency_month_names' in body",
115
+ optional: true,
116
+ args: ["frequency_month_names"],
117
+ defaults: [""]
118
+ },
119
+ {
120
+ name: "frequency_month_days",
121
+ short: "",
122
+ description: "Provides the value of 'frequency_month_days' in body",
123
+ optional: true,
124
+ args: ["frequency_month_days"],
125
+ defaults: [""]
126
+ },
127
+ {
128
+ name: "frequency_month_on_week",
129
+ short: "",
130
+ description: "Provides the value of 'frequency_month_on_week' in body",
131
+ optional: true,
132
+ args: ["frequency_month_on_week"],
133
+ defaults: [""]
134
+ },
135
+ {
136
+ name: "frequency_month_on_days",
137
+ short: "",
138
+ description: "Provides the value of 'frequency_month_on_days' in body",
139
+ optional: true,
140
+ args: ["frequency_month_on_days"],
141
+ defaults: [""]
142
+ },
143
+ {
144
+ name: "repeat_every_value",
145
+ short: "",
146
+ description: "Provides the value of 'repeat_every_value' in body",
147
+ optional: true,
148
+ args: ["repeat_every_value"],
149
+ defaults: [""]
150
+ },
151
+ {
152
+ name: "repeat_every_unit",
153
+ short: "",
154
+ description: "Provides the value of 'repeat_every_unit' in body",
155
+ optional: true,
156
+ args: ["repeat_every_unit"],
157
+ defaults: [""]
158
+ },
159
+ {
160
+ name: "repeat_until_value",
161
+ short: "",
162
+ description: "Provides the value of 'repeat_until_value' in body",
163
+ optional: true,
164
+ args: ["repeat_until_value"],
165
+ defaults: [""]
166
+ },
167
+ {
168
+ name: "repeat_until_unit",
169
+ short: "",
170
+ description: "Provides the value of 'repeat_until_unit' in body",
171
+ optional: true,
172
+ args: ["repeat_until_unit"],
173
+ defaults: [""]
174
+ },
175
+ {
176
+ name: "random_delay_value",
177
+ short: "",
178
+ description: "Provides the value of 'random_delay_value' in body",
179
+ optional: true,
180
+ args: ["random_delay_value"],
181
+ defaults: [""]
182
+ },
183
+ {
184
+ name: "random_delay_unit",
185
+ short: "",
186
+ description: "Provides the value of 'random_delay_unit' in body",
187
+ optional: true,
188
+ args: ["random_delay_unit"],
189
+ defaults: [""]
190
+ },
191
+ {
192
+ name: "cron_year",
193
+ short: "",
194
+ description: "Provides the value of 'cron_year' in body",
195
+ optional: true,
196
+ args: ["cron_year"],
197
+ defaults: [""]
198
+ },
199
+ {
200
+ name: "cron_month",
201
+ short: "",
202
+ description: "Provides the value of 'cron_month' in body",
203
+ optional: true,
204
+ args: ["cron_month"],
205
+ defaults: [""]
206
+ },
207
+ {
208
+ name: "cron_week",
209
+ short: "",
210
+ description: "Provides the value of 'cron_week' in body",
211
+ optional: true,
212
+ args: ["cron_week"],
213
+ defaults: [""]
214
+ },
215
+ {
216
+ name: "cron_day",
217
+ short: "",
218
+ description: "Provides the value of 'cron_day' in body",
219
+ optional: true,
220
+ args: ["cron_day"],
221
+ defaults: [""]
222
+ },
223
+ {
224
+ name: "cron_day_of_week",
225
+ short: "",
226
+ description: "Provides the value of 'cron_day_of_week' in body",
227
+ optional: true,
228
+ args: ["cron_day_of_week"],
229
+ defaults: [""]
230
+ },
231
+ {
232
+ name: "cron_hour",
233
+ short: "",
234
+ description: "Provides the value of 'cron_hour' in body",
235
+ optional: true,
236
+ args: ["cron_hour"],
237
+ defaults: [""]
238
+ },
239
+ {
240
+ name: "cron_minute",
241
+ short: "",
242
+ description: "Provides the value of 'cron_minute' in body",
243
+ optional: true,
244
+ args: ["cron_minute"],
245
+ defaults: [""]
246
+ },
247
+ {
248
+ name: "description",
249
+ short: "",
250
+ description: "Provides the value of 'description' in body",
251
+ optional: true,
252
+ args: ["description"],
253
+ defaults: [""]
254
+ }
255
+ ]);
256
+ }
257
+ override async exec()
258
+ {
259
+ let token = this.app.storage.getNSAToken();
260
+ if (token == null)
261
+ throw new Error("Token is not available. Please login first using:\nns-scheduler account config \nor \nns-scheduler account login.");
262
+ let storage = new IStorageMemoryDedicated();
263
+ let manager = new TokenManager(storage, () => { });
264
+ manager.setValue(token, false);
265
+ let url = this.app.storage.getItem("ns-scheduler-server-url");
266
+ let server = new NamirasoftSchedulerServer(url, manager, e => this.app.logger.error(e.message));
267
+ let ans = await server.scheduler.Create({
268
+ name: this.option_values.name,
269
+ start_date: this.option_values.start_date,
270
+ start_time: this.option_values.start_time,
271
+ end_date: this.option_values.end_date,
272
+ end_time: this.option_values.end_time,
273
+ max_repeat_count: this.option_values.max_repeat_count,
274
+ frequency_type: this.option_values.frequency_type,
275
+ frequency_day_every: this.option_values.frequency_day_every,
276
+ frequency_week_every: this.option_values.frequency_week_every,
277
+ frequency_week_days: this.option_values.frequency_week_days,
278
+ frequency_month_names: this.option_values.frequency_month_names,
279
+ frequency_month_days: this.option_values.frequency_month_days,
280
+ frequency_month_on_week: this.option_values.frequency_month_on_week,
281
+ frequency_month_on_days: this.option_values.frequency_month_on_days,
282
+ repeat_every_value: this.option_values.repeat_every_value,
283
+ repeat_every_unit: this.option_values.repeat_every_unit,
284
+ repeat_until_value: this.option_values.repeat_until_value,
285
+ repeat_until_unit: this.option_values.repeat_until_unit,
286
+ random_delay_value: this.option_values.random_delay_value,
287
+ random_delay_unit: this.option_values.random_delay_unit,
288
+ cron_year: this.option_values.cron_year,
289
+ cron_month: this.option_values.cron_month,
290
+ cron_week: this.option_values.cron_week,
291
+ cron_day: this.option_values.cron_day,
292
+ cron_day_of_week: this.option_values.cron_day_of_week,
293
+ cron_hour: this.option_values.cron_hour,
294
+ cron_minute: this.option_values.cron_minute,
295
+ description: this.option_values.description
296
+ });
297
+ this.app.logger.success(JSON.stringify(ans));
298
+ }
299
+ };