@cntrl-site/sdk 1.25.9 → 1.25.11-components.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/lib/Client/Client.d.ts +4 -0
- package/lib/Client/Client.js +30 -0
- package/lib/Rect/Rect.js +5 -3
- package/lib/index.d.ts +1 -0
- package/lib/schemas/article/FillLayer.schema.d.ts +0 -15
- package/lib/schemas/article/FillLayer.schema.js +3 -8
- package/lib/schemas/article/Item.schema.js +2 -1
- package/lib/schemas/article/ItemState.schema.d.ts +0 -210
- package/lib/schemas/keyframe/Keyframes.schema.d.ts +0 -100
- package/lib/types/article/Item.d.ts +1 -5
- package/lib/types/customComponent/CustomComponentMeta.d.ts +5 -0
- package/lib/types/customComponent/CustomComponentMeta.js +2 -0
- package/package.json +2 -1
package/lib/Client/Client.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Project } from '../types/project/Project';
|
|
|
3
3
|
import { Layout } from '../types/project/Layout';
|
|
4
4
|
import { Article } from '../types/article/Article';
|
|
5
5
|
import { KeyframeAny } from '../types/keyframe/Keyframe';
|
|
6
|
+
import { CustomComponentMeta } from '../types/customComponent/CustomComponentMeta';
|
|
6
7
|
export declare class Client {
|
|
7
8
|
private fetchImpl;
|
|
8
9
|
private url;
|
|
@@ -11,6 +12,8 @@ export declare class Client {
|
|
|
11
12
|
getPageData(pageSlug: string, buildMode?: 'default' | 'self-hosted'): Promise<CntrlPageData>;
|
|
12
13
|
getProjectPagesPaths(): Promise<string[]>;
|
|
13
14
|
getLayouts(): Promise<Layout[]>;
|
|
15
|
+
fetchCustomComponents(buildMode?: 'default' | 'self-hosted'): Promise<CustomComponentMeta[]>;
|
|
16
|
+
fetchCustomComponentBundle(componentId: string, buildMode?: 'default' | 'self-hosted'): Promise<string>;
|
|
14
17
|
private fetchProject;
|
|
15
18
|
private fetchArticle;
|
|
16
19
|
private findArticleIdByPageSlug;
|
|
@@ -18,6 +21,7 @@ export declare class Client {
|
|
|
18
21
|
interface FetchImplResponse {
|
|
19
22
|
ok: boolean;
|
|
20
23
|
json(): Promise<any>;
|
|
24
|
+
text(): Promise<string>;
|
|
21
25
|
statusText: string;
|
|
22
26
|
}
|
|
23
27
|
type FetchImpl = (url: string, init?: RequestInit) => Promise<FetchImplResponse>;
|
package/lib/Client/Client.js
CHANGED
|
@@ -81,6 +81,36 @@ class Client {
|
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
|
+
fetchCustomComponents() {
|
|
85
|
+
return __awaiter(this, arguments, void 0, function* (buildMode = 'default') {
|
|
86
|
+
const { username: projectId, password: apiKey, origin } = this.url;
|
|
87
|
+
const url = new url_1.URL(`/projects/${projectId}/custom-components?buildMode=${buildMode}`, origin);
|
|
88
|
+
const response = yield this.fetchImpl(url.href, {
|
|
89
|
+
headers: {
|
|
90
|
+
Authorization: `Bearer ${apiKey}`
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
if (!response.ok) {
|
|
94
|
+
throw new Error(`Failed to fetch custom components for project #${projectId}: ${response.statusText}`);
|
|
95
|
+
}
|
|
96
|
+
return response.json();
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
fetchCustomComponentBundle(componentId_1) {
|
|
100
|
+
return __awaiter(this, arguments, void 0, function* (componentId, buildMode = 'default') {
|
|
101
|
+
const { username: projectId, password: apiKey, origin } = this.url;
|
|
102
|
+
const url = new url_1.URL(`/projects/${projectId}/custom-components/${componentId}/bundle.js?buildMode=${buildMode}`, origin);
|
|
103
|
+
const response = yield this.fetchImpl(url.href, {
|
|
104
|
+
headers: {
|
|
105
|
+
Authorization: `Bearer ${apiKey}`
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
if (!response.ok) {
|
|
109
|
+
throw new Error(`Failed to fetch bundle for custom component #${componentId}: ${response.statusText}`);
|
|
110
|
+
}
|
|
111
|
+
return response.text();
|
|
112
|
+
});
|
|
113
|
+
}
|
|
84
114
|
fetchProject() {
|
|
85
115
|
return __awaiter(this, arguments, void 0, function* (buildMode = 'default') {
|
|
86
116
|
const { username: projectId, password: apiKey, origin } = this.url;
|
package/lib/Rect/Rect.js
CHANGED
|
@@ -185,9 +185,11 @@ class Rect {
|
|
|
185
185
|
}
|
|
186
186
|
static getNormalizedFactor(factor) {
|
|
187
187
|
const EPSILON = 1e-10;
|
|
188
|
-
return factor === 0
|
|
189
|
-
|
|
190
|
-
|
|
188
|
+
return factor === 0
|
|
189
|
+
? EPSILON
|
|
190
|
+
: factor === Infinity
|
|
191
|
+
? 1 / EPSILON
|
|
192
|
+
: factor;
|
|
191
193
|
}
|
|
192
194
|
}
|
|
193
195
|
exports.Rect = Rect;
|
package/lib/index.d.ts
CHANGED
|
@@ -21,3 +21,4 @@ export type { Meta } from './types/project/Meta';
|
|
|
21
21
|
export type { KeyframeValueMap, KeyframeAny } from './types/keyframe/Keyframe';
|
|
22
22
|
export type { CompoundSettings } from './types/article/CompoundSettings';
|
|
23
23
|
export type { Dimensions, Left, Position, RectCoordinates, RectObject, ScaleOrigin, Sides, Top } from './types/article/Rect';
|
|
24
|
+
export type { CustomComponentMeta } from './types/customComponent/CustomComponentMeta';
|
|
@@ -16,17 +16,14 @@ export declare const FillLayerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
16
16
|
id: z.ZodString;
|
|
17
17
|
type: z.ZodLiteral<"solid">;
|
|
18
18
|
value: z.ZodString;
|
|
19
|
-
blendMode: z.ZodString;
|
|
20
19
|
}, "strip", z.ZodTypeAny, {
|
|
21
20
|
id: string;
|
|
22
21
|
value: string;
|
|
23
22
|
type: "solid";
|
|
24
|
-
blendMode: string;
|
|
25
23
|
}, {
|
|
26
24
|
id: string;
|
|
27
25
|
value: string;
|
|
28
26
|
type: "solid";
|
|
29
|
-
blendMode: string;
|
|
30
27
|
}>, z.ZodObject<{
|
|
31
28
|
id: z.ZodString;
|
|
32
29
|
type: z.ZodLiteral<"linear-gradient">;
|
|
@@ -46,11 +43,9 @@ export declare const FillLayerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
46
43
|
start: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
47
44
|
end: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
48
45
|
angle: z.ZodNumber;
|
|
49
|
-
blendMode: z.ZodString;
|
|
50
46
|
}, "strip", z.ZodTypeAny, {
|
|
51
47
|
id: string;
|
|
52
48
|
type: "linear-gradient";
|
|
53
|
-
blendMode: string;
|
|
54
49
|
colors: {
|
|
55
50
|
position: number;
|
|
56
51
|
id: string;
|
|
@@ -62,7 +57,6 @@ export declare const FillLayerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
62
57
|
}, {
|
|
63
58
|
id: string;
|
|
64
59
|
type: "linear-gradient";
|
|
65
|
-
blendMode: string;
|
|
66
60
|
colors: {
|
|
67
61
|
position: number;
|
|
68
62
|
id: string;
|
|
@@ -90,12 +84,10 @@ export declare const FillLayerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
90
84
|
center: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
91
85
|
diameter: z.ZodNumber;
|
|
92
86
|
angle: z.ZodNumber;
|
|
93
|
-
blendMode: z.ZodString;
|
|
94
87
|
}, "strip", z.ZodTypeAny, {
|
|
95
88
|
center: [number, number];
|
|
96
89
|
id: string;
|
|
97
90
|
type: "radial-gradient";
|
|
98
|
-
blendMode: string;
|
|
99
91
|
colors: {
|
|
100
92
|
position: number;
|
|
101
93
|
id: string;
|
|
@@ -107,7 +99,6 @@ export declare const FillLayerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
107
99
|
center: [number, number];
|
|
108
100
|
id: string;
|
|
109
101
|
type: "radial-gradient";
|
|
110
|
-
blendMode: string;
|
|
111
102
|
colors: {
|
|
112
103
|
position: number;
|
|
113
104
|
id: string;
|
|
@@ -133,12 +124,10 @@ export declare const FillLayerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
133
124
|
}>, "many">;
|
|
134
125
|
center: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
135
126
|
angle: z.ZodNumber;
|
|
136
|
-
blendMode: z.ZodString;
|
|
137
127
|
}, "strip", z.ZodTypeAny, {
|
|
138
128
|
center: [number, number];
|
|
139
129
|
id: string;
|
|
140
130
|
type: "conic-gradient";
|
|
141
|
-
blendMode: string;
|
|
142
131
|
colors: {
|
|
143
132
|
position: number;
|
|
144
133
|
id: string;
|
|
@@ -149,7 +138,6 @@ export declare const FillLayerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
149
138
|
center: [number, number];
|
|
150
139
|
id: string;
|
|
151
140
|
type: "conic-gradient";
|
|
152
|
-
blendMode: string;
|
|
153
141
|
colors: {
|
|
154
142
|
position: number;
|
|
155
143
|
id: string;
|
|
@@ -163,13 +151,11 @@ export declare const FillLayerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
163
151
|
behavior: z.ZodString;
|
|
164
152
|
backgroundSize: z.ZodNumber;
|
|
165
153
|
opacity: z.ZodNumber;
|
|
166
|
-
blendMode: z.ZodString;
|
|
167
154
|
rotation: z.ZodOptional<z.ZodNumber>;
|
|
168
155
|
}, "strip", z.ZodTypeAny, {
|
|
169
156
|
opacity: number;
|
|
170
157
|
id: string;
|
|
171
158
|
type: "image";
|
|
172
|
-
blendMode: string;
|
|
173
159
|
src: string;
|
|
174
160
|
behavior: string;
|
|
175
161
|
backgroundSize: number;
|
|
@@ -178,7 +164,6 @@ export declare const FillLayerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
178
164
|
opacity: number;
|
|
179
165
|
id: string;
|
|
180
166
|
type: "image";
|
|
181
|
-
blendMode: string;
|
|
182
167
|
src: string;
|
|
183
168
|
behavior: string;
|
|
184
169
|
backgroundSize: number;
|
|
@@ -12,7 +12,6 @@ exports.FillLayerSchema = zod_1.z.discriminatedUnion('type', [
|
|
|
12
12
|
id: zod_1.z.string(),
|
|
13
13
|
type: zod_1.z.literal('solid'),
|
|
14
14
|
value: zod_1.z.string(),
|
|
15
|
-
blendMode: zod_1.z.string()
|
|
16
15
|
}),
|
|
17
16
|
zod_1.z.object({
|
|
18
17
|
id: zod_1.z.string(),
|
|
@@ -20,8 +19,7 @@ exports.FillLayerSchema = zod_1.z.discriminatedUnion('type', [
|
|
|
20
19
|
colors: zod_1.z.array(exports.ColorPointSchema),
|
|
21
20
|
start: zod_1.z.tuple([zod_1.z.number(), zod_1.z.number()]),
|
|
22
21
|
end: zod_1.z.tuple([zod_1.z.number(), zod_1.z.number()]),
|
|
23
|
-
angle: zod_1.z.number()
|
|
24
|
-
blendMode: zod_1.z.string()
|
|
22
|
+
angle: zod_1.z.number()
|
|
25
23
|
}),
|
|
26
24
|
zod_1.z.object({
|
|
27
25
|
id: zod_1.z.string(),
|
|
@@ -29,16 +27,14 @@ exports.FillLayerSchema = zod_1.z.discriminatedUnion('type', [
|
|
|
29
27
|
colors: zod_1.z.array(exports.ColorPointSchema),
|
|
30
28
|
center: zod_1.z.tuple([zod_1.z.number(), zod_1.z.number()]),
|
|
31
29
|
diameter: zod_1.z.number(),
|
|
32
|
-
angle: zod_1.z.number()
|
|
33
|
-
blendMode: zod_1.z.string()
|
|
30
|
+
angle: zod_1.z.number()
|
|
34
31
|
}),
|
|
35
32
|
zod_1.z.object({
|
|
36
33
|
id: zod_1.z.string(),
|
|
37
34
|
type: zod_1.z.literal('conic-gradient'),
|
|
38
35
|
colors: zod_1.z.array(exports.ColorPointSchema),
|
|
39
36
|
center: zod_1.z.tuple([zod_1.z.number(), zod_1.z.number()]),
|
|
40
|
-
angle: zod_1.z.number()
|
|
41
|
-
blendMode: zod_1.z.string()
|
|
37
|
+
angle: zod_1.z.number()
|
|
42
38
|
}),
|
|
43
39
|
zod_1.z.object({
|
|
44
40
|
id: zod_1.z.string(),
|
|
@@ -47,7 +43,6 @@ exports.FillLayerSchema = zod_1.z.discriminatedUnion('type', [
|
|
|
47
43
|
behavior: zod_1.z.string(),
|
|
48
44
|
backgroundSize: zod_1.z.number(),
|
|
49
45
|
opacity: zod_1.z.number(),
|
|
50
|
-
blendMode: zod_1.z.string(),
|
|
51
46
|
rotation: zod_1.z.number().optional()
|
|
52
47
|
})
|
|
53
48
|
]);
|
|
@@ -191,7 +191,8 @@ const ComponentItemSchema = ItemBase_schema_1.ItemBaseSchema.extend({
|
|
|
191
191
|
type: zod_1.z.literal(ArticleItemType_1.ArticleItemType.Component),
|
|
192
192
|
commonParams: zod_1.z.object({
|
|
193
193
|
componentId: zod_1.z.string(),
|
|
194
|
-
content: zod_1.z.any().optional()
|
|
194
|
+
content: zod_1.z.any().optional(),
|
|
195
|
+
parameters: zod_1.z.record(zod_1.z.any()).optional()
|
|
195
196
|
}),
|
|
196
197
|
sticky: zod_1.z.record(zod_1.z.object({
|
|
197
198
|
from: zod_1.z.number(),
|