@supernova-studio/client 0.59.17 → 0.59.19
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/index.d.mts +5253 -2054
- package/dist/index.d.ts +5253 -2054
- package/dist/index.js +97 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/dto/elements/documentation/page-actions-v2.ts +17 -0
- package/src/api/dto/elements/documentation/page-v2.ts +11 -2
- package/src/api/dto/elements/elements-action-v2.ts +4 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/redirect-validation.ts +76 -0
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
DTOMoveDocumentationPageInputV2,
|
|
8
8
|
DTORestoreDocumentationGroupInput,
|
|
9
9
|
DTORestoreDocumentationPageInput,
|
|
10
|
+
DTOUpdateDocumentationPageDocumentInputV2,
|
|
10
11
|
DTOUpdateDocumentationPageInputV2,
|
|
11
12
|
} from "./page-v2";
|
|
12
13
|
|
|
@@ -28,6 +29,11 @@ export const DTODocumentationPageUpdateActionOutputV2 = z.object({
|
|
|
28
29
|
output: SuccessPayload,
|
|
29
30
|
});
|
|
30
31
|
|
|
32
|
+
export const DTODocumentationPageUpdateDocumentActionOutputV2 = z.object({
|
|
33
|
+
type: z.literal("DocumentationPageUpdateDocument"),
|
|
34
|
+
output: SuccessPayload,
|
|
35
|
+
});
|
|
36
|
+
|
|
31
37
|
export const DTODocumentationPageMoveActionOutputV2 = z.object({
|
|
32
38
|
type: z.literal("DocumentationPageMove"),
|
|
33
39
|
output: SuccessPayload,
|
|
@@ -60,6 +66,9 @@ export const DTODocumentationPageApprovalStateChangeActionOutput = z.object({
|
|
|
60
66
|
|
|
61
67
|
export type DTODocumentationPageCreateActionOutputV2 = z.infer<typeof DTODocumentationPageCreateActionOutputV2>;
|
|
62
68
|
export type DTODocumentationPageUpdateActionOutputV2 = z.infer<typeof DTODocumentationPageUpdateActionOutputV2>;
|
|
69
|
+
export type DTODocumentationPageUpdateDocumentActionOutputV2 = z.infer<
|
|
70
|
+
typeof DTODocumentationPageUpdateDocumentActionOutputV2
|
|
71
|
+
>;
|
|
63
72
|
export type DTODocumentationPageMoveActionOutputV2 = z.infer<typeof DTODocumentationPageMoveActionOutputV2>;
|
|
64
73
|
export type DTODocumentationPageDuplicateActionOutputV2 = z.infer<typeof DTODocumentationPageDuplicateActionOutputV2>;
|
|
65
74
|
export type DTODocumentationPageDeleteActionOutputV2 = z.infer<typeof DTODocumentationPageDeleteActionOutputV2>;
|
|
@@ -82,6 +91,11 @@ export const DTODocumentationPageUpdateActionInputV2 = z.object({
|
|
|
82
91
|
input: DTOUpdateDocumentationPageInputV2,
|
|
83
92
|
});
|
|
84
93
|
|
|
94
|
+
export const DTODocumentationPageUpdateDocumentActionInputV2 = z.object({
|
|
95
|
+
type: z.literal("DocumentationPageUpdateDocument"),
|
|
96
|
+
input: DTOUpdateDocumentationPageDocumentInputV2,
|
|
97
|
+
});
|
|
98
|
+
|
|
85
99
|
export const DTODocumentationPageMoveActionInputV2 = z.object({
|
|
86
100
|
type: z.literal("DocumentationPageMove"),
|
|
87
101
|
input: DTOMoveDocumentationPageInputV2,
|
|
@@ -114,6 +128,9 @@ export const DTODocumentationPageApprovalStateChangeActionInput = z.object({
|
|
|
114
128
|
|
|
115
129
|
export type DTODocumentationPageCreateActionInputV2 = z.infer<typeof DTODocumentationPageCreateActionInputV2>;
|
|
116
130
|
export type DTODocumentationPageUpdateActionInputV2 = z.infer<typeof DTODocumentationPageUpdateActionInputV2>;
|
|
131
|
+
export type DTODocumentationPageUpdateDocumentActionInputV2 = z.infer<
|
|
132
|
+
typeof DTODocumentationPageUpdateDocumentActionInputV2
|
|
133
|
+
>;
|
|
117
134
|
export type DTODocumentationPageMoveActionInputV2 = z.infer<typeof DTODocumentationPageMoveActionInputV2>;
|
|
118
135
|
export type DTODocumentationPageDuplicateActionInputV2 = z.infer<typeof DTODocumentationPageDuplicateActionInputV2>;
|
|
119
136
|
export type DTODocumentationPageDeleteActionInputV2 = z.infer<typeof DTODocumentationPageDeleteActionInputV2>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DocumentationPageApprovalState } from "@supernova-studio/model";
|
|
1
|
+
import { DocumentationPageApprovalState, DocumentationPageContentItem } from "@supernova-studio/model";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { DTODocumentationPageApprovalState } from "../../documentation";
|
|
4
4
|
import { DTODocumentationDraftState } from "./draft-state";
|
|
@@ -64,7 +64,7 @@ export const DTOCreateDocumentationPageInputV2 = z.object({
|
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
export const DTOUpdateDocumentationPageInputV2 = z.object({
|
|
67
|
-
// Identifier of the
|
|
67
|
+
// Identifier of the page to update
|
|
68
68
|
id: z.string(),
|
|
69
69
|
|
|
70
70
|
// Page properties
|
|
@@ -72,6 +72,14 @@ export const DTOUpdateDocumentationPageInputV2 = z.object({
|
|
|
72
72
|
configuration: DTODocumentationItemConfigurationV2.partial().optional(),
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
+
export const DTOUpdateDocumentationPageDocumentInputV2 = z.object({
|
|
76
|
+
// Identifier of the page to update
|
|
77
|
+
id: z.string(),
|
|
78
|
+
|
|
79
|
+
// Page properties
|
|
80
|
+
documentItems: z.array(DocumentationPageContentItem),
|
|
81
|
+
});
|
|
82
|
+
|
|
75
83
|
export const DTOMoveDocumentationPageInputV2 = z.object({
|
|
76
84
|
// Identifier of the group to update
|
|
77
85
|
id: z.string(),
|
|
@@ -115,6 +123,7 @@ export const DTODocumentationPageApprovalStateChangeInput = z.object({
|
|
|
115
123
|
|
|
116
124
|
export type DTOCreateDocumentationPageInputV2 = z.infer<typeof DTOCreateDocumentationPageInputV2>;
|
|
117
125
|
export type DTOUpdateDocumentationPageInputV2 = z.infer<typeof DTOUpdateDocumentationPageInputV2>;
|
|
126
|
+
export type DTOUpdateDocumentationPageDocumentInputV2 = z.infer<typeof DTOUpdateDocumentationPageDocumentInputV2>;
|
|
118
127
|
export type DTOMoveDocumentationPageInputV2 = z.infer<typeof DTOMoveDocumentationPageInputV2>;
|
|
119
128
|
export type DTODuplicateDocumentationPageInputV2 = z.infer<typeof DTODuplicateDocumentationPageInputV2>;
|
|
120
129
|
export type DTODeleteDocumentationPageInputV2 = z.infer<typeof DTODeleteDocumentationPageInputV2>;
|
|
@@ -32,6 +32,8 @@ import {
|
|
|
32
32
|
DTODocumentationPageRestoreActionOutput,
|
|
33
33
|
DTODocumentationPageUpdateActionInputV2,
|
|
34
34
|
DTODocumentationPageUpdateActionOutputV2,
|
|
35
|
+
DTODocumentationPageUpdateDocumentActionInputV2,
|
|
36
|
+
DTODocumentationPageUpdateDocumentActionOutputV2,
|
|
35
37
|
} from "./documentation/page-actions-v2";
|
|
36
38
|
import {
|
|
37
39
|
DTOFigmaNodeRenderActionInput,
|
|
@@ -48,6 +50,7 @@ export const DTOElementActionOutput = z.discriminatedUnion("type", [
|
|
|
48
50
|
// Documentation pages
|
|
49
51
|
DTODocumentationPageCreateActionOutputV2,
|
|
50
52
|
DTODocumentationPageUpdateActionOutputV2,
|
|
53
|
+
DTODocumentationPageUpdateDocumentActionOutputV2,
|
|
51
54
|
DTODocumentationPageMoveActionOutputV2,
|
|
52
55
|
DTODocumentationPageDuplicateActionOutputV2,
|
|
53
56
|
DTODocumentationPageDeleteActionOutputV2,
|
|
@@ -84,6 +87,7 @@ export const DTOElementActionInput = z
|
|
|
84
87
|
// Documentation pages
|
|
85
88
|
DTODocumentationPageCreateActionInputV2,
|
|
86
89
|
DTODocumentationPageUpdateActionInputV2,
|
|
90
|
+
DTODocumentationPageUpdateDocumentActionInputV2,
|
|
87
91
|
DTODocumentationPageMoveActionInputV2,
|
|
88
92
|
DTODocumentationPageDuplicateActionInputV2,
|
|
89
93
|
DTODocumentationPageDeleteActionInputV2,
|
package/src/utils/index.ts
CHANGED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export const exhaustiveInvalidUriPaths = {
|
|
2
|
+
emptyPath: "",
|
|
3
|
+
spacesInPath: "/invalid path/with spaces",
|
|
4
|
+
specialCharacter1: "/path/with|invalid>characters",
|
|
5
|
+
specialCharacter2: "/path/with<invalid*characters",
|
|
6
|
+
specialCharacter3: "/path/{invalid}?characters",
|
|
7
|
+
consecutiveSlashes: "/path//with///too/many/slashes",
|
|
8
|
+
unencodedPercent: "/path/with/unencoded%percent",
|
|
9
|
+
unencodedSpaces: "/path/with unencoded spaces",
|
|
10
|
+
fragmentIdentifier: "/path/with#fragment",
|
|
11
|
+
queryParameters: "/path/with?query=parameter",
|
|
12
|
+
nullCharacter: "/path/with/\u0000nullcharacter",
|
|
13
|
+
onlySlash: "/",
|
|
14
|
+
controlCharacter: "/path/with/control\0character",
|
|
15
|
+
extremelyLongPath: "/" + "a".repeat(2047),
|
|
16
|
+
invalidStartCharacter: "///path/starting/with/slashes",
|
|
17
|
+
invalidStartCharacterColon: ":/path/starting/with/colon",
|
|
18
|
+
invalidTrailingDot: "/path/ending/with/dot.",
|
|
19
|
+
invalidPercentEncoding1: "/path/with/%2",
|
|
20
|
+
invalidPercentEncoding2: "/path/with/%ZZ",
|
|
21
|
+
invalidPercentEncoding3: "/path/with/%G1",
|
|
22
|
+
reservedCharacter1: "/path/with?<reserved>",
|
|
23
|
+
reservedCharacter2: '/path/with/"quotes"',
|
|
24
|
+
reservedCharacter3: "/path/with/[brackets]",
|
|
25
|
+
reservedCharacter4: "/path/with/\\backslashes",
|
|
26
|
+
nonAscii1: "/path/with/你好",
|
|
27
|
+
nonAscii2: "/path/with/emoji/😃",
|
|
28
|
+
mixedEncodingPath: "/path/%41A%42B%C3%28",
|
|
29
|
+
directoryTraversal1: "/path/../../etc/passwd",
|
|
30
|
+
directoryTraversal2: "/path/./././",
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
type ValidationErrorReason = "TooLong" | "InvalidURI" | "Empty" | "ContainsQuery" | "ContainsFragment";
|
|
34
|
+
|
|
35
|
+
export function isValidRedirectPath(path: string): { isValid: boolean; reason: ValidationErrorReason | undefined } {
|
|
36
|
+
const trimmedPath = path.toLowerCase().trim();
|
|
37
|
+
const url = "https://www.example.com" + trimmedPath;
|
|
38
|
+
if (url.length > 2048) {
|
|
39
|
+
return {
|
|
40
|
+
isValid: false,
|
|
41
|
+
reason: "TooLong",
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if (trimmedPath === "") {
|
|
45
|
+
return {
|
|
46
|
+
isValid: false,
|
|
47
|
+
reason: "Empty",
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (url === "/") {
|
|
51
|
+
return {
|
|
52
|
+
isValid: false,
|
|
53
|
+
reason: "Empty",
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (url.includes("?")) {
|
|
58
|
+
return {
|
|
59
|
+
isValid: false,
|
|
60
|
+
reason: "ContainsQuery",
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (url.includes("#")) {
|
|
64
|
+
return {
|
|
65
|
+
isValid: false,
|
|
66
|
+
reason: "ContainsFragment",
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const regex = /^\/[A-Za-z0-9_-]+(\/[A-Za-z0-9_-]+)*$/;
|
|
71
|
+
const isValid = regex.test(trimmedPath);
|
|
72
|
+
return {
|
|
73
|
+
isValid: regex.test(trimmedPath),
|
|
74
|
+
reason: !isValid ? "InvalidURI" : undefined,
|
|
75
|
+
};
|
|
76
|
+
}
|