@supernova-studio/client 1.60.1 → 1.60.3
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 +259 -4
- package/dist/index.d.ts +259 -4
- package/dist/index.js +179 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +178 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3385,7 +3385,7 @@ var ThemeOriginSource = z93.object({
|
|
|
3385
3385
|
var ThemeOrigin = z93.object({
|
|
3386
3386
|
sources: z93.array(ThemeOriginSource)
|
|
3387
3387
|
});
|
|
3388
|
-
var Theme =
|
|
3388
|
+
var Theme = DesignElementGroupableBase.extend(DesignElementBrandedPart.shape).extend({
|
|
3389
3389
|
origin: ThemeOrigin.optional(),
|
|
3390
3390
|
overrides: z93.array(ThemeOverride),
|
|
3391
3391
|
codeName: z93.string()
|
|
@@ -3693,6 +3693,7 @@ var Collection = z99.object({
|
|
|
3693
3693
|
name: z99.string(),
|
|
3694
3694
|
description: z99.string(),
|
|
3695
3695
|
backgroundColor: ColorTokenInlineData.optional(),
|
|
3696
|
+
parentPersistentId: z99.string().optional(),
|
|
3696
3697
|
/**
|
|
3697
3698
|
* ID of Select element property definition's option that corresponds to this collection.
|
|
3698
3699
|
*
|
|
@@ -8145,6 +8146,7 @@ var DTOTokenCollection = z270.object({
|
|
|
8145
8146
|
elementPropertyOptionId: z270.string(),
|
|
8146
8147
|
createdAt: z270.coerce.date(),
|
|
8147
8148
|
updatedAt: z270.coerce.date(),
|
|
8149
|
+
parentPersistentId: z270.string().optional(),
|
|
8148
8150
|
origin: CollectionOrigin.optional()
|
|
8149
8151
|
});
|
|
8150
8152
|
var DTOTokenCollectionsListReponse = z270.object({
|
|
@@ -11342,6 +11344,9 @@ var DTOThemeOverrideCreatePayload = DesignTokenTypedData.and(
|
|
|
11342
11344
|
|
|
11343
11345
|
// src/api/dto/themes/theme.ts
|
|
11344
11346
|
import { z as z346 } from "zod";
|
|
11347
|
+
var DTOThemesListQuery = z346.object({
|
|
11348
|
+
brandId: z346.string().optional()
|
|
11349
|
+
});
|
|
11345
11350
|
var DTOTheme = z346.object({
|
|
11346
11351
|
id: z346.string(),
|
|
11347
11352
|
persistentId: z346.string(),
|
|
@@ -11349,6 +11354,8 @@ var DTOTheme = z346.object({
|
|
|
11349
11354
|
brandId: z346.string(),
|
|
11350
11355
|
meta: ObjectMeta,
|
|
11351
11356
|
codeName: z346.string(),
|
|
11357
|
+
parentPersistentId: z346.string().optional(),
|
|
11358
|
+
collectionPersistentIds: z346.string().array(),
|
|
11352
11359
|
overrides: DTOThemeOverride.array()
|
|
11353
11360
|
});
|
|
11354
11361
|
var DTOThemeResponse = z346.object({
|
|
@@ -19981,6 +19988,174 @@ var TransactionQueue2 = class {
|
|
|
19981
19988
|
this.queue.clear();
|
|
19982
19989
|
}
|
|
19983
19990
|
};
|
|
19991
|
+
|
|
19992
|
+
// src/test-data-builders/fvp/base.ts
|
|
19993
|
+
import { randomUUID } from "crypto";
|
|
19994
|
+
var TestFVPDataBuilder = class {
|
|
19995
|
+
constructor(input) {
|
|
19996
|
+
__publicField(this, "input");
|
|
19997
|
+
__publicField(this, "collections");
|
|
19998
|
+
__publicField(this, "figmaIdCounter", 0);
|
|
19999
|
+
this.input = input;
|
|
20000
|
+
this.collections = {
|
|
20001
|
+
variableCollections: {},
|
|
20002
|
+
variables: {},
|
|
20003
|
+
variablesOrder: []
|
|
20004
|
+
};
|
|
20005
|
+
}
|
|
20006
|
+
//
|
|
20007
|
+
// Bulk
|
|
20008
|
+
//
|
|
20009
|
+
addBulk(data) {
|
|
20010
|
+
const collection = this.addCollection({
|
|
20011
|
+
collection: data.collection,
|
|
20012
|
+
modes: data.modes
|
|
20013
|
+
});
|
|
20014
|
+
const fullVariables = data.variables.map((v) => {
|
|
20015
|
+
return {
|
|
20016
|
+
...v,
|
|
20017
|
+
variableCollectionId: collection.id
|
|
20018
|
+
};
|
|
20019
|
+
});
|
|
20020
|
+
const variables = fullVariables.map((v) => this.addVariable(v));
|
|
20021
|
+
return { collection, variables };
|
|
20022
|
+
}
|
|
20023
|
+
//
|
|
20024
|
+
// Collections
|
|
20025
|
+
//
|
|
20026
|
+
addCollection(collectionWithModes) {
|
|
20027
|
+
const { collection, modes } = collectionWithModes;
|
|
20028
|
+
if (!modes.length) {
|
|
20029
|
+
throw SupernovaException.validationError(`At least one mode is required per collection`);
|
|
20030
|
+
}
|
|
20031
|
+
const fullCollection = {
|
|
20032
|
+
...collection,
|
|
20033
|
+
id: this.nextCollectionId(),
|
|
20034
|
+
modes: [],
|
|
20035
|
+
defaultModeId: "",
|
|
20036
|
+
hiddenFromPublishing: collection.hiddenFromPublishing ?? false,
|
|
20037
|
+
remote: collection.remote ?? false
|
|
20038
|
+
};
|
|
20039
|
+
this.collections.variableCollections[fullCollection.id] = fullCollection;
|
|
20040
|
+
const createdModes = modes.map((m) => this.addModeToCollection(m, fullCollection));
|
|
20041
|
+
fullCollection.defaultModeId = createdModes[0].modeId;
|
|
20042
|
+
return fullCollection;
|
|
20043
|
+
}
|
|
20044
|
+
updateCollection(collectionId, collectionUpdate) {
|
|
20045
|
+
const collection = this.collections.variableCollections[collectionId];
|
|
20046
|
+
if (!collection) throw SupernovaException.notFound(`Collection ${collectionId} was not found`);
|
|
20047
|
+
collection.name = collectionUpdate.name ?? collection.name;
|
|
20048
|
+
}
|
|
20049
|
+
deleteCollection(collectionId) {
|
|
20050
|
+
const deleted = delete this.collections.variableCollections[collectionId];
|
|
20051
|
+
if (!deleted) throw SupernovaException.notFound(`Collection ${collectionId} was not found`);
|
|
20052
|
+
}
|
|
20053
|
+
//
|
|
20054
|
+
// Modes
|
|
20055
|
+
//
|
|
20056
|
+
addMode(mode) {
|
|
20057
|
+
const { collectionId, ...rest } = mode;
|
|
20058
|
+
const collection = this.collections.variableCollections[collectionId];
|
|
20059
|
+
if (!collection) {
|
|
20060
|
+
throw SupernovaException.notFound(`Collection ${collectionId} was not found`);
|
|
20061
|
+
}
|
|
20062
|
+
return this.addModeToCollection(rest, collection);
|
|
20063
|
+
}
|
|
20064
|
+
addModeToCollection(mode, collection) {
|
|
20065
|
+
const fullMode = {
|
|
20066
|
+
...mode,
|
|
20067
|
+
modeId: this.nextModeId()
|
|
20068
|
+
};
|
|
20069
|
+
collection.modes.push(fullMode);
|
|
20070
|
+
Object.values(this.collections.variables).forEach((v) => {
|
|
20071
|
+
if (v.variableCollectionId !== collection.id) return;
|
|
20072
|
+
const defaultValue = v.valuesByMode[collection.defaultModeId];
|
|
20073
|
+
if (!defaultValue) {
|
|
20074
|
+
throw SupernovaException.shouldNotHappen(`Could not resolve default value for variable ${v.id}`);
|
|
20075
|
+
}
|
|
20076
|
+
v.valuesByMode[fullMode.modeId] = defaultValue;
|
|
20077
|
+
});
|
|
20078
|
+
return fullMode;
|
|
20079
|
+
}
|
|
20080
|
+
//
|
|
20081
|
+
// Variables
|
|
20082
|
+
//
|
|
20083
|
+
addVariable(variable) {
|
|
20084
|
+
const collection = this.collections.variableCollections[variable.variableCollectionId];
|
|
20085
|
+
if (!collection) {
|
|
20086
|
+
const availableCollections = Object.keys(this.collections.variableCollections).join(",");
|
|
20087
|
+
throw SupernovaException.notFound(
|
|
20088
|
+
`Variable ${variable.name} references non-existent collection ${variable.variableCollectionId}, available collections are: [${availableCollections}]. Make sure you've added collection using '.addCollection()' before adding variable to it`
|
|
20089
|
+
);
|
|
20090
|
+
}
|
|
20091
|
+
return this.addVariableToCollection(variable, collection);
|
|
20092
|
+
}
|
|
20093
|
+
updateVariable(variableId, data) {
|
|
20094
|
+
const variable = this.collections.variables[variableId];
|
|
20095
|
+
if (!variable) throw SupernovaException.notFound(`Variable ${variableId} was not found`);
|
|
20096
|
+
variable.scopes = data.scopes ?? variable.scopes;
|
|
20097
|
+
}
|
|
20098
|
+
deleteVariable(variableId) {
|
|
20099
|
+
const deleted = delete this.collections.variables[variableId];
|
|
20100
|
+
if (!deleted) throw SupernovaException.notFound(`Variable ${variableId} was not found`);
|
|
20101
|
+
this.collections.variablesOrder = this.collections.variablesOrder?.filter((id) => id !== variableId);
|
|
20102
|
+
}
|
|
20103
|
+
addVariableToCollection(variable, collection) {
|
|
20104
|
+
const valuesByMode = {};
|
|
20105
|
+
for (const mode of collection.modes) {
|
|
20106
|
+
valuesByMode[mode.modeId] = variable.defaultValue;
|
|
20107
|
+
}
|
|
20108
|
+
const { defaultValue, ...rest } = variable;
|
|
20109
|
+
const fullVariable = {
|
|
20110
|
+
...rest,
|
|
20111
|
+
id: this.nextVariableId(),
|
|
20112
|
+
description: variable.description ?? "",
|
|
20113
|
+
hiddenFromPublishing: variable.hiddenFromPublishing ?? false,
|
|
20114
|
+
remote: variable.remote ?? false,
|
|
20115
|
+
valuesByMode,
|
|
20116
|
+
key: randomUUID(),
|
|
20117
|
+
scopes: variable.scopes ?? ["ALL_SCOPES"]
|
|
20118
|
+
};
|
|
20119
|
+
this.collections.variables[fullVariable.id] = fullVariable;
|
|
20120
|
+
this.collections.variablesOrder.push(fullVariable.id);
|
|
20121
|
+
return fullVariable;
|
|
20122
|
+
}
|
|
20123
|
+
//
|
|
20124
|
+
// Output
|
|
20125
|
+
//
|
|
20126
|
+
buildPayload(payloadPart = {}) {
|
|
20127
|
+
return {
|
|
20128
|
+
...payloadPart,
|
|
20129
|
+
isTokenTypeSplitEnabled: payloadPart.isTokenTypeSplitEnabled ?? true,
|
|
20130
|
+
type: "FigmaVariablesPlugin",
|
|
20131
|
+
remoteId: payloadPart.remoteId ?? "test-fvp-source",
|
|
20132
|
+
sourceName: "Test FVP source",
|
|
20133
|
+
brandPersistentId: this.input.brandPersistentId,
|
|
20134
|
+
payload: this.buildCollections()
|
|
20135
|
+
};
|
|
20136
|
+
}
|
|
20137
|
+
buildCollections() {
|
|
20138
|
+
return structuredClone(this.collections);
|
|
20139
|
+
}
|
|
20140
|
+
//
|
|
20141
|
+
// ID Generation
|
|
20142
|
+
//
|
|
20143
|
+
nextModeId() {
|
|
20144
|
+
return this.nextId();
|
|
20145
|
+
}
|
|
20146
|
+
nextCollectionId() {
|
|
20147
|
+
return this.nextId("VariableCollectionId");
|
|
20148
|
+
}
|
|
20149
|
+
nextVariableId() {
|
|
20150
|
+
return this.nextId("VariableID");
|
|
20151
|
+
}
|
|
20152
|
+
nextId(prefix) {
|
|
20153
|
+
let id = `1:${this.figmaIdCounter}`;
|
|
20154
|
+
this.figmaIdCounter++;
|
|
20155
|
+
if (prefix) id = `${prefix}:${id}`;
|
|
20156
|
+
return id;
|
|
20157
|
+
}
|
|
20158
|
+
};
|
|
19984
20159
|
export {
|
|
19985
20160
|
BackendFeatureRoomYDoc,
|
|
19986
20161
|
BackendForgeProjectRoomYDoc,
|
|
@@ -20654,6 +20829,7 @@ export {
|
|
|
20654
20829
|
DTOThemeOverride,
|
|
20655
20830
|
DTOThemeOverrideCreatePayload,
|
|
20656
20831
|
DTOThemeResponse,
|
|
20832
|
+
DTOThemesListQuery,
|
|
20657
20833
|
DTOThread,
|
|
20658
20834
|
DTOThreadAgentResponseTracker,
|
|
20659
20835
|
DTOThreadAgentType,
|
|
@@ -20837,6 +21013,7 @@ export {
|
|
|
20837
21013
|
StorybookHostingEndpoint,
|
|
20838
21014
|
StringVariableScopeType,
|
|
20839
21015
|
SupernovaApiClient,
|
|
21016
|
+
TestFVPDataBuilder,
|
|
20840
21017
|
ThemesEndpoint,
|
|
20841
21018
|
ThreadRoomBaseYDoc,
|
|
20842
21019
|
ThreadsEndpoint,
|