diff --git a/.github/workflows/test.build.lib.yml b/.github/workflows/test.build.lib.yml index 2c7c26b6..00e82f3b 100644 --- a/.github/workflows/test.build.lib.yml +++ b/.github/workflows/test.build.lib.yml @@ -37,7 +37,7 @@ jobs: build-examples: if: needs.files-changed.outputs.build == 'true' name: Test Example Apps - needs: build + needs: [build, files-changed] runs-on: ubuntu-latest strategy: matrix: diff --git a/app/src/api/directus.ts b/app/src/api/directus.ts index 032be4b4..c49a10f5 100644 --- a/app/src/api/directus.ts +++ b/app/src/api/directus.ts @@ -6,6 +6,7 @@ import { createDirectus, rest, authentication } from '@directus/sdk' import type { AuthenticationData, AuthenticationStorage } from '@directus/sdk' import type { Point } from 'geojson' +import type { Item } from 'utopia-ui' export interface Place { id: string @@ -57,6 +58,10 @@ export interface MyCollections { tags: Tag[] projects: Project[] directus_users: CustomUserFields[] + items: Item[] + team: any[] + features: any[] + attestations: any[] } export const authLocalStorage = (mainKey = 'directus_storage') => diff --git a/app/src/api/itemsApi.ts b/app/src/api/itemsApi.ts index c67ccc5f..854734ab 100644 --- a/app/src/api/itemsApi.ts +++ b/app/src/api/itemsApi.ts @@ -12,14 +12,14 @@ import type { MyCollections } from './directus' import type { ItemsApi } from 'utopia-ui' export class itemsApi implements ItemsApi { - collectionName: string + collectionName: keyof MyCollections filter: any layerId: string | undefined mapId: string | undefined customParameter: any constructor( - collectionName: string, + collectionName: keyof MyCollections, layerId?: string | undefined, mapId?: string | undefined, filter?: any, @@ -81,7 +81,7 @@ export class itemsApi implements ItemsApi { async createItem(item: T & { id?: string }): Promise { try { const result = await directusClient.request( - createItem(this.collectionName as keyof MyCollections, { + createItem(this.collectionName, { ...item, ...(this.customParameter && this.customParameter), ...(this.layerId && { layer: this.layerId }), @@ -99,9 +99,7 @@ export class itemsApi implements ItemsApi { async updateItem(item: T & { id?: string }): Promise { try { - const result = await directusClient.request( - updateItem(this.collectionName as keyof MyCollections, item.id!, item), - ) + const result = await directusClient.request(updateItem(this.collectionName, item.id!, item)) return result as T } catch (error: any) { console.log(error) @@ -112,9 +110,7 @@ export class itemsApi implements ItemsApi { async deleteItem(id: string): Promise { try { - const result = await directusClient.request( - deleteItem(this.collectionName as keyof MyCollections, id), - ) + const result = await directusClient.request(deleteItem(this.collectionName, id)) return result as unknown as boolean } catch (error: any) { console.log(error)