Skip to content

Commit

Permalink
Update types and imports for templates
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Aug 8, 2024
1 parent 405053b commit 71f744c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions client/src/api/configTemplates.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { type components } from "@/api/schema";

export type CreateInstancePayload = components["schemas"]["CreateInstancePayload"];

export type Instance =
| components["schemas"]["UserFileSourceModel"]
| components["schemas"]["UserConcreteObjectStoreModel"];
Expand All @@ -10,9 +12,9 @@ export type TemplateVariable =
| components["schemas"]["TemplateVariablePathComponent"]
| components["schemas"]["TemplateVariableBoolean"];
export type TemplateSecret = components["schemas"]["TemplateSecret"];
export type VariableValueType = (string | boolean | number) | undefined;
export type VariableData = { [key: string]: VariableValueType };
export type SecretData = { [key: string]: string };
export type VariableData = CreateInstancePayload["variables"];
export type VariableValueType = VariableData[keyof VariableData];
export type SecretData = CreateInstancePayload["secrets"];

export type PluginAspectStatus = components["schemas"]["PluginAspectStatus"];
export type PluginStatus = components["schemas"]["PluginStatus"];
Expand Down
5 changes: 3 additions & 2 deletions client/src/components/ConfigTemplates/formUtil.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
type CreateInstancePayload,
type Instance,
type PluginStatus,
type SecretData,
Expand Down Expand Up @@ -139,7 +140,7 @@ export function createTemplateForm(template: TemplateSummary, what: string): For
return form;
}

export function createFormDataToPayload(template: TemplateSummary, formData: any) {
export function createFormDataToPayload(template: TemplateSummary, formData: any): CreateInstancePayload {
const variables = template.variables ?? [];
const secrets = template.secrets ?? [];
const variableData: VariableData = {};
Expand All @@ -155,7 +156,7 @@ export function createFormDataToPayload(template: TemplateSummary, formData: any
}
const name: string = formData._meta_name;
const description: string = formData._meta_description;
const payload = {
const payload: CreateInstancePayload = {
name: name,
description: description,
secrets: secretData,
Expand Down
1 change: 0 additions & 1 deletion client/src/components/ObjectStore/Instances/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { type components } from "@/api/schema/schema";

export type UserConcreteObjectStore = components["schemas"]["UserConcreteObjectStoreModel"];
export type CreateInstancePayload = components["schemas"]["CreateInstancePayload"];

0 comments on commit 71f744c

Please sign in to comment.