@supernova-studio/client 1.63.0 → 1.64.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/dist/index.d.mts +1 -308
- package/dist/index.d.ts +1 -308
- package/dist/index.js +1 -170
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -169
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -20000,174 +20000,6 @@ var TransactionQueue2 = class {
|
|
|
20000
20000
|
this.queue.clear();
|
|
20001
20001
|
}
|
|
20002
20002
|
};
|
|
20003
|
-
|
|
20004
|
-
// src/test-data-builders/fvp/base.ts
|
|
20005
|
-
import { randomUUID } from "crypto";
|
|
20006
|
-
var TestFVPDataBuilder = class {
|
|
20007
|
-
constructor(input) {
|
|
20008
|
-
__publicField(this, "input");
|
|
20009
|
-
__publicField(this, "collections");
|
|
20010
|
-
__publicField(this, "figmaIdCounter", 0);
|
|
20011
|
-
this.input = input;
|
|
20012
|
-
this.collections = {
|
|
20013
|
-
variableCollections: {},
|
|
20014
|
-
variables: {},
|
|
20015
|
-
variablesOrder: []
|
|
20016
|
-
};
|
|
20017
|
-
}
|
|
20018
|
-
//
|
|
20019
|
-
// Bulk
|
|
20020
|
-
//
|
|
20021
|
-
addBulk(data) {
|
|
20022
|
-
const collection = this.addCollection({
|
|
20023
|
-
collection: data.collection,
|
|
20024
|
-
modes: data.modes
|
|
20025
|
-
});
|
|
20026
|
-
const fullVariables = data.variables.map((v) => {
|
|
20027
|
-
return {
|
|
20028
|
-
...v,
|
|
20029
|
-
variableCollectionId: collection.id
|
|
20030
|
-
};
|
|
20031
|
-
});
|
|
20032
|
-
const variables = fullVariables.map((v) => this.addVariable(v));
|
|
20033
|
-
return { collection, variables };
|
|
20034
|
-
}
|
|
20035
|
-
//
|
|
20036
|
-
// Collections
|
|
20037
|
-
//
|
|
20038
|
-
addCollection(collectionWithModes) {
|
|
20039
|
-
const { collection, modes } = collectionWithModes;
|
|
20040
|
-
if (!modes.length) {
|
|
20041
|
-
throw SupernovaException.validationError(`At least one mode is required per collection`);
|
|
20042
|
-
}
|
|
20043
|
-
const fullCollection = {
|
|
20044
|
-
...collection,
|
|
20045
|
-
id: this.nextCollectionId(),
|
|
20046
|
-
modes: [],
|
|
20047
|
-
defaultModeId: "",
|
|
20048
|
-
hiddenFromPublishing: collection.hiddenFromPublishing ?? false,
|
|
20049
|
-
remote: collection.remote ?? false
|
|
20050
|
-
};
|
|
20051
|
-
this.collections.variableCollections[fullCollection.id] = fullCollection;
|
|
20052
|
-
const createdModes = modes.map((m) => this.addModeToCollection(m, fullCollection));
|
|
20053
|
-
fullCollection.defaultModeId = createdModes[0].modeId;
|
|
20054
|
-
return fullCollection;
|
|
20055
|
-
}
|
|
20056
|
-
updateCollection(collectionId, collectionUpdate) {
|
|
20057
|
-
const collection = this.collections.variableCollections[collectionId];
|
|
20058
|
-
if (!collection) throw SupernovaException.notFound(`Collection ${collectionId} was not found`);
|
|
20059
|
-
collection.name = collectionUpdate.name ?? collection.name;
|
|
20060
|
-
}
|
|
20061
|
-
deleteCollection(collectionId) {
|
|
20062
|
-
const deleted = delete this.collections.variableCollections[collectionId];
|
|
20063
|
-
if (!deleted) throw SupernovaException.notFound(`Collection ${collectionId} was not found`);
|
|
20064
|
-
}
|
|
20065
|
-
//
|
|
20066
|
-
// Modes
|
|
20067
|
-
//
|
|
20068
|
-
addMode(mode) {
|
|
20069
|
-
const { collectionId, ...rest } = mode;
|
|
20070
|
-
const collection = this.collections.variableCollections[collectionId];
|
|
20071
|
-
if (!collection) {
|
|
20072
|
-
throw SupernovaException.notFound(`Collection ${collectionId} was not found`);
|
|
20073
|
-
}
|
|
20074
|
-
return this.addModeToCollection(rest, collection);
|
|
20075
|
-
}
|
|
20076
|
-
addModeToCollection(mode, collection) {
|
|
20077
|
-
const fullMode = {
|
|
20078
|
-
...mode,
|
|
20079
|
-
modeId: this.nextModeId()
|
|
20080
|
-
};
|
|
20081
|
-
collection.modes.push(fullMode);
|
|
20082
|
-
Object.values(this.collections.variables).forEach((v) => {
|
|
20083
|
-
if (v.variableCollectionId !== collection.id) return;
|
|
20084
|
-
const defaultValue = v.valuesByMode[collection.defaultModeId];
|
|
20085
|
-
if (!defaultValue) {
|
|
20086
|
-
throw SupernovaException.shouldNotHappen(`Could not resolve default value for variable ${v.id}`);
|
|
20087
|
-
}
|
|
20088
|
-
v.valuesByMode[fullMode.modeId] = defaultValue;
|
|
20089
|
-
});
|
|
20090
|
-
return fullMode;
|
|
20091
|
-
}
|
|
20092
|
-
//
|
|
20093
|
-
// Variables
|
|
20094
|
-
//
|
|
20095
|
-
addVariable(variable) {
|
|
20096
|
-
const collection = this.collections.variableCollections[variable.variableCollectionId];
|
|
20097
|
-
if (!collection) {
|
|
20098
|
-
const availableCollections = Object.keys(this.collections.variableCollections).join(",");
|
|
20099
|
-
throw SupernovaException.notFound(
|
|
20100
|
-
`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`
|
|
20101
|
-
);
|
|
20102
|
-
}
|
|
20103
|
-
return this.addVariableToCollection(variable, collection);
|
|
20104
|
-
}
|
|
20105
|
-
updateVariable(variableId, data) {
|
|
20106
|
-
const variable = this.collections.variables[variableId];
|
|
20107
|
-
if (!variable) throw SupernovaException.notFound(`Variable ${variableId} was not found`);
|
|
20108
|
-
variable.scopes = data.scopes ?? variable.scopes;
|
|
20109
|
-
}
|
|
20110
|
-
deleteVariable(variableId) {
|
|
20111
|
-
const deleted = delete this.collections.variables[variableId];
|
|
20112
|
-
if (!deleted) throw SupernovaException.notFound(`Variable ${variableId} was not found`);
|
|
20113
|
-
this.collections.variablesOrder = this.collections.variablesOrder?.filter((id) => id !== variableId);
|
|
20114
|
-
}
|
|
20115
|
-
addVariableToCollection(variable, collection) {
|
|
20116
|
-
const valuesByMode = {};
|
|
20117
|
-
for (const mode of collection.modes) {
|
|
20118
|
-
valuesByMode[mode.modeId] = variable.defaultValue;
|
|
20119
|
-
}
|
|
20120
|
-
const { defaultValue, ...rest } = variable;
|
|
20121
|
-
const fullVariable = {
|
|
20122
|
-
...rest,
|
|
20123
|
-
id: this.nextVariableId(),
|
|
20124
|
-
description: variable.description ?? "",
|
|
20125
|
-
hiddenFromPublishing: variable.hiddenFromPublishing ?? false,
|
|
20126
|
-
remote: variable.remote ?? false,
|
|
20127
|
-
valuesByMode,
|
|
20128
|
-
key: randomUUID(),
|
|
20129
|
-
scopes: variable.scopes ?? ["ALL_SCOPES"]
|
|
20130
|
-
};
|
|
20131
|
-
this.collections.variables[fullVariable.id] = fullVariable;
|
|
20132
|
-
this.collections.variablesOrder.push(fullVariable.id);
|
|
20133
|
-
return fullVariable;
|
|
20134
|
-
}
|
|
20135
|
-
//
|
|
20136
|
-
// Output
|
|
20137
|
-
//
|
|
20138
|
-
buildPayload(payloadPart = {}) {
|
|
20139
|
-
return {
|
|
20140
|
-
...payloadPart,
|
|
20141
|
-
isTokenTypeSplitEnabled: payloadPart.isTokenTypeSplitEnabled ?? true,
|
|
20142
|
-
type: "FigmaVariablesPlugin",
|
|
20143
|
-
remoteId: payloadPart.remoteId ?? "test-fvp-source",
|
|
20144
|
-
sourceName: "Test FVP source",
|
|
20145
|
-
brandPersistentId: this.input.brandPersistentId,
|
|
20146
|
-
payload: this.buildCollections()
|
|
20147
|
-
};
|
|
20148
|
-
}
|
|
20149
|
-
buildCollections() {
|
|
20150
|
-
return structuredClone(this.collections);
|
|
20151
|
-
}
|
|
20152
|
-
//
|
|
20153
|
-
// ID Generation
|
|
20154
|
-
//
|
|
20155
|
-
nextModeId() {
|
|
20156
|
-
return this.nextId();
|
|
20157
|
-
}
|
|
20158
|
-
nextCollectionId() {
|
|
20159
|
-
return this.nextId("VariableCollectionId");
|
|
20160
|
-
}
|
|
20161
|
-
nextVariableId() {
|
|
20162
|
-
return this.nextId("VariableID");
|
|
20163
|
-
}
|
|
20164
|
-
nextId(prefix) {
|
|
20165
|
-
let id = `1:${this.figmaIdCounter}`;
|
|
20166
|
-
this.figmaIdCounter++;
|
|
20167
|
-
if (prefix) id = `${prefix}:${id}`;
|
|
20168
|
-
return id;
|
|
20169
|
-
}
|
|
20170
|
-
};
|
|
20171
20003
|
export {
|
|
20172
20004
|
BackendFeatureRoomYDoc,
|
|
20173
20005
|
BackendForgeProjectRoomYDoc,
|
|
@@ -21025,7 +20857,6 @@ export {
|
|
|
21025
20857
|
StorybookHostingEndpoint,
|
|
21026
20858
|
StringVariableScopeType,
|
|
21027
20859
|
SupernovaApiClient,
|
|
21028
|
-
TestFVPDataBuilder,
|
|
21029
20860
|
ThemesEndpoint,
|
|
21030
20861
|
ThreadRoomBaseYDoc,
|
|
21031
20862
|
ThreadsEndpoint,
|