@remnawave/subscription-page-types 0.0.1
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.
- package/build/backend/constants/index.d.ts +2 -0
- package/build/backend/constants/index.d.ts.map +1 -0
- package/build/backend/constants/index.js +17 -0
- package/build/backend/constants/subscription-page-config/index.d.ts +3 -0
- package/build/backend/constants/subscription-page-config/index.d.ts.map +1 -0
- package/build/backend/constants/subscription-page-config/index.js +18 -0
- package/build/backend/constants/subscription-page-config/subscription-page-config.contants.d.ts +15 -0
- package/build/backend/constants/subscription-page-config/subscription-page-config.contants.d.ts.map +1 -0
- package/build/backend/constants/subscription-page-config/subscription-page-config.contants.js +16 -0
- package/build/backend/constants/subscription-page-config/subscription-page-template-keys.contant.d.ts +3 -0
- package/build/backend/constants/subscription-page-config/subscription-page-template-keys.contant.d.ts.map +1 -0
- package/build/backend/constants/subscription-page-config/subscription-page-template-keys.contant.js +4 -0
- package/build/backend/index.d.ts +3 -0
- package/build/backend/index.d.ts.map +1 -0
- package/build/backend/index.js +18 -0
- package/build/backend/models/index.d.ts +2 -0
- package/build/backend/models/index.d.ts.map +1 -0
- package/build/backend/models/index.js +17 -0
- package/build/backend/models/subscription-page-config/index.d.ts +2 -0
- package/build/backend/models/subscription-page-config/index.d.ts.map +1 -0
- package/build/backend/models/subscription-page-config/index.js +17 -0
- package/build/backend/models/subscription-page-config/subscription-page-config.schema.d.ts +1682 -0
- package/build/backend/models/subscription-page-config/subscription-page-config.schema.d.ts.map +1 -0
- package/build/backend/models/subscription-page-config/subscription-page-config.schema.js +82 -0
- package/build/backend/models/subscription-page-config/subscription-page-config.validator.d.ts +4 -0
- package/build/backend/models/subscription-page-config/subscription-page-config.validator.d.ts.map +1 -0
- package/build/backend/models/subscription-page-config/subscription-page-config.validator.js +32 -0
- package/build/frontend/constants/index.js +17 -0
- package/build/frontend/constants/subscription-page-config/index.js +18 -0
- package/build/frontend/constants/subscription-page-config/subscription-page-config.contants.js +16 -0
- package/build/frontend/constants/subscription-page-config/subscription-page-template-keys.contant.js +4 -0
- package/build/frontend/index.js +18 -0
- package/build/frontend/models/index.js +17 -0
- package/build/frontend/models/subscription-page-config/index.js +17 -0
- package/build/frontend/models/subscription-page-config/subscription-page-config.schema.js +82 -0
- package/build/frontend/models/subscription-page-config/subscription-page-config.validator.js +32 -0
- package/package.json +33 -0
package/build/backend/models/subscription-page-config/subscription-page-config.schema.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription-page-config.schema.d.ts","sourceRoot":"","sources":["../../../../models/subscription-page-config/subscription-page-config.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;EAM9B,CAAC;AAEH,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKhB,CAAC;AAEH,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8Bf,CAAC;AAEH,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIrB,CAAC;AAEH,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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scriptionPageRawConfigSchema = exports.LocalizedTextSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
const subscription_page_config_validator_1 = require("./subscription-page-config.validator");
|
|
7
|
+
exports.LocalizedTextSchema = zod_1.z.object({
|
|
8
|
+
en: zod_1.z.string(),
|
|
9
|
+
ru: zod_1.z.string().optional(),
|
|
10
|
+
zh: zod_1.z.string().optional(),
|
|
11
|
+
fa: zod_1.z.string().optional(),
|
|
12
|
+
fr: zod_1.z.string().optional(),
|
|
13
|
+
});
|
|
14
|
+
const ButtonSchema = zod_1.z.object({
|
|
15
|
+
link: zod_1.z.string(),
|
|
16
|
+
type: zod_1.z.enum(['external', 'subscriptionLink']),
|
|
17
|
+
text: exports.LocalizedTextSchema,
|
|
18
|
+
svgIcon: zod_1.z.string(),
|
|
19
|
+
});
|
|
20
|
+
const BlockSchema = zod_1.z.object({
|
|
21
|
+
svgIcon: zod_1.z.string(),
|
|
22
|
+
svgIconColor: zod_1.z
|
|
23
|
+
.string()
|
|
24
|
+
.refine((value) => [
|
|
25
|
+
'blue',
|
|
26
|
+
'cyan',
|
|
27
|
+
'dark',
|
|
28
|
+
'grape',
|
|
29
|
+
'gray',
|
|
30
|
+
'green',
|
|
31
|
+
'indigo',
|
|
32
|
+
'lime',
|
|
33
|
+
'orange',
|
|
34
|
+
'pink',
|
|
35
|
+
'red',
|
|
36
|
+
'teal',
|
|
37
|
+
'violet',
|
|
38
|
+
'yellow',
|
|
39
|
+
].includes(value) || /^#[0-9a-fA-F]{3,8}$/.test(value), {
|
|
40
|
+
message: 'svgIconColor must be one of the predefined colors or a hex color beginning with #',
|
|
41
|
+
}),
|
|
42
|
+
title: exports.LocalizedTextSchema,
|
|
43
|
+
description: exports.LocalizedTextSchema,
|
|
44
|
+
buttons: zod_1.z.array(ButtonSchema),
|
|
45
|
+
});
|
|
46
|
+
const PlatformAppSchema = zod_1.z.object({
|
|
47
|
+
name: zod_1.z.string(),
|
|
48
|
+
featured: zod_1.z.boolean(),
|
|
49
|
+
blocks: zod_1.z.array(BlockSchema),
|
|
50
|
+
});
|
|
51
|
+
const PlatformSchema = zod_1.z.object({
|
|
52
|
+
displayName: exports.LocalizedTextSchema,
|
|
53
|
+
svgIcon: zod_1.z.string(),
|
|
54
|
+
apps: zod_1.z.array(PlatformAppSchema),
|
|
55
|
+
});
|
|
56
|
+
const BrandingSettingsSchema = zod_1.z.object({
|
|
57
|
+
title: zod_1.z.string(),
|
|
58
|
+
logoUrl: zod_1.z.string(),
|
|
59
|
+
supportUrl: zod_1.z.string().url(),
|
|
60
|
+
});
|
|
61
|
+
const UiConfigSchema = zod_1.z.object({
|
|
62
|
+
subscriptionInfo: zod_1.z.object({
|
|
63
|
+
block: zod_1.z.enum(['collapsed', 'expanded']),
|
|
64
|
+
}),
|
|
65
|
+
installationGuides: zod_1.z.object({
|
|
66
|
+
headerText: exports.LocalizedTextSchema,
|
|
67
|
+
}),
|
|
68
|
+
connectionKeys: zod_1.z.object({
|
|
69
|
+
headerText: exports.LocalizedTextSchema,
|
|
70
|
+
}),
|
|
71
|
+
});
|
|
72
|
+
exports.SubscriptionPageRawConfigSchema = zod_1.z
|
|
73
|
+
.object({
|
|
74
|
+
version: zod_1.z.nativeEnum(constants_1.SUBSCRIPTION_PAGE_CONFIG_VERSION),
|
|
75
|
+
additionalLocales: zod_1.z.array(zod_1.z.enum(constants_1.SUBSCRIPTION_PAGE_CONFIG_ADDITIONAL_LOCALES)),
|
|
76
|
+
brandingSettings: BrandingSettingsSchema,
|
|
77
|
+
uiConfig: UiConfigSchema,
|
|
78
|
+
platforms: zod_1.z.record(zod_1.z.nativeEnum(constants_1.SUBSCRIPTION_PAGE_CONFIG_PLATFORM_TYPES), PlatformSchema),
|
|
79
|
+
})
|
|
80
|
+
.superRefine((data, ctx) => {
|
|
81
|
+
(0, subscription_page_config_validator_1.validateLocalizedTexts)(data.platforms, data.additionalLocales, 'platforms', ctx);
|
|
82
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { TSubscriptionPageConfigAdditionalLocales } from '../../constants';
|
|
3
|
+
export declare const validateLocalizedTexts: (obj: unknown, requiredLocales: TSubscriptionPageConfigAdditionalLocales[], path: string, ctx: z.RefinementCtx) => void;
|
|
4
|
+
//# sourceMappingURL=subscription-page-config.validator.d.ts.map
|
package/build/backend/models/subscription-page-config/subscription-page-config.validator.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription-page-config.validator.d.ts","sourceRoot":"","sources":["../../../../models/subscription-page-config/subscription-page-config.validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,wCAAwC,EAAE,MAAM,iBAAiB,CAAC;AAG3E,eAAO,MAAM,sBAAsB,GAC/B,KAAK,OAAO,EACZ,iBAAiB,wCAAwC,EAAE,EAC3D,MAAM,MAAM,EACZ,KAAK,CAAC,CAAC,aAAa,KACrB,IA0BF,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateLocalizedTexts = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const validateLocalizedTexts = (obj, requiredLocales, path, ctx) => {
|
|
6
|
+
if (obj === null || typeof obj !== 'object')
|
|
7
|
+
return;
|
|
8
|
+
if ('en' in obj && typeof obj.en === 'string') {
|
|
9
|
+
for (const locale of requiredLocales) {
|
|
10
|
+
const value = obj[locale];
|
|
11
|
+
if (!value || value.trim() === '') {
|
|
12
|
+
ctx.addIssue({
|
|
13
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
14
|
+
message: `Missing required locale '${locale}' at ${path}`,
|
|
15
|
+
path: [path, locale],
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
22
|
+
if (Array.isArray(value)) {
|
|
23
|
+
value.forEach((item, index) => {
|
|
24
|
+
(0, exports.validateLocalizedTexts)(item, requiredLocales, `${path}.${key}[${index}]`, ctx);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
else if (typeof value === 'object' && value !== null) {
|
|
28
|
+
(0, exports.validateLocalizedTexts)(value, requiredLocales, `${path}.${key}`, ctx);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.validateLocalizedTexts = validateLocalizedTexts;
|
|
@@ -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("./subscription-page-config"), exports);
|
|
@@ -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("./subscription-page-config.contants"), exports);
|
|
18
|
+
__exportStar(require("./subscription-page-template-keys.contant"), exports);
|
package/build/frontend/constants/subscription-page-config/subscription-page-config.contants.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SUBSCRIPTION_PAGE_CONFIG_PLATFORM_TYPES = exports.SUBSCRIPTION_PAGE_CONFIG_ADDITIONAL_LOCALES = exports.SUBSCRIPTION_PAGE_CONFIG_VERSION = void 0;
|
|
4
|
+
exports.SUBSCRIPTION_PAGE_CONFIG_VERSION = {
|
|
5
|
+
1: '1',
|
|
6
|
+
};
|
|
7
|
+
exports.SUBSCRIPTION_PAGE_CONFIG_ADDITIONAL_LOCALES = ['ru', 'zh', 'fa', 'fr'];
|
|
8
|
+
exports.SUBSCRIPTION_PAGE_CONFIG_PLATFORM_TYPES = {
|
|
9
|
+
IOS: 'ios',
|
|
10
|
+
ANDROID: 'android',
|
|
11
|
+
LINUX: 'linux',
|
|
12
|
+
MACOS: 'macos',
|
|
13
|
+
WINDOWS: 'windows',
|
|
14
|
+
ANDROID_TV: 'androidTV',
|
|
15
|
+
APPLE_TV: 'appleTV',
|
|
16
|
+
};
|
|
@@ -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("./constants"), exports);
|
|
18
|
+
__exportStar(require("./models"), exports);
|
|
@@ -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("./subscription-page-config"), exports);
|
|
@@ -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("./subscription-page-config.schema"), exports);
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubscriptionPageRawConfigSchema = exports.LocalizedTextSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
const subscription_page_config_validator_1 = require("./subscription-page-config.validator");
|
|
7
|
+
exports.LocalizedTextSchema = zod_1.z.object({
|
|
8
|
+
en: zod_1.z.string(),
|
|
9
|
+
ru: zod_1.z.string().optional(),
|
|
10
|
+
zh: zod_1.z.string().optional(),
|
|
11
|
+
fa: zod_1.z.string().optional(),
|
|
12
|
+
fr: zod_1.z.string().optional(),
|
|
13
|
+
});
|
|
14
|
+
const ButtonSchema = zod_1.z.object({
|
|
15
|
+
link: zod_1.z.string(),
|
|
16
|
+
type: zod_1.z.enum(['external', 'subscriptionLink']),
|
|
17
|
+
text: exports.LocalizedTextSchema,
|
|
18
|
+
svgIcon: zod_1.z.string(),
|
|
19
|
+
});
|
|
20
|
+
const BlockSchema = zod_1.z.object({
|
|
21
|
+
svgIcon: zod_1.z.string(),
|
|
22
|
+
svgIconColor: zod_1.z
|
|
23
|
+
.string()
|
|
24
|
+
.refine((value) => [
|
|
25
|
+
'blue',
|
|
26
|
+
'cyan',
|
|
27
|
+
'dark',
|
|
28
|
+
'grape',
|
|
29
|
+
'gray',
|
|
30
|
+
'green',
|
|
31
|
+
'indigo',
|
|
32
|
+
'lime',
|
|
33
|
+
'orange',
|
|
34
|
+
'pink',
|
|
35
|
+
'red',
|
|
36
|
+
'teal',
|
|
37
|
+
'violet',
|
|
38
|
+
'yellow',
|
|
39
|
+
].includes(value) || /^#[0-9a-fA-F]{3,8}$/.test(value), {
|
|
40
|
+
message: 'svgIconColor must be one of the predefined colors or a hex color beginning with #',
|
|
41
|
+
}),
|
|
42
|
+
title: exports.LocalizedTextSchema,
|
|
43
|
+
description: exports.LocalizedTextSchema,
|
|
44
|
+
buttons: zod_1.z.array(ButtonSchema),
|
|
45
|
+
});
|
|
46
|
+
const PlatformAppSchema = zod_1.z.object({
|
|
47
|
+
name: zod_1.z.string(),
|
|
48
|
+
featured: zod_1.z.boolean(),
|
|
49
|
+
blocks: zod_1.z.array(BlockSchema),
|
|
50
|
+
});
|
|
51
|
+
const PlatformSchema = zod_1.z.object({
|
|
52
|
+
displayName: exports.LocalizedTextSchema,
|
|
53
|
+
svgIcon: zod_1.z.string(),
|
|
54
|
+
apps: zod_1.z.array(PlatformAppSchema),
|
|
55
|
+
});
|
|
56
|
+
const BrandingSettingsSchema = zod_1.z.object({
|
|
57
|
+
title: zod_1.z.string(),
|
|
58
|
+
logoUrl: zod_1.z.string(),
|
|
59
|
+
supportUrl: zod_1.z.string().url(),
|
|
60
|
+
});
|
|
61
|
+
const UiConfigSchema = zod_1.z.object({
|
|
62
|
+
subscriptionInfo: zod_1.z.object({
|
|
63
|
+
block: zod_1.z.enum(['collapsed', 'expanded']),
|
|
64
|
+
}),
|
|
65
|
+
installationGuides: zod_1.z.object({
|
|
66
|
+
headerText: exports.LocalizedTextSchema,
|
|
67
|
+
}),
|
|
68
|
+
connectionKeys: zod_1.z.object({
|
|
69
|
+
headerText: exports.LocalizedTextSchema,
|
|
70
|
+
}),
|
|
71
|
+
});
|
|
72
|
+
exports.SubscriptionPageRawConfigSchema = zod_1.z
|
|
73
|
+
.object({
|
|
74
|
+
version: zod_1.z.nativeEnum(constants_1.SUBSCRIPTION_PAGE_CONFIG_VERSION),
|
|
75
|
+
additionalLocales: zod_1.z.array(zod_1.z.enum(constants_1.SUBSCRIPTION_PAGE_CONFIG_ADDITIONAL_LOCALES)),
|
|
76
|
+
brandingSettings: BrandingSettingsSchema,
|
|
77
|
+
uiConfig: UiConfigSchema,
|
|
78
|
+
platforms: zod_1.z.record(zod_1.z.nativeEnum(constants_1.SUBSCRIPTION_PAGE_CONFIG_PLATFORM_TYPES), PlatformSchema),
|
|
79
|
+
})
|
|
80
|
+
.superRefine((data, ctx) => {
|
|
81
|
+
(0, subscription_page_config_validator_1.validateLocalizedTexts)(data.platforms, data.additionalLocales, 'platforms', ctx);
|
|
82
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateLocalizedTexts = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const validateLocalizedTexts = (obj, requiredLocales, path, ctx) => {
|
|
6
|
+
if (obj === null || typeof obj !== 'object')
|
|
7
|
+
return;
|
|
8
|
+
if ('en' in obj && typeof obj.en === 'string') {
|
|
9
|
+
for (const locale of requiredLocales) {
|
|
10
|
+
const value = obj[locale];
|
|
11
|
+
if (!value || value.trim() === '') {
|
|
12
|
+
ctx.addIssue({
|
|
13
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
14
|
+
message: `Missing required locale '${locale}' at ${path}`,
|
|
15
|
+
path: [path, locale],
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
22
|
+
if (Array.isArray(value)) {
|
|
23
|
+
value.forEach((item, index) => {
|
|
24
|
+
(0, exports.validateLocalizedTexts)(item, requiredLocales, `${path}.${key}[${index}]`, ctx);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
else if (typeof value === 'object' && value !== null) {
|
|
28
|
+
(0, exports.validateLocalizedTexts)(value, requiredLocales, `${path}.${key}`, ctx);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.validateLocalizedTexts = validateLocalizedTexts;
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@remnawave/subscription-page-types",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"public": true,
|
|
5
|
+
"license": "AGPL-3.0-only",
|
|
6
|
+
"description": "A types library for Remnawave Subscription Page.",
|
|
7
|
+
"author": "REMNAWAVE <github.com/remnawave>",
|
|
8
|
+
"homepage": "https://github.com/remnawave",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/remnawave/backend.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/remnawave/backend/issues"
|
|
15
|
+
},
|
|
16
|
+
"main": "build/backend/index.js",
|
|
17
|
+
"browser": "build/frontend/index.js",
|
|
18
|
+
"types": "build/backend/index.d.ts",
|
|
19
|
+
"files": [
|
|
20
|
+
"build/**/*"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"clean": "rm -rf build",
|
|
24
|
+
"build:backend": "tsc -p tsconfig.backend.json",
|
|
25
|
+
"build:frontend": "tsc -p tsconfig.frontend.json",
|
|
26
|
+
"build": "npm run clean && npm run build:backend && npm run build:frontend",
|
|
27
|
+
"prepublish": "npm run build"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"zod": "3.25.76"
|
|
32
|
+
}
|
|
33
|
+
}
|