mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
37 lines
942 B
TypeScript
37 lines
942 B
TypeScript
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
/* eslint-disable no-console */
|
|
import { readItems } from '@directus/sdk'
|
|
|
|
import { directusClient } from './directus'
|
|
|
|
export class layersApi {
|
|
mapId: string
|
|
|
|
constructor(mapId: string) {
|
|
this.mapId = mapId
|
|
}
|
|
|
|
async getItems() {
|
|
try {
|
|
const layers = await directusClient.request(
|
|
readItems('layers' as any, {
|
|
fields: [
|
|
'*',
|
|
{ itemType: ['*.*', { profileTemplate: ['*', 'item.*.*.*.*'] }] },
|
|
{ markerIcon: ['*'] } as any,
|
|
],
|
|
filter: { maps: { maps_id: { id: { _eq: this.mapId } } } },
|
|
limit: 500,
|
|
sort: ['sort'],
|
|
}),
|
|
)
|
|
return layers
|
|
} catch (error: any) {
|
|
console.log(error)
|
|
if (error.errors[0]?.message) throw error.errors[0].message
|
|
else throw error
|
|
}
|
|
}
|
|
}
|