Skip to content

Commit 675cde3

Browse files
committed
Fix CI issues
1 parent 8d9d3b0 commit 675cde3

File tree

9 files changed

+41
-38
lines changed

9 files changed

+41
-38
lines changed

components/modal/createModelData.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
type SchemaRow = { name: string, type: string, immutable: boolean };
1515
1616
const model = useModel();
17-
const defaultSchema = model.target?.schema.map((sch: SchemaRow) => sch);
17+
const defaultSchema = model.target?.schema?.map((sch) => ({
18+
name: sch.name,
19+
type: sch.type,
20+
immutable: sch.name === 'id'
21+
})) ?? [];
1822
const form = useForm({
1923
initialValues: {
2024
name: '',

components/model/grid.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import { Cog6ToothIcon } from '@heroicons/vue/24/outline';
3-
import { Model } from '~~/types/models';
3+
import { NormalizedModel } from '~~/types/models';
44
import useModel from '~~/stores/useModel';
55
import ModalCreateModelData from '~~/components/modal/createModelData.vue';
66
@@ -14,7 +14,7 @@
1414
};
1515
}
1616
17-
const handleSelectModel = (md: Model) => {
17+
const handleSelectModel = (md: NormalizedModel) => {
1818
model.setTarget(md);
1919
};
2020

composables/useModal.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ type UseModal = {
1616
open: () => void;
1717
};
1818

19-
const sleep = (ms: number) => new Promise((res) => setTimeout(() => res(ms), ms));
19+
const sleep = (ms: number) =>
20+
new Promise((resolve, _reject) => setTimeout(() => resolve(ms), ms));
2021

2122
/**
2223
* A composable for managing modals.

server/routes/models/[id]/model-data.post.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import ErrorResponse from '../../../utils/errorResponse';
2-
import {
3-
ModelServices,
4-
ModelDataServices,
5-
} from '~~/server/services';
6-
import generateResourceData from '~~/server/utils/generateResourceData';
2+
import { ModelServices, ModelDataServices } from '~~/server/services';
73
import extractAppKey from '~~/server/lib/extractAppKey';
84

95
type FakeSchema = {
@@ -14,7 +10,7 @@ type FakeSchema = {
1410
type BodyParams = {
1511
apiKey: string;
1612
increase: number;
17-
mockData: FakeSchema[]
13+
mockData: FakeSchema[];
1814
};
1915

2016
export default defineEventHandler(async (event) => {

server/services/modelDataServices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import SupabaseService from './supabaseService';
33

44
type Schema = {
55
name: string;
6-
type: string
6+
type: string;
77
};
88

99
export default class ModelDataService extends SupabaseService {

server/utils/generateModelData.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import { faker } from '@faker-js/faker';
22

3-
const DataOptions = {
4-
string: {
5-
animal: 'Animal',
6-
city: 'City',
7-
color: 'Color',
8-
country: 'Country',
9-
date: 'Date',
10-
email_address: 'Email Address',
11-
}
12-
};
3+
// const DataOptions = {
4+
// string: {
5+
// animal: 'Animal',
6+
// city: 'City',
7+
// color: 'Color',
8+
// country: 'Country',
9+
// date: 'Date',
10+
// email_address: 'Email Address',
11+
// }
12+
// };
1313

14-
function setValue(option: string) {
14+
export default function (option: string) {
1515
switch (option) {
1616
case 'faker_animal':
1717
return faker.animal.type();
@@ -44,10 +44,6 @@ function setValue(option: string) {
4444
case 'faker_vehicle':
4545
return faker.vehicle.type();
4646
default:
47-
throw Error(`The faker option ${option} does not exists.`);
47+
throw new Error(`The faker option ${option} does not exists.`);
4848
}
4949
}
50-
51-
export default function () {
52-
53-
}

stores/useApp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineStore } from 'pinia';
2-
import { AppWithAppKey } from '~/types/models';
32
import cloneDeep from 'lodash/cloneDeep';
3+
import { AppWithAppKey } from '~/types/models';
44

55
type CreateProps = {
66
description: string;

stores/useModel.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineStore } from 'pinia';
2-
import { Model } from '~/types/models';
32
import cloneDeep from 'lodash/cloneDeep';
3+
import { NormalizedModel } from '~/types/models';
44

55
type CreateProps = {
66
name: string;
@@ -14,24 +14,27 @@ type Options = {
1414
export default defineStore('models', () => {
1515
const toast = useToast();
1616
const apiKey = useAppRefKey();
17-
const target = ref<Model>();
17+
const target = ref<NormalizedModel>();
1818

19-
const { data, pending, refresh } = useLazyFetch<Model[]>('/models', {
20-
method: 'GET',
21-
query: { apiKey },
22-
server: false,
23-
});
19+
const { data, pending, refresh } = useLazyFetch<NormalizedModel[]>(
20+
'/models',
21+
{
22+
method: 'GET',
23+
query: { apiKey },
24+
server: false,
25+
}
26+
);
2427

2528
const list = computed(() => data.value || []);
2629
const isDisabled = computed(() => list.value.length === 10 || pending.value);
2730

28-
const setTarget = (md: Model) => {
31+
const setTarget = (md: NormalizedModel) => {
2932
target.value = cloneDeep(md);
3033
};
3134

3235
const unsetTarget = () => {
3336
target.value = undefined;
34-
}
37+
};
3538

3639
const create = async (body: CreateProps, options: Options): Promise<void> => {
3740
await $fetch('/models', {
@@ -66,6 +69,6 @@ export default defineStore('models', () => {
6669
/** METHODS */
6770
create,
6871
setTarget,
69-
unsetTarget
72+
unsetTarget,
7073
};
7174
});

types/models.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,6 @@ export type AppWithAppKey = App & {
4444
};
4545

4646
export type Model = Tables['models']['Row'];
47+
export type NormalizedModel = Omit<Model, 'schema'> & {
48+
schema: { name: string; type: string }[];
49+
};

0 commit comments

Comments
 (0)