@or-sdk/library-types-v1 6.0.6 → 6.0.7
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/CHANGELOG.md +6 -0
- package/dist/Categories/body.d.ts +3 -2
- package/dist/Packages/param.d.ts +17 -60
- package/dist/Packages/response.d.ts +252 -71
- package/dist/Packages/union.d.ts +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.js +66 -54
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/src/Categories/body.ts +13 -2
- package/src/Packages/param.ts +64 -88
- package/src/Packages/response.ts +44 -32
- package/src/index.ts +2 -0
package/package.json
CHANGED
package/src/Categories/body.ts
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
+
const uuidRegex = new RegExp(
|
|
4
|
+
/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
|
|
5
|
+
);
|
|
6
|
+
|
|
7
|
+
export const CategoryNameType = z
|
|
8
|
+
.string()
|
|
9
|
+
.trim()
|
|
10
|
+
.refine((s) => !uuidRegex.test(s), {
|
|
11
|
+
message: 'Category name cannot be uuid',
|
|
12
|
+
});
|
|
13
|
+
|
|
3
14
|
export const CreateCategoryBody = z.object({
|
|
4
|
-
name:
|
|
15
|
+
name: CategoryNameType,
|
|
5
16
|
});
|
|
6
17
|
|
|
7
18
|
export const UpdateCategoryBody = z.object({
|
|
8
|
-
name:
|
|
19
|
+
name: CategoryNameType,
|
|
9
20
|
hidden: z.boolean().optional(),
|
|
10
21
|
});
|
package/src/Packages/param.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
import { packageLevel, packageStatus } from './propTransformer';
|
|
9
9
|
|
|
10
|
-
function clearArray<T>(arr = []) {
|
|
10
|
+
function clearArray<T>(arr = []): T[] {
|
|
11
11
|
return arr
|
|
12
12
|
.map((e) => e?.trim?.())
|
|
13
13
|
.filter(
|
|
@@ -22,20 +22,24 @@ export enum PackagesOrderByEnum {
|
|
|
22
22
|
updatedAt = 'updatedAt',
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
const PackageArrayOfStringParam = z
|
|
26
|
+
.array(z.string())
|
|
27
|
+
.or(z.string())
|
|
28
|
+
.transform((data) => {
|
|
29
|
+
if (!Array.isArray(data)) {
|
|
30
|
+
data = [data];
|
|
31
|
+
}
|
|
32
|
+
return clearArray(data);
|
|
33
|
+
})
|
|
34
|
+
.optional()
|
|
35
|
+
.default([]);
|
|
36
|
+
|
|
25
37
|
export const GetPackagesQueryFilter = z.object({
|
|
26
38
|
filter: z
|
|
27
39
|
.object({
|
|
28
|
-
id:
|
|
29
|
-
.array(z.string())
|
|
30
|
-
.or(z.string())
|
|
31
|
-
.transform((data) => clearArray(Array.isArray(data) ? data : [data]))
|
|
32
|
-
.default([]),
|
|
40
|
+
id: PackageArrayOfStringParam,
|
|
33
41
|
schemaType: z.nativeEnum(PackageSchemaTypeEnum).optional(),
|
|
34
|
-
category:
|
|
35
|
-
.array(z.string())
|
|
36
|
-
.or(z.string())
|
|
37
|
-
.default([])
|
|
38
|
-
.transform((data) => (Array.isArray(data) ? data : [data])),
|
|
42
|
+
category: PackageArrayOfStringParam,
|
|
39
43
|
level: z
|
|
40
44
|
.array(z.nativeEnum(PackageStatusDetailsLevelEnum))
|
|
41
45
|
.or(
|
|
@@ -52,83 +56,55 @@ export const GetPackagesQueryFilter = z.object({
|
|
|
52
56
|
.default({}),
|
|
53
57
|
});
|
|
54
58
|
|
|
55
|
-
export const GetPackagesQuery = z
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
.transform((data) => {
|
|
105
|
-
if (data === PackagesOrderByEnum.created) {
|
|
106
|
-
return PackagesOrderByEnum.createdAt;
|
|
107
|
-
}
|
|
108
|
-
return data;
|
|
109
|
-
}),
|
|
110
|
-
order: z.nativeEnum(Prisma.SortOrder).default(Prisma.SortOrder.desc),
|
|
111
|
-
categories: z
|
|
112
|
-
.array(z.string())
|
|
113
|
-
.default([])
|
|
114
|
-
.transform((data) => clearArray(data)),
|
|
115
|
-
includeDeprecated: z
|
|
116
|
-
.string()
|
|
117
|
-
.transform((v) => ['true', '1', 1, true].includes(v))
|
|
118
|
-
.or(z.boolean())
|
|
119
|
-
.default(false),
|
|
120
|
-
})
|
|
121
|
-
.default({}),
|
|
122
|
-
)
|
|
123
|
-
.transform((data) => {
|
|
124
|
-
return {
|
|
125
|
-
...data,
|
|
126
|
-
categories: [
|
|
127
|
-
...(data.scope?.category || []),
|
|
128
|
-
...(data.filter?.category || []),
|
|
129
|
-
],
|
|
130
|
-
};
|
|
131
|
-
});
|
|
59
|
+
export const GetPackagesQuery = z.intersection(
|
|
60
|
+
GetPackagesQueryFilter,
|
|
61
|
+
z
|
|
62
|
+
.object({
|
|
63
|
+
id: PackageArrayOfStringParam,
|
|
64
|
+
type: z.nativeEnum(PackageTypeEnum).optional(),
|
|
65
|
+
query: z
|
|
66
|
+
.string()
|
|
67
|
+
.optional()
|
|
68
|
+
.transform((s) => (typeof s === 'string' ? s.trim() : s)),
|
|
69
|
+
scope: z
|
|
70
|
+
.object({
|
|
71
|
+
id: PackageArrayOfStringParam,
|
|
72
|
+
category: PackageArrayOfStringParam,
|
|
73
|
+
})
|
|
74
|
+
.default({}),
|
|
75
|
+
size: z
|
|
76
|
+
.number()
|
|
77
|
+
.or(z.string())
|
|
78
|
+
.default(10)
|
|
79
|
+
.transform((n) => Number(n) || 0),
|
|
80
|
+
cursor: z
|
|
81
|
+
.object({
|
|
82
|
+
from: z
|
|
83
|
+
.number()
|
|
84
|
+
.or(z.string())
|
|
85
|
+
.transform((n) => Number(n) || 0),
|
|
86
|
+
})
|
|
87
|
+
.or(z.any().transform(() => ({ from: 0 })))
|
|
88
|
+
.transform((data) => (data?.from ? data : { from: 0 })),
|
|
89
|
+
orderBy: z
|
|
90
|
+
.nativeEnum(PackagesOrderByEnum)
|
|
91
|
+
.default(PackagesOrderByEnum.createdAt)
|
|
92
|
+
.transform((data) => {
|
|
93
|
+
if (data === PackagesOrderByEnum.created) {
|
|
94
|
+
return PackagesOrderByEnum.createdAt;
|
|
95
|
+
}
|
|
96
|
+
return data;
|
|
97
|
+
}),
|
|
98
|
+
order: z.nativeEnum(Prisma.SortOrder).default(Prisma.SortOrder.desc),
|
|
99
|
+
categories: PackageArrayOfStringParam,
|
|
100
|
+
includeDeprecated: z
|
|
101
|
+
.string()
|
|
102
|
+
.transform((v) => ['true', '1', 1, true].includes(v))
|
|
103
|
+
.or(z.boolean())
|
|
104
|
+
.default(false),
|
|
105
|
+
})
|
|
106
|
+
.default({}),
|
|
107
|
+
);
|
|
132
108
|
|
|
133
109
|
export const PackageParamUniversal = z.object({
|
|
134
110
|
type: z.nativeEnum(PackageTypeEnum),
|
package/src/Packages/response.ts
CHANGED
|
@@ -15,6 +15,17 @@ const categoriesList = z.array(
|
|
|
15
15
|
}),
|
|
16
16
|
);
|
|
17
17
|
|
|
18
|
+
const PackageReleases = z
|
|
19
|
+
.array(
|
|
20
|
+
z.object({
|
|
21
|
+
status: z.nativeEnum(PackageStatusDetailsStatusEnum),
|
|
22
|
+
level: z.nativeEnum(PackageStatusDetailsLevelEnum),
|
|
23
|
+
version: z.string(),
|
|
24
|
+
primaryId: z.number().optional(),
|
|
25
|
+
}),
|
|
26
|
+
)
|
|
27
|
+
.default([]);
|
|
28
|
+
|
|
18
29
|
export const GetPackagesResponseEntity = z.object({
|
|
19
30
|
createdAt: z.date().or(z.string()).optional(),
|
|
20
31
|
id: z.string(),
|
|
@@ -26,16 +37,7 @@ export const GetPackagesResponseEntity = z.object({
|
|
|
26
37
|
level: z.nativeEnum(PackageStatusDetailsLevelEnum).optional(),
|
|
27
38
|
levels: z.array(z.nativeEnum(PackageStatusDetailsLevelEnum)).optional(),
|
|
28
39
|
name: z.string().optional(),
|
|
29
|
-
releases:
|
|
30
|
-
.array(
|
|
31
|
-
z.object({
|
|
32
|
-
status: z.nativeEnum(PackageStatusDetailsStatusEnum),
|
|
33
|
-
level: z.nativeEnum(PackageStatusDetailsLevelEnum),
|
|
34
|
-
version: z.string(),
|
|
35
|
-
primaryId: z.number().optional(),
|
|
36
|
-
}),
|
|
37
|
-
)
|
|
38
|
-
.optional(),
|
|
40
|
+
releases: PackageReleases,
|
|
39
41
|
latestDocId: z.any().optional(),
|
|
40
42
|
revisionId: z.string().optional(),
|
|
41
43
|
schemaType: z.nativeEnum(PackageSchemaTypeEnum),
|
|
@@ -105,11 +107,7 @@ export const GetPackageResponse = z.object({
|
|
|
105
107
|
servingType: z.string().optional(),
|
|
106
108
|
});
|
|
107
109
|
|
|
108
|
-
export const
|
|
109
|
-
version: z.string(),
|
|
110
|
-
baseUrl: z.string(),
|
|
111
|
-
statusDetails: PackageStatusDetails.optional(),
|
|
112
|
-
servingType: z.string().optional(),
|
|
110
|
+
export const GetPackageByIdIncludes = z.object({
|
|
113
111
|
releaseNotes: z
|
|
114
112
|
.object({ markdown: z.string().nullable().optional() })
|
|
115
113
|
.optional()
|
|
@@ -135,25 +133,39 @@ export const GetPackageByIdResponse = z.object({
|
|
|
135
133
|
.describe('Deprecated for v2 version api'),
|
|
136
134
|
membersAccountIds: z.array(z.string()).optional(),
|
|
137
135
|
membersUserIds: z.array(z.string()).optional(),
|
|
138
|
-
createdAt: z.date().or(z.string()).optional(),
|
|
139
|
-
revisionId: z.string().optional(),
|
|
140
|
-
name: z.string().optional(),
|
|
141
|
-
description: z.string().nullable().optional(),
|
|
142
|
-
categories: z.array(z.string()).optional(),
|
|
143
|
-
packageMeta: PackageMeta,
|
|
144
|
-
id: z.string().optional(),
|
|
145
|
-
schemaType: z.nativeEnum(PackageSchemaTypeEnum).optional(),
|
|
146
136
|
});
|
|
147
137
|
|
|
148
|
-
export const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
138
|
+
export const GetPackageByIdResponse = z.intersection(
|
|
139
|
+
z.object({
|
|
140
|
+
version: z.string(),
|
|
141
|
+
baseUrl: z.string(),
|
|
142
|
+
statusDetails: PackageStatusDetails.optional(),
|
|
143
|
+
servingType: z.string().optional(),
|
|
144
|
+
createdAt: z.date().or(z.string()).optional(),
|
|
145
|
+
revisionId: z.string().optional(),
|
|
146
|
+
name: z.string().optional(),
|
|
147
|
+
description: z.string().nullable().optional(),
|
|
148
|
+
categories: z.array(z.string()).optional(),
|
|
149
|
+
packageMeta: PackageMeta,
|
|
150
|
+
id: z.string().optional(),
|
|
151
|
+
schemaType: z.nativeEnum(PackageSchemaTypeEnum).optional(),
|
|
152
|
+
}),
|
|
153
|
+
GetPackageByIdIncludes,
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
export const GetPackageByIdLatestResponse = z.intersection(
|
|
157
|
+
z.object({
|
|
158
|
+
packageMeta: PackageMeta,
|
|
159
|
+
id: z.string(),
|
|
160
|
+
schemaType: z.nativeEnum(PackageSchemaTypeEnum),
|
|
161
|
+
version: z.string(),
|
|
162
|
+
name: z.string().trim().optional(),
|
|
163
|
+
baseUrl: z.string(),
|
|
164
|
+
servingType: z.string().optional(),
|
|
165
|
+
releases: PackageReleases,
|
|
166
|
+
}),
|
|
167
|
+
GetPackageByIdIncludes,
|
|
168
|
+
);
|
|
157
169
|
|
|
158
170
|
export const GetPackageArchiveSignedUrl = z.object({
|
|
159
171
|
key: z.string(),
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import * as allZodSchemas from './index.zod';
|
|
3
|
+
export type CategoryNameTypeDTO = z.infer<typeof allZodSchemas.CategoryNameType>
|
|
3
4
|
export type CreateCategoryBodyDTO = z.infer<typeof allZodSchemas.CreateCategoryBody>
|
|
4
5
|
export type UpdateCategoryBodyDTO = z.infer<typeof allZodSchemas.UpdateCategoryBody>
|
|
5
6
|
export type CategoriesParamUniversalDTO = z.infer<typeof allZodSchemas.CategoriesParamUniversal>
|
|
@@ -26,6 +27,7 @@ export type GetPackagesResponseEntityDTO = z.infer<typeof allZodSchemas.GetPacka
|
|
|
26
27
|
export type GetPackagesResponseDTO = z.infer<typeof allZodSchemas.GetPackagesResponse>
|
|
27
28
|
export type PackageStatusDetailsDTO = z.infer<typeof allZodSchemas.PackageStatusDetails>
|
|
28
29
|
export type GetPackageResponseDTO = z.infer<typeof allZodSchemas.GetPackageResponse>
|
|
30
|
+
export type GetPackageByIdIncludesDTO = z.infer<typeof allZodSchemas.GetPackageByIdIncludes>
|
|
29
31
|
export type GetPackageByIdResponseDTO = z.infer<typeof allZodSchemas.GetPackageByIdResponse>
|
|
30
32
|
export type GetPackageByIdLatestResponseDTO = z.infer<typeof allZodSchemas.GetPackageByIdLatestResponse>
|
|
31
33
|
export type GetPackageArchiveSignedUrlDTO = z.infer<typeof allZodSchemas.GetPackageArchiveSignedUrl>
|