{"version":3,"file":"roleMappingRule.cjs","names":["rules: RoleMappingRuleResponse[]","makeRestApiRequest"],"sources":["../src/api/roleMappingRule.ts"],"sourcesContent":["import type { IRestApiContext } from '../types';\nimport { makeRestApiRequest } from '../utils';\n\nexport type RoleMappingRuleType = 'instance' | 'project';\n\nexport type RoleMappingRuleResponse = {\n\tid: string;\n\texpression: string;\n\trole: string;\n\ttype: RoleMappingRuleType;\n\torder: number;\n\tprojectIds: string[];\n\tdescription?: string;\n\tcreatedAt: string;\n\tupdatedAt: string;\n};\n\nexport type CreateRoleMappingRuleInput = {\n\texpression: string;\n\trole: string;\n\ttype: RoleMappingRuleType;\n\torder?: number;\n\tprojectIds?: string[];\n};\n\nexport type PatchRoleMappingRuleInput = {\n\texpression?: string;\n\trole?: string;\n\ttype?: RoleMappingRuleType;\n\torder?: number;\n\tprojectIds?: string[];\n};\n\ntype RoleMappingRuleListResponse =\n\t| { count: number; items: RoleMappingRuleResponse[] }\n\t| RoleMappingRuleResponse[];\n\n// The list endpoint paginates with a small default page size, so a single\n// request silently drops every rule past the first page. The settings UI needs\n// the complete set to render and save correctly, so walk every page here.\nexport const listRoleMappingRules = async (\n\tcontext: IRestApiContext,\n): Promise<RoleMappingRuleResponse[]> => {\n\tconst pageSize = 250;\n\tconst rules: RoleMappingRuleResponse[] = [];\n\n\tfor (let skip = 0; ; skip += pageSize) {\n\t\tconst response = await makeRestApiRequest<RoleMappingRuleListResponse>(\n\t\t\tcontext,\n\t\t\t'GET',\n\t\t\t'/role-mapping-rule',\n\t\t\t{ skip, take: pageSize },\n\t\t);\n\n\t\tif (Array.isArray(response)) return response;\n\n\t\trules.push(...response.items);\n\n\t\tif (rules.length >= response.count || response.items.length === 0) break;\n\t}\n\n\treturn rules;\n};\n\nexport const createRoleMappingRule = async (\n\tcontext: IRestApiContext,\n\tinput: CreateRoleMappingRuleInput,\n): Promise<RoleMappingRuleResponse> => {\n\treturn await makeRestApiRequest(context, 'POST', '/role-mapping-rule', input);\n};\n\nexport const updateRoleMappingRule = async (\n\tcontext: IRestApiContext,\n\tid: string,\n\tpatch: PatchRoleMappingRuleInput,\n): Promise<RoleMappingRuleResponse> => {\n\treturn await makeRestApiRequest(context, 'PATCH', `/role-mapping-rule/${id}`, patch);\n};\n\nexport const deleteRoleMappingRule = async (\n\tcontext: IRestApiContext,\n\tid: string,\n): Promise<void> => {\n\tawait makeRestApiRequest(context, 'DELETE', `/role-mapping-rule/${id}`);\n};\n\nexport const moveRoleMappingRule = async (\n\tcontext: IRestApiContext,\n\tid: string,\n\ttargetIndex: number,\n): Promise<RoleMappingRuleResponse> => {\n\treturn await makeRestApiRequest(context, 'POST', `/role-mapping-rule/${id}/move`, {\n\t\ttargetIndex,\n\t});\n};\n"],"mappings":";;;AAwCA,MAAa,uBAAuB,OACnC,YACwC;CACxC,MAAM,WAAW;CACjB,MAAMA,QAAmC,EAAE;AAE3C,MAAK,IAAI,OAAO,IAAK,QAAQ,UAAU;EACtC,MAAM,WAAW,MAAMC,iCACtB,SACA,OACA,sBACA;GAAE;GAAM,MAAM;GAAU,CACxB;AAED,MAAI,MAAM,QAAQ,SAAS,CAAE,QAAO;AAEpC,QAAM,KAAK,GAAG,SAAS,MAAM;AAE7B,MAAI,MAAM,UAAU,SAAS,SAAS,SAAS,MAAM,WAAW,EAAG;;AAGpE,QAAO;;AAGR,MAAa,wBAAwB,OACpC,SACA,UACsC;AACtC,QAAO,MAAMA,iCAAmB,SAAS,QAAQ,sBAAsB,MAAM;;AAG9E,MAAa,wBAAwB,OACpC,SACA,IACA,UACsC;AACtC,QAAO,MAAMA,iCAAmB,SAAS,SAAS,sBAAsB,MAAM,MAAM;;AAGrF,MAAa,wBAAwB,OACpC,SACA,OACmB;AACnB,OAAMA,iCAAmB,SAAS,UAAU,sBAAsB,KAAK;;AAGxE,MAAa,sBAAsB,OAClC,SACA,IACA,gBACsC;AACtC,QAAO,MAAMA,iCAAmB,SAAS,QAAQ,sBAAsB,GAAG,QAAQ,EACjF,aACA,CAAC"}