@charisol/plexo-sdk 2.0.22 → 2.0.24
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/{InlineColorPicker-BaWBhgH4.js → InlineColorPicker-x6ODuEQD.js} +554 -321
- package/dist/{lint-CV3DmM0X.js → brandGuide-DgoZ7spo.js} +109 -78
- package/dist/{client-4pKkAJ3Y.js → client-DUSU8g5z.js} +121 -99
- package/dist/index.js +13198 -13275
- package/dist/plexo-sdk.css +1 -1
- package/dist/utilities/playground.interfaces.d.ts +2 -1
- package/dist/{v1-CBDSeo-a.js → v1--XVVNQh9.js} +2171 -2170
- package/dist/v2/components/design/AssetsView.d.ts +7 -0
- package/dist/v2/components/design/BrandGuideCard.d.ts +6 -0
- package/dist/v2/components/design/ReviewView.d.ts +1 -1
- package/dist/v2/components/design/StrataCard.d.ts +1 -0
- package/dist/v2/components/design/useStrataSync.d.ts +4 -0
- package/dist/v2/components/fonts/FontPicker.d.ts +2 -6
- package/dist/v2/sol/describe.d.ts +2 -0
- package/dist/v2/sol/prompt.d.ts +1 -1
- package/dist/v2/strata/brandGuide.d.ts +7 -0
- package/dist/v2/strata/client.d.ts +12 -1
- package/dist/v2/strata/index.d.ts +1 -0
- package/dist/v2/strata/types.d.ts +23 -0
- package/dist/v2-compile.js +2 -2
- package/dist/v2-strata.js +3 -2
- package/dist/v2.js +3368 -2895
- package/package.json +1 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as e, g as t } from "./brandGuide-DgoZ7spo.js";
|
|
2
2
|
//#region src/v2/strata/merge.ts
|
|
3
|
-
function
|
|
4
|
-
return Array.isArray(e) ? `[${e.map(
|
|
3
|
+
function n(e) {
|
|
4
|
+
return Array.isArray(e) ? `[${e.map(n).join(",")}]` : e && typeof e == "object" ? `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${n(e[t])}`).join(",")}}` : JSON.stringify(e);
|
|
5
5
|
}
|
|
6
|
-
var
|
|
6
|
+
var r = (e) => `${e.value}|${e.unit ?? ""}|${e.layer}|${e.type}`, i = (e) => e.name, a = (e) => n({
|
|
7
7
|
props: e.props ?? {},
|
|
8
8
|
nodes: e.nodes ?? []
|
|
9
9
|
});
|
|
10
|
-
function
|
|
10
|
+
function o(e) {
|
|
11
11
|
return {
|
|
12
|
-
tokens: Object.fromEntries(e.tokens.map((e) => [e.key,
|
|
13
|
-
components: Object.fromEntries(e.components.map((e) => [
|
|
12
|
+
tokens: Object.fromEntries(e.tokens.map((e) => [e.key, r(e)])),
|
|
13
|
+
components: Object.fromEntries(e.components.map((e) => [i(e), a(e)]))
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
let
|
|
16
|
+
function s(e, n) {
|
|
17
|
+
let o = e.strata?.base, s = !o, c = new Map(e.tokens.map((e) => [e.key, e])), l = new Map(n.tokens.map((e) => [e.key, e])), u = {
|
|
18
18
|
incoming: [],
|
|
19
19
|
outgoing: [],
|
|
20
20
|
conflicts: [],
|
|
@@ -22,73 +22,73 @@ function o(e, t) {
|
|
|
22
22
|
removedLocally: [],
|
|
23
23
|
same: 0
|
|
24
24
|
};
|
|
25
|
-
for (let e of /* @__PURE__ */ new Set([...
|
|
26
|
-
let
|
|
25
|
+
for (let e of /* @__PURE__ */ new Set([...c.keys(), ...l.keys()])) {
|
|
26
|
+
let n = c.get(e), i = l.get(e), a = o?.tokens[e], d = {
|
|
27
27
|
key: e,
|
|
28
|
-
local:
|
|
29
|
-
remote:
|
|
28
|
+
local: n,
|
|
29
|
+
remote: i
|
|
30
30
|
};
|
|
31
|
-
if (
|
|
32
|
-
if (n(t) ===
|
|
33
|
-
|
|
31
|
+
if (n && i) {
|
|
32
|
+
if (r(n) === r(i) || t(n) === t(i) && n.value === i.value) {
|
|
33
|
+
u.same += 1;
|
|
34
34
|
continue;
|
|
35
35
|
}
|
|
36
|
-
if (
|
|
37
|
-
|
|
36
|
+
if (s) {
|
|
37
|
+
u.conflicts.push(d);
|
|
38
38
|
continue;
|
|
39
39
|
}
|
|
40
|
-
let e = n
|
|
41
|
-
e &&
|
|
42
|
-
} else
|
|
40
|
+
let e = r(n) !== a, o = r(i) !== a;
|
|
41
|
+
e && o ? u.conflicts.push(d) : o ? u.incoming.push(d) : e ? u.outgoing.push(d) : u.same += 1;
|
|
42
|
+
} else n && !i ? a !== void 0 && !s ? (r(n) === a ? u.removedRemotely : u.conflicts).push(d) : u.outgoing.push(d) : i && !n && (a !== void 0 && !s ? (r(i) === a ? u.removedLocally : u.conflicts).push(d) : u.incoming.push(d));
|
|
43
43
|
}
|
|
44
|
-
let
|
|
44
|
+
let d = new Map(e.components.map((e) => [i(e), e])), f = new Map(n.components.map((e) => [i(e), e])), p = {
|
|
45
45
|
incoming: [],
|
|
46
46
|
outgoing: [],
|
|
47
47
|
conflicts: [],
|
|
48
48
|
same: 0
|
|
49
49
|
};
|
|
50
|
-
for (let e of /* @__PURE__ */ new Set([...
|
|
51
|
-
let t =
|
|
50
|
+
for (let e of /* @__PURE__ */ new Set([...d.keys(), ...f.keys()])) {
|
|
51
|
+
let t = d.get(e), n = f.get(e), r = o?.components[e], i = t ?? n, c = {
|
|
52
52
|
id: e,
|
|
53
|
-
name:
|
|
54
|
-
variant:
|
|
53
|
+
name: i.name,
|
|
54
|
+
variant: i.variant,
|
|
55
55
|
local: t,
|
|
56
56
|
remote: n
|
|
57
57
|
};
|
|
58
58
|
if (t && n) {
|
|
59
|
-
if (
|
|
60
|
-
|
|
59
|
+
if (a(t) === a(n)) {
|
|
60
|
+
p.same += 1;
|
|
61
61
|
continue;
|
|
62
62
|
}
|
|
63
|
-
if (
|
|
64
|
-
|
|
63
|
+
if (s) {
|
|
64
|
+
p.conflicts.push(c);
|
|
65
65
|
continue;
|
|
66
66
|
}
|
|
67
|
-
let e =
|
|
68
|
-
e &&
|
|
69
|
-
} else t ?
|
|
67
|
+
let e = a(t) !== r, i = a(n) !== r;
|
|
68
|
+
e && i ? p.conflicts.push(c) : i ? p.incoming.push(c) : e ? p.outgoing.push(c) : p.same += 1;
|
|
69
|
+
} else t ? p.outgoing.push(c) : p.incoming.push(c);
|
|
70
70
|
}
|
|
71
71
|
return {
|
|
72
|
-
firstSync:
|
|
73
|
-
tokens:
|
|
74
|
-
components:
|
|
72
|
+
firstSync: s,
|
|
73
|
+
tokens: u,
|
|
74
|
+
components: p
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
|
-
var
|
|
78
|
-
function
|
|
77
|
+
var c = (e) => e.tokens.incoming.length + e.tokens.outgoing.length + e.tokens.conflicts.length + e.tokens.removedRemotely.length + e.tokens.removedLocally.length + e.components.incoming.length + e.components.outgoing.length + e.components.conflicts.length > 0;
|
|
78
|
+
function l(e) {
|
|
79
79
|
return {
|
|
80
80
|
incoming: e.tokens.incoming.length + e.tokens.removedRemotely.length + e.components.incoming.length,
|
|
81
81
|
outgoing: e.tokens.outgoing.length + e.tokens.removedLocally.length + e.components.outgoing.length,
|
|
82
82
|
conflicts: e.tokens.conflicts.length + e.components.conflicts.length
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
var
|
|
85
|
+
var u = (e) => {
|
|
86
86
|
let { id: t, createdAt: n, updatedAt: r, ...i } = e;
|
|
87
87
|
return i;
|
|
88
88
|
};
|
|
89
|
-
function
|
|
90
|
-
let
|
|
91
|
-
if (
|
|
89
|
+
function d(t, n, o, s, c = {}, l) {
|
|
90
|
+
let d = s !== "push", p = s !== "pull", m = (e) => c[e] ?? "strata", h = new Map(t.tokens.map((e) => [e.key, e])), g = [], _ = [];
|
|
91
|
+
if (d) {
|
|
92
92
|
for (let e of o.tokens.incoming) e.remote && h.set(e.key, e.remote);
|
|
93
93
|
for (let e of o.tokens.removedRemotely) h.delete(e.key);
|
|
94
94
|
}
|
|
@@ -98,28 +98,28 @@ function u(t, a, o, s, c = {}, u) {
|
|
|
98
98
|
}
|
|
99
99
|
for (let e of o.tokens.conflicts) {
|
|
100
100
|
let t = m(e.key);
|
|
101
|
-
t === "strata" &&
|
|
101
|
+
t === "strata" && d ? e.remote ? h.set(e.key, e.remote) : h.delete(e.key) : t === "plexo" && p && (e.local ? g.push(e.local) : _.push(e.key));
|
|
102
102
|
}
|
|
103
|
-
let v = new Map(t.components.map((e) => [
|
|
104
|
-
if (
|
|
103
|
+
let v = new Map(t.components.map((e) => [i(e), e])), y = [];
|
|
104
|
+
if (d) for (let e of o.components.incoming) e.remote && v.set(e.id, u(e.remote));
|
|
105
105
|
if (p) for (let e of o.components.outgoing) e.local && y.push(e.local);
|
|
106
106
|
for (let e of o.components.conflicts) {
|
|
107
107
|
let t = m(e.id);
|
|
108
|
-
t === "strata" &&
|
|
108
|
+
t === "strata" && d && e.remote ? v.set(e.id, u(e.remote)) : t === "plexo" && p && e.local && y.push(e.local);
|
|
109
109
|
}
|
|
110
|
-
let b = new Map(
|
|
110
|
+
let b = new Map(n.tokens.map((e, t) => [e.key, t])), x = [...h.values()].sort((e, t) => (b.get(e.key) ?? 1e9) - (b.get(t.key) ?? 1e9)), S = e({
|
|
111
111
|
...t,
|
|
112
112
|
tokens: x,
|
|
113
113
|
components: [...v.values()]
|
|
114
114
|
}), C = {
|
|
115
|
-
variables:
|
|
116
|
-
components: y.map(
|
|
115
|
+
variables: f(g),
|
|
116
|
+
components: y.map(u),
|
|
117
117
|
..._.length ? { deleteVariables: _ } : {}
|
|
118
|
-
}, w = new Map(
|
|
118
|
+
}, w = new Map(n.tokens.map((e) => [e.key, e]));
|
|
119
119
|
for (let e of C.variables) w.set(e.key, e);
|
|
120
120
|
for (let e of _) w.delete(e);
|
|
121
|
-
let T = new Map(
|
|
122
|
-
for (let e of C.components) T.set(
|
|
121
|
+
let T = new Map(n.components.map((e) => [i(e), e]));
|
|
122
|
+
for (let e of C.components) T.set(i(e), e);
|
|
123
123
|
let E = t.strata?.base ?? {
|
|
124
124
|
tokens: {},
|
|
125
125
|
components: {}
|
|
@@ -128,17 +128,17 @@ function u(t, a, o, s, c = {}, u) {
|
|
|
128
128
|
components: { ...E.components }
|
|
129
129
|
}, O = new Map(S.tokens.map((e) => [e.key, e]));
|
|
130
130
|
for (let e of /* @__PURE__ */ new Set([...O.keys(), ...w.keys()])) {
|
|
131
|
-
let t = O.get(e),
|
|
132
|
-
t &&
|
|
131
|
+
let t = O.get(e), n = w.get(e);
|
|
132
|
+
t && n && r(t) === r(n) ? D.tokens[e] = r(t) : !t && !n && delete D.tokens[e];
|
|
133
133
|
}
|
|
134
|
-
let k = new Map(S.components.map((e) => [
|
|
134
|
+
let k = new Map(S.components.map((e) => [i(e), e]));
|
|
135
135
|
for (let e of /* @__PURE__ */ new Set([...k.keys(), ...T.keys()])) {
|
|
136
136
|
let t = k.get(e), n = T.get(e);
|
|
137
|
-
t && n &&
|
|
137
|
+
t && n && a(t) === a(n) ? D.components[e] = a(t) : !t && !n && delete D.components[e];
|
|
138
138
|
}
|
|
139
139
|
let A = {
|
|
140
|
-
...t.strata ?? { projectId:
|
|
141
|
-
...
|
|
140
|
+
...t.strata ?? { projectId: l?.projectId ?? "" },
|
|
141
|
+
...l ?? {},
|
|
142
142
|
syncedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
143
143
|
base: D
|
|
144
144
|
};
|
|
@@ -151,71 +151,71 @@ function u(t, a, o, s, c = {}, u) {
|
|
|
151
151
|
hasOutgoing: C.variables.length + C.components.length + (C.deleteVariables?.length ?? 0) > 0
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
|
-
var
|
|
155
|
-
function
|
|
154
|
+
var f = (e) => [...new Map(e.map((e) => [e.key, e])).values()], p = (e) => e.replace(/^--/, "").split("-").filter(Boolean).map((e) => e[0].toUpperCase() + e.slice(1)).join(" ");
|
|
155
|
+
function m(e) {
|
|
156
156
|
let { local: t, base: n, remote: r } = e, i = {
|
|
157
157
|
...t,
|
|
158
158
|
strata: {
|
|
159
159
|
...t.strata ?? { projectId: "" },
|
|
160
160
|
base: n
|
|
161
161
|
}
|
|
162
|
-
}, a =
|
|
162
|
+
}, a = s(i, r), o = [...a.tokens.conflicts.map((e) => ({
|
|
163
163
|
id: e.key,
|
|
164
164
|
kind: "token",
|
|
165
|
-
label: (e.local ?? e.remote)?.name?.startsWith("--") === !1 ? (e.local ?? e.remote).name :
|
|
165
|
+
label: (e.local ?? e.remote)?.name?.startsWith("--") === !1 ? (e.local ?? e.remote).name : p(e.key)
|
|
166
166
|
})), ...a.components.conflicts.map((e) => ({
|
|
167
167
|
id: e.id,
|
|
168
168
|
kind: "component",
|
|
169
169
|
label: e.name
|
|
170
|
-
}))], c = a.tokens.incoming.length + a.tokens.removedRemotely.length + a.components.incoming.length, l = a.tokens.outgoing.length + a.tokens.removedLocally.length + a.components.outgoing.length,
|
|
171
|
-
conflicts:
|
|
170
|
+
}))], c = a.tokens.incoming.length + a.tokens.removedRemotely.length + a.components.incoming.length, l = a.tokens.outgoing.length + a.tokens.removedLocally.length + a.components.outgoing.length, u = {
|
|
171
|
+
conflicts: o,
|
|
172
172
|
incoming: c,
|
|
173
173
|
unsynced: l,
|
|
174
174
|
plan: a
|
|
175
175
|
};
|
|
176
|
-
return n ?
|
|
176
|
+
return n ? o.length ? {
|
|
177
177
|
status: "needs-review",
|
|
178
178
|
reason: "Some things were changed here and in Strata.",
|
|
179
|
-
...
|
|
179
|
+
...u
|
|
180
180
|
} : c === 0 ? {
|
|
181
181
|
status: "up-to-date",
|
|
182
|
-
...
|
|
182
|
+
...u
|
|
183
183
|
} : l > 0 ? {
|
|
184
184
|
status: "needs-review",
|
|
185
185
|
reason: "You have changes here that haven’t been sent to Strata yet.",
|
|
186
|
-
...
|
|
186
|
+
...u
|
|
187
187
|
} : {
|
|
188
188
|
status: "safe-to-apply",
|
|
189
|
-
merged:
|
|
190
|
-
...
|
|
189
|
+
merged: d(i, r, a, "pull").designSystem,
|
|
190
|
+
...u
|
|
191
191
|
} : {
|
|
192
|
-
status: c + l +
|
|
192
|
+
status: c + l + o.length === 0 ? "up-to-date" : "needs-review",
|
|
193
193
|
reason: "This site hasn’t been matched up with Strata yet.",
|
|
194
|
-
...
|
|
194
|
+
...u
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
197
|
//#endregion
|
|
198
198
|
//#region src/v2/strata/client.ts
|
|
199
|
-
var
|
|
199
|
+
var h = class extends Error {
|
|
200
200
|
kind;
|
|
201
201
|
status;
|
|
202
202
|
details;
|
|
203
203
|
constructor(e, t, n = 0, r) {
|
|
204
204
|
super(e), this.name = "StrataError", this.kind = t, this.status = n, this.details = r;
|
|
205
205
|
}
|
|
206
|
-
},
|
|
207
|
-
function
|
|
206
|
+
}, g = (e) => e === "semantic" ? "semantic" : e === "component" ? "component" : "brand";
|
|
207
|
+
function _(e) {
|
|
208
208
|
return {
|
|
209
209
|
key: String(e.key ?? e.name),
|
|
210
210
|
name: String(e.name ?? e.key),
|
|
211
211
|
value: String(e.value ?? ""),
|
|
212
212
|
type: String(e.type ?? "string"),
|
|
213
213
|
unit: e.unit === void 0 || e.unit === null || e.unit === "null" ? null : String(e.unit),
|
|
214
|
-
layer:
|
|
214
|
+
layer: g(e.layer),
|
|
215
215
|
comment: e.comment ?? null
|
|
216
216
|
};
|
|
217
217
|
}
|
|
218
|
-
function
|
|
218
|
+
function v(e) {
|
|
219
219
|
let { id: t, componentId: n, createdAt: r, updatedAt: i, ...a } = e;
|
|
220
220
|
return {
|
|
221
221
|
...a,
|
|
@@ -225,7 +225,7 @@ function _(e) {
|
|
|
225
225
|
nodes: Array.isArray(e.nodes) ? e.nodes : []
|
|
226
226
|
};
|
|
227
227
|
}
|
|
228
|
-
function
|
|
228
|
+
function y(e) {
|
|
229
229
|
return {
|
|
230
230
|
id: String(e.projectId ?? e.id),
|
|
231
231
|
name: String(e.title ?? e.name ?? "Untitled project"),
|
|
@@ -236,7 +236,7 @@ function v(e) {
|
|
|
236
236
|
...e.role === "owner" || e.role === "editor" || e.role === "viewer" ? { role: e.role } : {}
|
|
237
237
|
};
|
|
238
238
|
}
|
|
239
|
-
var
|
|
239
|
+
var b = (e) => ({
|
|
240
240
|
key: e.key,
|
|
241
241
|
name: e.name,
|
|
242
242
|
value: e.value,
|
|
@@ -245,11 +245,11 @@ var y = (e) => ({
|
|
|
245
245
|
layer: e.layer,
|
|
246
246
|
comment: e.comment
|
|
247
247
|
});
|
|
248
|
-
function
|
|
248
|
+
function x(e) {
|
|
249
249
|
let t = e.fetch ?? fetch, n = e.baseUrl.replace(/\/$/, "");
|
|
250
250
|
async function r(r, i = {}) {
|
|
251
251
|
let a = await e.getToken();
|
|
252
|
-
if (!a) throw new
|
|
252
|
+
if (!a) throw new h("Connect Strata to continue.", "expired", 401);
|
|
253
253
|
let o;
|
|
254
254
|
try {
|
|
255
255
|
o = await t(`${n}${r}`, {
|
|
@@ -259,29 +259,29 @@ function b(e) {
|
|
|
259
259
|
...i.body === void 0 ? {} : { "Content-Type": "application/json" },
|
|
260
260
|
Accept: "application/json"
|
|
261
261
|
},
|
|
262
|
-
body: i.body === void 0 ? void 0 : JSON.stringify(i.body)
|
|
262
|
+
body: i.form ?? (i.body === void 0 ? void 0 : JSON.stringify(i.body))
|
|
263
263
|
});
|
|
264
264
|
} catch {
|
|
265
|
-
throw new
|
|
265
|
+
throw new h("Couldn't reach Strata. Check your connection and try again.", "network");
|
|
266
266
|
}
|
|
267
267
|
let s = await o.json().catch(() => ({}));
|
|
268
268
|
if (o.ok) return s;
|
|
269
269
|
let c = s?.error?.code, l = typeof s?.error?.message == "string" ? s.error.message : typeof s?.message == "string" ? s.message : "";
|
|
270
|
-
if (o.status === 401) throw new
|
|
271
|
-
if (o.status === 403) throw new
|
|
272
|
-
if (o.status === 404) throw new
|
|
273
|
-
if (o.status === 409 && c === "REVISION_CONFLICT") throw new
|
|
274
|
-
if (o.status === 409) throw new
|
|
270
|
+
if (o.status === 401) throw new h("Your Strata sign-in has run out. Reconnect to keep syncing.", "expired", 401);
|
|
271
|
+
if (o.status === 403) throw new h("You can see this Strata project but not change it. Ask its owner for edit access, or pick a project of your own.", "forbidden", 403);
|
|
272
|
+
if (o.status === 404) throw new h("That Strata project wasn't found. It may have been deleted, or you may no longer have access.", "not_found", 404);
|
|
273
|
+
if (o.status === 409 && c === "REVISION_CONFLICT") throw new h("Someone changed this project in Strata since you last checked. Check for updates first, then send your changes.", "conflict", 409, s.error.details);
|
|
274
|
+
if (o.status === 409) throw new h(l || "A project with that name already exists. Choose another name.", "invalid", 409, s.error?.details);
|
|
275
275
|
if (o.status === 400) {
|
|
276
276
|
let e = s?.error?.details?.errors, t = e?.[0];
|
|
277
|
-
throw new
|
|
277
|
+
throw new h(t ? `Strata didn't accept ${t.key ?? t.component ?? "one of the changes"}: ${t.message}` : l || "Strata didn't accept those changes.", "invalid", 400, e);
|
|
278
278
|
}
|
|
279
|
-
throw new
|
|
279
|
+
throw new h("Strata had a problem. Please try again in a moment.", "server", o.status);
|
|
280
280
|
}
|
|
281
281
|
return {
|
|
282
282
|
async listProjects() {
|
|
283
283
|
let e = await r("/user/projects");
|
|
284
|
-
return (Array.isArray(e.data) ? e.data : []).map(
|
|
284
|
+
return (Array.isArray(e.data) ? e.data : []).map(y);
|
|
285
285
|
},
|
|
286
286
|
async createProject(e) {
|
|
287
287
|
let t = await r(e.template === "base" ? "/projects?preset=base" : "/projects", {
|
|
@@ -291,7 +291,7 @@ function b(e) {
|
|
|
291
291
|
...e.template === "base" && e.brandPrimary && /^#[0-9A-Fa-f]{6}$/.test(e.brandPrimary) ? { brandPrimary: e.brandPrimary } : {}
|
|
292
292
|
}
|
|
293
293
|
});
|
|
294
|
-
return
|
|
294
|
+
return y(t.data ?? t);
|
|
295
295
|
},
|
|
296
296
|
async pull(e) {
|
|
297
297
|
let t = encodeURIComponent(e);
|
|
@@ -299,15 +299,15 @@ function b(e) {
|
|
|
299
299
|
let e = await r(`/projects/${t}/design-system`), n = e.data ?? e;
|
|
300
300
|
return {
|
|
301
301
|
revision: n.revision,
|
|
302
|
-
tokens: (n.variables ?? []).map(
|
|
303
|
-
components: (n.components ?? []).map(
|
|
302
|
+
tokens: (n.variables ?? []).map(_),
|
|
303
|
+
components: (n.components ?? []).map(v)
|
|
304
304
|
};
|
|
305
305
|
} catch (e) {
|
|
306
|
-
if (!(e instanceof
|
|
306
|
+
if (!(e instanceof h) || e.kind !== "not_found" || e.status !== 404) throw e;
|
|
307
307
|
let [n, i] = await Promise.all([r(`/projects/${t}/variables`), r(`/projects/${t}/components`)]);
|
|
308
308
|
return {
|
|
309
|
-
tokens: (n.data ?? []).map(
|
|
310
|
-
components: (i.data ?? []).map(
|
|
309
|
+
tokens: (n.data ?? []).map(_),
|
|
310
|
+
components: (i.data ?? []).map(v)
|
|
311
311
|
};
|
|
312
312
|
}
|
|
313
313
|
},
|
|
@@ -316,7 +316,7 @@ function b(e) {
|
|
|
316
316
|
method: "PUT",
|
|
317
317
|
body: {
|
|
318
318
|
...n ? { baseRevision: n } : {},
|
|
319
|
-
variables: t.variables.map(
|
|
319
|
+
variables: t.variables.map(b),
|
|
320
320
|
components: t.components,
|
|
321
321
|
...t.deleteVariables?.length ? { deleteVariables: t.deleteVariables } : {}
|
|
322
322
|
}
|
|
@@ -326,6 +326,28 @@ function b(e) {
|
|
|
326
326
|
warnings: a.warnings
|
|
327
327
|
};
|
|
328
328
|
},
|
|
329
|
+
async listAssets(e) {
|
|
330
|
+
let t = await r(`/projects/${encodeURIComponent(e)}/assets`);
|
|
331
|
+
return (Array.isArray(t.data) ? t.data : []).flatMap((e) => {
|
|
332
|
+
let t = typeof e.mimeType == "string" ? e.mimeType : "", n = t.startsWith("video/") ? "video" : t.startsWith("image/") ? "image" : null;
|
|
333
|
+
return !n || typeof e.cdnUrl != "string" || !e.cdnUrl || e.status === "DEPRECATED" ? [] : [{
|
|
334
|
+
id: String(e.assetId),
|
|
335
|
+
name: String(e.name ?? e.fileName ?? "Untitled"),
|
|
336
|
+
kind: n,
|
|
337
|
+
url: e.cdnUrl,
|
|
338
|
+
type: e.type,
|
|
339
|
+
role: e.role,
|
|
340
|
+
mimeType: t
|
|
341
|
+
}];
|
|
342
|
+
});
|
|
343
|
+
},
|
|
344
|
+
async uploadAsset(e, t) {
|
|
345
|
+
let n = new FormData();
|
|
346
|
+
n.append("type", t.type), n.append("name", t.name), t.role && n.append("role", t.role), t.metadata && n.append("metadata", JSON.stringify(t.metadata)), n.append("file", t.file, t.fileName), await r(`/projects/${encodeURIComponent(e)}/assets`, {
|
|
347
|
+
method: "POST",
|
|
348
|
+
form: n
|
|
349
|
+
});
|
|
350
|
+
},
|
|
329
351
|
async me() {
|
|
330
352
|
let e = await r("/user"), t = e.data?.user ?? e.data ?? e.user ?? {};
|
|
331
353
|
return {
|
|
@@ -336,4 +358,4 @@ function b(e) {
|
|
|
336
358
|
};
|
|
337
359
|
}
|
|
338
360
|
//#endregion
|
|
339
|
-
export {
|
|
361
|
+
export { _ as a, o as c, l as d, y as i, c as l, v as n, m as o, x as r, d as s, h as t, s as u };
|