Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.

Commit 637d939

Browse files
merge: #3474
3474: feat(dal,sdf,app): Reimplement variant_defs endpoints r=stack72 a=stack72 As we are moving away from the concept of SchemaVariantDefinitions, we want to move the metadata that was part of a SchemaVariantDefinition to be part of the SchemaVariant This will allow us to start bringing back the authoring workflow without the need to have the concept of a SchemaVariantDefinition This PR also re-implements the get_variant_def endpoint as well as renaming variant_def to be variant in the API routes Co-authored-by: stack72 <public@paulstack.co.uk>
2 parents 1d0ec39 + 350e3b3 commit 637d939

32 files changed

Lines changed: 1101 additions & 894 deletions

File tree

app/web/src/components/AssetDetailsPanel.vue

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,9 @@
1212
<VButton
1313
:loading="executeAssetTaskRunning"
1414
:loadingText="
15-
editingAsset.schemaVariantId
16-
? 'Updating Asset...'
17-
: 'Creating Asset...'
18-
"
19-
:label="
20-
editingAsset.schemaVariantId ? 'Update Asset' : 'Create Asset'
15+
editingAsset.id ? 'Updating Asset...' : 'Creating Asset...'
2116
"
17+
:label="editingAsset.id ? 'Update Asset' : 'Create Asset'"
2218
:disabled="disabled"
2319
tone="action"
2420
icon="bolt"
@@ -83,7 +79,7 @@
8379
/>
8480
<VormInput
8581
id="menuName"
86-
v-model="editingAsset.menuName"
82+
v-model="editingAsset.displayName"
8783
type="text"
8884
:disabled="disabled"
8985
label="Display name"
@@ -150,14 +146,12 @@
150146
ref="executeAssetModalRef"
151147
size="sm"
152148
:title="
153-
editingAsset && editingAsset.schemaVariantId
154-
? 'Asset Updated'
155-
: 'New Asset Created'
149+
editingAsset && editingAsset.id ? 'Asset Updated' : 'New Asset Created'
156150
"
157151
@closeComplete="closeHandler"
158152
>
159153
{{
160-
editingAsset && editingAsset.schemaVariantId
154+
editingAsset && editingAsset.id
161155
? "The asset you just updated will be available to use from the Assets Panel"
162156
: "The asset you just created will now appear in the Assets Panel."
163157
}}
@@ -222,9 +216,7 @@ const componentTypeOptions = [
222216
223217
const attachModalRef = ref<InstanceType<typeof AssetFuncAttachModal>>();
224218
const assetSchemaVariantId = computed(() =>
225-
props.assetId
226-
? assetStore.assetsById[props.assetId]?.schemaVariantId
227-
: undefined,
219+
props.assetId ? assetStore.assetsById[props.assetId]?.id : undefined,
228220
);
229221
230222
const editingAsset = ref(_.cloneDeep(assetStore.selectedAsset));

app/web/src/components/AssetFuncListPanel.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<SidebarSubpanelTitle label="Asset Functions">
1010
<AssetFuncAttachDropdown
1111
v-if="assetStore.selectedAssetId"
12-
:disabled="!assetStore.selectedAsset?.schemaVariantId"
12+
:disabled="!assetStore.selectedAsset?.id"
1313
label="Attach"
1414
@selected-attach-type="openAttachFuncModal"
1515
/>
@@ -97,9 +97,7 @@ const loadAssetReqStatus = assetStore.getRequestStatus(
9797
9898
const attachModalRef = ref<InstanceType<typeof AssetFuncAttachModal>>();
9999
const assetSchemaVariantId = computed(() =>
100-
props.assetId
101-
? assetStore.assetsById[props.assetId]?.schemaVariantId
102-
: undefined,
100+
props.assetId ? assetStore.assetsById[props.assetId]?.id : undefined,
103101
);
104102
105103
const openAttachFuncModal = (type: "new" | "existing") => {

app/web/src/components/AssetListPanel.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
title="Contribute Assets"
5656
label="Contribute to System Initiative"
5757
:loadingText="_.sample(contributeLoadingTexts)"
58-
:preSelectedSchemaVariantId="assetStore.selectedAsset?.schemaVariantId"
58+
:preSelectedSchemaVariantId="assetStore.selectedAsset?.id"
5959
@export-success="onExport"
6060
/>
6161
<Modal ref="exportSuccessModalRef" size="sm" title="Contribution sent">
@@ -130,7 +130,7 @@ const categorizedAssets = computed(() =>
130130
if (searchString.value.length) {
131131
return (
132132
asset.name.toLocaleLowerCase().includes(searchString.value) ||
133-
asset.menuName?.toLocaleLowerCase().includes(searchString.value)
133+
asset.displayName?.toLocaleLowerCase().includes(searchString.value)
134134
);
135135
}
136136

app/web/src/components/FuncEditor/FuncTest.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ const dryRunConfig = computed(() => {
280280
281281
const components = computed(() => {
282282
return componentsStore.allComponents.filter(
283-
(c) => c.schemaVariantId === asset.value?.schemaVariantId,
283+
(c) => c.schemaVariantId === asset.value?.id,
284284
);
285285
});
286286

app/web/src/components/Workspace/WorkspaceCustomizeAssets.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<FuncDetails
5050
v-if="assetStore.selectedFuncId"
5151
:funcId="assetStore.selectedFuncId"
52-
:schemaVariantId="assetStore.selectedAsset?.schemaVariantId"
52+
:schemaVariantId="assetStore.selectedAsset?.id"
5353
singleModelScreen
5454
testPanelEnabled
5555
@detached="onDetach"

app/web/src/store/asset.store.ts

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import { useRouterStore } from "./router.store";
2323

2424
export type AssetId = string;
2525

26-
export interface ListVariantDefsResponse {
27-
variantDefs: ListedVariantDef[];
26+
export interface ListVariantsResponse {
27+
variants: ListedVariant[];
2828
}
2929

3030
export interface InstalledPkgAssetView {
@@ -70,10 +70,10 @@ export interface DetachedValidationPrototype {
7070
propKind: PropKind;
7171
}
7272

73-
export interface ListedVariantDef {
73+
export interface ListedVariant {
7474
id: AssetId;
7575
name: string;
76-
menuName?: string;
76+
displayName?: string;
7777
category: string;
7878
componentType: ComponentType;
7979
color: string;
@@ -83,16 +83,15 @@ export interface ListedVariantDef {
8383
updatedAt: IsoDateString;
8484
}
8585

86-
export interface VariantDef extends ListedVariantDef {
86+
export interface Variant extends ListedVariant {
8787
link?: string;
88-
schemaVariantId?: string;
8988
code: string;
9089
types?: string;
9190
hasComponents: boolean;
9291
}
9392

94-
export type Asset = VariantDef;
95-
export type AssetListEntry = ListedVariantDef;
93+
export type Asset = Variant;
94+
export type AssetListEntry = ListedVariant;
9695
export type AssetSaveRequest = Visibility &
9796
Omit<Asset, "createdAt" | "updatedAt" | "variantExists" | "hasComponents">;
9897
export type AssetCreateRequest = Omit<
@@ -104,7 +103,7 @@ export type AssetCloneRequest = Visibility & { id: AssetId };
104103
const LOCAL_STORAGE_LAST_SELECTED_ASSET_ID_KEY = "si-open-asset-id";
105104

106105
export const assetDisplayName = (asset: Asset | AssetListEntry) =>
107-
(asset.menuName ?? "").length === 0 ? asset.name : asset.menuName;
106+
(asset.displayName ?? "").length === 0 ? asset.name : asset.displayName;
108107

109108
export const useAssetStore = () => {
110109
const changeSetsStore = useChangeSetsStore();
@@ -170,8 +169,8 @@ export const useAssetStore = () => {
170169
assetBySchemaVariantId(): Record<string, Asset> {
171170
const assetsWithSchemaVariantId = _.filter(
172171
this.assets,
173-
(a) => a.schemaVariantId !== undefined,
174-
) as (VariantDef & {
172+
(a) => a.id !== undefined,
173+
) as (Variant & {
175174
schemaVariantId: string;
176175
})[];
177176

@@ -182,7 +181,7 @@ export const useAssetStore = () => {
182181
setSchemaVariantIdForAsset(assetId: AssetId, schemaVariantId: string) {
183182
const asset = this.assetsById[assetId];
184183
if (asset) {
185-
asset.schemaVariantId = schemaVariantId;
184+
asset.id = schemaVariantId;
186185
this.assetsById[assetId] = asset;
187186
}
188187
},
@@ -254,7 +253,6 @@ export const useAssetStore = () => {
254253
funcs: [],
255254
createdAt: new Date().toISOString(),
256255
updatedAt: new Date().toISOString(),
257-
schemaVariantId: undefined,
258256
hasComponents: false,
259257
};
260258
},
@@ -269,12 +267,11 @@ export const useAssetStore = () => {
269267
AssetCreateRequest
270268
>({
271269
method: "post",
272-
url: "/variant_def/create_variant_def",
270+
url: "/variant/create_variant",
273271
params: {
274272
...visibility,
275273
..._.omit(asset, [
276274
"id",
277-
"schemaVariantId",
278275
"hasComponents",
279276
"createdAt",
280277
"updatedAt",
@@ -295,7 +292,7 @@ export const useAssetStore = () => {
295292
>({
296293
method: "post",
297294
keyRequestStatusBy: assetId,
298-
url: "/variant_def/clone_variant_def",
295+
url: "/variant/clone_variant",
299296
params: {
300297
...visibility,
301298
id: assetId,
@@ -331,7 +328,7 @@ export const useAssetStore = () => {
331328
return new ApiRequest<{ success: boolean }, AssetSaveRequest>({
332329
method: "post",
333330
keyRequestStatusBy: asset.id,
334-
url: "/variant_def/save_variant_def",
331+
url: "/variant/save_variant",
335332
optimistic: () => {
336333
if (isHead) return () => {};
337334

@@ -347,12 +344,7 @@ export const useAssetStore = () => {
347344
},
348345
params: {
349346
...visibility,
350-
..._.omit(asset, [
351-
"schemaVariantId",
352-
"hasComponents",
353-
"createdAt",
354-
"updatedAt",
355-
]),
347+
..._.omit(asset, ["hasComponents", "createdAt", "updatedAt"]),
356348
},
357349
});
358350
},
@@ -364,7 +356,7 @@ export const useAssetStore = () => {
364356
id: AssetId;
365357
}
366358
>({
367-
url: "/variant_def/get_variant_def",
359+
url: "/variant/get_variant",
368360
keyRequestStatusBy: assetId,
369361
params: {
370362
id: assetId,
@@ -377,11 +369,11 @@ export const useAssetStore = () => {
377369
},
378370

379371
async LOAD_ASSET_LIST() {
380-
return new ApiRequest<ListVariantDefsResponse, Visibility>({
381-
url: "/variant_def/list_variant_defs",
372+
return new ApiRequest<ListVariantsResponse, Visibility>({
373+
url: "/variant/list_variants",
382374
params: { ...visibility },
383375
onSuccess: (response) => {
384-
this.assetList = response.variantDefs;
376+
this.assetList = response.variants;
385377
},
386378
});
387379
},
@@ -405,16 +397,11 @@ export const useAssetStore = () => {
405397
AssetSaveRequest
406398
>({
407399
method: "post",
408-
url: "/variant_def/exec_variant_def",
400+
url: "/variant/exec_variant",
409401
keyRequestStatusBy: assetId,
410402
params: {
411403
...visibility,
412-
..._.omit(asset, [
413-
"schemaVariantId",
414-
"hasComponents",
415-
"createdAt",
416-
"updatedAt",
417-
]),
404+
..._.omit(asset, ["hasComponents", "createdAt", "updatedAt"]),
418405
},
419406
onSuccess: (response) => {
420407
this.executeAssetTaskId = response.taskId;
@@ -433,21 +420,21 @@ export const useAssetStore = () => {
433420
},
434421
},
435422
{
436-
eventType: "SchemaVariantDefinitionCreated",
423+
eventType: "SchemaVariantCreated",
437424
callback: (data) => {
438425
if (data.changeSetId !== changeSetId) return;
439426
this.LOAD_ASSET_LIST();
440427
},
441428
},
442429
{
443-
eventType: "SchemaVariantDefinitionCloned",
430+
eventType: "SchemaVariantCloned",
444431
callback: (data) => {
445432
if (data.changeSetId !== changeSetId) return;
446433
this.LOAD_ASSET_LIST();
447434
},
448435
},
449436
{
450-
eventType: "SchemaVariantDefinitionSaved",
437+
eventType: "SchemaVariantSaved",
451438
callback: (data) => {
452439
if (data.changeSetId !== changeSetId) return;
453440
this.LOAD_ASSET_LIST();
@@ -491,7 +478,7 @@ export const useAssetStore = () => {
491478
},
492479
},
493480
{
494-
eventType: "SchemaVariantDefinitionFinished",
481+
eventType: "SchemaVariantFinished",
495482
callback: async ({
496483
taskId,
497484
schemaVariantId,

app/web/src/store/realtime/realtime_events.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,21 +220,21 @@ export type WsEventPayloadMap = {
220220
secretId: SecretId;
221221
changeSetId: ChangeSetId;
222222
};
223-
SchemaVariantDefinitionCreated: {
224-
schemaVariantDefinitionId: string;
223+
SchemaVariantCreated: {
224+
schemaVariantId: string;
225225
changeSetId: ChangeSetId;
226226
};
227-
SchemaVariantDefinitionCloned: {
228-
schemaVariantDefinitionId: string;
227+
SchemaVariantCloned: {
228+
schemaVariantId: string;
229229
changeSetId: ChangeSetId;
230230
};
231-
SchemaVariantDefinitionFinished: {
231+
SchemaVariantFinished: {
232232
taskId: string;
233233
schemaVariantId: string;
234234
detachedAttributePrototypes: DetachedAttributePrototype[];
235235
};
236-
SchemaVariantDefinitionSaved: {
237-
schemaVariantDefinitionId: string;
236+
SchemaVariantSaved: {
237+
schemaVariantId: string;
238238
changeSetId: ChangeSetId;
239239
};
240240
FuncCreated: {

lib/dal-test/src/schemas/test_exclusive_schema_katy_perry.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ pub async fn migrate_test_exclusive_schema_katy_perry(ctx: &DalContext) -> Built
110110
.func(resource_payload_to_value_func)
111111
.func(yaml_code_gen_func)
112112
.func(string_code_gen_func)
113+
.func(kp_authoring_schema_func)
113114
.schema(kp_schema)
114115
.build()?;
115116

0 commit comments

Comments
 (0)