{"version":3,"file":"users.js","names":[],"sources":["../../../../src/rest/commands/read/users.ts"],"sourcesContent":["import type { DirectusUser } from '../../../schema/user.js';\nimport type { ApplyQueryFields, Query } from '../../../types/index.js';\nimport type { RestCommand } from '../../types.js';\nimport { throwIfEmpty } from '../../utils/index.js';\n\nexport type ReadUserOutput<\n\tSchema,\n\tTQuery extends Query,\n\tItem extends object = DirectusUser,\n> = ApplyQueryFields;\n\n/**\n * List all users that exist in Directus.\n *\n * @param query The query parameters\n *\n * @returns An array of up to limit user objects. If no items are available, data will be an empty array.\n */\nexport const readUsers =\n\t>>(\n\t\tquery?: TQuery,\n\t): RestCommand[], Schema> =>\n\t() => ({\n\t\tpath: `/users`,\n\t\tparams: query ?? {},\n\t\tmethod: 'GET',\n\t});\n\n/**\n * List an existing user by primary key.\n *\n * @param key The primary key of the user\n * @param query The query parameters\n *\n * @returns Returns the requested user object.\n * @throws Will throw if key is empty\n */\nexport const readUser =\n\t>>(\n\t\tkey: DirectusUser['id'],\n\t\tquery?: TQuery,\n\t): RestCommand, Schema> =>\n\t() => {\n\t\tthrowIfEmpty(String(key), 'Key cannot be empty');\n\n\t\treturn {\n\t\t\tpath: `/users/${key}`,\n\t\t\tparams: query ?? {},\n\t\t\tmethod: 'GET',\n\t\t};\n\t};\n\n/**\n * Retrieve the currently authenticated user.\n *\n * @param query The query parameters\n *\n * @returns Returns the user object for the currently authenticated user.\n */\nexport const readMe =\n\t>>(\n\t\tquery?: TQuery,\n\t): RestCommand, Schema> =>\n\t() => ({\n\t\tpath: `/users/me`,\n\t\tparams: query ?? {},\n\t\tmethod: 'GET',\n\t});\n"],"mappings":"6DAkBA,MAAa,EAEX,QAEM,CACN,KAAM,SACN,OAAQ,GAAS,EAAE,CACnB,OAAQ,MACR,EAWW,GAEX,EACA,SAGA,EAAa,OAAO,EAAI,CAAE,sBAAsB,CAEzC,CACN,KAAM,UAAU,IAChB,OAAQ,GAAS,EAAE,CACnB,OAAQ,MACR,EAUU,EAEX,QAEM,CACN,KAAM,YACN,OAAQ,GAAS,EAAE,CACnB,OAAQ,MACR"}