@supernova-studio/client 1.63.0 → 1.65.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 +12 -171
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -170
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -19765,13 +19765,23 @@ var LocalProjectActionExecutor = class {
|
|
|
19765
19765
|
if (!existingFeature) {
|
|
19766
19766
|
throw new Error(`Cannot update feature: feature ${id} was not found in local storage`);
|
|
19767
19767
|
}
|
|
19768
|
+
let publishedState = existingFeature.publishedState;
|
|
19769
|
+
if (input.publishedState === null) {
|
|
19770
|
+
publishedState = void 0;
|
|
19771
|
+
} else if (input.publishedState) {
|
|
19772
|
+
publishedState = {
|
|
19773
|
+
...input.publishedState,
|
|
19774
|
+
lastPublishedAt: /* @__PURE__ */ new Date()
|
|
19775
|
+
};
|
|
19776
|
+
}
|
|
19768
19777
|
const mergedFeature = {
|
|
19769
19778
|
...existingFeature,
|
|
19770
19779
|
name: input.name ?? existingFeature.name,
|
|
19771
19780
|
description: input.description ?? existingFeature.description,
|
|
19772
19781
|
isArchived: input.isArchived ?? existingFeature.isArchived,
|
|
19773
19782
|
status: input.status ?? existingFeature.status,
|
|
19774
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
19783
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
19784
|
+
publishedState
|
|
19775
19785
|
};
|
|
19776
19786
|
this.features.set(id, mergedFeature);
|
|
19777
19787
|
}
|
|
@@ -20000,174 +20010,6 @@ var TransactionQueue2 = class {
|
|
|
20000
20010
|
this.queue.clear();
|
|
20001
20011
|
}
|
|
20002
20012
|
};
|
|
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
20013
|
export {
|
|
20172
20014
|
BackendFeatureRoomYDoc,
|
|
20173
20015
|
BackendForgeProjectRoomYDoc,
|
|
@@ -21025,7 +20867,6 @@ export {
|
|
|
21025
20867
|
StorybookHostingEndpoint,
|
|
21026
20868
|
StringVariableScopeType,
|
|
21027
20869
|
SupernovaApiClient,
|
|
21028
|
-
TestFVPDataBuilder,
|
|
21029
20870
|
ThemesEndpoint,
|
|
21030
20871
|
ThreadRoomBaseYDoc,
|
|
21031
20872
|
ThreadsEndpoint,
|