@hosterai/types 0.0.33 → 0.0.36
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/dist/dtos/action.dto.js +1 -1
- package/dist/dtos/country.dto.js +1 -2
- package/dist/dtos/field.dto.js +1 -2
- package/dist/dtos/info.dto.js +3 -3
- package/dist/dtos/multilang-text.dto.js +1 -2
- package/dist/dtos/notification/notification-info.dto.js +1 -2
- package/dist/dtos/product/product-info.dto.js +1 -1
- package/dist/dtos/product/responses/product-create-response.dto.d.ts +6 -0
- package/dist/dtos/product/responses/product-create-response.dto.js +8 -0
- package/dist/dtos/product/responses/product-delete-response.dto.d.ts +6 -0
- package/dist/dtos/product/responses/product-delete-response.dto.js +8 -0
- package/dist/dtos/product/responses/product-downgrade-response.dto.d.ts +6 -0
- package/dist/dtos/product/responses/product-downgrade-response.dto.js +8 -0
- package/dist/dtos/product/responses/product-renew-response.dto.d.ts +6 -0
- package/dist/dtos/product/responses/product-renew-response.dto.js +8 -0
- package/dist/dtos/product/responses/product-suspend-response.dto.d.ts +6 -0
- package/dist/dtos/product/responses/product-suspend-response.dto.js +8 -0
- package/dist/dtos/product/responses/product-unsuspend-response.dto.d.ts +6 -0
- package/dist/dtos/product/responses/product-unsuspend-response.dto.js +8 -0
- package/dist/dtos/product/responses/product-upgrade-response.dto.d.ts +6 -0
- package/dist/dtos/product/responses/product-upgrade-response.dto.js +8 -0
- package/dist/openapi/schemas/components.schemas.d.ts +48 -68
- package/dist/openapi/schemas/components.schemas.js +754 -1804
- package/dist/openapi/schemas/components.schemas.spec.d.ts +1 -0
- package/dist/openapi/schemas/components.schemas.spec.js +122 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const components_schemas_1 = require("./components.schemas");
|
|
4
|
+
const Schemas = components_schemas_1.ComponentsSchemas;
|
|
5
|
+
const NAMED_ENUMS = [
|
|
6
|
+
'EventsEnum',
|
|
7
|
+
'RolesEnum',
|
|
8
|
+
'LanguageEnum',
|
|
9
|
+
'CountryEnum',
|
|
10
|
+
'FieldTypeEnum',
|
|
11
|
+
'ProductActionsEnum',
|
|
12
|
+
'OpenMethodEnum',
|
|
13
|
+
'NotificationMessageTypeEnum',
|
|
14
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* Paths (relative to a top-level schema) that are allowed to keep an inline
|
|
17
|
+
* enum because they are single-value `@IsIn` discriminators, not real enums.
|
|
18
|
+
* These are length-1 enums so the generic tripwire skips them anyway, but the
|
|
19
|
+
* allowlist documents the intent explicitly.
|
|
20
|
+
*/
|
|
21
|
+
const DISCRIMINATOR_ALLOWLIST = new Set([
|
|
22
|
+
'MenuDtoWithUrl.properties.type',
|
|
23
|
+
'MenuDtoWithSubmenu.properties.type',
|
|
24
|
+
]);
|
|
25
|
+
const isRef = (node) => !!node && typeof node === 'object' && typeof node.$ref === 'string';
|
|
26
|
+
describe('ComponentsSchemas - named enum schemas', () => {
|
|
27
|
+
it('exposes every shared enum as a standalone { type: "string", enum: [...] } schema', () => {
|
|
28
|
+
for (const name of NAMED_ENUMS) {
|
|
29
|
+
const schema = Schemas[name];
|
|
30
|
+
expect(schema).toBeDefined();
|
|
31
|
+
expect(schema.type).toBe('string');
|
|
32
|
+
expect(Array.isArray(schema.enum)).toBe(true);
|
|
33
|
+
expect(schema.enum.length).toBeGreaterThanOrEqual(2);
|
|
34
|
+
// values must be non-empty strings (LanguageEnum legitimately contains a
|
|
35
|
+
// duplicate code, so do not assert uniqueness here).
|
|
36
|
+
for (const v of schema.enum) {
|
|
37
|
+
expect(typeof v).toBe('string');
|
|
38
|
+
expect(v.length).toBeGreaterThan(0);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
describe('ComponentsSchemas - enum properties are $refs (no inline enums)', () => {
|
|
44
|
+
const refExpectations = [
|
|
45
|
+
{
|
|
46
|
+
label: 'InfoDto.listenEvents.items',
|
|
47
|
+
node: () => Schemas.InfoDto.properties.listenEvents.items,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: 'InfoDto.requiredRoles.items',
|
|
51
|
+
node: () => Schemas.InfoDto.properties.requiredRoles.items,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
label: 'InfoDto.supportedLanguages.items',
|
|
55
|
+
node: () => Schemas.InfoDto.properties.supportedLanguages.items,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
label: 'ProductInfoDto.supportedActions.items',
|
|
59
|
+
node: () => Schemas.ProductInfoDto.properties.supportedActions.items,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
label: 'CountryDto.code',
|
|
63
|
+
node: () => Schemas.CountryDto.properties.code,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
label: 'MultilangTextDto.language',
|
|
67
|
+
node: () => Schemas.MultilangTextDto.properties.language,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
label: 'NotificationInfoDto.type',
|
|
71
|
+
node: () => Schemas.NotificationInfoDto.properties.type,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
label: 'ActionDto.openMethod',
|
|
75
|
+
node: () => Schemas.ActionDto.properties.openMethod,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
label: 'FieldDto.type',
|
|
79
|
+
node: () => Schemas.FieldDto.properties.type,
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
it.each(refExpectations)('$label is a $ref with no inline enum', ({ node }) => {
|
|
83
|
+
const n = node();
|
|
84
|
+
expect(isRef(n)).toBe(true);
|
|
85
|
+
expect(n.enum).toBeUndefined();
|
|
86
|
+
});
|
|
87
|
+
it('keeps the array node structure intact for array enum properties', () => {
|
|
88
|
+
const arr = Schemas.InfoDto.properties.supportedLanguages;
|
|
89
|
+
expect(arr.type).toBe('array');
|
|
90
|
+
expect(isRef(arr.items)).toBe(true);
|
|
91
|
+
// The array node itself must NOT carry an inline enum.
|
|
92
|
+
expect(arr.enum).toBeUndefined();
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
describe('ComponentsSchemas - generic inline-enum regression tripwire', () => {
|
|
96
|
+
it('contains no inline enum (length >= 2) outside top-level named enum defs and the discriminator allowlist', () => {
|
|
97
|
+
const offenders = [];
|
|
98
|
+
const walk = (node, path, topKey) => {
|
|
99
|
+
if (Array.isArray(node)) {
|
|
100
|
+
node.forEach((child, i) => walk(child, `${path}[${i}]`, topKey));
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (node && typeof node === 'object') {
|
|
104
|
+
if (Array.isArray(node.enum) && node.enum.length >= 2) {
|
|
105
|
+
const isTopLevelNamedEnumDef = path === topKey;
|
|
106
|
+
const relative = path.slice(topKey.length + 1); // strip "TopKey."
|
|
107
|
+
const isAllowlisted = DISCRIMINATOR_ALLOWLIST.has(`${topKey}.${relative}`);
|
|
108
|
+
if (!isTopLevelNamedEnumDef && !isAllowlisted) {
|
|
109
|
+
offenders.push(path);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
for (const [k, v] of Object.entries(node)) {
|
|
113
|
+
walk(v, `${path}.${k}`, topKey);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
for (const [topKey, schema] of Object.entries(Schemas)) {
|
|
118
|
+
walk(schema, topKey, topKey);
|
|
119
|
+
}
|
|
120
|
+
expect(offenders).toEqual([]);
|
|
121
|
+
});
|
|
122
|
+
});
|