Skip to content

Commit 68a9fc6

Browse files
committed
feat: add subscription page configurations
1 parent c2509cd commit 68a9fc6

File tree

56 files changed

+5635
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+5635
-15
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
/libs/hashed-set/build
1111
/libs/hashed-set/node_modules
1212
/libs/hashed-set/dist
13+
/libs/subscription-page/build
14+
/libs/subscription-page/node_modules
15+
/libs/subscription-page/dist
1316
# Logs
1417
logs
1518
*.log

libs/contract/api/controllers-info.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,8 @@ export const CONTROLLERS_INFO = {
9898
tag: 'Remnawave Settings Controller',
9999
description: '',
100100
},
101+
SUBSCRIPTION_PAGE_CONFIGS: {
102+
tag: 'Subscription Page Configs Controller',
103+
description: '',
104+
},
101105
} as const;

libs/contract/api/controllers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export * from './passkeys';
1212
export * from './remnawave-settings';
1313
export * from './snippets';
1414
export * from './subscription';
15+
export * from './subscription-page-configs';
1516
export * from './subscription-request-history';
1617
export * from './subscription-settings';
1718
export * from './subscription-template';
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export const SUBSCRIPTION_PAGE_CONFIGS_CONTROLLER = 'subscription-page-configs' as const;
2+
3+
const ACTIONS_ROUTE = 'actions' as const;
4+
5+
export const SUBSCRIPTION_PAGE_CONFIGS_ROUTES = {
6+
GET_ALL: '', // get
7+
GET: (uuid: string) => `${uuid}`, // get
8+
UPDATE: '', // patch
9+
DELETE: (uuid: string) => `${uuid}`, // delete
10+
CREATE: '', // post
11+
12+
ACTIONS: {
13+
REORDER: `${ACTIONS_ROUTE}/reorder`,
14+
},
15+
} as const;

libs/contract/api/routes.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,4 +385,16 @@ export const REST_API = {
385385
GET: `${ROOT}/${CONTROLLERS.REMNAAWAVE_SETTINGS_CONTROLLER}/${CONTROLLERS.REMNAAWAVE_SETTINGS_ROUTES.GET}`,
386386
UPDATE: `${ROOT}/${CONTROLLERS.REMNAAWAVE_SETTINGS_CONTROLLER}/${CONTROLLERS.REMNAAWAVE_SETTINGS_ROUTES.UPDATE}`,
387387
},
388+
SUBSCRIPTION_PAGE_CONFIGS: {
389+
GET: (uuid: string) =>
390+
`${ROOT}/${CONTROLLERS.SUBSCRIPTION_PAGE_CONFIGS_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_PAGE_CONFIGS_ROUTES.GET(uuid)}`,
391+
GET_ALL: `${ROOT}/${CONTROLLERS.SUBSCRIPTION_PAGE_CONFIGS_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_PAGE_CONFIGS_ROUTES.GET_ALL}`,
392+
UPDATE: `${ROOT}/${CONTROLLERS.SUBSCRIPTION_PAGE_CONFIGS_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_PAGE_CONFIGS_ROUTES.UPDATE}`,
393+
DELETE: (uuid: string) =>
394+
`${ROOT}/${CONTROLLERS.SUBSCRIPTION_PAGE_CONFIGS_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_PAGE_CONFIGS_ROUTES.DELETE(uuid)}`,
395+
CREATE: `${ROOT}/${CONTROLLERS.SUBSCRIPTION_PAGE_CONFIGS_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_PAGE_CONFIGS_ROUTES.CREATE}`,
396+
ACTIONS: {
397+
REORDER: `${ROOT}/${CONTROLLERS.SUBSCRIPTION_PAGE_CONFIGS_CONTROLLER}/${CONTROLLERS.SUBSCRIPTION_PAGE_CONFIGS_ROUTES.ACTIONS.REORDER}`,
398+
},
399+
},
388400
} as const;

libs/contract/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export * from './passkeys';
1212
export * from './remnawave-settings';
1313
export * from './snippets';
1414
export * from './subscription';
15+
export * from './subscription-page-configs';
1516
export * from './subscription-request-history';
1617
export * from './subscription-settings';
1718
export * from './subscription-template';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './reorder.command';
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { z } from 'zod';
2+
3+
import { REST_API, SUBSCRIPTION_PAGE_CONFIGS_ROUTES } from '../../../api';
4+
import { SubscriptionPageConfigSchema } from '../../../models';
5+
import { getEndpointDetails } from '../../../constants';
6+
7+
export namespace ReorderSubscriptionPageConfigsCommand {
8+
export const url = REST_API.SUBSCRIPTION_PAGE_CONFIGS.ACTIONS.REORDER;
9+
export const TSQ_url = url;
10+
11+
export const endpointDetails = getEndpointDetails(
12+
SUBSCRIPTION_PAGE_CONFIGS_ROUTES.ACTIONS.REORDER,
13+
'post',
14+
'Reorder subscription page configs',
15+
);
16+
17+
export const RequestSchema = z.object({
18+
items: z.array(
19+
SubscriptionPageConfigSchema.pick({
20+
viewPosition: true,
21+
uuid: true,
22+
}),
23+
),
24+
});
25+
export type Request = z.infer<typeof RequestSchema>;
26+
27+
export const ResponseSchema = z.object({
28+
response: z.object({
29+
total: z.number(),
30+
configs: z.array(SubscriptionPageConfigSchema),
31+
}),
32+
});
33+
34+
export type Response = z.infer<typeof ResponseSchema>;
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { z } from 'zod';
2+
3+
import { REST_API, SUBSCRIPTION_PAGE_CONFIGS_ROUTES } from '../../api';
4+
import { SubscriptionPageConfigSchema } from '../../models';
5+
import { getEndpointDetails } from '../../constants';
6+
7+
export namespace CreateSubscriptionPageConfigCommand {
8+
export const url = REST_API.SUBSCRIPTION_PAGE_CONFIGS.CREATE;
9+
export const TSQ_url = url;
10+
11+
export const endpointDetails = getEndpointDetails(
12+
SUBSCRIPTION_PAGE_CONFIGS_ROUTES.CREATE,
13+
'post',
14+
'Create subscription page config',
15+
);
16+
17+
export const RequestSchema = z.object({
18+
name: z
19+
.string()
20+
.min(2, 'Name must be at least 2 characters')
21+
.max(30, 'Name must be less than 30 characters')
22+
.regex(
23+
/^[A-Za-z0-9_\s-]+$/,
24+
'Name can only contain letters, numbers, underscores, dashes and spaces',
25+
),
26+
});
27+
28+
export type Request = z.infer<typeof RequestSchema>;
29+
30+
export const ResponseSchema = z.object({
31+
response: SubscriptionPageConfigSchema,
32+
});
33+
34+
export type Response = z.infer<typeof ResponseSchema>;
35+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { z } from 'zod';
2+
3+
import { REST_API, SUBSCRIPTION_PAGE_CONFIGS_ROUTES } from '../../api';
4+
import { getEndpointDetails } from '../../constants';
5+
6+
export namespace DeleteSubscriptionPageConfigCommand {
7+
export const url = REST_API.SUBSCRIPTION_PAGE_CONFIGS.DELETE;
8+
export const TSQ_url = url(':uuid');
9+
10+
export const endpointDetails = getEndpointDetails(
11+
SUBSCRIPTION_PAGE_CONFIGS_ROUTES.DELETE(':uuid'),
12+
'delete',
13+
'Delete subscription page config',
14+
);
15+
16+
export const RequestSchema = z.object({
17+
uuid: z.string().uuid(),
18+
});
19+
20+
export type Request = z.infer<typeof RequestSchema>;
21+
22+
export const ResponseSchema = z.object({
23+
response: z.object({
24+
isDeleted: z.boolean(),
25+
}),
26+
});
27+
28+
export type Response = z.infer<typeof ResponseSchema>;
29+
}

0 commit comments

Comments
 (0)