@isardsat/editorial-common 6.8.1 → 6.9.0
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/index.js +1 -17
- package/dist/schemas.d.ts +1 -0
- package/dist/schemas.js +70 -58
- package/dist/types.js +1 -2
- package/package.json +2 -1
- package/src/schemas.ts +20 -0
- package/tsconfig.json +3 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
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("./schemas.js"), exports);
|
|
1
|
+
export * from './schemas.js';
|
package/dist/schemas.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export declare const EditorialSchemaItemFieldType: z.ZodEnum<{
|
|
|
51
51
|
color: "color";
|
|
52
52
|
select: "select";
|
|
53
53
|
}>;
|
|
54
|
+
export declare const RGBColorSchema: z.ZodString;
|
|
54
55
|
export declare const EditorialSchemaItemFieldSchema: z.ZodObject<{
|
|
55
56
|
type: z.ZodEnum<{
|
|
56
57
|
string: "string";
|
package/dist/schemas.js
CHANGED
|
@@ -1,41 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
previewUrl: zod_openapi_1.z.string().optional(),
|
|
13
|
-
silent: zod_openapi_1.z.boolean().optional(),
|
|
14
|
-
firebase: zod_openapi_1.z
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
2
|
+
export const EditorialConfigSchema = z.object({
|
|
3
|
+
name: z.string(),
|
|
4
|
+
publicUrl: z.url(),
|
|
5
|
+
publicDir: z.string().default("public/files"),
|
|
6
|
+
publicDeletedDir: z.string().default("public/files/.deleted"),
|
|
7
|
+
filesUrl: z.url(),
|
|
8
|
+
largeFilesUrl: z.url(),
|
|
9
|
+
previewUrl: z.string().optional(),
|
|
10
|
+
silent: z.boolean().optional(),
|
|
11
|
+
firebase: z
|
|
15
12
|
.object({
|
|
16
|
-
apiKey:
|
|
17
|
-
authDomain:
|
|
18
|
-
databaseURL:
|
|
19
|
-
projectId:
|
|
20
|
-
storageBucket:
|
|
21
|
-
messagingSenderId:
|
|
22
|
-
dbUsersPath:
|
|
13
|
+
apiKey: z.string(),
|
|
14
|
+
authDomain: z.string(),
|
|
15
|
+
databaseURL: z.string(),
|
|
16
|
+
projectId: z.string(),
|
|
17
|
+
storageBucket: z.string(),
|
|
18
|
+
messagingSenderId: z.string(),
|
|
19
|
+
dbUsersPath: z.string(),
|
|
23
20
|
})
|
|
24
21
|
.optional(),
|
|
25
22
|
});
|
|
26
|
-
|
|
27
|
-
id:
|
|
28
|
-
type:
|
|
23
|
+
export const EditorialDataObjectWithTypeSchema = z.looseObject({
|
|
24
|
+
id: z.string(),
|
|
25
|
+
type: z.string(),
|
|
29
26
|
});
|
|
30
|
-
|
|
31
|
-
id:
|
|
32
|
-
isDraft:
|
|
33
|
-
createdAt:
|
|
34
|
-
updatedAt:
|
|
27
|
+
export const EditorialDataItemSchema = z.looseObject({
|
|
28
|
+
id: z.string(),
|
|
29
|
+
isDraft: z.boolean().default(false),
|
|
30
|
+
createdAt: z.iso.datetime().default(() => new Date().toISOString()),
|
|
31
|
+
updatedAt: z.iso.datetime().default(() => new Date().toISOString()),
|
|
35
32
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
export const EditorialDataTypeSchema = z.record(z.string(), EditorialDataItemSchema);
|
|
34
|
+
export const EditorialDataSchema = z.record(z.string(), EditorialDataTypeSchema);
|
|
35
|
+
export const EditorialSchemaItemFieldType = z.enum([
|
|
39
36
|
"string",
|
|
40
37
|
"boolean",
|
|
41
38
|
"date",
|
|
@@ -46,37 +43,52 @@ exports.EditorialSchemaItemFieldType = zod_openapi_1.z.enum([
|
|
|
46
43
|
"select",
|
|
47
44
|
"url",
|
|
48
45
|
]);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
export const RGBColorSchema = z
|
|
47
|
+
.string()
|
|
48
|
+
.regex(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/, "Must be a valid RGB color format: rgb(r, g, b)")
|
|
49
|
+
.refine((value) => {
|
|
50
|
+
const match = value.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/);
|
|
51
|
+
if (!match)
|
|
52
|
+
return false;
|
|
53
|
+
const [, r, g, b] = match;
|
|
54
|
+
return (Number(r) >= 0 &&
|
|
55
|
+
Number(r) <= 255 &&
|
|
56
|
+
Number(g) >= 0 &&
|
|
57
|
+
Number(g) <= 255 &&
|
|
58
|
+
Number(b) >= 0 &&
|
|
59
|
+
Number(b) <= 255);
|
|
60
|
+
}, "RGB values must be between 0 and 255");
|
|
61
|
+
export const EditorialSchemaItemFieldSchema = z.looseObject({
|
|
62
|
+
type: EditorialSchemaItemFieldType,
|
|
63
|
+
displayName: z.string(),
|
|
64
|
+
displayExtra: z.string().optional(),
|
|
65
|
+
placeholder: z.string().optional(),
|
|
66
|
+
optional: z.boolean().default(false),
|
|
67
|
+
showInSummary: z.boolean().optional(),
|
|
56
68
|
});
|
|
57
|
-
|
|
58
|
-
displayName:
|
|
59
|
-
singleton:
|
|
60
|
-
fields:
|
|
69
|
+
export const EditorialSchemaItemSchema = z.object({
|
|
70
|
+
displayName: z.string(),
|
|
71
|
+
singleton: z.boolean().optional(),
|
|
72
|
+
fields: z.record(z.string(), EditorialSchemaItemFieldSchema),
|
|
61
73
|
});
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
name:
|
|
65
|
-
type:
|
|
66
|
-
path:
|
|
67
|
-
relativePath:
|
|
68
|
-
size:
|
|
69
|
-
isLarge:
|
|
74
|
+
export const EditorialSchemaSchema = z.record(z.string(), EditorialSchemaItemSchema);
|
|
75
|
+
export const BaseEditorialFileSchema = z.object({
|
|
76
|
+
name: z.string(),
|
|
77
|
+
type: z.enum(["file", "directory"]),
|
|
78
|
+
path: z.string(),
|
|
79
|
+
relativePath: z.string(),
|
|
80
|
+
size: z.number(),
|
|
81
|
+
isLarge: z.boolean().optional(),
|
|
70
82
|
});
|
|
71
|
-
|
|
72
|
-
children:
|
|
73
|
-
.lazy(() =>
|
|
83
|
+
export const EditorialFileSchema = BaseEditorialFileSchema.extend({
|
|
84
|
+
children: z
|
|
85
|
+
.lazy(() => EditorialFileSchema.array())
|
|
74
86
|
.openapi({
|
|
75
87
|
type: "array",
|
|
76
88
|
}),
|
|
77
89
|
});
|
|
78
|
-
|
|
79
|
-
files:
|
|
80
|
-
totalSize:
|
|
90
|
+
export const EditorialFilesResponseSchema = z.object({
|
|
91
|
+
files: z.array(EditorialFileSchema),
|
|
92
|
+
totalSize: z.number(),
|
|
81
93
|
});
|
|
82
|
-
|
|
94
|
+
export const EditorialFilesSchema = z.array(EditorialFileSchema);
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/package.json
CHANGED
package/src/schemas.ts
CHANGED
|
@@ -56,6 +56,26 @@ export const EditorialSchemaItemFieldType = z.enum([
|
|
|
56
56
|
"url",
|
|
57
57
|
]);
|
|
58
58
|
|
|
59
|
+
export const RGBColorSchema = z
|
|
60
|
+
.string()
|
|
61
|
+
.regex(
|
|
62
|
+
/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/,
|
|
63
|
+
"Must be a valid RGB color format: rgb(r, g, b)"
|
|
64
|
+
)
|
|
65
|
+
.refine((value) => {
|
|
66
|
+
const match = value.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/);
|
|
67
|
+
if (!match) return false;
|
|
68
|
+
const [, r, g, b] = match;
|
|
69
|
+
return (
|
|
70
|
+
Number(r) >= 0 &&
|
|
71
|
+
Number(r) <= 255 &&
|
|
72
|
+
Number(g) >= 0 &&
|
|
73
|
+
Number(g) <= 255 &&
|
|
74
|
+
Number(b) >= 0 &&
|
|
75
|
+
Number(b) <= 255
|
|
76
|
+
);
|
|
77
|
+
}, "RGB values must be between 0 and 255");
|
|
78
|
+
|
|
59
79
|
export const EditorialSchemaItemFieldSchema = z.looseObject({
|
|
60
80
|
type: EditorialSchemaItemFieldType,
|
|
61
81
|
displayName: z.string(),
|