{"version":3,"file":"ArchivableCrudApi.mjs","names":[],"sources":["../../src/core/ArchivableCrudApi.ts"],"sourcesContent":["import type { ApiClient } from './ApiClient'\nimport { BaseCrudApi } from './BaseCrudApi'\nimport type { ListQuery } from './types'\n\n/**\n * CRUD base for resources that support soft-delete via an `archivedAt` timestamp\n * (PUT `${basePath}/${id}` with `{ archivedAt }`). Adds `archive`/`unarchive` on\n * top of {@link BaseCrudApi}.\n *\n * Only extend this for resources whose archive write mechanism is `archivedAt`.\n * Resources that archive through a different field (e.g. cards use `isArchived`)\n * or a dedicated endpoint (e.g. ticket-topics POST `/archive`) must NOT use this\n * base and should implement `archive`/`unarchive` themselves.\n */\nexport class ArchivableCrudApi<\n  TResponse,\n  TCreate,\n  TUpdate extends { archivedAt?: string | null } = TCreate & { archivedAt?: string | null },\n  TQuery extends ListQuery<TResponse> = ListQuery<TResponse>,\n> extends BaseCrudApi<TResponse, TCreate, TUpdate, TQuery> {\n  constructor(client: ApiClient, basePath: string) {\n    super(client, basePath)\n    this.archive = this.archive.bind(this)\n    this.unarchive = this.unarchive.bind(this)\n  }\n\n  /**\n   * Archives a resource (soft-delete) by setting `archivedAt` to the current time.\n   * @permissions $resourceName.update\n   */\n  archive(id: string, headers?: Record<string, string>): Promise<TResponse> {\n    return this.updateById(id, { archivedAt: new Date().toISOString() } as TUpdate, headers)\n  }\n\n  /**\n   * Restores a previously archived resource by clearing `archivedAt`.\n   * @permissions $resourceName.update\n   */\n  unarchive(id: string, headers?: Record<string, string>): Promise<TResponse> {\n    return this.updateById(id, { archivedAt: null } as TUpdate, headers)\n  }\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,IAAa,oBAAb,cAKU,YAAiD;CACzD,YAAY,QAAmB,UAAkB;AAC/C,QAAM,QAAQ,SAAS;AACvB,OAAK,UAAU,KAAK,QAAQ,KAAK,KAAK;AACtC,OAAK,YAAY,KAAK,UAAU,KAAK,KAAK;;;;;;CAO5C,QAAQ,IAAY,SAAsD;AACxE,SAAO,KAAK,WAAW,IAAI,EAAE,6BAAY,IAAI,MAAM,EAAC,aAAa,EAAE,EAAa,QAAQ;;;;;;CAO1F,UAAU,IAAY,SAAsD;AAC1E,SAAO,KAAK,WAAW,IAAI,EAAE,YAAY,MAAM,EAAa,QAAQ"}