{"version":3,"file":"panels.cjs","names":[],"sources":["../../../../src/rest/commands/read/panels.ts"],"sourcesContent":["import type { DirectusPanel } from '../../../schema/panel.js';\nimport type { ApplyQueryFields, Query } from '../../../types/index.js';\nimport type { RestCommand } from '../../types.js';\nimport { throwIfEmpty } from '../../utils/index.js';\n\nexport type ReadPanelOutput<\n\tSchema,\n\tTQuery extends Query<Schema, Item>,\n\tItem extends object = DirectusPanel<Schema>,\n> = ApplyQueryFields<Schema, Item, TQuery['fields']>;\n\n/**\n * List all Panels that exist in Directus.\n * @param query The query parameters\n * @returns An array of up to limit panel objects. If no items are available, data will be an empty array.\n */\nexport const readPanels =\n\t<Schema, const TQuery extends Query<Schema, DirectusPanel<Schema>>>(\n\t\tquery?: TQuery,\n\t): RestCommand<ReadPanelOutput<Schema, TQuery>[], Schema> =>\n\t() => ({\n\t\tpath: `/panels`,\n\t\tparams: query ?? {},\n\t\tmethod: 'GET',\n\t});\n\n/**\n * List an existing panel by primary key.\n * @param key The primary key of the dashboard\n * @param query The query parameters\n * @returns Returns the requested panel object.\n * @throws Will throw if key is empty\n */\nexport const readPanel =\n\t<Schema, const TQuery extends Query<Schema, DirectusPanel<Schema>>>(\n\t\tkey: DirectusPanel<Schema>['id'],\n\t\tquery?: TQuery,\n\t): RestCommand<ReadPanelOutput<Schema, TQuery>, Schema> =>\n\t() => {\n\t\tthrowIfEmpty(String(key), 'Key cannot be empty');\n\n\t\treturn {\n\t\t\tpath: `/panels/${key}`,\n\t\t\tparams: query ?? {},\n\t\t\tmethod: 'GET',\n\t\t};\n\t};\n"],"mappings":"kDAgBa,EAEX,QAEM,CACN,KAAM,UACN,OAAQ,GAAS,EAAE,CACnB,OAAQ,MACR,EASW,GAEX,EACA,SAGA,EAAA,aAAa,OAAO,EAAI,CAAE,sBAAsB,CAEzC,CACN,KAAM,WAAW,IACjB,OAAQ,GAAS,EAAE,CACnB,OAAQ,MACR"}