@remnawave/backend-contract 2.1.75 → 2.1.77

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 (48) hide show
  1. package/build/backend/commands/subscription/get-subscription-by-short-uuid-by-client-type.command.d.ts +2 -3
  2. package/build/backend/commands/subscription/get-subscription-by-short-uuid-by-client-type.command.d.ts.map +1 -1
  3. package/build/backend/commands/subscription-settings/get-subscription-settings.command.d.ts +242 -0
  4. package/build/backend/commands/subscription-settings/get-subscription-settings.command.d.ts.map +1 -1
  5. package/build/backend/commands/subscription-settings/update-subscription-settings.command.d.ts +440 -0
  6. package/build/backend/commands/subscription-settings/update-subscription-settings.command.d.ts.map +1 -1
  7. package/build/backend/commands/subscription-settings/update-subscription-settings.command.js +2 -1
  8. package/build/backend/commands/subscription-template/get-template.command.d.ts +14 -14
  9. package/build/backend/commands/subscription-template/update-template.command.d.ts +14 -14
  10. package/build/backend/commands/subscriptions/get-by/get-raw-subscription-by-short-uuid.command.d.ts +4 -4
  11. package/build/backend/constants/response-rules/response-rules.contants.d.ts +38 -6
  12. package/build/backend/constants/response-rules/response-rules.contants.d.ts.map +1 -1
  13. package/build/backend/constants/response-rules/response-rules.contants.js +29 -3
  14. package/build/backend/constants/subscription-template/template-type/request-template-type.constant.d.ts +1 -2
  15. package/build/backend/constants/subscription-template/template-type/request-template-type.constant.d.ts.map +1 -1
  16. package/build/backend/constants/subscription-template/template-type/request-template-type.constant.js +0 -1
  17. package/build/backend/constants/subscription-template/template-type/template-type.constant.d.ts +5 -5
  18. package/build/backend/constants/subscription-template/template-type/template-type.constant.d.ts.map +1 -1
  19. package/build/backend/constants/subscription-template/template-type/template-type.constant.js +4 -4
  20. package/build/backend/models/response-rules/index.d.ts +1 -1
  21. package/build/backend/models/response-rules/index.d.ts.map +1 -1
  22. package/build/backend/models/response-rules/index.js +1 -1
  23. package/build/backend/models/response-rules/response-rule-condition.schema.d.ts +29 -0
  24. package/build/backend/models/response-rules/response-rule-condition.schema.d.ts.map +1 -0
  25. package/build/backend/models/response-rules/response-rule-condition.schema.js +29 -0
  26. package/build/backend/models/response-rules/response-rule.schema.d.ts +53 -12
  27. package/build/backend/models/response-rules/response-rule.schema.d.ts.map +1 -1
  28. package/build/backend/models/response-rules/response-rule.schema.js +101 -19
  29. package/build/backend/models/response-rules/response-rules-config.schema.d.ts +73 -16
  30. package/build/backend/models/response-rules/response-rules-config.schema.d.ts.map +1 -1
  31. package/build/backend/models/response-rules/response-rules-config.schema.js +44 -3
  32. package/build/backend/models/subscription-settings.schema.d.ts +198 -0
  33. package/build/backend/models/subscription-settings.schema.d.ts.map +1 -1
  34. package/build/backend/models/subscription-settings.schema.js +2 -0
  35. package/build/frontend/commands/subscription-settings/update-subscription-settings.command.js +2 -1
  36. package/build/frontend/constants/response-rules/response-rules.contants.js +29 -2
  37. package/build/frontend/constants/subscription-template/template-type/request-template-type.constant.js +0 -1
  38. package/build/frontend/constants/subscription-template/template-type/template-type.constant.js +4 -4
  39. package/build/frontend/models/response-rules/index.js +1 -1
  40. package/build/frontend/models/response-rules/response-rule-condition.schema.js +29 -0
  41. package/build/frontend/models/response-rules/response-rule.schema.js +101 -19
  42. package/build/frontend/models/response-rules/response-rules-config.schema.js +44 -3
  43. package/build/frontend/models/subscription-settings.schema.js +2 -0
  44. package/package.json +1 -1
  45. package/build/backend/models/response-rules/response-rules-json-schema.d.ts +0 -7
  46. package/build/backend/models/response-rules/response-rules-json-schema.d.ts.map +0 -1
  47. package/build/backend/models/response-rules/response-rules-json-schema.js +0 -11
  48. package/build/frontend/models/response-rules/response-rules-json-schema.js +0 -11
@@ -4,7 +4,6 @@ exports.REQUEST_TEMPLATE_TYPE_VALUES = exports.REQUEST_TEMPLATE_TYPE = void 0;
4
4
  exports.REQUEST_TEMPLATE_TYPE = {
5
5
  STASH: 'stash',
6
6
  SINGBOX: 'singbox',
7
- SINGBOX_LEGACY: 'singbox-legacy',
8
7
  MIHOMO: 'mihomo',
9
8
  XRAY_JSON: 'json',
10
9
  V2RAY_JSON: 'v2ray-json',
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SUBSCRIPTION_TEMPLATE_TYPE_VALUES = exports.SUBSCRIPTION_TEMPLATE_TYPE = void 0;
4
4
  exports.SUBSCRIPTION_TEMPLATE_TYPE = {
5
- STASH: 'STASH',
6
- SINGBOX: 'SINGBOX',
7
- SINGBOX_LEGACY: 'SINGBOX_LEGACY',
8
- MIHOMO: 'MIHOMO',
9
5
  XRAY_JSON: 'XRAY_JSON',
6
+ XRAY_BASE64: 'XRAY_BASE64',
7
+ MIHOMO: 'MIHOMO',
8
+ STASH: 'STASH',
10
9
  CLASH: 'CLASH',
10
+ SINGBOX: 'SINGBOX',
11
11
  };
12
12
  exports.SUBSCRIPTION_TEMPLATE_TYPE_VALUES = Object.values(exports.SUBSCRIPTION_TEMPLATE_TYPE);
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./response-rule-condition.schema"), exports);
17
18
  __exportStar(require("./response-rule.schema"), exports);
18
19
  __exportStar(require("./response-rules-config.schema"), exports);
19
- __exportStar(require("./response-rules-json-schema"), exports);
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ResponseRuleConditionSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const constants_1 = require("../../constants");
6
+ exports.ResponseRuleConditionSchema = zod_1.z.object({
7
+ headerName: zod_1.z
8
+ .string()
9
+ .regex(/^[!#$%&'*+\-.0-9A-Z^_`a-z|~]+$/, 'Invalid header name. Only letters(a-z, A-Z), numbers(0-9), underscores(_) and hyphens(-) are allowed.')
10
+ .describe(JSON.stringify({
11
+ title: 'Header Name',
12
+ markdownDescription: 'Name of the HTTP header to check, case insensitive, must comply with RFC 7230.',
13
+ })),
14
+ operator: zod_1.z.nativeEnum(constants_1.RESPONSE_RULES_CONDITION_OPERATORS).describe(JSON.stringify({
15
+ markdownDescription: `Comparison operator to compare the header value against.\n\n${Object.entries(constants_1.RESPONSE_RULES_CONDITION_OPERATORS_DESCRIPTION)
16
+ .map(([key, description]) => `- **${key}**: ${description}\n`)
17
+ .join('\n')}`,
18
+ })),
19
+ value: zod_1.z
20
+ .string()
21
+ .min(1, 'Value is required')
22
+ .max(255, 'Value must be less than 255 characters')
23
+ .describe(JSON.stringify({
24
+ markdownDescription: `Value to check against the header, case sensitive (excluding regex/not_regex operator). Maximum length is 255 characters.`,
25
+ })),
26
+ caseSensitive: zod_1.z.boolean().describe(JSON.stringify({
27
+ markdownDescription: 'Whether the value is case sensitive. If true, the value will be compared case sensitive. If false, the value will be lowercased before comparison.',
28
+ })),
29
+ });
@@ -3,27 +3,109 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ResponseRuleSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const constants_1 = require("../../constants");
6
- exports.ResponseRuleSchema = zod_1.z.object({
7
- name: zod_1.z.string().min(1, 'Name is required').max(50, 'Name must be less than 50 characters'),
6
+ const response_rule_condition_schema_1 = require("./response-rule-condition.schema");
7
+ const RuleExampleJson = JSON.stringify({
8
+ name: 'Block Legacy Clients',
9
+ description: 'Block requests from legacy clients',
10
+ enabled: true,
11
+ operator: constants_1.RESPONSE_RULES_OPERATORS.OR,
12
+ conditions: [
13
+ {
14
+ headerName: 'user-agent',
15
+ operator: constants_1.RESPONSE_RULES_CONDITION_OPERATORS.CONTAINS,
16
+ value: 'Hiddify',
17
+ caseSensitive: true,
18
+ },
19
+ {
20
+ headerName: 'user-agent',
21
+ operator: constants_1.RESPONSE_RULES_CONDITION_OPERATORS.CONTAINS,
22
+ value: 'FoxRay',
23
+ caseSensitive: true,
24
+ },
25
+ ],
26
+ responseType: constants_1.RESPONSE_RULES_RESPONSE_TYPES.BLOCK,
27
+ }, null, 2);
28
+ exports.ResponseRuleSchema = zod_1.z
29
+ .object({
30
+ name: zod_1.z
31
+ .string()
32
+ .min(1, 'Name is required')
33
+ .max(50, 'Name must be less than 50 characters')
34
+ .describe(JSON.stringify({
35
+ title: 'Name',
36
+ markdownDescription: 'Name of the response rule.',
37
+ })),
8
38
  description: zod_1.z
9
39
  .string()
10
40
  .min(1, 'Description is required')
11
41
  .max(250, 'Description must be less than 250 characters')
12
- .optional(),
13
- operator: zod_1.z.nativeEnum(constants_1.RESPONSE_RULES_OPERATORS).describe('Operator to use for the rule.'),
14
- conditions: zod_1.z.array(zod_1.z.object({
15
- headerName: zod_1.z
16
- .string()
17
- .regex(/^[!#$%&'*+\-.0-9A-Z^_`a-z|~]+$/, 'Invalid header name. Only letters(a-z, A-Z), numbers(0-9), underscores(_) and hyphens(-) are allowed.')
18
- .describe('Name of the HTTP header to check, case insensitive, must comply with RFC 7230.'),
19
- operator: zod_1.z
20
- .nativeEnum(constants_1.RESPONSE_RULES_CONDITION_OPERATORS)
21
- .describe('Operator to use for the condition.'),
22
- value: zod_1.z
23
- .string()
24
- .min(1, 'Value is required')
25
- .max(255, 'Value must be less than 255 characters')
26
- .describe('Value to check against the header, case sensitive.'),
42
+ .optional()
43
+ .describe(JSON.stringify({
44
+ title: 'Description',
45
+ markdownDescription: 'Description of the response rule. Maximum length is 250 characters.',
46
+ })),
47
+ enabled: zod_1.z.boolean().describe(JSON.stringify({
48
+ markdownDescription: 'Whether the response rule is enabled. If disabled, the rule will not be applied.',
49
+ })),
50
+ operator: zod_1.z.nativeEnum(constants_1.RESPONSE_RULES_OPERATORS).describe(JSON.stringify({
51
+ title: 'Operator',
52
+ markdownDescription: 'Operator to use for combining conditions in the rule.',
53
+ })),
54
+ conditions: zod_1.z.array(response_rule_condition_schema_1.ResponseRuleConditionSchema),
55
+ responseType: zod_1.z.nativeEnum(constants_1.RESPONSE_RULES_RESPONSE_TYPES).describe(JSON.stringify({
56
+ markdownDescription: `Type of the response. Determines the type of **response** to be returned when the rule is matched.\n\n${Object.entries(constants_1.RESPONSE_RULES_RESPONSE_TYPES_DESCRIPTION)
57
+ .map(([key, description]) => `- **${key}**: ${description}\n`)
58
+ .join('\n')}`,
27
59
  })),
28
- responseType: zod_1.z.nativeEnum(constants_1.RESPONSE_RULES_RESPONSE_TYPES).describe('Type of the response.'),
29
- });
60
+ responseModifications: zod_1.z.object({
61
+ headers: zod_1.z
62
+ .array(zod_1.z.object({
63
+ key: zod_1.z
64
+ .string()
65
+ .regex(/^[!#$%&'*+\-.0-9A-Z^_`a-z|~]+$/, 'Invalid header name. Only letters(a-z, A-Z), numbers(0-9), underscores(_) and hyphens(-) are allowed.')
66
+ .describe(JSON.stringify({
67
+ title: 'Key',
68
+ markdownDescription: 'Key of the response header. Must comply with RFC 7230.',
69
+ })),
70
+ value: zod_1.z
71
+ .string()
72
+ .min(1, 'Value is required')
73
+ .describe(JSON.stringify({
74
+ title: 'Value',
75
+ markdownDescription: 'Value of the response header. ',
76
+ })),
77
+ }))
78
+ .optional()
79
+ .describe(JSON.stringify({
80
+ markdownDescription: 'Response headers to be added when the rule is matched.',
81
+ })),
82
+ }),
83
+ })
84
+ .describe(JSON.stringify({
85
+ title: 'Response Rule',
86
+ markdownDescription: `\n\nFields:\n- **name**: Name of the response rule (required)\n- **description**: Description of the response rule (optional)\n- **enabled**: Whether the response rule is enabled. If disabled, the rule will not be applied.\n- **operator**: Operator to combine conditions (AND/OR)\n- **conditions**: Array of conditions to match against HTTP headers\n - **headerName**: Name of the HTTP header to check (case insensitive)\n - **operator**: Comparison operator (CONTAINS, EQUALS, etc)\n - **value**: Value to compare against (case sensitive, max 255 chars)\n- **responseType**: Type of response when rule matches (e.g. BLOCK)\n\nExample:\n\`\`\`json\n${RuleExampleJson}\n\`\`\``,
87
+ examples: [
88
+ {
89
+ name: 'This is example rule name',
90
+ description: 'This is example rule description (optional)',
91
+ enabled: true,
92
+ operator: constants_1.RESPONSE_RULES_OPERATORS.AND,
93
+ conditions: [
94
+ {
95
+ headerName: 'user-agent',
96
+ operator: constants_1.RESPONSE_RULES_CONDITION_OPERATORS.CONTAINS,
97
+ value: 'Example Rule Value, replace with your own value',
98
+ caseSensitive: true,
99
+ },
100
+ ],
101
+ responseType: constants_1.RESPONSE_RULES_RESPONSE_TYPES.BLOCK,
102
+ },
103
+ {
104
+ name: 'Empty rule',
105
+ enabled: true,
106
+ operator: constants_1.RESPONSE_RULES_OPERATORS.AND,
107
+ conditions: [],
108
+ responseType: constants_1.RESPONSE_RULES_RESPONSE_TYPES.BLOCK,
109
+ },
110
+ ],
111
+ }));
@@ -4,11 +4,52 @@ exports.ResponseRulesConfigSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const constants_1 = require("../../constants");
6
6
  const response_rule_schema_1 = require("./response-rule.schema");
7
+ const RuleExampleJson = JSON.stringify({
8
+ name: 'Block Legacy Clients',
9
+ description: 'Block requests from legacy clients',
10
+ operator: constants_1.RESPONSE_RULES_OPERATORS.OR,
11
+ enabled: true,
12
+ conditions: [
13
+ {
14
+ headerName: 'user-agent',
15
+ operator: constants_1.RESPONSE_RULES_CONDITION_OPERATORS.CONTAINS,
16
+ value: 'Hiddify',
17
+ caseSensitive: true,
18
+ },
19
+ {
20
+ headerName: 'user-agent',
21
+ operator: constants_1.RESPONSE_RULES_CONDITION_OPERATORS.CONTAINS,
22
+ value: 'FoxRay',
23
+ caseSensitive: true,
24
+ },
25
+ ],
26
+ responseType: constants_1.RESPONSE_RULES_RESPONSE_TYPES.BLOCK,
27
+ }, null, 2);
7
28
  exports.ResponseRulesConfigSchema = zod_1.z.object({
8
29
  version: zod_1.z.nativeEnum(constants_1.RESPONSE_RULES_CONFIG_VERSION).describe(JSON.stringify({
9
30
  title: 'Response Rules Config Version',
10
- description: 'Version of the response rules config.',
11
- examples: [constants_1.RESPONSE_RULES_CONFIG_VERSION[1]],
31
+ markdownDescription: 'Version of the **response rules** config. Currently supported version is **1**.',
32
+ })),
33
+ rules: zod_1.z.array(response_rule_schema_1.ResponseRuleSchema).describe(JSON.stringify({
34
+ examples: [
35
+ [
36
+ {
37
+ name: 'This is example rule name',
38
+ description: 'This is example rule description (optional)',
39
+ operator: constants_1.RESPONSE_RULES_OPERATORS.AND,
40
+ enabled: true,
41
+ conditions: [
42
+ {
43
+ headerName: 'user-agent',
44
+ operator: constants_1.RESPONSE_RULES_CONDITION_OPERATORS.CONTAINS,
45
+ value: 'Example Rule Value, replace with your own value',
46
+ caseSensitive: true,
47
+ },
48
+ ],
49
+ responseType: constants_1.RESPONSE_RULES_RESPONSE_TYPES.BLOCK,
50
+ },
51
+ ],
52
+ ],
53
+ markdownDescription: `Array of **response rules**.\n\nRules served from top to bottom – first matched rule is applied. Each rule is an object with the following properties:\n\n- **name**: Name of the response rule.\n- **description**: Description of the response rule.(Optional) \n- **enabled**: Whether the response rule is enabled. If disabled, the rule will not be applied.\n- **operator**: Operator to use for the rule.\n- **conditions**: Array of conditions to use for the rule.\n- **responseType**: Type of the response.\n\nExamples:\n\n1. Block legacy clients:\n\n\`\`\`json\n${RuleExampleJson}\n\`\`\`\n\nThis example shows how to block requests from legacy clients by checking if the User-Agent header contains "Hiddify" or "FoxRay".`,
12
54
  })),
13
- rules: zod_1.z.array(response_rule_schema_1.ResponseRuleSchema),
14
55
  });
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SubscriptionSettingsSchema = void 0;
4
4
  const zod_1 = require("zod");
5
+ const response_rules_1 = require("./response-rules");
5
6
  exports.SubscriptionSettingsSchema = zod_1.z.object({
6
7
  uuid: zod_1.z.string().uuid(),
7
8
  profileTitle: zod_1.z.string(),
@@ -21,6 +22,7 @@ exports.SubscriptionSettingsSchema = zod_1.z.object({
21
22
  disabledUsersRemarks: zod_1.z.array(zod_1.z.string()),
22
23
  customResponseHeaders: zod_1.z.nullable(zod_1.z.record(zod_1.z.string(), zod_1.z.string())),
23
24
  randomizeHosts: zod_1.z.boolean(),
25
+ responseRules: zod_1.z.nullable(response_rules_1.ResponseRulesConfigSchema),
24
26
  createdAt: zod_1.z
25
27
  .string()
26
28
  .datetime()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remnawave/backend-contract",
3
- "version": "2.1.75",
3
+ "version": "2.1.77",
4
4
  "public": true,
5
5
  "license": "AGPL-3.0-only",
6
6
  "description": "A contract library for Remnawave Backend. It can be used in backend and frontend.",
@@ -1,7 +0,0 @@
1
- export declare const ResponseRulesJsonSchema: import("zod-to-json-schema").JsonSchema7Type & {
2
- $schema?: string | undefined;
3
- definitions?: {
4
- [key: string]: import("zod-to-json-schema").JsonSchema7Type;
5
- } | undefined;
6
- };
7
- //# sourceMappingURL=response-rules-json-schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"response-rules-json-schema.d.ts","sourceRoot":"","sources":["../../../../models/response-rules/response-rules-json-schema.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,uBAAuB;;;;;CAKlC,CAAC"}
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ResponseRulesJsonSchema = void 0;
4
- const zod_to_json_schema_1 = require("zod-to-json-schema");
5
- const _1 = require(".");
6
- exports.ResponseRulesJsonSchema = (0, zod_to_json_schema_1.zodToJsonSchema)(_1.ResponseRulesConfigSchema, {
7
- name: 'Response Rules Config Schema',
8
- $refStrategy: 'none',
9
- errorMessages: true,
10
- markdownDescription: true,
11
- });
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ResponseRulesJsonSchema = void 0;
4
- const zod_to_json_schema_1 = require("zod-to-json-schema");
5
- const _1 = require(".");
6
- exports.ResponseRulesJsonSchema = (0, zod_to_json_schema_1.zodToJsonSchema)(_1.ResponseRulesConfigSchema, {
7
- name: 'Response Rules Config Schema',
8
- $refStrategy: 'none',
9
- errorMessages: true,
10
- markdownDescription: true,
11
- });