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