@supernova-studio/client 0.57.20 → 0.58.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/dist/index.d.mts +150 -1103
- package/dist/index.d.ts +150 -1103
- package/dist/index.js +63 -58
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +948 -943
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/dto/aux/color.ts +7 -0
- package/src/api/dto/aux/index.ts +2 -0
- package/src/api/dto/aux/meta.ts +8 -0
- package/src/api/dto/elements/elements-action-v2.ts +0 -18
- package/src/api/dto/elements/properties/index.ts +0 -1
- package/src/api/dto/elements/properties/property-definitions.ts +22 -16
- package/src/api/endpoints/design-system/versions/property-definitions.ts +18 -0
- package/src/api/transport/request-executor.ts +4 -1
- package/src/api/dto/elements/properties/property-definitions-actions-v2.ts +0 -53
package/package.json
CHANGED
package/src/api/dto/aux/index.ts
CHANGED
|
@@ -34,14 +34,6 @@ import {
|
|
|
34
34
|
DTODocumentationPageUpdateActionOutputV2,
|
|
35
35
|
} from "./documentation/page-actions-v2";
|
|
36
36
|
import { DTOFigmaNodeRenderActionInput, DTOFigmaNodeRenderActionOutput } from "./figma-nodes/node-actions-v2";
|
|
37
|
-
import {
|
|
38
|
-
DTOPropertyDefinitionCreateActionInputV2,
|
|
39
|
-
DTOPropertyDefinitionCreateActionOutputV2,
|
|
40
|
-
DTOPropertyDefinitionDeleteActionInputV2,
|
|
41
|
-
DTOPropertyDefinitionDeleteActionOutputV2,
|
|
42
|
-
DTOPropertyDefinitionUpdateActionInputV2,
|
|
43
|
-
DTOPropertyDefinitionUpdateActionOutputV2,
|
|
44
|
-
} from "./properties/property-definitions-actions-v2";
|
|
45
37
|
|
|
46
38
|
//
|
|
47
39
|
// Read
|
|
@@ -67,11 +59,6 @@ export const DTOElementActionOutput = z.discriminatedUnion("type", [
|
|
|
67
59
|
// Figma frames
|
|
68
60
|
DTOFigmaNodeRenderActionOutput,
|
|
69
61
|
|
|
70
|
-
// Properties Definitions
|
|
71
|
-
DTOPropertyDefinitionCreateActionOutputV2,
|
|
72
|
-
DTOPropertyDefinitionUpdateActionOutputV2,
|
|
73
|
-
DTOPropertyDefinitionDeleteActionOutputV2,
|
|
74
|
-
|
|
75
62
|
// Restore
|
|
76
63
|
DTODocumentationPageRestoreActionOutput,
|
|
77
64
|
DTODocumentationGroupRestoreActionOutput,
|
|
@@ -106,11 +93,6 @@ export const DTOElementActionInput = z.discriminatedUnion("type", [
|
|
|
106
93
|
// Figma frames
|
|
107
94
|
DTOFigmaNodeRenderActionInput,
|
|
108
95
|
|
|
109
|
-
// Properties Definitions
|
|
110
|
-
DTOPropertyDefinitionCreateActionInputV2,
|
|
111
|
-
DTOPropertyDefinitionUpdateActionInputV2,
|
|
112
|
-
DTOPropertyDefinitionDeleteActionInputV2,
|
|
113
|
-
|
|
114
96
|
// Restore
|
|
115
97
|
DTODocumentationPageRestoreActionInput,
|
|
116
98
|
DTODocumentationGroupRestoreActionInput,
|
|
@@ -1,28 +1,35 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ElementPropertyDefinitionOption,
|
|
3
2
|
ElementPropertyLinkType,
|
|
4
3
|
ElementPropertyTargetType,
|
|
5
4
|
ElementPropertyTypeSchema,
|
|
6
5
|
nullishToOptional,
|
|
7
|
-
ObjectMeta,
|
|
8
6
|
} from "@supernova-studio/model";
|
|
9
7
|
import { z } from "zod";
|
|
8
|
+
import { DTOColorTokenInlineData } from "../../aux";
|
|
9
|
+
import { DTOObjectMeta } from "../../aux/meta";
|
|
10
10
|
|
|
11
11
|
const CODE_NAME_REGEX = /^[a-zA-Z_$][a-zA-Z_$0-9]{1,99}$/;
|
|
12
12
|
|
|
13
|
+
export const DTOElementPropertyDefinitionOption = z.object({
|
|
14
|
+
id: z.string(),
|
|
15
|
+
name: z.string(),
|
|
16
|
+
backgroundColor: DTOColorTokenInlineData.optional(),
|
|
17
|
+
});
|
|
18
|
+
|
|
13
19
|
// DTO Object
|
|
14
20
|
export const DTOElementPropertyDefinition = z.object({
|
|
15
21
|
id: z.string(),
|
|
16
22
|
designSystemVersionId: z.string(),
|
|
17
|
-
meta:
|
|
23
|
+
meta: DTOObjectMeta,
|
|
18
24
|
persistentId: z.string(),
|
|
19
25
|
type: ElementPropertyTypeSchema,
|
|
20
26
|
targetElementType: ElementPropertyTargetType,
|
|
21
27
|
codeName: z.string().regex(CODE_NAME_REGEX),
|
|
22
|
-
options: nullishToOptional(z.array(
|
|
28
|
+
options: nullishToOptional(z.array(DTOElementPropertyDefinitionOption)),
|
|
23
29
|
linkElementType: nullishToOptional(ElementPropertyLinkType),
|
|
24
30
|
});
|
|
25
31
|
|
|
32
|
+
export type DTOElementPropertyDefinitionOption = z.infer<typeof DTOElementPropertyDefinitionOption>;
|
|
26
33
|
export type DTOElementPropertyDefinition = z.infer<typeof DTOElementPropertyDefinition>;
|
|
27
34
|
|
|
28
35
|
//
|
|
@@ -44,23 +51,22 @@ export type DTOElementPropertyDefinitionResponse = z.infer<typeof DTOElementProp
|
|
|
44
51
|
// Write
|
|
45
52
|
//
|
|
46
53
|
|
|
47
|
-
export const DTOElementPropertyDefinitionCreatePayload =
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
export const DTOElementPropertyDefinitionCreatePayload = z.object({
|
|
55
|
+
meta: DTOObjectMeta,
|
|
56
|
+
persistentId: z.string(),
|
|
57
|
+
type: ElementPropertyTypeSchema,
|
|
58
|
+
targetElementType: ElementPropertyTargetType,
|
|
59
|
+
codeName: z.string().regex(CODE_NAME_REGEX),
|
|
60
|
+
options: nullishToOptional(z.array(DTOElementPropertyDefinitionOption)),
|
|
61
|
+
linkElementType: nullishToOptional(ElementPropertyLinkType),
|
|
62
|
+
columnWidth: z.number().max(1024).optional(),
|
|
50
63
|
});
|
|
51
64
|
|
|
52
65
|
export const DTOElementPropertyDefinitionUpdatePayload = z.object({
|
|
53
|
-
|
|
54
|
-
name: z.string().optional(),
|
|
55
|
-
description: z.string().optional(),
|
|
66
|
+
meta: DTOObjectMeta.optional(),
|
|
56
67
|
codeName: z.string().regex(CODE_NAME_REGEX).optional(),
|
|
57
|
-
options: z.array(
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
export const DTOElementPropertyDefinitionDeletePayload = z.object({
|
|
61
|
-
id: z.string(),
|
|
68
|
+
options: z.array(DTOElementPropertyDefinitionOption).optional(),
|
|
62
69
|
});
|
|
63
70
|
|
|
64
71
|
export type DTOElementPropertyDefinitionCreatePayload = z.infer<typeof DTOElementPropertyDefinitionCreatePayload>;
|
|
65
72
|
export type DTOElementPropertyDefinitionUpdatePayload = z.infer<typeof DTOElementPropertyDefinitionUpdatePayload>;
|
|
66
|
-
export type DTOElementPropertyDefinitionDeletePayload = z.infer<typeof DTOElementPropertyDefinitionDeletePayload>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
1
2
|
import {
|
|
2
3
|
DTOElementPropertyDefinitionCreatePayload,
|
|
3
4
|
DTOElementPropertyDefinitionListResponse,
|
|
4
5
|
DTOElementPropertyDefinitionResponse,
|
|
6
|
+
DTOElementPropertyDefinitionUpdatePayload,
|
|
5
7
|
} from "../../../dto";
|
|
6
8
|
import { RequestExecutor } from "../../../transport/request-executor";
|
|
7
9
|
|
|
@@ -22,4 +24,20 @@ export class ElementPropertyDefinitionsEndpoint {
|
|
|
22
24
|
{ method: "POST", body }
|
|
23
25
|
);
|
|
24
26
|
}
|
|
27
|
+
|
|
28
|
+
update(designSystemId: string, versionId: string, defId: string, body: DTOElementPropertyDefinitionUpdatePayload) {
|
|
29
|
+
return this.requestExecutor.json(
|
|
30
|
+
`/design-systems/${designSystemId}/versions/${versionId}/element-properties/definitions/${defId}`,
|
|
31
|
+
DTOElementPropertyDefinitionResponse,
|
|
32
|
+
{ method: "PUT", body }
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
delete(designSystemId: string, versionId: string, defId: string) {
|
|
37
|
+
return this.requestExecutor.json(
|
|
38
|
+
`/design-systems/${designSystemId}/versions/${versionId}/element-properties/definitions/${defId}`,
|
|
39
|
+
z.any(),
|
|
40
|
+
{ method: "DELETE" }
|
|
41
|
+
);
|
|
42
|
+
}
|
|
25
43
|
}
|
|
@@ -58,8 +58,11 @@ export class RequestExecutor {
|
|
|
58
58
|
throw RequestExecutorError.serverError(endpoint, response.status, bodyString);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
const
|
|
61
|
+
const json = await response.json();
|
|
62
|
+
const wrapperParseResult = ResponseWrapper.safeParse(json);
|
|
62
63
|
if (!wrapperParseResult.success) {
|
|
64
|
+
console.error(`Response was:`);
|
|
65
|
+
console.error(json);
|
|
63
66
|
throw RequestExecutorError.responseParsingError(endpoint, wrapperParseResult.error);
|
|
64
67
|
}
|
|
65
68
|
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
DTOElementPropertyDefinition,
|
|
4
|
-
DTOElementPropertyDefinitionCreatePayload,
|
|
5
|
-
DTOElementPropertyDefinitionDeletePayload,
|
|
6
|
-
DTOElementPropertyDefinitionUpdatePayload,
|
|
7
|
-
} from "./property-definitions";
|
|
8
|
-
|
|
9
|
-
// Outputs
|
|
10
|
-
|
|
11
|
-
const SuccessPayload = z.object({
|
|
12
|
-
success: z.literal(true),
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export const DTOPropertyDefinitionCreateActionOutputV2 = z.object({
|
|
16
|
-
type: z.literal("PropertyDefinitionCreate"),
|
|
17
|
-
definition: DTOElementPropertyDefinition,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export const DTOPropertyDefinitionUpdateActionOutputV2 = z.object({
|
|
21
|
-
type: z.literal("PropertyDefinitionUpdate"),
|
|
22
|
-
definition: DTOElementPropertyDefinition,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
export const DTOPropertyDefinitionDeleteActionOutputV2 = z.object({
|
|
26
|
-
type: z.literal("PropertyDefinitionDelete"),
|
|
27
|
-
output: SuccessPayload,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
export type DTOPropertyDefinitionCreateActionOutputV2 = z.infer<typeof DTOPropertyDefinitionCreateActionOutputV2>;
|
|
31
|
-
export type DTOPropertyDefinitionUpdateActionOutputV2 = z.infer<typeof DTOPropertyDefinitionUpdateActionOutputV2>;
|
|
32
|
-
export type DTOPropertyDefinitionDeleteActionOutputV2 = z.infer<typeof DTOPropertyDefinitionDeleteActionOutputV2>;
|
|
33
|
-
|
|
34
|
-
// Inputs
|
|
35
|
-
|
|
36
|
-
export const DTOPropertyDefinitionCreateActionInputV2 = z.object({
|
|
37
|
-
type: z.literal("PropertyDefinitionCreate"),
|
|
38
|
-
input: DTOElementPropertyDefinitionCreatePayload,
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
export const DTOPropertyDefinitionUpdateActionInputV2 = z.object({
|
|
42
|
-
type: z.literal("PropertyDefinitionUpdate"),
|
|
43
|
-
input: DTOElementPropertyDefinitionUpdatePayload,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
export const DTOPropertyDefinitionDeleteActionInputV2 = z.object({
|
|
47
|
-
type: z.literal("PropertyDefinitionDelete"),
|
|
48
|
-
input: DTOElementPropertyDefinitionDeletePayload,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
export type DTOPropertyDefinitionCreateActionInputV2 = z.infer<typeof DTOPropertyDefinitionCreateActionInputV2>;
|
|
52
|
-
export type DTOPropertyDefinitionUpdateActionInputV2 = z.infer<typeof DTOPropertyDefinitionUpdateActionInputV2>;
|
|
53
|
-
export type DTOPropertyDefinitionDeleteActionInputV2 = z.infer<typeof DTOPropertyDefinitionDeleteActionInputV2>;
|