import { HttpData, HttpMethod, HttpParams, HttpResult, RequestOptions } from "./Http.types.mjs"; import { CancellablePromise } from "./cancellable.mjs"; import { Http } from "./Http.mjs"; import { ResourceService } from "./Resource.types.mjs"; //#region ../http/src/Resource.d.ts /** * RESTful resource helper built on top of Http. * * Extend this class and set `route` to get fully-typed CRUD methods: * * @example * class UsersResource extends Resource { * route = '/users'; * } * * const users = new UsersResource(); * const { data, error } = await users.list({ page: 1 }); */ declare class Resource implements ResourceService { /** * Base route for this resource, e.g. "/users". * All methods build URLs relative to this route. */ route: string; /** * Default query params merged into every `list()` call. * Override per-instance or in a subclass. */ defaultListParams: HttpParams; /** * Lazy reference to the Http instance. * Resolved on first use via getCurrentHttp() so that setCurrentHttp() * does not have to be called before the class is instantiated. */ private _http; protected get http(): Http; /** * Override the Http instance used by this specific resource. * Useful for resources that talk to a different API base URL. */ useHttp(instance: Http): this; list(params?: HttpParams, options?: RequestOptions): CancellablePromise>; get(id: number | string, options?: RequestOptions): CancellablePromise>; create(data: HttpData, options?: RequestOptions): CancellablePromise>; update(id: number | string, data: HttpData, options?: RequestOptions): CancellablePromise>; patch(id: number | string, options?: RequestOptions): CancellablePromise>; delete(id: number | string, options?: RequestOptions): CancellablePromise>; bulkDelete(data: HttpData, options?: RequestOptions): CancellablePromise>; /** * Toggle the published state of a record. * * Sends a PATCH to `//` with `{ [publishKey]: published }`. * If `published` is already an object, it is sent as-is. * * Uses `this.http.patch` directly — no double-route bug. */ publish(id: number | string, published: boolean | HttpData, publishKey?: string, options?: RequestOptions): CancellablePromise>; /** * Send a non-CRUD action on a specific record. * * @example * // POST /users/42/activate * await users.action(42, 'activate'); * * // POST /orders/5/refund { amount: 100 } * await orders.action(5, 'refund', { amount: 100 }); * * // PATCH /posts/1/publish * await posts.action(1, 'publish', undefined, {}, 'PATCH'); */ action(id: number | string, actionName: string, data?: HttpData, options?: RequestOptions, method?: HttpMethod): CancellablePromise>; /** * Build a path relative to the base route. * * @example * this.path(42) // "/users/42" * this.path('profile') // "/users/profile" * this.path() // "/users" */ path(suffix?: string | number): string; /** * Build a path for a named action on a specific record. * * @example * this.actionPath(42, 'activate') // "/users/42/activate" */ actionPath(id: string | number, actionName: string): string; } //#endregion export { Resource }; //# sourceMappingURL=Resource.d.mts.map