namirasoft-cost 1.4.20 → 1.4.22

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 (237) hide show
  1. package/.ns-sdkg-dir-deep +3 -2
  2. package/.ns-sdkg-file-keep +21 -5
  3. package/dist/NamirasoftCostServer.d.ts +2 -0
  4. package/dist/NamirasoftCostServer.js +3 -1
  5. package/dist/NamirasoftCostServer.js.map +1 -1
  6. package/dist/NamirasoftCostServerBillWatchAWS.d.ts +4 -4
  7. package/dist/NamirasoftCostServerBillWatchAWS.js +6 -6
  8. package/dist/NamirasoftCostServerBillWatchAWS.js.map +1 -1
  9. package/dist/NamirasoftCostServerBillWatchAzure.d.ts +4 -4
  10. package/dist/NamirasoftCostServerBillWatchAzure.js +6 -6
  11. package/dist/NamirasoftCostServerBillWatchAzure.js.map +1 -1
  12. package/dist/NamirasoftCostServerBillWatchGCP.d.ts +4 -4
  13. package/dist/NamirasoftCostServerBillWatchGCP.js +6 -6
  14. package/dist/NamirasoftCostServerBillWatchGCP.js.map +1 -1
  15. package/dist/NamirasoftCostServerFieldCategory.d.ts +4 -4
  16. package/dist/NamirasoftCostServerFieldCategory.js +6 -6
  17. package/dist/NamirasoftCostServerFieldCategory.js.map +1 -1
  18. package/dist/NamirasoftCostServerFieldField.d.ts +4 -4
  19. package/dist/NamirasoftCostServerFieldField.js +6 -6
  20. package/dist/NamirasoftCostServerFieldField.js.map +1 -1
  21. package/dist/NamirasoftCostServerSecretSecret.d.ts +36 -0
  22. package/dist/NamirasoftCostServerSecretSecret.js +53 -0
  23. package/dist/NamirasoftCostServerSecretSecret.js.map +1 -0
  24. package/dist/bonus/BaseBonus.d.ts +13 -0
  25. package/dist/bonus/BaseBonus.js +11 -0
  26. package/dist/bonus/BaseBonus.js.map +1 -0
  27. package/dist/bonus/DeactiveBonus.d.ts +10 -0
  28. package/dist/bonus/DeactiveBonus.js +27 -0
  29. package/dist/bonus/DeactiveBonus.js.map +1 -0
  30. package/dist/bonus/FreeCountBonus.d.ts +10 -0
  31. package/dist/bonus/FreeCountBonus.js +27 -0
  32. package/dist/bonus/FreeCountBonus.js.map +1 -0
  33. package/dist/bonus/FreeTotalValueBonus.d.ts +33 -0
  34. package/dist/bonus/FreeTotalValueBonus.js +39 -0
  35. package/dist/bonus/FreeTotalValueBonus.js.map +1 -0
  36. package/dist/bonus/LowAmountBonus.d.ts +10 -0
  37. package/dist/bonus/LowAmountBonus.js +27 -0
  38. package/dist/bonus/LowAmountBonus.js.map +1 -0
  39. package/dist/bonus/LowSecondsBonus.d.ts +10 -0
  40. package/dist/bonus/LowSecondsBonus.js +27 -0
  41. package/dist/bonus/LowSecondsBonus.js.map +1 -0
  42. package/dist/bonus/LowTotalCountBonus.d.ts +10 -0
  43. package/dist/bonus/LowTotalCountBonus.js +27 -0
  44. package/dist/bonus/LowTotalCountBonus.js.map +1 -0
  45. package/dist/bonus/LowTotalValueBonus.d.ts +10 -0
  46. package/dist/bonus/LowTotalValueBonus.js +27 -0
  47. package/dist/bonus/LowTotalValueBonus.js.map +1 -0
  48. package/dist/bonus/TrialBonus.d.ts +12 -0
  49. package/dist/bonus/TrialBonus.js +32 -0
  50. package/dist/bonus/TrialBonus.js.map +1 -0
  51. package/dist/command/BillWatchAWSCommand.js +4 -4
  52. package/dist/command/BillWatchAWSCommand.js.map +1 -1
  53. package/dist/command/{BillWatchAWS_CreateForCommand.d.ts → BillWatchAWSEstimateHourlyCommand.d.ts} +1 -1
  54. package/dist/command/{BillWatchGCPEstimationCommand.js → BillWatchAWSEstimateHourlyCommand.js} +15 -15
  55. package/dist/command/BillWatchAWSEstimateHourlyCommand.js.map +1 -0
  56. package/dist/command/BillWatchAWS_CreateForHourlyCommand.d.ts +5 -0
  57. package/dist/command/{BillWatchAWS_CreateForCommand.js → BillWatchAWS_CreateForHourlyCommand.js} +14 -14
  58. package/dist/command/BillWatchAWS_CreateForHourlyCommand.js.map +1 -0
  59. package/dist/command/BillWatchAzureCommand.js +4 -4
  60. package/dist/command/BillWatchAzureCommand.js.map +1 -1
  61. package/dist/command/BillWatchAzureEstimateHourlyCommand.d.ts +5 -0
  62. package/dist/command/BillWatchAzureEstimateHourlyCommand.js +76 -0
  63. package/dist/command/BillWatchAzureEstimateHourlyCommand.js.map +1 -0
  64. package/dist/command/BillWatchAzure_CreateForHourlyCommand.d.ts +5 -0
  65. package/dist/command/BillWatchAzure_CreateForHourlyCommand.js +94 -0
  66. package/dist/command/BillWatchAzure_CreateForHourlyCommand.js.map +1 -0
  67. package/dist/command/BillWatchGCPCommand.js +4 -4
  68. package/dist/command/BillWatchGCPCommand.js.map +1 -1
  69. package/dist/command/{BillWatchAWSEstimationCommand.d.ts → BillWatchGCPEstimateHourlyCommand.d.ts} +1 -1
  70. package/dist/command/{FieldCategoryEstimationCommand.js → BillWatchGCPEstimateHourlyCommand.js} +15 -15
  71. package/dist/command/BillWatchGCPEstimateHourlyCommand.js.map +1 -0
  72. package/dist/command/BillWatchGCP_CreateForHourlyCommand.d.ts +5 -0
  73. package/dist/command/{FieldCategory_CreateForCommand.js → BillWatchGCP_CreateForHourlyCommand.js} +14 -14
  74. package/dist/command/BillWatchGCP_CreateForHourlyCommand.js.map +1 -0
  75. package/dist/command/FieldCategoryCommand.js +4 -4
  76. package/dist/command/FieldCategoryCommand.js.map +1 -1
  77. package/dist/command/FieldCategoryEstimateHourlyCommand.d.ts +5 -0
  78. package/dist/command/FieldCategoryEstimateHourlyCommand.js +76 -0
  79. package/dist/command/FieldCategoryEstimateHourlyCommand.js.map +1 -0
  80. package/dist/command/FieldCategory_CreateForHourlyCommand.d.ts +5 -0
  81. package/dist/command/FieldCategory_CreateForHourlyCommand.js +94 -0
  82. package/dist/command/FieldCategory_CreateForHourlyCommand.js.map +1 -0
  83. package/dist/command/FieldFieldCommand.js +4 -4
  84. package/dist/command/FieldFieldCommand.js.map +1 -1
  85. package/dist/command/{BillWatchAzure_CreateForCommand.d.ts → FieldFieldEstimateHourlyCommand.d.ts} +1 -1
  86. package/dist/command/{BillWatchAzureEstimationCommand.js → FieldFieldEstimateHourlyCommand.js} +15 -15
  87. package/dist/command/{BillWatchAzureEstimationCommand.js.map → FieldFieldEstimateHourlyCommand.js.map} +1 -1
  88. package/dist/command/FieldField_CreateForHourlyCommand.d.ts +5 -0
  89. package/dist/command/{BillWatchGCP_CreateForCommand.js → FieldField_CreateForHourlyCommand.js} +14 -14
  90. package/dist/command/FieldField_CreateForHourlyCommand.js.map +1 -0
  91. package/dist/command/SecretSecretCommand.d.ts +4 -0
  92. package/dist/command/SecretSecretCommand.js +21 -0
  93. package/dist/command/SecretSecretCommand.js.map +1 -0
  94. package/dist/command/SecretSecretEstimateHourlyCommand.d.ts +5 -0
  95. package/dist/command/{BillWatchAWSEstimationCommand.js → SecretSecretEstimateHourlyCommand.js} +15 -15
  96. package/dist/command/SecretSecretEstimateHourlyCommand.js.map +1 -0
  97. package/dist/command/{BillWatchAzureEstimationCommand.d.ts → SecretSecretEstimateReadCommand.d.ts} +1 -1
  98. package/dist/command/{FieldFieldEstimationCommand.js → SecretSecretEstimateReadCommand.js} +17 -17
  99. package/dist/command/SecretSecretEstimateReadCommand.js.map +1 -0
  100. package/dist/command/SecretSecret_CreateForHourlyCommand.d.ts +5 -0
  101. package/dist/command/{BillWatchAzure_CreateForCommand.js → SecretSecret_CreateForHourlyCommand.js} +14 -14
  102. package/dist/command/SecretSecret_CreateForHourlyCommand.js.map +1 -0
  103. package/dist/command/SecretSecret_CreateForReadCommand.d.ts +5 -0
  104. package/dist/command/{FieldField_CreateForCommand.js → SecretSecret_CreateForReadCommand.js} +16 -16
  105. package/dist/command/SecretSecret_CreateForReadCommand.js.map +1 -0
  106. package/dist/command/cli.js +2 -0
  107. package/dist/command/cli.js.map +1 -1
  108. package/dist/estimator/BaseEstimator.d.ts +15 -0
  109. package/dist/estimator/BaseEstimator.js +58 -0
  110. package/dist/estimator/BaseEstimator.js.map +1 -0
  111. package/dist/estimator/BillWatchAWSHourlyEstimator.d.ts +3 -0
  112. package/dist/estimator/BillWatchAWSHourlyEstimator.js +8 -0
  113. package/dist/estimator/BillWatchAWSHourlyEstimator.js.map +1 -0
  114. package/dist/estimator/BillWatchAzureHourlyEstimator.d.ts +3 -0
  115. package/dist/estimator/BillWatchAzureHourlyEstimator.js +8 -0
  116. package/dist/estimator/BillWatchAzureHourlyEstimator.js.map +1 -0
  117. package/dist/estimator/BillWatchBaseHourlyEstimator.d.ts +14 -0
  118. package/dist/estimator/BillWatchBaseHourlyEstimator.js +26 -0
  119. package/dist/estimator/BillWatchBaseHourlyEstimator.js.map +1 -0
  120. package/dist/estimator/BillWatchGCPHourlyEstimator.d.ts +3 -0
  121. package/dist/estimator/BillWatchGCPHourlyEstimator.js +8 -0
  122. package/dist/estimator/BillWatchGCPHourlyEstimator.js.map +1 -0
  123. package/dist/estimator/FieldBaseHourlyEstimator.d.ts +9 -0
  124. package/dist/estimator/FieldBaseHourlyEstimator.js +22 -0
  125. package/dist/estimator/FieldBaseHourlyEstimator.js.map +1 -0
  126. package/dist/estimator/FieldCategoryHourlyEstimator.d.ts +8 -0
  127. package/dist/estimator/FieldCategoryHourlyEstimator.js +12 -0
  128. package/dist/estimator/FieldCategoryHourlyEstimator.js.map +1 -0
  129. package/dist/estimator/FieldFieldHourlyEstimator.d.ts +8 -0
  130. package/dist/estimator/FieldFieldHourlyEstimator.js +12 -0
  131. package/dist/estimator/FieldFieldHourlyEstimator.js.map +1 -0
  132. package/dist/estimator/SecretSecretHourlyEstimator.d.ts +14 -0
  133. package/dist/estimator/SecretSecretHourlyEstimator.js +25 -0
  134. package/dist/estimator/SecretSecretHourlyEstimator.js.map +1 -0
  135. package/dist/estimator/SecretSecretReadEstimator.d.ts +14 -0
  136. package/dist/estimator/SecretSecretReadEstimator.js +25 -0
  137. package/dist/estimator/SecretSecretReadEstimator.js.map +1 -0
  138. package/dist/index.d.ts +16 -15
  139. package/dist/index.js +16 -15
  140. package/dist/index.js.map +1 -1
  141. package/dist/type/Estimation.d.ts +10 -3
  142. package/dist/type/EstimationOption.d.ts +10 -0
  143. package/dist/type/{EstimationRow.js → EstimationOption.js} +2 -1
  144. package/dist/type/EstimationOption.js.map +1 -0
  145. package/dist/type/Period.d.ts +20 -2
  146. package/dist/type/Period.js +61 -0
  147. package/dist/type/Period.js.map +1 -1
  148. package/dist/type/Usage.d.ts +24 -0
  149. package/dist/type/Usage.js +30 -0
  150. package/dist/type/Usage.js.map +1 -0
  151. package/package.json +2 -2
  152. package/src/NamirasoftCostServer.ts +4 -1
  153. package/src/NamirasoftCostServerBillWatchAWS.ts +6 -6
  154. package/src/NamirasoftCostServerBillWatchAzure.ts +6 -6
  155. package/src/NamirasoftCostServerBillWatchGCP.ts +6 -6
  156. package/src/NamirasoftCostServerFieldCategory.ts +6 -6
  157. package/src/NamirasoftCostServerFieldField.ts +6 -6
  158. package/src/NamirasoftCostServerSecretSecret.ts +61 -0
  159. package/src/bonus/BaseBonus.ts +14 -0
  160. package/src/bonus/DeactiveBonus.ts +15 -0
  161. package/src/bonus/FreeCountBonus.ts +15 -0
  162. package/src/bonus/FreeTotalValueBonus.ts +29 -0
  163. package/src/bonus/LowAmountBonus.ts +15 -0
  164. package/src/bonus/LowSecondsBonus.ts +15 -0
  165. package/src/bonus/LowTotalCountBonus.ts +15 -0
  166. package/src/bonus/LowTotalValueBonus.ts +15 -0
  167. package/src/bonus/TrialBonus.ts +19 -0
  168. package/src/command/BillWatchAWSCommand.ts +4 -4
  169. package/src/command/{FieldCategoryEstimationCommand.ts → BillWatchAWSEstimateHourlyCommand.ts} +12 -12
  170. package/src/command/{BillWatchAzure_CreateForCommand.ts → BillWatchAWS_CreateForHourlyCommand.ts} +11 -11
  171. package/src/command/BillWatchAzureCommand.ts +4 -4
  172. package/src/command/BillWatchAzureEstimateHourlyCommand.ts +83 -0
  173. package/src/command/BillWatchAzure_CreateForHourlyCommand.ts +101 -0
  174. package/src/command/BillWatchGCPCommand.ts +4 -4
  175. package/src/command/{BillWatchGCPEstimationCommand.ts → BillWatchGCPEstimateHourlyCommand.ts} +12 -12
  176. package/src/command/{FieldCategory_CreateForCommand.ts → BillWatchGCP_CreateForHourlyCommand.ts} +11 -11
  177. package/src/command/FieldCategoryCommand.ts +4 -4
  178. package/src/command/FieldCategoryEstimateHourlyCommand.ts +83 -0
  179. package/src/command/FieldCategory_CreateForHourlyCommand.ts +101 -0
  180. package/src/command/FieldFieldCommand.ts +4 -4
  181. package/src/command/{BillWatchAzureEstimationCommand.ts → FieldFieldEstimateHourlyCommand.ts} +12 -12
  182. package/src/command/{BillWatchGCP_CreateForCommand.ts → FieldField_CreateForHourlyCommand.ts} +11 -11
  183. package/src/command/SecretSecretCommand.ts +38 -0
  184. package/src/command/{BillWatchAWSEstimationCommand.ts → SecretSecretEstimateHourlyCommand.ts} +12 -12
  185. package/src/command/{FieldFieldEstimationCommand.ts → SecretSecretEstimateReadCommand.ts} +14 -14
  186. package/src/command/{BillWatchAWS_CreateForCommand.ts → SecretSecret_CreateForHourlyCommand.ts} +11 -11
  187. package/src/command/{FieldField_CreateForCommand.ts → SecretSecret_CreateForReadCommand.ts} +13 -13
  188. package/src/command/cli.ts +2 -0
  189. package/src/estimator/BaseEstimator.ts +63 -0
  190. package/src/estimator/BillWatchAWSHourlyEstimator.ts +5 -0
  191. package/src/estimator/BillWatchAzureHourlyEstimator.ts +5 -0
  192. package/src/estimator/BillWatchBaseHourlyEstimator.ts +26 -0
  193. package/src/estimator/BillWatchGCPHourlyEstimator.ts +5 -0
  194. package/src/estimator/FieldBaseHourlyEstimator.ts +21 -0
  195. package/src/estimator/FieldCategoryHourlyEstimator.ts +10 -0
  196. package/src/estimator/FieldFieldHourlyEstimator.ts +10 -0
  197. package/src/estimator/SecretSecretHourlyEstimator.ts +25 -0
  198. package/src/estimator/SecretSecretReadEstimator.ts +26 -0
  199. package/src/index.ts +17 -16
  200. package/src/type/Estimation.ts +10 -3
  201. package/src/type/EstimationOption.ts +12 -0
  202. package/src/type/Period.ts +72 -3
  203. package/src/type/Usage.ts +25 -0
  204. package/dist/TimeUtil.d.ts +0 -7
  205. package/dist/TimeUtil.js +0 -66
  206. package/dist/TimeUtil.js.map +0 -1
  207. package/dist/command/BillWatchAWSEstimationCommand.js.map +0 -1
  208. package/dist/command/BillWatchAWS_CreateForCommand.js.map +0 -1
  209. package/dist/command/BillWatchAzure_CreateForCommand.js.map +0 -1
  210. package/dist/command/BillWatchGCPEstimationCommand.d.ts +0 -5
  211. package/dist/command/BillWatchGCPEstimationCommand.js.map +0 -1
  212. package/dist/command/BillWatchGCP_CreateForCommand.d.ts +0 -5
  213. package/dist/command/BillWatchGCP_CreateForCommand.js.map +0 -1
  214. package/dist/command/FieldCategoryEstimationCommand.d.ts +0 -5
  215. package/dist/command/FieldCategoryEstimationCommand.js.map +0 -1
  216. package/dist/command/FieldCategory_CreateForCommand.d.ts +0 -5
  217. package/dist/command/FieldCategory_CreateForCommand.js.map +0 -1
  218. package/dist/command/FieldFieldEstimationCommand.d.ts +0 -5
  219. package/dist/command/FieldFieldEstimationCommand.js.map +0 -1
  220. package/dist/command/FieldField_CreateForCommand.d.ts +0 -5
  221. package/dist/command/FieldField_CreateForCommand.js.map +0 -1
  222. package/dist/enum/TrialUnit.d.ts +0 -5
  223. package/dist/enum/TrialUnit.js +0 -10
  224. package/dist/enum/TrialUnit.js.map +0 -1
  225. package/dist/type/EstimationRow.d.ts +0 -9
  226. package/dist/type/EstimationRow.js.map +0 -1
  227. package/dist/type/Trial.d.ts +0 -5
  228. package/dist/type/Trial.js +0 -3
  229. package/dist/type/Trial.js.map +0 -1
  230. package/dist/type/TrialDuration.d.ts +0 -5
  231. package/dist/type/TrialDuration.js +0 -3
  232. package/dist/type/TrialDuration.js.map +0 -1
  233. package/src/TimeUtil.ts +0 -67
  234. package/src/enum/TrialUnit.ts +0 -6
  235. package/src/type/EstimationRow.ts +0 -10
  236. package/src/type/Trial.ts +0 -7
  237. package/src/type/TrialDuration.ts +0 -7
@@ -23,7 +23,7 @@ import { IStorageMemoryDedicated } from "namirasoft-core";
23
23
  import { NamirasoftCostServer } from "../NamirasoftCostServer";
24
24
  import { TokenManager } from "namirasoft-account";
25
25
 
26
- export class FieldFieldEstimationCommand extends BaseFinalCommand
26
+ export class SecretSecretEstimateReadCommand extends BaseFinalCommand
27
27
  {
28
28
  constructor(argv: string[])
29
29
  {
@@ -37,27 +37,27 @@ export class FieldFieldEstimationCommand extends BaseFinalCommand
37
37
  defaults: [""]
38
38
  },
39
39
  {
40
- name: "row_number",
40
+ name: "period",
41
41
  short: "",
42
- description: "Provides the value of 'row_number' in body",
42
+ description: "Provides the value of 'period' in body",
43
43
  optional: false,
44
- args: ["row_number"],
44
+ args: ["period"],
45
45
  defaults: [""]
46
46
  },
47
47
  {
48
- name: "active",
48
+ name: "total",
49
49
  short: "",
50
- description: "Provides the value of 'active' in body",
50
+ description: "Provides the value of 'total' in body",
51
51
  optional: false,
52
- args: ["active"],
52
+ args: ["total"],
53
53
  defaults: [""]
54
54
  },
55
55
  {
56
- name: "period",
56
+ name: "count",
57
57
  short: "",
58
- description: "Provides the value of 'period' in body",
58
+ description: "Provides the value of 'count' in body",
59
59
  optional: false,
60
- args: ["period"],
60
+ args: ["count"],
61
61
  defaults: [""]
62
62
  }
63
63
  ]);
@@ -72,11 +72,11 @@ export class FieldFieldEstimationCommand extends BaseFinalCommand
72
72
  manager.setValue(token, false);
73
73
  let url = this.app.storage.getItem("ns-cost-server-url");
74
74
  let server = new NamirasoftCostServer(url, manager, e => this.app.logger.error(e.message));
75
- let ans = await server.field_field.Estimation({
75
+ let ans = await server.secret_secret.EstimateRead({
76
76
  first_entity_created_at: this.option_values.first_entity_created_at,
77
- row_number: this.option_values.row_number,
78
- active: this.option_values.active,
79
- period: this.option_values.period
77
+ period: this.option_values.period,
78
+ total: this.option_values.total,
79
+ count: this.option_values.count
80
80
  });
81
81
  this.app.logger.success(JSON.stringify(ans));
82
82
  }
@@ -23,7 +23,7 @@ import { IStorageMemoryDedicated } from "namirasoft-core";
23
23
  import { NamirasoftCostServer } from "../NamirasoftCostServer";
24
24
  import { TokenManager } from "namirasoft-account";
25
25
 
26
- export class BillWatchAWS_CreateForCommand extends BaseFinalCommand
26
+ export class SecretSecret_CreateForHourlyCommand extends BaseFinalCommand
27
27
  {
28
28
  constructor(argv: string[])
29
29
  {
@@ -36,6 +36,14 @@ export class BillWatchAWS_CreateForCommand extends BaseFinalCommand
36
36
  args: ["first_entity_created_at"],
37
37
  defaults: [""]
38
38
  },
39
+ {
40
+ name: "period",
41
+ short: "",
42
+ description: "Provides the value of 'period' in body",
43
+ optional: false,
44
+ args: ["period"],
45
+ defaults: [""]
46
+ },
39
47
  {
40
48
  name: "row_number",
41
49
  short: "",
@@ -52,14 +60,6 @@ export class BillWatchAWS_CreateForCommand extends BaseFinalCommand
52
60
  args: ["active"],
53
61
  defaults: [""]
54
62
  },
55
- {
56
- name: "period",
57
- short: "",
58
- description: "Provides the value of 'period' in body",
59
- optional: false,
60
- args: ["period"],
61
- defaults: [""]
62
- },
63
63
  {
64
64
  name: "workspace_id",
65
65
  short: "",
@@ -88,11 +88,11 @@ export class BillWatchAWS_CreateForCommand extends BaseFinalCommand
88
88
  manager.setValue(token, false);
89
89
  let url = this.app.storage.getItem("ns-cost-server-url");
90
90
  let server = new NamirasoftCostServer(url, manager, e => this.app.logger.error(e.message));
91
- let ans = await server.bill_watch_aws._CreateFor(this.arg_values[0], {
91
+ let ans = await server.secret_secret._CreateForHourly(this.arg_values[0], {
92
92
  first_entity_created_at: this.option_values.first_entity_created_at,
93
+ period: this.option_values.period,
93
94
  row_number: this.option_values.row_number,
94
95
  active: this.option_values.active,
95
- period: this.option_values.period,
96
96
  workspace_id: this.option_values.workspace_id,
97
97
  resource_id: this.option_values.resource_id
98
98
  });
@@ -23,7 +23,7 @@ import { IStorageMemoryDedicated } from "namirasoft-core";
23
23
  import { NamirasoftCostServer } from "../NamirasoftCostServer";
24
24
  import { TokenManager } from "namirasoft-account";
25
25
 
26
- export class FieldField_CreateForCommand extends BaseFinalCommand
26
+ export class SecretSecret_CreateForReadCommand extends BaseFinalCommand
27
27
  {
28
28
  constructor(argv: string[])
29
29
  {
@@ -37,27 +37,27 @@ export class FieldField_CreateForCommand extends BaseFinalCommand
37
37
  defaults: [""]
38
38
  },
39
39
  {
40
- name: "row_number",
40
+ name: "period",
41
41
  short: "",
42
- description: "Provides the value of 'row_number' in body",
42
+ description: "Provides the value of 'period' in body",
43
43
  optional: false,
44
- args: ["row_number"],
44
+ args: ["period"],
45
45
  defaults: [""]
46
46
  },
47
47
  {
48
- name: "active",
48
+ name: "total",
49
49
  short: "",
50
- description: "Provides the value of 'active' in body",
50
+ description: "Provides the value of 'total' in body",
51
51
  optional: false,
52
- args: ["active"],
52
+ args: ["total"],
53
53
  defaults: [""]
54
54
  },
55
55
  {
56
- name: "period",
56
+ name: "count",
57
57
  short: "",
58
- description: "Provides the value of 'period' in body",
58
+ description: "Provides the value of 'count' in body",
59
59
  optional: false,
60
- args: ["period"],
60
+ args: ["count"],
61
61
  defaults: [""]
62
62
  },
63
63
  {
@@ -88,11 +88,11 @@ export class FieldField_CreateForCommand extends BaseFinalCommand
88
88
  manager.setValue(token, false);
89
89
  let url = this.app.storage.getItem("ns-cost-server-url");
90
90
  let server = new NamirasoftCostServer(url, manager, e => this.app.logger.error(e.message));
91
- let ans = await server.field_field._CreateFor(this.arg_values[0], {
91
+ let ans = await server.secret_secret._CreateForRead(this.arg_values[0], {
92
92
  first_entity_created_at: this.option_values.first_entity_created_at,
93
- row_number: this.option_values.row_number,
94
- active: this.option_values.active,
95
93
  period: this.option_values.period,
94
+ total: this.option_values.total,
95
+ count: this.option_values.count,
96
96
  workspace_id: this.option_values.workspace_id,
97
97
  resource_id: this.option_values.resource_id
98
98
  });
@@ -30,6 +30,7 @@ import { FieldCategoryCommand } from "./FieldCategoryCommand";
30
30
  import { FieldFieldCommand } from "./FieldFieldCommand";
31
31
  import { HealthzCommand } from "./HealthzCommand";
32
32
  import { MetricsCommand } from "./MetricsCommand";
33
+ import { SecretSecretCommand } from "./SecretSecretCommand";
33
34
  import { ValueCommand } from "./ValueCommand";
34
35
 
35
36
  let app = new Application("ns-cost", new BaseStorage(),
@@ -42,6 +43,7 @@ let app = new Application("ns-cost", new BaseStorage(),
42
43
  "billwatchgcp": BillWatchGCPCommand,
43
44
  "fieldcategory": FieldCategoryCommand,
44
45
  "fieldfield": FieldFieldCommand,
46
+ "secretsecret": SecretSecretCommand,
45
47
  "cost": CostCommand,
46
48
  "account": AccountCommand,
47
49
  "config": (argv: string[]) => new ConfigCommand(argv, ["ns-cost-server-url"])
@@ -0,0 +1,63 @@
1
+ import { EstimationOption } from "../type/EstimationOption";
2
+ import { BaseBonus } from "../bonus/BaseBonus";
3
+ import { Estimation } from "../type/Estimation";
4
+ import { PeriodUtil } from "../type/Period";
5
+
6
+ export abstract class BaseEstimator
7
+ {
8
+ async estimate(option: EstimationOption, calculate_bonus: boolean = true): Promise<Estimation[]>
9
+ {
10
+ let seconds = PeriodUtil.toSeconds(option.period);
11
+ let percent = seconds / 3600;
12
+ let fee_object = this.getFee();
13
+ let fee = option.active ? fee_object.active : fee_object.deactive;
14
+
15
+ let amount = percent * fee * option.value;
16
+ let currency = "USD";
17
+
18
+ let estimation: Estimation = {
19
+ option,
20
+ seconds,
21
+ usage: {
22
+ value: option.value,
23
+ ...this.getUsage()
24
+ },
25
+ fee,
26
+ amount,
27
+ currency,
28
+ free: undefined
29
+ };
30
+
31
+ let ans: Estimation[] = [];
32
+ if (calculate_bonus)
33
+ {
34
+ let bonuses = this.getBonues();
35
+ for (let bonus of bonuses)
36
+ {
37
+ let res = await bonus.isFree(option, estimation);
38
+ if (res.free)
39
+ {
40
+ if (res.split)
41
+ {
42
+ let estimation_free = await this.estimate(res.split.free, false);
43
+ estimation_free.forEach(e => { e.free = bonus; });
44
+ ans.push(...estimation_free);
45
+ for (let estimation_paid of res.split.paids)
46
+ ans.push(...await this.estimate(estimation_paid, false));
47
+ }
48
+ else
49
+ {
50
+ estimation.free = bonus;
51
+ ans.push(estimation);
52
+ }
53
+ break;
54
+ }
55
+ }
56
+ }
57
+
58
+ return ans;
59
+ }
60
+ abstract getFee(): { active: number, deactive: number };
61
+ abstract getUsage(): { name: string, unit: string };
62
+ abstract getBonues(): BaseBonus[];
63
+ }
@@ -0,0 +1,5 @@
1
+ import { BillWatchBaseHourlyEstimator } from "./BillWatchBaseHourlyEstimator";
2
+
3
+ export class BillWatchAWSHourlyEstimator extends BillWatchBaseHourlyEstimator
4
+ {
5
+ }
@@ -0,0 +1,5 @@
1
+ import { BillWatchBaseHourlyEstimator } from "./BillWatchBaseHourlyEstimator";
2
+
3
+ export class BillWatchAzureHourlyEstimator extends BillWatchBaseHourlyEstimator
4
+ {
5
+ }
@@ -0,0 +1,26 @@
1
+ import { DurationUnit, PriceOperation } from "namirasoft-core";
2
+ import { BaseEstimator } from "./BaseEstimator";
3
+ import { Usage } from "../type/Usage";
4
+ import { TrialBonus } from "../bonus/TrialBonus";
5
+
6
+ export abstract class BillWatchBaseHourlyEstimator extends BaseEstimator
7
+ {
8
+ static WATCH_PER_HOUR_ACTIVE = PriceOperation.cent_to_millicent(3);
9
+ override getFee()
10
+ {
11
+ return { active: BillWatchBaseHourlyEstimator.WATCH_PER_HOUR_ACTIVE, deactive: 0 };
12
+ }
13
+ override getUsage()
14
+ {
15
+ return {
16
+ name: Usage.Time.name,
17
+ unit: Usage.Time.units.Hour.name
18
+ };
19
+ }
20
+ override getBonues()
21
+ {
22
+ return [
23
+ new TrialBonus(1, DurationUnit.Week)
24
+ ];
25
+ }
26
+ }
@@ -0,0 +1,5 @@
1
+ import { BillWatchBaseHourlyEstimator } from "./BillWatchBaseHourlyEstimator";
2
+
3
+ export class BillWatchGCPHourlyEstimator extends BillWatchBaseHourlyEstimator
4
+ {
5
+ }
@@ -0,0 +1,21 @@
1
+ import { DurationUnit } from "namirasoft-core";
2
+ import { TrialBonus } from "../bonus/TrialBonus";
3
+ import { BaseEstimator } from "./BaseEstimator";
4
+ import { Usage } from "../type/Usage";
5
+
6
+ export abstract class FieldBaseHourlyEstimator extends BaseEstimator
7
+ {
8
+ override getBonues()
9
+ {
10
+ return [
11
+ new TrialBonus(1, DurationUnit.Week)
12
+ ];
13
+ }
14
+ override getUsage()
15
+ {
16
+ return {
17
+ name: Usage.Time.name,
18
+ unit: Usage.Time.units.Hour.name
19
+ };
20
+ }
21
+ }
@@ -0,0 +1,10 @@
1
+ import { FieldBaseHourlyEstimator } from "./FieldBaseHourlyEstimator";
2
+
3
+ export class FieldCategoryHourlyEstimator extends FieldBaseHourlyEstimator
4
+ {
5
+ static PER_HOUR_ACTIVE = 200;
6
+ override getFee()
7
+ {
8
+ return { active: FieldCategoryHourlyEstimator.PER_HOUR_ACTIVE, deactive: FieldCategoryHourlyEstimator.PER_HOUR_ACTIVE };
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ import { FieldBaseHourlyEstimator } from "./FieldBaseHourlyEstimator";
2
+
3
+ export class FieldFieldHourlyEstimator extends FieldBaseHourlyEstimator
4
+ {
5
+ static PER_HOUR_ACTIVE = 250;
6
+ override getFee()
7
+ {
8
+ return { active: FieldFieldHourlyEstimator.PER_HOUR_ACTIVE, deactive: FieldFieldHourlyEstimator.PER_HOUR_ACTIVE };
9
+ }
10
+ }
@@ -0,0 +1,25 @@
1
+ import { FreeCountBonus } from "../bonus/FreeCountBonus";
2
+ import { Usage } from "../type/Usage";
3
+ import { BaseEstimator } from "./BaseEstimator";
4
+
5
+ export class SecretSecretHourlyEstimator extends BaseEstimator
6
+ {
7
+ static PER_HOUR_ACTIVE = 2;
8
+ override getFee()
9
+ {
10
+ return { active: SecretSecretHourlyEstimator.PER_HOUR_ACTIVE, deactive: SecretSecretHourlyEstimator.PER_HOUR_ACTIVE };
11
+ }
12
+ override getUsage()
13
+ {
14
+ return {
15
+ name: Usage.Time.name,
16
+ unit: Usage.Time.units.Hour.name
17
+ };
18
+ }
19
+ override getBonues()
20
+ {
21
+ return [
22
+ new FreeCountBonus(100)
23
+ ];
24
+ }
25
+ }
@@ -0,0 +1,26 @@
1
+ import { FreeTotalValueBonus } from "../bonus/FreeTotalValueBonus";
2
+ import { Usage } from "../type/Usage";
3
+ import { BaseEstimator } from "./BaseEstimator";
4
+
5
+ export class SecretSecretReadEstimator extends BaseEstimator
6
+ {
7
+ static PER_CALL = 1;
8
+
9
+ override getFee()
10
+ {
11
+ return { active: SecretSecretReadEstimator.PER_CALL, deactive: SecretSecretReadEstimator.PER_CALL };
12
+ }
13
+ override getUsage()
14
+ {
15
+ return {
16
+ name: Usage.APICALL.name,
17
+ unit: Usage.APICALL.units.REQUEST.name
18
+ };
19
+ }
20
+ override getBonues()
21
+ {
22
+ return [
23
+ new FreeTotalValueBonus(1000)
24
+ ];
25
+ }
26
+ }
package/src/index.ts CHANGED
@@ -28,40 +28,41 @@ export * from "./NamirasoftCostServerFieldCategory";
28
28
  export * from "./NamirasoftCostServerFieldField";
29
29
  export * from "./NamirasoftCostServerHealthz";
30
30
  export * from "./NamirasoftCostServerMetrics";
31
+ export * from "./NamirasoftCostServerSecretSecret";
31
32
  export * from "./NamirasoftCostServerValue";
32
- export * from "./TimeUtil";
33
33
  export * from "./command/BillWatchAWSCommand";
34
- export * from "./command/BillWatchAWSEstimationCommand";
35
- export * from "./command/BillWatchAWS_CreateForCommand";
34
+ export * from "./command/BillWatchAWSEstimateHourlyCommand";
35
+ export * from "./command/BillWatchAWS_CreateForHourlyCommand";
36
36
  export * from "./command/BillWatchAzureCommand";
37
- export * from "./command/BillWatchAzureEstimationCommand";
38
- export * from "./command/BillWatchAzure_CreateForCommand";
37
+ export * from "./command/BillWatchAzureEstimateHourlyCommand";
38
+ export * from "./command/BillWatchAzure_CreateForHourlyCommand";
39
39
  export * from "./command/BillWatchGCPCommand";
40
- export * from "./command/BillWatchGCPEstimationCommand";
41
- export * from "./command/BillWatchGCP_CreateForCommand";
40
+ export * from "./command/BillWatchGCPEstimateHourlyCommand";
41
+ export * from "./command/BillWatchGCP_CreateForHourlyCommand";
42
42
  export * from "./command/CostCommand";
43
43
  export * from "./command/CostListCommand";
44
44
  export * from "./command/Cost_CreateForCommand";
45
45
  export * from "./command/FieldCategoryCommand";
46
- export * from "./command/FieldCategoryEstimationCommand";
47
- export * from "./command/FieldCategory_CreateForCommand";
46
+ export * from "./command/FieldCategoryEstimateHourlyCommand";
47
+ export * from "./command/FieldCategory_CreateForHourlyCommand";
48
48
  export * from "./command/FieldFieldCommand";
49
- export * from "./command/FieldFieldEstimationCommand";
50
- export * from "./command/FieldField_CreateForCommand";
49
+ export * from "./command/FieldFieldEstimateHourlyCommand";
50
+ export * from "./command/FieldField_CreateForHourlyCommand";
51
51
  export * from "./command/HealthzCommand";
52
52
  export * from "./command/HealthzGetCommand";
53
53
  export * from "./command/MetricsCommand";
54
54
  export * from "./command/MetricsGetCommand";
55
+ export * from "./command/SecretSecretCommand";
56
+ export * from "./command/SecretSecretEstimateHourlyCommand";
57
+ export * from "./command/SecretSecretEstimateReadCommand";
58
+ export * from "./command/SecretSecret_CreateForHourlyCommand";
59
+ export * from "./command/SecretSecret_CreateForReadCommand";
55
60
  export * from "./command/ValueCommand";
56
61
  export * from "./command/ValueListCommand";
57
- export * from "./enum/TrialUnit";
58
62
  export * from "./meta/CostMetaTable";
59
63
  export * from "./meta/NamirasoftCostMetaDatabase";
60
64
  export * from "./row/CostCreateRow";
61
65
  export * from "./row/CostRow";
62
66
  export * from "./type/Estimation";
63
- export * from "./type/EstimationRow";
64
67
  export * from "./type/EstimationUsage";
65
- export * from "./type/Period";
66
- export * from "./type/Trial";
67
- export * from "./type/TrialDuration";
68
+ export * from "./type/Period";
@@ -1,7 +1,14 @@
1
- import { EstimationRow } from "./EstimationRow";
1
+ import { BaseBonus } from "../bonus/BaseBonus";
2
+ import { EstimationOption } from "./EstimationOption";
3
+ import { EstimationUsage } from "./EstimationUsage";
2
4
 
3
5
  export type Estimation =
4
6
  {
5
- sum: number;
6
- rows: EstimationRow[];
7
+ option: EstimationOption;
8
+ seconds: number;
9
+ usage: EstimationUsage;
10
+ fee: number;
11
+ amount: number;
12
+ currency: string;
13
+ free?: BaseBonus;
7
14
  };
@@ -0,0 +1,12 @@
1
+ import { Period } from "./Period";
2
+
3
+ export interface EstimationOption
4
+ {
5
+ period: Period;
6
+ total_count: number;
7
+ number: number;
8
+ total_value: number;
9
+ value: number;
10
+ active: boolean;
11
+ trial_started_at: Date | null;
12
+ };
@@ -1,5 +1,74 @@
1
+ import { TimeOperation } from "namirasoft-core";
2
+
1
3
  export type Period =
2
4
  {
3
- start: Date;
4
- end: Date;
5
- };
5
+ year: number;
6
+ month: number;
7
+ day: number;
8
+ hour: number;
9
+ start: {
10
+ minute: number;
11
+ second: number;
12
+ };
13
+ end: {
14
+ minute: number;
15
+ second: number;
16
+ };
17
+ };
18
+
19
+ export class PeriodUtil
20
+ {
21
+ static toSeconds(period: Period)
22
+ {
23
+ return (period.end.minute * 60 + period.end.second) - (period.start.minute * 60 + period.start.second) + 1
24
+ }
25
+ static toDates(period: Period)
26
+ {
27
+ let start = new Date(period.year, period.month, period.day, period.hour, period.start.minute, period.start.second);
28
+ let end = new Date(period.year, period.month, period.day, period.hour, period.end.minute, period.end.second);
29
+ return { start, end };
30
+ }
31
+ static async loop(start: Date, end: Date, estimate_hour: (period: Period) => Promise<void>): Promise<void>
32
+ {
33
+ let pre_estimate_hour = async (start: Date, end: Date) =>
34
+ {
35
+ if (end <= start)
36
+ return;
37
+ return await estimate_hour({
38
+ year: start.getFullYear(),
39
+ month: start.getMonth(),
40
+ day: start.getDate(),
41
+ hour: start.getHours(),
42
+ start: {
43
+ minute: start.getMinutes(),
44
+ second: start.getSeconds(),
45
+ },
46
+ end: {
47
+ minute: end.getMinutes(),
48
+ second: end.getSeconds(),
49
+ }
50
+ });
51
+ }
52
+
53
+ let s = start;
54
+ let e = null;
55
+
56
+ do
57
+ {
58
+ let next_start = TimeOperation.hoursLater(1, s);
59
+ next_start.setMilliseconds(0);
60
+ next_start.setSeconds(0);
61
+ next_start.setMinutes(0);
62
+ if (end < next_start)
63
+ {
64
+ next_start = end;
65
+ e = end;
66
+ }
67
+ else
68
+ e = TimeOperation.secondsAgo(1, next_start);
69
+ await pre_estimate_hour(s, e);
70
+ s = next_start;
71
+ }
72
+ while (e < end)
73
+ }
74
+ };
@@ -0,0 +1,25 @@
1
+ export class Usage
2
+ {
3
+ static Time = {
4
+ name: "Time",
5
+ units: {
6
+ Second: {
7
+ name: "Second"
8
+ },
9
+ Minute: {
10
+ name: "Minute"
11
+ },
12
+ Hour: {
13
+ name: "Hour"
14
+ }
15
+ }
16
+ };
17
+ static APICALL = {
18
+ name: "API Call",
19
+ units: {
20
+ REQUEST: {
21
+ name: "Request"
22
+ }
23
+ }
24
+ };
25
+ };
@@ -1,7 +0,0 @@
1
- import { Trial } from "./type/Trial";
2
- import { Period } from "./type/Period";
3
- export declare class TimeUtil {
4
- static trialEndsAt(trial: Trial): Date;
5
- static isTrial(trial: Trial, date: Date): boolean;
6
- static loopHourly(trial: Trial | null, period: Period, estimate_hour: (period: Period, trial: boolean) => Promise<void>): Promise<void>;
7
- }