@remnawave/backend-contract 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. package/api/controllers/api-tokens.ts +7 -0
  2. package/api/controllers/auth.ts +5 -0
  3. package/api/controllers/hosts.ts +9 -0
  4. package/api/controllers/inbounds.ts +5 -0
  5. package/api/controllers/index.ts +9 -0
  6. package/api/controllers/keygen.ts +5 -0
  7. package/api/controllers/nodes.ts +14 -0
  8. package/api/controllers/subscription.ts +6 -0
  9. package/api/controllers/users.ts +13 -0
  10. package/api/controllers/xray.ts +6 -0
  11. package/api/index.ts +2 -0
  12. package/api/routes.ts +73 -0
  13. package/build/api/controllers/api-tokens.js +9 -0
  14. package/build/api/controllers/auth.js +7 -0
  15. package/build/api/controllers/hosts.js +11 -0
  16. package/build/api/controllers/inbounds.js +7 -0
  17. package/build/api/controllers/index.js +25 -0
  18. package/build/api/controllers/keygen.js +7 -0
  19. package/build/api/controllers/nodes.js +15 -0
  20. package/build/api/controllers/subscription.js +8 -0
  21. package/build/api/controllers/users.js +15 -0
  22. package/build/api/controllers/xray.js +8 -0
  23. package/build/api/index.js +18 -0
  24. package/build/api/routes.js +81 -0
  25. package/build/commands/api-tokens/create.command.js +19 -0
  26. package/build/commands/api-tokens/delete.command.js +15 -0
  27. package/build/commands/api-tokens/find.command.js +13 -0
  28. package/build/commands/api-tokens/index.js +19 -0
  29. package/build/commands/auth/index.js +17 -0
  30. package/build/commands/auth/login.command.js +18 -0
  31. package/build/commands/hosts/create.command.js +50 -0
  32. package/build/commands/hosts/delete.command.js +17 -0
  33. package/build/commands/hosts/index.js +18 -0
  34. package/build/commands/inbounds/get-inbounds.command.js +13 -0
  35. package/build/commands/inbounds/index.js +17 -0
  36. package/build/commands/index.js +25 -0
  37. package/build/commands/keygen/get-pubkey.command.js +14 -0
  38. package/build/commands/keygen/index.js +17 -0
  39. package/build/commands/nodes/create.command.js +36 -0
  40. package/build/commands/nodes/delete.command.js +17 -0
  41. package/build/commands/nodes/disable.command.js +16 -0
  42. package/build/commands/nodes/enable.command.js +16 -0
  43. package/build/commands/nodes/get-all.command.js +13 -0
  44. package/build/commands/nodes/get-one.command.js +16 -0
  45. package/build/commands/nodes/index.js +25 -0
  46. package/build/commands/nodes/restart-all.command.js +14 -0
  47. package/build/commands/nodes/restart.command.js +17 -0
  48. package/build/commands/nodes/update.command.js +38 -0
  49. package/build/commands/subscription/get-subscription-by-short-uuid.command.js +12 -0
  50. package/build/commands/subscription/get-subscription-info-by-short-uuid.command.js +28 -0
  51. package/build/commands/subscription/index.js +18 -0
  52. package/build/commands/users/create-user.command.js +94 -0
  53. package/build/commands/users/delete-user.command.js +17 -0
  54. package/build/commands/users/disable-user.command.ts.js +16 -0
  55. package/build/commands/users/enable-user.command.js +16 -0
  56. package/build/commands/users/get-all-users.command.js +23 -0
  57. package/build/commands/users/get-user-by-short-uuid.command.js +16 -0
  58. package/build/commands/users/get-user-by-subscription-uuid.command.js +16 -0
  59. package/build/commands/users/get-user-by-uuid.command.js +16 -0
  60. package/build/commands/users/index.js +25 -0
  61. package/build/commands/users/revoke-user-subscription.command.js +16 -0
  62. package/build/commands/xray/get-config.command.js +14 -0
  63. package/build/commands/xray/index.js +17 -0
  64. package/build/constants/errors/errors.js +236 -0
  65. package/build/constants/errors/index.js +17 -0
  66. package/build/constants/hosts/alpn.js +9 -0
  67. package/build/constants/hosts/fingerprints.js +15 -0
  68. package/build/constants/hosts/index.js +18 -0
  69. package/build/constants/index.js +22 -0
  70. package/build/constants/nodes/cycle/cycle.js +8 -0
  71. package/build/constants/nodes/cycle/index.js +17 -0
  72. package/build/constants/nodes/index.js +18 -0
  73. package/build/constants/nodes/status/index.js +17 -0
  74. package/build/constants/nodes/status/status.constant.js +9 -0
  75. package/build/constants/roles/index.js +17 -0
  76. package/build/constants/roles/role.js +7 -0
  77. package/build/constants/templates/index.js +18 -0
  78. package/build/constants/templates/template-keys.js +4 -0
  79. package/build/constants/templates/user-statuses.js +9 -0
  80. package/build/constants/users/index.js +18 -0
  81. package/build/constants/users/reset-periods/index.js +17 -0
  82. package/build/constants/users/reset-periods/reset-periods.constant.js +11 -0
  83. package/build/constants/users/status/index.js +17 -0
  84. package/build/constants/users/status/status.constant.js +10 -0
  85. package/build/index.js +20 -0
  86. package/build/models/api-tokens.schema.js +12 -0
  87. package/build/models/auth.schema.js +7 -0
  88. package/build/models/hosts.schema.js +19 -0
  89. package/build/models/inbounds.schema.js +9 -0
  90. package/build/models/index.js +22 -0
  91. package/build/models/nodes.schema.js +28 -0
  92. package/build/models/users.schema.js +34 -0
  93. package/commands/api-tokens/create.command.ts +22 -0
  94. package/commands/api-tokens/delete.command.ts +18 -0
  95. package/commands/api-tokens/find.command.ts +13 -0
  96. package/commands/api-tokens/index.ts +3 -0
  97. package/commands/auth/index.ts +1 -0
  98. package/commands/auth/login.command.ts +20 -0
  99. package/commands/hosts/create.command.ts +52 -0
  100. package/commands/hosts/delete.command.ts +20 -0
  101. package/commands/hosts/index.ts +2 -0
  102. package/commands/inbounds/get-inbounds.command.ts +13 -0
  103. package/commands/inbounds/index.ts +1 -0
  104. package/commands/index.ts +9 -0
  105. package/commands/keygen/get-pubkey.command.ts +14 -0
  106. package/commands/keygen/index.ts +1 -0
  107. package/commands/nodes/create.command.ts +39 -0
  108. package/commands/nodes/delete.command.ts +20 -0
  109. package/commands/nodes/disable.command.ts +19 -0
  110. package/commands/nodes/enable.command.ts +19 -0
  111. package/commands/nodes/get-all.command.ts +13 -0
  112. package/commands/nodes/get-one.command.ts +19 -0
  113. package/commands/nodes/index.ts +9 -0
  114. package/commands/nodes/restart-all.command.ts +13 -0
  115. package/commands/nodes/restart.command.ts +20 -0
  116. package/commands/nodes/update.command.ts +41 -0
  117. package/commands/subscription/get-subscription-by-short-uuid.command.ts +12 -0
  118. package/commands/subscription/get-subscription-info-by-short-uuid.command.ts +31 -0
  119. package/commands/subscription/index.ts +2 -0
  120. package/commands/users/create-user.command.ts +103 -0
  121. package/commands/users/delete-user.command.ts +19 -0
  122. package/commands/users/disable-user.command.ts.ts +18 -0
  123. package/commands/users/enable-user.command.ts +19 -0
  124. package/commands/users/get-all-users.command.ts +26 -0
  125. package/commands/users/get-user-by-short-uuid.command.ts +19 -0
  126. package/commands/users/get-user-by-subscription-uuid.command.ts +19 -0
  127. package/commands/users/get-user-by-uuid.command.ts +19 -0
  128. package/commands/users/index.ts +9 -0
  129. package/commands/users/revoke-user-subscription.command.ts +19 -0
  130. package/commands/xray/get-config.command.ts +12 -0
  131. package/commands/xray/index.ts +1 -0
  132. package/constants/errors/errors.ts +233 -0
  133. package/constants/errors/index.ts +1 -0
  134. package/constants/hosts/alpn.ts +8 -0
  135. package/constants/hosts/fingerprints.ts +14 -0
  136. package/constants/hosts/index.ts +2 -0
  137. package/constants/index.ts +6 -0
  138. package/constants/nodes/cycle/cycle.ts +7 -0
  139. package/constants/nodes/cycle/index.ts +1 -0
  140. package/constants/nodes/index.ts +2 -0
  141. package/constants/nodes/status/index.ts +1 -0
  142. package/constants/nodes/status/status.constant.ts +8 -0
  143. package/constants/roles/index.ts +1 -0
  144. package/constants/roles/role.ts +7 -0
  145. package/constants/templates/index.ts +2 -0
  146. package/constants/templates/template-keys.ts +2 -0
  147. package/constants/templates/user-statuses.ts +6 -0
  148. package/constants/users/index.ts +2 -0
  149. package/constants/users/reset-periods/index.ts +1 -0
  150. package/constants/users/reset-periods/reset-periods.constant.ts +10 -0
  151. package/constants/users/status/index.ts +1 -0
  152. package/constants/users/status/status.constant.ts +9 -0
  153. package/index.ts +4 -0
  154. package/models/api-tokens.schema.ts +11 -0
  155. package/models/auth.schema.ts +5 -0
  156. package/models/hosts.schema.ts +17 -0
  157. package/models/inbounds.schema.ts +7 -0
  158. package/models/index.ts +6 -0
  159. package/models/nodes.schema.ts +28 -0
  160. package/models/users.schema.ts +38 -0
  161. package/package.json +16 -0
  162. package/tsconfig.json +103 -0
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./api-tokens"), exports);
18
+ __exportStar(require("./auth"), exports);
19
+ __exportStar(require("./hosts"), exports);
20
+ __exportStar(require("./inbounds"), exports);
21
+ __exportStar(require("./keygen"), exports);
22
+ __exportStar(require("./nodes"), exports);
23
+ __exportStar(require("./subscription"), exports);
24
+ __exportStar(require("./users"), exports);
25
+ __exportStar(require("./xray"), exports);
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetPubKeyCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ var GetPubKeyCommand;
7
+ (function (GetPubKeyCommand) {
8
+ GetPubKeyCommand.url = api_1.REST_API.KEYGEN.GET;
9
+ GetPubKeyCommand.ResponseSchema = zod_1.z.object({
10
+ response: zod_1.z.object({
11
+ pubKey: zod_1.z.string(),
12
+ }),
13
+ });
14
+ })(GetPubKeyCommand || (exports.GetPubKeyCommand = GetPubKeyCommand = {}));
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./get-pubkey.command"), exports);
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateNodeCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ const models_1 = require("../../models");
7
+ var CreateNodeCommand;
8
+ (function (CreateNodeCommand) {
9
+ CreateNodeCommand.url = api_1.REST_API.NODES.CREATE;
10
+ CreateNodeCommand.RequestSchema = models_1.NodesSchema.pick({}).extend({
11
+ name: zod_1.z.string().min(5, 'Name is required'),
12
+ address: zod_1.z.string().min(2, 'Address is required'),
13
+ port: zod_1.z.number().int().min(1, 'Port is required').optional(),
14
+ isTrafficTrackingActive: zod_1.z.boolean().optional().default(false),
15
+ trafficLimitBytes: zod_1.z
16
+ .number()
17
+ .int()
18
+ .min(0, 'Traffic limit must be greater than 0')
19
+ .optional(),
20
+ notifyPercent: zod_1.z
21
+ .number()
22
+ .int()
23
+ .min(0, 'Notify percent must be greater than 0')
24
+ .max(100, 'Notify percent must be less than 100')
25
+ .optional(),
26
+ trafficResetDay: zod_1.z
27
+ .number()
28
+ .int()
29
+ .min(1, 'Traffic reset day must be greater than 0')
30
+ .max(31, 'Traffic reset day must be less than 31')
31
+ .optional(),
32
+ });
33
+ CreateNodeCommand.ResponseSchema = zod_1.z.object({
34
+ response: models_1.NodesSchema,
35
+ });
36
+ })(CreateNodeCommand || (exports.CreateNodeCommand = CreateNodeCommand = {}));
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeleteNodeCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ var DeleteNodeCommand;
7
+ (function (DeleteNodeCommand) {
8
+ DeleteNodeCommand.url = api_1.REST_API.NODES.DELETE;
9
+ DeleteNodeCommand.RequestSchema = zod_1.z.object({
10
+ uuid: zod_1.z.string().uuid(),
11
+ });
12
+ DeleteNodeCommand.ResponseSchema = zod_1.z.object({
13
+ response: zod_1.z.object({
14
+ isDeleted: zod_1.z.boolean(),
15
+ }),
16
+ });
17
+ })(DeleteNodeCommand || (exports.DeleteNodeCommand = DeleteNodeCommand = {}));
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DisableNodeCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ const models_1 = require("../../models");
7
+ var DisableNodeCommand;
8
+ (function (DisableNodeCommand) {
9
+ DisableNodeCommand.url = api_1.REST_API.NODES.DISABLE;
10
+ DisableNodeCommand.RequestSchema = zod_1.z.object({
11
+ uuid: zod_1.z.string().uuid(),
12
+ });
13
+ DisableNodeCommand.ResponseSchema = zod_1.z.object({
14
+ response: models_1.NodesSchema,
15
+ });
16
+ })(DisableNodeCommand || (exports.DisableNodeCommand = DisableNodeCommand = {}));
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EnableNodeCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ const models_1 = require("../../models");
7
+ var EnableNodeCommand;
8
+ (function (EnableNodeCommand) {
9
+ EnableNodeCommand.url = api_1.REST_API.NODES.ENABLE;
10
+ EnableNodeCommand.RequestSchema = zod_1.z.object({
11
+ uuid: zod_1.z.string().uuid(),
12
+ });
13
+ EnableNodeCommand.ResponseSchema = zod_1.z.object({
14
+ response: models_1.NodesSchema,
15
+ });
16
+ })(EnableNodeCommand || (exports.EnableNodeCommand = EnableNodeCommand = {}));
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetAllNodesCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ const models_1 = require("../../models");
7
+ var GetAllNodesCommand;
8
+ (function (GetAllNodesCommand) {
9
+ GetAllNodesCommand.url = api_1.REST_API.NODES.GET_ALL;
10
+ GetAllNodesCommand.ResponseSchema = zod_1.z.object({
11
+ response: zod_1.z.array(models_1.NodesSchema),
12
+ });
13
+ })(GetAllNodesCommand || (exports.GetAllNodesCommand = GetAllNodesCommand = {}));
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetOneNodeCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ const models_1 = require("../../models");
7
+ var GetOneNodeCommand;
8
+ (function (GetOneNodeCommand) {
9
+ GetOneNodeCommand.url = api_1.REST_API.NODES.GET_ONE;
10
+ GetOneNodeCommand.RequestSchema = zod_1.z.object({
11
+ uuid: zod_1.z.string().uuid(),
12
+ });
13
+ GetOneNodeCommand.ResponseSchema = zod_1.z.object({
14
+ response: models_1.NodesSchema,
15
+ });
16
+ })(GetOneNodeCommand || (exports.GetOneNodeCommand = GetOneNodeCommand = {}));
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./create.command"), exports);
18
+ __exportStar(require("./delete.command"), exports);
19
+ __exportStar(require("./disable.command"), exports);
20
+ __exportStar(require("./enable.command"), exports);
21
+ __exportStar(require("./get-all.command"), exports);
22
+ __exportStar(require("./get-one.command"), exports);
23
+ __exportStar(require("./restart-all.command"), exports);
24
+ __exportStar(require("./restart.command"), exports);
25
+ __exportStar(require("./update.command"), exports);
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RestartAllNodesCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ var RestartAllNodesCommand;
7
+ (function (RestartAllNodesCommand) {
8
+ RestartAllNodesCommand.url = api_1.REST_API.NODES.RESTART_ALL;
9
+ RestartAllNodesCommand.ResponseSchema = zod_1.z.object({
10
+ response: zod_1.z.object({
11
+ eventSent: zod_1.z.boolean(),
12
+ }),
13
+ });
14
+ })(RestartAllNodesCommand || (exports.RestartAllNodesCommand = RestartAllNodesCommand = {}));
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RestartNodeCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ var RestartNodeCommand;
7
+ (function (RestartNodeCommand) {
8
+ RestartNodeCommand.url = api_1.REST_API.NODES.RESTART;
9
+ RestartNodeCommand.RequestSchema = zod_1.z.object({
10
+ uuid: zod_1.z.string().uuid(),
11
+ });
12
+ RestartNodeCommand.ResponseSchema = zod_1.z.object({
13
+ response: zod_1.z.object({
14
+ eventSent: zod_1.z.boolean(),
15
+ }),
16
+ });
17
+ })(RestartNodeCommand || (exports.RestartNodeCommand = RestartNodeCommand = {}));
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpdateNodeCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ const models_1 = require("../../models");
7
+ var UpdateNodeCommand;
8
+ (function (UpdateNodeCommand) {
9
+ UpdateNodeCommand.url = api_1.REST_API.NODES.UPDATE;
10
+ UpdateNodeCommand.RequestSchema = models_1.NodesSchema.pick({
11
+ uuid: true,
12
+ }).extend({
13
+ name: zod_1.z.string().min(5, 'Name is required').optional(),
14
+ address: zod_1.z.string().min(2, 'Address is required').optional(),
15
+ port: zod_1.z.number().int().min(1, 'Port is required').optional(),
16
+ isTrafficTrackingActive: zod_1.z.boolean().optional(),
17
+ trafficLimitBytes: zod_1.z
18
+ .number()
19
+ .int()
20
+ .min(0, 'Traffic limit must be greater than 0')
21
+ .optional(),
22
+ notifyPercent: zod_1.z
23
+ .number()
24
+ .int()
25
+ .min(0, 'Notify percent must be greater than 0')
26
+ .max(100, 'Notify percent must be less than 100')
27
+ .optional(),
28
+ trafficResetDay: zod_1.z
29
+ .number()
30
+ .int()
31
+ .min(1, 'Traffic reset day must be greater than 0')
32
+ .max(31, 'Traffic reset day must be less than 31')
33
+ .optional(),
34
+ });
35
+ UpdateNodeCommand.ResponseSchema = zod_1.z.object({
36
+ response: models_1.NodesSchema,
37
+ });
38
+ })(UpdateNodeCommand || (exports.UpdateNodeCommand = UpdateNodeCommand = {}));
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetSubscriptionByShortUuidCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ var GetSubscriptionByShortUuidCommand;
7
+ (function (GetSubscriptionByShortUuidCommand) {
8
+ GetSubscriptionByShortUuidCommand.url = api_1.REST_API.SUBSCRIPTION.GET;
9
+ GetSubscriptionByShortUuidCommand.RequestSchema = zod_1.z.object({
10
+ shortUuid: zod_1.z.string(),
11
+ });
12
+ })(GetSubscriptionByShortUuidCommand || (exports.GetSubscriptionByShortUuidCommand = GetSubscriptionByShortUuidCommand = {}));
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetSubscriptionInfoByShortUuidCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ const constants_1 = require("../../constants");
7
+ var GetSubscriptionInfoByShortUuidCommand;
8
+ (function (GetSubscriptionInfoByShortUuidCommand) {
9
+ GetSubscriptionInfoByShortUuidCommand.url = api_1.REST_API.SUBSCRIPTION.GET_INFO;
10
+ GetSubscriptionInfoByShortUuidCommand.RequestSchema = zod_1.z.object({
11
+ shortUuid: zod_1.z.string(),
12
+ });
13
+ GetSubscriptionInfoByShortUuidCommand.ResponseSchema = zod_1.z.object({
14
+ response: zod_1.z.object({
15
+ isFound: zod_1.z.boolean(),
16
+ user: zod_1.z.object({
17
+ shortUuid: zod_1.z.string(),
18
+ daysLeft: zod_1.z.number(),
19
+ trafficUsed: zod_1.z.string(),
20
+ trafficLimit: zod_1.z.string(),
21
+ username: zod_1.z.string(),
22
+ expiresAt: zod_1.z.date(),
23
+ isActive: zod_1.z.boolean(),
24
+ userStatus: zod_1.z.enum([constants_1.USERS_STATUS_VALUES[0], ...constants_1.USERS_STATUS_VALUES]),
25
+ }),
26
+ }),
27
+ });
28
+ })(GetSubscriptionInfoByShortUuidCommand || (exports.GetSubscriptionInfoByShortUuidCommand = GetSubscriptionInfoByShortUuidCommand = {}));
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./get-subscription-by-short-uuid.command"), exports);
18
+ __exportStar(require("./get-subscription-info-by-short-uuid.command"), exports);
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateUserCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ const constants_1 = require("../../constants");
7
+ const models_1 = require("../../models");
8
+ var CreateUserCommand;
9
+ (function (CreateUserCommand) {
10
+ CreateUserCommand.url = api_1.REST_API.USERS.CREATE;
11
+ CreateUserCommand.RequestSchema = models_1.UsersSchema.pick({}).extend({
12
+ username: zod_1.z
13
+ .string({
14
+ required_error: 'Username is required',
15
+ invalid_type_error: 'Username must be a string',
16
+ })
17
+ .regex(/^[a-zA-Z0-9_-]+$/, 'Username can only contain letters, numbers, underscores and dashes')
18
+ .max(32, 'Username must be less than 32 characters')
19
+ .min(6, 'Username must be at least 6 characters'),
20
+ status: models_1.UsersSchema.shape.status.optional().default(constants_1.USERS_STATUS.ACTIVE),
21
+ subscriptionUuid: zod_1.z
22
+ .string({
23
+ invalid_type_error: 'Subscription UUID must be a string',
24
+ })
25
+ .uuid('Invalid subscription UUID format')
26
+ .optional(),
27
+ shortUuid: zod_1.z
28
+ .string({
29
+ invalid_type_error: 'Short UUID must be a string',
30
+ })
31
+ .optional(),
32
+ trojanPassword: zod_1.z
33
+ .string({
34
+ invalid_type_error: 'Trojan password must be a string',
35
+ })
36
+ .min(8, 'Trojan password must be at least 8 characters')
37
+ .max(32, 'Trojan password must be less than 32 characters')
38
+ .optional(),
39
+ vlessUuid: zod_1.z
40
+ .string({
41
+ invalid_type_error: 'Vless UUID must be a string',
42
+ })
43
+ .uuid('Invalid Vless UUID format')
44
+ .optional(),
45
+ ssPassword: zod_1.z
46
+ .string({
47
+ invalid_type_error: 'SS password must be a string',
48
+ })
49
+ .min(8, 'SS password must be at least 8 characters')
50
+ .max(32, 'SS password must be less than 32 characters')
51
+ .optional(),
52
+ trafficLimitBytes: zod_1.z
53
+ .number({
54
+ invalid_type_error: 'Traffic limit must be a number',
55
+ })
56
+ .int('Traffic limit must be an integer')
57
+ .min(0, 'Traffic limit must be greater than 0')
58
+ .describe('Traffic limit in bytes. 0 - unlimited')
59
+ .optional(),
60
+ trafficLimitStrategy: models_1.UsersSchema.shape.trafficLimitStrategy
61
+ .describe('Traffic limit reset strategy')
62
+ .optional()
63
+ .default(constants_1.RESET_PERIODS.NO_RESET)
64
+ .superRefine((val, ctx) => {
65
+ if (val && !Object.values(constants_1.RESET_PERIODS).includes(val)) {
66
+ ctx.addIssue({
67
+ code: zod_1.z.ZodIssueCode.invalid_enum_value,
68
+ message: 'Invalid traffic limit strategy',
69
+ path: ['trafficLimitStrategy'],
70
+ received: val,
71
+ options: Object.values(constants_1.RESET_PERIODS),
72
+ });
73
+ }
74
+ }),
75
+ enabledInbounds: zod_1.z
76
+ .array(models_1.InboundsSchema.pick({
77
+ uuid: true,
78
+ }), {
79
+ invalid_type_error: 'Enabled inbounds must be an array',
80
+ })
81
+ .optional(),
82
+ expireAt: zod_1.z.coerce
83
+ .date({
84
+ required_error: 'Expiration date is required',
85
+ invalid_type_error: 'Invalid expiration date format',
86
+ })
87
+ .refine((date) => date > new Date(), {
88
+ message: 'Expiration date cannot be in the past',
89
+ }),
90
+ });
91
+ CreateUserCommand.ResponseSchema = zod_1.z.object({
92
+ response: models_1.UsersSchema,
93
+ });
94
+ })(CreateUserCommand || (exports.CreateUserCommand = CreateUserCommand = {}));
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeleteUserCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ var DeleteUserCommand;
7
+ (function (DeleteUserCommand) {
8
+ DeleteUserCommand.url = api_1.REST_API.USERS.DELETE_USER;
9
+ DeleteUserCommand.RequestSchema = zod_1.z.object({
10
+ uuid: zod_1.z.string().uuid(),
11
+ });
12
+ DeleteUserCommand.ResponseSchema = zod_1.z.object({
13
+ response: zod_1.z.object({
14
+ isDeleted: zod_1.z.boolean(),
15
+ }),
16
+ });
17
+ })(DeleteUserCommand || (exports.DeleteUserCommand = DeleteUserCommand = {}));
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DisableUserCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ const users_schema_1 = require("../../models/users.schema");
7
+ var DisableUserCommand;
8
+ (function (DisableUserCommand) {
9
+ DisableUserCommand.url = api_1.REST_API.USERS.DISABLE_USER;
10
+ DisableUserCommand.RequestSchema = zod_1.z.object({
11
+ uuid: zod_1.z.string().uuid(),
12
+ });
13
+ DisableUserCommand.ResponseSchema = zod_1.z.object({
14
+ response: users_schema_1.UsersSchema,
15
+ });
16
+ })(DisableUserCommand || (exports.DisableUserCommand = DisableUserCommand = {}));
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EnableUserCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ const users_schema_1 = require("../../models/users.schema");
7
+ var EnableUserCommand;
8
+ (function (EnableUserCommand) {
9
+ EnableUserCommand.url = api_1.REST_API.USERS.ENABLE_USER;
10
+ EnableUserCommand.RequestSchema = zod_1.z.object({
11
+ uuid: zod_1.z.string().uuid(),
12
+ });
13
+ EnableUserCommand.ResponseSchema = zod_1.z.object({
14
+ response: users_schema_1.UsersSchema,
15
+ });
16
+ })(EnableUserCommand || (exports.EnableUserCommand = EnableUserCommand = {}));
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetAllUsersCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ const users_schema_1 = require("../../models/users.schema");
7
+ var GetAllUsersCommand;
8
+ (function (GetAllUsersCommand) {
9
+ GetAllUsersCommand.url = api_1.REST_API.USERS.GET_ALL;
10
+ GetAllUsersCommand.RequestQuerySchema = zod_1.z.object({
11
+ limit: zod_1.z
12
+ .string()
13
+ .default('10')
14
+ .transform((val) => parseInt(val)),
15
+ offset: zod_1.z
16
+ .string()
17
+ .default('0')
18
+ .transform((val) => parseInt(val)),
19
+ });
20
+ GetAllUsersCommand.ResponseSchema = zod_1.z.object({
21
+ response: zod_1.z.array(users_schema_1.UsersSchema),
22
+ });
23
+ })(GetAllUsersCommand || (exports.GetAllUsersCommand = GetAllUsersCommand = {}));
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetUserByShortUuidCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ const users_schema_1 = require("../../models/users.schema");
7
+ var GetUserByShortUuidCommand;
8
+ (function (GetUserByShortUuidCommand) {
9
+ GetUserByShortUuidCommand.url = api_1.REST_API.USERS.GET_BY_SHORT_UUID;
10
+ GetUserByShortUuidCommand.RequestSchema = zod_1.z.object({
11
+ shortUuid: zod_1.z.string(),
12
+ });
13
+ GetUserByShortUuidCommand.ResponseSchema = zod_1.z.object({
14
+ response: users_schema_1.UsersSchema,
15
+ });
16
+ })(GetUserByShortUuidCommand || (exports.GetUserByShortUuidCommand = GetUserByShortUuidCommand = {}));
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetUserBySubscriptionUuidCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ const users_schema_1 = require("../../models/users.schema");
7
+ var GetUserBySubscriptionUuidCommand;
8
+ (function (GetUserBySubscriptionUuidCommand) {
9
+ GetUserBySubscriptionUuidCommand.url = api_1.REST_API.USERS.GET_BY_SUBSCRIPTION_UUID;
10
+ GetUserBySubscriptionUuidCommand.RequestSchema = zod_1.z.object({
11
+ subscriptionUuid: zod_1.z.string(),
12
+ });
13
+ GetUserBySubscriptionUuidCommand.ResponseSchema = zod_1.z.object({
14
+ response: users_schema_1.UsersSchema,
15
+ });
16
+ })(GetUserBySubscriptionUuidCommand || (exports.GetUserBySubscriptionUuidCommand = GetUserBySubscriptionUuidCommand = {}));
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetUserByUuidCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ const users_schema_1 = require("../../models/users.schema");
7
+ var GetUserByUuidCommand;
8
+ (function (GetUserByUuidCommand) {
9
+ GetUserByUuidCommand.url = api_1.REST_API.USERS.GET_BY_UUID;
10
+ GetUserByUuidCommand.RequestSchema = zod_1.z.object({
11
+ uuid: zod_1.z.string().uuid(),
12
+ });
13
+ GetUserByUuidCommand.ResponseSchema = zod_1.z.object({
14
+ response: users_schema_1.UsersSchema,
15
+ });
16
+ })(GetUserByUuidCommand || (exports.GetUserByUuidCommand = GetUserByUuidCommand = {}));
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./create-user.command"), exports);
18
+ __exportStar(require("./delete-user.command"), exports);
19
+ __exportStar(require("./disable-user.command.ts"), exports);
20
+ __exportStar(require("./enable-user.command"), exports);
21
+ __exportStar(require("./get-all-users.command"), exports);
22
+ __exportStar(require("./get-user-by-short-uuid.command"), exports);
23
+ __exportStar(require("./get-user-by-subscription-uuid.command"), exports);
24
+ __exportStar(require("./get-user-by-uuid.command"), exports);
25
+ __exportStar(require("./revoke-user-subscription.command"), exports);
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RevokeUserSubscriptionCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ const users_schema_1 = require("../../models/users.schema");
7
+ var RevokeUserSubscriptionCommand;
8
+ (function (RevokeUserSubscriptionCommand) {
9
+ RevokeUserSubscriptionCommand.url = api_1.REST_API.USERS.REVOKE_SUBSCRIPTION;
10
+ RevokeUserSubscriptionCommand.RequestSchema = zod_1.z.object({
11
+ uuid: zod_1.z.string().uuid(),
12
+ });
13
+ RevokeUserSubscriptionCommand.ResponseSchema = zod_1.z.object({
14
+ response: users_schema_1.UsersSchema,
15
+ });
16
+ })(RevokeUserSubscriptionCommand || (exports.RevokeUserSubscriptionCommand = RevokeUserSubscriptionCommand = {}));
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetXrayConfigCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const api_1 = require("../../api");
6
+ var GetXrayConfigCommand;
7
+ (function (GetXrayConfigCommand) {
8
+ GetXrayConfigCommand.url = api_1.REST_API.XRAY.GET_CONFIG;
9
+ GetXrayConfigCommand.ResponseSchema = zod_1.z.object({
10
+ response: zod_1.z.object({
11
+ config: zod_1.z.record(zod_1.z.any()),
12
+ }),
13
+ });
14
+ })(GetXrayConfigCommand || (exports.GetXrayConfigCommand = GetXrayConfigCommand = {}));
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./get-config.command"), exports);